Repository navigation
simd: masked_sum_i32 sums dense words branch-free, walks sparse ones - #376
Conversation
Per 64-bit mask word: empty words are skipped, words with at most 16 set bits keep the set-bit walk, and full words with more than 16 set bits sum all 64 lanes branch-free, each widened to i64 and masked, so the i64 contract holds and the loop vectorizes. The threshold and the speed-up (2-5x, never slower than the walk) come from the D-MPF-2b measurement in lance-graph #1752. A partial final word always takes the walk. New test masked_sum_i32_both_word_routes_match_reference covers words at, below and above the threshold plus random densities, and asserts the fixture takes both routes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
What
masked_sum_i32now chooses its method one 64-bit mask word at a time:i64and masked before the add, so thei64contract still holds and the loop can vectorize.values.The threshold of 16 and the expected speed-up come from the D-MPF-2b measurement in lance-graph #1752: 2–5× faster than the walk, and never slower.
Measured in the consumer (lance-graph #1763, P2 probe, 4096-slot fold, median)
The 25 % masks barely move: at about 16 set bits per word, most words stay on the walk path.
Verification
masked_sum_i32_both_word_routes_match_referencecovers words just below, at and above the threshold, plus random densities. It asserts that at least 5 words take each path, so neither path can go untested.i32breaks 3 tests, including the widening test;cargo test --lib: 2627 pass.cargo clippy --lib --tests -D warnings: clean.scripts/masking-parity.sh native: PASS on AVX-512 and onconfig-v3(AVX2), 19 groups.The function is a free function in
simd_masking_ops.rsand the same body serves every backend; nosimd_{arch}file changed.Generated by Claude Code