Say i have a kernel with a 2 dimensional block grid:
THREAD_w = 8
THREAD_h = 16
dim3 block(THREAD_w, THREAD_h, 1);
This gives me 2x16 = 128 threads per block.
I’d like to figure out from threadIdx which warp or half-warp i’m in,
in order to optimize my code by selecting random branching to alternate but follow the same paths inside each warp.
The manual is unclear as to how this is indexed for 2d grids like my example above.
LSChien, you shouldn’t hard code the warp size when determining a value, as that could (and probably will) introduce errors into your code on future devices. Just use the built-in variable “warpSize”: