Codes as follows, THETA is a const, I can define outImage as 1 in GPU function. The expected output should be 1 but they are NaN.
I think that there is an error in 3D thread ID computation. But I don’t know where? So could you tell me?
dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
dim3 dimGrid(iRotated / dimBlock.x , iRotated / dimBlock.y, THETA/dimBlock.z);
global void roatationD(float* outImage, int widthR, int heightR)
{
int ix = blockIdx.x * BLOCK_SIZE + threadIdx.x;
int iy = blockIdx.y * BLOCK_SIZE + threadIdx.y;
int iz = blockIdx.z * BLOCK_SIZE + threadIdx.z;
int idx = ix + iy * widthR + iz * widthR * heightR; // index
outImage[idx] = 1.0f;
The z component of dimGrid must be 1 on current hardware. Blocks can be 3D, but grids must be 2D. Your kernel probably aborts with an error when you try to run it in this configuration.
const dim3 dimBlock(192);
int dim = ceil(sqrt((float)(DATA_W*DATA_D*DATA_H)/192.0f));
const dim3 dimGrid(dim,dim);
convolve<<<dimGrid, dimBlock,0>>>(d_Result);
const int idx = (blockIdx.y*blockDim.x*gridDim.x)+blockIdx.x*blockDim.x+threadIdx.x;
const int z = idx/(DATA_W*DATA_H);
const int y = (idx - z * DATA_W * DATA_H) / DATA_W;
const int x = (idx - z * DATA_W * DATA_H - y * DATA_W);