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. |
|
RTX 3060 12 GB, a larger program than the six in the description (7.05 MB HLSL, 25,107 instructions): pipeline creation 1.26× faster with the default windows, 1.04× with heap windows. Head Setup: NVIDIA GeForce RTX 3060 12 GB (driver 617.42, 32-lane waves, split wave64), Intel i5-14600K, Windows 11 build 26300, rustc 1.94.0, DXC 1.8.2502.11 from the Windows SDK (
The two runs of each PSO measurement agreed within 1 %. Not tested: run time of the dispatches (see @CharlyRien's 3090 numbers), AMD, a title run with this change, DXC 1.9. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Ada (RTX 4090) data point: the build win is bigger on the title's own programs than the description shows, and the run-time cost @CharlyRien measured on Ampere reproduces here — but only in the split-wave64 exchange helpers. A knob that keeps those inline keeps both, and I measured it. The PR does not merge into current Cold driver compile, the title's own compute outliers, HLSL path (
Driver time 1.63 – 3.84× faster across the four, with the biggest factor on the two largest. The asymmetry is the point: on These are not harness-only numbers: a 180 s run of the title on this rig with the implicit caches cold logs its own cold compute compiles at the same sizes and the same order of magnitude — The same four records measured with XCL's own tool,
Same DXIL bytes as the harness table above, bigger ratios — this is the pairing I would keep if only one were quoted, and it is a command a reviewer can run. The same tool with What the class looks like. Exporting the HLSL of the ten largest compute programs of this title that have no driver blob (15 011 KB down to 4 461 KB of HLSL) and counting helper call sites: eight of the ten have no split-wave64 exchange sites at all ( Why this class matters right now: #2120 reroutes compute programs whose HLSL exceeds 8 MiB, which is two records of this title's set ( GPU time of the same program, both trees (a 32 768-iteration loop, 2^18 threads, timestamps, median of 9, 1 024
So on Ada the window-accessor and format outlining is free to slightly positive, and the cost is in The cost this PR pays on a title that is already warm. The typed-format prelude is rewritten for every compute program (the The variant @CharlyRien suggested and nobody has measured: keep the split-wave64 exchange helpers inline and outline only the window accessors and the format conversions. One line in
So the inline form gives back the whole run-time cost — 1.015× On the one program of the ten that does read lanes the switch is not free, and it goes the other way.
So on the program that has the exchange sites, keeping the exchange inline gives the outlining back and then some: 21 % more DXIL and 14 – 24 % more driver time than the outlined form, 7 % more DXIL and 8 % more driver time than Measurement conditions worth stating: each pair was measured under the same process layout (the Regression run — A second pair of the same two trees, run before that one with the shared cache each tree had already warmed (1530 frames / 35 647 MB on What the logs do separate is the per-pipeline cost. In the warm pair, Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the measurements and wrote this; the runs are ours. |
|
I tested the >8 MiB outlier
All four runs reached the time limit without writing DXIL. In a separate control on #2120 AI use — OpenAI Codex (GPT-6.2 Sol) ran the tests and wrote this report. |
|
Test report: cold driver build time on a GTX 1650 (Turing, 4 GB), four of the title's largest compute programs. The PR's head against its own base, same machine, one program at a time. Tested
The DXIL is 18 – 26 % smaller on all four, DXC is faster on all four, and the driver builds the two largest in about a quarter of the time. That is the same direction as the PR's own tables and @brandostrong's numbers on an RTX 4090, on a card and driver neither has used. Not tested
AI use
|
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.