Repository navigation
Recompiler: direct DXIL vectorizes multi-dword loads and window switch - #1699
RandomGithub12309 wants to merge 1 commit into
Conversation
`gpu/dxil/lower_mem` lowered `with_mem` as four sequential `guarded` diamonds (8 blocks, 2 temporary SSA variables, and `i64` unpack/repack per access) and emitted multi-dword SMEM, MUBUF, `ld_raw`, and FLAT/global accesses as scalar per-dword `mem_ld`/`mem_st` loops, repeating the full window dispatch for each dword. Lower `with_mem_n` as a single `Op::Switch` over `VAR_WIN` (folding constant `VAR_WIN` inline without branching), merging return values directly through `join` phis and sealing `join` as a single-predecessor SSA pass-through from the pre-switch block. Group contiguous unbounded multi-dword loads/stores (`s_load_dwordx2..x16`, `ld_raw`, and FLAT/global `load_dwordx2..x4` / `store_dwordx2..x4`) into up to 4-wide `rawBufferLoad`/`rawBufferStore` chunks under one switch, share one switch across `s_buffer_load*` and `buffer_load*` dwords with per-dword bounds clamping, and combine 1-dword `buffer_store_dword`'s lane and range guards. Bump `TRANSLATOR_VERSION` to 5. On a 200-program retail pack sample (`--direct --sample 200 --max-bytes 0 --validate --compare`, 4 windows, split wave64), total direct DXIL size across the 197 translated programs drops from 30.24 MB to 22.57 MB (-25.4%, direct/HLSL 1.25 -> 0.94), and translation time drops from p50 20.36 ms / p95 277.55 ms / max 837.86 ms to 15.66 ms / 152.00 ms / 417.81 ms with 0 validator errors. Part of xcl-dev#1269 Assisted-by: Antigravity (Gemini 4 Carbon / Gemini 4 Hydrogen)
|
Independent AMD native-wave64 coverage at Tested
The base used guarded branches and scalar loads for this fixture. The PR's three switches correspond to the three 16-word reads. Not tested Retail title or shader pack, AMD discrete or other adapters, heap windows in direct DXIL, or compilation and runtime timing. AI use OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary comparison, ran the tests, and drafted this report. |
|
Offline pass under Wine, CPU only, Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 62 GB RAM. These passes used no card. Release, cross-compiled to Tested
Every direct pass compiled all its programs (2,689 or 243) with 0 errors and wrote no DXC output file, which is how "no fallback" was counted. The By size on
On the first 243 programs in the split form the HLSL path writes 49.1 MB on Read
Not tested: AI use: Claude Code (Claude Fable 5.2) ran the passes, read the diff and wrote this report. Posted without review by a person: the account owner was away and reads replies later. |
|
Independent NVIDIA wave32 / split-wave64 verification and rebase review of Environment
Tested
Review / rebase notes against current However,
Not tested
AI use
|
|
Test report: Retail 1.0.2.1
In the 16–48 KB range one program is 7.4 of the 12.4 s saved (23.5 → 16.1 s). The two slower ones: 2.70 → 3.33 s and 18.4 → 19.2 s. For comparison, a local prototype that only groups loads (scalar loads, the same compare ladder, no Tested: One question: a vector load or store that straddles the end of a 4 GiB window no longer wraps its later dwords to the window's start as the per-dword form did. I have not tested it. Intended? Not tested: the branch merged with #1693 (it conflicts with AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this. |
|
Tested commit Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
|
Closing as superseded by |
In the direct RDNA2 → DXIL backend (
XCL_DIRECT_DXIL),Lw::with_memlowered multi-window accesses as four sequentialguardeddiamonds (8 basic blocks, two temporary SSA variables, andi64unpack/repack per access), and multi-dword SMEM,ld_raw,s_buffer_load*,buffer_load*, and FLAT/global instructions ran per-dword scalar loops that repeated that full window dispatch for every dword.Lw::with_mem_nnow emits a singleOp::SwitchoverVAR_WIN(folding constantVAR_WINinline without branching), merges returned values directly throughjoinphis without temporary SSA variables ori64split/repack, and sealsjoinas an O(1) pass-through from the pre-switch block. Contiguous unbounded multi-dword accesses (s_load_dwordx2..x16,ld_raw, and FLAT/globalload_dwordx2..x4/store_dwordx2..x4) pack into up to 4-widerawBufferLoad/rawBufferStorechunks under one switch,s_buffer_load*andbuffer_load*share a single switch across their dwords with per-dword bounds clamping, and 1-dwordbuffer_store_dwordcombines its lane and range guards. Part of #1269.What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs:Lw::with_mem_n,Lw::with_mem,Lw::mem_ld_n, andLw::mem_st_n; single-switch multi-dword lowering inld_raw,smem,mubuf, andflat.crates/xcl/src/gpu/dxil/kernel.rs: bumpTRANSLATOR_VERSIONfrom4to5.crates/xcl/src/gpu/dxil/tests.rs:multi_window_accesses_emit_one_switch_and_wide_raw_ops(validates and disassembles a 5-instruction test checking oneswitch i32per instruction andi8 154-wide raw buffer ops) andmulti_window_vector_loads_stores_and_atomics_run_on_the_gpu(runs 2-windowUmaGPU checks forS_LOAD_DWORDX8,S_BUFFER_LOAD_DWORDX4andBUFFER_LOAD_DWORDX3straddlingnum_records, unalignedBUFFER_LOAD_FORMAT_XYZWviald_raw,GLOBAL_LOAD_DWORDX4/GLOBAL_STORE_DWORDX4, and 64-bitGLOBAL_ATOMIC_ADD_X2GLC=1).Tested
32.0.16.2114), Intel Core Ultra 7 255HX, Windows 11 Home build26300,rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.8.2502.11; debug for tests, release for shader sweeps and smoke runs, on7b8711407e77..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4):860 passed, 0 failed, 42 ignored(811lib +49integration).SKIPPEDGPU tests on this adapter:gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo test -p xcl --lib gpu::dxil -- --test-threads=4:82 passed, 0 failed, 1 ignored.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp:194 passed, 0 failed, 18 ignored(both--test-threads=1and--test-threads=4; one earlier--test-threads=4run hit a transient0x887a0006device removal under 8 GB VRAM contention alongside concurrent sparse-VRAM fixtures).XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu::recomp -- --test-threads=1:194 passed, 0 failed, 18 ignored(run single-threaded because concurrent sparse-VRAM /Umafixtures exhaust 8 GB VRAM under--test-threads=4).xcl shaders <pack> --direct, 4 windows, split wave64,--validate --compare, release builds before/after this diff):--sample 50(seed 1):34 / 36translated (0validator errors;2GS unsupported); DXIL size1,647,204 B → 1,394,876 B(−15.3 %,direct/HLSL 1.08 → 0.91); translation timep50 16.44 → 13.31 ms,p95 40.12 → 24.41 ms,max 41.80 → 29.96 ms.--sample 200 --max-bytes 0 --timeout 20(seed 1):197 / 200translated (21 CS, 67 MS, 86 PS, 23 VS,0validator errors;3GS unsupported); DXIL size30,238,100 B → 22,568,676 B(−25.4 %,direct/HLSL 1.25 → 0.94vs24,113,960 BHLSL+DXC); translation timep50 20.36 → 15.66 ms(−23.1 %),p95 277.55 → 152.00 ms(−45.2 %),max 837.86 → 417.81 ms(−50.1 %).Regression run
Retail title, 60 s each, release builds,
XCL_DIRECT_DXILunset (default runtime path), no uncommitted changes.main:
this PR:
Not tested
vkd3d-proton).XCL_DIRECT_DXIL=1/=all(the smoke runs above exercise the default runtime path; the direct backend changes are covered by theXCL_DIRECT_DXILgpu::recompsuites, thegpu::dxilGPU tests, and the 200-program validated pack sweep).AI use
crates/xcl/src/gpu/dxil/lower_mem.rs, wrote the implementation, tests, and this description, and ran the test suites, shader sweeps, and smoke runs on the machine above.