I want to know the printf result of kernel, so i define the g_idata[8]={0,1,2,3,4,5,6,7}, the code as shown:
__global__ void kernel_reduceInterleaved(int *g_idata, int *g_odata, int size){
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int tid = threadIdx.x;
int *idata = g_idata + blockDim.x * blockIdx.x ; //only lock memory
printf("%d, %d, %d, %d, %d, %d, %d, %d\n", tid, idx, blockIdx.x, blockDim.x, idata[idx], idata[tid], idata[5], g_idata[5]);
}
the result is:
(1) I can’t understand why the value of idata[5] is 0 in the block 1, in my idea, i thin the index 5 now we can regard it as idx(5), so the result should be 5. I am confused about this point.
(2) The value is 0 in the block1 for idata[idx], why, I think it should keep consistence with the g_idata[idx], I am also confused about this point.