GPU Programming
For what kind of access does CUDA constant memory perform especially well?
- AWhen all threads of a warp read the same address (one read is broadcast to all)
- BWhen warp threads write to different addresses
- CWhen warp threads read different, random addresses
Show answer and explanation
Answer: A. When all threads of a warp read the same address (one read is broadcast to all)
Constant memory is a small region that does not change during a kernel and has its own cache. When every thread in a warp reads the same address, one read is broadcast to all of them, which is very fast. It suits values every thread uses, such as image filter coefficients or simulation parameters. Scattered addresses split the reads and make it slower instead.
- A. Correct. It suits values everyone uses, such as filter coefficients.
- B. Kernels cannot write constant memory.
- C. Different addresses are serialized and slow.