Repository navigation
wave64_halves: track unsigned v_dot*c_u32_* in RMW_DEST and mirror sgpr_imm scalar folds - #8810
DatGuyShorty wants to merge 1 commit into
Conversation
…pr_imm scalar folds
|
Tested
No fixture in that harness uses AI-assisted (Claude Code). |
|
Tested
No game files. AI-assisted (Antigravity / Gemini 4 Neon). |
|
AMD RDNA2 GPU-suite check of Same per-fixture results as main: 247 translated, 247 pass spirv-val; 224/241 passed, 17 skipped, 0 failed on both. No fixture changes status (this suite has no fixture aimed at the new rule, so the rule itself is covered only by the semantic test). |
|
Verified head
AI-assisted. |
|
macOS arm64 verification (Apple M3 Pro) Tested PR head Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2.
+1 file / +3 tests over the baseline, no new failures. The two Negative control: the
Tier A means "observable results do not change when the wave is cut into two 32-lane halves", i.e. safe to run partitioned. An accumulating Spot-checks of the newly mirrored folds (the class of thing that silently breaks a partition decision):
All 21 operator names the new docstring lists do appear in Suggestion for that last point: the docstring now asks future editors to keep No functional issues found. No game files. AI-assisted. |
tanbentam
left a comment
There was a problem hiding this comment.
Tested 0334ea7a1 on Windows 11, CPython 3.12.10 (CPU-only via spirv_wave_interp.py, synthetic shaders, no game files): pass.
- Applies cleanly onto
main867d922f0;scripts/check_no_game_data.pypasses on both files. - Negative control (PR test against unmodified
main867d922f0): fails in 57 subcases (v_dot*c_u32_*and the 24 scalar-foldADD_TID_ENABLEcases). - With the fix:
test_wave64_halves_dotc_lit_sgpr.py: 3/3 OK (all subtests pass)test_wave64_halves.py: 125/125 OKtest_wave64_subgroup_ops.py: 6/6 OKtests/test_wave64_graphics_scan.py: 19/19 OK (2 skipped)tests/test_wave64_pipeline_audit.py: 14/14 OK
- Source audit against
tools/rdna2spirv.py: verified everyself.sgpr_imm[...]assignment (s_abs_i32,s_sext_i32_i8/16,s_min/max_i32/u32,s_add/sub_u32/i32,s_lshl1..4_add_u32,s_xor/andn2/orn2/nand/nor/xnor_b32,s_bfe_u32/i32,s_absdiff_i32, plus the mask exclusion ands_or_b32omission); the formulas inliteral_sgprmatchrdna2spirv.pybit-for-bit. - Minor PR-description note (code itself is accurate): the description's list of ops "previously handled" by
literal_sgprmentionss_or_b32,s_ashr_i32,s_brev_b32,s_mul_hi_*,s_cselect_b32,s_bcnt*, etc., whichliteral_sgprdid not previously fold (andrdna2spirv.pydoes not record insgpr_imm).
AI-assisted.
|
The 32-wide half of the check: tested
Not run: the full |
|
Reviewed 0334ea7, code read (CPU), AI-assisted: LGTM. The added |
|
Independent check on Windows (no game files, no LLVM). The new Run on Windows 11 (10.0.26100), CPython 3.15.0,
Code read:
AI-assisted review (OpenCode). |
|
Checked Tests
Corpus, counts only. 13,405 wave64 VS/PS/GS shaders (2,236 VS, 10,974 PS, 195 GS). The other 1,127 graphics shaders of the copy are wave32 and get no tier.
0 of the 13,405 change tier, and 0 change their reason list. None of the 14,532 graphics listings contains a How the count was made. One pass of this head's No game data, no GPU. AI-assisted (ZCode). |
Claim: #8683 (comment)
Depends on: none
Cause & Fix
Fixes two soundness gaps between
tools/wave64_halves.pyandtools/rdna2spirv.py:Unsigned dot-accumulate instructions missing from
RMW_DEST(v_dot2c_u32_u16,v_dot4c_u32_u8,v_dot8c_u32_u4):v_dot2c_u32_u16,v_dot4c_u32_u8, andv_dot8c_u32_u4accumulate intovdst(D.u = dot(S0, S1) + D.u) and are already listed as read-before-write intools/rdna2spirv.py(read_before_write_vgprsat line 15826 andreg_reads_writesat line 16087).tools/wave64_halves.pyonly hadv_dot2c_f32_f16,v_dot2c_i32_i16,v_dot4c_i32_i8, andv_dot8c_i32_i4inRMW_DEST,operands(ins)omitteda[0](vdst) fromsrcsfor the unsigned variants.transfer()dropped existing taint (LANE,RNK,CNT,X,CTRL) and rank/base provenance onvdst, and the wave-uniformity pass (st[u]/st[ua]at lines 1030–1035) marked a lane-varyingvdstaccumulator as wave-uniform wheneverS0andS1were uniform. A subsequentv_readfirstlane_b32orv_readlane_b32onvdstwas then misclassified as Tier B (readfirstlane-uniform/readlane-uniform), which also causesrdna2spirv.py(uniform_readlane) to elide the cross-lane read and use each lane's own varying register in2x32.v_dot2c_u32_u16,v_dot4c_u32_u8, andv_dot8c_u32_u4toRMW_DEST.Analysis.literal_sgprmissing 24 scalar constant folds thatrdna2spirv.pywrites intoself.sgpr_imm:tools/rdna2spirv.py(mubuf_addr, lines 3611–3645), when a MUBUF/MTBUF instruction has noidxenand V# word 3 (s[r+3]) is inself.sgpr_immwith bit 23 (ADD_TID_ENABLE,0x00800000) set,rdna2spirv.pyfoldstid = Trueat compile time and setsidx = self.wave_lane().tools/wave64_halves.py(add_tid_lane, lines 523–538),LANEtaint is added for non-idxenbuffer operations only whenself.literal_sgpr(n, i, w3)returns an integer with bit 23 set; whenliteral_sgprreturnsNone,add_tid_lanereturns0(assuming a run-time V# withADD_TID_ENABLEclear).literal_sgprpreviously handled onlys_mov_b32,s_and_b32,s_or_b32,s_lshl_b32,s_lshr_b32,s_ashr_i32,s_not_b32,s_brev_b32,s_bfm_b32,s_pack_ll_b32_b16,s_pack_lh_b32_b16,s_pack_hh_b32_b16,s_mul_i32,s_mul_hi_u32,s_mul_hi_i32,s_cselect_b32,s_cmov_b32,s_bcnt0_i32_b32,s_bcnt1_i32_b32,s_ff0_i32_b32,s_ff1_i32_b32,s_flbit_i32_b32,s_flbit_i32, ands_bitreplicate_b64_b32. When V# word 3 was produced by any of the remaining 24 scalar operations thatrdna2spirv.pyfolds intoself.sgpr_imm(s_abs_i32,s_sext_i32_i8,s_sext_i32_i16,s_min_i32,s_max_i32,s_min_u32,s_max_u32,s_add_u32,s_sub_u32,s_add_i32,s_sub_i32,s_lshl1_add_u32,s_lshl2_add_u32,s_lshl3_add_u32,s_lshl4_add_u32,s_xor_b32,s_andn2_b32,s_orn2_b32,s_nand_b32,s_nor_b32,s_xnor_b32,s_bfe_u32,s_bfe_i32,s_absdiff_i32),rdna2spirv.pyfoldedADD_TID_ENABLEintoidx = wave_lane()whilewave64_halves.pyreturnedNonefromliteral_sgprand misclassified the shader as Tier A (reasons=()).Analysis.literal_sgpr(including the mask-operand exclusion on bitwise ops matchingrdna2spirv.py).Overlap Check
Audited all open PRs and recent coordination threads (
#8344,#8504,#8683):literal_sgpr,add_tid_lane, orv_dot2c_u32_u16/v_dot4c_u32_u8/v_dot8c_u32_u4intools/wave64_halves.py.#4373edits line 90 ofRMW_DEST(v_fmac_legacy_f32), while this PR edits line 91 ofRMW_DEST(v_dot*c_*);#7014cachesoperands()includingRMW_DEST.Tests & Verification
tests/semantic/test_wave64_halves_dotc_lit_sgpr.py(3 test methods / 108 subtests):origin/main867d922f0):python -m unittest discover -s tests/semantic -p test_wave64_halves_dotc_lit_sgpr.py -v->
Ran 3 tests in 1.406s — FAILED (failures=57)(all 9 unsignedv_dot*c_u32_*subtests failed with'A' != 'C'or'B' != 'C', and all 48add_tid=Truebuffer load/store subtests across the 24 scalar ops failed with'A' != 'C').python -m unittest discover -s tests/semantic -p test_wave64_halves_dotc_lit_sgpr.py -v->
Ran 3 tests in 2.086s — OK(all 108 subtests pass, including1x64vs2x32execution ontests/semantic/spirv_wave_interp.pyproving actual memory/output divergence on lanes 32..63 for Tier C cases and exact1x64 == 2x32equality for Tier A/B controls).python -m unittest discover -s tests/semantic -p test_wave64*.py->Ran 238 tests in 27.494s — OKpython -I tests/test_wave64_graphics_scan.py->Ran 19 tests in 0.147s — OKpython -I tests/test_wave64_pipeline_audit.py->Ran 14 tests in 0.997s — OKpython -I tests/test_make_game_wave64.py->Ran 38 tests in 0.719s — OKpython -I tests/test_semantic_translator_use.py->Ran 3 tests in 3.063s — OKpython -I tests/test_report_paths.py->Ran 22 tests in 7.501s — OKpython -m compileall -q make_game.py tools tests-> exit 0python -I scripts/check_no_game_data.py tools/wave64_halves.py tests/semantic/test_wave64_halves_dotc_lit_sgpr.py-> exit 0Environment
spirv_wave_interp.py; no game files, no GPU test required).