Recompiler: batch consecutive v_readfirstlane/v_readlane exchanges in direct DXIL split-wave64 #2071

Closed
github-bot wants to merge 1 commit from gh-pr/2071/head into gh-pr/2071/base
Owner

@⁠zondy1i on GitHub · 2026-11-25 02:52 UTC · original
zondy1i:dxil/split-readlane-batch → main · +358 −8 · 5 files · 1 commits · closed without merging

Part of #1269.

Brings the split-wave64 v_readfirstlane_b32 / v_readlane_b32 exchange batching idea (similar to #944 for HLSL) to the direct DXIL backend (crates/xcl/src/gpu/dxil/).

In split-wave64 mode (wave64 console shaders running on 32-lane hardware such as NVIDIA/Intel GPUs), every v_readfirstlane_b32 / v_readlane_b32 previously emitted its own single-word exchange_n(&[m]) — 2 group barriers per instruction in Partner::Present (64-thread groups) and a full 4-block spin-wait loop with 2 TGSM_FENCE barriers and 2 groupshared atomicrmw ops per instruction in Partner::Spin (>64-thread groups). Consecutive independent runs now share a single exchange_n call. Native wave64 and wave32 lowering is untouched.

What changed

  • crates/xcl/src/gpu/dxil/lanes.rs:
    • Add Lw::read_lane_uniform_batch(&[(Value, Value)]) to perform one cross-half exchange_n across a run of independent lane reads (reusing l & 31 and lh == self.half when consecutive items share the same lane index).
  • crates/xcl/src/gpu/dxil/lower_valu.rs:
    • Add Lw::lower_block_insts to greedily batch consecutive Variant::Plain v_readfirstlane_b32 / v_readlane_b32 instructions within a basic block up to self.xslot, stopping at any SGPR read-after-write hazard (including EXEC, VCCZ, EXECZ, M0, or EXEC writes).
    • Add max_readlane_batch (stopping at CFG block leaders) to size split-wave64 exchange slots in Lw::new.
  • crates/xcl/src/gpu/dxil/kernel.rs & crates/xcl/src/gpu/dxil/compact.rs:
    • Lower block instructions through Lw::lower_block_insts in both the standard and compact forms.
    • Size slot in Lw::new when split and max_readlane_batch >= 2 (up to 16 words without LDS; bounded to at most 256 total dwords = 1 KiB when sharing LDS).
  • crates/xcl/src/gpu/dxil/core_tests.rs:
    • split_readlane_batch_merges_present_and_spin_exchanges: verifies 6 consecutive v_readfirstlane_b32 / v_readlane_b32 collapse from 13 to 3 barriers (Partner::Present) and from 13 to 3 atomicrmw add spin ops (Partner::Spin).
    • split_readlane_batch_respects_sgpr_hazards: verifies lane-selector RAW dependencies and EXEC writes break the batch.
    • gpu_split_readlane_batch_executes_correctly: GPU execution check on lower-half, upper-half, masked-lower-half, and dependent-chain cases.

Tested

  • Toolchain: Windows 11 x64, rustc 1.100.0, DXC / dxil.dll 1.9.2602.17, NVIDIA GeForce RTX 3060 Ti 8 GB (driver 621.01).
  • cargo test -p xcl --lib -- gpu::dxil --skip fuzz_tests: 155 passed, 0 failed, 1 ignored (includes split_readlane_batch_merges_present_and_spin_exchanges, split_readlane_batch_respects_sgpr_hazards, gpu_split_readlane_batch_executes_correctly, and compact_tests).
  • xcl shaders <corpus> --direct --sample 500 --seed 1 --max-bytes 262144 --split 1 --validate --threads 8: 500/500 translated and validated (0 unsupported, 0 validator failures, 0 panics).

Not tested

  • gpu::dxil::fuzz_tests, AMD / Intel GPUs, Linux / Wine / vkd3d-proton.

Regression run
main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR:

xcl-smoke v1
commit: 77a9a6e1c28296e918245696f40f7586584bc7fc
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1621 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14615 MB

AI use
Antigravity (Gemini 4 Neon) assisted with implementation, IR/hazard/GPU tests, and validation; all changes were reviewed and verified locally.

**@⁠zondy1i** on GitHub · 2026-11-25 02:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071) `zondy1i:dxil/split-readlane-batch` → `main` · +358 −8 · 5 files · 1 commits · closed without merging Part of #1269. Brings the split-wave64 `v_readfirstlane_b32` / `v_readlane_b32` exchange batching idea (similar to #944 for HLSL) to the direct DXIL backend (`crates/xcl/src/gpu/dxil/`). In split-wave64 mode (wave64 console shaders running on 32-lane hardware such as NVIDIA/Intel GPUs), every `v_readfirstlane_b32` / `v_readlane_b32` previously emitted its own single-word `exchange_n(&[m])` — 2 group barriers per instruction in `Partner::Present` (64-thread groups) and a full 4-block spin-wait loop with 2 `TGSM_FENCE` barriers and 2 groupshared `atomicrmw` ops per instruction in `Partner::Spin` (>64-thread groups). Consecutive independent runs now share a single `exchange_n` call. Native wave64 and wave32 lowering is untouched. **What changed** - `crates/xcl/src/gpu/dxil/lanes.rs`: - Add `Lw::read_lane_uniform_batch(&[(Value, Value)])` to perform one cross-half `exchange_n` across a run of independent lane reads (reusing `l & 31` and `lh == self.half` when consecutive items share the same lane index). - `crates/xcl/src/gpu/dxil/lower_valu.rs`: - Add `Lw::lower_block_insts` to greedily batch consecutive `Variant::Plain` `v_readfirstlane_b32` / `v_readlane_b32` instructions within a basic block up to `self.xslot`, stopping at any SGPR read-after-write hazard (including `EXEC`, `VCCZ`, `EXECZ`, `M0`, or `EXEC` writes). - Add `max_readlane_batch` (stopping at CFG block `leaders`) to size split-wave64 exchange slots in `Lw::new`. - `crates/xcl/src/gpu/dxil/kernel.rs` & `crates/xcl/src/gpu/dxil/compact.rs`: - Lower block instructions through `Lw::lower_block_insts` in both the standard and compact forms. - Size `slot` in `Lw::new` when `split` and `max_readlane_batch >= 2` (up to 16 words without LDS; bounded to at most 256 total dwords = 1 KiB when sharing LDS). - `crates/xcl/src/gpu/dxil/core_tests.rs`: - `split_readlane_batch_merges_present_and_spin_exchanges`: verifies 6 consecutive `v_readfirstlane_b32` / `v_readlane_b32` collapse from 13 to 3 barriers (`Partner::Present`) and from 13 to 3 `atomicrmw add` spin ops (`Partner::Spin`). - `split_readlane_batch_respects_sgpr_hazards`: verifies lane-selector RAW dependencies and `EXEC` writes break the batch. - `gpu_split_readlane_batch_executes_correctly`: GPU execution check on lower-half, upper-half, masked-lower-half, and dependent-chain cases. **Tested** - Toolchain: Windows 11 x64, `rustc 1.100.0`, DXC / `dxil.dll` `1.9.2602.17`, NVIDIA GeForce RTX 3060 Ti 8 GB (driver `621.01`). - `cargo test -p xcl --lib -- gpu::dxil --skip fuzz_tests`: **155 passed, 0 failed, 1 ignored** (includes `split_readlane_batch_merges_present_and_spin_exchanges`, `split_readlane_batch_respects_sgpr_hazards`, `gpu_split_readlane_batch_executes_correctly`, and `compact_tests`). - `xcl shaders <corpus> --direct --sample 500 --seed 1 --max-bytes 262144 --split 1 --validate --threads 8`: **500/500 translated and validated** (0 unsupported, 0 validator failures, 0 panics). **Not tested** - `gpu::dxil::fuzz_tests`, AMD / Intel GPUs, Linux / Wine / vkd3d-proton. **Regression run** `main`: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1580 (PresentX 1580) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15495 MB ``` PR: ``` xcl-smoke v1 commit: 77a9a6e1c28296e918245696f40f7586584bc7fc gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1621 (PresentX 1622) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14615 MB ``` **AI use** Antigravity (Gemini 4 Neon) assisted with implementation, IR/hazard/GPU tests, and validation; all changes were reviewed and verified locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:29 +00:00
github-bot closed this pull request 2026-11-26 05:17:29 +00:00
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 03:05 UTC · original

XCL #2071 — Intel Arc A770 split-wave64 compatibility

Tested

Clean PR head c270670b7b82aab8b3f805a3cd438d46642fbeea on 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) and the unoptimized test profile. Each process logged dxcompiler and dxil 1.9.2609.5 (DXC build 01b62ad4). The local checkout was clean before and after execution. GitHub showed the PR open at the tested SHA before and after the run. The final public conversation check at 2026-11-25 03:03:23 UTC showed no matching report or review.

The process environment used CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0, CARGO_TARGET_DIR=L:/XclTooling/pr1947-1831ec4-t3-97236edf/target, TEMP=TMP=L:/XclTooling/pr2071/run-20261125T030121836Z/temp, XCL_ADAPTER=A770 and XCL_DXC_DIR=$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64.

& "$env:USERPROFILE/.cargo/bin/cargo.exe" test --locked -p xcl --lib -j 2 --no-run --message-format=json
$binary = 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
& $binary --exact gpu::dxil::core_tests::split_readlane_batch_merges_present_and_spin_exchanges --nocapture --test-threads=1
& $binary --exact gpu::dxil::core_tests::split_readlane_batch_respects_sgpr_hazards --nocapture --test-threads=1
# This invocation ran in a child PowerShell with process-scoped RemoteSigned.
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $binary --exact gpu::dxil::core_tests::gpu_split_readlane_batch_executes_correctly --nocapture --test-threads=1
}

The prebuild exited 0 outside the Arc mutex and Cargo reported a newly built test executable (fresh: false). The GPU test acquired and released the Arc mutex.

Checked-in fixture Passed Failed Ignored Skipped Filtered out
split_readlane_batch_merges_present_and_spin_exchanges 1 0 0 0 1126
split_readlane_batch_respects_sgpr_hazards 1 0 0 0 1126
gpu_split_readlane_batch_executes_correctly 1 0 0 0 1126

3 passed, 0 failed, 0 ignored, 0 skipped. All three exited 0. Disassembly matched three barriers for the 64-thread group and three atomicrmw add operations for the 128-thread group. The lane-selector dependency and EXEC write cases each retained five barriers. The GPU fixture validated the signed direct DXIL container and dispatched it on the A770. All eight expected SGPR values matched, covering reads from both halves, first-active-lane selection with the lower half masked, and a dependent lane-selector chain.

Not tested

GPU execution of the 128-thread spin path, native wave64, standalone wave32 lowering, HLSL execution, other adapters, the full workspace suite, stress, throughput, retail titles and smoke runs.

The Cargo JSON and stderr, each fixture's stdout and stderr, and all exit codes are preserved in L:/XclTooling/pr2071/run-20261125T030121836Z.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the three checked-in fixtures and prepared this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7151580076) # XCL #2071 — Intel Arc A770 split-wave64 compatibility <!-- xcl-independent-test: pr=2071 head=c270670b7b82aab8b3f805a3cd438d46642fbeea adapter=arc-a770 scope=split-readlane-batch --> **Tested** Clean PR head `c270670b7b82aab8b3f805a3cd438d46642fbeea` on 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`) and the unoptimized test profile. Each process logged dxcompiler and dxil 1.9.2609.5 (DXC build `01b62ad4`). The local checkout was clean before and after execution. GitHub showed the PR open at the tested SHA before and after the run. The final public conversation check at 2026-11-25 03:03:23 UTC showed no matching report or review. The process environment used `CARGO_BUILD_JOBS=2`, `CARGO_INCREMENTAL=0`, `CARGO_PROFILE_DEV_DEBUG=0`, `CARGO_PROFILE_TEST_DEBUG=0`, `CARGO_TARGET_DIR=L:/XclTooling/pr1947-1831ec4-t3-97236edf/target`, `TEMP=TMP=L:/XclTooling/pr2071/run-20261125T030121836Z/temp`, `XCL_ADAPTER=A770` and `XCL_DXC_DIR=$env:LOCALAPPDATA/XclTooling/dxc-1.9.2609/bin/x64`. ```powershell & "$env:USERPROFILE/.cargo/bin/cargo.exe" test --locked -p xcl --lib -j 2 --no-run --message-format=json $binary = 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' & $binary --exact gpu::dxil::core_tests::split_readlane_batch_merges_present_and_spin_exchanges --nocapture --test-threads=1 & $binary --exact gpu::dxil::core_tests::split_readlane_batch_respects_sgpr_hazards --nocapture --test-threads=1 # This invocation ran in a child PowerShell with process-scoped RemoteSigned. & 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { & $binary --exact gpu::dxil::core_tests::gpu_split_readlane_batch_executes_correctly --nocapture --test-threads=1 } ``` The prebuild exited 0 outside the Arc mutex and Cargo reported a newly built test executable (`fresh: false`). The GPU test acquired and released the Arc mutex. | Checked-in fixture | Passed | Failed | Ignored | Skipped | Filtered out | | --- | ---: | ---: | ---: | ---: | ---: | | `split_readlane_batch_merges_present_and_spin_exchanges` | 1 | 0 | 0 | 0 | 1126 | | `split_readlane_batch_respects_sgpr_hazards` | 1 | 0 | 0 | 0 | 1126 | | `gpu_split_readlane_batch_executes_correctly` | 1 | 0 | 0 | 0 | 1126 | **3 passed, 0 failed, 0 ignored, 0 skipped.** All three exited 0. Disassembly matched three barriers for the 64-thread group and three `atomicrmw add` operations for the 128-thread group. The lane-selector dependency and EXEC write cases each retained five barriers. The GPU fixture validated the signed direct DXIL container and dispatched it on the A770. All eight expected SGPR values matched, covering reads from both halves, first-active-lane selection with the lower half masked, and a dependent lane-selector chain. **Not tested** GPU execution of the 128-thread spin path, native wave64, standalone wave32 lowering, HLSL execution, other adapters, the full workspace suite, stress, throughput, retail titles and smoke runs. The Cargo JSON and stderr, each fixture's stdout and stderr, and all exit codes are preserved in `L:/XclTooling/pr2071/run-20261125T030121836Z`. **AI use** T3 Code / Codex (`gpt-6.2-sol`) ran the three checked-in fixtures and prepared this report.
Author
Owner

@⁠WebIdentity1 on GitHub · 2026-11-25 03:05 UTC · original · edited 2026-11-25 03:08 UTC

RTX 3090: actual multi-wave compute execution and cost

The new fixture below closes the GPU-execution gap for Partner::Spin (also explicitly untested in the new Arc report). No runtime changes: parent cbc296ab65a2661a61e3e2da109134bcd5319f60 versus head c270670b7b82aab8b3f805a3cd438d46642fbeea, each with the identical test-only addition to core_tests.rs.

Tested: 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. Each process printed the actual NVIDIA adapter.

$env:XCL_ADAPTER='3090'
# Separate process for each value, on each snapshot:
$env:XCL_DIRECT_COMPACT='0' # then '1'
cargo test --locked -p xcl --lib -- gpu_readlane_batch_multiwave_loop_probe --test-threads=1 --show-output

All four invocations: 1 passed / 0 failed / 0 ignored, zero SKIPPED notices. Each executes both 64-thread Present and 128-thread Spin compute shaders, 16 groups, 64 loop iterations, six independent reads per iteration (lanes 0/7/31/32/41/63). Values evolve each iteration and differ by console wave. Every 1,024/2,048 output word agrees with the independent CPU sum and all 16 tail guards remain unchanged. This checks normal and forced-compact translation, repeated exchanges and cross-wave isolation. Both parent and head are correct; this is optimization coverage, not a newly fixed semantic failure.

Form / threads DXIL bytes parent → head Translation median ms parent → head GPU dispatch median µs parent → head
Normal / 64 2788 → 2824 1.7185 → 1.9372 17.408 → 8.192
Normal / 128 4400 → 3336 2.7085 → 1.9236 67.072 → 17.408
Compact / 64 3864 → 3892 2.2746 → 2.0802 22.528 → 14.336
Compact / 128 5516 → 4444 3.1909 → 2.3891 73.728 → 21.504

Emitted barrier calls fall 13 → 3 in all four forms; atomicrmw add falls 13 → 3 for the 128-thread spin case (64-thread remains one setup atomic). The spin form gets smaller and translates faster in this fixture. The 64-thread normal form instead grows by 36 bytes and has a slightly higher measured translation cost; there is no universal compile-time improvement claim.

Method: one untimed warm translation then five timed translate_compute calls, each byte-identical to that reference; explicit final DXIL validation outside the timer. GPU timings are ten samples after discarding the first of eleven timestamped dispatches; they exclude PSO creation, resources, upload/readback, submission, CPU wait and the barriers between dispatches. Correctness was checked on a separate untimed dispatch: the timed API discards its readback. One process per form/revision, parent before head, no randomized order/clock control; these short synthetic timings are descriptive, not retail speedup or cold-PSO evidence. Both 322-file source snapshots match before/after Windows execution and locally; Cargo rebuilt XCL for each revision.

Not tested: full workspace, retail smoke, native wave64, AMD, LDS-carved exchange storage, divergent/partial EXEC in this new fixture, or memory consumption. The existing author hazard tests cover different cases and were not rerun here. The fixture is offered for adoption alongside those tests; no competing PR.

AI use: Codex (GPT-6) wrote the synthetic test, performed the native Windows comparison and prepared this report.

Portable test-only patch (same addition on parent and head)
diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs
index 5e52646..e5a5cd1 100644
--- a/crates/xcl/src/gpu/dxil/core_tests.rs
+++ b/crates/xcl/src/gpu/dxil/core_tests.rs
@@ -711,3 +711,69 @@ fn gpu_split_readlane_batch_executes_correctly() {
     assert_eq!(r.sgpr[16], 0x1000 + 37, "s16 = v0[37]");
     assert_eq!(r.sgpr[17], 0x2000 + 37 * 3, "s17 = v1[37]");
 }
+
+/// Exercise batched reads through real multi-wave compute loops, not only the kernel ABI.
+#[test]
+fn gpu_readlane_batch_multiwave_loop_probe() {
+    use crate::gpu::recomp::{self, runner, CsInterface};
+    if runner::wave32_supported() != Ok(true) || recomp::dxc::location().is_err() {
+        runner::skip_test("no wave32 / DXC");
+        return;
+    }
+    println!("READLANE_GPU={}", runner::adapter().unwrap());
+    let compact = super::kernel::compact_mode().expect("set XCL_DIRECT_COMPACT=0 or 1");
+    for threads in [64u32, 128] {
+        let cs = CsInterface { threads: [threads, 1, 1], user_sgprs: 8, tgid: [true, false, false], tg_size: false, tid_components: 1 };
+        let mut code = prog(&[
+            ("S_LSHL_B32", "ENC_SOP2", &[("SDST", 9), ("SSRC0", 8), ("SSRC1", 128 + threads.trailing_zeros() as u64)], None),
+            ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 9), ("VSRC1", 0)], None),
+            ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 130), ("VSRC1", 1)], None),
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 20), ("SSRC0", 192)], None),
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 30), ("SSRC0", 128)], None),
+        ]);
+        code.truncate(code.len() - 4);
+        let loop_at = code.len();
+        code.extend(encode("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 10), ("SRC0", 257)], None).unwrap());
+        for (dst, lane) in [(11, 7), (12, 31), (13, 32), (14, 41), (15, 63)] {
+            code.extend(encode("V_READLANE_B32", "ENC_VOP3", &[("VDST", dst), ("SRC0", 257), ("SRC1", 128 + lane)], None).unwrap());
+        }
+        for src in 10..16 {
+            code.extend(encode("S_ADD_U32", "ENC_SOP2", &[("SDST", 30), ("SSRC0", 30), ("SSRC1", src)], None).unwrap());
+        }
+        code.extend(encode("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 129), ("VSRC1", 1)], None).unwrap());
+        code.extend(encode("S_SUB_U32", "ENC_SOP2", &[("SDST", 20), ("SSRC0", 20), ("SSRC1", 129)], None).unwrap());
+        code.extend(encode("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 20), ("SSRC1", 128)], None).unwrap());
+        let back = (loop_at as i64 - code.len() as i64 - 4) / 4;
+        code.extend(encode("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", back as i16 as u16 as u64)], None).unwrap());
+        code.extend(prog(&[
+            ("V_MOV_B32", "ENC_VOP1", &[("VDST", 3), ("SRC0", 30)], None),
+            ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 2), ("DATA", 3), ("SADDR", 0)], None),
+        ]));
+        let o = KernelOptions { wave64: true, split: true, mem_windows: 1, sampler_base: 0 };
+        let compile = || super::kernel::translate_compute(&code, o, &cs).unwrap().dxil;
+        let dxil = compile();
+        super::validate::validate(&dxil).unwrap();
+        let dis = super::validate::disassemble(&dxil).unwrap();
+        let mut compile_ms = Vec::new();
+        for _ in 0..5 {
+            let start = std::time::Instant::now();
+            let again = compile();
+            compile_ms.push(start.elapsed().as_secs_f64() * 1000.0);
+            assert_eq!(again, dxil, "translation changed bytes");
+        }
+        let mut io = vec![0u32; recomp::KERNEL_SGPRS];
+        io[1] = 1;
+        io[recomp::IO_UMA_BASE_HI] = 1;
+        let n = threads as usize * 16;
+        let mem = vec![0xdeadbeef; n + 16];
+        let out = runner::dispatch(&dxil, [16, 1, 1], &io, &mem).unwrap();
+        for (i, &got) in out[..n].iter().enumerate() {
+            let wave_base = (i / 64 * 64) as u32;
+            let want: u32 = (0..64).map(|iteration| [0, 7, 31, 32, 41, 63].into_iter().map(|l| wave_base + l + iteration).sum::<u32>()).sum();
+            assert_eq!(got, want, "compact={compact} threads={threads} output[{i}]");
+        }
+        assert_eq!(&out[n..], &mem[n..], "tail overwritten");
+        let gpu_ms = runner::dispatch_timed(&dxil, [16, 1, 1], &io, &mem, 11).unwrap();
+        println!("READLANE compact={compact} threads={threads} output_words={n} guard_words=16 dxil_bytes={} barriers={} atomic_add={} compile_ms={compile_ms:?} gpu_ms={gpu_ms:?}", dxil.len(), dis.matches("call void @dx.op.barrier(").count(), dis.matches("atomicrmw add").count());
+    }
+}
**@⁠WebIdentity1** on GitHub · 2026-11-25 03:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7151576806) · edited 2026-11-25 03:08 UTC ### RTX 3090: actual multi-wave compute execution and cost The new fixture below closes the GPU-execution gap for `Partner::Spin` (also explicitly untested in the new Arc report). No runtime changes: parent `cbc296ab65a2661a61e3e2da109134bcd5319f60` versus head `c270670b7b82aab8b3f805a3cd438d46642fbeea`, each with the identical test-only addition to `core_tests.rs`. **Tested:** 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. Each process printed the actual NVIDIA adapter. ```powershell $env:XCL_ADAPTER='3090' # Separate process for each value, on each snapshot: $env:XCL_DIRECT_COMPACT='0' # then '1' cargo test --locked -p xcl --lib -- gpu_readlane_batch_multiwave_loop_probe --test-threads=1 --show-output ``` All four invocations: **1 passed / 0 failed / 0 ignored, zero SKIPPED notices**. Each executes both 64-thread `Present` and 128-thread `Spin` compute shaders, 16 groups, 64 loop iterations, six independent reads per iteration (lanes 0/7/31/32/41/63). Values evolve each iteration and differ by console wave. Every 1,024/2,048 output word agrees with the independent CPU sum and all 16 tail guards remain unchanged. This checks normal and forced-compact translation, repeated exchanges and cross-wave isolation. Both parent and head are correct; this is optimization coverage, not a newly fixed semantic failure. | Form / threads | DXIL bytes parent → head | Translation median ms parent → head | GPU dispatch median µs parent → head | |---|---:|---:|---:| | Normal / 64 | 2788 → 2824 | 1.7185 → 1.9372 | 17.408 → 8.192 | | Normal / 128 | 4400 → 3336 | 2.7085 → 1.9236 | 67.072 → 17.408 | | Compact / 64 | 3864 → 3892 | 2.2746 → 2.0802 | 22.528 → 14.336 | | Compact / 128 | 5516 → 4444 | 3.1909 → 2.3891 | 73.728 → 21.504 | Emitted barrier calls fall **13 → 3** in all four forms; `atomicrmw add` falls **13 → 3** for the 128-thread spin case (64-thread remains one setup atomic). The spin form gets smaller and translates faster in this fixture. The 64-thread normal form instead grows by 36 bytes and has a slightly higher measured translation cost; there is no universal compile-time improvement claim. Method: one untimed warm translation then five timed `translate_compute` calls, each byte-identical to that reference; explicit final DXIL validation outside the timer. GPU timings are ten samples after discarding the first of eleven timestamped dispatches; they exclude PSO creation, resources, upload/readback, submission, CPU wait and the barriers between dispatches. Correctness was checked on a separate untimed dispatch: the timed API discards its readback. One process per form/revision, parent before head, no randomized order/clock control; these short synthetic timings are descriptive, **not retail speedup or cold-PSO evidence**. Both 322-file source snapshots match before/after Windows execution and locally; Cargo rebuilt XCL for each revision. **Not tested:** full workspace, retail smoke, native wave64, AMD, LDS-carved exchange storage, divergent/partial EXEC in this new fixture, or memory consumption. The existing author hazard tests cover different cases and were not rerun here. The fixture is offered for adoption alongside those tests; no competing PR. **AI use:** Codex (GPT-6) wrote the synthetic test, performed the native Windows comparison and prepared this report. <details> <summary>Portable test-only patch (same addition on parent and head)</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/core_tests.rs b/crates/xcl/src/gpu/dxil/core_tests.rs index 5e52646..e5a5cd1 100644 --- a/crates/xcl/src/gpu/dxil/core_tests.rs +++ b/crates/xcl/src/gpu/dxil/core_tests.rs @@ -711,3 +711,69 @@ fn gpu_split_readlane_batch_executes_correctly() { assert_eq!(r.sgpr[16], 0x1000 + 37, "s16 = v0[37]"); assert_eq!(r.sgpr[17], 0x2000 + 37 * 3, "s17 = v1[37]"); } + +/// Exercise batched reads through real multi-wave compute loops, not only the kernel ABI. +#[test] +fn gpu_readlane_batch_multiwave_loop_probe() { + use crate::gpu::recomp::{self, runner, CsInterface}; + if runner::wave32_supported() != Ok(true) || recomp::dxc::location().is_err() { + runner::skip_test("no wave32 / DXC"); + return; + } + println!("READLANE_GPU={}", runner::adapter().unwrap()); + let compact = super::kernel::compact_mode().expect("set XCL_DIRECT_COMPACT=0 or 1"); + for threads in [64u32, 128] { + let cs = CsInterface { threads: [threads, 1, 1], user_sgprs: 8, tgid: [true, false, false], tg_size: false, tid_components: 1 }; + let mut code = prog(&[ + ("S_LSHL_B32", "ENC_SOP2", &[("SDST", 9), ("SSRC0", 8), ("SSRC1", 128 + threads.trailing_zeros() as u64)], None), + ("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 9), ("VSRC1", 0)], None), + ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 130), ("VSRC1", 1)], None), + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 20), ("SSRC0", 192)], None), + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 30), ("SSRC0", 128)], None), + ]); + code.truncate(code.len() - 4); + let loop_at = code.len(); + code.extend(encode("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 10), ("SRC0", 257)], None).unwrap()); + for (dst, lane) in [(11, 7), (12, 31), (13, 32), (14, 41), (15, 63)] { + code.extend(encode("V_READLANE_B32", "ENC_VOP3", &[("VDST", dst), ("SRC0", 257), ("SRC1", 128 + lane)], None).unwrap()); + } + for src in 10..16 { + code.extend(encode("S_ADD_U32", "ENC_SOP2", &[("SDST", 30), ("SSRC0", 30), ("SSRC1", src)], None).unwrap()); + } + code.extend(encode("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 129), ("VSRC1", 1)], None).unwrap()); + code.extend(encode("S_SUB_U32", "ENC_SOP2", &[("SDST", 20), ("SSRC0", 20), ("SSRC1", 129)], None).unwrap()); + code.extend(encode("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 20), ("SSRC1", 128)], None).unwrap()); + let back = (loop_at as i64 - code.len() as i64 - 4) / 4; + code.extend(encode("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", back as i16 as u16 as u64)], None).unwrap()); + code.extend(prog(&[ + ("V_MOV_B32", "ENC_VOP1", &[("VDST", 3), ("SRC0", 30)], None), + ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 2), ("DATA", 3), ("SADDR", 0)], None), + ])); + let o = KernelOptions { wave64: true, split: true, mem_windows: 1, sampler_base: 0 }; + let compile = || super::kernel::translate_compute(&code, o, &cs).unwrap().dxil; + let dxil = compile(); + super::validate::validate(&dxil).unwrap(); + let dis = super::validate::disassemble(&dxil).unwrap(); + let mut compile_ms = Vec::new(); + for _ in 0..5 { + let start = std::time::Instant::now(); + let again = compile(); + compile_ms.push(start.elapsed().as_secs_f64() * 1000.0); + assert_eq!(again, dxil, "translation changed bytes"); + } + let mut io = vec![0u32; recomp::KERNEL_SGPRS]; + io[1] = 1; + io[recomp::IO_UMA_BASE_HI] = 1; + let n = threads as usize * 16; + let mem = vec![0xdeadbeef; n + 16]; + let out = runner::dispatch(&dxil, [16, 1, 1], &io, &mem).unwrap(); + for (i, &got) in out[..n].iter().enumerate() { + let wave_base = (i / 64 * 64) as u32; + let want: u32 = (0..64).map(|iteration| [0, 7, 31, 32, 41, 63].into_iter().map(|l| wave_base + l + iteration).sum::<u32>()).sum(); + assert_eq!(got, want, "compact={compact} threads={threads} output[{i}]"); + } + assert_eq!(&out[n..], &mem[n..], "tail overwritten"); + let gpu_ms = runner::dispatch_timed(&dxil, [16, 1, 1], &io, &mem, 11).unwrap(); + println!("READLANE compact={compact} threads={threads} output_words={n} guard_words=16 dxil_bytes={} barriers={} atomic_add={} compile_ms={compile_ms:?} gpu_ms={gpu_ms:?}", dxil.len(), dis.matches("call void @dx.op.barrier(").count(), dis.matches("atomicrmw add").count()); + } +} ``` </details>
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-25 03:14 UTC · original

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 #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. c270670 as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • gpu_split_readlane_batch_executes_correctly: ok, not skipped
    • split_readlane_batch_merges_present_and_spin_exchanges: ok, not skipped
    • split_readlane_batch_respects_sgpr_hazards: 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.
**@⁠JoaoPauluu** on GitHub · 2026-11-25 03:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7151725807) 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 #257, DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `c270670` as it is (merge base with `main` `cbc296a`), no uncommitted changes. The lib test binary runs under Wine, one test per process. - `gpu_split_readlane_batch_executes_correctly`: ok, not skipped - `split_readlane_batch_merges_present_and_spin_exchanges`: ok, not skipped - `split_readlane_batch_respects_sgpr_hazards`: 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 05:09 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 05:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7153508880) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 03:29 UTC · original · edited 2026-11-25 12:35 UTC

Update for head 3b7dbf5: same result. Tested as is (it no longer applies on current main), gpu_split_readlane_batch_executes_correctly passes on the RX 9070 XT and the RTX 3060. Whole gpu:: filter: RTX 3060 632 passed, 0 failed; RX 9070 XT 629 passed, 3 failed, all three also failing on this head's base 426a5a7 without the PR (the #2115 fuzz seeds and gpu_image_get_resinfo_past_last_level, since fixed on main).


AMD run, with gpu::dxil::fuzz_tests, both of which this PR lists as not tested.

Tested: head c270670 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_split_readlane_batch_executes_correctly ok. The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3 (seeds 722 and 1599, a wrong result word on this card). They fail the same way on main cbc296a without this PR, so this change neither causes nor fixes them; fuzz_validate_and_gpu_0 and _2 pass with it.
  • NVIDIA RTX 3060, driver 32.0.16.1088, split wave64: 589 passed, 0 failed, 22 ignored, all fuzz tests included.

Not tested: Linux / Wine / vkd3d-proton.

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

**@⁠DarkPanda69** on GitHub · 2026-11-25 03:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7151964371) · edited 2026-11-25 12:35 UTC **Update for head `3b7dbf5`:** same result. Tested as is (it no longer applies on current `main`), `gpu_split_readlane_batch_executes_correctly` passes on the RX 9070 XT and the RTX 3060. Whole `gpu::` filter: RTX 3060 632 passed, 0 failed; RX 9070 XT 629 passed, 3 failed, all three also failing on this head's base `426a5a7` without the PR (the #2115 fuzz seeds and `gpu_image_get_resinfo_past_last_level`, since fixed on `main`). --- AMD run, with `gpu::dxil::fuzz_tests`, both of which this PR lists as not tested. **Tested:** head `c270670` 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_split_readlane_batch_executes_correctly` ok. The 2 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` and `_3` (seeds 722 and 1599, a wrong result word on this card). They fail the same way on `main` `cbc296a` without this PR, so this change neither causes nor fixes them; `fuzz_validate_and_gpu_0` and `_2` pass with it. - NVIDIA RTX 3060, driver 32.0.16.1088, split wave64: 589 passed, 0 failed, 22 ignored, all fuzz tests included. **Not tested:** Linux / Wine / vkd3d-proton. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠zondy1i on GitHub · 2026-11-25 16:10 UTC · original

Continued in #2343 (rebased cleanly onto current main; this PR was auto-closed when the fork branch was briefly deleted during a GitHub sync glitch and cannot be reopened).

**@⁠zondy1i** on GitHub · 2026-11-25 16:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7167652775) Continued in #2343 (rebased cleanly onto current `main`; this PR was auto-closed when the fork branch was briefly deleted during a GitHub sync glitch and cannot be reopened).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 07:14 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 07:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2071#issuecomment-7185237227) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.