Parallel Prefix Scans by Tree Traversal
Compute every prefix with linear work and logarithmic span by separating subtree totals from incoming prefixes.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
An upsweep combines disjoint ranges
Place \(n\) values at leaves of a balanced binary tree. Each internal node computes the associative combination of its left and right range totals in input order. This takes linear work and logarithmic depth. For addition on \((2,1,4,3)\), pair totals are \(3,7\) and the root total is \(10\).
A downsweep supplies each child’s preceding aggregate
Give the root the identity as incoming prefix. The left child gets its parent’s incoming prefix. The right child gets that prefix combined with the entire left total, in that order. At the leaves this produces exclusive prefixes \((0,2,3,7)\). Combining each with its own value produces the inclusive result. Associativity is sufficient even when the operation is not commutative. Work and span quantify the two passes. Parallel reductions compute just the combined total.[1]