Home Knowledge Base GPU Shared Memory Bank Conflicts

GPU Shared Memory Bank Conflicts are the performance penalties that occur when multiple threads in a warp simultaneously access different addresses that map to the same shared memory bank — forcing the accesses to be serialized rather than served simultaneously, reducing effective bandwidth by a factor equal to the degree of the conflict, and representing one of the most common and impactful GPU optimization targets.

Shared Memory Bank Architecture

Conflict Examples

// No conflict — stride 1 (consecutive access)
shared[threadIdx.x]           // thread 0→bank 0, thread 1→bank 1, ...

// 2-way conflict — stride 2
shared[threadIdx.x * 2]       // thread 0→bank 0, thread 16→bank 0 (conflict!)

// 32-way conflict — stride 32 (worst case)
shared[threadIdx.x * 32]      // ALL threads hit bank 0 → fully serialized

// No conflict — stride that is odd
shared[threadIdx.x * 3]       // Odd stride → all banks hit uniquely

Bank Conflict Rule

Common Conflict Scenarios and Fixes

ScenarioProblemFix
Matrix column accessStride = matrix width (power of 2)Pad shared array: shared[N][N+1]
Struct arrayStruct size = power of 2 bytesPad struct or use SoA layout
Reduction treeHalf-warp accesses same bankUse sequential addressing, not interleaved
HistogramMultiple threads update same binUse privatization, then merge

Padding Technique (Most Common Fix)

// Problem: 32x32 matrix, column access = stride 32 = 32-way conflict
__shared__ float tile[32][32];       // column access: 32-way conflict

// Fix: Pad each row by 1 element
__shared__ float tile[32][32 + 1];   // column access: stride 33 (odd) → no conflict!

Diagnosing Bank Conflicts

GPU shared memory bank conflicts are one of the most frequent micro-architectural performance pitfalls — a single line of code using a power-of-2 stride can reduce shared memory throughput by 32x, making bank conflict analysis and padding/layout optimization essential skills for GPU performance engineers.

gpu shared memory bank conflictshared memory optimizationbank conflict resolutionshared memory access pattern

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.