GPU Programming

A 32 × 32 float tile in shared memory causes bank conflicts when a warp's 32 threads read down a column. What is the common fix?

  1. AKeep 32 × 32 and read in random order
  2. BStop using shared memory and read everything from global memory
  3. CAllocate the tile as 32 × 33, adding one extra column so each row's bank alignment shifts
Show answer and explanation

Answer: C. Allocate the tile as 32 × 33, adding one extra column so each row's bank alignment shifts

With 32 floats (128 bytes) per row, every row starts in the same bank, so all elements of a column fall in one bank and reading down the column funnels 32 threads into that bank. Making each row 33 floats long shifts the bank by one with every row, so the 32 elements of a column spread across all banks and are read in one access. It is a simple trick costing only one unused column of memory.

  • A. Random order does not reduce conflicts.
  • B. Global memory is much slower, so this backfires.
  • C. Correct. Padding removes the conflicts.
Practice this topic Back to topic

More GPU Programming questions

  1. When multiplying large matrices on a GPU, why are the matrices split into small tiles loaded into shared memory?
  2. What can happen if a GPU kernel uses too many registers per thread?
  3. Which describes occupancy on a GPU?
  4. What is the main way a GPU hides long memory latency (hundreds of cycles)?
  5. Which statement about GPU occupancy is correct?