Home Knowledge Base GPU Memory Coalescing

GPU Memory Coalescing is the hardware optimization where adjacent threads in a warp (32 threads) that access adjacent memory addresses have their individual memory requests combined into a single wide memory transaction (32, 64, or 128 bytes) — reducing the number of memory transactions by up to 32x and achieving peak memory bandwidth, while uncoalesced access patterns (strided, random) generate separate transactions per thread, reducing effective bandwidth to 3-10% of peak.

How Coalescing Works

When a warp executes a load instruction, the memory controller examines all 32 threads' addresses:

Access Patterns and Their Coalescing Behavior

Array of Structures vs. Structure of Arrays

The most impactful data layout decision for GPU performance:

// AoS (Array of Structures) — BAD for GPU
struct Particle { float x, y, z, mass; };
Particle particles[N];
// Thread i reads particles[i].x → stride-4 access (every 16 bytes)

// SoA (Structure of Arrays) — GOOD for GPU  
float x[N], y[N], z[N], mass[N];
// Thread i reads x[i] → stride-1 access (perfectly coalesced)

Converting AoS to SoA is often the single highest-impact GPU optimization — can improve memory-bound kernel performance by 4-8x.

L1/L2 Cache Interaction

Modern GPUs (Ampere, Hopper) have configurable L1 caches (up to 228 KB per SM on H100). Uncoalesced accesses that hit L1 cache are less penalized than L1 misses. For random access patterns, increasing L1 cache size (at the expense of shared memory) can partially mitigate uncoalesced access.

Alignment Requirements

Aligned loads (address divisible by transaction size) avoid split transactions. Built-in vector types (float4, int4) guarantee 16-byte aligned loads. __align__ directive in CUDA forces alignment of arrays and structures. Misaligned base addresses can cause every warp to generate two transactions instead of one.

Memory Coalescing is the single most important GPU performance rule — determining whether a memory-bound kernel achieves 80-100% of peak bandwidth or limps along at 3-10%, making data layout design the first and most impactful optimization decision in GPU programming.

gpu memory coalescingmemory access pattern gpuglobal memory transactionaligned memory accessstrided access gpu

Explore 500+ Semiconductor & AI Topics

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