Repository navigation
Recompiler: propagate half-local masks through 64-bit bitwise ops and EXEC - #1875
Closed
certified-retart wants to merge 1 commit into
Closed
certified-retart wants to merge 1 commit into
certified-retart wants to merge 1 commit into
Conversation
Contributor
Author
Contributor
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1269, #1598, and #675.
In split-wave64 mode (NVIDIA / 32-lane wave GPUs),
x64_masks::whole_live_outpreviously treated every scalar read of a 64-bit mask register—and every read or write ofEXEC—as requiring the whole 64-bit mask across both 32-lane halves. As a result, anyv_cmp_*/v_cmpx_*feeding a 64-bit bitwise mask chain (s_and_b64,s_or_b64,s_xor_b64,s_andn2_b64,s_not_b64,s_mov_b64,s_cselect_b64,s_*_saveexec_b64,s_*_wrexec_b64, etc.) or feedingEXECfor branchless predication emitted a full cross-halfxcl_x_ballot(LDS write + twoGroupMemoryBarrierWithGroupSyncbarriers + LDS read) even when neither the resulting mask nor itsSCCwas ever observed across halves.Summary of changes
crates/xcl/src/gpu/recomp/x64_masks.rs:SCCwhole-liveness (bit 125, stripped before returning fromwhole_live_out) and propagate half-local liveness backward through bit-parallel 64-bit SALU ops (S_MOV_B64,S_CMOV_B64,S_NOT_B64,S_WQM_B64,S_CSELECT_B64,S_{AND,OR,XOR,ANDN2,ORN2,NAND,NOR,XNOR}_B64,S_*_SAVEEXEC_B64, andS_*_WREXEC_B64) on even-aligned 64-bit pairs.s_{2k}in half 0,s_{2k+1}in half 1), bit-parallel ops preserve half-exactness when neither the destination pair nor a liveSCCis observed whole; whenever either is whole-live (or whensrc_vccz/src_execz/SCCis read), all inputs are forced whole.EXECwhole-liveness with demand-drivenEXECliveness:EXECis marked whole-live at cross-half observations (S_CBRANCH_EXECZ/NZ,src_execz,V_READFIRSTLANE_B32,DS_BPERMUTE_B32,DS_PERMUTE_B32,S_MOVREL*, non-bit-parallel scalar reads ofEXEC, indirect jumps, andend_reads_all), while in-half reads (act(), DPP,V_PERMLANE(X)16,DS_SWIZZLE) remain half-local.pub fn uses(d: &Decoded)unchanged forlane_masksandrecomp::lower.gpu::recomp::x64_masks::teststo 19 unit tests covering bit-parallel propagation,SCCsoundness,SAVEEXEC/WREXECpatterns,EXECcross-half reads (S_CBRANCH_EXECZ,V_READFIRSTLANE_B32,DS_BPERMUTE_B32), and loop/back-edge propagation.crates/xcl/src/gpu/recomp/emit.rs&crates/xcl/src/gpu/dxil/lower.rs:write_maskto use the half-local ballot when writingEXEC(n <= 126 && n % 2 == 0instead ofn < 126) wheneverEXECis not whole-live after the write.crates/xcl/src/gpu/dxil/kernel.rs:TRANSLATOR_VERSIONfrom7to8.crates/xcl/src/gpu/recomp/tests.rs:gpu_split_wave64_bit_parallel_and_exec_masksverifying both HLSL and Direct DXIL execution on GPU: bit-parallel mask chains, branchlesss_and_saveexec_b64/s_andn2_b64if/else, restored outerEXEC, half-localv_cmpx, and cross-half soundness with upper-half-only active lanes (45..63) forSCC,v_readfirstlane_b32,s_cbranch_execz, andds_bpermute_b32.Measured impact (split-wave64 compute shaders)
Across 200 retail compute shaders (
>= 64 KBHLSL) exported with--split 1:xcl_x_ballotcalls: 10,286 → 6,734 (-3,552 exchanges, -34.5%, removing 7,104 group memory barriers).xcl_x_ballot_localcalls: 7,725 → 11,277.Sample large wave64 compute shaders compiled with DXC (
-E main -T cs_6_6 -HV 2021 -O1,dxcompiler 1.9.2602.17):xcl_x_ballot(main → PR)Direct DXIL sweep with
XCL_FORCE_SPLIT_WAVE64=1(--direct --sample 1000 --max-bytes 65536 --validate): 977 / 977 (100.0%) translated and validated bydxil.dll 1.9.2602.17with 0 validator errors, 0 panics, and 0 timeouts.Regression run
Baseline (
origin/main):PR (
recomp/x64-masks-bitwise-exec):Tested
dxil.dll1.9.2602.17 (Windows SDK 10.0.26100.0), Rust MSVC toolchain.cargo test --workspace -- --test-threads=4— full suite passed (0 failed), including all 19gpu::recomp::x64_masks::testsunit tests and the new GPU testgpu_split_wave64_bit_parallel_and_exec_masks.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib "gpu::dxil::"andgpu_split_wave64— 100/100 Direct DXIL tests (including fuzz suites) and 6/6 split-wave64 GPU tests passed.XCL_FORCE_SPLIT_WAVE64=1, 1,000 sampled records,<= 64 KB): 977/977 validated with 0 errors.scripts/smoke.ps1) onorigin/main(689f2db) vs PR head (b478b4e).Not tested
CreateComputePipelineStatetiming via--measure-pso(Windows Developer Mode is disabled on this machine).AI use