Repository navigation
Recompiler: split single-wave compute groups of any shape - #2353
Draft
zohaiblazuli wants to merge 4 commits into
Draft
zohaiblazuli wants to merge 4 commits into
zohaiblazuli wants to merge 4 commits into
Conversation
Use the workgroup's flat logical thread ID for the continuation of each wave32 half. Keep each counter signal with its peer wait, and transfer the per-half arrival counters and double-buffered exchange slots at a group-wide rendezvous between pieces. Wave allocation starts afresh in each piece. Leave guest LDS and partial guest waves on the whole path. Exercise four wave64s with different exchange epochs across repeated cuts and compare every output word to the whole shader and a CPU oracle. Assisted-by: OpenAI Codex (GPT-6) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adopt WebIdentity1's four-wave fixture. Two guest waves return at different points while the other waves keep exchanging. Compare the whole shader and the dispatch chain to the CPU oracle across a 3D grid. Source: xcl-dev#2097 (comment) Assisted-by: OpenAI Codex (GPT-6) Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
The dispatch-chain splitter kept every program with guest LDS whole: its mutable-global check refused xcl_lds, and its scan refused LDS loads, stores and atomics and guest barriers. Now the LDS (with the split form's exchange words at its top) is copied to the per-group scratch at each piece exit and back at the next piece's start, like the exchange slots of several split waves. Geps into it can cross a cut as their index. In the split form the lane counter lives in the LDS too, so a piece meets once more before restoring over it. One console wave follows the guest's scalar control flow, so any cut keeps its guest barriers paired. A group of several waves can branch and return apart: a piece of such a program starts only at a component every thread enters exactly once (no earlier edge jumps past it, no earlier block returns), and a loop that reads the LDS (a load or an atomic), which could poll for another wave's write past a cut, keeps the program whole.
The direct splitter took a native wave32 group only when it was exactly [32, 1, 1]. A 2-D or 3-D group of 32 threads (8x4x1 in the title) is still one console wave, but its lane setup handed out thread numbers through a group-shared counter behind two group barriers, so the program stayed whole. In a census of the title's 30 largest compute programs (direct DXIL, default settings), 8 of the 13 that stayed whole were wave32 8x4x1 with guest LDS: 14.3 MB of plain DXIL, each a 66-217 s cold NVIDIA build on an RTX 3060. - lanes.rs: a 32-thread multi-dimensional group in native wave32 takes its thread number from its lane index. The DXIL pins wave size 32, so the group is one hardware wave and the counter would give it base zero anyway. - kernel.rs / split.rs: the chain is offered by the group's thread count (one console wave) instead of [32, 1, 1]; split_compute refuses other native groups itself. A 64-thread split-wave64 group with guest LDS now gets its split lane id, so it splits like the 64x1x1 case. Groups of several waves keep every existing check. Measured cold (implicit caches off, fresh process), whole against the chain's pieces built in parallel: 219287eb2f6021fe 217.2 s -> 9.2 s (29 pieces), 7b468aa4210b1810 74.9 s -> 5.9 s, df45a39c275d0db5 65.7 s -> 4.0 s. Assisted-by: OpenAI Codex (GPT-6.2 Sol) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Two contributors checked independently and found that #2349 solves the same problem (for #2088) in a different way: #1607, group D85. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2299 (which is stacked on #2097); only the top commit belongs here (
7e92361). Part of #2088 (workstream 4, large-pipeline splitting).The direct splitter takes a native wave32 group only when it is exactly
[32, 1, 1]. A 2-D or 3-D group of 32 threads, like the title's 8×4×1, is still one console wave. But its lane setup inlanes.rshands out thread numbers through a group-shared counter behind two group barriers, so the program stays whole. In a census of the title's 30 largest compute programs (direct DXIL, default settings, on #2299's head), 8 of the 13 that stay whole are wave32 8×4×1 with guest LDS: 14.3 MB of plain DXIL, each a 66–217 s cold build on an RTX 3060. With this change all 8 split, into 15–29 pieces each.What is in it
crates/xcl/src/gpu/dxil/lanes.rs: a 32-thread 2-D / 3-D group in native wave32 takes its thread number from its lane index instead of the counter. The DXIL pins wave size 32, so the group is one hardware wave, and the counter would hand that wave base zero anyway. X, Y and Z still come from that number, x fastest. This drops the counter and both barriers for every such program, split or not.crates/xcl/src/gpu/dxil/kernel.rs: the chain is offered by the group's thread count (one console wave) instead of[32, 1, 1]. A 64-thread split-wave64 group with guest LDS now gets its split lane id, so it splits like 64×1×1. Recompiler: split direct compute programs that use guest LDS #2299's description lists that case as cut, but its translator gate still kept it whole.crates/xcl/src/gpu/dxil/module/split.rs:split_computeitself refuses native groups of more than one wave without a split lane id. Tests: Recompiler: split direct compute programs that use guest LDS #2299's LDS fixture now takes a group shape and checks each thread's x/y/z. It runs for wave32 8×4×1, 4×8×1 and 2×4×4, and for split wave64 8×4×2. A new test checks that an 8×8×1 wave32 group (two waves) is refused.README.md: one line on group shapes.Tested
RTX 3060 12 GB (NVIDIA 617.42, 32-lane waves only), Intel Core i5-14600K, 32 GB, Windows 11 Pro 26300, Rust 1.94.0, DXC 1.8.2502.11. Tests in debug, smoke and timings in release.
cargo test --workspace --no-fail-fast -- --test-threads=4on7e92361: 1260 passed, 2 failed, 46 ignored. The two failures,pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translatoranddevice_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa, also fail on the base4de5261(checked). Recompiler: split direct compute programs that use guest LDS #2299 reports the same two, and Tests: two expectations that no longer match the code #2245 fixes them onmain.SKIPPED (25): 21 wave64 cases (no native wave64), 3 per-lane f16/f32 forms the per-lane lowering refuses, and no heap windows (1).
cargo test -p xcl --lib split: 41 passed, 0 failed, 1 ignored (bench_split_wave64). The new shape tests ran on the GPU without skips. Whole and split forms each match a CPU reference word for word over 3 groups, plus 16 guard words: 3 pieces for each wave32 shape, 4 for 8×4×2.Cold
CreateComputePipelineState,xcl shaders <pack> --measure-psowith a local, not-included change that builds a chain's pieces in parallel. Implicit driver caches off, fresh process, no cached blob. The second call took under 2 ms with the first PSO alive.XCL_DIRECT_DXIL=1, 4 windows, default compact selection and split target, 1 run each:219287eb2f6021fe7b468aa4210b1810df45a39c275d0db5Regression run
scripts/smoke.ps1 -Game <title> -Seconds 100, both withXCL_DIRECT_DXIL=1(the default HLSL path does not reach this code). 100 s because the title enters a texture-heavy phase near 60 s: some 60 s runs ended before it on every revision, and peak commit then differed by ~4 GB from run to run.Not tested
4de5261, 2 on this head), each with a fresh exe path, a fresh DXIL cache,XCL_PSO_DISK_CACHE=0,XCL_DIRECT_DXIL=1andXCL_PSO_TRACE=1. The title asks for all 8 programs at 14–20 s, during startup. Each stays a lazy stand-in: none was built or dispatched, and the title waited 0 ms on them. All 4 runs reached the BC-texture and dispatch-heavy phase (≥ 100 dispatches per 2 s at 232–244 s). Not one split piece was built and not one chained dispatch was made, for any program. So the cold-build gain counts where these pipelines do get built: in a precompile, or later in the title than 300 s. The chains' GPU execution time is not measured. Recompiler: split large direct compute pipelines at CFG edges #2080's chains measured 1.57–2.06× on its test shader.AI use
🤖 Generated with Claude Code