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.

  • A. Correct. The whole of one launch is the grid.
  • B. That is smallest to largest.
  • C. The order is wrong.
Practice this topic Back to topic

More GPU Programming questions

  1. A CUDA kernel computes each thread's index i with the expression above. What is i for the thread with blockIdx.x = 2, blockDim.x = 256 and threadIdx.x = 5?
  2. To process a 1000-element array with one element per thread and 256 threads per block, how many blocks should be launched?
  3. Why does the CUDA kernel above include "if (i < n)"?
  4. On NVIDIA GPUs, what is the unit of 32 threads bundled together to execute the same instruction in lockstep called?
  5. How does the GPU SIMT (single instruction, multiple threads) model differ from CPU SIMD instructions?