Repository navigation
Conversation
With heap windows (XCL_HEAP_WINDOWS=1), every read of the direct DXIL translator was a branch on `w < windows` (and the lane guard) around the heap lookup, and a phi per value at the join. On NVIDIA the driver's compile time follows the block count, and the reads of a large compute program make thousands of blocks. XCL_HEAP_FLAT=1 (with heap windows; new flag HEAP_FLAT in the windows count, so the caches keep the forms apart) reads in one path: the lane loads from window `w`, or window 0 when `w` is outside the windows or the lane is not active, and those lanes take 0, as the guarded form and the switch over root UAVs give. All with_mem_i32s callers only load (raw, SMEM, unaligned, format and BVH node reads). Stores and atomics keep their branch. Compute stages only: vertex and pixel shaders are unchanged. The HLSL path ignores the flag. The one-path form is the idea xcl-dev#1695 brings to the HLSL heap form. Measured cold on an RTX 5070 Ti (610.74), shader cache disabled, 4 windows, split wave64, five large compute programs: the driver took 6.7-60.7 s with the switch over root UAVs and 3.4-28.6 s with this form; its native code was 11-25 % smaller. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Tested commit Environment
Results
|
717fec5 to
0f04514
Compare
Port #2427 (XCL_HEAP_FLAT=1, HEAP_FLAT=0x200) for compute stages using XCL_HEAP_WINDOWS=1 so every heap-window read in Lw::with_mem_i32s() lowers to a single clamped ResourceDescriptorHeap[NonUniformResourceIndex(4 + w)] load and select instead of a per-read branch, merge block, and PHI set. Large compute shaders (including 95cc13288a27a96e with 1,316 heap-window reads and a74706fb8f96ade9 with 1,012 reads) eliminate thousands of basic blocks and PHIs on AMD RDNA4 as well as NVIDIA; heap_raw_buffer_uav already sets NonUniformResourceIndex=true and out-of-range/inactive lanes read harmlessly from window 0 and select 0. Includes gpu_heap_flat_reads_match_the_switch_form regression test. Assisted-by: Antigravity (Gemini 4 Neon High)
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
Part of #2088.
Draft: the regression pair is still to run. I'll fill in Regression run and mark this ready when it finishes.
With heap memory windows (
XCL_HEAP_WINDOWS=1), every read in a direct-DXIL compute program is a branch onw < windows(and the lane guard) around the heap lookup, with a phi per value where the paths join. NVIDIA's compile time follows the block count, not the byte count, and the reads in a large compute program make thousands of blocks.This PR adds a one-path form behind
XCL_HEAP_FLAT=1. It applies only with heap windows on:w's heap view. It uses window 0 instead whenwis outside the windows or the lane is inactive, and those lanes then take 0. The guarded form and the switch over root UAVs give the same results.HEAP_FLATflag is in the windows count, so the caches keep the forms apart.with_mem_i32scallers). Stores and atomics keep their branch. Vertex, pixel, mesh and GS programs and the HLSL path are unchanged.Cold pipeline builds, RTX 5070 Ti (NVIDIA 610.74), shader cache disabled (
ShaderCacheControl), 4 windows, split wave64. Five large compute programs from title: ea3b5e4d, one run each, all in one job:GetCachedBlob) is 11–25 % smaller. That is less shader code for the driver to hold (cf. NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403's device removal with a shader-code heap above 512 MB), but I have not checked whether it is enough there.What is in it
gpu/dxil/lower_mem.rs: the one-path read inwith_mem_i32s.gpu/dxil/kernel.rs,gpu/dxil/lower.rs:heap_flatinLw, set for compute stages withHEAP_FLATand heap windows.gpu/recomp/mod.rs,gpu/recomp/pso.rs: theHEAP_FLATflag andXCL_HEAP_FLAT=1. The HLSL path strips the flag the way it stripsHEAP_WINDOWS.gpu/recomp/tests.rs:gpu_heap_flat_reads_match_the_switch_form. It runs one program in all three forms (switch, guarded heap, flat heap) over a 4-window arena and compares SGPRs and VGPRs. The program has SMEM loads into window 2 and outside the UMA, ans_buffer_load_dwordx4from window 3, abuffer_loadfrom window 1, and per-laneglobal_loads spread over all four windows. Every eighth lane reads outside the UMA, lanes 0–32 are inactive (v_cmpx), and there is a SADDRglobal_load_dwordx2.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on717fec50: 1290 passed, 1 failed, 46 ignored.a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, also fails onmain68a284a5.window), default and withXCL_DIRECT_DXIL=1: 31 passed, 0 failed.gpu_heap_flat_reads_match_the_switch_formpasses in the suite run.Regression run
main68a284a5vs this head)Not tested
XCL_HEAP_FLAT=1.xcl shaders --precompilekeys this form only in the follow-up PR, which turns it on by default. WithXCL_HEAP_FLAT=1alone, precompiled entries are not found and the programs are translated at run time.AI use
🤖 Generated with Claude Code