Recompiler: split-wave64 EXEC is exchanged only where it is read whole #1596
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!1596
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1596"
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?
@MiguelMachado-dev on GitHub · 2026-11-24 18:05 UTC · original
MiguelMachado-dev:recomp/x64-mask-opt→main· +607 −30 · 3 files · 2 commits · openStacked on #1111; only the top commit (
524b25c) belongs here. #1111 is in this branch as a cherry-pick ontomain9e3831e(ce0eeec, its head is02d65c8), so this branch is rebased once #1111 merges. Part of #1269.In the split wave64 form,
x64_maskskept EXEC whole-live at every instruction, so everyv_cmpx*and everys_*_saveexec_b64/s_*_wrexec_b64exchanged the two halves' masks, and so did the compares feeding them. Every VALU reads EXEC lane by lane (lanebit), and DPP,ds_swizzleandv_permlane(x)16read it for a source lane in the reader's own half. EXEC needs its whole value only where the program reads it whole:s_cbranch_exec(n)z,src_execz, a scalar operand,v_readfirstlaneandds_(b)permute. This change treats EXEC like the other masks.What is in it
crates/xcl/src/gpu/recomp/x64_masks.rs:sccis read whole. When only the saved old EXEC is read whole, it needs whole EXEC alone. Odd pairs keep reading their operands whole.uses()adds the EXEC reads the operand tables leave out:v_readfirstlane_b32,ds_bpermute_b32andds_permute_b32.crates/xcl/src/gpu/recomp/emit.rs: EXEC (s126) can take the local ballot. #1111's even-alignment check is kept.exec_is_exchanged_only_when_read_whole(replacesexec_is_always_exchanged) andsaveexec_needs_whole_inputs_only_for_a_whole_read;gpu_split_wave64_predicated_exec_masks: av_cmpxregion and ans_and_saveexec_b64region stay local, and av_cmpxread byv_readfirstlaneis still exchanged and gives the first active lane in both halves;s_cbranch_execz).Measured with a temporary local test, not in this PR. It translates every wave64 CS / MS program of the retail 1.0.2.1
shaders.rpfin the split form with 4 memory windows and counts mask writes that usexcl_x_ballot:main9e3831ece0eeec524b25cdocs/wave64-on-wave32.md:123says "EXEC is always whole-live". After this change that is no longer true. The doc is not edited here.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4at524b25c: 785 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).gpu_split_wave64_predicated_exec_masksran in the split form, and its HLSL counts were checked: 2 local, 1 exchanged.Regression run
Each block is the second of two back-to-back 60 s runs of the same build (the first one filled the shader and driver caches).
main:
PR:
Not tested
AI use
@rGillyazanov on GitHub · 2026-11-24 18:43 UTC · original
Tested PR #1596 at
524b25c. The targeted test passed on an RTX 3060 Ti (8 GB, driver 621.40) with Windows 11 build 26300, Rust 1.100.0 MSVC, and DXC 1.8.2505.32. PR #15961 passed, 0 failed, 0 skipped. With
XCL_ADAPTER="RTX 3060 Ti"andXCL_REQUIRE_GPU=wave64, the test exercised split wave64 on 32-lane hardware. Both local ballot assertions, the cross-half ballot assertion, and GPU readback passed. This run covered the single synthetic test.AI use — OpenAI Codex ran the test and drafted this report. Exact model version unavailable.
@futurepro62 on GitHub · 2026-11-24 18:58 UTC · original
Full suite on NVIDIA plus native wave64 on an AMD RDNA2 iGPU, to go with the targeted split-wave64 check above. Tested exact head
524b25c(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 784 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_masks,gpu_split_wave64_predicated_exec_masks,saveexec_needs_whole_inputs_only_for_a_whole_read,bitwise_mask_chain_for_selector_needs_no_exchange,bitwise_mask_with_live_scc_keeps_exchange,bitwise_mask_feeding_whole_read_keeps_exchange,cselect_and_cmov_b64_propagate_lane_masks_and_keep_scc_uniform,vccz_operand_and_odd_alignment_in_bitwise_ops_keep_exchange,loop_exit_reading_scc_keeps_exchange_inside_loop.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 785 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 20:12 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@Raghav314 on GitHub · 2026-11-25 18:40 UTC · original
@MiguelMachado-dev this PR carried onto current
main, for you to take or leave:Raghav314/xclx64/exec-local-on-main(81cf0fc, onmained95117). It is #1111's commit (7c92fcf, unchanged, zondy1i's) and this PR's change as one commit with you as co-author. With it, the direct DXIL path's cold driver build of a split wave64 program is 26 % shorter than onmain.Why it needed more than a rebase:
mainrewrotex64_masks.rs(operand plans per encoding, liveness solved per basic block, and the same analysis now feeds pixel shaders, #1111 aside). So the change is re-implemented on that structure rather than conflict-resolved:InstFlowgetssave_exec, and one transfer function,gen_of, now serves the per-block, per-instruction and reference solvers alike, with your rule for the saved / new EXEC.whole_live_out_split/by_pc_split, used only for the split form: the HLSL emitter's split compute, mesh and kernel programs, and the direct DXIL kernel (dxil/kernel.rs). Pixel shaders keep EXEC whole-live as before, since theirballot_px_localholds only the lane's own bit, and DPP /ds_swizzleread another lane's EXEC bit in the quad.v_readfirstlaneandds_(b)permuteread EXEC whole in that mode. That is added in the flows, not inuses(), so the per-lane form's use ofuses()is unchanged.Lw::write_masktakes EXEC (s126) as local too, anddxil/compact.rs's block key includes EXEC's liveness bits, so two blocks that differ only there are not merged.Tests (RTX 4090, 617.14, Windows 11, release):
gpu_split_wave64_predicated_exec_masks(passes on the 4090). The block solver against the reference now runs in both modes, and the synthetic shader gains saveexec /v_cmpxregions.cargo test --release -p xcl --lib -- --test-threads=4: 1235 passed, 1 failed, 26 ignored. The failure,lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(3 group barriers, 1 expected), fails the same way on plainmained95117.Cold driver time,
xcl shaders --time-forms(#1830;ShaderCacheControlwith the three implicit caches off), direct DXIL, split wave64, heap windows with 4 windows, one coldCreateComputePipelineStateper process:062468c09af883b9(wave64)mained9511781cf0fc)76b0a8c7541c6c91(no half exchanges), + bothFor scale, @Kalmarv's upper bound for this program with no exchange at all was 56 → 7.8 s on #2088, so more is left there. I'm looking at #1597 next. Its tree sync (
xcl_x_sync_mask) is HLSL-emitter code, so the direct path needs its own version of it.Not tested: a title run; AMD (native wave64 is not affected: the mode is split-only); the HLSL path's driver time.
AI use: Claude Code (Claude Opus 5.5) ported the change, ran the tests and timings, and wrote this for @Raghav314.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.