Repository navigation
Recompiler: large compute programs call shared helpers instead of inlining them - #1901
SamG-Coder wants to merge 1 commit into
Conversation
…ining them DXC inlines every helper before it optimises, so a large compute program gets a copy of the memory-window switch, the split-wave64 exchange and the typed-format conversions at every use, and the driver compiles all of them. From 1 024 instructions (256 for the format helpers) these stay [noinline] with scalar parameters, which SM 6.6 DXIL keeps as calls. Heap windows keep their single access. The EXEC bit test stays inline: as a call it made the driver slower. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@SamG-Coder the device suspension I reported on #1867 (#1867 (comment)) is still there on #1901 at
Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this comment. |
|
Synthetic isolation for the outlined switch-window accessors on an RTX 3090, exact #1901 head I padded the existing Tested — native Windows 10 19045, RTX 3090 driver 591.74, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, DXC 1.8.2502.11;
The added test lines on #1901's - let p = prog(&refs);
+ let mut p = encode("S_NOP", "ENC_SOPP", &[], None).unwrap().repeat(1024);
+ p.extend(prog(&refs));
let one = translate(&p, &Options::default()).unwrap();
@@
- assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap, "heap windows: no switch over windows");
+ assert_eq!(t.hlsl.contains("switch (xcl_w)") || t.hlsl.contains("switch (window)"), !heap, "heap windows: no switch over windows");
+ let outlined_atomic = t.hlsl.contains("[noinline] void xcl_mInterlockedAdd(");
+ assert_eq!(outlined_atomic, !heap, "large switch-form program should outline the atomic accessor");
+ println!("outlined atomic: {outlined_atomic}");Not tested: AMD, the failing retail shader, full suite, retail smoke, cold compilation time or memory. These passes show this small outlined program works on the 3090; they do not explain or dismiss the RX 9070 device suspension. I corrected and reran an initial diagnostic that looked for the wrong ( AI use: Codex desktop (GPT-6) prepared the synthetic test overlay, ran the paired Windows checks and drafted this report from retained logs. |
Melow-code
left a comment
There was a problem hiding this comment.
The 2-6x PSO creation speedup is significant. The RDNA4 device suspend on outlined switch-form accessors is the blocker — the driver may not handle cross-function LDS access correctly with noinline. Worth checking if the suspend reproduces with only the LDS helpers outlined, leaving the typed-format ones inlined.
|
Run time on an RTX 3090 (32-lane waves, split wave64): the programs build faster but run 1.7 – 2.7× slower, because the split-wave64 exchange helpers are now calls. With those inline again the run time is back to the base's. The description measures DXC and pipeline creation. This adds the GPU time of the dispatches themselves, same trees. Setup
Results
Which helper costs the time (program A,
So on 32-lane GPUs the trade here is about half the pipeline-creation time once, against about twice the GPU time of every dispatch of a program that loops. A threshold on the number of exchange sites inside loops, or keeping the exchange inline and outlining only the accessors and the format helpers, would keep most of the build gain; I have not measured those variants. One more thing for the cache: the typed-format code at the top of every program is rewritten for all sizes, so the HLSL of every compute program of the pack changes, including the quarter of them under 256 instructions. A translated-shader cache is rebuilt entirely. Not tested
AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the port of the harness and the measurements) ran this and drafted the report. |
|
RDNA3 data point for #1901 at Unlike RDNA4's ResultsPR unit test (
Three retail compute records (
DXIL validation & isolation finding
Tested
Not tested
AI use: Antigravity (Gemini 4 Neon) built both trees, ran the measurements and wrote this comment. |
|
RDNA3 run of this PR, since the numbers in the description are NVIDIA's: on an RX 7800 XT the device is removed within the first 2–3 s, twice, with this commit; Setup: AMD Radeon RX 7800 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17, release, retail title,
So the driver takes the outlined DXIL (no PSO is refused) and the GPU faults at address 0 on the first work that runs it; I cannot tell from here which program. Not tested: the suite on this tree; AI use: Claude Code (Claude Fable 5.1) built the trees, read the logs and wrote this; the runs were mine. |
…ders) Integrates upstream PR xcl-dev#1901 (5064119) so large compute shaders call shared [noinline] helpers instead of inlining them, reducing DXIL size and compile time while preserving xcl-dev#1414's zero-for-missing-channel rule in fmt_comp.
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Run time on Blackwell (RTX 5080, 32-lane waves, split wave64): on these synthetic programs the GPU time stays within 5 % of the base or drops, even with exchanges inside a loop. Driver builds are 6–28× faster in the switch form, and every output matches the base bit for bit. This adds a second NVIDIA generation next to @CharlyRien's RTX 3090 numbers. It doesn't reproduce his slowdown, so the cost may depend on the GPU generation or on his program's shape (50 ballots and 75 lane reads in loops, real inputs), which these programs don't have. Setup: RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2609.5, release. Trees: this head
For each program, in this order:
Trees interleaved per program. All programs pass the 1,024-instruction threshold: the PR's HLSL has 42
So on this GPU the trade that @CharlyRien measured on Ampere, half the build time against double the run time, isn't visible for these shapes. Whether his program A behaves the same on Blackwell is the open question. A run of that captured dispatch on an RTX 40 or 50 would settle whether a threshold on exchange sites in loops is needed per generation or everywhere. Not tested: retail programs, real inputs (these use zero-filled memory and own-slot accesses, so their memory traffic is lighter than a real program's), the coherent window or AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it on the machine above and wrote this report. I checked the numbers against the logs. |
Part of #1269. Replaces draft #1867, which combined this with other changes. Large compute programs call one shared copy of the memory-window accessors, the split-wave64 exchange and the typed-format conversions instead of having DXC inline them at every use. On six retail compute programs of 1.3 – 6.7 MB HLSL, pipeline creation is 2.1 – 5.9× faster with the default memory windows and 1.13 – 3.7× faster with
XCL_HEAP_WINDOWS=1, and the DXIL 4 – 28 % smaller (tables below).What is in it
Em::finishtakes the program's instruction count. From 1 024 instructions (compute and kernel mode), the memory-window accessors and the split-wave64 exchange functions are[noinline], with scalar parameters andoutresults, which SM 6.6 DXIL keeps as calls. Vector loads and stores go through one scalar_sharedfunction per width.fmt_value,fmt_pack_shared,st_bytes_shared) are[noinline]in the same way.fmt_compis split so the conversion takes scalars;fmt_packandst_byteskeep their signatures as wrappers. The store logic is unchanged.XCL_HEAP_WINDOWS=1) keep their single access: only the switch form's accessors are outlined.lanebit) stays inline. As a[noinline]call it made the driver slower on every program measured (with heap windows, the 3.40 MB program: 5.83 s inline, 7.27 s as a call).gpu_large_compute_shares_wave_and_window_helperschecks that a small program stays inline, that a large one calls the shared accessors, that the outlined DXIL is smaller than the same source inlined, and that both memory windows and a vector load return the right values on the GPU.Measurements (
xcl shaders <pack> --measure-pso <record> --repeat 3: DXC, thenCreateComputePipelineStatewith the driver cache off;mainc4d37beagainst this PR on the same machine, one program at a time; a second pass agrees within 3 %)Default memory windows (switch form):
XCL_HEAP_WINDOWS=1:DXC is slower on one of the twelve (4.21 MB, default windows: +3 %).
Tested
cargo test --workspace -- --test-threads=4: 960 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, found and removed thelanebitslowdown by measuring each part on its own, ran the tests and measurements, and wrote this description.