I'm new to cuda; I have a 2D image (width, height) with 3 channels (colors). What I want is to lunch a kernel that have 3D block and 2D grid like this
kernel_2D_3D<<<dim3(1,m,n), dim3(3,TILEy,TILEz)>>>(float *in, float *out)
I use x for colors, y for width and z for height. My question is: How can I calculate the row and column of the image:
- unsigned int Row = ?
- unsigned int Col = ?
and the I use this function to calculate global unique index
__device__ int getGlobalIdx_2D_3D()
{
int blockId = blockIdx.x+ blockIdx.y * gridDim.x;
int Idx = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.z * (blockDim.x * blockDim.y))
+ (threadIdx.y * blockDim.x)
+ threadIdx.x;
return Idx;
}