Home Knowledge Base Parallel Prefix Sum (Scan)

Parallel Prefix Sum (Scan) is the fundamental parallel computing primitive that computes all prefix sums of an input array — where prefix_sum[i] = sum(input[0..i]) for all i simultaneously — in O(N/P + log P) time on P processors, serving as the building block for parallel sorting, stream compaction, histogram computation, and virtually every parallel algorithm that requires computing cumulative quantities or assigning output positions dynamically.

Why Scan Is Foundational

Sequentially, computing prefix sums is trivial: iterate once, accumulating. But in parallel, each element's result depends on all preceding elements — a seemingly inherently serial dependency chain. The breakthrough is that associative operations can be restructured into a tree pattern that computes all prefixes in O(log N) parallel steps.

Scan Variants

Blelloch's Work-Efficient Parallel Scan

Two phases on a balanced binary tree: 1. Up-Sweep (Reduce): Bottom-up, each node stores the sum of its left and right children. After log₂(N) steps, the root contains the total sum. Total work: N-1 additions. 2. Down-Sweep: Top-down, the root receives 0 (identity). Each node passes its value to its left child and (its value + left child's old value) to its right child. After log₂(N) steps, every leaf contains its exclusive prefix sum. Total work: N-1 additions.

Total work: 2(N-1) additions — the same as sequential (work-efficient). Span: 2×log₂(N) steps.

GPU Implementation

Critical Applications

Parallel Scan is the universal addressing primitive of parallel computing — the algorithm that answers "where does each element go?" in parallel, enabling the dynamic data movement that makes complex parallel algorithms possible on architectures with no shared mutable state.

parallel prefix scaninclusive exclusive scanwork efficient scanparallel scan algorithmprefix sum application

Explore 500+ Semiconductor & AI Topics

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