Repository navigation
Conversation
|
Tested What I ran:
Code review:
|
Kam471
left a comment
There was a problem hiding this comment.
Ran this at a54ea0ee on Windows 11, RTX 5070 Ti.
tests/semantic/test_wave64_emulate_opt.py-> 23 tests, OK (5.7 s);git diff --checkclean. The newtest_folded_region_scalar_branch_to_join_skips_the_restcovers taken and not-takenscc0/scc1at 64 and 128 threads and asserts the region is still folded.- GPU emulated run,
LEONIDA_W64_EMULATE=1 run_gpu_tests.py --filter cs_w64xwith this translator -> 19/19 passed, includingcs_w64x_saveexec_b64,cs_w64x_mask_reuse(2),cs_w64x_sbarrier,cs_w64x_wg128_branches,cs_w64x_partial_scmp.
find_local_exec_folds now gives a sub_end exit node to edges into skip and drops that empty guard from the tree, so the blocks after an in-region scalar exit keep their %pc guard. With the old edge dropped, the test's four taken cases ran the rest of the region. No blocking issue; still not GPU-verified specifically for the exit sequence, as the row says.
|
Tested head
The scalar-branch join handling in the wave64 emulator matches the description. AI-assisted (Devin). |
|
Verified GPU, semantic & negative-control checks
AI-assisted (Gemini, Antigravity). |
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted Windows CPU check at a54ea0ee, uv CPython 3.12.13. The exact scalar-exit case matched all 768 lane words across the eight taken and fallthrough variants at 64 and 128 threads. All eight retained one dispatch switch case and passed Vulkan 1.2 spirv-val.
I inspected the generated modules before attempting the exact case on Radeon. The existing wave64 scheduler emits overlapping non-atomic workgroup stores in its initial clear and round reset. Those code paths predate this PR, and #4247 (SHADER-708) already addresses them. I submitted no GPU dispatches for these fixtures. This is CPU confirmation of the branch fix, with hardware verification of the exact sequence pending that scheduler change.
Flyander
left a comment
There was a problem hiding this comment.
Reviewed the control-flow exit handling and its regression cases; I found no additional correctness issue in this pass.
whattheflop
left a comment
There was a problem hiding this comment.
Follow-up to the CPU-only review. Scratch 619d84ef combines a54ea0ee with #4247 5f16276d on d0835dd9. On Windows Radeon iGPU (25.10.30.02), all eight exact early-exit variants completed with 768/768 lane words matching and zero GPU-assisted validation errors or race reports. This covers the 64- and 128-thread emulated case with #4247. Details in #166. AI-assisted.
|
Verdict: approve (nits only). The change is correct and the new test is a real regression test. Two checks I ran myself, in a clean worktree at
Why one exit node is exact rather than approximate: the region closure in Extra evidence: a loop inside the region with an early exit to the join fails on Nits:
AI-assisted review. |
|
Thanks all for the testing and reviews at @SweatierKey, @Atomic258, @justr4mzi, @Kam471, @whattheflop: thank you for the Linux, Windows CPU and GPU runs and the negative controls. @whattheflop, the combined run with #4247 on Radeon is very helpful for the exact exit sequence, since that is the part I could not verify here (no GPU on this machine). @Flyander, thanks for the approval. @wavehs, thanks for the careful review and the extra loop-with-early-exit case:
AI-assisted. |
a54ea0e to
28b20ea
Compare
|
Rebased onto main at 3eb4410 to clear a docs/design.md conflict (my new row sits next to the Workgroup memory limit row, which main had just edited). New head 28b20ea, code and test unchanged. Rechecked on Linux x86_64, CPU only (no GPU on this machine): compileall clean, |
|
Verified the folded-region regression itself on the GPU at Negative control: restored just Method: used the test's unmodified |
|
Thanks @Kev-Ball, that is really useful. I could only test on CPU here, so a run on real 32-lane hardware with a negative control that fails on exactly the taken-branch cases is the check I was missing. Much appreciated. |
|
Tested 28b20ea merged with main 98fa503 on Linux (Python 3.12.16): pass - tests/semantic/test_wave64_emulate_opt.py 23 OK, tests/test_docs_*.py (10 files) OK; negative control: upstream/main tools/wave64_emulate_opt.py with the new test: 4 failures (the four taken-branch subtests: 2 cmp/branch pairs x 64 and 128 threads, as the docs row says); the not-taken cases pass on main as expected. I read the sub-CFG exit-node change and the new design.md row and found no issue. Not GPU-verified, as the PR states. |
|
Thanks @kapitche for running the suite and the negative control against main, and for reading the exit-node change. Glad the four taken-branch subtests fail on main and pass here as the docs row describes. |
|
Verified merged with current main: the CPU coverage genuinely pins the fix — the new folded-region test passes with your optimizer and fails 122 != 1 lane 3 in all four taken-branch subcases with main's (re-run here), and the rest of the neighbourhood is green (emulate_opt 23, translate 596 in the venv, cfg_structure 18,228 graphs, docs guards). Two review notes rather than blockers: the contract row is updated but no standalone semantic .asm fixture accompanies the rule change — please add one per the translator-rule convention; and the row's phrase against the native wave64 translation oversells the new test, which compares emulated output to expected values, not to a native run. No CI checks were reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/design.md
…ign.md row says what the test compares against
28b20ea to
30fd24a
Compare
|
Rebased on main. The fix itself already landed with the 4c17a68 merge, so the branch now only adds |
|
Tested 30fd24a on AMD Radeon RX 7900 XTX (RDNA3, subgroup 32..64), AMD proprietary 26.10.1, Windows 11, MSVC 19.44: no regression against
The failures are the same on This is a regression check on AMD at 32-wide and 64-wide; I did not check whether any GPU fixture reaches the folded-EXECZ case this PR fixes. AI-assisted (Claude wrote the test script and read the logs); the runs are from my machine. |
Claimed in the coordination issue as: new SHADER item (claim comment)
What and why
Under
--wave64-emulate, a folded lane-locals_cbranch_execzregion could ignore a scalar branch that leaves the region early. Example:Native wave64 (structured and
--dispatch-loop) leaves v4 alone on every lane, as the ISA says. The emulated translation added 21 on every lane that entered the region, with subgroup size 32 or 64.Cause:
find_local_exec_foldsintools/wave64_emulate_opt.pybuilt the region's sub-CFG from the edges inside the region only. The inner block's edge toskip(the join) was dropped, socfg_structure.structuresaw a straight line and put the next block in with no%pcguard.emit_folded_regionstored the right%pcfor the branch and then ran the next block anyway.Fix: edges to the join now go to an exit node
sub_endin the sub-CFG, so later blocks of the region get their%pcguard._drop_tree_blockremoves the exit node from the tree before_unwrap_known_pc_guards, so it emits nothing. Regions without such an exit edge get the same tree as before, and the region is still folded (the test checks for one switch case).Found with a local differential: cf_diff-style wave64 programs (plus cross-lane leaves) translated as compute shaders, emulated vs native vs
tools/cf_ref.py. I minimized it from one program out of about 1,800.Tested
All on Linux x86_64, Python 3.13.5, on the CPU only. There is no GPU on this machine, so this is not GPU-verified.
test_folded_region_scalar_branch_to_join_skips_the_restintests/semantic/test_wave64_emulate_opt.py. It covers taken and not-takens_cbranch_scc0/scc1to the join at 64 and 128 threads on the file's barrier-checking workgroup interpreter, and it asserts that the region is still folded. Onmain(03b09a08) the 4 taken-branch subtests fail (for example122 != 1 : lane 3). With the fix the whole file passes (23 tests).python -m pytest testswith llvm-mc 22.1.8 and Debian spirv-tools on PATH: 13,895 passed and 11 failed. Those 11 are the same ones that fail onmainand are already claimed elsewhere:test_loop_ballot_barrier(tests: test_loop_ballot_barrier follows #2089's structured wave64 emulation (main red since 1cc7497b) #3995),test_mutationsv_mul_legacy anchor (tests/semantic: re-anchor the v_mul_legacy_f32 mutation after the flush change #3883),test_cmp_class_f64rejected forms (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),test_u16_high_halfd16 spirv-val (rdna2spirv: register the buffer-format table constants before the dump #4466), andtest_fma_khr(FMAKHRis unknown to this older spirv-tools).test_loop_ballot_barrier.pywith this change: 15 passed.python -m compileall -q tools tests: clean.python -I make_game.py --help: OK.node --test tests/test_*.cjs: 47 passed.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.