On this page

0101: Fixed reduction shape makes par results independent of thread count

Status: Proposed (default; pending owner confirmation)

Extends ADR-0003's interpreter reference to parallel operations.

Context

Scheduling-dependent reduction trees change results and traps, especially for non-associative operations. The interpreter must remain a useful reference.

Decision

For nonempty input of length n, use min(n, 256) chunks, sized evenly with the first n % chunks chunks one element longer. Left-fold each chunk from its first element, then left-fold chunk results in order. Empty input returns zero. This shape depends only on n, not thread count. The result equals a serial fold from zero when the block is associative and zero its identity; even otherwise the shape-defined result is thread-count independent.

The interpreter executes serially in the same map and fold order, ignoring thread limits. After workers join, report the trap at the lowest input index; memory-limit out-of-memory traps are excluded from determinism because peak memory depends on thread count.

Consequences

Non-associative folds are deterministic but need not equal a serial fold. Tests compare outputs and traps across thread counts and the interpreter.