0PricingLogin
CUDA Academy · Lesson

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

  1. The Thread Hierarchy
  2. threadIdx, blockIdx, blockDim
  3. Why Blocks Exist
  4. Choosing Threads per Block
← Back to CUDA Academy