Repository navigation
wave64_emulate_opt: guard 32-bit opposite-half and live-SCC mask barriers (SHADER-W64-FOLD-B32-MASK-BARRIERS) - #1735
Conversation
…iers (SHADER-W64-FOLD-B32-MASK-BARRIERS)
lixonik
left a comment
There was a problem hiding this comment.
Independent A/B on native Windows / CPython 3.12.1 at 499b6bce and its merge base 3de22a19. Running the four new B32MaskBarrierTests against the merge-base implementation reproduced 11 failures, including the multi-wave guard and opposite-half cases. At the PR head all 17 barrier tests and all 33 wave64 optimizer tests passed.
AI-assisted. Hand-written fixtures and the CPU workgroup interpreter only.
|
I checked the wave64 mask changes on an RTX 4090 (native Windows 11, NVIDIA 616.64). I used the same eight hand-written compute shaders at parent
On the head, all eight modules passed |
|
Tested
For anyone tracking it: this PR doesn't touch the fold gap I described on #808, where a region that contains the last block, ending in a conditional branch with no A small test note: in |
Address @adrianmjim's review note on ProjectLeonida#1735: fix the active-lane comment (36..63, not 36..47) and assert expected outputs across all 64 lanes (0..15, inactive 16..35 staying 0, and 36..63 preserving untouched high half state) for all nine EXECZ-region cases.
|
Thank you @adrianmjim for the RX 7900 XT full-suite run and the sharp test note! Updated |
Item ID: SHADER-W64-FOLD-B32-MASK-BARRIERS
Claim: #1608 (comment)
Depends on: none
Summary
Follow-up to @whoalin1's finding (#1608 (comment)): aligns
tools/wave64_emulate_opt.py(_classify_block_body,find_local_exec_folds,_insn_may_barrier_with_meta, and_is_uniform_scc_safe) with all 32-bit wave64 lane-mask barrier/vote paths lowered bytools/rdna2spirv.pyunder--wave64-emulate.Root cause
Three 32-bit mask paths in
tools/rdna2spirv.pyemitwave_mask/g_vote(x_round/x_split/OpControlBarrier) under--wave64-emulate, but were missed bytools/wave64_emulate_opt.py:_mask_b32_src(rdna2spirv.py:6095-6110) ons_mov_b32,s_cselect_b32,s_not_b32, andMASK_SOP2_B32(independent of SCC liveness).scc_logicvotes (rdna2spirv.py:6134-6156) on_SOP2_B32_LOGIC(s_and/or/xor/andn2/orn2/nand/nor/xnor/not_b32) when writing a mask destination (exec_lo/hi, orvcc_lo/hiwith mask) or reading same-half / single-half lane-mask sources.wave_maskons_*_saveexec_b32/s_*_wrexec_b32(rdna2spirv.py:11163-11215) when reading a high-half mask source or saving intoexec_hi/vcc_hi(independent of SCC liveness).Before this change, folding an
s_cbranch_execzregion containing any of these instructions trippedAssertionError: wave64 emulation: x_split inside a folded lane-local region, and multi-waveplan_structured_emulationmisclassified wave-divergent guards containing them asinline_sync_free.Changes
tools/wave64_emulate_opt.py:_mask_half,_mask_b32_dst_half, and a single shared_mask_chk_may_barrierhelper used by_classify_block_body,find_local_exec_folds, and_insn_may_barrier_with_meta._MASK_CHK_B32_MOV,_MASK_CHK_B32_LOGIC,_MASK_CHK_B32_CSELECT, and opposite-half checks on_ALL_SAVEEXEC_WREXEC_b32ops._is_uniform_scc_safeto also detectvcc_lo/vcc_himask writes via_mask_b32_dst_half.s_and_b32 vcc_lo, vcc_lo, -1with dead SCC) continue to fold with 0 barriers.tests/semantic/test_wave64_emulate_barriers.py: addedB32MaskBarrierTestscovering unit barrier prediction, all 9 foldeds_cbranch_execzcases (64-thread workgroup interpreter +spirv_asm.assemble), a same-half dead-SCC positive fold control, and a 128-thread multi-wave divergent guard test (reverse_order=False/True).docs/design.md: added contract-table row for--wave64-emulate32-bit opposite-half and live-SCC barrier guards.Verification
spirv-val, or retail game files)python3 -I tests/semantic/test_wave64_emulate_barriers.py: 17/17 OKpython3 -I tests/semantic/test_wave64_emulate_opt.py: 33/33 OKpython3 -I tests/test_wave64_emulate_opt_cfg.py: 26/26 OKpython3 -I scripts/run_semantic_tests.py tests/semantic: 487 files, 6,283 tests, 0 files failed (76 s)python3 -m compileall -q make_game.py tools tests: OKpython3 -I tests/test_text_write_line_endings.py: 3/3 OKpython3 -I scripts/check_no_game_data.py tools/wave64_emulate_opt.py tests/semantic/test_wave64_emulate_barriers.py docs/design.md: OKB32MaskBarrierTestsagainst unpatchedmain:tools/wave64_emulate_opt.py): 11 failures (all 9 foldeds_cbranch_execzcases crash withAssertionError: wave64 emulation: x_split inside a folded lane-local region, plus the unit check and 128-thread multi-wave guard check).