Hi,
I am beginner in cuda programming…
i need few clarification for understanding Number of blocks and threads in cuda…
As of now my understanding is like as follows
[codebox]//---------------------kernal----------------------------
global void abc(int *a, int *b, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
b[i]=a[i];
}
//-------------------------------------------------------
numberofblock=1;
numberofthreadsperblock=16;
abc <<< numberofblock, numberofthreadsperblock <<< (a,B)
[/codebox]
- While using like above, 16 threads are used in block 1 it’s right or wrong?
Another example…
[codebox]//---------------------kernal----------------------------
global void abc(int *a, int *b, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index=i+j*n;
b[index]=a[index];
}
//-------------------------------------------------------
numberofblock=2;
numberofthreadsperblock=16;
dim3 dimblock(2,2);
dim3 nthread(16,16);
abc <<< dimblock, nthread<<< (a,b,n)
[/codebox]
-
How can i consider blocks here?
whether i need to consider like block (0,0) (0,1) (1,0) (1,1) …?
if i consider like above…
in block (0,0) 16 threads are executed… its right or wrong?
-
If my above understanding is wrong how can i relate dimblock(2,2) and nthread(16,16)…?
Thanks in advance,
s.sudhagar. :mellow: