GPU Programming
In CUDA, what is the relationship between blocks and SMs (streaming multiprocessors)?
- AA block's threads are spread across all SMs
- BThe number of blocks must always equal the number of SMs
- CEach block is assigned to one SM and runs there to completion, and one SM may hold several blocks at once
Show answer and explanation
Answer: C. Each block is assigned to one SM and runs there to completion, and one SM may hold several blocks at once
A GPU has many SMs and assigns a kernel's blocks to free SMs in turn. A block runs on one SM, so its threads can use that SM's shared memory and synchronize. Launching many more blocks than SMs keeps every SM busy regardless of the GPU's size, with the next block assigned to whichever SM finishes.
- A. A block runs within a single SM.
- B. There can be far more blocks than SMs.
- C. Correct. That is why shared memory works within a block.