Repository navigation
D-BINARY-ABACUS-POLYFILL-0 PR A: half/full adder mask words; vectorized pow2n_from_int - #402
Merged
Merged
Conversation
simd_exp_f32 (and with it vsexp, vstanh, vserf) built 2^n one lane at a time through to_array. It now stays in registers through the facade's typed words: clamp n, add 2^23 + 127 so the biased exponent sits in the mantissa field, and shift the bits left by 23. That needs U32x16 << U32x16, which only the AVX-512 and scalar backends had. Added Shl/Shr<Self> for U32x16 on AVX2 (VPSLLVD/VPSRLVD per 256-bit half), AVX without AVX2 (per lane; no AVX1 form exists), NEON (vshlq_u32), wasm simd128 (lane extracts; simd128 shifts are uniform) and the nightly core::simd backend, following each backend's U64x8 shifts. Tests: pow2n_from_int bit for bit against the scalar exponent rule over n in [-200, 200]; U32x16 shifts against per-lane shifts with distinct counts per lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
…y for U32x16 shifts half_add_mask(a, carry) = (a ^ carry, a & carry) and full_add_mask(a, b, c) = (a ^ b ^ c, majority) are the flip and carry_save3 laws proven in #391 and #389, now in simd_masking_ops and re-exported through ndarray::simd. Each u64 is one significance column of 64 independent counters; the carry belongs one column up in the same lane. Tests: both truth tables in every lane position, lanes 0/31/32/63 alone, 2000 random words (with zero, all-ones and alternating masks) against per-lane addition, and a ripple counter that keeps lanes apart while moving the carry to a neighbouring bit corrupts it. The wasm parity harness now also checks U32x16 << and >> with a distinct count per lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
…sal (lab) D-BINARY-ABACUS-POLYFILL-0 cost-gate candidate, kept in the research fixture. F's eager ripple built from ndarray::simd::half_add_mask; on overflow the touched columns are restored by recomputing the carry chain forward from the input mask, so the success path keeps no undo log. BITS <= 122 keeps lane values and the 64-lane total exact in u128. Tests: lanes 0/31/32/63 alone, carry chains of 1..64 columns, repeated carries, refusal leaves the counter unchanged (overflow and out-of-range significance), 24,000 random steps against 64 u128 counters with both outcomes common, and reversed traversal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
Adds candidate C next to native and F in the counter rows, and records the cost gate: C matches F, both beat 64 per-lane adds ~4x on dense and single-lane masks. PR B (public BinaryAbacus64) and PR C (facet bit-plane helper) are deferred: no consumer yet, and the planes already cost one AND and one cmpeq_mask each on existing facade words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
AdaWorldAPI
marked this pull request as ready for review
October 30, 2026 12:17
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. |
AdaWorldAPI
pushed a commit
that referenced
this pull request
Oct 30, 2026
Records #402, plus the rows #400 and #401 moved. New dots N22-N26: the adders as facade words with no consumer yet, the exp speed-up reaching every exp-based word, AVX2 select mask packing as a second array-backed cost, NEON scalar fcmp/csel in simd_exp_f32, and the transactional Abacus against the non-transactional eager counter. Fruit L20, L21, H12, H13; PR C not planned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
AdaWorldAPI
pushed a commit
that referenced
this pull request
Oct 30, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
AdaWorldAPI
added a commit
that referenced
this pull request
Oct 30, 2026
Synergy map R7: #402 (adder words, vectorized exp, Abakus cost gate)
AdaWorldAPI
added a commit
that referenced
this pull request
Oct 30, 2026
Synergy map R7.5: #402's late CI jobs all passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR A of D-BINARY-ABACUS-POLYFILL-0, plus the cost-gate lab work that decides PR B and PR C. Four commits:
1.
9aea2fc:half_add_mask,full_add_maskfliplaw (D-DOMINO-MOV-0: bit flip, positional substitution and lazy FULL carry (probe) #391,examples/u9_domino) and thecarry_save3law (D-U9-ABACUS: schoolbook U9 x U9 with carry escalation and power-of-two anchors (probe) #389,examples/u9_abacus), moved unchanged intosimd_masking_opsand re-exported with plainpub usethroughndarray::simd.u64is one significance column of 64 independent counters, with bitjbelonging to lanej. The carry belongs one column up, in the same lane.Tests (4 unit tests, 2 doctests):
2.
02f9018: vectorizedpow2n_from_int;U32x16variable shifts on every backendsimd_exp_f32built 2^n one lane at a time throughto_array, andvsexp,vstanhandvserfall go through it. The new version stays in registers:For integral
n, after the clamp,2^23 + 127 + nis an exact f32 whose mantissa field holds the biased exponent. Shifting left by 23 drops the0x4B00_0000exponent and leavesk << 23. The function stays private:simd_exp_f32still does its own high-exponent, subnormal and NaN handling around it, unchanged.This needed
U32x16 << U32x16, which only the AVX-512 and scalar backends had.Shl/Shr<Self>forU32x16now follow each backend'sU64x8shifts:VPSLLVD/VPSRLVDper 256-bit halfvshlq_u32core::simd<</>>Lowering.
simd_exp_f32compiled out of line, new against master:vpslld $23on both x86 tiers.vpextrw/vpinsrwpacking thesimd_gt/selectmasks; that code predates this change.fcmp/csel, which predate this change and are noted rather than fixed here.Timing. ns per element, n = 65,536, best of 15, three runs each:
vsexp/vstanh/vserfvsexp/vstanh/vserfTests.
pow2n_from_int, bit for bit against the scalar exponent rule over n ∈ [−200, 200], across both clamp ends.U32x16shifts against per-lane shifts, with a distinct count in every lane.simd_exp_f32andvmltests (2 ULP, bit-for-bit unfused sequence, infinities, NaN per lane, overflow and subnormals).U32x16shift check (return codes 14 and 15).Passed:
scripts/wasm-parity.shOK;3.
a70f336,de03001: cost gate (lab only,examples/u9_domino)Candidate C,
Abacus<BITS>, is F's eager ripple built fromhalf_add_mask:1 <= BITS <= 122, so a lane value and the 64-lane total are both exact inu128.try_add_atis transactional. On overflow, the touched columns are restored by recomputing the carry chain forward from the input mask (old_k = new_k ^ m_k,m_{k+1} = old_k & m_k), so the success path keeps no undo log.BITSis refused without any change.Tests (6, in
tests/u9_domino.rs):u128counters, with both outcomes common;Disables, each red: no rollback; rollback stops after one column; no range check; carry moved to the neighbouring lane.
ns per add, range over 3 processes:
Verdicts (full report in
.claude/knowledge/binary-abacus-polyfill-probe.md):BinaryAbacus64: deferred. The semantics are settled and the cost matches F, but no consumer counts 64-lane masks at chosen significances yet. C stays in the fixture as the reference.cmpeq_maskeach on existing facade words.lut9and Codec9 do.Disable runs for the library commits (each red, then restored)
pow2nshifts by 22pow2n_…+ 5simd_exp_f32testsshluses the low half's counts for the high halfu32x16_variable_shifts_…(v3)shrwithout negated countsu32x16_variable_shifts_…(aarch64 qemu)shldoesshrshluses lane 0's countu32x16_variable_shifts_…(SandyBridge qemu)t & ccarry termChecks
-D warningsclean on native and v3, including the fixture example and test; fmt clean.Not merged automatically.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY