GPU Programming

Which correctly orders the CUDA thread hierarchy from largest to smallest?

  1. AGrid → block → thread
  2. BThread → block → grid
  3. CBlock → thread → grid
Show answer and explanation

Answer: A. Grid → block → thread

One kernel launch forms a grid, which is divided into many blocks, each containing many threads. A block's threads run on the same SM (a cluster of execution units) and can cooperate through shared memory and synchronize. Different blocks run independently, so the number running at once adapts to the GPU's size, and the same program runs on small and large GPUs.

GPU thread hierarchy and assignment to SMs Grid B0 B1 B2 B3 B4 B5 Block Warp 0 Warp 1 Warp 2 Warp (32 threads) Same instruction in lockstep Threads grouped by 32 Each block goes to an SM SM0 B0 B3 Shared memory SM1 B1 B4 Shared memory SM2 B2 B5 Shared memory Global memory (read/write from all blocks) A block runs on one SM and cooperates via shared memory
GPU thread hierarchy and assignment to SMs · View in diagrams
  • A. Correct. The whole of one launch is the grid.
  • B. That is smallest to largest.
  • C. The order is wrong.