Skip to content

gfx2hlsl: prove lane-local compute readfirstlane waterfall bodies - #2694

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/compute-numeric-waterfall-proof
Nov 26, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/compute-numeric-waterfall-proof

Conversation

@RavenCurseBurg

@RavenCurseBurg RavenCurseBurg commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Change

This implements the numeric and fixed raw-buffer part of #2644 T1. A compute loop can use a lane-varying v_readfirstlane_b32 key when the next compare selects that key's lanes, the saved remaining mask is intact, and s_andn2_wrexec_b32 plus s_cbranch_scc1 closes the loop. The fixture covers groups of up to 32 threads for the low-word mask.

Each active lane receives its own key on its one participating visit. The proof reuses the compute scalar effect sets, exit liveness and branch targets. It checks the mask copy, entry edges, loop-carried scalars, the straight-line body and the registers that can escape. The output SGPR is marked varying. Per-key byte offsets are supported in a fixed bound raw buffer. Per-key resource selection still requires T3's bound heap range. AMD describes the waterfall and the two WREXEC widths in RDNA 2 ISA §12.3, opcodes 58 and 71.

Verification

Both complete synthetic programs stop at v_readfirstlane_b32 requires a proven uniform source on the parent f06646ba. The host and LLVM 15.0.7 reassembly modes pass on the candidate. They cover a store, a read of the actual active-mask rank, a changed saved mask, a different compare source, a second entry edge, an escaping scalar on one or all paths, loop-carried SGPR/SCC, a per-key descriptor and a group with 33 threads. Overwriting the escaping scalar on every path is a positive control.

python -B tests/startup_compute_readfirstlane_check.py
python -B tests/startup_compute_readfirstlane_check.py --llvm-mc llvm-mc-15
python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer warp
python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer hardware

The independent host reference covers 1,215 input and active-mask combinations. An active-mask-rank body produced 495 counterexamples to singleton execution and has a named refusal here. The synthetic fixtures use no captured input.

The registered dispatch fixture passed on WARP, GeForce RTX 4060 and Intel UHD 770 at 4fe7a4a5. Each run checked active counts from zero to four, an arithmetic overflow case, fixed-buffer reads, and two deliberately wrong references. The affected fixture also retains its original uniform-source and mutation checks.

I separately compiled both programs with an input-configurable mask. For each adapter, five key tuples crossed with all 16 four-lane masks gave 80 arithmetic and 80 fixed-buffer readbacks. All 480 outputs matched the independent reference over all 320 words. A separately compiled mutant used the same lane's key for everyone. On each adapter, its first mismatch was word 1 in both programs (arithmetic expected 0x30, got 0x50; fixed buffer expected 0x91, got 0x119). All 97 selected host-side translator and documentation checks passed. Two neighboring graphics fixtures also passed in their actual WARP draw modes.

The branch includes #2693, which lets the existing fixture accept the renderer's adapter-selection notice when testing a secondary GPU. Review the four waterfall files against that prerequisite.

The first Linux CI run failed only the scalar-table arity mutation count (37 of 40). I reproduced the same result on unmodified main at e76f8acd. The three templates with dedicated refusals are s_bfm_b32, s_mul_hi_i32 and s_mul_hi_u32. Windows and LLVM CI passed on that head. The upstream fix landed in #2659 at ad1ad194. I merged main through 8ad488af: the resulting head 27de79c9 passes both the scalar-table mutation suite and the host readfirstlane tests, including LLVM reassembly.

Refs #2644 and #2274. AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).

@R0Y00
R0Y00 merged commit d382863 into R0Y00:main Nov 26, 2026
5 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