Repository navigation
wave64_halves: a vote on EXEC ends with a new EXEC, plus GPU test ps_w64_c_vote_rewrite (SHADER-820) - #4620
wave64_halves: a vote on EXEC ends with a new EXEC, plus GPU test ps_w64_c_vote_rewrite (SHADER-820)#4620LouisRiverstone wants to merge 5 commits into
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 7708d08f on Windows 11: tests/semantic/test_wave64_halves_soundness.py -> 33 tests, OK; tests/semantic/test_wave64_halves.py -> 73 tests, OK; git diff --check clean.
The change drops the ("vote", mask) SCC tag when either register of the voted pair is rewritten, so a later s_cbranch_scc is not treated as a vote on the new mask; the reduced repro and the tier-C expectation are in the added case.
Duplicate/overlap: #4619 covers the same rewritten-vote-mask issue as part of a larger wave64_halves change (narrowed-EXEC off-lane taints plus this vote fix). The two branches conflict in tools/wave64_halves.py (git merge-tree refs/remotes/pr/4619 refs/remotes/pr/4620 -> conflict). You claimed SHADER-820 first (03:10), so the coordinator may prefer this focused fix and have #4619 drop its vote-mask hunk on rebase; either order leaves one redundant hunk. Flagged on both.
|
Thanks @Kam471 for the run and for spotting the overlap with #4619. This PR is only the SCC-vote check at the top of |
|
Tested
No game files. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Tested head
AI-assisted (Devin). |
|
Tested 7708d08 merged with main d0835dd on WSL2 Ubuntu (Python 3.12.16) and native Windows 11 (Python 3.13.1): pass.
|
|
Tested 7708d08 on AMD Radeon RX 9070 XT (RADV GFX1201, wave32/64) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
|
Approved with nits. The fix at Two branches it names or adds are untested: AI-assisted review, no game files, no GPU. |
|
Census (TEST-1006) of Setup. Native mode ( Result: no tier moves.
Tested on CPU only (no GPU run), under WSL on Windows 11. |
7708d08 to
703dfc9
Compare
|
Tested What I ran:
Cause:
|
|
Tested 703dfc9 merged with main 98fa503 on Linux (Python 3.12.16): concern - test_wave64_halves_soundness.py 33 OK, tests/test_docs_.py OK, negative control (tools/wave64_halves.py and docs from main, PR tests kept): 2 failures of 33. But the full tests/semantic/test_wave64.py run is 201 tests with 1 failure: test_wave64_halves.py KillExit.test_c_mask_redefined_or_not_the_vote (line 881, ps_kill_redef: 'reasons [tainted-branch] lack [unsafe-vote-branch]'). It passes on main 98fa503 alone and fails with the PR's tools/wave64_halves.py, so the PR changes that shader's reason (still tier C); that test's expectation, or the rule, needs updating in this PR. |
|
Census (TEST-1006) of the new head Setup. Each PR is merged onto The merge gives the same A 5,054 / B 106 / C 8,245. Only one PS changes: it was already tier C, loses AI-assisted (Claude Code). Part of TEST-1006 on the coordination issue. |
… unsafe-vote-branch Rebased on main, which added test_c_mask_redefined_or_not_the_vote (ItsNotRexed#2674's kill rule): a mask rewritten after its vote must be tier C with reason unsafe-vote-branch. Dropping the SCC vote tag made it tier C with tainted-branch instead. put() now turns the tag into ('stale_vote', ...), and s_cbranch_scc* on a stale vote reports unsafe-vote-branch; no other SCC reader sees a vote. docs/design.md wording follows.
|
Rebased on |
|
Thanks @SweatierKey, @kapitche and @465d6a0eac. The @465d6a0eac, thanks for the census: no tier moves, and |
|
Tested PR #4620 (
AI-assisted review (Gemini 4 Neon). |
|
Thanks @DenRakEiw, on the current head |
|
Tested 7bfba13 on Linux (CachyOS, kernel 7.3.5, Mesa 26.3.1-arch3.5 RADV): RX 9070 XT (gfx1201) and the Ryzen 7 9800X3D iGPU (gfx1036). Pass, and the bug is real on hardware.
To turn this into a GPU regression test, add the fixture to AI-assisted (Claude Code). |
… its branch @AwkGrep256's pixel fixture of shdann's listing (ItsNotRexed#4620): only pixel (0, 0) is in the voted mask, then v_cmp_le_u32_e64 rewrites s[20:21] before s_cbranch_scc0. On an RX 9070 XT and a gfx1036 iGPU (RADV) the images drawn at fragment subgroup sizes 64 and 32 differ in r0 and agree in r1: tier C. main classifies it tier A, this PR tier C unsafe-vote-branch. Registered in w64_graphics.py with _c_vote_stale's expectation and in test_wave64_halves_fixtures.py's EXPECT (which fails with main's wave64_halves.py).
|
Thanks @AwkGrep256, that's the proof on hardware this PR lacked:
|
|
Census (TEST-1006) of Merged onto AI-assisted (Claude Code). |
|
Thanks @kapitche, @KkelebekK (Radeon 780M, with the merge-base control) and @memorypressure. #4619's complementary rule auto-merges with this one; once both land, a joint run of |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/design.md
…SHADER-820 (ItsNotRexed#4620) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…GPU fixture main has this PR's first commit (2cbc8e0: a rewritten vote mask ends the vote, so the branch is tier C tainted-branch) and its tests now expect that. The later change to a stale vote / unsafe-vote-branch only answered the old test, so it is dropped: tools/wave64_halves.py, docs/design.md and tests/semantic are main's. What remains is ps_w64_c_vote_rewrite (@AwkGrep256), expected tier C tainted-branch.
|
Merged current |
|
AI-assisted review (Claude Code). No game files; hand-written listings; CPU wave interpreter only (Windows 11, Python 3.14.7). Head What is correct. The three listings of the finding are tier C One case is still tier A: the vote is on EXEC, and EXEC gets a new value before the branch.
Tier A with no reasons. One 64-lane wave exports v6 = 9 in lanes 32 to 63, two 32-lane waves export 0 (32 lanes differ). The same occurs when the vote comes from To reproduce, from the repository root at this head or at # 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_eq_u32_e32 vcc, 2, v0", "s_and_saveexec_b64 s[12:13], vcc", "s_mov_b64 exec, s[10:11]",
"s_cbranch_scc0 1", "v_add_nc_u32_e32 v6, 9, v6"]
(tier, reasons, _), asm = meta_of("vs_exec_vote_rewritten", 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]) # A [] (9,) (0,)Proposal: in |
…aves SCC alone (SHADER-820) @shdann on ItsNotRexed#4620: put() skips EXEC, so ('vote', 'exec') on SCC outlived s_mov_b64 exec / s_cselect_b64 exec / v_cmpx, none of which writes SCC; the branch then voted on the old EXEC while the run side used the new one, and the shader was tier A although one 64-lane wave and two 32-lane waves differ (lanes 32..63). exec_write() now drops that tag on such writes, and on any other EXEC write it does not model; s_cselect_b64/s_cmov_b64 into EXEC no longer mark SCC as a fresh vote either. Tests (test_wave64_halves_soundness.py): the saveexec / s_and_b64 exec votes followed by s_mov_b64 or s_cselect_b64 into EXEC, and the s_bcnt1 count with EXEC restored, are tier C and diverge; a kept and a re-voted EXEC stay tier A and invariant. With main's rule the new tests fail 4 subtests. All wave64 suites pass.
|
Thanks @shdann. That's a real hole, and your repro made it quick to confirm. I've fixed it here, since this is the SHADER-820 thread: The fix
Your cases, now tier C
Controls, still tier A and invariant: a kept EXEC, and one re-voted by a second These cases are in |
|
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
One conservative result, no defect: |
|
Tested 2dd34ba on CachyOS, RADV/Mesa 26.3.1, LLVM 23.1.5: pass. GPU (
CPU: Note: AI-assisted. |
|
Tested
No game files. AI-assisted. |
|
Tested 2dd34ba merged with main 1cc6e3c on Linux/Python 3.12.16: pass. Ran (venv python, -I):
Negative control: tools/wave64_halves.py from main, PR tests kept: test_wave64_halves_soundness.py 35 tests, 4 FAIL. So the new tests do depend on the tools change. Earlier issue: my concern on 703dfc9 (KillExit.test_c_mask_redefined_or_not_the_vote failing in the full wave64 semantic run) is not present here; the full run is clean on this head. The GPU test ps_w64_c_vote_rewrite was not run (no GPU in this check), and native Windows was not run. |
|
Tested
No game files. AI-assisted (Claude Code). |
…fore the branch (SHADER-820) @sennecools on ItsNotRexed#4620: the EXEC rule of 2dd34ba had no GPU fixture. This is @shdann's case in ps_w64_c_vote_rewrite's layout: only pixel (0, 0) passes the compare, s_and_saveexec_b64 votes on the narrowed EXEC, s_mov_b64 exec restores the launch mask without touching SCC, and s_cbranch_scc0 still decides on the old EXEC. sennecools measured this body on an RX 9070 XT (RADV): r0 differs between required subgroup sizes 64 and 32. Registered in w64_graphics.py (_c_vote_stale's layout) and expected tier C tainted-branch in test_wave64_halves_fixtures.py; with main's wave64_halves.py that test fails (tier A). Translates and passes spirv-val; build summary tier C.
|
Thanks @sennecools for putting the EXEC case on the GPU, and for the 9070 XT run. I've added it as the second fixture you suggested,
Your note on the 9800X3D iGPU, that the reference check only fits 32-only devices, is a harness limit, as you say, so I've left it out of this PR. Thanks also @kapitche (236 wave64 tests OK at the previous head). |
|
Census for TEST-1006 (claim): the corpus census before and after the EXEC-vote fix in Setup. My own Xbox copy, 1.0.2.1. All 108 manifest files match Result: identical. No shader's tier or reasons change between the merge base and this PR. I compared the two indexes shader by shader, not only the totals.
Tier C reasons: tainted-branch 6,534, unsafe-vote-branch 6,496, tainted-exec 6,360, cross-lane 4,624, stale-scalar 3,487, mask-half 759, unsafe-execz-branch 583, first-lane 353, lane-id 152, waterfall-scalar 3, lane-count 1. Tier B idioms: readfirstlane-uniform 3,288, waterfall 1,318, lane-spill 287. So on this copy no tier A or B shader votes on EXEC and then gets a new EXEC from The output above is counts only. No shader names or listings. AI-assisted (Claude Code). I ran the census and compared the two indexes. |
|
Thanks @JoaoPauluu for the census: no tier or reason changes across 13,405 shaders, so on this copy the fix is sound-side only. |
SHADER-820: the GPU fixture for the rewritten-vote-mask rule.
Status after
mainmoved. The rule itself is onmainas2cbc8e046, which is this PR's first commit: a vote on a mask ends when the mask register is rewritten before the branch, so the branch is tier Ctainted-branch.main's tests now expect that result. This PR had later changed it to a "stale vote" reported asunsafe-vote-branch, but only to satisfy an older test. Both tiers are C, so the change is dropped, andtools/wave64_halves.py,docs/design.mdandtests/semanticaremain's.And a fix for the EXEC case (@shdann): a vote on EXEC now ends when EXEC gets a new value from an op that leaves SCC alone (
s_mov_b64,s_cselect_b64,s_cmov_b64orv_cmpxinto EXEC). Before,maincalled such shaders tier A even though 1×64 and 2×32 differ. The fix is intools/wave64_halves.pyexec_write(), with tests intest_wave64_halves_soundness.pyand a clause in the SHADER-10 row.What this PR adds.
runtime/test/shaders/ps_w64_c_vote_rewrite.asm(fixture by @AwkGrep256), registered inw64_graphics.pyand expected as tier Ctainted-branchintests/test_wave64_halves_fixtures.py. Only pixel (0, 0) is in the voted mask. The branch still decides on the old mask, while the run side narrows EXEC to the new one, so a 64-lane wave and two 32-lane waves write differentv6in the other half's pixels.Verify.
python -I -m pytest -q tests/test_wave64_halves_fixtures.py: 10 passed.test_wave64_halves*.py(discovered fromtests/semantic): OK.No game files.
AI-assisted (Claude Code): I reviewed and ran the tests above.