GPU Programming

For what kind of access does CUDA constant memory perform especially well?

  1. AWhen all threads of a warp read the same address (one read is broadcast to all)
  2. BWhen warp threads write to different addresses
  3. 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.
Practice this topic Back to topic

More GPU Programming questions

  1. In general, how do GPU caches compare with CPU caches?
  2. Which is an example of a parallel-programming framework for GPUs that also works on GPUs other than NVIDIA's?
  3. On a GPU you want to compact only the elements meeting a condition into another array (each thread outputs 0 or 1 items). Which parallel computation is commonly used to determine each thread's write position?
  4. Which assumption must be respected when writing GPU kernels?
  5. When transposing a large matrix on a GPU (b[j][i] = a[i][j]), what is the main purpose of going through shared memory?