I’m using the code below to get the global threadid for a 3D Block and 3D Grid , but the first 256 threads always get the wrong Id, what I’m I missing?
blockId = (blockIdx%x-1) + (blockIdx%y-1)*gridDim%x &
+ gridDim%x*gridDim%y*(blockIdx%z-1)
threadId = blockId*(blockDim%x*blockDim%y*blockDim%z) &
+ (threadIdx%z*(blockDim%x*blockDim%y)) &
+ (threadIdx%y*blockDim%x) + threadIdx%x
getGlobalId = threadId