threadIdx index origin

I’m sure this is in some CUDA document somewhere, but I haven’t bean able to find it.

Is the first value of threadIdx.x equal to “0” or to “1”. I assume that it is “0”, but all the documentation I’ve read give examples for, say, a 2 x 2 block as having indices of (0,0), (0,1), (1,0), (1,1).

I would guess that the zero reference is handled transparently.

If so, it would be nice to see that documented explicitly.

Thanks for the feedback on a simple question.

Yes, threadIdx.x is 0 indexed. So a 256 thread block would have threads numbered 0 to 255 inclusive.

Your 2x2 block example is correct, and also 0 indexed (in 2D)… but it sounds like you don’t think it is.

By the way, what a wonderfully melodic name you have!

It is 0, following standard C conventions, which is also precisely what your example shows as well. The only thing which differs from standard C is that multi-dimensional blocks and grids use column-major ordering.