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?
- AKeep 32 × 32 and read in random order
- BStop using shared memory and read everything from global memory
- 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.