Recompiler: elide EXEC masking where all lanes are active and cache lane active bit #1356
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!1356
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1356"
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?
@XaviFortes on GitHub · 2026-11-24 15:10 UTC · original
XaviFortes:recomp-exec-active→main· +497 −12 · 4 files · 1 commits · openAddresses #1269 (EXEC emulation optimization).
What changed
exec_active.rs,emit.rs,mod.rs):exec_active::all_active_pcs) over decoded RDNA2 instructions that proves which PCs haveEXEC == entry_exec(ballot(true)at entry, so every executing lane is active).EXECand saved-EXECSGPRs acrosss_*_saveexec_b64/_b32,s_mov_b64/_b32(save/copy/restore),s_or_b64/_b32restores,s_wqm_b64/_b32, wave64 pair clobbering,s_movrel*, andLOOP_GUARDloop-head exit edges. Any non-fetchF_INDIRECTbranch makes the whole shader conservative.Vertex,Pixel,Compute, andMeshshaders (KernelandGeometrystay conservative;XCL_NO_EXEC_ELIDE=1disables elision for A/B debugging).vN = val;directly instead ofvN = select(lanebit(exec_lo, exec_hi), val, vN);, eliminating both the per-instructionselect/lanebitIR and the false read dependency on the old VGPR value.ballot(cond)instead ofballot(and(lanebit(...), cond)).select(en, val, v)instead ofselect(and(act, en), val, v).bool ea(emit.rs):EXECmay be narrowed (divergent regions,Kernel,Geometry), caches the current lane's EXEC bit in a localbool earefreshed only whenexec_lo/exec_hiis written (sync_ea()), instead of recomputinglanebit(exec_lo, exec_hi)on every VALU instruction.Benchmark (
retail_translation_survey, 1-in-50 sample of retailshaders.rpf, 4 DXC threads, release build)533 FSSM variants (54 CS, 4 GS, 183 MS/NGG, 242 PS, 2 VS/ES, 48 VS; 917,308 RDNA2 instructions), DXC
1.8.2502.11:main(930e8b4)621e6ab)CS_RaytracingResolve_b1139868)cargo build --workspace && cargo test --workspace -- --test-threads=4on Windows 11 (10.0.26200.0), AMD Radeon RX 7900 XT, DXC1.8.2502.11: 756 passed, 0 failed, 41 ignored, 0 SKIPPED.gpu::recomp::exec_active::tests(straight-line all-active,s_and_saveexec_b64+s_or_b64restore, wave32s_and_saveexec_b32+s_mov_b32restore, and clobbering the high half of a saved wave64 pair) plus end-to-end GPU testgpu_exec_elide_divergent_and_restored_computeverifying both HLSL shape and per-lane GPU output.retail_translation_surveywithXCL_SURVEY_EVERY=50andXCL_SURVEY_DXC=1: 533/533 variants translated and compiled with 0 DXC errors.Regression run
Baseline (
mainancestor4017f8ff8faaae6007fd83910d230a027dd85a33):PR (
recomp-exec-active621e6abad1075703fe74cce3961df439637917ee):Not tested
shaders.rpfDXC sweep (sampled 1-in-50 = 533 shaders across all stages).AI use
@DarkPanda69 on GitHub · 2026-11-24 15:16 UTC · original
NVIDIA run, which this PR lists as not tested: one existing split-wave64 test fails with this PR.
Tested: head
621e6abapplied on its basemain930e8b4, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu::recomp --test-threads=4:gpu_exec_elide_divergent_and_restored_computeok.The failure,
gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves:cargo test -p xcl --lib -- gpu_split_wave64_local_and_exchanged_masks_in_diverging_waveson the RTX 3060:main930e8b4passes 3/3, with this PR it fails 3/3.XCL_SPLIT_WAVE64=1, so it looks like the split wave64 form, not the adapter.Not tested: the whole workspace suite; a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@futurepro62 on GitHub · 2026-11-24 15:20 UTC · original · edited 2026-11-24 15:21 UTC
Following up on @DarkPanda69's split-wave64 failure: same result here (RTX 5070 Ti, driver 616.64, waves 32 only, head
621e6ab; fails 3 of 3,main930e8b4passes 3 of 3), and it looks like the test's expected HLSL text is out of date, not a wrong result.if runner::split_wave64()asserts count= xcl_x_ballot(and((1) and= xcl_x_ballot_local(and((2). With EXEC known to be full in that program, this PR emitsuint2 t9 = xcl_x_ballot(s13 > v2);,xcl_x_ballot_local(t13 < v8)andxcl_x_ballot_local((t15w >> 32) != 0ull)with noand(lanebit(exec_lo, exec_hi), ...), so both counts are 0. That's the masking this PR is meant to drop.= xcl_x_ballot(/= xcl_x_ballot_local(instead should make it pass while still checking which ballots are local.XCL_ADAPTER=radeon), full workspace suite: 756 passed, 0 failed, 41 ignored, no skips.AI use
@ArturoWolff on GitHub · 2026-11-24 15:23 UTC · original
Split-wave64 Compute, RTX 4060 / Proton: inactive lanes kept their previous values after independently narrowing and restoring the two EXEC halves. This is a separate generated shader, not a rerun of the ballot-text assertion reported above.
Tested
930e8b49c1c2ec683d22c724a398b39111cd0e56and621e6abad1075703fe74cce3961df439637917ee. Three 64-lane workgroups reached the same join with different masks: all lanes, upper half only, lower half only. Head kept the guard there and updated exactly those lanes. After restoring an intact saved mask pair, head emitted a direct assignment, and all 64 lanes in each group updated. Restoring just one half earlier preserved the sparse mask in the other half. Base guarded all 13 vector writes; head elided six. Both real emitters' unedited output was compiled and dispatched.Tested: one dispatch per revision; each matched an independent CPU reference for all 192 lane outputs and 80 untouched sentinel words. Ryzen 5 5600, RTX 4060, NVIDIA 620.73.04, GE-Proton11-14, vkd3d-proton
4522cc1a8b1347f+, DXC 1.9.2609.5. Offline Windows-target release builds:cargo build --offline --locked -j1 --release --target x86_64-pc-windows-gnullvm -p xcl --lib; linked the same private fixture to each build and ranemit,compile,pso_readbackwith--exact --nocapture --test-threads=1. Six invocations passed, none failed/ignored/skipped, two filtered per invocation.Not tested: native wave64, graphics stages, other control flow, full suite, retail loading or performance. This does not clear the separately reported suite failure.
AI use: Hermes Agent, gpt-6.2-astra (fixture, execution, verification and report).
@HKEY-Funk-Machine on GitHub · 2026-11-24 15:27 UTC · original
Test report: #1356 at
621e6abon AMD RDNA4 (Windows), full-title intro: driver time, not DXC timeYour numbers cover DXC. I checked the other half on AMD, since @Sr-0w saw the AMD driver get slower when exec selects were removed (#1269).
Tested
xcl runwithXCL_NETWORK=0, plus one local patch that skipsInitializeApiImplEx2(it hangs for this title here). Otherwise clean621e6ab, compared against cleanmain930e8b4with the same patch.mainand 1 on #1356. One run each.main930e8b4621e6ab+0x23cf683at 2m22sCreateComputePipelineStatetimeOn this path the AMD driver doesn't get faster with #1356. Mean PSO time is up about 10 %, and the total DXIL from the intro's compute programs is about 13 % larger, which I didn't expect. The slowest single PSO did drop, from 27.6 s to 18.6 s. The intro still hits the same watchdog; crash time varies between runs, so I wouldn't read much into 1m37s vs 2m22s.
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the builds and the game, extracted the timings from the XCL logs, and drafted this report.
@mastrr9 on GitHub · 2026-11-24 15:30 UTC · original
RTX 5080 (wave32 / split-wave64) test report for head
621e6abad1075703fe74cce3961df439637917ee(Windows 11, DXC 1.9.2602.17, Rust MSVC, debug build, clean worktree):cargo test -p xcl --lib -- gpu::recomp --test-threads=4: 193 passed, 1 failed, 18 ignored (0 new compiler warnings).gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_wavespanicked atcrates\xcl\src\gpu\recomp\tests.rs:5951(single run with 4 threads; flagging in case the cachedea/ EXEC elision interacts with split-wave64 diverging mask exchanges).Not tested: AMD native wave64, retail smoke (
scripts/smoke.ps1).AI use: T3 Code (Antigravity / Claude Sonnet 5.5) built the worktree, ran the test suite on our RTX 5080, and drafted this comment from the output.
@Creaa on GitHub · 2026-11-24 16:09 UTC · original
Test report:
621e6abon an RTX 4070 (32-lane waves, so the split wave64 form). The EXEC elision hangs the GPU when the lib tests run in parallel; one split-wave64 test also fails on its HLSL pattern.Setup: RTX 4070 12 GB (driver 617.14), i7-13700F, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2602.17, debug build.
main930e8b4run the same way for comparison.1. GPU hang (
0x887A0006) with parallel tests, caused by the elisioncargo test -p xcl --lib -- --test-threads=4, runs alternated on the same machine:main930e8b4621e6abXCL_NO_EXEC_ELIDE=1--skip gpu_sparse_vram_descriptors_buffers_and_xmem--test-threads=1gpu_sparse_vram_descriptors_buffers_and_xmemfails first (submit 1 lane 0 mismatch, left 0, right 1077: the output was not written within its 5 s fence wait). The test the device removal lands on varies (gpu_wave32_and_wave64_src_vccz_execz,gpu_valu_16_and_64_bit), and 8–9 later GPU tests fail with0x887A0005after it.mainin three lines only:t8_act, thev_add_nc_u32write and thebuffer_store_dwordguard becometrue/ a plain assignment. With 64 threads all lanes are active, so the change looks right by itself; I did not find why the shader then does not finish under concurrent GPU load. One guess, not checked: with no guard left,exec_lo/exec_hiare dead after the entryxcl_x_ballot(true), and DXC may compile that cross-half exchange differently. The DXIL of both versions would tell.2.
gpu_split_wave64_local_and_exchanged_masks_in_diverging_wavesfails (every run)The assertion
t.hlsl.matches("= xcl_x_ballot(and(").count() == 1gets 0: the v_cmp is nowuint2 t9 = xcl_x_ballot(s13 > v2);. This branch only runs whenrunner::split_wave64(), so it does not run on a 64-lane AMD GPU. With the pattern changed locally to accept the unguarded form, the test passes, including its GPU results; the exchanged/local split is unchanged (onexcl_x_ballot, twoxcl_x_ballot_local).3. Compile cost on a sample (67 compute programs, every 40th of a retail pack's 2 689,
xcl shaders <folder> --precompile --only cs [--pipelines], release, 4 windows, split wave64, empty XCL caches, one run each)--pipelines)mainOn this sample the difference is within what I would expect from run-to-run noise; one run each, so no claim either way. The sample has few programs large enough for
-O1/-O0, where your survey found the gain.Full suite:
cargo test --workspace --no-fail-fast -- --test-threads=4: 745 passed, 11 failed, 41 ignored (the hang above); SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64), plus six "no GPU" after the device was lost.Not tested: AMD, other NVIDIA cards, a title run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and measurements on my machine and drafted this comment; I checked it before posting.
@upipibi on GitHub · 2026-11-24 16:20 UTC · original
@Creaa I think I found the cause of the parallel-run failure of
gpu_sparse_vram_descriptors_buffers_and_xmem, and it is not this PR's elision. It is a bug in the test that this PR's extra tests expose.The test encodes its three
S_LOADs withoutSOFFSET, so the field is 0. That is s0, not NULL (0x7D), and the translation shows it:… + (uint64_t)(int64_t)(int)0x00000000u + (uint64_t)s0on every scalar load. s0 is the low dword ofarg_table. So each load reads at its base plusarg_table's low bits, which is right only whilearg_tablehappens to sit at a 4 GiB-aligned offset of window 3, i.e. when no other test allocated there first. In a parallel run it can land elsewhere: the descriptors come from the wrong place, and the output is never written.Reproduced on
main930e8b4alone (RTX 3070, the test run by itself): with one extrau.alloc(0x1_0000, 256)in window 3 beforearg_table, it fails with exactly your message,submit 1 lane 0 mismatch, left 0, right 1077. Without the extra allocation it passes. WithSOFFSETset to 0x7D it passes both ways. This PR adds tests that allocate in parallel, which would explain why it shows up here and not onmain. I have not reproduced the0x887A0006that followed, but loads and stores through garbage descriptors into the sparse windows fit it.Fix in #1456:
SOFFSETNULL on the three loads, and a block allocated ahead of the table so a load that adds s0 fails on every run, not only in parallel ones. The HLSL diff you listed (t8_act, the write, the store guard) is the same as here and harmless with 64 active lanes.AI-assisted (Claude Code).
@DavidM1911 on GitHub · 2026-11-24 16:28 UTC · original
Test report — RTX 3060 Ti (Windows 11), branch merged with current
main(b7aa9f3):cargo test -p xcl --lib -- --test-threads=1: 1 failure (726 passed, 1 failed, 21 ignored):The failing test is pre-existing on
main— the EXEC-masking elision / lane-active caching appears to drop a mask update that av_cmpin diverging split-wave64 waves relies on. Reproduces consistently single-threaded and standalone (cargo test -p xcl --lib gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves).@LocranKing on GitHub · 2026-11-24 17:43 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32) test and retail smoke report on clean head
621e6abad1075703fe74cce3961df439637917ee.Confirms the known wave32 / split-wave64 test failure (
gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves,tests.rs:5951,left: 0, right: 1onthe v_cmp: read whole by the odd waves) reported by@DarkPanda69,@futurepro62,@Creaa, and@DavidM1911. All other 755 workspace tests passed, and the 60 s retail smoke run completed cleanly with no crashes or device removals.Tested
621e6abad1075703fe74cce3961df439637917ee(clean tree, merge-base930e8b4)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 755 passed, 1 failed, 41 ignored, exit101gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves(crates\xcl\src\gpu\recomp\tests.rs:5951:13,left: 0, right: 1)SKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
621e6abad1075703fe74cce3961df439637917ee):Not tested: debug build, AMD / native wave64 hardware, extended gameplay past 60 s.
AI use: Antigravity (
Gemini 4 Neon) ran the build, tests, and smoke runs and drafted this report from the command outputs.@Creaa on GitHub · 2026-11-24 17:48 UTC · original
Follow-up to my report above: the GPU hang is not your elision's logic. The elision exposes it, and
mainshows the same failure when that test's shader changes in any equivalent way. I wrote "caused by the elision" above; that was too strong.Same machine (RTX 4070, driver 617.14, split wave64).
cargo test -p xcl --lib -- --test-threads=8, which failsgpu_sparse_vram_descriptors_buffers_and_xmemmore often than 4 threads:main930e8b4main, that test's HLSL with your three changed lines (t8_act = true, the plainv2write,if (true)store guard)main, only one of the three lines changed, for each of the threemain, a comment appended to the HLSL instead (same DXIL)XCL_WAVE64_SPIN=0GetCompletedValue()=u64::MAX, so the device was removed under it (TDR).XCL_WAVE64_SPIN=0(a group barrier instead of the arrival counters) there was no hang in 6 runs, but the test still failed in 2 of them.maintoo, so it probably deserves its own issue rather than blocking this PR.The other point of my report stands:
gpu_split_wave64_local_and_exchanged_masks_in_diverging_wavesstill looks for= xcl_x_ballot(and(, which the elidedv_cmpno longer has, so it fails on every 32-lane GPU.Separately, on the 31 compute programs of my #680 report, replacing every EXEC guard by
true(an upper bound, not your change) cut the cold NVIDIA driver time by 29 % (#1269), so on this card the guards are worth removing.AI use: Claude Code (Claude Opus 5.5) ran the experiments on my machine and drafted this comment; I checked it before posting.
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.