Skip to content

Recompiler: split single-wave compute groups of any shape - #2353

Draft
zohaiblazuli wants to merge 4 commits into
xcl-dev:mainfrom
zohaiblazuli:split-single-wave-any-shape
Draft

zohaiblazuli wants to merge 4 commits into
xcl-dev:mainfrom
zohaiblazuli:split-single-wave-any-shape

Conversation

@zohaiblazuli

@zohaiblazuli zohaiblazuli commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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 in lanes.rs hands 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_compute itself 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=4 on 7e92361: 1260 passed, 2 failed, 46 ignored. The two failures, pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator and device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa, also fail on the base 4de5261 (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 on main.

  • 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-pso with 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:

    record pieces whole split (wall)
    219287eb2f6021fe 29 217.2 s 9.2 s
    7b468aa4210b1810 16 74.9 s 5.9 s
    df45a39c275d0db5 15 65.7 s 4.0 s

Regression run

  • scripts/smoke.ps1 -Game <title> -Seconds 100, both with XCL_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.
xcl-smoke v1
commit: afc5ee86ae3a9521c9f15d96505cd73fe72f2191
gpu: NVIDIA GeForce RTX 3060
title: 6ca5cab7
seconds: 100
exit: 0x0
frames shown: 2672 (PresentX 2672)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14237 MB
xcl-smoke v1
commit: 7e92361dcea5970884e3d7d070f419bcd213472f
gpu: NVIDIA GeForce RTX 3060
title: 6ca5cab7
seconds: 100
exit: 0x0
frames shown: 2676 (PresentX 2677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14267 MB

Not tested

  • The title does not yet dispatch the changed programs, so this PR does not change its time to a milestone so far. I made 4 cold 300 s runs (2 on base 4de5261, 2 on this head), each with a fresh exe path, a fresh DXIL cache, XCL_PSO_DISK_CACHE=0, XCL_DIRECT_DXIL=1 and XCL_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.
  • AMD / Intel GPUs, native wave64 hardware, other NVIDIA cards and drivers, ExecuteIndirect (which uses the whole pipeline).
  • Timings are 1 run each, on one card.

AI use

  • Claude Code (Claude Opus 5.5) planned the work, reviewed the diff and the safety argument, ran the test suite and smoke runs, and wrote this description.
  • OpenAI Codex (GPT-6.2 Sol) wrote the code and tests and made the census and the driver timings.

🤖 Generated with Claude Code

Kalmarv and others added 4 commits November 25, 2026 06:46
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>
@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants