Repository navigation
Translator: a lane mask read as data gives the wave's bits (SHADER-21 part 1, #210) - #293
simonbronk wants to merge 5 commits into
Conversation
|
Tested I built the Vulkan harness from this head on Ubuntu 26.04.1 LTS and ran
Coverage is limited to the five compute fixtures on the PR head. The requested corpus comparison remains open. AI-assisted verification. |
|
Ran this on a second AMD GPU with native wave64: RX 6700 XT (RDNA2, RADV NAVI22, Mesa 26.3.1, Linux). PR head
AI-assisted (Claude Code): it ran the checks and wrote this summary. No game files. |
|
Tested f721e5f (as pushed) on NVIDIA GeForce RTX 3050 Laptop GPU (Ampere, subgroup 32), driver 610.91, Windows 11 build 26300: pass. AI-assisted (Claude Code).
Toolchain: MSVC 14.44, Vulkan SDK 1.4.363 / SPIRV-Tools v2026.4, llvm-mc 21.1.8 (built with |
|
Code read and CPU tests on Commands:
Findings:
Fable 5.2 AI Assisted review |
|
SHADER-84 follow-up to the RTX 5090 wave32 report. I checked what the memory fuzzer expects and compared the translator before and after this PR. On the reporter's baseline I also ran three synthetic compute cases on Mesa llvmpipe, subgroup size 8. The fixtures verify the eight contributing lanes share a subgroup. For EXEC This isolates a translator defect that produces the reported failure count. Can someone with the original 32-wide setup compare its failing indices or replay the 50 programs on this PR after its rebase? That would tell us whether it accounts for the entire hardware report. AI-assisted. All inputs were synthetic. |
|
I ran the corpus comparison asked for above, plus the suite on RDNA4: RX 9070 XT (gfx1201, native 64-wide subgroups), driver 32.0.32015.16001, Windows 11, native llvm-mc 21. PR head f721e5f vs merge-base 36ace71. |
Runs each FUZZ-7 program natively on the AMD GPU in wave32 and native wave64, with its real group size and EXEC setup, every thread storing its 14 words, and compares them with the model. hw_oracle gains raw kernels (own stores), per-kernel workgroup size and wave64 code objects; the launcher takes name:threads:words tokens. 24,000 programs on gfx1150: 0 mismatches; the permlane FI=0 and DPP8 inactive-source hypotheses hold on the hardware too. Translator mismatches all trace to masks read as data (#293) and permlane (#580). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Replay of
No game data used. AI-assisted test execution and reporting. |
|
Fuzzer check of f721e5f on Windows 11, NVIDIA GeForce RTX 2080 Ti (Turing, 32-wide subgroups), driver 621.14, with one case worth re-checking after the rebase. The same 200 programs ( Minimizing the head's wave32 failures ( It runs in a 20-thread group, so a partial wave. The base is 1,396 commits behind No game files. AI-assisted (Claude Code). |
f721e5f to
7874f5f
Compare
|
Rebased on Conflicts resolved
Tested on Windows 11 with native llvm-mc 21.1.8:
Fuzzer, honestly:
baptisteba's point 2 (a mask ANDed with an unknown register, then used as a selector): still a hypothesis. I found no such case in the fuzzer runs. A corpus count of @esteban-dcp: the rebase is done, so TEST-88 ( AI-assisted (Claude Code). No game data used. |
…U under random EXEC Seeded integer VALU programs run on every lane of a wave32 or wave64 wave with EXEC rewritten between instructions: compares into SGPR masks and VCC, v_cmpx, v_cndmask on the masks, carry-out/carry-in forms, v_mad_u64/i64 with a mask carry-out, 16-bit op_sel half writes and 32-bit ops. A per-lane ISA model is compared with rdna2spirv run in tests/semantic/spirv_wave_interp.py, optionally with the hardware through tools/hw_oracle. Known divergences (VCC data read as a mask, ItsNotRexed#2206; a mask read as data, ItsNotRexed#293) only with --known. AI-assisted.
… every encoding and source kind A separate ISA model for 55 integer opcodes (VOP1/VOP2 as e32 and e64, VOP3-only ops, VOPC e64 + v_cndmask) with VGPR, SGPR, inline, float-inline and literal sources within the encoding and constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle. A mask read as data (ItsNotRexed#293) only with --known. AI-assisted.
|
Correction to my comment above (now edited): the |
The corpus is disassembled for gfx1013 without +wavefrontsize64, so the 64-bit SDST of a wave64 v_cmp_*_e64 or carry-out prints as one register (v_cmp_gt_f32_e64 s0, ...) while the wave writes s[0:1]. lane_masks.py took it as s0 alone, so s1 was unknown and a later s_and_b64 / s_or_b64 of two compare results took the 64-bit data path: SCC was each lane's own bit instead of the wave's vote, and s_bcnt1_i32_b64 of it counted data bits. lane_masks.step/analyse take the shader's wave size; mask_sdst widens a one-register VALU mask destination to the pair in wave64. rdna2spirv's valu_mask_dst writes both registers: since 804f4ae a pair read as a wave64 mask takes lanes 32-63 from the high register, which the one-register write left stale. Corpus (26,503 shaders): one-register SDSTs in 18,866 of 23,839 wave64 shaders; 18,868 translate differently, all wave64; the same 26,501 still translate and pass spirv-val as on main. New GPU test cs_w64_sdst_pair (corpus form) and tests/semantic/test_w64_sdst_pair.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… part 1, ItsNotRexed#210) A register holding a lane mask keeps only this lane's bit (0 or ~0). When an instruction reads it as a plain value (a VALU source, store data, s_lshr / s_and with a constant, s_lshr_b64, s_add, exec_lo/hi or vcc_lo/hi as a value), hardware sees the whole wave's mask; the translation saw the lane's bool. lane_masks.data_reads finds those reads, leaving mask readers (bcnt, ff1, mbcnt, cmp, bitcmp), copies, mask-to-mask bitwise ops, saveexec, the v_cndmask selector, carry-ins and EXEC/VCC writes alone. The translator gathers each half with OpGroupNonUniformBitwiseOr (or the emulated wave64 round) before the instruction and returns it from load_reg / src_u. New GPU tests cs_wm_as_data, cs_wm_as_data2 (wave64) and cs_wm_as_data32 (wave32), all failing before; data_reads unit tests; design.md row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…exec_lo takes the lane's bit Follow-up to the lane-mask-as-data change (ItsNotRexed#210), rebased on main's 64-bit SALU data path (src64_data / dst64_data): - s_and/or/xor/andn2/orn2_b64 and s_cselect_b64 whose lane-mask sources are read as data (mask_data64) take main's data path on both words instead of the per-lane mask path. - mask_src reads the raw register, so the v_cndmask selector stays a mask when the same register is also a value operand. - A register written to exec_lo turns on the lanes 0-31 whose bit is set (the same as non-zero for a one-bit-per-lane mask), so a mask combined with data and moved to EXEC no longer turns on every lane; in wave64 lanes 32-63 keep their EXEC (exec_half_write). - tests/semantic: test_salu64_bitwise_data and test_scselect_b64_data expected v_mov_b32 vN, s<mask> to give the lane's bool; it gives the wave's bits (ItsNotRexed#210). New GPU tests cs_wm_as_data64 and cs_wm_as_exec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gathered when read as data A mask copied into a VGPR (v_mov_b32 v7, s16) and then given data in one lane (v_writelane_b32 v7, s15, 27) was gathered as the wave's bits when read as data, so lane 27's data set bit 27 in every lane. Mark such a VGPR (and VGPR copies of it) so data_reads reads it lane by lane, as main does (crosslane_fuzz seed 6, cs_xl32_600042, which passed on main and failed with this PR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its at the copy With ItsNotRexed#2290 merged, a v_mov_b32 copy of a mask into a VGPR is an EXEC-gated write, so lanes EXEC leaves off keep their old VGPR. Gathering the mask at a later read (the store) then took those lanes' old words as set bits and overwrote them: cs_mask_vgpr_exec failed on AMD and on the RTX 5070. Hardware writes the wave's bits to the active lanes, so the copy now reads its mask source as data (lane_masks.data_reads) and the VGPR holds data from there on. cs_mask_vgpr_exec2 uses a mask that differs per lane: lanes 0-3 get 0x1f, lanes 4-31 keep 0xdeadbeef; main gives 0xffffffff in lanes 0-3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-188: CPU bisection and RTX 5070 (616.56) confirm original seed 1 programs 100007/100008 now match main f847748 after #2290. On main a 60-program run still has four ordinary mismatches: 100014/100023/100026/100034. In CPU replay, replacing a single v_mov mask source with its expected scalar word eliminated all 30/31/44/58 wrong words respectively. Exact #293 head 1c9faf7 and its base 6a6704d both have 6 native wave32 and 8 emulated wave64 ordinary mismatches across 60 programs; head changes some output words but not the failing IDs. Not a merged-main test. No rejected programs or harness errors. Main semantic suite: 7322 tests, one expected failure. AI-assisted synthetic validation.
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-21 integration handoff at 1c9faf7. Main f847748 plus current #2231 (8276a25) merges cleanly. Replaying the first #293-only commit 14cfce2 onto that tree conflicts in six files. Please preserve both per-instruction EITHER and reads tracking in analyse(), and cur_either plus mask_as_data() during emission, along with #2231's widened destination writes. An author rebase would unblock the RTX comparison. No integrated GPU result. AI-assisted.
1c9faf7 to
004e31f
Compare
|
Rebased on #2290 and this PR together broke Fix (004e31f): gather at the copy. Hardware writes the wave's bits to the active lanes, so
That gives the same result on AMD (native) and on the RTX 5070 ( Rechecked on the rebased head:
@bvtterbroot @Dom-in, here is the fuzz rerun against the new
The "other cause" I mentioned earlier was this interaction: gathering a VGPR whose lanes EXEC had left off. The gap that is left is listed in the body and in AI-assisted (Claude Code). Counts only, no game data. |
kacper-serewis
left a comment
There was a problem hiding this comment.
Updated head 004e31f includes #2231 at 8276a25 and merges cleanly with f847748. Integrated tree 7dcb89ba2e39a7400c6d1b3f9db2b6d1dbdcd9b5 passed CPU interpreter replay for all four later SHADER-188 seeds (prior main mismatching words 30,31,44,58; integrated 0 each), plus original controls 100007/100008 and nine handwritten predicates. RTX comparison queued on this exact tree. AI-assisted, synthetic inputs.
|
GPU result for this PR on an RTX 4070 (NVIDIA 621.01), Windows 11, llvm-mc 23.1.6, |
kacper-serewis
left a comment
There was a problem hiding this comment.
Integrated RTX result for SHADER-21/188 on tree 7dcb89ba2e39a7400c6d1b3f9db2b6d1dbdcd9b5 (includes #2231). On RTX 5070 driver 616.56 all six tracked seeds matched. Seed 1, 60 synthetic programs, 30 per mode (native wave32/emulated wave64): 45 exact, 15 hypothesis-flagged differences on the same seeds as main, zero unflagged differences versus four on main. Eight-program prefix: seven exact, one flagged. No rejects, skips or harness errors. A hypothesis flag does not identify the cause. AI-assisted.
|
Tested 004e31f on RTX 4070 Ti SUPER (Ada), driver 621.14, Windows 11 Pro 26H2: pass. Follow-up to my earlier replay on the old head, same method:
No game data used. AI-assisted test execution and reporting. |
Depends on: #2231
SHADER-21, part 1 (#210): a lane mask read as plain data now gives the wave's bits, not this lane's bool.
The translator keeps one bit per lane in a register holding a lane mask (0 or 0xffffffff). Hardware has the whole mask there. Any instruction that reads such a register as a value got the lane's bool instead. Examples:
v_mov_b32 v1, s20followed by a store;s_lshr_b32ors_and_b32 …, 0xffof a mask; ans_mov_b64copy read back withv_mov_b32;v_readlaneof a parked mask;exec_lo/vcc_hiused as values. #210 measured this on NVIDIA with emulation. The tests below show the same result on AMD with native wave64, and in wave32.Change
tools/lane_masks.py: newdata_reads(ins, state), called fromanalyse(..., reads=). It finds registers that hold a mask but that an instruction reads as data. These stay one bit per lane:s_bcnt*,s_ff*,v_mbcnt*,s_cmp*,s_bitcmp*;v_cndmaskselector and carry-ins;tools/rdna2spirv.py:mask_as_datagathers each half (OpGroupNonUniformBitwiseOr, or the emulated wave64 round) before the instruction emits anything.load_regandsrc_ureturn that word for those registers.wave_maskis split sowave_bitscan be reused.s_and/or/xor/andn2/orn2_b64ands_cselect_b64on data now compute each register of the pair. Before, they wrote the low word into both, sos_or_b64 s[56:57], s[2:3], 1lost the high word even with no mask involved.mask_srcreads the raw register. This keeps thev_cndmaskselector a mask when the same register is also a value operand.exec_lowrites turn on a lane when that lane's bit is set ((v >> (lane & 31)) & 1). For a one-bit-per-lane value this is the same as non-zero. Without it, a mask combined with data and moved to EXEC would turn on every lane.docs/design.md: a "Lane mask read as data" contract row, with covered cases and known gaps.Tests
New GPU tests, each failing on
main(measured on the AMD iGPU):maincs_wm_as_data(wave64)v_mov_b32and store,s_mov_b64copy,s_lshr_b32,s_and_b32, writelane/readlane,s_lshr_b64,v_add_nc_u32,s_add_u320 0 0 0 0 0 1 30xfafafafa 0xfafafafa 0x7d7d7d7d 0xfa 0xfafafafa 0xafafafaf 0xfafafafb 0xfafafafdcs_wm_as_data2(wave64)exec_lo,exec_hi,vcc_hi, av_cndmaskvalue,s_or_b32, afterv_readfirstlane; pluss_bcnt1and a mask-selectedv_cndmask, unchanged0xffffffff 0 0xffffffff 0xffffffff 24 2 0xffffffff 0xffffffff0xffff0000 0x10000 0xff 0xff 24 2 0xffff0001 0xffff0000cs_wm_as_data32(wave32)v_mov_b32and store,s_lshr_b32,s_lshl_b32+s_add_u32,v_or_b320 0 0xff00 00xfafafafa 0xfafafaf 0xfafbf900 0xfafafafacs_wm_as_data64(wave64)s_and_b64,s_xor_b64ands_cselect_b64of a mask with a data pair;s_or_b64of data;v_cndmaskwiths20as value ands[20:21]as selector0 0 0xf0f0f0f 0xf0f0f0f 0 0 0xffffffff 00xa0a0a0a 0xfa00fa00 0xf5f5f5f5 0x5fa05fa 0xfafafafa 0xfafafafa 0xff00ff00 0xfafafafacs_wm_as_exec(wave64)s_and_b32of a mask and data, thens_mov_b32 exec_lo0 1 0 1 1 1 1 10 1 0 1 0 0 0 0Each is registered in
check.pyandrun_gpu_tests.py.tests/test_lane_masks.pyaddstest_data_readsfor the classification.tests/test_shader_checks.pylearns about wave32 dump tests other thancs_store.Windows 11, LLVM 21.1.8
llvm-mc, GPU picked withVK_LOADER_DRIVERS_SELECT:run_gpu_tests.pycheck.pyLEONIDA_W64_EMULATE=1LEONIDA_W64_EMULATE=1The skips are the same as on
main: wave64 tests without a 64-wide subgroup, mesh shadersbuild.pydoesn't build, andps_vcc_x2, which runs only in the interpreter. Results:python -m pytest tests -qwithLLVM_MCset: 1478 passed, 6 skipped, 1 xfailed.python -I -m unittest discover -s tests/semantic: OK.python -m compileall -q make_game.py tools tests: clean.Scope and gaps
--wave64-emulate, and in wave32. On 32-wide hardware without emulation, each subgroup sees only its own half, ass_bcnt1already does (GPU test results on RTX 4090 (32-wide subgroups): cs_wavemask fails on main, #73's wave64 tests fail #101). Wave64 PS/VS on 32-wide GPUs stays with SHADER-10.design.md):v_or_b32 v1, s4, s5);s_xor_b32 s0, s4, s5);v_writelaneand stored without av_readlaneback;v_or_b32 vN, s20, s22, written in every lane) under a partial EXEC: the lanes EXEC leaves off get the mask's word where hardware keeps the old VGPR;--wave64-emulate,main1628210): on top of Translator: a wave64 VALU mask SDST printed as one SGPR is the SGPR pair #2231, the same 26,501 translate and passspirv-valas onmain. 21,475 SPIR-V binaries differ frommain(18,868 of them already with Translator: a wave64 VALU mask SDST printed as one SGPR is the SGPR pair #2231 alone), and 2,608 differ from Translator: a wave64 VALU mask SDST printed as one SGPR is the SGPR pair #2231 alone.Rebased on #2231 (2026-11-22). #2231 makes a wave64
v_cmp_*_e64/ carry-out SDST printed as one SGPR the pair. Without it, about 99% of this PR's wave-bit gathers were for pairs that are really masks (98,882 in 9,326 shaders on an oldermain; 775 in 46 with the fix).tests/semantic/test_salu_movrels_lane_mask.py(SHADER-284, added tomainsince) expected the old behaviour for its control: a mask copy read byv_mov_b32gave this lane's bit. That control now expects the wave's bits (5), as on hardware. After the rebase: semantic suite 1647 OK;run_gpu_tests.py170/179 passed, 9 skipped, on both AMD 25.10.36 (native) and RTX 5070 621.24 (LEONIDA_W64_EMULATE=1); the skips are the same as onmain.Rebased on
main1628210 with #2290 merged (2026-11-22, head 004e31f). #2290 (SHADER-21 part 2) made av_mov_b32copy of a mask into a VGPR an EXEC-gated write. Combined with this PR, that broke #2290'scs_mask_vgpr_execon both GPUs: the mask was gathered at the store, so the old words of the lanes EXEC had left off counted as set bits and were overwritten. The copy now reads its mask source as data, gathered at thev_mov_b32, as hardware writes the wave's bits to the active lanes. The VGPR holds plain data from there on. A new GPU test,cs_mask_vgpr_exec2(wave32), uses a mask that differs per lane: lanes 0-3 get0x1fand lanes 4-31 keep0xdeadbeef;maingives0xffffffffin lanes 0-3.tests/test_lane_masks.pyfollows the new shape.After that rebase:
run_gpu_tests.py: 181/196 passed, 15 skipped, on AMD 25.10.36 (native) and RTX 5070 621.24 (LEONIDA_W64_EMULATE=1); the skips are the same as onmain;crosslane_fuzz.py --wave both --w64-nativeon the AMD iGPU, seeds 5 and 6 (--dpp, 50 programs) and 9001 (150): 0 non-hypothesis mismatches in every mode.main1628210 has 2/1/1, 1/0/0 and 4/3/3 (wave32 native / wave64 emulate / wave64 native).AI-assisted (Claude Code). No game data used.
🤖 Generated with Claude Code