Skip to content

Recompiler: emit globallycoherent on compute memory windows only when needed - #1850

Open
certified-retart wants to merge 1 commit into
xcl-dev:mainfrom
certified-retart:recomp/conditional-globallycoherent
Open

certified-retart wants to merge 1 commit into
xcl-dev:mainfrom
certified-retart:recomp/conditional-globallycoherent

Conversation

@certified-retart

@certified-retart certified-retart commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Only emit globallycoherent on compute shaders' flat memory windows (mem, mem1… and XCL_HEAP_WINDOWS heap views) when the RDNA2 program actually uses cross-workgroup flat-memory coherence (GLC/DLC/SLC, flat-memory atomics, or data cache invalidation). Part of #675 and #1269.

Previously both the HLSL emitter and the direct DXIL translator marked every compute shader's flat memory UAVs globallycoherent unconditionally so cross-workgroup algorithms (such as bottom-up BVH builds) would see other workgroups' writes. On NVIDIA D3D12 hardware, globallycoherent bypasses SM L1 for every RWByteAddressBuffer load—including uniform SMEM loads that all threads in a wave fetch from the same address—turning L1 broadcasts into serialized L2 traffic (and on imported host-memory heaps, multi-microsecond GPU-wide serialized loads).

On RDNA2 hardware itself, a workgroup can span both CUs of a WGP (each with its own GL0 cache), so any console shader relying on cross-wave or cross-workgroup flat-memory visibility already emits GLC/DLC/SLC, atomics, or cache invalidations. Plain compute shaders without any of those only access read-only or disjointly written memory within the dispatch and can safely keep L1 caching enabled.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs: add shared needs_coherent_mem(insts: &[Decoded]) -> bool returning true iff the program contains any flat-memory atomic (BUFFER_ATOMIC_*, GLOBAL_ATOMIC_*, FLAT_ATOMIC_*), GLC/DLC/SLC on ENC_SMEM/ENC_MUBUF/ENC_MTBUF/ENC_FLAT/ENC_FLAT_GLBL, or cache invalidation (S_DCACHE_INV, S_GL1_INV, BUFFER_GL0_INV, BUFFER_GL1_INV); set em.coherent_mem in translate().
  • crates/xcl/src/gpu/recomp/emit.rs: emit globallycoherent on root mem/mem1… declarations and XCL_HEAP_WINDOWS accessors (XCL_MW) only when self.coherent_mem is set.
  • crates/xcl/src/gpu/dxil/kernel.rs & crates/xcl/src/gpu/recomp/lower_dxil.rs: pass cs.is_some() && recomp::needs_coherent_mem(insts) to mem_windows in Lw::new (covering both direct DXIL and lower_dxil).
  • crates/xcl/src/gpu/recomp/tests.rs: add compute_globallycoherent_only_when_needed (HLSL root/switch/heap, Mode::Kernel, and Direct DXIL annotateHandle IsGloballyCoherent bit checks across all triggers) and gpu_compute_coherent_and_cached_loads (real GPU execution of cached plain compute and multi-workgroup coherent atomic+GLC compute across both HLSL and Direct DXIL).

Measured GPU impact (RTX 5070)

  • Controlled SMEM microbenchmark (80× Load4, 320×180×1 groups of 8×8×1):
    • Root UAV: 6.140 ms (globallycoherent) → 0.552 ms (cached) — 11.1× faster
    • Heap window UAV (XCL_HEAP_WINDOWS=1): 6.975 ms → 0.538 ms — 13.0× faster
  • Isolated retail compute shader (320×180×1, zero-initialized memory):
    • Switch mode: 4.921 ms → 2.297 ms (2.14× faster)
    • Heap windows: 5.514 ms → 2.171 ms (2.54× faster)
  • Live heavy retail title 3D world load (XCL_GPU_PROFILE=1, XCL_HEAP_WINDOWS=1):
    • Heavy 4×4×4 / 8×8×1 world-load compute passes that previously took 17–494 ms per dispatch (1,001 ms in 460 ops) dropped by 6×–37× (e.g. an 85.4 ms 16×16×16 pass dropped to 2.3 ms), allowing the title to advance through 10+ consecutive 3D world frames (~24k dispatches).

Tested

  • NVIDIA GeForce RTX 5070, AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, XCL_D3D12_DIR Agility SDK v614, DXC 1.9.2602.17.
  • Rebased onto main cbc296a (ecc9723):
    • cargo test -p xcl --lib compute_globallycoherent_only_when_needed -- --nocapture: 1 passed, 0 failed (HLSL & Direct DXIL).
    • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_compute_coherent_and_cached_loads -- --nocapture: 1 passed, 0 failed.
    • cargo test --workspace -- --test-threads=4 passed with 0 failures on prior rebase (3da2abb); targeted unit and real-GPU tests plus 60 s smoke re-verified on ecc9723.
    • SKIPPED GPU tests on this host: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64), shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Regression run
main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5070
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1682 (PresentX 1682)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15030 MB

PR:

xcl-smoke v1
commit: ecc9723b6cdbd8e33ea00fabfa72987ba71337bc
gpu: NVIDIA GeForce RTX 5070
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1685 (PresentX 1685)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15660 MB

Not tested

  • AMD / Intel GPUs and native wave64-hardware-only GPU tests.

AI use

  • Antigravity with Gemini 4 Neon: designed, implemented, benchmarked, rebased, and wrote tests and PR description; all tests, microbenchmarks, live world-load profiles, and matched smoke runs were executed and verified locally on an RTX 5070.

@thehollowedone

thehollowedone commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested

On 0861c8ce, both stock tests passed on the RTX 3080 Ti. That covered the generated coherence flags and the synthetic cached-load and atomic-ticket readbacks.

I also ran a separate HLSL microbenchmark that varied only globallycoherent on a single root UAV. Each of 8,192 groups of 32 threads summed 80 group-uniform Load4 reads and stored one result per thread. Both versions matched the CPU values at all 262,144 output positions. GPU timestamps excluded pipeline creation, uploads, and CPU waits. In coherent / cached / cached / coherent order, the medians were 0.1966 / 0.0410 / 0.0420 / 0.1966 ms, with nine measured dispatches per batch after omitting the first.

Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1 passed 1/1 each for compute_globallycoherent_only_when_needed, gpu_compute_coherent_and_cached_loads, and the local scratch_coherence_flag_timing_on_root_uav fixture. Zero skips.

Not tested

The timings isolate the qualifier on an HLSL compute shader. This does not measure retail frame time or descriptor-heap dispatch performance.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the timing fixture and drafted this report.

Descriptor-heap retest on the same revision

I ran the cached-load and atomic-ticket fixtures with two distinct 4 KiB descriptor-heap views on the same RTX 3080 Ti setup. The shader addressed window 1 for its input, output, and atomic counter. Window 0 held sentinels at the same offsets.

HLSL, per-instruction DXIL, and per-lane DXIL each returned all 128 expected load results and all 512 atomic tickets, with a final counter of 512. All 1,024 sentinel words in window 0 stayed intact in both cases. Each backend was compiled and dispatched directly.

cargo test --offline --locked -p xcl --lib scratch_gpu_two_heap_windows_coherence -- --nocapture --test-threads=1 passed 1/1 with zero skips. This measures correctness through descriptor-heap views. The timing above remains for the root UAV only.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

On Ampere: RTX 3070 8 GB (32-lane waves), driver 616.56, Windows 11, debug.

Merge with main 689f2db: one conflict, in dxil/kernel.rs. main added Entry::Geometry to the res line. Keeping main's res and your two coherent / mem_windows lines builds cleanly.

cargo test -p xcl --lib -- gpu_ coherent --skip gpu_sparse_vram --test-threads=4:

Tree HLSL path XCL_DIRECT_DXIL=1
main 689f2db 111 passed, 1 failed* 112 passed
0861c8c on 689f2db 114 passed 114 passed

*coherent_buffer_sanitizes_console_flags_and_state, the VirtualFree flake from #1487 / #1590, on main only. The extra passes are your compute_globallycoherent_only_when_needed and gpu_compute_coherent_and_cached_loads (both paths). No new failures, including the split-wave64 and BVH GPU tests. XCL's own cross-wave state (exchange slots, barrier counters, XCL_WT) is in groupshared, so dropping globallycoherent from the memory windows doesn't touch it. The sparse test was skipped because of #1727.

AI-assisted (Claude Code). Synthetic tests only.

@CharlyRien

CharlyRien commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested (RTX 3090, 32-lane waves so the split wave64 form, XCL_HEAP_WINDOWS=1)

I applied the HLSL-path part of this PR (needs_coherent_mem and the two emit.rs sites, not the direct-DXIL part) on the tree under Setup below and ran a heavy retail title into its 3D world. GPU times below are D3D12 timestamp queries around each dispatch.

1. The rule removes the worst dispatches here

with the qualifier without it
one captured world-load dispatch (32x32x2 groups of 4x4x4), replayed offline with its real inputs 7 369 ms (7.2 – 8.2 s in the title, three per frame) 9.95 ms, byte-identical output
same program and a second one (64x64x1, 16.6 – 17.0 s before), in the title in every list of operations over 1 s no longer in it (two runs)

2. Why it is seconds here and milliseconds in the description: the imported host-memory heap

The cost is not only the L1 bypass. It depends on what backs the memory window. Micro-benchmark, one heap view, 1 024 dependent loads per thread, ns per load per wave:

memory behind the view globallycoherent plain
video memory 177 72
host memory imported with OpenExistingHeapFromAddress (the committed window) 5 875, and serialized GPU-wide (64 independent groups: 374 ms) 73

So a coherent load from the committed window is about 30 times more expensive than the same load from video memory, and other groups wait for it. That is what turned loops over a constant buffer into 8 s dispatches.

3. What remains with the rule: programs kept for one atomic

About 23 % of the pack's compute programs keep the qualifier under this rule. In a world frame they now carry almost all the GPU time, about 5 s per frame on the main queue:

dispatch this PR's rule (two runs) committed window in video memory (#1329 forced with XCL_UMA_SHADOW=1, two runs)
160x90x1 2.1 – 2.4 s 4 – 8 ms
57600x1x1 0.8 – 1.5 s 5 – 7 ms
three more at 160x90x1 or 57600x1x1 0.3 – 0.4 s each not in the 25 heaviest

Every one of these is kept because of a buffer_atomic_add or buffer_atomic_cmpswap (GLC on the atomic itself); their ordinary loads carry no GLC. So the next step could be per instruction rather than per program: a coherent view for the instructions that ask for it and a plain view of the same window for the rest. I am measuring that offline (whether a plain view stays fast when a coherent view of the same heap is used in the same shader, and whether outputs match) and will report here.

Setup (edited in: the exact stack)

Not tested

  • The direct-DXIL part of the PR, current main, AMD or Intel GPUs. No scripts/smoke.ps1 block: the base is old and carries local diagnostics.
  • The per-frame total: in the run with the PR's rule, pipelines not yet recompiled were skipped (XCL_PSO_WAIT_MS=50), so 5 s per frame is a lower bound. The per-dispatch times are not affected.
  • The D3D12.X: the committed window gets a copy in video memory #1329 path is not a usable alternative here yet: with it the compute queues stop and each frame waits for the 5 s GPU queue.Wait release. Looking into it separately.

AI use: Claude Code (Claude Fable 5.2) ran the measurements and drafted this report.

mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
…to ethans-superbuild

- dxil/kernel.rs: needs_coherent_mem in Lw::new; TRANSLATOR_VERSION stays 9.
- recomp/mod.rs: needs_coherent_mem beside the compact backend; prepare sets
  Em::coherent_mem for both backends.
- recomp/tests.rs: both new tests.

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

Copy link
Copy Markdown

Title runs with both parts of 0861c8c (direct DXIL and HLSL) on an RTX 3080 10 GB (driver 610.88), XCL_DIRECT_DXIL=1, retail 1.0.2.1 into the world load. This adds the direct-DXIL path to @CharlyRien's HLSL-path numbers.

Tree: main 4178e88 + #640 + #742 + #751 + #800 + #1055 + #1405 + #1580 + #1765 + #1766 + #1791, and this PR ported by hand. kernel.rs and mod.rs needed the change re-applied on that base, because kernel.rs decodes into cfg.insts there. I didn't port the tests. XCL_PSO_WAIT_MS=50 XCL_PAGE_BUDGET_MB=4096, warm caches, A every 10 s.

1. The program from #1766's example, CS 79d178afa02abd49 (XCL_GPU_PROFILE, per dispatch, same tree with and without this PR):

without (1 run) with (1 run)
median 56.3 ms 6.4 ms
longest 564.2 ms 77.3 ms

2. The GPU wait stalls (#1452) over the whole run:

without with
queue.Wait … released on CPU 5 in 197 s (same tree), 88 and 106 (tree without #1580/#1766/#751, 600 s) 2, 0, 0, 19 (4 runs, 213–480 s)
alive at the end 0 of 3 2 of 4 (420 s and 480 s, still loading, the screen shows a spinner)

The two runs with this PR that ended early, at 213 s and 225 s, are the title reading through garbage pointers (the #1164 family), not GPU waits.

Not tested: this PR's own head (only the port); its tests on this base; AMD.

AI use: Claude Code (Claude Opus 5.5) ported the change, ran the runs and wrote this.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@certified-retart
certified-retart force-pushed the recomp/conditional-globallycoherent branch from 0861c8c to dc7565d Compare November 25, 2026 01:45
@certified-retart

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto \main\ (\3da2abb, new head \dc7565d) to resolve the \dxil/kernel.rs\ and
ecomp/tests.rs\ conflicts. Re-ran the full workspace test suite (1,113 passed, 0 failed), direct-DXIL tests, and fresh matched 60 s smoke runs. Thanks everyone for the thorough independent benchmarks and verification!

@certified-retart
certified-retart force-pushed the recomp/conditional-globallycoherent branch from dc7565d to e878d28 Compare November 25, 2026 01:58
@certified-retart

Copy link
Copy Markdown
Contributor Author

@CharlyRien I ran a quick follow-up microbenchmark on an RTX 5070 (Blackwell, Agility SDK v614, DXC 1.9.2602.17) backed by a 1 MiB host-memory buffer imported via \OpenExistingHeapFromAddress\ (64 groups × 32 threads, 512 dependent loads/thread, D3D12 timestamp queries, median of 3 measured dispatches after warmup) to test splitting plain loads and \globallycoherent\ atomics/stores in the same compute shader:

Variant (on \OpenExistingHeapFromAddress\ host memory) Median (ms) Speedup vs all-coherent
Heap all-plain loads 0.1938 ms —
Heap all-coherent (512 loads + 1 \InterlockedAdd) 13.5055 ms 1.0×
Heap split (plain \ResourceDescriptorHeap[0]\ loads + \globallycoherent\ \ResourceDescriptorHeap[0]\ atomic) 0.2283 ms 59.2×
Root UAV all-coherent (\u6) 13.8784 ms 1.0×
Root UAV split (plain \u2\ loads + \globallycoherent u6\ atomic, same GPU VA) 0.3788 ms 36.6×
Heap plain stores (512 stores/thread) 0.1572 ms —
Heap \globallycoherent\ stores (512 stores/thread) 0.1572 ms 1.0× (0% overhead)

A same-thread hazard check (plain \Load\ → coherent \Store\ → plain \Load\ → coherent \InterlockedAdd\ → plain \Load) also showed \

@certified-retart
certified-retart force-pushed the recomp/conditional-globallycoherent branch from e878d28 to ecc9723 Compare November 25, 2026 02:26
@imnicho

imnicho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

RTX 5080: a retail dispatch that does not finish with globallycoherent heap windows, and finishes without the flag

Measured tonight before I knew of this PR, so this is not a run of your code: it is the same change made by hand in one program. It supports what you measured, from a card with 32-lane waves where that dispatch ends the run.

Setup. RTX 5080 16 GB (driver 610.47), i7-7700K, Windows 10 22H2; the retail title of #675 (my own copy), XCL_NETWORK=0, no XCL_PSO_WAIT_MS, heap windows on, every pipeline already built (0 driver builds of 10 s or more in these runs), nothing skipped. Tree: main b7aa9f3 + #684 + #266 + #1288 + #1316 / #1448 + #1323 (XCL_GPU_CULPRIT=1). The longer account is on #675: #675 (comment)

In the title. Every run on this card ends in 0x887a0006 7 - 98 s after the world's set-up. The first dispatch not done at the watchdog's report is record 50625695d2e6cbe7: numthreads(4, 4, 4), groups 32x32x2, split wave64. Its own code has 87 mem.Load* and 83 xcl_loadx4 sites and no store or atomic on flat memory (whether its loads carry GLC I did not check). With a local hook that substitutes text in the HLSL of that one record and leaves every other pipeline as it is, one run each:

that program's memory windows its dispatch at the report (5 s) the run
heap, globallycoherent (as main emits them) not done 0x887a0006
heap, NonUniformResourceIndex taken off the index not done 0x887a0006
heap, the range guard taken off not done 0x887a0006
heap, without globallycoherent done about 11,400 dispatch markers further (#14557 against #3180), then 0x887a0006 with other programs not done
switch form (root UAVs, globallycoherent) done about 9,600 markers further, then the same

Synthetic, same card (my own shader in a local test: [WaveSize(32)], numthreads(4, 4, 4), groups 32x32x2, 1,024 loads a thread from 4 windows of 64 MiB of committed video memory; wall time of the dispatch, median of the three after the first):

loads switch, globallycoherent switch, plain heap, globallycoherent heap, plain heap, handles taken once, globallycoherent
addresses spread over the windows 7.8 ms 8.0 ms 7.7 ms 7.3 ms 7.7 ms
the same 64 addresses in every thread 2.2 ms 0.5 ms 4.2 ms 0.5 ms 2.2 ms
the same 64, and a store each 16th load 6.8 ms 1.3 ms 9.3 ms 3.1 ms 6.8 ms

So here too the flag costs 4 - 8x on loads every thread repeats; the heap form's handle per access doubles that once more (taking the four handles once at the start of main brings it back to the switch form's time); and for one retail program that is the difference between a dispatch that completes and a device removal. The synthetic numbers are on committed video memory, not on the imported host memory the title's windows sit on, where your numbers say the cost is higher still.

Not tested

AI use: Claude Code with Claude Fable 5.2 ran the title and the tests and wrote this.

@CharlyRien

Copy link
Copy Markdown

@certified-retart thanks for running that – it matches what we measured here, and here is the follow-up I promised above: the per-instruction form implemented in the translator and what it does to the programs this PR's rule keeps coherent.

Setup

Micro-benchmark (one shader with both views of the same imported host heap, 1 024 dependent loads per thread; ns per load per wave)

imported host heap video memory
loads through the plain view 80 79
loads through the coherent view 5 810 190
plain loads + 1 coherent atomic + 1 coherent store per thread 81 79

Atomics cost the same through either view (1 423 ns per wave), stores too (37 ns). 64 groups, whole dispatch: plain 0.085 ms, coherent 373 ms, split 0.161 ms. Results exact in every run (65 536 of 65 536 tickets distinct, counter exact, stores visible to the CPU). The DXIL has one createHandleFromHeap and two annotateHandle.

On the pack

  • Every program this PR's rule keeps coherent (about 23 % of the compute programs) takes the split; none has a cache invalidation. In total 3 773 memory instructions go through the coherent view and 146 487 through the plain one (median per program: 2 against 224). In the seven programs that carry the remaining GPU time of a world frame the coherent instructions are only buffer_atomic_*: 1 of 109 memory instructions in the heaviest one, 1 of 12, 4 of 22, 6 of 32, 1 of 14, 2 of 61, 74 of 452.
  • Replay with synthetic inputs (the committed window on the imported heap): the 160x90x1 dispatch that takes 2.1 – 2.4 s in the title takes 2 462 – 2 656 ms whole-program and 21.0 – 22.6 ms split (21.5 – 27.4 ms with no qualifier at all); the 57600x1x1 one 334 – 351 ms against 0.104 ms. Memory windows after the dispatch are identical across the variants.
  • Cross-group test on the GPU: two groups take atomic tickets, store a flag with a GLC store, read it back with a plain load and spin with a GLC load on the other group's flag. It passes 20 rounds with the split and 20 with the whole-program qualifier; the control with every qualifier removed lets only 64 of 128 threads see the other group's flag, so the coherent view is what makes it work.
  • GPU test suite of the translator on this tree: 125 passed, 0 failed.

Not tested yet

  • In the title, and on real captured inputs for these programs (two capture runs died of unrelated causes); that run is next and I will add the per-frame GPU time here.
  • The risk that a plain load keeps stale data another group changed inside the same dispatch without a GLC load: by the console's own rules such a read needs GLC, but I have not searched the pack for a program that relies on it by accident.
  • The direct-DXIL path, the switch-window form (falls back to whole-program), AMD and Intel.

I can post the diff (emit.rs, the _c copies of the memory helpers and the test) if you want to fold it into this PR or a follow-up.

AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the implementation and the benchmark) did this and drafted the report.

@JJAutoCompare

Copy link
Copy Markdown

PR #1850 qualifier test

Tested

  • PR #1850 was open at ecc9723b6cdbd8e33ea00fabfa72987ba71337bc before and after the run. The assigned checkout was clean at that commit before and after the test. Before the run, GitHub returned nine discussion comments, zero reviews and zero inline review comments. I found no independent report of this qualifier test at the exact head in those comments. After the run, GitHub's public PR page still showed the PR open and the same discussion comment IDs. The public Git ref confirmed the exact SHA.
  • Windows 11 Enterprise Evaluation x64 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc, LLVM 23.1.5), Cargo 1.100.0 (3acc79c0c). Cargo used the unoptimized test profile with debug info disabled. The fixture logged DXC and DXIL 1.9.2609.5 (DXC build 01b62ad4).
  • Process environment used XCL_ADAPTER=A770, XCL_DXC_DIR=C:\Users\ljensen\AppData\Local\XclTooling\dxc-1.9.2609\bin\x64, CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0, CARGO_TARGET_DIR=L:/XclTooling/pr1778-2e2ee55-20261125-020159/target, and both TEMP and TMP set to L:/XclTooling/pr1850/temp.
  • 1 passed, 0 failed, 0 ignored, 0 skipped (zero SKIPPED lines), with 1,125 filtered out and exit code 0. The fixture verified the generated HLSL qualifier for plain compute and the checked-in coherence triggers across single-root, multi-window switch, and descriptor-heap configurations. It checked that kernel-mode HLSL omits the qualifier for the atomic case. With DXC loaded, it also checked the direct-DXIL IsGloballyCoherent bit for plain and atomic compute shaders in single-root and descriptor-heap configurations.
& 'C:\Users\ljensen\.cargo\bin\cargo.exe' test -p xcl --lib gpu::recomp::tests::compute_globallycoherent_only_when_needed -- --exact --nocapture --test-threads=1
  • Raw logs share the prefix L:/XclTooling/pr1850/qualifier-ecc9723-20261125T025429671Z and have .environment.log, .stdout.log, and .stderr.log suffixes. Cargo emitted two Rust fetch_update deprecation warnings.

Not tested

  • GPU dispatch and readback, driver-level compatibility, performance, retail titles, smoke tests, release builds, and the full workspace suite. The earlier PR #2067 report covers the GPU fixture gpu_compute_coherent_and_cached_loads on its own revision, a03bc75e8bebe1dc9864356fd875abb9c5b165fb.

AI use

  • T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and recorded the results.

theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
Conflicts:
- the translator's version is one of its own (its output differs from main's: globallycoherent
  windows only where a program needs them, xcl-dev#1850);
- compute and graphics driver blobs reach the disk cache also when the store in memory is full
  (main's read_pso_cached_blob and graphics blobs, our return of the blob);
- sparse: our copies back with main's lock_state and wait notes;
- title textures: our uploads on the title's queue in main's batches (256 textures, 32 MiB);
- DirectStorage: a page list is read again at execution (xcl-dev#1405) through main's read_own (xcl-dev#509);
- list_x / bind: our diagnostics and the ExecuteIndirect guard kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TyraelDauthau

Copy link
Copy Markdown

Tested ecc9723 alone (release) on the retail title of #675 with heap windows: no GPU reset in 12 runs, 10 of which reached the world load (9 of those with a warm cache).

RTX 5060 Ti 16 GB (driver 610.88), Ryzen 9 9900X, Windows 11 build 26300, DXC 1.9.2609.5. XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1, A pressed every 10 s from 20 s (XCL_PRESS_A_AT), 100 s per run with scripts/smoke.ps1, the first run on an empty XCL cache. A reset is an nvlddmkm event in the System log.

Translator Runs Reached the world load GPU resets
direct DXIL (XCL_DIRECT_DXIL=1) 6, the first cold 5; the sixth crashed at 36 s in CPU texture detiling, which this PR does not touch 0
HLSL 6, the first partly cold 6 0

Before this PR, on c4d37be with the same input (builds and settings varied), 6 of 10 warm heap-window runs reset the GPU at the world load, and 0 of 3 cold. One dispatch of 50625695d2e6cbe7, the program in imnicho's report, took 1.6 s there, near Windows' 2 s timeout.

Not tested

  • main with heap windows on this base: the runs before this PR are on c4d37be.
  • GPU time per program on this head, AMD, Intel.

AI use: Claude Code (Claude Opus 5.5) built the head, ran the runs and drafted this report.

@imnicho

imnicho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

RTX 5080 16 GB, the title on this PR's rule (the follow-up I promised above): the dispatch that hung takes 7 ms; what is left are the programs the rule keeps coherent

Setup. As in my comment above (RTX 5080 16 GB, driver 610.47, 32-lane waves; i7-7700K, 16 GB RAM; Windows 10 22H2; the retail title of #675, my own copy; XCL_NETWORK=0, binds waiting, nothing skipped but in the one run named below). Tree: #2057 at f862f5f, which carries this PR's rule (its needs_coherent_mem is the same as ecc9723's), + #684 + #266; from the fourth section on also #1515 (the budget in the memory line). XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HUGE_PSO_CONCURRENCY=2, release. Five 15-minute runs filled the caches first; the numbers are from the runs after them. TdrDelay is 8 s on this PC.

1. The program of my first table (50625695d2e6cbe7, 4x4x4 threads, groups 32x32x2). With this rule it is not coherent any more, and in #1766's profile it takes 7.4 ms a call, longest 15.1 ms (the 9 calls that reached the 2 s lists of one run). Before, it was the first dispatch not done at every device removal.

2. The device is still removed, later (imported host memory behind the committed window, the default on this card). Seven runs: 0x887a0006 at 93, 153, 233 and 722 s after the world's set-up in four of them, each with a System event 4101 (the display driver stopped responding) at that time; the other three ended in the title after the GPU-wait watchdog had released 47 to 146 waits: two in an exception, one at the null write of #675's title, 25 s after a burst of dispatches skipped with "unified memory is full" (the committed window at 4,095 of 4,095 MB). Frames after the set-up: 13 to 285 a run. On the tree of my first comment the removal came 7 to 98 s after the set-up.

3. Where the GPU time is now (one run with XCL_GPU_PROFILE=1, 35 world frames, 89.8 s of console GPU time in all, removal 156 s after the set-up):

program (threads, code, groups) calls ms a call longest kept coherent by the rule
1b5466f261a70cde (8x8x1, 9,060 B, 160x90x1) 35 359.7 1,874.8 yes
19a1c1ba0b567618 (8x8x1, 1,148 B, 160x90x1) 35 204.1 2,771.5 yes
9dc85ad397cbaffe (8x8x1, 2,404 B, 160x90x1) 35 199.7 2,655.9 yes
3429c04607b00016 (32x1x1, 684 B, 57600x1x1) 35 187.6 1,385.3 yes
b78fa10b425b8e54 (8x8x1, 7,228 B, 160x90x1) 35 184.2 480.6 no
56446569eccb04f0 (32x1x1, 2,052 B, 57600x1x1) 35 154.7 2,154.0 yes
67657769b50d2f8b (32x1x1, 4,196 B, 57600x1x1) 35 140.3 1,072.9 yes

"Kept coherent" is from each program's translated source. Later in that run single calls reached 3.0 s (9dc85ad397cbaffe) and 3.4 s (3429c04607b00016). This is the picture of @CharlyRien's section 3 above, on another card.

4. With the committed window in video memory (XCL_UMA_SHADOW=1, #1329 as #2057 has it): three runs, 0 waits released, no device removal (two ran to their 300 s limit, one ended at 252 s at the title's int3 of #1164). In the two that had the profile on, the six coherent programs take 1 ms a call or less (longest call 3.4 ms), and all console code of a run is 5.1 and 6.6 s of GPU time (120 to 140 ms per world frame, against 2,566 ms in the run of section 3). The cost on a 16 GB card: 19.4 GB of local video memory against a budget of 15.2 GB. Without the shadow it is 15.4 GB against 15.1 GB, so this card is at its budget in the Series X profile either way.

5. Instruction by instruction. That is #2067 now. I had made the direct-path part of the same idea locally before I saw it, and measured it in this title: the frame's console GPU time falls by about a third without the shadow, five of the six coherent programs above take 2.4 to more than 10 times less a call, the sixth (56446569eccb04f0, one buffer_atomic_add with GLC in a dispatch of 57,600 groups) does not, and the device is still removed. The table is on #2067: #2067 (comment)

Not tested

AI use: Claude Code with Claude Fable 5.2 ran the title and the tests and wrote this.

@bielfreedom

Copy link
Copy Markdown

AMD RDNA4 offline numbers for #1850: AMD driver time −2.3 % (repeats in both rounds), but DXC's DXIL grows 6.9 %. That is on the HLSL path, 24 retail compute programs; 21 of the 24 lose globallycoherent.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700, 32 GB RAM, Windows 11. DXC 1.8.2502.11, release.
  • Builds:
    • base cbc296a;
    • cbc296a + this PR ecc9723, merged cleanly.
  • Both builds carry a local patch that only logs per-program DXIL size and per-CreateComputePipelineState time.

Method

  • The same 24 compute programs as my A14 rows: 7.6 KB to 1.0 MB of DXIL, 6 per size bucket.
  • xcl shaders --precompile --only cs, then --pipelines from that cache.
  • XCL_HEAP_WINDOWS=0, XCL_DXC_THREADS=1, XCL_PIPELINE_THREADS=1.
  • XCL_PSO_DISK_CACHE=0, with a fresh exe name per phase, since the AMD driver cache is keyed on it.
  • 2 rounds, interleaved with the base.

Totals (round 1 / round 2; 0 refused in all runs)

base #1850
driver, sum of 24 176.2 / 173.2 s 171.3 / 170.2 s (−2.3 %)
512 KB+ bucket 128.4 / 125.4 s 124.7 / 124.8 s (−1.7 %)
total DXIL 7.564 MB 8.086 MB (+6.9 %)
translation + DXC wall 104.4 / 104.6 s 106.1 / 99.1 s
driver-phase peak private 4.49 GB 4.50 GB

Per program (mean of 2 rounds)

  • DXIL changed for 21 of 24 programs, all upward: +0.8 % to +10.7 %. The four ~0.9–1 MB programs grew +8.4 to +9.1 %.
  • The three unchanged ones are presumably the programs that still need coherence (43, 171 and 182 KB).
  • Driver time ratios were ×0.87 to ×1.14. Most fell between ×0.95 and ×1.00, and the largest four were ×0.95 to ×1.00.

Read / inference

  • On RDNA4 the compile-time effect is small but consistent in the right direction. The usual round-to-round spread on this machine is about ±2–5 %, so I'd call it "no regression, maybe −2 %".
  • The diff only drops the globallycoherent qualifier, so the DXIL growth comes from DXC treating non-coherent UAV access differently. Possibly it combines or reorders more freely. I did not look at the DXIL to confirm. It does not slow the AMD driver here, but the description might want to mention it, since DXIL size is used as a cost proxy elsewhere in [OFFICIAL] Looking for PRs with shaders optimization #1269.
  • The main expected gain of this PR is GPU run time (cached UAV access). This offline run doesn't measure that.

Not tested

  • Dispatch GPU time.
  • A title run.
  • The direct route (lower_dxil.rs / kernel.rs changes).
  • XCL_HEAP_WINDOWS=1.

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

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.

10 participants