threadIdx, blockIdx, blockDim
The built-in variables that locate a thread.
Where Am I?
Every thread runs the same code, so each one needs to ask: which piece of data is mine? CUDA answers with built-in variables. 📍
Meet threadIdx
Inside a kernel, threadIdx tells a thread its position within its own block. The first thread in a block has threadIdx.x equal to 0.
int t = threadIdx.x;All lessons in this course
- The Thread Hierarchy
- threadIdx, blockIdx, blockDim
- Why Blocks Exist
- Choosing Threads per Block