Home Knowledge Base Parallel Reduction

Parallel Reduction is the fundamental parallel algorithm pattern that combines N input values into a single result (sum, max, min, dot product) using a logarithmic-depth tree of binary operations — requiring only O(log N) steps on N processors compared to O(N) for sequential reduction, making it the building block for virtually every aggregate computation in parallel and GPU computing.

The Reduction Tree

Given N = 1024 values to sum:

GPU Implementation Hierarchy

1. Warp-Level Reduction (Shuffle Instructions): Within a single warp (32 threads), CUDA's __shfl_down_sync() instruction allows threads to directly exchange register values without going through shared memory. A 32-element reduction completes in 5 shuffle operations (~5 cycles). This is the fastest reduction primitive.

2. Block-Level Reduction (Shared Memory): For thread blocks with multiple warps (e.g., 256 threads = 8 warps), each warp first reduces its 32 elements via shuffles, then the 8 warp results are combined via shared memory. The final value is written to global memory by one thread.

3. Grid-Level Reduction (Kernel Launch or Atomics): Multiple thread blocks each produce local sums. A second kernel launch (or atomic operations) combines the per-block results. Two-pass reduction (large kernel → small kernel) is standard for arrays with millions of elements.

Optimization Techniques

Performance

An optimized GPU reduction on an A100 achieves 80-90% of peak memory bandwidth (1.5+ TB/s) for large arrays — the operation is entirely memory-bandwidth-bound since the arithmetic (addition) is trivially cheap compared to the data movement.

Parallel Reduction is the simplest algorithm that exposes the full complexity of GPU optimization — just adding numbers reveals every performance pitfall: memory coalescing, warp divergence, shared memory bank conflicts, and kernel launch overhead.

parallel reduction algorithmgpu reductiontree reduction parallelwarp shuffle reductionreduction optimization

Explore 500+ Semiconductor & AI Topics

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