Recompiler: propagate split-wave64 lane-local masks through 64-bit bitwise SALU ops #1111
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1111
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1111"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zondy1i on GitHub · 2026-11-24 11:43 UTC · original
zondy1i:recomp/x64-bitwise-mask-liveness→main· +747 −101 · 3 files · 1 commits · open��Reduces
xcl_x_ballot()cross-half exchanges in split-wave64 (docs/wave64-on-wave32.md) by propagating lane-local mask liveness through 64-bit bitwise SALU ops inx64_masks.rs.Why
x64_masks.rs,v_cmp*and carry outputs (v_add_co_u32/v_sub*_co_u32) already avoid a cross-halfxcl_x_ballot()exchange (xcl_x_ballot_local()) when they feed only per-lane readers (v_cndmask_b32,v_add_co_ci_u32,v_sub*_co_ci_u32).s_and_b64,s_or_b64,s_xor_b64,s_andn2_b64,s_orn2_b64,s_nand_b64,s_nor_b64,s_xnor_b64,s_not_b64,s_mov_b64,s_cselect_b64,s_cmov_b64) before feedingv_cndmask_b32(s_wqm_b64is excluded because it combines 4-lane quads and requires quad helper bits in pixel shaders). Previously,x64_maskstreated every SALU instruction as reading its source SGPR pairs whole, forcingxcl_x_ballot()on all upstream compares even when neither the result mask norsccwas ever read whole.xcl_x_ballot_local()leaves each 32-lane half's own word exact (low dword on half 0, high dword on half 1) and none of these 64-bit lane-wise ops crosses the 32-lane boundary, each half produces its own exact 32-lane result word without exchanging the inputs provided:EXECis always whole-live, so writes toEXECstay exchanged);scc(all excepts_mov_b64/s_cmov_b64/s_cselect_b64),sccis dead afterward (tracked jointly in the backward liveness pass, includingLOOP_GUARDexits and kernel-mode end readback);vccz(251) /execz(252) still markVCC/EXECwhole-live.What is in it
crates/xcl/src/gpu/recomp/x64_masks.rs: tracksccliveness alongside whole-live SGPRs (reads_scc, conservativewrites_sccmatchingemit.rs,lane_wise_salu64, andflow()), propagate non-whole-live masks through even-aligned 64-bit lane-wise SALU ops, update three existing tests that used a deads_mov_b64 s[2:3], vccas a dummy whole-reader, and add 6 unit tests covering bitwise chains, live vs overwrittenscc,s_and_saveexec_b64/EXECwrites,s_cselect_b64/s_cmov_b64,vccz/ odd alignment, andLOOP_GUARDexits readingscc.crates/xcl/src/gpu/recomp/emit.rs: requiren & 1 == 0when emittingxcl_x_ballot_localintoDst::S(n)so low/high half alignment is guaranteed globally.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_split_wave64_bitwise_lane_masksverifying both 0-exchange bitwise mask chains (s_and_b64,s_andn2_b64,s_not_b64,s_or_b64,s_mov_b64,s_cselect_b64�!v_cndmask_b32) and kept exchanges whensccis read (s_and_b64matching upper half only �!s_cselect_b32).Measured impact (RTX 3060 Ti, split-wave64)
xcl_x_ballot()calls drop from 210,324 �! 170,561 ("39,763 exchanges, "18.9%).cs_6_6) and NVIDIA D3D12 PSO compile benchmarks on three retail compute shaders (before384f7f7�! after02d65c8):xcl_x_ballot513 �! 433("15.6%), DXIL834,160 �! 803,648 B("3.7%), DXC23,166 �! 14,804 ms("36.1%), cold PSO28,780 �! 21,316 ms("25.9%).xcl_x_ballot420 �! 370("11.9%), DXIL512,592 �! 494,064 B("3.6%), DXC12,011 �! 8,786 ms("26.9%), cold PSO16,405 �! 11,792 ms("28.1%).xcl_x_ballot135 �! 75("44.4%), DXIL152,752 �! 130,920 B("14.3%), DXC3,455 �! 1,874 ms("45.8%), cold PSO4,106 �! 3,108 ms("24.3%).Tested
x86_64-pc-windows-msvc), debug + release.c29bbad(ontomain0cdc896with#1090):cargo test -p xcl --lib -- gpu::recomp::x64_masks --test-threads=1: 25 passed, 0 failed, 1 ignored (includinguse_plan_matches_fallback_across_all_rdna2_instructionsandblock_liveness_matches_reference_bit_for_bit).cargo test -p xcl --lib -- gpu_split_wave64 --test-threads=1: 7 passed, 0 failed (includinggpu_split_wave64_bitwise_lane_masks).02d65c8: 744 passed, 0 failed, 41 ignored.Regression run
main:
PR:
Not tested
x64_masksonly runs whensplit_wave64is active on wave32-only GPUs or forced viaXCL_SPLIT_WAVE64=1).AI use
xcl_x_ballotconsumers across the shader corpus, designed and implemented thex64_masks.rsscc+ bitwise propagation pass, wrote unit/GPU tests, ran the DXC/PSO benchmarks, and drafted the PR description; all tests, benchmarks, and paired smoke runs were executed locally on the hardware above and the diff was reviewed line by line.@Aniseto on GitHub · 2026-11-24 12:01 UTC · original
Ran the mask tests on an NVIDIA Blackwell part at
02d65c8:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All six split-wave64 GPU tests pass here, including the new
gpu_split_wave64_bitwise_lane_masks. This adapter has no native wave64, so every wave64 console program runs in the split form and exercises the changed path directly. The author's run was on an Ampere RTX 3060 Ti; this adds a Blackwell part with driver 32.0.16.2124.Not tested: native wave64 (not available on this GPU), RDNA2/RDNA4 and Intel GPUs, Wine, release profile, retail titles.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.
@bjarngard on GitHub · 2026-11-24 12:45 UTC · original
Test report for head
02d65c8(AMD, native wave64)Tested
XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 744 passed, 0 failed, 41 ignored, no SKIPPEDXCL_REQUIRE_GPU=wave64:--lib x64_masks22 passed,--lib gpu_split_wave646 passedNot tested: retail titles, benchmarks, RDNA3/RDNA4.
AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
@SlopTart on GitHub · 2026-11-24 13:19 UTC · original
Wine/RDNA3 datapoint for this fix: merged head
02d65c8onto main47efa2e(lane mergeb97b44d) and ran the forced-split cluster (XCL_SPLIT_WAVE64=1,--test-threads=1, release) for 6 reps, against a plain-main control lane in the same session (3 reps).Aggregate pass counts on this rig:
gpu_split_wave64_waves_diverge- 2/6 on your head, 0/3 controlgpu_split_wave64_local_and_exchanged_masks_in_diverging_waves- 1/6, control 0/3gpu_split_wave64_masks_read_whole_after_partial_writes- 0/6, control 0/3gpu_split_wave64_cross_half_operations- 0/6, control 0/3gpu_split_wave64_lane_local_masks- 6/6 bothNo cure observed on this axis: the exchange cluster from my #772 follow-up stays red, and the odd ok in
waves_divergesits inside the flake band this rig shows for that test. (Your newgpu_split_wave64_bitwise_lane_masksstatus line interleaves with Wine'sCreateDXGIFactory2warning in my capture, so I am not quoting a number for it; it did not error out.)Also worth knowing: this head and #1090 both rewrite
x64_masks.rsand conflict when merged together, so combined behavior is untestable until they reconcile. Full elimination list (not ACO, not a regression, timing-sensitive) is in my #772 comment.Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@testclanker on GitHub · 2026-11-24 13:50 UTC · original
Tested on NVIDIA RTX 5060 Ti (Blackwell, wave32 only, split wave64) at
02d65c8Tested
XCL_SAMPLE_RPFandXCL_SAMPLE_DLLSset.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 744 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_split_wave64_bitwise_lane_masksran (no SKIPPED line) and passes, as do the other 5gpu_split_wave64_*tests and allx64_masksunit tests.gpu_pso_e2eon the sample pack: 7 passed.Regression run (60 s, networking off, no input). One warm-up run of the PR build came first so that both builds started with a warm DXIL cache (exit 0x0, no removal, no crash). That run compiled 38 shaders main's cache didn't have, so the title runs code this PR changes. Then main and this PR ran back to back. Main is at
47efa2e, 9 commits past this PR's base384f7f7; none of them touchgpu/recomp.main:
this PR:
Frames 102 % of main, peak commit 100.1 % of main.
Not tested: native wave64 (no AMD GPU), a release-build test run, this PR merged onto current
main.AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and smoke runs and wrote this comment.
@Cecerw on GitHub · 2026-11-24 14:09 UTC · original
Tested on NVIDIA Ampere (32-lane waves, split wave64): passes
02d65c8(base384f7f7)main930e8b4.\scripts\test.ps1(cargo test --workspace -- --test-threads=4), no local changes; the merge was done locally, no conflictsgpu_split_wave64_bitwise_lane_masks(runs split on this GPU) and the six mask-liveness unit tests (bitwise_mask_chain_for_selector_needs_no_exchange…loop_exit_reading_scc_keeps_exchange_inside_loop): okgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)Not tested: AMD, any title (no smoke run).
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@MiguelMachado-dev on GitHub · 2026-11-24 18:06 UTC · original
I'm stacking two split-wave64 changes on top of this PR. Your commit is cherry-picked onto
main9e3831eunchanged, with your authorship:v_cmpx, even-aligneds_*_saveexec_b64/s_*_wrexec_b64).xcl_x_sync_mask), instead of once per compare.Both build on your
flow()/lane_opand yoursccliveness. Neither changes the logic in your commit. Each of them edits some of your tests, and the reasons are in its description:gpu_split_wave64_bitwise_lane_maskspart 2 now expects local compares plus one exchange at thes_and_b64.On the retail pack (all wave64 CS / MS programs, split form, 4 windows) the exchanged mask writes go 210 324 (
main) → 170 561 (this PR, the same count as in your description) → 153 728 (A) → 138 438 (B, including the 10 473 tree exchanges).AI use: Claude Code (Claude Opus 5.5) wrote both PRs and this comment.
@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Both AMD (RDNA2 iGPU + RDNA3 Wine) and NVIDIA (RTX 5070 Ti, RTX 5060 Ti, RTX 3060 Ti) test reports look solid on
02d65c8.Remaining before merge:
#1090just merged intomainwith basic-block liveness incrates/xcl/src/gpu/recomp/x64_masks.rs, so please rebase#1111ontomain(foldingflow()/sccliveness onto the block solver) and letBuild and test (Windows, no GPU)run cleanly.@zondy1i on GitHub · 2026-11-25 01:24 UTC · original
Rebased onto
main(0cdc896) atc29bbad, foldingInstFlow/sccliveness onto#1090's precomputedUsePlanTableand basic-block liveness solver (blocks without lane-wise 64-bit SALU ops stay O(1) per iteration; blocks with lane-wise ops recompute only when(out, sout, left, sleft)changes). Also excludedS_WQM_B64fromlane_wise_salu64sincex64_masksis now shared with pixel shaders (ballot_px_local), where 4-lane quad WQM still needs quad helper bits.Verified locally on RTX 3060 Ti:
gpu::recomp::x64_masks: 25/25 passed (includinguse_plan_matches_fallback_across_all_rdna2_instructionsandblock_liveness_matches_reference_bit_for_bit).gpu_split_wave64: 7/7 passed (includinggpu_split_wave64_bitwise_lane_masks).c29bbad.(AI use: Antigravity (Gemini 4 Neon) performed the rebase onto
#1090, ran the tests/smoke, and drafted this reply.)@raylitebull on GitHub · 2026-11-25 01:34 UTC · original
Rebased head
c29bbadcleanly foldsInstFlow/sccliveness onto#1090'sUsePlanTableand basic-block solver, excludesS_WQM_B64fromlane_wise_salu64, and passesBuild and test (Windows, no GPU)+PR description(UsePlanTable/ block-reference tests +gpu_split_wave64_bitwise_lane_maskson RTX 3060 Ti).Remaining before merge: one independent AMD (or second-vendor) verification pass on
c29bbadconfirming the rebased#1090integration before merging.@DavidM1911 on GitHub · 2026-11-25 08:21 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@Raghav314 on GitHub · 2026-11-25 18:00 UTC · original
Test report for #1111 in the direct DXIL path, whose kernel uses the same
x64_masksanalysis (gpu/dxil/kernel.rs:595,x64_masks::by_pc): the driver's cold build of a split-wave64 program is about 9 % shorter.Setup: RTX 4090 24 GB (617.14), Windows 11, Developer Mode on, release.
main68a284awith this PR atc29bbadmerged (no conflicts), plus #1830's--time-formsfor the timing.--time-forms --idx <record> --split 1 --windows 4 --heap --no-hlsl: direct DXIL, split wave64, heap windows; one coldCreateComputePipelineStateper process, with the driver's three implicit caches off (ShaderCacheControl).062468c09af883b9(wave64, split)main76b0a8c7541c6c91(no half exchanges)mainwas under 0.2 s over three processes, so the 1.7–2.1 s is outside it.maininx64_masks.rs(12 hunks across four files,mainhas rewritten the file since), so I could not time them. After a rebase I can run the same three on this program.Not tested: GPU output of the merged tree (no suite run; timing only), AMD, the HLSL path, a title run.
AI use: Claude Code (Claude Opus 5.5) merged the PR, ran the timings and wrote this for @Raghav314.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.