Repository navigation
Direct DXIL: size a compute program's LDS block from its LDS_SIZE - #2158
grahamster2 wants to merge 2 commits into
Conversation
Every translated program that touches LDS declared `groupshared uint xcl_lds[8192]`, the D3D12 limit of 32 KB, whatever the console program allocated. COMPUTE_PGM_RSRC2.LDS_SIZE (bits 15..23, 512-byte units) is in the FSSM descriptor already: the HLSL block of a compute program is now the next power of two that holds it and the runtime words kept at the top (the split-wave64 exchange, the safe barrier's words, the 2-D thread hand-out), with accesses masked by `XCL_LDS_MASK`. LDS_SIZE 0 and the other stages keep 32 KB. 32 KB per group lets an NVIDIA Ampere SM hold 3 groups, 6 warps of a 64-thread group, so the split form's meets have nothing to hide behind. On an RTX 3080, a loop with an LDS store and load and one exchange per iteration (2^18 threads x 8192 iterations, 64-thread groups) takes 41.9 ms in the split form with the 32 KB block and 14.0 ms with a 1K-word one; native wave32 10.0 -> 4.2 ms. The retail title's 84 LDS-using split programs allocate 512 B to 16.9 KB (34 of them 512 B). Assisted-by: Claude Code (Claude Opus 5.5)
The direct DXIL backend (XCL_DIRECT_DXIL) declared its `xcl_lds` with 8192 words for every program, as the HLSL kernel did. It now sizes it by the same rule: a compute program's COMPUTE_PGM_RSRC2.LDS_SIZE plus the same reserved top words, rounded up to a power of two (the exchange slot size each backend picks can still differ for a program), with the exchange, `XCL_WT` and the address mask moved to that block's top. LDS_SIZE 0 and the other stages keep 8192 words. The LDS ring GPU test runs the direct translation too (the kernels `direct_or` runs), and checks that its block has the HLSL block's size. `bench_compute_lds_block` (ignored, next to `bench_split_wave64`) times a loop with an LDS store and load and an exchange per iteration with both blocks. RTX 3080, 2^18 threads x 8192 iterations, 64-thread groups, 32 KB block -> LDS_SIZE block: HLSL: wave32 7.8 -> 3.5 ms, split wave64 39.4 -> 12.4 ms direct: wave32 10.3 -> 2.3 ms, split wave64 16.5 -> 5.5 ms Assisted-by: Claude Code (Claude Opus 5.5)
TestedPR #2158, stacked on #2146, was open at STOR-WINLAB ran Windows 11 Enterprise Evaluation 26200.9974 on a Ryzen 7 3800X with an Intel Arc A770, driver Cargo used the unoptimized test profile with cargo test --locked -p xcl --lib -j 2 --no-run --message-format=json
$fixtureExe = 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = Join-Path $env:LOCALAPPDATA 'XclTooling/dxc-1.9.2609/bin/x64'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
$env:XCL_DIRECT_DXIL = '1'
& $fixtureExe --exact gpu::recomp::tests::gpu_compute_lds_ring_in_a_block_of_the_programs_size --nocapture --test-threads=1
$env:XCL_DIRECT_DXIL = '0'
& $fixtureExe --exact gpu::recomp::tests::gpu_compute_lds_ring_in_a_block_of_the_programs_size --nocapture --test-threads=1
}
The fixture explicitly compiles HLSL through DXC and translates direct DXIL under both environment settings. The two invocations therefore repeat the same assertions. The existing STOR-WINLAB A770 capability log records a D3D12 wave-lane range of 8 to 32, so the fixture exercised wave32 and split wave64 for 64×1×1, 256×1×1 and 8×8×1 thread groups. For each of the six configurations, the fixture checked the direct DXIL The executable SHA-256 was Combined: 2 passed, 0 failed, 0 ignored, 0 skipped. Not testedNative wave64, other adapters, other exchange layouts, negative cases, runtime backend selection, broader test suites, benchmarks, retail titles and smoke/regression runs. AI useT3 Code / Codex ( |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested:
Head |
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
…LDS_SIZE Merges xcl-dev#2146 (fork/lds-size-from-rsrc2, 52577f9: the HLSL path declares xcl_lds from COMPUTE_PGM_RSRC2.LDS_SIZE plus the runtime words at its top) and xcl-dev#2158 (fork/lds-size-direct-dxil, 55d06c1: the direct DXIL translator sizes its block the same way). Conflicts: - dxil/kernel.rs: HEAD calls setup_storage after the partner is chosen; kept that order and passed the compute program's lds_bytes to it. - recomp/tests.rs: kept HEAD's tests and added the PRs' LDS tests after gpu_compute_tg_size_counts_a_partial_last_wave. Follow-ups for HEAD: - CsInterface literals added since the PR base get lds_bytes: 0. - gpu_compute_lds_ring_in_a_block_of_the_programs_size: the direct translator now refuses an s_barrier in a group of several hardware waves (safe barrier on by default), so that refusal skips the direct form, and a 32-thread wave32 case keeps direct DXIL covered.
|
Independent desktop NVIDIA verification of PR #2158 at head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib compute_lds_block_takes_the_programs_lds_size -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1126 filtered out × 3 (0.00s × 3, 0 skipped) |
cargo test --release -p xcl --lib gpu_compute_lds_ring_in_a_block_of_the_programs_size -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1126 filtered out × 3 (0.60s, 0.53s, 0.54s, 0 skipped; live RTX 4060 execution across HLSL and direct-DXIL backends) |
cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4 (3 consecutive runs) |
122 passed; 0 failed; 3 ignored; 1002 filtered out × 3 (4.08s, 4.19s, 4.35s, 0 skipped) |
cargo build --release -p xcl |
Clean build (1m 28s, exit 0, 0 new warnings) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact parent & merge-base (cbc296ab65a2661a61e3e2da109134bcd5319f60, cached baseline on the same machine):
xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1572 (PresentX 1572)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14509 MB
PR #2158 (55d06c1e02831b09a931d383b7f6ea4bb6793b9e):
xcl-smoke v1
commit: 55d06c1e02831b09a931d383b7f6ea4bb6793b9e
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1569 (PresentX 1569)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14521 MB
Limits of coverage
- Sizing direct-DXIL compute
xcl_ldsblocks fromCOMPUTE_PGM_RSRC2.LDS_SIZEplus top-reserved runtime words (matching stacked HLSL PR Recompiler: size a compute program's LDS block from its LDS_SIZE #2146) was directly verified on desktop RTX 4060 viacompute_lds_block_takes_the_programs_lds_size(3/3),gpu_compute_lds_ring_in_a_block_of_the_programs_size(3/3, live GPU execution), andgpu::dxil::(122/122× 3). - The ignored
bench_compute_lds_blockmicrobenchmark was not run; the 60 s retail smoke confirms zero runtime regression ontitle: 29640639(single-run frame/commit delta vs. cached parent reflects normal startup variance, not this PR).
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
`xcl_lds` was always 32 KB. Its size now follows what the program allocates (RSRC2 LDS_SIZE, 512-byte granules, `CsInterface::lds_bytes`) plus the words XCL keeps above it (the split form's exchange, the safe barrier's state), in both the direct DXIL path and HLSL. Groups that ask for little LDS then fit many to a GPU core: a retail title's busiest program allocates 512 B, and 32 KB let ~3 of its groups onto an NVIDIA SM. Measured in-run A/B (run 186, RTX 4070 Ti under Wine): that program -34 % GPU time per call (60.8 -> 40.2 ms over 30 windows). `XCL_LDS_FIT=0`: 32 KB as before. GPU test included; the test literals get `lds_bytes: 0` (size not known: 32 KB). Upstream PRs xcl-dev#2146 and xcl-dev#2158 (grahamster2, open) size the LDS block from LDS_SIZE too; this is our own form, made before we saw them. Platform: all Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A retail measurement of the same idea, not of this PR's head: our tree sizes the LDS block from LDS_SIZE the same way (direct DXIL and HLSL; our commit), and we compared it with the 32 KB block inside one run of a retail title's world. Setup: RTX 4070 Ti 12 GB (32-lane waves only), NVIDIA 620.73.04, Linux + Proton Experimental (Wine 11.0) + vkd3d-proton 3.1, Result (30 windows of 2 s)
Written with Claude Code (Claude Opus 5.5) from our run records. |
…idia-dev refuses the direct form `gpu_compute_lds_ring_in_a_block_of_the_programs_size` translates its ring program with the direct DXIL translator too and unwrapped the result. On nvidia-dev the direct path refuses an s_barrier in a group of several hardware waves (`barrier_waves`), as on this wave32-only card for its larger groups: such a program runs as HLSL, so the test now checks the HLSL form alone then. With it, the LDS tests pass on an RTX 4070 Ti under Wine (33 passed, 0 failed), the GPU dispatches of the fitted blocks included. Platform: carried Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream PRs xcl-dev#2146 and xcl-dev#2158 by grahamster2 (size a compute program's LDS block from its LDS_SIZE, HLSL and direct DXIL; heads 52577f9 / 55d06c1) do what our 50876a8 did, tested on many GPUs. Their form differs: the block is the next power of two that holds the program's LDS and the runtime words, and accesses are masked with it (`XCL_LDS_MASK`). They are carried in place of ours: our `XCL_LDS_FIT` switch, our sizing in `emit::lds_words`, `Lw::setup_storage` and lower_mem, and our GPU test are taken out; their `lds_words`, `lds_decl`, `setup_storage(.., lds_bytes)` and tests are in. Their tests are appended at the end of recomp/tests.rs (nvidia-dev's tests sit where they added them on main). Ours on top: a one-pass mesh shader (`Options::mesh_one`, `Entry::MeshOnePass`) is sized from its own LDS as well, through their functions, and is refused when that is over 28 KB (a mesh shader's limit). Tested here (Wine, no usable GPU at the time): compute_lds_block_takes_the_ programs_lds_size and the one-pass tests pass; the GPU tests (their gpu_compute_lds_ring_in_a_block_of_the_programs_size among them) are not run yet. Kept on branch linux-lds-2146 until they are. Platform: carried Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idia-dev refuses the direct form `gpu_compute_lds_ring_in_a_block_of_the_programs_size` translates its ring program with the direct DXIL translator too and unwrapped the result. On nvidia-dev the direct path refuses an s_barrier in a group of several hardware waves (`barrier_waves`), as on this wave32-only card for its larger groups: such a program runs as HLSL, so the test now checks the HLSL form alone then. With it, the LDS tests pass on an RTX 4070 Ti under Wine (33 passed, 0 failed), the GPU dispatches of the fitted blocks included. Platform: carried Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #2146; only the last commit (55d06c1) belongs here, please review that one.
The direct DXIL backend (
XCL_DIRECT_DXIL) declares itsxcl_ldswith 8192 words for every program, as the HLSL kernel did before #2146. This sizes it by the same rule: a compute program'sCOMPUTE_PGM_RSRC2.LDS_SIZEplus the same reserved top words, rounded up to a power of two. The exchange words,XCL_WTand the address mask inlds_indexmove to the new block's top. LDS_SIZE 0 and the other stages keep 8192 words.Part of #675.
What is in it
Lw::lds_words, set insetup_storagefrom the entry'slds_bytes(gpu/dxil/lanes.rs,kernel.rs,lower.rs), and used by the mask inlds_index(lower_mem.rs).gpu_compute_lds_ring_in_a_block_of_the_programs_sizealso runs the direct translation. It covers the kernelsdirect_orruns (wave32, and wave64 in the split form) and checks that@xcl_ldshas the HLSL block's size. With the old 8192-word block, the test fails.bench_compute_lds_block(ignored, next tobench_split_wave64): the 32 KB block against the LDS_SIZE block, in a loop with an LDS store and load and an exchange per iteration.Tested
cargo test --workspace -- --test-threads=4at 55d06c1: 1156 passed, 0 failed, 47 ignored. The SKIPPED tests are the same as in Recompiler: size a compute program's LDS block from its LDS_SIZE #2146 (no wave64).XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- --test-threads=4: 1099 passed, 1 failed, 27 ignored. The failure,gpu_image_get_resinfo_1d_array, also fails withXCL_DIRECT_DXIL=1at 52577f9, so it is not from this change.bench_compute_lds_block, 2^18 threads x 8192 iterations, 64-thread groups, 32 KB block -> LDS_SIZE block:256-thread groups: 1.0x to 1.27x.
Regression run
Both runs with
XCL_DIRECT_DXIL=1(the path this changes).main (cbc296a):
this PR (55d06c1):
Not tested
AI use
direct_orruns, and to matching@xcl_ldsexactly.