Repository navigation
Recompiler: split-wave64 EXEC is exchanged only where it is read whole - #1596
MiguelMachado-dev wants to merge 2 commits into
Conversation
x64_masks kept EXEC whole-live everywhere, so every v_cmpx and every s_*_saveexec_b64 / s_*_wrexec_b64 exchanged the two halves' masks, and so did the compares feeding them. Every VALU reads EXEC lane by lane (the emitter's lanebit), and DPP, ds_swizzle and v_permlane(x)16 read it for a source lane in the reader's own half, so EXEC needs the whole value only where the program reads it whole: s_cbranch_exec(n)z, src_execz, a scalar operand, v_readfirstlane (first active lane) and ds_(b)permute (lanes of the other half). The last three are not in the operand tables and are now added in uses(). EXEC is now a mask like the others in the liveness: no longer live at every instruction or at the end of a compute program (the kernel runner still reads every SGPR at the end). An even-aligned saveexec / wrexec needs whole inputs only when the new EXEC or its scc is read whole, and whole EXEC alone when only the saved old EXEC is; odd pairs keep reading their operands whole. The emitter lets EXEC (s126) take the local ballot. Three tests from the bitwise-mask change relied on EXEC being always live; they now read EXEC whole after the write. Assisted-by: Claude Code (Claude Opus 5.5)
|
Tested PR #1596 at cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_split_wave64_predicated_exec_masks -- --exact --nocapture1 passed, 0 failed, 0 skipped. With AI use — OpenAI Codex ran the test and drafted this report. Exact model version unavailable. |
|
Full suite on NVIDIA plus native wave64 on an AMD RDNA2 iGPU, to go with the targeted split-wave64 check above. Tested exact head Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
@MiguelMachado-dev this PR carried onto current Why it needed more than a rebase:
Tests (RTX 4090, 617.14, Windows 11, release):
Cold driver time,
For 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 ( 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. |
Stacked 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. Recompiler: propagate split-wave64 lane-local masks through 64-bit bitwise SALU ops #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