Skip to content

kernels: SumP on several cores again, bit-identical to floats.SumPairwise - #99

Merged
tannevaled merged 1 commit into
mainfrom
k1/sump-parallel
Nov 7, 2026
Merged

tannevaled merged 1 commit into
mainfrom
k1/sump-parallel

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Fixes the regression of #97 (v0.37.0): SumP became serial. It runs on several cores again with the same bits as floats.SumPairwise (NumPy's order) whatever the core count: it cuts NumPy's pairwise tree where DOUBLE_pairwise_sum cuts it, sums about four subtrees per worker, and adds the results back up the same tree. The only difference from the serial recursion is the sign of a subtree of only -0 values, which NumPy's final +0 + result erases.

TestSumPParallelIsBitIdentical: 6 core counts x 7 lengths (64 to 3 Mi) with wide dynamic range, and all -0, bit for bit; the race detector run is green. README states the parallel behaviour. No timing (host load).

🤖 Generated with Claude Code

…mPairwise

v0.37.0 made SumP serial so that the result would not depend on the core count.
It can keep both: NumPy's pairwise sum is a fixed binary tree, so SumP descends the
top levels of that tree exactly as DOUBLE_pairwise_sum cuts it (n/2 rounded down to
a multiple of 8, leaves of at most 128), sums about four subtrees per worker with
floats.SumPairwise, and adds the results back up the same tree. Tested bit for bit
against floats.SumPairwise for 6 core counts and 7 lengths up to 3 Mi, wide
dynamic range, and all -0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 2c4b8b4 into main Nov 7, 2026
12 checks passed
@tannevaled
tannevaled deleted the k1/sump-parallel branch November 7, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant