Repository navigation
rdna2spirv, lane_masks: fix wave64 split SGPR-pair masks, emulate x_mcache, and b64 mask+imm tracking (SHADER-371) - #2222
Conversation
…cache, and b64 mask+imm tracking
|
Regression check of
As with #2221, the new rules (split SGPR-pair masks, |
|
GPU check on an AMD Radeon RX 9070 (RDNA4, gfx1201, 32..64 subgroups, so native wave64 too), Windows 11, Vulkan SDK 1.4.363. Tested head 804f4ae merged onto
AI-assisted (Claude Code); runs on my machine. |
|
Independent verification on AMD Radeon RX 7800 XT (Vulkan 1.4.359 / driver 24.20.19.05 / Windows 11): pass. Tested
Code read:
AI-assisted. |
|
Tested 804f4ae on Windows 11 Home 26300: pass, no failures on either GPU. AI-assisted (Claude Code). Hardware: AMD Ryzen 5 7600X; iGPU AMD Radeon(TM) Graphics (RDNA2, subgroup 32..64), AMD driver 24.10.24 (Vulkan driver 2.0.302); NVIDIA GeForce RTX 5060 Ti, driver 610.88 (subgroup 32..32). MSVC 14.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.12.10. Test programs built at 804f4ae with
On the iGPU, 77 of the skips are its 128-byte push-constant limit (#2048 isn't in this base), so the native wave64 run judges fewer tests there than on a desktop RDNA2 card.
|
|
Tested 804f4ae on Windows 11 (26200) on both GPUs of a two-GPU PC: pass. I ran
A first run against a stale build of mine failed |
…4 mask ballot row The 06451e4 tree had two Wave64 mask ballot rows (the old short one and the PR #2222 superset); the ec8ec4c row dedup merged them into one row but kept three subset sentences from the old row after their supersets: the short lane_masks.py sentence (without the _b64-immediates/#1792 clause), the short s_bcnt/s_ff reconstruct sentence (without the v_mbcnt/mask_half clause), and the short RX 9070 XT GPU-checked sentence (2 test files instead of 4, without the CPU-checked parenthetical). Removing the three subset sentences restores the row byte-identical to the PR #2222 superset row. No code change.
Item:
SHADER-371(claimed in #1902 (comment), tracked in #2078)Summary
Fixes four wave64 lane-mask /
--wave64-emulatebugs found by whole-workgroup loop-ballot & barrier testing (keeping disjoint diff hunks from #615, #663, #1999, #2000, andSHADER-370):--wave64-emulatewave_maskx_mcachehigh-dword invalidation (tools/rdna2spirv.py):Gen.wave_maskpreviously keyedself.x_mcacheonly onself.x_tokof("sgpr", a["r"])(the low dword). Whens[r+1]was rewritten between two 64-bit mask reads in the same block (for examples_bcnt1_i32_b64 s6, s[14:15]; s_mov_b32 s15, 0; s_bcnt1_i32_b64 s7, s[14:15]), the second read reused the stale cached(lo, hi)exchange instead of starting a new exchange.wave_masknow keysx_mcacheontuple(self.x_tok.get(("sgpr", a["r"] + i), ("start", a["r"] + i)) for i in range(a.get("n", 1))).tools/rdna2spirv.py,tools/lane_masks.py):s[r:r+1]has its two halves written separately (MASK_LO/MASK_HI, or one mask half paired with a0/-1EITHERconstant, including across loop back-edges),Gen.holds_lane_masknow matcheslane_masks.kind()(usinganalyse(..., include_either=True)), andGen.mask_srcselectss[r+1]forwave_lane() >= 32ands[r]for< 32instead of readings[r]on all 64 lanes._b64mask + immediate tracking (tools/lane_masks.py):_b64COPIESof immediates intovcc(s_mov_b64 vcc, 0x3F) and_b64BITWISEops combining a mask source orvccdestination with immediate operands (s_and_b64 s[14:15], vcc, 0xFF), while keeping_b32mask + non-0/-1immediate into an SGPR as plain data per rdna2spirv: a constant used as a lane mask through an SGPR (or a b32 SOP2 on EXEC) gives each lane its bit #1792.v_mbcnt_lo_u32_b32/v_mbcnt_hi_u32_b32half-mask selection (tools/rdna2spirv.py):self.mask_half(a[1])when known in wave64 sov_mbcnt_lo_u32_b32onvcc_hi(MASK_HI) readswave_mask(a[1])[1]andv_mbcnt_hi_u32_b32onvcc_lo/exec_lo(MASK_LO) readswave_mask(a[1])[0].tests/semantic/test_loop_ballot_barrier.py(15 synthetic whole-workgroup semantic tests covering divergent loop ballots, loop-carried split SGPR pairs,x_mcachehigh-dword invalidation,_b64mask+immediate ops,v_mbcnthalf-mask selection, and uniform loops_barrieracross native wave32, native wave64, and--wave64-emulate) andtest_b64_mask_imm_and_include_eitherintests/test_lane_masks.py.Wave64 mask ballotrow indocs/design.md.Testing (AI-assisted)
Tested on Windows 11 (Python 3.14, CPU semantic interpreter; zero game data committed):
python -m compileall -q make_game.py tools tests— OKpython -I make_game.py --help— OKpython -I tests/test_lane_masks.py— OKpython -I tests/semantic/test_loop_ballot_barrier.py -v— 15/15 OKpython -I tests/semantic/test_mask_src_sgpr_const.py— 7/7 OKpython -I tests/semantic/test_scalar_bitcmp.py— 21/21 OKpython -I tests/semantic/test_scalar_alu_shifts.py— 22/22 OKpython -m unittest discover -s tests/semantic -p "test_wave64_*.py"— 82/82 OKpython -I tests/test_docs_links.py— 5/5 OKpython -I tests/test_text_write_line_endings.py— 2/2 OK