Repository navigation
Conversation
|
Reviewed and tested at Tests Run
Code Review (
|
|
Thanks @justr4mzi, good catch. |
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 682d14421 on Windows 11: tests/semantic/test_wave64_halves.py -> 77 tests, OK; tests/semantic/test_wave64_halves_soundness.py -> 30 tests, OK; git diff --check clean.
The lane mask accumulated by lane-local definitions is no longer treated as stale when a later read consumes it (SHADER-821), and the unused LANE_LOCAL_OPS list is dropped; the added cases cover the accumulated-mask and the rewritten-mask forms. Merge check: clean with #4619, #4620, #4624 and #4630; conflicts only with #4655 in tools/wave64_halves.py. No blocking issue.
…e (SHADER-821) A compiler's break loop ORs a v_cmp result into an SGPR pair and narrows EXEC with it. stale_uses() treated the pair as a scalar, so the loop was tier C tainted-exec although each bit belongs to one lane. A def that ORs (or AND-NOTs) a same-block v_cmp result into the pair leaves the off lanes' bits alone; a read that only uses the pair as a lane mask (an EXEC write, or the next such def) is no longer stale. Scalar uses (s_bcnt1, s_cmp) still are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DER-821) After the rebase onto main, the kill-exit test from cc4231d that expected a conservative tier C for an exit whose live mask two kills define now gets A: both definitions are `s_andn2_b64 D, D, vcc` after a v_cmp, so the mask is lane-local. Run it on the emulator (64 lanes against two halves of 32, with the halves leaving at different votes) and the words match. Keep a C control where the second definition ORs in a scalar register. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
682d144 to
649260f
Compare
|
Tested 649260f merged with main 98fa503 on WSL Ubuntu, Python 3.12.16: pass
|
|
Tested GPU suite (
So no regression on a 32-wide GPU. It also means none of the 242 fixtures AI-assisted (Claude Code). |
|
Rebased onto Conflict: One test on
Census after the rebase: I translated my own 1.0.2.1 copy at
As before, no shader in this corpus changes tier, so the rule only matters for the LLVM-style loop in the finding. Tests: I ran the whole |
|
Verified at the PR head: tests/semantic/test_wave64_halves.py passes 107/107 under python -I, and the translator-use guard, soundness and fixtures suites are clean. The lane-local-def rule reads correctly (v_cmp's zeroed inactive bits make the accumulated mask half-invariant). The head merges cleanly with current main; sequencing note: #4655 edits the same tool and semantic test — land in some order and re-run after each. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested Scope: the 32-wide half only (NVIDIA Volta). The AMD / 64-wide half still needs someone with an AMD GPU. (The change is in Setup: the PR diff applied to
No game files. AI-assisted (Claude Code); I ran the commands above and checked the numbers against the logs. |
|
Census (TEST-1006) of Setup. I merged the PR onto Result. Both sides translate all 13,405, and all 13,405 pass So no wave64 VS/PS/GS in the game has a stale-scalar finding that comes only from a lane mask built up by lane-local defs. The compiler AI-assisted (Claude Code). Part of TEST-1006 on the coordination issue. |
|
AI-assisted review (Claude Code). No game files; hand-written listings; CPU wave interpreter only (Windows 11, Python 3.14.7). Head One defect: a pattern moves from tier C to tier A, and the two runs differ. The rule says that a
The To reproduce, from the repository root at this head: # python -I repro.py
import sys
sys.path.insert(0, "tests/semantic")
from test_wave64_halves import meta_of, vs, run_cut, out_param
body = ["v_cmp_gt_u32_e64 s[16:17], 0, v0", "v_cmp_eq_u32_e32 vcc, 2, v0", "s_and_saveexec_b64 s[12:13], vcc",
"s_cbranch_execz 3", "s_mov_b64 exec, s[10:11]", "v_cmp_gt_u32_e32 vcc, 64, v0",
"s_or_b64 s[16:17], vcc, s[16:17]", "s_mov_b64 exec, s[10:11]", "s_and_b64 exec, exec, s[16:17]",
"v_add_nc_u32_e32 v6, 1, v6", "s_mov_b64 exec, s[10:11]"]
(tier, reasons, _), asm = meta_of("vs_lane_local_widened", vs(body))
whole, halves = out_param(run_cut(asm, 64)), out_param(run_cut(asm, 32))
print(tier, reasons, whole[32][:1], halves[32][:1]) # this head: A [] (1,) (0,)Proposal: accept the definition only when EXEC at the compare is inside the EXEC of the vote that the block depends on. The dataflow has the facts: the EXEC token at the instruction ( What passed. Tier A here with equal results: the break loop of the description; the same definition ( |
…te (SHADER-821) @shdann on ItsNotRexed#4656: an EXEC write between the vote and the v_cmp (the run side restoring the launch mask) switches the lanes of a half that skipped back on, so the compare sets their bits and the wave and the halves differ in lanes 32..63. lane_local_defs only cleared at an EXEC write after the compare. widened_after_vote() is a forward dataflow: once a vote has run on a path, an EXEC write other than a narrowing (EXEC AND/AND-NOT a mask, the and-saveexec family, v_cmpx, or the run side's s_mov_b64 exec, <vote mask>) stops later v_cmp results from counting as zero for the off lanes. Regression tests: both of @shdann's listings (tier C, and the wave and halves differ), and the narrowed control (tier A, equal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @shdann, that's a real hole, and the repro made it easy. Fixed in b3933dc with the sufficient condition you proposed.
The rule now rejects a join's restore inside a loop as well. That's conservative, and the EXEC-token /
AI-assisted (Claude Code). Linux, CPU only; no game files posted. |
|
AI-assisted review (Claude Code). No game files; hand-written listings; CPU wave interpreter only (Windows 11, Python 3.14.7). I tested the new head Correct now. The listing of my review is tier C. These widenings in the run side before the compare are tier C also, and the two runs differ for each: Two instructions are still accepted as a narrowing, and they are not.
Tier A with no reasons at Proposal: count only |
|
Tested
So the restore that AI-assisted (Claude Code). |
Claim: SHADER-821 (#4571 (comment)), from @shdann's finding.
What and why
stale_uses()treats a 64-bit lane mask in an SGPR pair as a scalar. In a compiler'sbreakloop, the pair collects the lanes that left:The pair's in-loop def is control dependent on the loop's EXEC vote, so its reads were stale and the two EXEC writes
tainted-exec: tier C. Each bit belongs to one lane, though. Av_cmpwrites 0 for the lanes that are off, so OR-ing it in can't change an off lane's bit. A half that leaves the loop early therefore has the same bits for its lanes as the wave.The rule (narrow on purpose)
Analysis.lane_local_defs):s_or_b64 D, M, D(either order) ors_andn2_b64 D, D, M, where D is an SGPR pair and M is VCC or a pair that av_cmp(notv_cmpx) wrote earlier in the same block, with no EXEC write in between.stale_uses(), a read of D is not stale when every vote-dependent def that reaches it is lane-local and the read only uses D as a lane mask, either as an EXEC write or as the next lane-local def.s_bcnt1,s_cmp, data) are still stale. So is an OR with anything that isn't a freshv_cmpresult.Tests (
tests/semantic/test_wave64_halves.py)test_a_break_loop_lane_mask: the loop above as a PS is tier A (tier Ctainted-execonmain).test_a_break_loop_lane_mask_runs_the_same: as a VS through the CPU wave interpreter, one 64-lane wave and two 32-lane waves write the same outputs (trip counts 1 to 4 per lane), and the tier is A.test_c_break_loop_mask_read_as_scalar:s_bcnt1_i32_b64of the pair is exported.test_c_break_loop_or_with_a_non_compare_mask: OR-ing a copy of EXEC instead of av_cmpresult.Corpus census (asked for by the item)
On my own 1.0.2.1 copy I translated the whole corpus at
main(d0835dd) and with this change, then ranwave64_halves.py --census. Counts only.maintainted-exec/stale-scalarNo shader changes tier. The shape doesn't occur in this corpus: none of the 25,734 listings narrows EXEC with
s_andn2_b64 exec, …. The game's compiler narrows withs_and_b64 exec, exec, s[pair](15,971 times) and loops withs_andn2_wrexec_b64waterfalls. So this PR fixes the classifier for the LLVM-style loop in the finding, but it has no effect on 1.0.2.1's tiers. I'm reporting that plainly so the maintainer can decide whether the rule is worth keeping. If not, the census still answers the item's open question, and I'm happy to close this.Tested
tests/semantic/test_wave64_halves.py+test_wave64_halves_soundness.py: 107 run, OK.python -m unittest discover -s tests/semantic: 7460 run. Its 7 failures and 2 errors are exactly main's known set at d0835dd by test name (test_cmp_class_f64,test_mutations,test_loop_ballot_barrier; fixes open in fix(rdna2spirv): route v_cmp(x)_class_f64 to cmp_class_f64 so malformed forms are rejected #3885/rdna2spirv: reject a modified class mask and a non-EXEC v_cmpx destination (TEST-853) #3948, tests/semantic: re-anchor the v_mul_legacy_f32 mutation after the flush change #3883, tests: test_loop_ballot_barrier follows #2089's structured wave64 emulation (main red since 1cc7497b) #3995).Touches
tools/wave64_halves.pyalongside #4619/#4620 (SHADER-819/820), but instale_uses()and a new helper, not input()/narrows.AI-assisted (Claude Code).
🤖 Generated with Claude Code