The Thread Hierarchy
Threads group into blocks, blocks into a grid.
The Thread Hierarchy is a free CUDA Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CUDA Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Many Threads, One Job
A CUDA kernel runs in parallel across many threads, and each thread does the same work on its own slice of the data. 🧵
Threads Need Structure
Launching millions of loose threads would be chaos. CUDA organizes them into a clean hierarchy so the hardware can schedule them well.
Threads Form Blocks
Threads are grouped into a block. Every thread in a block runs the same kernel and can cooperate closely with its neighbors.
Blocks Form the Grid
All the blocks for one launch together make up the grid. So the chain is simple: threads live in blocks, and blocks live in the grid.
Why Two Levels?
The two-level design lets one kernel scale from a tiny GPU to a huge one. You describe the work once and the grid stretches to fit.
Picking the Shape at Launch
You choose how many blocks and how many threads per block right at the launch, using the triple-angle-bracket syntax.
myKernel<<<numBlocks, threadsPerBlock>>>(data);A Concrete Example
Say you launch 4 blocks of 256 threads. That gives you 4 times 256, or 1024 threads all running at once.
Blocks Are Independent
Different blocks cannot assume any order or talk to each other directly. This independence is exactly what lets the GPU run them in any sequence.
Threads Within a Block Cooperate
Inside one block, threads can share fast on-chip memory and synchronize with each other. That teamwork is a block's superpower.
Grids and Blocks Can Be 3D
Both the grid and each block can be 1D, 2D, or 3D. The dim3 type lets you map naturally onto images or volumes.
dim3 block(16, 16);
dim3 grid(32, 32);One Thread, One Element
The common goal is to give each thread exactly one data element to handle. The hierarchy is just how you reach that mapping.
Quick Check
Let us check how the pieces nest together.
Recap: The Hierarchy
You learned the CUDA ladder: threads make a block, blocks make the grid. Independent blocks scale, while threads inside a block cooperate. 🎯
Frequently asked questions
Is the “The Thread Hierarchy” lesson free?
Yes — the full text of “The Thread Hierarchy” is free to read here on the web, and the CUDA Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CUDA Academy course, upgrade to CoddyKit PRO.
What will I learn in “The Thread Hierarchy”?
Threads group into blocks, blocks into a grid. You practise CUDA Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start CUDA Academy?
No prior experience is required. CUDA Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The Thread Hierarchy” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this CUDA Academy lesson?
Yes. Every CUDA Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Thread Hierarchy
- threadIdx, blockIdx, blockDim
- Why Blocks Exist
- Choosing Threads per Block