Repository navigation
Recompiler: large compute programs share repeated code with DXC and the driver - #1867
SamG-Coder wants to merge 1 commit into
Conversation
…he driver Buffer bounds checks, typed-buffer conversions, memory-window accessors, the split-wave64 exchange and the EXEC bit test are emitted once and called, instead of being repeated at every use in large compute programs. Repeated single-entry branch arms of very large programs are outlined into functions. Buffer indices add the lane id when the descriptor's ADD_TID bit is set, inactive or out-of-range lanes load from address 0, and unaligned 8- and 16-byte typed stores write every affected dword. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@SamG-Coder an AMD data point for this draft: on an RX 9070 (RDNA4), every pipeline built from this branch's HLSL suspends the device. Tested
The Not tested
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the measurements and wrote this comment. |
|
Superseded by #1901, which is the shared-helper change from this branch on its own, per CONTRIBUTING's one change per PR. Measuring each part separately showed that the |
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
Part of #1269. Large compute programs share code the HLSL path repeated at every use, so DXC and the driver see one copy instead of thousands. On six retail compute programs of 1.3 – 6.7 MB HLSL, pipeline creation is 1.4 – 5.4× faster and the DXIL 11 – 27 % smaller (table below).
Draft: this branch combines the changes so they could be measured together on current
main. It will be split into separate PRs per CONTRIBUTING before review (see What is in it), and the regression runs are still missing.What is in it
xcl_buf_in_rangehelper instead of an inline bounds expression at every buffer access.lanebitis[noinline]in programs of 4 096+ instructions (one copy of the EXEC bit test instead of one per vector write).fmt_*,st_bytes) are shared,[noinline], in compute programs of 256+ instructions; the memory-window accessors and the split-wave64 exchange are out of line from 1 024 instructions (switch windows only; heap windows are unchanged).regions.rs: in compute programs of 4 096+ instructions where repeated blocks are over a third of the code, a repeated single-entryifarm is emitted once as a function.gpu/recomp/tests.rs.Measurements (
xcl shaders <pack> --measure-pso <record> --repeat 3: DXC, thenCreateComputePipelineStatewith the driver cache off; same machine,mainc4d37bevs this branch; the first pass and a second pass agree within 3 %)DXC is slower on one of the six (4.21 MB: +4 %). Whole-pack translation (
XCL_RECOMP_STAGES=CS xcl shaders <pack> --recomp): 2 689 / 2 689 compute programs translate on both, HLSL 3 542.6 → 3 518.9 MB (the gain is in what DXC and the driver do with it, not in the text).Tested
cargo test --workspace -- --test-threads=4: 967 passed, 0 failed, 43 ignored (SKIPPED GPU tests: 12 tests, 22 cases: the wave64 cases ofgpu::recomp::lower/lower_dxilandgpu_wave32_program_in_wave64_hardware,gpu_geometry_wave32_prefix_count_over_a_maskfor no wave64 on this GPU;heap_window_out_of_memory_falls_back_to_the_switch_formfor no heap windows). Release build, aftercargo build --workspace --release.Regression run
main:
PR:
Not tested
scripts/smoke.ps1regression run yet (main or PR); required before this leaves draft.AI use
main(resolving the conflicts with heap windows and the structured-size fallback), ran the tests and measurements, and wrote this description.