GPU Programming

What can happen if a GPU kernel uses too many registers per thread?

  1. ARegisters grow automatically and performance always improves
  2. BResults are always wrong
  3. CEach SM has a fixed register file, so fewer threads fit at once and memory latency becomes harder to hide
Show answer and explanation

Answer: C. Each SM has a fixed register file, so fewer threads fit at once and memory latency becomes harder to hide

GPUs keep the registers of every active thread on chip so that switching warps is instantaneous. So if each thread uses many registers, fewer threads fit on an SM at once. Registers that do not fit are spilled to memory, which can also slow things down. Compiler options can cap register usage to balance it against thread count.

  • A. The total register count is fixed in hardware.
  • B. Results remain correct; speed is affected.
  • C. Correct. Registers are one of the resources limiting thread count.
Practice this topic Back to topic

More GPU Programming questions

  1. Which describes occupancy on a GPU?
  2. What is the main way a GPU hides long memory latency (hundreds of cycles)?
  3. Which statement about GPU occupancy is correct?
  4. In CUDA, what is the relationship between blocks and SMs (streaming multiprocessors)?
  5. In CUDA, you want to wait mid-kernel for every other block to finish before moving to the next phase. What is the usual approach?