Repository navigation
Conversation
RTX 3090: actual multi-wave compute execution and costThe new fixture below closes the GPU-execution gap for 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-outputAll four invocations: 1 passed / 0 failed / 0 ignored, zero SKIPPED notices. Each executes both 64-thread
Emitted barrier calls fall 13 → 3 in all four forms; Method: one untimed warm translation then five timed 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());
+ }
+} |
XCL #2071 — Intel Arc A770 split-wave64 compatibilityTested Clean PR head The process environment used & "$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 (
3 passed, 0 failed, 0 ignored, 0 skipped. All three exited 0. Disassembly matched three barriers for the 64-thread group and three 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 AI use T3 Code / Codex ( |
|
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
Not tested
AI use
|
|
AMD run, with Tested: head
Not tested: Linux / Wine / vkd3d-proton. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Part of #1269.
Brings the split-wave64
v_readfirstlane_b32/v_readlane_b32exchange 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_b32previously emitted its own single-wordexchange_n(&[m])— 2 group barriers per instruction inPartner::Present(64-thread groups) and a full 4-block spin-wait loop with 2TGSM_FENCEbarriers and 2 groupsharedatomicrmwops per instruction inPartner::Spin(>64-thread groups). Consecutive independent runs now share a singleexchange_ncall. Native wave64 and wave32 lowering is untouched.What changed
crates/xcl/src/gpu/dxil/lanes.rs:Lw::read_lane_uniform_batch(&[(Value, Value)])to perform one cross-halfexchange_nacross a run of independent lane reads (reusingl & 31andlh == self.halfwhen consecutive items share the same lane index).crates/xcl/src/gpu/dxil/lower_valu.rs:Lw::lower_block_inststo greedily batch consecutiveVariant::Plainv_readfirstlane_b32/v_readlane_b32instructions within a basic block up toself.xslot, stopping at any SGPR read-after-write hazard (includingEXEC,VCCZ,EXECZ,M0, orEXECwrites).max_readlane_batch(stopping at CFG blockleaders) to size split-wave64 exchange slots inLw::new.crates/xcl/src/gpu/dxil/kernel.rs&crates/xcl/src/gpu/dxil/compact.rs:Lw::lower_block_instsin both the standard and compact forms.slotinLw::newwhensplitandmax_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 consecutivev_readfirstlane_b32/v_readlane_b32collapse from 13 to 3 barriers (Partner::Present) and from 13 to 3atomicrmw addspin ops (Partner::Spin).split_readlane_batch_respects_sgpr_hazards: verifies lane-selector RAW dependencies andEXECwrites 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
rustc 1.100.0, DXC /dxil.dll1.9.2609.5, NVIDIA GeForce RTX 3060 Ti 8 GB (driver621.01).cargo test -p xcl --lib -- gpu::dxil --skip fuzz_tests: 120 passed, 0 failed, 1 ignored (includessplit_readlane_batch_merges_present_and_spin_exchanges,split_readlane_batch_respects_sgpr_hazards,gpu_split_readlane_batch_executes_correctly, andcompact_tests).xcl shaders <corpus> --direct --sample 500 --seed 1 --max-bytes 262144 --split 1 --validate --threads 8: 500/500 translated and validated bydxil.dll 1.9.2609.5(0 unsupported, 0 validator failures, 0 panics).Not tested
gpu::dxil::fuzz_tests, AMD / Intel GPUs, Linux / Wine / vkd3d-proton.Regression run
main:PR:
AI use
Antigravity (Gemini 4 Neon) assisted with implementation, IR/hazard/GPU tests, and validation; all changes were reviewed and verified locally.