Skip to content

Direct DXIL: bound single-wave split exchanges - #1741

Open
hajduzsolt wants to merge 1 commit into
xcl-dev:mainfrom
hajduzsolt:fix/direct-dxil-single-wave-spin
Open

hajduzsolt wants to merge 1 commit into
xcl-dev:mainfrom
hajduzsolt:fix/direct-dxil-single-wave-spin

Conversation

@hajduzsolt

@hajduzsolt hajduzsolt commented Nov 24, 2026 •

Copy link
Copy Markdown

Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

Tested

  • Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB: cargo test -p xcl --lib split_single_wave_uses_bounded_exchange -- --test-threads=2 passed.
  • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1 --nocapture passed (5 passed, no reported skips).
  • cargo test --workspace -- --test-threads=2 passed; library tests: 827 passed, 22 ignored. Other test binaries also passed. Runtime GPU skips were not individually assessed in this run.

Regression run

main:

xcl-smoke v1
commit: b9b6ea62080cc62fc19e212033372d01c6214e5c
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14840 MB

PR:

xcl-smoke v1
commit: 254f51a7e6faa1d757016b39979ced29ab05b24b
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14845 MB

Not tested

AI use

  • Codex (GPT 6.1 Terra Medium) wrote the implementation and synthetic unit tests; human review and smoke verification are pending.

@hajduzsolt
hajduzsolt marked this pull request as ready for review November 24, 2026 20:09
anoyarou pushed a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
@fromthemoonx

Copy link
Copy Markdown

On an NVIDIA wave32 card the #1727 hang still happens with this PR, as often as on main. The build, the tests and the new test's check are fine.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (32-lane waves, so wave64 runs split), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974); rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug

  • Direct DXIL: split wave64 uses a group barrier for 1-wave groups – GPU hangs in parallel test runs on NVIDIA (RTX 5070) #1727's reproduction, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- --test-threads=4, alternating main b9b6ea6 and this head 254f51a, 12 runs each:

    runs hung (0x887a0006)
    main 12 6
    this PR 12 6
    main, default HLSL path (no XCL_DIRECT_DXIL) 6 0

    The System log has 44 nvlddmkm event 153 entries during these runs. The hung runs fail the same wave64 tests on both trees (gpu_split_wave64_waves_diverge, gpu_wave64_ps_spill_slots, gpu_wave64_vs_spill_slots_and_identity, …), plus gpu_sparse_vram_descriptors_buffers_and_xmem and the tests that share the removed device. So the 33–64-thread group barrier does not look like the cause on this card, or not the only one.

  • Exact head 254f51a7e6faa1d757016b39979ced29ab05b24b (base 85e3826): cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 876 passed, 0 failed, 42 ignored

  • Merged onto current main b9b6ea6 (no conflict): 890 passed, 0 failed, 42 ignored

  • split_single_wave_uses_bounded_exchange fails with 33..=64 => Partner::Present put back (33 threads must use bounded counter exchange). 10 runs with the change: 10 of 10 passed.

  • Your command, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 3 of 3 passed (5 tests each). One thread does not hang on either tree.

  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows

Not tested

  • Release build; a retail title with XCL_DIRECT_DXIL=1; DRED.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds, tests and hang counts on the machine above and wrote this report from the output.

@IgorAntunes66

Copy link
Copy Markdown

Test report from split-wave64 hardware (the case listed under "Not tested"), plus a correction on the motivation.

RTX 5070 12 GB (wave32 only), driver 621.24, Windows 11 26H2, rustc 1.100.0, DXC 1.9.2602.17, PR head 254f51a (base 85e3826).

Correctness: cargo test -p xcl --lib -- --test-threads=1: 827 passed, 0 failed, 22 ignored, both without and with
XCL_DIRECT_DXIL=1 (skips: 2 × no wave64, 1 × Developer Mode). split_single_wave_uses_bounded_exchange + gpu_split_wave64*
with XCL_DIRECT_DXIL=1: 6 passed.

#1727 hang: this does not fix it. I wrote #1727's barrier hypothesis and later bisected it to the sparse VRAM test, which
#614 fixes (correction in #1727). XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu::recomp::tests::gpu_ --test-threads=4,
runs interleaved with base 85e3826:

runs hung (0x887a0006 + nvlddmkm 153)
85e3826 12 2
this PR 12 9
this PR + #614 12 0

An equivalent local patch earlier gave 9/15 vs 9/15 on c160d86, so I would not read the 9 vs 2 as this PR making it worse;
with #614 applied it is clean. So this can stand as hardening, but not as the fix for #1727.

Review notes (from reading the code, not tested):

  • TRANSLATOR_VERSION (kernel.rs:36-39) is not bumped. Its comment says it must change with any change to the emitted
    containers because gpu/dxil is not in build.rs's source hash, so existing direct-DXIL disk caches would keep serving the
    barrier form.
  • The HLSL path lets XCL_WAVE64_SPIN=0 go back to group barriers for 1-wave groups; there is no counterpart here.

AI use: Claude Code (claude-opus-5-5) ran the tests and measurements and drafted this comment; I reviewed it.

mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
Brings xcl-dev#1747, xcl-dev#1791, xcl-dev#605, xcl-dev#1679, xcl-dev#1806, xcl-dev#1745, xcl-dev#1307, xcl-dev#1321 among others.

Resolutions:
- dxil/kernel.rs: upstream's Lw::new / Lw::finish; the safe s_barrier state
  and policy and xcl-dev#1741's single-wave bounded exchange move into Lw::new, with
  a safe_barrier flag (false for the per-lane lowering).
- dxil/lower.rs: VAR_BAR_DEAD moves to VAR_BUDGET + 6 (+5 is VAR_F32_MODE).
- TRANSLATOR_VERSION 9.
- d3d12x/bind.rs: the bounded ExecuteIndirect call runs inside
  fresh_indirect_arguments.
- d3d12x/list_x.rs: tracked_list_type, and transition (pub(super)) over the
  batched transitions.
- recomp/mod.rs: compact backend and per-lane modules both kept; the
  oversized-structured-code fallback applies to translate after prepare.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

@Raul-Paiva

Copy link
Copy Markdown

A test of this PR on split-wave64 NVIDIA hardware, the case under Not tested. Counts only.

Setup:

Warm caches hide this PR. src/gpu/dxil/ is not in TRANSLATOR_SOURCES (build.rs), so with a warm translated cache the new DXIL is never built (#1947 fixes that). I changed the cache identity locally for the runs below.

Result on a retail title:

  • Without this PR (2 runs), the device was removed (0x887a0006) 3.5 s after a burst of compute dispatches. Nsight Aftermath showed the GPU hung in a 64-thread compute program (one console wave per group).
  • With this PR (6 runs), that program grows from 8.5 KB to 10.7 KB of DXIL, and Aftermath no longer finds the hang there.
  • The device removal is still there in 5 of the 6 runs, 4 – 85 s after the burst. DRED names the same partly executed list as before. Aftermath shows the hang in another 64-thread program, the one with the most cross-half exchanges (136).
  • It does not change when the spin gives up after 1 024 polls instead of 2^20 (local switch, 4 runs). So the remaining hang does not look like this PR's exchange.

A cost: the bounded exchange grows the largest compute program from 4.0 MB to 6.2 MB of DXIL. The NVIDIA driver took 92 s to build it once, and with 32 GB of RAM (47 GB commit limit) four runs and two precompile attempts ran out of memory while it was building. For the other runs I kept the group barrier locally for that one program.

Not tested: the whole suite on this tree; AMD; the HLSL path; the title without the other PRs listed above.

AI use: Claude Code (Claude Opus 5.5) applied the PR locally, ran the builds, tests and runs, read the logs and dumps, and wrote this comment.

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.

6 participants