Skip to content

Recompiler: give a compute loop above the split target its own dispatch piece - #2107

Open
Kalmarv wants to merge 6 commits into
xcl-dev:mainfrom
Kalmarv:direct-split-oversized-scc
Open

Kalmarv wants to merge 6 commits into
xcl-dev:mainfrom
Kalmarv:direct-split-oversized-scc

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1269. Stacked on #2080: only the last commit, d4b8717, is new here.

#2080 keeps each strongly connected component (every loop) in one piece and declines a program when a single component is bigger than the piece target. The title's b3618a0fd76af79c (a raytracing resolve, 120,327 DXIL instructions) has one 15,652-instruction loop against the 12,500 target, so it stays whole and takes 31 s to build cold. With this change that loop gets a piece of its own, the rest splits as before, and the program builds in 4.1 s.

What is in it

  • crates/xcl/src/gpu/dxil/module/split.rs: a component over the target gets its own piece, up to four times the target. The components around it go in separate pieces. A component over four times the target, or a plan that ends up as one piece, keeps the whole pipeline as before.
  • README.md: XCL_DIRECT_SPLIT_INSTRUCTIONS now describes the four-times ceiling.
  • Tests: a planner test on both sides of the ceiling (a two-block loop, an oversized entry block, a program that can't be partitioned). A GPU test, dispatch_chain_oversized_loop_matches_whole, gives a 55-instruction loop its own piece at a target of 40. Its whole and split outputs match the CPU reference in native wave32 (96 words) and split wave64 (192 words).

Tested

Regression run

scripts/smoke.ps1, the same retail title for 120 s each, one after the other on the machine under Tested, release builds from clean trees.

main cbc296a (the same code as this PR's base f5c5bdf, which changed only the README and its images):

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 1308 (PresentX 1308)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 29701 MB

this PR, d4b8717:

xcl-smoke v1
commit: d4b8717f92d1fcc8f3be31c2070de03ca58246fc
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 1300 (PresentX 1300)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 30395 MB

PR vs main: 1300 / 1308 frames (99 %), peak commit 30395 / 29701 MB (102 %); device removals 0 and crashes 0 on the PR run, 0 and 0 on main.

Both runs use XCL_DIRECT_DXIL=1 (the split applies only on the direct route) and start with the same private XCL pipeline cache, holding only the pipeline list; the driver's own cache was left alone. The PR run logged compute split: 33 programs split, 173 pieces built, 156 chained dispatches issued at 120 s. An earlier run on d131645 logged 52 chains and 1322 frames. Both runs stop presenting at about 64 s for a reason this change doesn't touch, and in an earlier 120 s run that logged every compute dispatch the title never dispatched b3618a0fd76af79c, so this run checks for regressions but doesn't show the build gain.

Not tested

  • b3618a0fd76af79c's output on the GPU. There is no seeded input for it yet, and the 120 s title run never dispatched it, so the title run below doesn't reach it either.
  • GPU time of the split form.
  • AMD, native wave64 on hardware, Linux.

AI use

OpenAI Codex (GPT-6) wrote the change and the tests. Claude Code (Claude Opus 5.5) helpers ran the driver timings, and Claude Code wrote this description and opened the PR.

🤖 Generated with Claude Code

@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean detached PR head d1316454dd83c20a770ac48e6df7bc08d1b3a364 on STOR-WINLAB. Windows 11 Enterprise Evaluation 25H2 x64 (26200.9974), Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5. Unoptimized test profile with debug info and incremental compilation disabled.

cargo test --locked -p xcl --lib --no-run ran outside the GPU mutex and exited 0 in 1m 55s. With XCL_ADAPTER=A770 and XCL_DXC_DIR set to the installed 1.9.2609 toolchain, ran this prebuilt command under the shared Invoke-ArcTest.ps1 -Test mutex.

& 'L:/XclTooling/pr1975-b62e6e3/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole --exact --test-threads=1 --nocapture

1 passed, 0 failed, 0 ignored, 0 skipped, 1,128 filtered out, 0.48 s. Fixture and wrapper exited 0. The oversized loop occupied its own piece at a target size of 40, and the dispatch chain contained at least three pieces for both wave forms. All 96 native-wave32 words and 192 split-wave64 words matched in the whole-dispatch vs CPU reference and split-chain vs whole-dispatch comparisons.

Not tested

Native wave64, other adapters, planner ceiling rejection cases, dispatch timing, workspace suite, and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the existing fixture, checked the evidence, and wrote this report.

Kalmarv and others added 6 commits November 25, 2026 00:00
Keep control-flow cycles in one pipeline, pass edge-live values through per-dispatch scratch and compile the pieces on the PSO workers. Direct dispatch records the chain with UAV ordering. Indirect dispatch builds the whole form on demand.

Assisted-by: OpenAI Codex (GPT-6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The synthetic split fixture declared u2 twice with different coherence flags. Bind its existing memory window and validate the whole fixture before checking the cut.

Assisted-by: OpenAI Codex (GPT-6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adjacent lanes previously accessed ef008c0f's continuation data 1,612 bytes apart. Store the tag and each live dword in a separate lane-contiguous plane; transport both halves of i64 values through their own planes.

Assisted-by: OpenAI Codex (GPT-6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adopt WebIdentity1's fixture from xcl-dev#2080. Lanes return early, skip ahead
over a piece, or run different numbers of loop iterations. Check the
whole and split outputs against the CPU model and guard words on a
2 x 3 x 2 dispatch grid for native wave32 and split wave64.

Source: xcl-dev#2080 (comment)
Assisted-by: OpenAI Codex (GPT-6)
Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
Compile and validate a partitionable CFG through the native-wave64 admission gate. On a wave64 adapter, run the whole pipeline and check its lane count and output. Identify the existing compare(64) case as two hardware waves.

Assisted-by: OpenAI Codex (GPT-6)
Allow an indivisible strongly connected component to exceed the target
up to fourfold. Keep surrounding components in separate pieces. Decline
when a component exceeds that ceiling or the result is only one piece.

Exercise both sides of the ceiling with a two-block loop, an oversized
entry block and a program that cannot be partitioned.

Assisted-by: OpenAI Codex (GPT-6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the direct-split-oversized-scc branch from d131645 to d4b8717 Compare November 25, 2026 05:01
@JoaoPauluu

Copy link
Copy Markdown

Same as on #2080, plus this PR's tests. A run with vkd3d-proton as the host D3D12. 4 of the new dispatch-chain GPU tests crash the test process inside vkd3d-proton.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. d4b8717 as it is (merge base with main f5c5bdf), no uncommitted changes. The lib test binary runs under Wine, one test per process, twice: at d131645 and at d4b8717, with the same result.
    • dispatch_chain_oversized_loop_matches_whole: crashes (see below)
    • dispatch_chain_divergent_forward_edges_3d: crashes (see below)
    • dispatch_chain_wave32_live_loops: crashes (see below)
    • dispatch_chain_wave64_live_loops_and_exchange: crashes (see below)
    • dispatch_chain_native_wave64_builds_whole: ok, SKIPPED (no wave64)
    • oversized_loop_occupies_one_piece_up_to_the_hard_ceiling: ok
  • Each failing test kills the process before it reports anything (exit 5): an access violation, page fault on read access to 0x0000000000000110, at 0x6ffffca2b118. That address is inside vkd3d-proton's d3d12core.dll, which is loaded at 0x6ffffc880000. I traced it for dispatch_chain_wave32_live_loops; the others end with the same exit code. So the host's D3D12 crashes on something the dispatch chain does. I have not found which call.

Not tested

  • the split programs on the retail title, the whole suite on this head, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
In the second XCLM run no graphics pipeline was built after world load (74 s): the workers
were all on huge compute pipelines and the split pieces of xcl-dev#2080/xcl-dev#2097/xcl-dev#2107, which went to
the lane taken first. Every draw went on with its stand-in (7936 of 19940 skipped) and the
screen stayed black. A quarter of the workers (at least 2, XCL_PSO_GFX_WORKERS) now take
graphics builds only, and compute pieces go to the front of the compute lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@bielfreedom

Copy link
Copy Markdown

AMD RDNA4 data for #2107: on the RX 9070 XT this change splits 347 more retail compute programs (462 → 809 of 2,689). The 12 measured build 9.1× faster split than whole (844 s → 93 s). Every build succeeded, and the PR's tests pass on this card.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Build: this PR at d4b8717 (on Recompiler: split large direct compute pipelines at CFG edges #2080), plus the local timing patch from my #2080 report. For a program with a dispatch_chain, the patch builds the whole DXIL, then the pieces on up to 16 threads, and times every CreateComputePipelineState.

Census (XCL_DIRECT_DXIL=1, default split target)

Measured

  • 12 of the 347, spread evenly by size.
  • XCL_PSO_DISK_CACHE=0, a fresh exe name per round (the AMD driver cache is keyed on it), 2 rounds.
direct DXIL pieces whole split, 16 threads faster sum of pieces
895 KB 11 79.4 s 6.6 s 12.1× 44.2 s
918 KB 11 76.8 s 7.4 s 10.4× 49.6 s
940 KB 11 71.1 s 9.6 s 7.4× 69.1 s
957 KB 11 65.8 s 7.9 s 8.3× 61.0 s
963 KB 11 69.0 s 7.2 s 9.6× 51.1 s
983 KB 12 76.7 s 7.2 s 10.7× 60.0 s
997 KB 12 73.1 s 9.1 s 8.0× 75.8 s
1025 KB 12 73.0 s 5.8 s 12.5× 51.1 s
1057 KB 12 50.5 s 8.5 s 6.0× 80.7 s
1096 KB 13 96.5 s 7.1 s 13.7× 55.6 s
1144 KB 13 52.6 s 9.7 s 5.4× 86.5 s
1235 KB 14 59.3 s 7.0 s 8.5× 68.0 s
total 843.8 s 93.0 s 9.1× 752.6 s

Tests on this card (XCL_REQUIRE_GPU=1, XCL_ADAPTER=9070)

  • cargo test --release -p xcl --lib -- dispatch_chain split::tests --test-threads=1: 6 passed, 0 failed, no SKIPPED notices.
  • That includes dispatch_chain_oversized_loop_matches_whole and oversized_loop_occupies_one_piece_up_to_the_hard_ceiling.

Not tested

AI use: Claude Code (Claude Opus 5.5) ran the census, timings and tests and drafted this. Counts and timings only, no game data.

@bielfreedom

Copy link
Copy Markdown

A follow-up for #2107 from the RDNA4 side. The retail program 84eee477d68b6fdf (CS_RaytracingResolve) never finishes on the HLSL path on the RX 6800 (reported on #1809) or on the RX 9070 XT (over 20 min here). On the RX 9070 XT:

Numbers and method: #1809 comment.

AI use: Claude Code (Claude Opus 5.5) wrote this. Account owner away; counts and timings only.

@bielfreedom

Copy link
Copy Markdown

Combined with #2126 on the RX 9070 XT, this PR's 12 newly split programs plus 84eee477d68b6fdf build in 34.3 s split, against 837 s whole (24×). That is 87.3 s with this PR alone. Numbers: #2126 comment.

AI use: Claude Code (Claude Opus 5.5) wrote this. Account owner away.

@thehollowedone

Copy link
Copy Markdown

Independent GPU execution timing on d4b8717, RTX 3080 Ti / 621.35, Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC and DXC 1.8.2502.11.

The stock dispatch_chain_oversized_loop_matches_whole passed (1 passed, 0 failed, 0 skips). A scratch extension of the same synthetic test used D3D12 timestamp queries around one whole dispatch or the full split chain. I ran both orders in two fresh processes and dropped the first five of 21 samples in each series. All repeated-dispatch readbacks matched. The table shows the range of series medians in µs.

Threads per group Groups Whole Split
32 256 3.07 9.22–10.24 (5 pieces)
32 4,096 9.22–10.24 24.58 (5 pieces)
64, emulated on wave32 256 3.07–4.10 13.31 (6 pieces)
64, emulated on wave32 4,096 14.34 110.59–113.66 (6 pieces)

The test command was cargo test --offline --locked -p xcl --lib dispatch_chain_oversized_loop_matches_whole -- --nocapture --test-threads=1. Both timed runs passed with zero skips. These timings cover dispatch execution, including the in-chain barriers. Compilation, upload and readback are outside the timestamps. Retail frame pacing was not tested.

AI use: Codex (GPT-6, exact variant unspecified) extended and ran the synthetic test and drafted this report.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants