Skip to content

examples: ternlog_popcnt_gap_probe — the mask_ternlog_popcount loop shape is not the gap - #335

Merged
AdaWorldAPI merged 1 commit into
masterfrom
claude/fold-distillation-pr-wave-s57uj7
Sep 25, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
claude/fold-distillation-pr-wave-s57uj7

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

This adds examples/ternlog_popcnt_gap_probe.rs, which measures where mask_ternlog_popcount loses time. The answer is that its loop shape is not the gap.

3 planes, (a&b)|c. Every arm is asserted equal. The arms are:

  • P: production mask_ternlog_popcount.
  • T: the same loop with no popcount, which is the loop's floor.
  • M: ternlog plus a Mula popcount (VPSHUFB + VPSADBW), as a lab arm with raw intrinsics.
  • S: the plain scalar loop.

Results on a Xeon at 2.8 GHz with AVX-512F/BW and no VPOPCNTDQ:

  • P equals M at every size. The scalar-lane popcount fallback compiles as fast as a Mula LUT, so it is not a cost.
  • P is within about 1.15× of the floor T. At 1024 words (one 64k-row tile) it is 1.3× faster than S.

5 planes, ((a|b)&c)^(d&!e), 4K–16K words:

  • Timings: two-pass 13.3 µs, register-resident two-ternlog 11.8 µs, the same unrolled ×4 11.9 µs, scalar 9.0 µs.
  • Fusing the two tables in registers buys only 1.1×.
  • The scalar loop is 1.2–1.5× ahead of every U64x8 form.
  • Unrolling doesn't explain it, and a rebuild with the 256-bit preference switched on and off was inconclusive.
  • The cause is left OPEN; it is small next to the aperture results in lance-graph.

Also fixed: ternlog_fold_probe's header claimed the no-VPOPCNTDQ fallback is a LUT path. It is the scalar-lane fallback, and the header now says so.

Tests: example-only, no library change. cargo clippy --release --example ternlog_popcnt_gap_probe -D warnings is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GXUahz73MZxtxWcfpHp9dG


Generated by Claude Code

…hape is not the gap

Measures production mask_ternlog_popcount against a no-popcount floor, a
Mula-popcount lab arm and the scalar loop, plus a 5-plane two-ternlog
comparison. On AVX-512F/BW without VPOPCNTDQ the scalar-lane popcount
fallback is as fast as a Mula LUT, and the 3-plane kernel sits within
~1.15x of its floor. Corrects ternlog_fold_probe's claim that the
fallback is a LUT path.

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

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: b2c6e055-33ed-4f4e-8772-d79bca51ff44

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff97d4 and 34c8410.

📒 Files selected for processing (3)
  • Cargo.toml
  • examples/ternlog_fold_probe.rs
  • examples/ternlog_popcnt_gap_probe.rs
 __________________________________________________________________
< Ah yes, the classic pattern: 'parse first, ask questions never'. >
 ------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

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

@cursor

cursor Bot commented Sep 25, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_586ea674-1ea3-4ab7-ab5c-5429092bf1ab)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review September 25, 2026 09:38
@AdaWorldAPI
AdaWorldAPI merged commit 239613e into master Sep 25, 2026
27 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