CPU, GPU AND RAM

Shared-memory bank conflicts: why padding can change access

In this article
THE QUICK TAKE

Shared-memory conflicts depend on simultaneous addresses and bank mapping; padding helps only when it changes the problematic mapping for that access.

Shared memory is addressed by cooperating threads, but its implementation contains banks. An access pattern can map different addresses onto the same bank and require additional servicing. Understanding the mapping makes padding and transposition deliberate indexing decisions instead of unexplained performance folklore.

A bank is an access resource

An address in shared memory is served through a bank arrangement defined by the architecture. When participating lanes request different locations that compete for the same servicing resource, the instruction can require extra work. Accessing the same value can have different broadcast behavior, so it should not automatically be classified like conflicting distinct addresses. The address pattern, value width and actual hardware generation determine the interpretation.

Primary reference: CUDA Programming Guide: Writing SIMT Kernels.

Read a tile in the other direction

A transpose kernel can write a shared tile in a convenient order and later read it in the perpendicular direction. The second direction may turn a harmless row stride into repeated bank competition. Changing the physical row pitch alters that mapping while preserving the logical tile. This is why a padding element can matter: it shifts subsequent row starts rather than providing additional mathematical input to the transpose.

Primary reference: CUDA C++ Best Practices Guide.

Padding also consumes a resource

Extra shared storage can change block residency, especially when a kernel already approaches an allocation boundary. Padding may therefore reduce bank servicing work while leaving fewer resident blocks. These are connected effects rather than contradictory measurements. Keep the padded pitch, logical dimensions and shared-memory allocation together in the launch record. A change that helps one tile size need not retain the same balance for a larger tile.

Primary reference: Nsight Compute Profiling Guide.

Inspect the instruction under study

A kernel contains many shared-memory instructions, and only some may exhibit the suspected pattern. Associate the profiler observation with the relevant source or instruction region. A change in total duration can also come from global-memory access or synchronization. Use the bank-related evidence to test a specific indexing explanation, preserving data type and participating lanes. Avoid interpreting an entire kernel through one aggregate conflict number without identifying its expensive accesses.

Treat the layout as part of the algorithm

For a proposed transpose experiment, compare the original and padded layouts on the same input, including partial boundary tiles. Check output coordinates as well as values. Record both the changed bank pattern and any changed residency. The useful result explains the cost of cooperating through this tile. It does not imply that every shared-memory array should receive the same padding or that bank conflicts are the dominant issue in every kernel.

Related reading: A GPU inference benchmark you can trust; Reproducible inference stacks: preserving a GPU pilot’s result.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles