Skip to content

Recompiler: emit per-instruction globallycoherent on compute flat memory (stacked on #1850) - #2067

Open
certified-retart wants to merge 3 commits into
xcl-dev:mainfrom
certified-retart:recomp/per-instruction-globallycoherent
Open

certified-retart wants to merge 3 commits into
xcl-dev:mainfrom
certified-retart:recomp/per-instruction-globallycoherent

Conversation

@certified-retart

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

Copy link
Copy Markdown
Contributor

What is in it

Part of #1269 (follow-up stacked on #1850 ecc9723): instead of marking every memory access in an atomic- or GLC-containing compute shader globallycoherent, split flat-memory accesses per instruction so ordinary loads (!GLC && !DLC && !SLC) stay L1-cached while coherent loads, stores, and atomics use globallycoherent views.

Why this matters: #1850 removes globallycoherent from compute shaders with no atomics/GLC/cache-inv (~77% of compute shaders), but the remaining ~23% that contain even a single atomic or GLC op still pay full L1 bypass on every ordinary SMEM/MUBUF/FLAT/GLOBAL/BVH load — which is especially costly on OpenExistingHeapFromAddress host-memory windows. Measured on RTX 5070 against 1 MiB OpenExistingHeapFromAddress host memory (64 groups x 32 threads, 512 dependent loads + 1 InterlockedAdd):

  • Heap-window split (plain ResourceDescriptorHeap loads + globallycoherent atomic): 13.51 ms -> 0.23 ms (59.2x faster)
  • Root-UAV split (plain u2 loads + globallycoherent u6 atomic on the same GPU VA): 13.88 ms -> 0.38 ms (36.6x faster)
  • Plain vs globallycoherent stores (512 stores/thread): 0.157 ms vs 0.157 ms (0.0% overhead)
  • Same-thread aliasing check (plain Load -> coherent Store -> plain Load -> coherent InterlockedAdd -> plain Load): 0/128 stale reads

Changes:

  • CoherenceMode (crates/xcl/src/gpu/recomp/mod.rs): replaces needs_coherent_mem with a three-tier classification for compute shaders:
    • None: no flat-memory atomics, GLC/DLC/SLC, or cache invalidations -> plain (L1-cached) views only (same as Recompiler: emit globallycoherent on compute memory windows only when needed #1850).
    • PerInstruction: flat-memory atomics and/or GLC/DLC/SLC ops, no data-cache invalidation -> ordinary loads (!GLC && !DLC && !SLC, including SMEM, MUBUF/MTBUF, FLAT/GLOBAL, and BVH traversal) use plain views; GLC/DLC/SLC loads, all stores (0% overhead, preserves write-through cross-workgroup visibility matching RDNA2 GL0), and all atomics (including CAS loads) use globallycoherent views.
    • AllCoherent: program contains S_DCACHE_INV, S_GL1_INV, BUFFER_GL0_INV, or BUFFER_GL1_INV -> every memory access stays globallycoherent (D3D12 has no L1-invalidate intrinsic for non-coherent UAVs).
  • HLSL emitter (crates/xcl/src/gpu/recomp/emit.rs): in PerInstruction, declares plain mem.. (u2..u5) + coherent memc.. (u6..u9) for root UAVs, or plain XCL_MW + coherent XCL_MWC indexing ResourceDescriptorHeap[MEM_HEAP_BASE + xcl_w] for XCL_HEAP_WINDOWS=1, with matching xcl_loadx4/xcl_loadx4_c, ld_raw/ld_raw_c, and xcl_m*/xcl_mc* accessors.
  • Direct DXIL backend (crates/xcl/src/gpu/dxil/kernel.rs, lower.rs, lower_mem.rs, recomp/lower.rs, recomp/lower_dxil.rs): allocates plain u2.. and coherent u6.. RawUav handles for root-UAV PerInstruction, routes loads via inst_coherent_load and stores/atomics via coherence != None (including single-window per-lane DxilIr::mem_load / mem_store shortcuts via Ir::mem_instruction), and passes per-access coherent to heap_raw_buffer_uav(i, coherent) for XCL_HEAP_WINDOWS=1.
  • ABI root signature & bindings (crates/xcl/src/gpu/recomp/pso.rs, runner.rs, hle/d3d12x/bind.rs, console_list.rs): extends the ABI root signature from 6 to 10 root UAVs (u0 io, u1 res, u2..u5 plain windows, u6..u9 coherent aliases; 20 DWORDs vs the 64-DWORD limit) and binds compute u6..u9 to the same 4 memory-window GPU VAs as u2..u5.
  • Tests (crates/xcl/src/gpu/recomp/tests.rs, lower_dxil.rs): updates compute_globallycoherent_only_when_needed for all three tiers, adds compute_per_instruction_globallycoherent (single-window, multi-window root UAV, multi-window heap, DXC SM 6.6 compile, and Direct DXIL annotateHandle 4107/20491 validation), adds per_lane_memory_shortcuts_preserve_coherence (verifying single-window per-lane S_LOAD/GLOBAL_LOAD/GLOBAL_STORE handle routing and GPU output), and extends real-GPU gpu_compute_coherent_and_cached_loads to exercise mixed plain SMEM/GLOBAL loads + atomic + coherent store + GLC=1 load across both HLSL and Direct DXIL.

Tested

  • cargo test --workspace -- --test-threads=4: 1,158 passed, 0 failed, 46 ignored across 21 test suites (on NVIDIA RTX 5070, Agility SDK v614, DXC/dxil 1.9.2602.17).
  • Targeted GPU tests on 9b35718: per_lane_memory_shortcuts_preserve_coherence, gpu_compute_coherent_and_cached_loads, and compute_per_instruction_globallycoherent all passed with 0 skips.
  • Console BVH builder E2E on GPU (cargo test -p xcl --test console_dlls_e2e -- xbox_bvh_builder_builds --nocapture --test-threads=1 with XCL_CONSOLE_LISTS=1, XCL_PROBE_BVH_GPU=1, XCL_PROBE_BVH_TLAS=1, tested on a03bc75 prior to the single-window per-lane shortcut fix):
    • HLSL + root UAVs: TLAS 800/800 rays match brute force (69 hits); BLAS 64-tri (91 hits) & 200-tri (257 hits) 500/500 rays match brute force.
    • Direct DXIL + XCL_HEAP_WINDOWS=1: TLAS 800/800 & BLAS 500/500 + 500/500 rays match brute force.

Regression run

Matched 60 s scripts/smoke.ps1 runs on RTX 5070 (baseline binary built from origin/main cbc296ab65a2661a61e3e2da109134bcd5319f60, PR binary built from 9b35718ffd32170a4fdd88601ce7e60ef8ec0393):

Baseline (origin/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 (9b35718ffd32170a4fdd88601ce7e60ef8ec0393, default root UAVs):

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

Not tested

  • AMD RDNA2/RDNA3/RDNA4 hardware (only tested on NVIDIA RTX 5070 Blackwell).
  • Extended world-load dispatch timing beyond the 60 s smoke window and the RTX 5070 OpenExistingHeapFromAddress microbenchmark; cross-vendor world-load validation welcome.

AI use

Antigravity (gemini-4-neon) implemented the per-instruction coherence pass, incorporated the single-window per-lane coherence shortcut fix reported by @WebIdentity1, ran the workspace/GPU tests and matched 60 s smoke runs, and updated this PR description.

@WebIdentity1

WebIdentity1 commented Nov 25, 2026 •

Copy link
Copy Markdown

Ready-to-pick-up fix

Packaged the verified per-lane repair and its regression as one commit: d8e7cfd, based directly on this PR's a03bc75. The committed tree matches all 322 source hashes from the Windows runs below; no source changes since those runs. The branch is on the fork for cherry-picking, with no competing PR. Runtime diff remains 9 additions / 2 deletions, plus the regression. The shared CLAMP failure and absent retail smoke still apply.

Full-workspace follow-up for the per-lane candidate

Completed the broader build/regression check for the small fix below. Both snapshots are a03bc75e8bebe1dc9864356fd875abb9c5b165fb plus the same regression; only the candidate additionally has the 9-added/2-removed runtime patch. These are local patched snapshots, not an unmodified PR-head run.

Native Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug, XCL_ADAPTER=3090:

cargo build --locked --workspace
cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output
Snapshot Workspace build Passed / failed / ignored across 21 harness summaries
PR head + regression passed 1156 / 2 / 46
PR head + candidate + regression passed 1157 / 1 / 46

The candidate removes only the new coherence-routing failure. Both retain gpu_clamp_and_omod_per_instruction, with the identical lane-0 v_pk_add_i16 clamp mismatch: actual 2146467856, expected 2147516415. Both Cargo test commands therefore exit 101. No candidate-only failure observed; not an all-green suite. The new test again executes on the named RTX 3090 and checks 64/64 outputs in both snapshots, then distinguishes handle counts [5,0,2,0] from the repaired [2,3,0,2].

Both runs have the same 27 explicit SKIPPED notices (order varies): 20 unavailable native-wave64 subcases, three refused wave32 per-lane subcases (f16 arithmetic, f16 packed, f32 conversions), two missing-debug-layer checks, one unavailable driver-cache-control check, and one unavailable heap-window check. Also identical are 13 other early-return messages: eight unset RPF sample variables, one unset TTPF, one unset AWC, one unavailable 64-lane path, one missing system xgameruntime DLL, and one heap-window opt-in/capability check. These notices are not necessarily distinct tests; some data-dependent tests return silently when sample variables are unset. Harness pass totals do not imply retail-data coverage.

All 322 source hashes in each snapshot matched before and after the Windows run and against the local patch; XCL recompiled for each. This supersedes the earlier “no full suite” limitation for this local candidate only. No AMD/native-wave64 execution, retail smoke, concurrent stale-read reproduction, or candidate performance claim. Earlier performance results farther below belong to the unchanged regular compiler, not this fix. The patch and failing-first test are ready for the author's consideration; the required clean-head/main retail gate remains outstanding.

AI use: Codex (GPT-6) prepared the patch/test and performed and reported the native Windows validation.


Follow-up: single-window per-lane shortcuts bypass the new coherence policy

Verified a narrow integration gap on unchanged a03bc75e8bebe1dc9864356fd875abb9c5b165fb. With XCL_PER_LANE=1 and one memory window, lower::smem / lower::vmem use the native Ir::mem_load / mem_store shortcuts before trying the foreign bridge. DxilIr still routes both to self.mem (u2), which is now the plain view in PerInstruction mode. Consequently GLC/DLC loads and ordinary stores miss the coherent u6 alias. Multiple windows refuse these shortcuts and take the already-correct Lw bridge; our earlier two-window timing/alias probes did not cover this path.

Small candidate below: a default no-op instruction-policy hook in Ir, implemented by DxilIr using this PR's existing coherence helpers; native loads choose the coherent alias when requested and native stores use it whenever present. None/AllCoherent keep their existing single handle. 9 added / 2 removed runtime lines, plus one regression, across two files. No competing implementation or PR.

Tested — native Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug:

cargo test --locked -p xcl --lib -- gpu::recomp::lower_dxil::tests --test-threads=1 --show-output
Snapshot Passed / failed / ignored Plain / coherent loads Plain / coherent stores
PR head + regression 18 / 1 / 0 5 / 0 2 / 0
PR head + candidate + same regression 19 / 0 / 0 2 / 3 0 / 2

Both runs emit the same 17 SKIPPED notices: 14 native-wave64 subcases unavailable on this adapter, and three existing refused wave32 per-lane subcases (f16 arithmetic, f16 packed, f32 conversions). The new regression does not skip. It lowers an actual synthetic compute program through lower_compute, follows emitted raw-buffer calls through annotateHandle / createHandleFromBinding to the root registers, then finishes and DXIL-validates that same IR. Both variants execute on the named RTX 3090 and produce all 64/64 expected non-contended outputs before the handle-policy assertion. The 18 existing controls remain unchanged.

This proves incorrect emitted handle routing and its repair; it does not reproduce a stale cross-thread read or a gameplay failure. Both 322-file source snapshots matched before/after on Windows and locally; XCL rebuilt for each. An earlier attempt failed to compile because my test read a private handle field; neither variant executed then. The final fixture uses existing module-inspection APIs and needs no visibility changes.

Not tested — full workspace suite, retail smoke, AMD/native-wave64 hardware, concurrency stress, imported-memory alias visibility, or performance of this candidate. Earlier timing results below remain for unchanged a03bc75 and the regular translator, not this per-lane fix. Required merge checks remain separate.

AI use — Codex (GPT-6) identified the missed path, wrote the candidate/regression, ran and verified the native comparison and prepared this update.

Candidate and regression against a03bc75
diff --git a/crates/xcl/src/gpu/recomp/lower.rs b/crates/xcl/src/gpu/recomp/lower.rs
index ca82cf4..7eae6d8 100644
--- a/crates/xcl/src/gpu/recomp/lower.rs
+++ b/crates/xcl/src/gpu/recomp/lower.rs
@@ -102,6 +102,8 @@ pub trait Ir: Sink {
     /// the dword of the flat memory (`mem`, u2) at a byte address (a multiple of 4); out of
     /// range reads 0 and writes nothing, as D3D12 raw buffers do
     fn mem_load(&mut self, addr: Self::V) -> Self::V;
+    /// Memory policy for the single-window shortcuts of the instruction about to be lowered.
+    fn mem_instruction(&mut self, _d: &Decoded) {}
     fn mem_store(&mut self, addr: Self::V, value: Self::V);
     /// the 4 GiB memory windows the program addresses: with more than one, `mem_load` /
     /// `mem_store` (window 0 only) are not used, and memory instructions go to `foreign`
@@ -1753,6 +1755,7 @@ impl<I: Ir> Lower<'_, I> {
 
     /// Lowers one non-terminator instruction in block `b`, falling back to `bridge`.
     fn lower_inst(&mut self, b: usize, d: &Decoded) -> R<()> {
+        self.ir.mem_instruction(d);
         let name = d.inst.name;
         let r = if name.starts_with("S_LOAD_") || name.starts_with("S_BUFFER_LOAD_") {
             self.smem(b, d)
diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs
index 978dd74..8482c2c 100644
--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -305,12 +305,16 @@ impl Ir for DxilIr {
         let res = self.res.expect("res is bound in kernel mode");
         self.lw.s.raw_store(res, a, &[value]);
     }
+    fn mem_instruction(&mut self, d: &Decoded) {
+        self.lw.inst_coherent_load = self.lw.coherence == super::CoherenceMode::AllCoherent
+            || super::inst_has_mem_coherence_bits(d) || super::inst_is_flat_atomic(d);
+    }
     fn mem_load(&mut self, addr: Value) -> Value {
-        let mem = self.mem;
+        let mem = if self.lw.inst_coherent_load { self.lw.mems_coh.first().copied().unwrap_or(self.mem) } else { self.mem };
         self.lw.s.raw_load(mem, addr, 1)[0]
     }
     fn mem_store(&mut self, addr: Value, value: Value) {
-        let mem = self.mem;
+        let mem = self.lw.mems_coh.first().copied().unwrap_or(self.mem);
         self.lw.s.raw_store(mem, addr, &[value]);
     }
     // through `Lw`, which records the edges for its own variables (the split form's exchange
@@ -428,6 +432,68 @@ mod tests {
     use super::super::lower::tests::*;
     use super::super::{dxc, runner, translate, Mode, Options};
 
+    /// The single-window shortcuts must preserve the same coherence policy as bridged ops.
+    #[test]
+    fn per_lane_memory_shortcuts_preserve_coherence() {
+        use crate::gpu::dxil::module::{Block, InstInfo};
+        let lines: &[I] = &[
+            ("S_LOAD_DWORD", "ENC_SMEM", &[("SDATA", 4), ("SBASE", 0), ("OFFSET", 0), ("SOFFSET", 125)]),
+            ("S_LOAD_DWORD", "ENC_SMEM", &[("SDATA", 5), ("SBASE", 0), ("OFFSET", 4), ("SOFFSET", 125), ("GLC", 1)]),
+            ("S_LOAD_DWORD", "ENC_SMEM", &[("SDATA", 6), ("SBASE", 0), ("OFFSET", 8), ("SOFFSET", 125), ("DLC", 1)]),
+            ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 0)]),
+            ("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 2), ("ADDR", 1), ("SADDR", 0)]),
+            ("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 3), ("ADDR", 1), ("SADDR", 0), ("GLC", 1)]),
+            ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 4), ("SRC0", 4), ("VSRC1", 2)]),
+            ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 4), ("SRC0", 5), ("VSRC1", 4)]),
+            ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 4), ("SRC0", 6), ("VSRC1", 4)]),
+            ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", 4), ("SADDR", 2)]),
+            ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", 3), ("SADDR", 2), ("OFFSET", 128)]),
+            ENDPGM,
+        ];
+        let insts = decode(lines);
+        let cs = crate::gpu::recomp::CsInterface { threads: [32, 1, 1], user_sgprs: 4, tgid: [false; 3], tg_size: false, tid_components: 1 };
+        let initial = super::DxilIr::new(&insts, false, &super::Entry::Compute(cs.clone()));
+        let ir = super::lower::lower_compute(&insts, &cs, false, initial).unwrap();
+        let m = &ir.lw.s.m;
+        // Follow each emitted memory call through annotateHandle to its root-UAV register.
+        let binding = |handle| {
+            let super::Value::Inst(i) = handle else { panic!("handle is not an instruction") };
+            let InstInfo::Call(name, args) = m.inst_info(i) else { panic!("handle is not annotated") };
+            assert_eq!(name, "dx.op.annotateHandle");
+            let super::Value::Inst(i) = args[1] else { panic!("binding is not an instruction") };
+            let InstInfo::Call(name, args) = m.inst_info(i) else { panic!("missing binding") };
+            assert_eq!(name, "dx.op.createHandleFromBinding");
+            m.const_u64(args[2]).unwrap()
+        };
+        let mut counts = [0usize; 4]; // plain/coherent loads, plain/coherent stores
+        for b in 0..m.block_count() {
+            for &i in m.block_insts(Block(b as u32)) {
+                if let InstInfo::Call(name, args) = m.inst_info(i) {
+                    let slot = if name.starts_with("dx.op.rawBufferLoad.") { 0 } else if name.starts_with("dx.op.rawBufferStore.") { 2 } else { continue };
+                    if binding(args[1]) == 2 { counts[slot] += 1; }
+                    if binding(args[1]) == 6 { counts[slot + 1] += 1; }
+                }
+            }
+        }
+        println!("PER_LANE_COHERENCE handles={counts:?}");
+        let dxil = ir.finish(cs.threads, 32).unwrap().dxil;
+        crate::gpu::dxil::validate::validate(&dxil).unwrap();
+        if gpu() {
+            println!("PER_LANE_COHERENCE_GPU={}", runner::adapter().unwrap());
+            let mut io = vec![0u32; super::super::KERNEL_SGPRS];
+            io[0] = 0x100; io[2] = 0x200;
+            let mut mem = vec![0u32; 0x400 / 4];
+            for lane in 0..32 { mem[0x100 / 4 + lane] = 100 + lane as u32; }
+            let out = runner::dispatch(&dxil, [1, 1, 1], &io, &mem).unwrap();
+            for lane in 0..32 {
+                assert_eq!(out[0x200 / 4 + lane], 403 + lane as u32);
+                assert_eq!(out[0x280 / 4 + lane], 100 + lane as u32);
+            }
+            println!("PER_LANE_COHERENCE_OUTPUT=64/64");
+        }
+        assert_eq!(counts, [2, 3, 0, 2], "GLC/DLC loads and all mixed-policy stores must use the coherent alias");
+    }
+
     fn gpu() -> bool {
         if !gpu_waves() {
             runner::skip_test("no GPU with 32-lane waves");

Independent RTX 3090 / Ampere results on exact a03bc75e8bebe1dc9864356fd875abb9c5b165fb: the translated same-lane alias probe passes, and per-instruction coherence substantially reduces GPU time for a translated dependent-load workload on imported host memory.

Tested — Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 (32.0.15.9174), Rust/Cargo 1.98.1 x64 MSVC, DXC/DXIL 1.8.2502.11, debug Rust, XCL_ADAPTER=3090. Runtime unchanged in positive snapshots; local synthetic fixtures only.

  1. cargo test --locked -p xcl --lib -- gpu_per_instruction_alias_reads_observe_own_writes --test-threads=1 --show-output: 1 passed / 0 failed / 0 ignored / 0 skipped. Four real dispatches: HLSL/direct × root/heap. Each of 128 lanes uses its own address and performs ordinary load → coherent store → ordinary load → coherent atomic → ordinary load. All 640 checked values per dispatch match, including final memory and atomic return. These dispatches use the runner's DEFAULT-heap memory. No cross-thread visibility claim.
  2. cargo test --locked -p xcl --lib -- gpu_per_instruction_host_memory_cost --test-threads=1 --show-output: 1 / 0 / 0 / 0 on each policy, XCL_DIRECT_COMPACT=0. The comparison control changes only coherence_mode's needs_per_inst result to AllCoherent on the same head, preserving its ABI; it is not a parent checkout. Both snapshots use identical test instrumentation.

The cost fixture uses actual console-ISA translation, a 1 MiB pointer chain in a 2 MiB OpenExistingHeapFromAddress allocation, 64 groups × 32 threads × 512 dependent ordinary GLOBAL loads, then one output store and one independent atomic increment per lane. No inter-lane atomic contention. Each path runs 11 timestamped dispatches with UAV barriers between them; discard the first timestamp and take the median of the remaining 10. At the end, all 2,048 outputs and 2,048 accumulated atomic counts match, and all 262,144 input-chain words remain unchanged. That is a final-state oracle, not intermediate readback after every dispatch.

Path All-coherent control, GPU ms Per-instruction, GPU ms Ratio
HLSL / root 0.472064 0.204288 2.31×
Direct DXIL / root 0.478720 0.229376 2.09×
HLSL / heap 2.750976 0.223232 12.32×
Direct DXIL / heap 2.585088 0.253440 10.20×

Timestamps exclude resource/PSO creation, uploads, readback, CPU waits and the barriers between dispatches. One process per policy, control then head, no clock control or randomized order. These are workload-specific measurements, not a predicted world-loading or frame-rate gain. Root and heap configurations select window 0; every window descriptor/alias points to the same imported allocation.

Warm translation API cost was also recorded: one warm translation then three timed translations per path, byte-identical within each path/policy; explicit final validation is outside these timings. These debug samples do not establish a compilation-speed improvement:

Path Median compile API ms, control → head DXIL bytes, control → head
HLSL / root 15.233 → 14.778 4492 → 4680
Direct DXIL / root 1.997 → 1.738 2744 → 2976
HLSL / heap 15.679 → 16.302 4416 → 4416
Direct DXIL / heap 1.425 → 1.592 2616 → 2616

All three source snapshots matched their 322-file SHA256 manifests before/after on Windows and locally; XCL recompiled for each. The host-memory runner override is cfg(test), thread-local and reset by RAII; it reuses the existing upload, barrier, timestamp and readback implementation. No production runner changes, commit/push or competing PR.

Not tested — full workspace suite, retail smoke/world loading, AMD/native wave64, same-lane alias visibility specifically on imported host memory, cross-workgroup communication, distinct-window addresses, invalidation opcodes, cold driver compilation, or peak process memory. No merge-readiness claim. The tests below are offered as complementary regression/benchmark coverage for this PR.

AI use — Codex (GPT-6) reviewed the code, wrote the synthetic fixtures/test seam, ran and verified the native comparisons and prepared this report. The coherence implementation is the PR author's.

Same-lane alias regression (test only)
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 5ab82cd..cc537df 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -9278,3 +9278,58 @@ fn gpu_compute_coherent_and_cached_loads() {
         }
     }
 }
+
+/// A lane must see its own stores and atomics through the ordinary-load alias.
+#[test]
+fn gpu_per_instruction_alias_reads_observe_own_writes() {
+    if !gpu_ready() { return; }
+    println!("ALIAS_GPU={}", runner::adapter().unwrap());
+    let cs = super::CsInterface { threads: [32, 1, 1], user_sgprs: 10, tgid: [true, false, false], tg_size: false, tid_components: 1 };
+    let mut p = Vec::new();
+    let mut add = |n: &str, e: &str, f: &[(&str, u64)]| p.extend(encode(n, e, f, None).unwrap());
+    add("S_LSHL_B32", "ENC_SOP2", &[("SDST", 11), ("SSRC0", 10), ("SSRC1", 133)]);
+    add("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 9), ("SRC0", 11), ("VSRC1", 0)]);
+    add("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 9)]);
+    add("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 3), ("ADDR", 1), ("SADDR", 0)]);
+    add("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 4), ("SRC0", 135), ("VSRC1", 3)]);
+    add("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", 4), ("SADDR", 0)]);
+    add("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 5), ("ADDR", 1), ("SADDR", 0)]);
+    add("V_MOV_B32", "ENC_VOP1", &[("VDST", 8), ("SRC0", 129)]);
+    add("GLOBAL_ATOMIC_ADD", "ENC_FLAT_GLBL", &[("VDST", 6), ("ADDR", 1), ("DATA", 8), ("SADDR", 0), ("GLC", 1)]);
+    add("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 7), ("ADDR", 1), ("SADDR", 0)]);
+    for (reg, base) in [(3, 2), (5, 4), (6, 6), (7, 8)] {
+        add("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", reg), ("SADDR", base)]);
+    }
+    add("S_ENDPGM", "ENC_SOPP", &[]);
+    let mut io = vec![0u32; super::KERNEL_SGPRS];
+    for (s, addr) in [(0, 0x400), (2, 0x1000), (4, 0x1400), (6, 0x1800), (8, 0x1c00)] { io[s] = addr; }
+    let mut input = vec![0xDEAD_BEEFu32; 0x2000 / 4];
+    for lane in 0..128 { input[0x400 / 4 + lane] = 1000 + lane as u32; }
+    let mut failures = Vec::new();
+    for heap in [false, true] {
+        for direct in [false, true] {
+            let start = std::time::Instant::now();
+            let dxil = if direct {
+                let o = crate::gpu::dxil::kernel::KernelOptions { wave64: false, split: false, mem_windows: 2 | if heap { super::HEAP_WINDOWS } else { 0 }, sampler_base: 0 };
+                crate::gpu::dxil::kernel::translate_compute(&p, o, &cs).unwrap().dxil
+            } else {
+                let t = translate(&p, &Options { mode: Mode::Compute(cs.clone()), wave64: false, mem_windows: 2, heap_windows: heap, ..Default::default() }).unwrap();
+                assert!(t.complete(), "{:?}", t.unsupported_why);
+                super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap()
+            };
+            let compile_ms = start.elapsed().as_secs_f64() * 1000.0;
+            crate::gpu::dxil::validate::validate(&dxil).unwrap();
+            let out = runner::dispatch(&dxil, [4, 1, 1], &io, &input).unwrap();
+            let mut wrong = [0usize; 5];
+            for (stage, (addr, delta)) in [(0x400 / 4, 8), (0x1000 / 4, 0), (0x1400 / 4, 7), (0x1800 / 4, 7), (0x1c00 / 4, 8)].into_iter().enumerate() {
+                for lane in 0..128 {
+                    let expected = 1000 + lane as u32 + delta;
+                    if out[addr + lane] != expected { wrong[stage] += 1; }
+                }
+            }
+            println!("ALIAS direct={direct} heap={heap} words=640 wrong={wrong:?} first={:?} dxil_bytes={} compile_ms={compile_ms:.3}", [out[0x400/4], out[0x1000/4], out[0x1400/4], out[0x1800/4], out[0x1c00/4]], dxil.len());
+            if wrong != [0; 5] { failures.push((direct, heap, wrong)); }
+        }
+    }
+    assert!(failures.is_empty(), "same-lane alias visibility: {failures:?}");
+}
Translated host-memory cost fixture and test-only runner seam
diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs
index da5e99b..6f99d47 100644
--- a/crates/xcl/src/gpu/recomp/runner.rs
+++ b/crates/xcl/src/gpu/recomp/runner.rs
@@ -1675,6 +1675,22 @@ fn dispatch_with(
         std::ptr::copy_nonoverlapping(m.as_ptr(), (p as *mut u32).add(io.len()), m.len());
         upload.Unmap(0, None);
         let io_buf = buffer(dev, io_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?;
+        #[cfg(test)]
+        let mem_buf = if let Some(base) = HOST_PROBE.with(|p| p.get()) {
+            let dev3: ID3D12Device3 = dev.cast().map_err(e)?;
+            let heap: ID3D12Heap = dev3.OpenExistingHeapFromAddress(base as *const std::ffi::c_void).map_err(e)?;
+            let desc = D3D12_RESOURCE_DESC {
+                Dimension: D3D12_RESOURCE_DIMENSION_BUFFER, Width: mem_bytes, Height: 1,
+                DepthOrArraySize: 1, MipLevels: 1, SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
+                Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
+                Flags: D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER,
+                ..Default::default()
+            };
+            let mut r: Option<ID3D12Resource> = None;
+            dev.CreatePlacedResource(&heap, 0, &desc, D3D12_RESOURCE_STATE_COMMON, None, &mut r).map_err(e)?;
+            r.ok_or("host probe resource")?
+        } else { buffer(dev, mem_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)? };
+        #[cfg(not(test))]
         let mem_buf = buffer(dev, mem_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?;
         let res_buf = buffer(dev, 256, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?;
         let readback = buffer(dev, mem_bytes, D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST, false)?;
@@ -1763,3 +1779,27 @@ fn dispatch_with(
         Ok((out, ms))
     }
 }
+
+#[cfg(test)]
+thread_local! { static HOST_PROBE: std::cell::Cell<Option<usize>> = const { std::cell::Cell::new(None) }; }
+
+#[cfg(test)]
+pub fn dispatch_host_probe(dxil: &[u8], groups: [u32; 3], sgprs: &[u32], mem: &[u32], reps: usize, arena: &crate::gpu::uma::Uma) -> Result<(Vec<u32>, Vec<f64>), String> {
+    assert!(mem.len() * 4 <= arena.window(0).1);
+    assert!(HOST_PROBE.with(|p| p.replace(Some(arena.window(0).0 as usize))).is_none());
+    struct Reset;
+    impl Drop for Reset { fn drop(&mut self) { HOST_PROBE.with(|p| p.set(None)); } }
+    let _reset = Reset;
+    let mut g = GPU.lock().unwrap();
+    let gpu = g.get_or_insert_with(init).as_mut().map_err(|x| x.clone())?;
+    let pso: ID3D12PipelineState = unsafe {
+        gpu.dev.CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC {
+            pRootSignature: transmute_copy(&gpu.rs),
+            CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr() as _, BytecodeLength: dxil.len() },
+            ..Default::default()
+        })
+    }
+    .map_err(|x| format!("CreateComputePipelineState: {x}"))?;
+    dispatch_with(&gpu.dev, &gpu.queue, &gpu.fence, &mut gpu.value, &pso, &gpu.rs, groups, sgprs, mem, reps.max(1), true)
+}
+
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 5ab82cd..caf0fcb 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -9278,3 +9278,67 @@ fn gpu_compute_coherent_and_cached_loads() {
         }
     }
 }
+
+/// Translated dependent loads plus an atomic on real imported host memory.
+#[test]
+fn gpu_per_instruction_host_memory_cost() {
+    if !gpu_ready() { return; }
+    println!("HOST_GPU={}", runner::adapter().unwrap());
+    let cs = super::CsInterface { threads: [32, 1, 1], user_sgprs: 8, tgid: [true, false, false], tg_size: false, tid_components: 1 };
+    let p = prog(&[
+        ("S_LSHL_B32", "ENC_SOP2", &[("SDST", 9), ("SSRC0", 8), ("SSRC1", 133)], None),
+        ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 9), ("VSRC1", 0)], None),
+        ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 3), ("SRC0", 130), ("VSRC1", 2)], None),
+        ("V_MOV_B32", "ENC_VOP1", &[("VDST", 1), ("SRC0", 259)], None),
+        ("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", 1), ("ADDR", 1), ("SADDR", 0)], None),
+        ("S_SUB_U32", "ENC_SOP2", &[("SDST", 6), ("SSRC0", 6), ("SSRC1", 129)], None),
+        ("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 6), ("SSRC1", 128)], None),
+        ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFB)], None),
+        ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 3), ("DATA", 1), ("SADDR", 2)], None),
+        ("V_MOV_B32", "ENC_VOP1", &[("VDST", 4), ("SRC0", 129)], None),
+        ("GLOBAL_ATOMIC_ADD", "ENC_FLAT_GLBL", &[("VDST", 5), ("ADDR", 3), ("DATA", 4), ("SADDR", 4), ("GLC", 1)], None),
+    ]);
+    let arena = crate::gpu::uma::Uma::with_windows(1, 2 << 20).unwrap();
+    let base = arena.window(0).0 as u64;
+    let mut io = vec![0u32; super::KERNEL_SGPRS];
+    for (s, offset) in [(0, 0u64), (2, 0x10_0000), (4, 0x11_0000)] {
+        let addr = base + offset;
+        io[s] = addr as u32;
+        io[s + 1] = (addr >> 32) as u32;
+    }
+    io[super::IO_UMA_BASE_HI] = (base >> 32) as u32;
+    io[6] = 512;
+    let mut mem = vec![0u32; (2 << 20) / 4];
+    for idx in 0..262144 { mem[idx] = (((idx + 65537) & 262143) * 4) as u32; }
+    for heap in [false, true] {
+        for direct in [false, true] {
+            let compile = || {
+                if direct {
+                    let o = crate::gpu::dxil::kernel::KernelOptions { wave64: false, split: false, mem_windows: 2 | if heap { super::HEAP_WINDOWS } else { 0 }, sampler_base: 0 };
+                    crate::gpu::dxil::kernel::translate_compute(&p, o, &cs).unwrap().dxil
+                } else {
+                    let t = translate(&p, &Options { mode: Mode::Compute(cs.clone()), wave64: false, mem_windows: 2, heap_windows: heap, ..Default::default() }).unwrap();
+                    assert!(t.complete(), "{:?}", t.unsupported_why);
+                    super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap()
+                }
+            };
+            let dxil = compile();
+            crate::gpu::dxil::validate::validate(&dxil).unwrap();
+            let mut compile_ms = Vec::new();
+            for _ in 0..3 {
+                let t = std::time::Instant::now();
+                let again = compile();
+                compile_ms.push(t.elapsed().as_secs_f64() * 1000.0);
+                assert_eq!(again, dxil);
+            }
+            let (out, times) = runner::dispatch_host_probe(&dxil, [64, 1, 1], &io, &mem, 11, &arena).unwrap();
+            assert_eq!(&out[..262144], &mem[..262144], "input chain changed");
+            for lane in 0..2048 {
+                let want = (((lane + 512 * 65537) & 262143) * 4) as u32;
+                assert_eq!(out[0x10_0000 / 4 + lane], want, "heap={heap} direct={direct} lane={lane}");
+                assert_eq!(out[0x11_0000 / 4 + lane], 11, "atomic count lane={lane}");
+            }
+            println!("HOST direct={direct} heap={heap} output_words=4096 chain_words=262144 dxil_bytes={} compile_ms={compile_ms:?} gpu_ms={times:?}", dxil.len());
+        }
+    }
+}

For the control only, replace CoherenceMode::PerInstruction with CoherenceMode::AllCoherent in the if needs_per_inst result of coherence_mode; leave the ABI and fixture unchanged.

@JJAutoCompare

Copy link
Copy Markdown

Tested

  • PR Recompiler: emit per-instruction globallycoherent on compute flat memory (stacked on #1850) #2067, exact head a03bc75e8bebe1dc9864356fd875abb9c5b165fb. The PR was open at that SHA before and after the run. The assigned checkout was clean before and after execution.
  • Windows 11 Enterprise Evaluation 26200.9974 x64, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), unoptimized test profile with debug info disabled. The run logged DXC/DXIL 1.9.2609.5 (dxcompiler build 01b62ad4).
  • Process environment used XCL_ADAPTER=A770, XCL_DXC_DIR=$env:LOCALAPPDATA/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 TEMP=TMP=L:/XclTooling/pr2067/temp.
  • Outside the shared Arc lock, prebuilt with & (Join-Path $env:USERPROFILE '.cargo/bin/cargo.exe') test -p xcl --lib --no-run --message-format=json-render-diagnostics. Cargo recorded a successful build. Ran only the following exact libtest binary under the shared lock, with RemoteSigned scoped to the child PowerShell process.
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -Command "& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { & 'L:\XclTooling\pr1778-2e2ee55-20261125-020159\target\debug\build\xcl\97fdf2b9ff8e1482\out\xcl-97fdf2b9ff8e1482.exe' --exact gpu::recomp::tests::gpu_compute_coherent_and_cached_loads --nocapture --test-threads=1 }"
  • 1 passed, 0 failed, 0 ignored, 0 GPU skips, with 1,126 filtered out. The child exited 0. The fixture made four GPU dispatches across HLSL compiled by DXC as cs_6_6 and direct DXIL. Each backend executed the plain cached case and the mixed coherent case as wave32 with a single root-UAV window (u2, with its coherent alias at u6 for the mixed shader). Each backend matched all 128 plain outputs, the mixed final counter of 512 and all 512 ticket-indexed outputs. All 512 mixed GLC counter reads per backend were in the expected range 1–512.

Not tested

  • Descriptor-heap and multi-window root-UAV dispatch, wave64, the separate same-address alias-visibility workload, performance, NVIDIA or AMD GPUs, release, baseline comparisons, the full workspace suite, and title smoke.

AI use

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

@JoaoPauluu

JoaoPauluu commented Nov 25, 2026 •

Copy link
Copy Markdown

Update, 9b35718: all 4 new tests pass under Wine with the same setup as below, none skipped. That includes the new per_lane_memory_shortcuts_preserve_coherence, plus compute_globallycoherent_only_when_needed, compute_per_instruction_globallycoherent and gpu_compute_coherent_and_cached_loads (merge base with main cbc296a, no uncommitted changes). Claude Code (Claude Opus 5.5) ran this rerun.


A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's 3 new tests pass.

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. a03bc75 as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • compute_globallycoherent_only_when_needed: ok, not skipped
    • compute_per_instruction_globallycoherent: ok, not skipped
    • gpu_compute_coherent_and_cached_loads: ok, not skipped

Not tested

  • the whole suite on this head, a retail title, 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.

@DarkPanda69

DarkPanda69 commented Nov 25, 2026 •

Copy link
Copy Markdown

Update for head 9b35718: same result. Applied on main cbc296a, cargo test -p xcl --lib -- gpu:: --test-threads=4: RX 9070 XT 588 passed, 2 failed (the two fuzz_validate_and_gpu seeds, which fail the same way on main on this card); RTX 3060 590 passed, 0 failed. gpu_compute_coherent_and_cached_loads ok on both.


AMD RDNA4 run, which this PR lists as not tested (only an RTX 5070 so far; the other reports here are Intel / NVIDIA).

Tested: pass, head a03bc75 applied on its base main cbc296a, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17. cargo test -p xcl --lib -- gpu:: --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 587 passed, 2 failed, 22 ignored. gpu_compute_coherent_and_cached_loads ok. The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3, the same as on main cbc296a without this PR on this card.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 589 passed, 0 failed, 22 ignored. Same test ok.

Not tested: RDNA2/3; dispatch timing.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

…ndow shortcuts

In single-window per-lane mode, lower::smem and lower::vmem call Ir::mem_load and Ir::mem_store directly instead of going through Lw's foreign bridge. Add an Ir::mem_instruction hook so DxilIr updates Lw::inst_coherent_load and routes GLC/DLC loads and all mixed-policy stores to the coherent alias (mems_coh[0], u6) rather than plain mem (u2). Reported and verified by @WebIdentity1 on xcl-dev#2067.
@certified-retart

Copy link
Copy Markdown
Contributor Author

Thanks @WebIdentity1 for catching the single-window per-lane shortcut bypass (and for the RTX 3090 benchmarks), and thanks @JJAutoCompare and @JoaoPauluu for the Arc A770 and vkd3d-proton runs. Incorporated the Ir::mem_instruction / DxilIr coherent-alias routing fix and per_lane_memory_shortcuts_preserve_coherence regression in 9b35718, re-ran the full workspace suite (1,158 passed, 0 failed, 46 ignored) and a clean 60 s smoke run on the RTX 5070.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@imnicho

imnicho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

RTX 5080: what the rule buys in a world frame of a retail title on the direct DXIL path, measured with a local version of that part (not this head)

For "Not tested: extended world-load dispatch timing". Before I saw this PR I had written the direct-path part of the same rule on top of ecc9723 and run it in the title. I am not opening it, this PR covers it and more. What mine did: with heap windows, an access takes the globallycoherent view only if its instruction is a memory atomic or has GLC / DLC / SLC; a program with a cache invalidation stays coherent as a whole. One difference from this PR: a store without those bits took the plain view in mine. So read the numbers as what the load side of the rule does, not as a test of this head.

Setup. RTX 5080 16 GB (driver 610.47, 32-lane waves, so the split wave64 form), i7-7700K, 16 GB RAM, Windows 10 22H2, release. The retail title of #675 (my own copy), XCL_NETWORK=0, scripted pad, binds waiting, nothing skipped. XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HUGE_PSO_CONCURRENCY=2 XCL_GPU_PROFILE=1, caches filled by earlier runs. "#1850's rule" is #2057 at f862f5f + #684 + #266; "by instruction" is the same + #1515 + #495 + my commit. The committed window is on imported host memory (no XCL_UMA_SHADOW), the default on this card. TdrDelay is 8 s on this PC.

GPU time of the console programs in the world (#1766's last report of each run; one run each):

program (threads, code, groups) #1850's rule: calls, ms a call, longest by instruction: calls, ms a call, longest
1b5466f261a70cde (8x8x1, 9,060 B, 160x90x1) 35, 359.7, 1,874.8 24, 120.1, 851.4
19a1c1ba0b567618 (8x8x1, 1,148 B, 160x90x1) 35, 204.1, 2,771.5 under 19.7 ms a call (not among the 15 heaviest)
9dc85ad397cbaffe (8x8x1, 2,404 B, 160x90x1) 35, 199.7, 2,655.9 under 19.7 ms a call (not among the 15 heaviest)
3429c04607b00016 (32x1x1, 684 B, 57600x1x1) 35, 187.6, 1,385.3 24, 77.6, 490.1
67657769b50d2f8b (32x1x1, 4,196 B, 57600x1x1) 35, 140.3, 1,072.9 24, 50.5, 254.2
56446569eccb04f0 (32x1x1, 2,052 B, 57600x1x1) 35, 154.7, 2,154.0 24, 226.0, 2,275.1
all console code of the run, per world frame 2,566 ms (89,822 ms, 35 frames) 1,692 ms (40,615 ms, 24 frames)

These six are the programs among the heaviest that #1850's rule keeps coherent (checked in each one's translated source). The frame's console GPU time falls by about a third.

What it does not change here

This head on this card. 9b35718 merged into #2057 at 41303e4 (eight conflict blocks in kernel.rs, emit.rs, lower_dxil.rs and recomp/mod.rs, each of them #1850's line against this PR's replacement of it; with this PR's side taken it builds), plus #684, #266, #1515, #495 and #1405. compute_per_instruction_globallycoherent, compute_globallycoherent_only_when_needed, gpu_compute_coherent_and_cached_loads and per_lane_memory_shortcuts_preserve_coherence pass there on the RTX 5080, none skipped.

Not tested

  • This head in the title. That tree's pipelines are not built here yet, which takes hours on this CPU.
  • AMD, Intel, native 64-lane waves. Root UAV windows in the title (every run above has heap windows).

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

@certified-retart

Copy link
Copy Markdown
Contributor Author

Huge thanks for the real world-frame RTX 5080 measurements and for verifying 9b35718 on your setup, @imnicho! Cutting console GPU frame time from 2,566 ms to 1,692 ms (~34% drop, with individual heavy compute dispatches dropping 2.4x-10x) on imported host memory is awesome confirmation of the rule's real-world impact. And thank you @DavidM1911 for the RTX 3060 Ti verification as well!

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.

7 participants