Repository navigation
Conversation
…roup barrier On a GPU with 32-lane waves, the two halves of a console wave64 exchange words. In the direct DXIL translator the halves of a compute or mesh group of one console wave meet through bounded arrival counters since xcl-dev#1741 (a guess at the hang of xcl-dev#1727); the HLSL path meets them at a group barrier unless XCL_WAVE64_SPIN asks for the counters. The direct translator did not read the switch, although it is in the cache keys. In a retail title on an RTX 5070 Ti one such compute program (a particle update, 191 exchanges, numthreads(64,1,1)) takes 50 ms at every dispatch: one half polls its partner's counter to the limit of 1 << 20 and gives up, about 57 times a frame, 2.8 s of a 4.2 s frame. With the poll limit cut to 16,384 for that program a call takes 0.9 ms, with the group barrier 0.1 ms. The translated program is consistent (the exchange number and the counters agree on every path), a half that leaves the program was ruled out, and so were the mask plan and the memory fences: the counters do not work for this program on this driver, the barrier does. XCL_WAVE64_SPIN=0 now gives one-wave compute and mesh groups the group barrier in the direct translator too. The default stays the counters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Review (head 334564a, diff read, not a merge-check):
Fine: opt-in with the default unchanged; AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Independent NVIDIA validation: RTX 5090, driver 616.56, Windows 11. The DXIL structure test and synthetic GPU readback test passed without skips on base 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? |
|
Follow-up on the larger dispatch-chain case: I ran a synthetic regression test on 334564a with 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. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 334564ab: 1 finding(s) (1 medium), most severe first.
- Medium
crates/xcl/src/gpu/dxil/kernel.rs:887: see below.
On lines outside the diff:
- Medium
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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
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. 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; a test override that goes along into the translator's thread. Groups of several console waves keep the counters.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: two sentences that said the direct translator always uses the counters for compute and mesh.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on 334564a (on main f07e426): 2904 passed, 0 failed, 51 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.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 Recompiler: programs whose compact table needs more than 12,288 words take the plain form again #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 (two warm-ups, the two above, one with frame dumps): no device removal, no crash, no hang.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. In this session the title lost the D3D12 device (0x887a0006) near 120 s in 1 of 3 runs of main f07e426 and in 1 of 3 runs of this head; the blocks are a clean run of each.
Not tested
AI use
🤖 Generated with Claude Code