Repository navigation
Recompiler: pass and track explicit SRC_SCC in per-lane lowering - #2833
safesearch77 wants to merge 1 commit into
Conversation
Fix three gaps in per-lane (and split-wave64) explicit SRC_SCC (253) handling: - Lower::bridge checked only implicit OPR_SSRC_SPECIAL_SCC operands, omitting Var::Scc from Ir::foreign inputs and skipping read_scc stale tracking when a bridged instruction encoded SRC_SCC (253) explicitly. - lane_masks::reads_scc and compute_scc_liveness missed SDWA scalar SRC_SCC sources (S0=1/VSRC0=253, S1=1/VSRC1=253) and scanned unused primary encoding fields instead of active non-implicit input operands. - Lower::src64 and Lower::src_bit rejected code 253 instead of zero-extending SCC ((zext(scc), 0) and (lane == 0) & scc).
|
Independent parent/head comparison on Windows 11 build 26200, Ryzen 7 5800X, RTX 3060 12 GB (NVIDIA 610.88), rustc 1.100.0 MSVC, DXC 1.9.2602.17, debug. With
Neither run printed AI use: Codex (GPT-6.2 Astra) ran the tests, checked the logs and drafted the report. |
|
RX 9070 / Wine per-lane SCC check at Tested RX 9070 16 GB, RADV GFX1201 / Mesa Exact pinned source copies, with both new CPU test functions copied unchanged to main and an identical local
The local fixture checks native Wave32, native Wave64 and split Wave64 using two hardware Wave32s. Kernel inputs cover zero-extended SCC in scalar/mask sources, true/false/true Three fresh processes per entry/revision, alternating revision order, gave identical per-case outcomes:
Main reports The local collection tests assert on any refusal, so each reports 0 passed / 1 failed / 0 ignored on both revisions, despite the increased coverage on head. Refused cases were never submitted to the GPU. Across 20 final harness invocations there were 0 ignored and 0 capability skips. The matrix evaluated 648 records and performed 522 validated GPU dispatches. Independently recomputed 16,608 kernel lane values, 336 scalar values and 71,760 compute words, including guards: zero mismatches. All 72 HLSL/instruction control shader containers matched byte-for-byte between revisions; each emitted case repeated byte-identically across its three runs. Not tested Graphics entry points, every explicit SCC consumer/encoding, partial-launch EXEC, more than one compute group or logical wave per group in the local matrix, end-to-end fallback, full workspace suite, native Windows, other adapters, retail data, AI use OpenAI Codex (GPT-6; exact serving variant not exposed) audited the diff, wrote local test-only fixtures, ran the paired tests, independently verified raw outputs/source/executable hashes, and drafted this report. Publication authorized by the account owner. |
…RC_SCC tracking, wave32 VALU read64-skip) xcl-dev#2833 (f5a52c3): lane_masks::reads_scc goes pub(super) with SDWA S0/S1 refinement (VSRC 253 only when the S-bit selects the scalar source; v253 VGPR reads excluded), movrels/VOP3-unused-SRC2 exclusions, and implicit-field filtering; lower.rs src_bit/src64 gain the 253 arm (zext(scc) & lane==0), compute_scc_liveness and bridged-SCC input both delegate to lane_masks::reads_scc. Tests: sdwa_and_vop3_src_scc_reads_are_classified_accurately + explicit_src_scc_in_salu_valu_bridge_and_wave_liveness, verbatim. xcl-dev#2834 (653f8f1): Direct DXIL wave32 VALU lane-mask sources skip the 64-bit read (read + 0 instead of read64) for OPR_SREG/OPR_VCC 64-bit operands; 279-line wave32_mask_src_tests module added with one twin delta: #[cfg(all(test, windows))] instead of #[cfg(test)], because validate/runner are Windows-only in this tree until the Phase-D SPIR-V backend lands (same bucket as the other dxil translation test modules in dxil/mod.rs). xcl-dev#2832 (e2ecdfa) triaged SKIP: single-file d3d12x/pso_async.rs need_by_submit wanted-cap change, Windows-only, zero Linux twin. Gates: both checks 0 errors; lib 780/0/1 threads=4 (+2, zero regressions); title e2e 4 passed/1 failed by design, 12 unique FAILs all D3D12.X, 0 non-GPU; retail HOLDS (exit 139 SIGSEGV exe+0x2237320, stubs 20, xgr exactly XAsync/XNetworking/XUser). Lock audit: 0 new lock().
Pass and track explicit
SRC_SCC(253) scalar operands consistently across the per-lane and split-wave64 (WaveSize(32)) Direct DXIL recompiler (crates/xcl/src/gpu/recomp/{lane_masks.rs,lower.rs}).Previously, per-lane lowering had three interlocking gaps whenever an RDNA2 instruction read
SCCvia scalar source code253(src_scc) rather than an implicitOPR_SSRC_SPECIAL_SCCoperand:Lower::bridge(crates/xcl/src/gpu/recomp/lower.rs:1753) checkedoperand(true, "OPR_SSRC_SPECIAL_SCC"), omitting(Var::Scc, zext(s))fromIr::foreigninputs and skippingself.read_scc(b)whenever a bridged instruction (V_CVT_F32_U32 v, src_scc,S_BFE_U32,V_ADD_CO_CI_U32, SDWAsrc_scc, etc.) encoded253explicitly. In compute, split-wave64, and graphics modes (ComputeInit/setup_gfxpre-seedingVAR_SCC = 0),DxilIr::foreignsucceeded whileLwsilently read0(or a stale block-localVAR_SCCwritten by an earlier bridged instruction) instead of the liveVar::Scc; in kernel mode it failed with"it reads register 125 the per-lane form did not pass"unless masked by an earlier bridged instruction in the same block; and partial-blockSCCwrites read after reconvergence bypassed thestalecheck.lane_masks::reads_scc(lane_masks.rs:282) andlower::compute_scc_liveness(lower.rs:1188) only scanned primary encoding fields["SSRC0", "SSRC1", "SRC0", "SRC1", "SRC2", "SOFFSET"]. ForVariant::Sdwa(SRC0 = 0xF9), scalarsrc_sccis encoded in the SDWA extension dword (S0 == 1 && VSRC0 == 253orS1 == 1 && VSRC1 == 253), solane_masksmissed divergent mask-opSCCreads in!wave_branchesandcompute_scc_livenessmarkedscc_live_after = falseinwave_branches(including split-wave64 compute), causingmask_nonzero_sccto skip the whole-wave ballot and hardcodeSCC = false. Scanning raw primary fields without checkingd.ienc.operandsalso caused false positives on unused fields (e.g.SRC2 = 253on a 1-sourceENC_VOP3instruction orOPR_ATTRonV_INTERP_*).Lower::src64(lower.rs:785) andLower::src_bit(lower.rs:475) rejected code253("64-bit source code 253"/"mask source code 253") instead of zero-extendingSCC((zext(scc), 0)insrc64and(lane == 0) & sccinsrc_bit, matchingdxil/lower.rs:732andrecomp/emit.rs:840).Part of #1269
What is in it
crates/xcl/src/gpu/recomp/lane_masks.rs: makereads_sccpub(super), inspect SDWAS0/VSRC0andS1/VSRC1scalar sources viaemit::ext_encoding, and restrict primary-word253checks to active non-implicit input operands (excluding non-plainSRC0, relative-sourceS_MOVRELS_*/S_MOVRELSD_2_B32SSRC0, andOPR_ATTR/OPR_PARAM) (+24 / -5).crates/xcl/src/gpu/recomp/lower.rs: uselane_masks::reads_sccin bothLower::bridgeandcompute_scc_liveness, and handle source code253inLower::src_bitandLower::src64(+13 / -6).crates/xcl/src/gpu/recomp/lane_masks.rs(tests::sdwa_and_vop3_src_scc_reads_are_classified_accurately): verifies non-uniform mask-opSCCrejection for SDWAS0andS1src_scc, acceptance whenS0/S1are0(v253) or afterS_AND_SAVEEXEC_B64, and no false positive on unusedENC_VOP3SRC2 = 253(+48).crates/xcl/src/gpu/recomp/lower.rs(tests::explicit_src_scc_in_salu_valu_bridge_and_wave_liveness): CPU execution andIr::foreignverification across 64-bit SALU & per-lane mask ops (S_MOV_B64,S_CSELECT_B64,V_CNDMASK_B32,S_AND_B64), bridged explicitSRC_SCC(V_CVT_F32_U32,S_BFE_U32), partial-block staleSCCrefusal across reconvergence, and split-wave64compute_scc_livenesswhole-wave ballot preservation before SDWAsrc_scc(+161).Tested
x86_64-pc-windows-gnu:cargo check --offline --workspace --testsgave 0 errors and 0 new warnings (only the 3 pre-existing baseline warnings on8b957bec, none ingpu/).rustc --edition=2021 --testharness compilinggpu::{rdna2_spec, rdna2_xbox, rdna2}andgpu::recomp::{x64_masks, ssa, upper_lanes, lane_masks, lower}(with Windows D3D12/DXC runner plumbing stubbed; no lowering or analysis code modified):8b957bec: all 4red_green_scc_testsfail (0 passed; 4 failed:"unsupported V_CVT_F32_U32 (it reads register 125 the per-lane form did not pass)", missinglane_masksrefusal on SDWAS0=1, VSRC0=253,ballots == 0on split-wave64S_AND_SAVEEXEC_B64before SDWAsrc_scc, and"64-bit source code 253").f5a352c3:107 passed; 0 failed; 1 ignoredacross allrdna2,x64_masks,ssa,upper_lanes,lane_masks,lower, andred_green_scc_testsunit tests.Regression run
xcl-smokeblocks (8b957becandf5a352c3) must be attached from a Windows GPU retail run before marking ready for review.Not tested
cargo test --workspace -- --test-threads=4GPU execution suite (including D3D12 wave32 / split-wave64 / native wave64 dispatch and DXCdxcompiler.dllvalidation) and paired Windowsscripts/smoke.ps1retail runs. Prepared on a Linux CPU host without a Windows GPU or retail title.AI use
Lower::bridge,reads_scc/compute_scc_liveness, andsrc64/src_bitSRC_SCC(253) defects, implemented the fix and unit tests, ran the Linuxrustc --testRED-to-GREEN harness andx86_64-pc-windows-gnuworkspace checks, and drafted this PR description.