Recompiler: vectorize multi-dword loads/stores and merge window switches #1439
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1439
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1439"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@coolpersonnn on GitHub · 2026-11-24 15:58 UTC · original
coolpersonnn:recomp/vectorize-multi-dword-loads→main· +276 −38 · 2 files · 1 commits · openVectorize 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.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 against930e8b4with 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 #1269 Assisted-by: T3 Code / Antigravity (gemini-pro-orchestrator-neon)@mastrr9 on GitHub · 2026-11-24 16:04 UTC · original
Verified head
d2d28789aa24eb40970f486e16c22f561ce749a4on Windows 11 / NVIDIA RTX 5080 (wave32 / split-wave64, DXC 1.9.2602.17, Rust MSVC, debug build, clean worktree):cargo test -p xcl --lib -- gpu::recomp --test-threads=4: 191 passed, 0 failed, 18 ignored (0 new compiler warnings).Not tested: AMD native wave64, full workspace, retail smoke (
scripts/smoke.ps1).AI use: T3 Code (Antigravity / Claude Sonnet 5.5) ran the build and tests on our RTX 5080 and drafted this report.
@tctev on GitHub · 2026-11-24 16:15 UTC · original
Tested head
d2d28789aa24in debug on an RTX 4050 Laptop (driver 32.0.16.1742, wave32 / split wave64), i5-12500H, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2602.17.Running the whole suite with
cargo build --workspace && cargo test --workspace -- --test-threads=4gave 757 passed, 0 failed, and 41 ignored, withgpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardwareskipped for no wave64.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
global_load_dwordx4and aglobal_store_dwordx3in window 1 togpu_memory_windows_above_4_gib(diff below) passes on this head while its call-site check fails onmain, so it pins the one-switch form for multi-window programs.I also read through the
emit.rspart. The new load helpers are defined beforePRELUDE_MEMuses them in both the one-window and multi-window headers, and the per-dword bounds masking is still there; nothing I'd change.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.
@coolpersonnn on GitHub · 2026-11-24 16:20 UTC · original
Thanks @tctev for the full-suite run, the
emit.rsreview, and the suggested multi-window test addition from #1443 (and thanks @DarkPanda69 and @mastrr9 for testing on RX 9070 XT, RTX 3060, and RTX 5080 — great to have native wave64 RDNA4 coverage on headd2d28789aa24).Adding unaligned
global_load_dwordx4andglobal_store_dwordx3plus thexcl_mLoad4(/xcl_mStore3(call-site checks togpu_memory_windows_above_4_gibis a clean way to pin the multi-window vector path on the GPU. Keepingd2d28789aa24as-is for now so the existing multi-GPU runs and smoke check stay aligned with head, and happy to fold that test diff in (with a freshscripts/smoke.ps1run) if a maintainer wants it included before merge.Message generated by AI (Gemini Neon)
@DTsordas on GitHub · 2026-11-24 17:16 UTC · original
Test report for
d2d2878on a discrete AMD GPU, with DXC timings across a broad program mixTested
cargo build --workspace && cargo test --workspace -- --test-threads=4ond2d2878: 757 passed, 0 failed, 41 ignored, no SKIPPED. Both new GPU tests pass:gpu_vectorized_loads_partial_oob_at_buffer_end_and_global_rwandgpu_grouped_loads_bounds_and_inactive_lanes.d2d2878and its base037aecd, then ranxcl shaders shaders.rpf --recompwithXCL_DUMP_HLSLandXCL_DUMP_EVERY=400. That dumps the same 59 programs from each build (every program whose name hash ≡ 0 mod 400: 26 MS, 19 PS, 5 CS, 5 VS, 4 GS). I compiled them withdxc.exe1.9.2602.17 using XCL's flags (-HV 2021, -O picked by size asdxc.rsdoes), best of 2, withscripts/dxc_ab.py. All 59 compile on both builds.XCL_RECOMP_WINDOWS=4)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
mainthe buffer loads this PR rewrites cost about 6.5 ms of DXC time each, against about 0.7 ms for a VALU op. They are 3 % of instructions and 22 % of DXC time. With one window, this PR saves 3.7 s on the same programs. The ablation, run separately on a latermain, put buffer and SMEM loads together at about 16 s. That is only a rough comparison, but it suggests a good part of the load cost is still left.Not tested
AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and measurements and wrote this report.
@coolpersonnn on GitHub · 2026-11-24 18:50 UTC · original
Thanks @GonZiin for catching that — rebased onto
c160d86and force-pushed (7ed8f93):XCL_MW) implementations ofxcl_load4x2,xcl_load4x4, andxcl_load5inmem_accessors(crates/xcl/src/gpu/recomp/emit.rs), zeroing alloutparameters before returning whenxcl_w >= windows.multi_dword_loads_and_stores_use_vector_accessorsto translate and DXC-compile 1-window, 4-window switch, and 4-window descriptor-heap modes.gpu_memory_windows_from_the_heap,gpu_heap_windows_reject_out_of_uma_aliasing, and their switch counterparts) forS_LOAD_DWORDX8, partial-OOBS_BUFFER_LOAD_DWORDX4(at window top in bounded heap mode and interior in unbounded Root-UAV mode), and out-of-UMAS_LOAD_DWORDX8.GLOBAL_LOAD_DWORDX4andGLOBAL_STORE_DWORDX3+xcl_mLoad4(/xcl_mStore3(multi-window checks from #1443 (and thanks @DTsordas for the discrete AMD DXC A/B numbers across the 59 retail programs).Re-verified on RTX 5090 (
XCL_ADAPTER=nvidia) on7ed8f93:.\scripts\test.ps1: 860 passed, 0 failed, 42 ignored (2wave64-only tests and1heap_window_out_of_memory_falls_back_to_the_switch_formskipped).scripts/smoke.ps1, 60 s):1669frames on PR7ed8f93vs1670onmainc160d86,0device removals,0crashes,14660 MBpeak commit.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.
@DavidM1911 on GitHub · 2026-11-24 18:52 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@nnonno91 on GitHub · 2026-11-24 19:05 UTC · original
Independent AMD native-wave64 check of
7ed8f931a1757b1e37d3e52cf8133ee5ef9b646c.Tested
XCL_ADAPTER='AMD Radeon'and used unoptimized debug/test builds (debug info disabled on the PR).cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 860 passed, 0 failed, 42 ignored. The bundled title passed. One explicit GPU skip is included in the pass count (heap_window_out_of_memory_falls_back_to_the_switch_form, heap windows off).XCL_REQUIRE_GPU=wave64,mesh,cargo test --locked -p xcl --lib -- multi_dword_loads_and_stores_use_vector_accessors gpu_vectorized_loads_partial_oob_at_buffer_end_and_global_rw gpu_memory_windows_above_4_gib gpu_memory_windows_from_the_heap gpu_memory_windows_reject_out_of_uma_aliasing gpu_heap_windows_reject_out_of_uma_aliasing --test-threads=1 --nocapturegave 6 passed, 0 failed, 0 ignored, 0 skips. This covered the single-window GPU fixture and the switch and descriptor-heap multiple-window fixtures.XCL_HEAP_WINDOWS=1,cargo test --locked -p xcl --test gpu_compute_e2e -- --test-threads=1 --show-outputgave 4 passed, 0 failed, 0 ignored, 0 skips. The log confirmed use of the shared descriptor heap and a rebuild in switch form after the test injected an out-of-memory result.cargo test --locked -p xcl --test dwordx16_window_probe -- --exact dwordx16_reads_respect_window_and_buffer_bounds --test-threads=1 --nocaptureran the same temporary native-wave64 fixture at the PR and its basec160d86ef2efe3a07e4dfb473e4fa72eafb413c0(one pass each, no skips). It dispatched in switch and descriptor-heap modes, with two mapped windows 4 GiB apart. In both modes and builds, all 16 words of an ordinary load came from window 1, a buffered load returned 13 valid words and three zeros, and a load targeting an unmapped window returned 16 zeros. The partial heap read ended at the physical view boundary. In switch mode the three excluded words had nonzero sentinels. The PR emitted threexcl_load4x4call sites per mode, versus zero on the base.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.
@DarkPanda69 on GitHub · 2026-11-24 16:02 UTC · original · edited 2026-11-24 19:51 UTC
The run on a discrete AMD GPU with
XCL_ADAPTER=radeon, which this PR lists as not tested. Updated for head7ed8f93(first run was ond2d28789aa24, same result).Tested: pass, head
7ed8f93merged ontomain9039900(no conflicts), debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu::recomp --test-threads=4:XCL_ADAPTER=radeon, native wave64: 196 passed, 0 failed, 18 ignored, 0 SKIPPED.gpu_vectorized_loads_partial_oob_at_buffer_end_and_global_rwand the memory / heap window tests ok.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.
@DavidM1911 on GitHub · 2026-11-26 05:27 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.@GonZiin on GitHub · 2026-11-24 17:47 UTC · original · reviewed
The rebase onto current
mainneeds a heap-window implementation for all three new vector helpers. I confirmed the conflict with #680 inmem_accessors. Keeping the old heap branch and resolving only the switch branch leavesxcl_load4x2,xcl_load4x4andxcl_load5undeclared in heap-window shaders.Tested
git merge-tree --write-treefor base9e3831e1f570d3646e53ab753b19ec07eb8f1485and PR headd2d28789aa24eb40970f486e16c22f561ce749a4reported a content conflict incrates/xcl/src/gpu/recomp/emit.rs.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.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.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.