I have the feeling, that the builtin variable blockIdx.z
returns wrong values. It shows numbers != 0
rathet than 0. When there is a grid
with Dimension 1,1,1 there can’t be a blockIdx.z
not equal to 0.
In device Emulation it works.
global static void MyKernel(int *values){
const unsigned int tid = (threadIdx.x ) ;
if(tid==0){
values[tid+0] = blockIdx.x;
values[tid+1] = blockIdx.y;
values[tid+2] = blockIdx.z;
}
}
int dvalues;
int returnvalues[3]={97,98,99};
cudaMalloc((void*)&dvalues, 3* sizeof(int) );
MyKernel<<<1, 16 >>>(dvalues);
CUDA_SAFE_CALL(cudaMemcpy(returnvalues, dvalues, 3*sizeof(int), CudaMemcpyDeviceToHost));
Thank you. That’s right.
A grid is a grid and not a ‘3D Grid’.
there is an error message,
when starting a Kernel with gridDim.z
not equal to 1.
In chapter 2.2.2 of thr programming guide
it is clearly stated, that a grid is 2D.
After reding: in my eyes the declaration
of gridDim as dim3 just gives room for a future extension
of grids to 3D grids.