Recompiler: large compute programs share repeated code with DXC and the driver #1867
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!1867
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1867/head"
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?
@SamG-Coder on GitHub · 2026-11-24 22:08 UTC · original
SamG-Coder:recomp/shared-compute-code→main· +871 −85 · 5 files · 1 commits · closed without mergingPart 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.@HKEY-Funk-Machine on GitHub · 2026-11-24 22:48 UTC · original
@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.
CreateComputePipelineStatereturns0x887A0005within seconds, after the driver printsUnknown pointer operation encountered during ParseAddress. That includes a small program that builds in 6 s on the base commit.Tested
35a3980and its basec4d37be, release, each with one local-only change inmeasure_pso: this machine has no Windows Developer Mode, soShaderCacheControl(DISABLE)fails (0x887A002D). I made that a warning and instead ran every measurement under anxcl.execopied to a new name, which gives the AMD driver a cold cache.xcl shaders <pack>/shaders.rpf --measure-pso <hash> --repeat 1, one process per measurement, default 4 switch windows, process memory sampled every 2 s.c4d37be35a398062b584e061c05fc5(197 280 B DXIL on the base)0x887A0005(device suspended) afterUnknown pointer operation encountered during ParseAddress56c0cd3b82a00c6e0x8007000Eafter ~4 min, peak 105 GB private0x887A0005, same message, within 4 s95cc13288a27a96e0x8007000Eafter ~5.5 min, peak 105 GB private0x887A0005, same message, within ~40 sThe
35a3980result on56c0cd3b82a00c6erepeated in a second process. The message reads like the AMD compiler meeting a pointer form in the DXIL that it can't parse. My guess is the shared code's calls or memory accessors, but I haven't checked the DXIL.Not tested
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the measurements and wrote this comment.
@SamG-Coder on GitHub · 2026-11-24 22:48 UTC · original
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
[noinline]EXEC bit test (lanebit) made the driver slower on every program measured, so #1901 leaves it inline. Without it, the shared helpers are faster than in this draft on all six programs, and also withXCL_HEAP_WINDOWS=1(numbers in #1901). The other changes here (buffer bounds by the V# out-of-range mode, ADD_TID, inactive-lane loads, single-channel typed loads, unaligned typed stores, the mesh pass-through vertex budget, and outlining repeated branch arms) will follow as their own PRs.@DavidM1911 on GitHub · 2026-11-25 01:38 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Pull request closed