Skip to content

D-SIMD-MICRO-MACRO-1 step 1: packed microtile oracle (lab fixture) - #406

Merged
AdaWorldAPI merged 1 commit into
masterfrom
ccr-45a41fb4-0j3i0l
Oct 30, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
ccr-45a41fb4-0j3i0l

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Step 1 of the micro/macro sequence in synergy map R7.6: a packed 128-bit microtile, checked against an exact oracle. This is a lab fixture. It adds no public type, changes no backend and has no production caller. Steps 2–4 (binding to a KPEA method, reusing Thought-0 work across thought deltas, interlacing) are not started.

What it is

The fixture is examples/microtile/ (four realizations plus a cost gate) and tests/microtile.rs (exactness). One 128-bit tile holds one of two layouts:

  • 5×U24/I24, plus 8 metadata bits;
  • 14×U9/I9, plus 2 spare bits.

Operations:

  • wrapping add and sub, with each carry and borrow kept inside its own field;
  • per-field carry-out, borrow-out and signed overflow;
  • an intra-tile stencil, f[j-1] + 2f[j] + f[j+1];
  • an exact fold giving each field's unsigned and signed sum across many tiles.

Every result keeps the left operand's metadata.

Realizations

All four are checked against one unpacked per-field oracle:

  1. u128: the whole tile in one 128-bit integer.
  2. SoA U64x8: 8 tiles per operation, each tile split into a low and a high 64-bit word. The fields that cross bit 64 get an explicit carry or borrow out of bit 63, computed with lane-wise logic only.
  3. Widened U32x16: one field per u32 lane. The fold flushes the lanes to u64 before they can overflow.
  4. Bit planes: added with simd::full_add_mask, folded by popcount.

Tests

  • 9 tests, green on AVX-512, AVX2, AVX (qemu SandyBridge), x86-64-v2 (qemu Nehalem), NEON (qemu aarch64) and nightly core::simd.
  • Disable runs D1–D13 each turn the tests red, except D6: that one removed a redundant mask on the stencil's left shift, so I deleted the mask itself.
  • Clippy (-D warnings, v3 and v4) and fmt are clean, and the FACET STRIDE guard passes.

Cost gate

x86 only; ns per tile, as the range across three runs. Full table in .claude/knowledge/microtile-probe.md. No realization wins every case:

  • U24x5: widened is fastest for both add (≈0.7 at 4K tiles) and fold (≈0.3).
  • U9x14:
    • packed SoA is fastest for add while the data fits in L2 (1.1–1.7, against ≈1.9 widened);
    • bit planes are fastest for the fold (0.6–0.8);
    • widened costs 3.5× the bytes and is about 3× slower at 1 MB.
  • The single u128 never wins (about 2 ns/tile): rustc does not vectorize it, and the packed speed comes from the SoA split.

Found along the way

On NEON and wasm, U32x16 lacks &, |, -, !, +=, from_slice and copy_to_slice. The fixture works around this; the gap is recorded in the report, not fixed here.

No automatic merge.


Generated by Claude Code

One 128-bit tile carrying 5xU24/I24 (+8 metadata bits) or 14xU9/I9 (+2 spare)
isolated fields: wrapping add/sub, per-field carry/borrow/signed overflow, an
intra-tile stencil, and an exact unsigned+signed fold. Four realizations (u128,
SoA U64x8, widened U32x16, bit planes over full_add_mask) are checked against
one unpacked oracle on six SIMD realizations, with disable runs D1-D13.

No realization wins every case; report in .claude/knowledge/microtile-probe.md.
NEON/wasm U32x16 facade gaps recorded, not fixed. No public type, no backend
change.

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

coderabbitai Bot commented Oct 30, 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: a08dbf17-10d6-41c0-bb23-9776f99de1ec
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 30, 2026 13:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T13:40:25.220964Z 97d8cdd 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 000b077 into master Oct 30, 2026
31 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97d8cdd5d0

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +114 to +115
for (ak, bk) in pa[j].chunks_exact(w).zip(pb[j].chunks_exact(w)) {
acc ^= planes_add(ak, bk, &mut op);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Materialize and consume the bit-plane addition results

In the release cost gate, every bit-plane block writes its sum into the same op scratch buffer, but that buffer is never read; only the carry masks reach black_box. Because planes_add is inlined, the optimizer can eliminate the sum calculations and stores, leaving a carry-only benchmark. Even without that optimization, this path avoids writing a complete result dataset, unlike the other three addition paths. This makes the reported addition timings and bandwidth conclusions incomparable. Store each block's sum in a full output buffer and pass that output through black_box inside the timed closure.

Useful? React with 👍 / 👎.

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