Recompiler: XCL_WAVE64_SPIN=0 gives direct DXIL one-wave groups the group barrier #3625
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3625"
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?
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T23:16:38Z.
On a GPU with 32-lane waves the two halves of a console wave64 exchange words. The HLSL path meets the halves of a one-wave group at a group barrier unless
XCL_WAVE64_SPINasks for the arrival counters; the direct DXIL translator has used the counters for compute and mesh groups since #1741 (a guess at the hang of #1727) and did not read the switch, although the switch is in the cache keys. This PR makesXCL_WAVE64_SPIN=0give those groups the group barrier in the direct translator too, and keeps such a program whole: it is not cut into a dispatch chain (split_compute), as it is not with the counters. The default does not change.Why: in a retail title on an RTX 5070 Ti one such compute program (a particle update,
numthreads(64,1,1), 191 exchanges, 370 KB of DXIL) takes almost exactly 50 ms at every dispatch, about 57 dispatches a frame: one half polls its partner's counter to the limit of1 << 20and gives up. That is 2.8 s of a 4.2 s frame in the intro cutscene after the title screen. Part of #1833.1 << 20)XCL_WAVE64_SPIN=0(every one-wave compute and mesh group)What the wait is not (each tested with a local build that changed this one program): the mask plan (all masks exchanged: no change), a half that left the program (an exit mark its partner sees: no change), the memory fences around the exchange (taken out: no change), short lane counts (both halves count whole waves of 32). At the timed-out wait the lower half has added
(k + 1) * 32, its partner's counter is exactly one exchange short, andkis 32 or more. A read of the translated DXIL found the exchange number and the counters consistent on every path. So the counters do not work for this program on this driver, and I do not know why; the group barrier does.What is in it
crates/xcl/src/gpu/dxil/kernel.rs:one_wave_spin(the switch, asComputePolicyKey::wave64_spinreads it) and its use whereLw::newpicksPartner::PresentorPartner::Spinfor a group of 33 to 64 threads;finish_dispatch, a split program at the group barrier stays whole like one with the counters (review: with the switch it could otherwise be cut into a dispatch chain, a path no test runs at 64 threads);crates/xcl/src/gpu/dxil/kernel.rs, testa_split_wave64_compute_program_at_the_group_barrier_stays_whole.crates/xcl/src/gpu/dxil/core_tests.rs,a_single_split_wave_of_a_compute_group_exchanges_without_a_group_barrier: also checks the switch's values, that a 64-thread group without the counters has group barriers at the exchange and no compare-exchange, and that a 128-thread group keeps the counters.crates/xcl/src/gpu/dxil/mask_exchange.rs,gpu_split_wave64_compare_batch_preserves_both_words: runs its 64-thread compute program on the GPU through the group barrier too and expects the same memory.docs/wave64-on-wave32.md: the paragraph on the default now says the direct translator uses the counters by default (=0gives the group barrier, no chain) and the HLSL path the group barrier (=1gives the counters).Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4one3dabe10(on main078358a0): 3007 passed, 0 failed, 52 ignored.SKIPPEDon this adapter: 28: 22no wave64; 2no heap windows; 2no d3d12SDKLayers.dll; 1no D3D12 debug layer; 1 cannot disable the driver cache (no Developer Mode). Both tests this PR changes ran, the GPU one on wave32.334564ab(where these programs could still be chained), 360 s runs, the start prompt pressed at 70 s,XCL_TEXTURE_LEVEL_PAGES=1 XCL_GPU_TIMES=6,200, one compute program left out in every run (XCL_SKIP_CS, the compact-form removal of #3516), builds of this branch, interleaved, each setting after a warm-up run of its own:XCL_WAVE64_SPIN=0, run 1XCL_WAVE64_SPIN=0, run 2XCL_WAVE64_SPIN=0in all on that head (two warm-ups, the two above, one with frame dumps): no device removal, no crash, no hang.e3dabe10, one 420 s run withXCL_WAVE64_SPIN=0 XCL_RESIDENCY_PRIORITY=1 XCL_GPU_TIMES=6,200(no level pages, no program left out, so not comparable with the table): 3872 frames, 158 and 157 presents in minutes 5 and 6, no device removal, no crash, no hang. There was no run with the switch unset in this setting.Regression run
Both without the switch: the smoke runs check that the default is unchanged. Each follows a warm-up run of the same build; the start prompt is pressed once at 70 s. Both are the first counted run after the warm-up; neither lost the device.
Not tested
AI use
334564ab. Gemini 4 Neon (agy) read the translated DXIL for consistency; I did not re-verify that reading line by line.e3dabe10, and updated this description.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T23:21:16Z.
Review (head
334564ab, diff read, not a merge-check):gpu/dxil/kernel.rs, onlyPartner::Spinkeeps a split 64-thread program whole (~887). WithXCL_WAVE64_SPIN=0the program becomesPartner::Present(~852), so one without LDS overXCL_DIRECT_SPLIT_INSTRUCTIONS(12,500 by default) goes tosplit_compute(~897) and can be cut into several dispatches. Since0f2fa3ee0no test runs that chain path at 64 threads (module/split.rs~971 now asserts the program stays whole), the PR's tests do not cover it, and the description does not mention this second effect.docs/wave64-on-wave32.md~75 still says "Both translators use this variant [the counters] by default for one console wave per group", butx64_spin_for(recomp/emit.rs~6554) gives the HLSL path's one-wave groups the group barrier by default, as the description says; the rewritten sentence after it still reads as if both default to the counters.Fine: opt-in with the default unchanged;
one_wave_spin_wantedis only checked for compute and mesh groups of 33 to 64 threads; the test override reaches the translator thread; the switch is already in the compute and pipeline cache keys (ComputePolicyKey::wave64_spin,semantic_pipeline_setting,cache_allowed); multi-wave groups keep the counters, and the test checks it.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by i7Gamer on 2026-12-02T01:24:58Z.
Independent NVIDIA validation: RTX 5090, driver 616.56, Windows 11. The DXIL structure test and synthetic GPU readback test passed without skips on base
1c8b5514, PR head334564ab, and integrationab09d222. The four-thread integration suite also passed: 2,909 passed, 0 failed, 51 ignored.This covers the tested wave32 compute case. The larger dispatch-chain path, native wave64, mesh-stage execution, and retail titles were not tested. Would a separate synthetic compiler test for the larger dispatch chain be useful?
Imported from ivall/xcl. Originally posted by i7Gamer on 2026-12-02T13:19:54Z.
Follow-up on the larger dispatch-chain case: I ran a synthetic regression test on
334564abwith the test-only patch applied (RTX 5090, driver 616.56, Windows 11). It produced two dispatch pieces. The whole and chained GPU readbacks both matched the CPU reference, and the buffer guards passed. The test ran once and passed without skipping.This covers the tested split-wave64 compute case on hardware wave32. It doesn’t cover native wave64, mesh execution, or retail titles. I can share the test patch here or open a separate test-only PR, whichever you prefer.
AI assistance: Codex drafted the test and ran the validation.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:21:28Z.
Review: COMMENTED
Review of
334564ab: 1 finding(s) (1 medium), most severe first.crates/xcl/src/gpu/dxil/kernel.rs:887: see below.On lines outside the diff:
crates/xcl/src/gpu/dxil/kernel.rs:887: Not certain about this one: with XCL_WAVE64_SPIN=0, split one-wave[64,1,1]compute programs without LDS are no longer kept whole.finish_dispatchsends them tosplit_compute(numthreads, split_tid, limit), whose barrier-exchange cut detection and per-piece lane re-assignment have had no production use since #1741 and no GPU test with Partner::Present. A title'snumthreads(64,1,1)program over 12,500 instructions (likely including the PR's 370 KB particle program) is cut into a dispatch chain. If a cut breaks the exchange (store, barrier, load, barrier), or the arrival-order half assignment in a later piece, continuation values come out silently wrong. The PR's tests check one whole program (mask_exchange) and a disassembly, never a chained Present program. Keeping Present programs whole, as before, until the chained form has a GPU test would avoid the risk.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:21:31Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T01:46:26Z.
Updated to
e3dabe10(rebased on main078358a0) after @Foniass's review of334564ab:Partner::Presentlet a split 64-thread program over the instruction limit go tosplit_compute.finish_dispatchnow keeps a split program at the group barrier whole, as it does for one with the counters. So the switch changes only how the halves meet and brings back no chains. New test:a_split_wave64_compute_program_at_the_group_barrier_stays_whole. Native wave32 programs are not split and still chain as before; they usePartner::Presenttoo.=0gives the group barrier and no chain); the HLSL path defaults to the group barrier (=1gives the counters).@i7Gamer, thanks for the 5090 runs and the chain test. With this change the switch no longer sends these programs into a chain, so the chain path stays as on
mainand this PR doesn't need that test. It would still make a good test-only PR for the chain path itself.Suite on
e3dabe10: 3007 passed, 0 failed, 52 ignored, 28 SKIPPED. Smoke blocks in the description are rerun on this head. One 420 s title run with the switch on this head: no hang, no device removal, no crash. The timing table in the description is still from the previous head.AI use: Claude Code (Claude Opus 5.5) made the change, ran the suite and the runs, and wrote this.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T01:48:48Z.
Follow-up review of
e3dabe10, since334564ab(code reading only, not a merge-check) · no new findingsIn short: This push answers both points from my last review. With
XCL_WAVE64_SPIN=0, a split one-wave compute program that meets its other half at the group barrier is now kept whole above the dispatch piece limit, as with the counters, so no dispatch chain of that untested form is made. A test checks it. The doc paragraph now gives each translator's default correctly. Nothing blocks it.Checked and fine
finish_dispatch(gpu/dxil/kernel.rs~941) now skipssplit_computewhenself.split && self.partner == Partner::Present.Partner::Presentis chosen only for 33-64 threads withone_wave_spin_wanted()false (~907), so only with the switch. Smaller groups getMissingand larger onesSpin, as before.a_split_wave64_compute_program_at_the_group_barrier_stays_wholebuilds a program well past the piece limit under the switch, assertsPartner::Present, then checks it has no dispatch chain and validates.docs/wave64-on-wave32.md~75-78 now says the direct translator uses the counters by default for one-wave compute and mesh groups,XCL_WAVE64_SPIN=0gives them the group barrier with no chain, and the HLSL path uses the group barrier by default (=1gives it the counters).IDIOMS_IN_TESTnow reaches the translator thread, like the spin override.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T07:40:34Z.
Test report for this head (
e3dabe10): the switch's effect in a retail title's gameplay.Tree: main
395405e4merged with #3094 (8a28d317), #3282 (ea91c5f4) and this PR (e3dabe10), release.Hardware: RTX 5070 Ti, driver 32.0.16.2124; i7-12700K; Windows 11 Pro 26200.
Settings: the 16-window layout, without which this title's world stays black:
XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_VIEW_REACH_MB=36 XCL_MIRROR_FILL_MB=128 XCL_TWO_PASS_MB=4096XCL_TEXTURE_LEVEL_PAGES=1 XCL_ALIAS_COPY=1 XCL_PAIR_PAGES=1Runs: 1300 s each, A pressed once at 70 s, the same binary and warm shader caches; only
XCL_WAVE64_SPINdiffers. Each run spends its last ~17 minutes in the first gameplay scene.XCL_WAVE64_SPINWith the switch, gameplay runs about 45 % faster.
Image: the lit HDR target, dumped with
XCL_DUMP_TARGETSafter 900 or 1000 s, looks the same with and without the switch. That includes a speckled patch over one window, which appears in runs with both settings. The three RGBA8 G-buffer targets have the same number of drawn texels within 1 %. The format-29 target varies between runs, from 134,066 to 186,423 of 230,400 sampled texels, and the lowest count is in one of the default runs. The other default run (185,767) is close to both runs with the switch, so the difference does not follow the switch.Not checked: AMD; a wave64 adapter.
AI use: Claude Code, Claude Opus 5.5 ran the runs and wrote this report.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.