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 |
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.