Repository navigation
Recompiler: vectorize multi-dword loads/stores and merge window switches - #1439
coolpersonnn wants to merge 1 commit into
Conversation
|
The run on a discrete AMD GPU with Tested: pass, head
Not tested: AMD shader benchmark timings; the whole workspace suite; Linux / Wine; a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Verified head
Not tested: AMD native wave64, full workspace, retail smoke ( |
|
Tested head Running the whole suite with I closed #1443 as a duplicate of this, though one thing from it may be worth taking: none of the GPU tests here run the vector global path across real memory windows (the shape test translates with several windows, the GPU test runs one). Adding an unaligned I also read through the Not tested: retail title, AMD, native wave64. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and drafted this report. diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 66691c7..22377bc 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -3367,2 +3367,4 @@ fn gpu_memory_windows_above_4_gib() {
glbl("GLOBAL_ATOMIC_ADD", &[("VDST", 10), ("ADDR", 3), ("DATA", 11), ("SADDR", 16), ("OFFSET", 0), ("GLC", 1)]), // s[16:17] + v3 → window 1
+ glbl("GLOBAL_LOAD_DWORDX4", &[("VDST", 12), ("ADDR", 4), ("SADDR", 0x7D), ("OFFSET", 4)]), // v[4:5] + 4: not 16-byte aligned
+ glbl("GLOBAL_STORE_DWORDX3", &[("ADDR", 16), ("DATA", 12), ("SADDR", 0x7D), ("OFFSET", 0)]), // v[16:17] → window 1
];
@@ -3374,2 +3376,4 @@ fn gpu_memory_windows_above_4_gib() {
assert!(t.hlsl.contains("RWByteAddressBuffer mem1 : register(u3)"));
+ // check call sites since the accessors are defined either way
+ assert!(t.hlsl.contains("= xcl_mLoad4(") && t.hlsl.contains(") xcl_mStore3("), "global x4 / x3: one window switch each");
let dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap();
@@ -3391,2 +3395,4 @@ fn gpu_memory_windows_above_4_gib() {
r[11] = 1;
+ r[16] = (w1 + 0x7000 + 16 * l) as u32;
+ r[17] = hi(w1);
}
@@ -3400,2 +3406,7 @@ fn gpu_memory_windows_above_4_gib() {
assert_eq!(*word(w1 + 0x5000 + 4 * l), 7 * l as u32, "lane {l}: global_store into window 1");
+ // dwords l+1..l+4 of the 64 written at 0x4000; anything past them is 0
+ let x4: Vec<u32> = (1..5).map(|k| if l + k < 64 { 5000 + (l + k) as u32 } else { 0 }).collect();
+ assert_eq!(r.vgpr[l as usize][12..16], x4, "lane {l}: global_load_dwordx4 from window 1");
+ let x3: Vec<u32> = (0..3).map(|k| *word(w1 + 0x7000 + 16 * l + 4 * k)).collect();
+ assert_eq!(x3, x4[..3], "lane {l}: global_store_dwordx3 into window 1");
} |
|
Thanks @tctev for the full-suite run, the Adding unaligned Message generated by AI (Gemini Neon) |
Compiles the HLSL samples two XCL builds dumped for the same programs and reports DXC time and DXIL size overall and per stage. Part of xcl-dev#1269. Used on xcl-dev#1439 (d2d2878) against its base 037aecd, 59 retail programs, RX 9060 XT machine, dxc 1.9.2602.17, best of 2: one memory window DXC 47.60 -> 43.91 s (-7.8 %), DXIL -4.2 %; four windows 68.50 -> 61.70 s (-9.9 %), DXIL -9.2 %. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report for Tested
DXC time by stage:
Whole pack, 26 698 programs: HLSL 9 665.7 → 9 645.2 MB with 1 window and 10 759.3 → 10 753.6 MB with 4. The text barely shrinks, but DXC time and DXIL size drop. For context, I measured on #1269 that on Not tested
AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and measurements and wrote this report. |
GonZiin
left a comment
There was a problem hiding this comment.
The rebase onto current main needs a heap-window implementation for all three new vector helpers. I confirmed the conflict with #680 in mem_accessors. Keeping the old heap branch and resolving only the switch branch leaves xcl_load4x2, xcl_load4x4 and xcl_load5 undeclared in heap-window shaders.
Tested
- Linux:
git merge-tree --write-treefor base9e3831e1f570d3646e53ab753b19ec07eb8f1485and PR headd2d28789aa24eb40970f486e16c22f561ce749a4reported a content conflict incrates/xcl/src/gpu/recomp/emit.rs. - Windows 11 Pro 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug, SDK DXC 1.8.2502.11. On a temporary merge I extended
multi_dword_loads_and_stores_use_vector_accessorsto compile one-window, four-window switch and four-window descriptor-heap HLSL. Runningcargo test -p xcl --lib multi_dword_loads_and_stores_use_vector_accessors -- --nocapturepassed the first two modes and DXC rejected the third with undeclared identifiers for the three helpers. - I then emitted the three helpers in the heap branch using
XCL_MWand preserved zero outputs for an out-of-range window. The same test passed with all three modes enabled (1 passed, 0 failed, 0 ignored).
Please include the four-window heap case in the regression test when rebasing. It catches the API gap that the switch tests alone miss.
Not tested
GPU execution of the temporary merge and retail titles. This check compiles the emitted HLSL.
AI use
Codex (gpt-6.2-sol) tested the merge conflict, wrote and ran the temporary compilation probe, and drafted this review.
Previously s_buffer_load_dwordx{2,4,8,16} and buffer_load_dwordx{2,3,4}
used xcl_loadx4 (four scalar mem.Load calls per 4-dword group),
s_load_dwordx{8,16}, s_buffer_load_dwordx{8,16}, and ld_raw emitted
multiple [branch] switch (xcl_w) (or XCL_MW descriptor-heap) blocks per
instruction under mem_windows > 1, and flat/global multi-dword accesses
emitted scalar mem.Load/mem.Store calls.
Replace xcl_loadx4 with vector mem.Load{2,3,4} (gating the base address
on any(in) and zeroing OOB components with componentwise select), emit
mem.Load{2,3,4}/mem.Store{2,3,4} for multi-dword flat/global accesses,
and add xcl_load4x2, xcl_load4x4, and xcl_load5 in both switch and
descriptor-heap (`XCL_MW`) `mem_accessors` modes so multi-chunk reads
share one memory window dispatch and preserve zero outputs out of range.
Across 4 large extracted retail compute shaders (--windows 4 --split 1,
measured pre-rebase against 930e8b4 with cold DXIL and driver caches),
this cut DXIL size by 9.0%, cold DXC compile time by 17.2%, and cold
RTX 5090 PSO compile time by 5.8%.
Part of xcl-dev#1269
Assisted-by: T3 Code / Antigravity (gemini-pro-orchestrator-neon)
d2d2878 to
7ed8f93
Compare
|
Thanks @GonZiin for catching that — rebased onto
Re-verified on RTX 5090 (
AI use: T3 Code / Antigravity (gemini-pro-orchestrator-neon) resolved the rebase conflict, updated the tests, ran the suite and smoke checks, and wrote this reply. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Independent AMD native-wave64 check of Tested
Not tested Discrete AMD, retail workloads, Linux / Wine, or performance. AI use OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the tests, and drafted this report. |
Vectorize multi-dword memory loads/stores (
Load{2,3,4},Store{2,3,4}) and merge multi-chunk memory window dispatches into shared helpers so DXC and GPU shader compilers optimize fewer scalar memory operations and window branches. Part of #1269.What is in it
xcl_loadx4scalar expansion insmem(s_buffer_load_dwordx{2,4}) andmubuf(buffer_load_dwordx{2,3,4}) with branch-free vectormem.Load{count}(select(any(...), addr, 0u))and componentwiseselectzeroing OOB dwords (crates/xcl/src/gpu/recomp/emit.rs).xcl_loadx4and repeated[branch] switch (xcl_w)/XCL_MWdescriptor-heap lookups ins_load_dwordx{8,16},s_buffer_load_dwordx{8,16}, andPRELUDE_MEM'sld_rawwith shared helpersxcl_load4x2,xcl_load4x4, andxcl_load5across single-window (LOAD_HELPERS_ONE_WINDOW), multi-window switch, and descriptor-heap (XCL_MWinmem_accessors, zeroingoutparameters whenxcl_w >= windows) modes (crates/xcl/src/gpu/recomp/emit.rs).mem.Load{2,3,4}andmem.Store{2,3,4}inflatfor multi-dwordglobal/flataccesses while keeping the 1-dword form unchanged (crates/xcl/src/gpu/recomp/emit.rs).multi_dword_loads_and_stores_use_vector_accessors(covering 1-window, 4-window switch, and 4-window descriptor-heap HLSL + DXC compilation), add GPU testgpu_vectorized_loads_partial_oob_at_buffer_end_and_global_rw(bounds at the end of a 256-bytemembuffer, inactive lanes, and unalignedglobal_store/global_loadx2/x3/x4), and extendmemory_windows_above_4_gibandmemory_windows_reject_out_of_uma_aliasing(covering both switch and heap windows) withS_LOAD_DWORDX8, partial-OOBS_BUFFER_LOAD_DWORDX4, unalignedGLOBAL_LOAD_DWORDX4,GLOBAL_STORE_DWORDX3, and out-of-UMAS_LOAD_DWORDX8(crates/xcl/src/gpu/recomp/tests.rs).Tested
32.0.16.2101), AMD Ryzen 9 9950X3D 16-Core Processor, Windows 11 (NT 10.0.26300.0),rustc 1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11..\scripts\test.ps1(XCL_ADAPTER=nvidia, debug build on rebased7ed8f931a175):860 passed, 0 failed, 42 ignored(811lib +49integration/e2e/oracle;SKIPPEDGPU tests on RTX 5090:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows;XCL_SAMPLE_*unset/skipped).930e8b4in 4-window switch mode,--precompile --only cs --windows 4 --split 1, isolated coldXCL_DXIL_CACHE,XCL_PSO_DISK_CACHE=0, and cold NVIDIA/D3D12 shader caches) across 4 large extracted retail compute shaders:0ee92721dbda03f6: DXIL1,165,204 -> 1,066,328 B(-8.5%), cold DXC28.443 -> 22.154 s(-22.1%), cold PSO177.441 -> 167.876 s(-5.4%)6893b6dcf6e8b9e0: DXIL1,138,784 -> 1,034,028 B(-9.2%), cold DXC14.954 -> 10.502 s(-29.8%), cold PSO100.793 -> 100.184 s(-0.6%)ab5e0d66397ce5c8: DXIL1,304,588 -> 1,175,752 B(-9.9%), cold DXC15.246 -> 16.708 s(+9.6%), cold PSO155.008 -> 141.814 s(-8.5%)d821b06a29eceb3e: DXIL1,190,680 -> 1,091,000 B(-8.4%), cold DXC12.269 -> 9.339 s(-23.9%), cold PSO94.762 -> 87.735 s(-7.4%)4,799,256 -> 4,367,108 B(-9.0%), cold DXC70.912 -> 58.703 s(-17.2%), cold RTX 5090 PSO528.004 -> 497.609 s(-5.8%).mainand PR smoke runs in Regression run below ran with existing shader caches warm in default switch-window mode.Regression run
main:
PR:
Not tested
7ed8f931a175) on AMD (XCL_ADAPTER=radeon), native wave64, or discrete AMD GPUs; AMD shader benchmark timings; retail smoke withXCL_HEAP_WINDOWS=1; Linux / Wine;XCL_SAMPLE_*sample tests; and retail gameplay past 60 s.AI use
T3 Code / Antigravity (gemini-pro-orchestrator-neon) — inspected
emit.rsandtests.rs, implemented vectorized multi-dword loads/stores and merged switch/descriptor-heap helpers, wrote unit and GPU tests, rebased ontoc160d86, ran the test suite, shader benchmarks, and smoke runs, and drafted the commit, PR description, and review reply.