Skip to content

simd: mask_scatter_or_u16 — scatter-or over u16 ordinals, no widening - #377

Merged
AdaWorldAPI merged 1 commit into
masterfrom
claude/clone-repositories-71a5sw
Oct 26, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
claude/clone-repositories-71a5sw

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Adds ndarray::simd::mask_scatter_or_u16, the u16-index twin of mask_scatter_or_u32.

Why. Sealed 64×64 focus maps in lance-graph store canonical addresses as u16, because the 65,536-address universe is exactly the u16 domain. Scattering them through the u32 primitive first needs a widened copy of every map: 16 KiB per 4,096-slot map, 1 MiB per 64 maps. In the lance-graph lab that widening dominated small selections: 9 µs with u16 against 46 µs with u32, for 4,096 selected addresses.

What.

  • Both widths share one private set-bit walker, scatter_or_walk.
  • The contract is identical for both widths:
    • only selected source bits are walked;
    • the destination is OR-accumulated, never zeroed;
    • repeated targets collapse to one bit;
    • out-of-range targets are silently dropped;
    • the final partial source word is clamped to index.len();
    • each function panics with its own name.
  • The u32 function's behaviour and messages are unchanged, and its 8 existing tests pass.
  • Still scalar on every backend, for the same reason as before: no backend has a bit-level scatter.

Tests.

  • Equivalence: u16 equals u32 and a naive reference, for n up to 4,096, out_rows ∈ {50, 4,096, 65,536}, with dirty tail bits.
  • Top of the u16 domain: target 65,535 is kept at out_rows = 65,536 and dropped at 65,535.
  • Accumulation: repeated targets union, successive calls accumulate, and a pre-set bit survives.
  • Panics: short source and short output buffers.
  • Disable runs: both new behaviours turn the tests red. Capping the domain at 65,535 fails the top-of-domain test; removing the tail clamp fails the equivalence test.
  • Parity crate: simd-masking-parity gains check 0xD12 (u16 against the u32 reference); native AVX-512 run: 19 groups OK.
  • Gates: cargo test --lib mask_scatter 13/13, doctests 2/2, cargo clippy -- -D warnings clean, cargo fmt --check clean.

Not in scope. mask-risc exposure (a LaneRef::U16 read by the existing scatter terminal) is designed in lance-graph but waits for this PR.


Generated by Claude Code

…ls in place

Sealed 64x64 focus maps hold canonical addresses as u16 (the 65,536 universe
is exactly the u16 domain). mask_scatter_or_u32 forced a widened u32 copy of
every map (16 KiB per 4,096-slot map, 1 MiB per 64 maps) just to scatter.

Both widths now share one private set-bit walker (scatter_or_walk): same
clamp of the final partial src word, same OR-accumulate (never zeroes the
destination), same union of repeated targets, same silent drop of
out-of-range targets, same panic messages per name. Scalar on every backend,
as before: no backend has a bit-level scatter.

Tests: u16 equals u32 and a naive reference across the tail (n up to 4,096,
out_rows 50 / 4,096 / 65,536, dirty tail bits); top-of-domain 65,535 kept at
out_rows 65,536 and dropped at 65,535; union + accumulation + preset bit;
short src / out panics. Disable runs (domain ceiling, tail clamp) both red.
simd-masking-parity gains check 0xD12 (u16 vs the u32 reference).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d603a45-7c04-48e4-9b4e-208ce5774063
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T17:49:32.562790Z c6b2c8d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdaWorldAPI
AdaWorldAPI merged commit af4910a into master Oct 26, 2026
30 checks passed
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.

2 participants