Skip to content

eri: specialize prim_g_root on the quartet shape - #20

Open
ZuseZ4 wants to merge 1 commit into
mainfrom
eri-constify
Open

eri: specialize prim_g_root on the quartet shape#20
ZuseZ4 wants to merge 1 commit into
mainfrom
eri-constify

Conversation

@ZuseZ4

@ZuseZ4 ZuseZ4 commented Aug 2, 2026

Copy link
Copy Markdown
Member

Rust has better const support than C, so I wanted to try if we could use that.
Apparently the benefit here isn't on removing branching, but from doing more computations at comptime.
It didn't generate the change I asked for, but still worth testing if the claimed speedup is true (~35%).

The angular momenta and the g-buffer strides never change inside a quartet's
loops, but they were runtime values, so every index in the VRR/HRR recurrences
and the gout contraction was computed with runtime multiplies. `Shape` collects
them and `seg_body` is specialized on it, so in the specialized arms every loop
bound, every branch and every stride is a compile-time constant.

Also unrolls `for ax in 0..3` into three explicit calls (vrr_axis/hrr_axis).

And there is a hard Enzyme cliff at 8 arms: the reverse SIGSEGVs at runtime with
a garbage `gx` base pointer, so we only use 6 here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant