Repository navigation
Conversation
235a71f to
7e1f8aa
Compare
7e1f8aa to
ccfd4c6
Compare
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
|
Thanks, @DavidM1911. I verified that the head at the time contains AI use Codex (gpt-6.2-sol) checked the Git refs and merge tree and drafted this reply. |
|
Update for the RTX 3060 Ti retest: AI use Codex (gpt-6.2-sol) checked the merge trees and drafted this update. |
ccfd4c6 to
9c26337
Compare
|
@DavidM1911 the retest head was stacked on #1448 AI use Codex (gpt-6.2-sol) rebased, validated, and drafted this update. |
…nslate No behaviour change: the decoding, block leaders and emitter set-up at the start of translate() move into prepare(), so a second form of the program (the compact form) is built from exactly the same decoded program and emitter state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DXC inlines every helper of a cs_6_x target, so a retail compute shader with thousands of equal blocks (ActivateProbes 56c0cd3b82a00c6e: 88,863 instructions, 3,281 buffer_load_format_x) becomes 29.75 MB of DXIL that the driver needs minutes for. translate_compact() cuts the program into blocks (leaders, plus every instruction whose HLSL exceeds 600 B on its own), emits each instruction with emit::Em as translate() does, temporaries numbered from t1 per instruction, and shares equal block texts as cases of one dispatch loop. Branches go to a block at an offset from their own (part of the text), so a static table only holds every block's case, packed. The table is capped at 8,192 words: on an RTX 5070 Ti, CreateComputePipelineState of this program's compact form with an added 12,288-word static array succeeded; with 15,360 words it failed with E_OUTOFMEMORY. Back edges spend the loop budget (65,536 per lane); once it is spent the program ends, where the structured form leaves the loop and runs what follows. compact_wanted() picks programs of 20,000+ instructions whose distinct blocks hold under 30 % of them. Not called yet. Measured on 56c0cd3b82a00c6e (4 memory windows, split wave64, RTX 5070 Ti, a local merge, 31be310): 723,453 B HLSL, DXIL 1,053,264 B in 12.5 s, CreateComputePipelineState 9.7 s from a new exe with no cached blob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests_compact translates each program with translate and with compact::translate_compact and runs both on the same inputs. The kernel programs assert byte-identical SGPRs, SCC, VGPRs of all lanes, exports and the split form's upper-half SGPRs, plus flat memory or the first 64 KiB of each memory window; the compute dispatch compares memory. Programs: nested execz regions, divergent and scalar backward loops, one block repeated at five addresses, far jumps (s_getpc_b64, add or sub, s_setpc_b64) forward and backward, v_mul_lo_u32, buffer_load_format_x in twelve formats and repeated as a block of its own, a cross-lane block (ballot, readfirstlane, readlane) repeated under four exec masks, s_endpgm before the last block, a loop through four memory windows with loads, stores and per-lane atomics, a compute dispatch, and 200 forward jumps that xcl-dev#1307's bound sends to pc blocks in translate (gpu_compact_against_the_pc_block_fallback). The kernel programs run in each form forms() lists for the adapter (wave64 split or native, wave32; with branches also unstructured), and in the wave64 forms with mem_windows: 4; the compute dispatch runs in wave64 (split where the adapter needs it) and wave32. Every program here except one has a branch, and the tests assert that translate_compact gives it the compact form: they read its dispatch loop back from the HLSL. translate_compact keeps translate's form for a program without branches, so the two straight-line programs start with a branch to the next instruction. For the repeated blocks, the exchange block, the buffer loads, the window loop, the far jumps and s_endpgm they also assert the shape: fewer cases than blocks, one case for the four copies of the exchange block and one for the block after the load, the load a case of its own, the far jumps' block offsets, two program ends before the last block. The exception is the memory-window program of gpu_memory_windows_above_4_gib (no branch): it gets translate's form from both, so its test compares translate with itself; the window loop runs the compact form through the windows. The atomics in the memory-window programs add to a dword per lane. On an RTX 5070 Ti (split wave64, 4 windows), with all 64 lanes adding to one dword, 40 runs of the same DXIL returned two different lane 0 values (5 and 35 runs): the split halves' atomics land in either order. gpu_compact_sample_big_cs (XCL_SAMPLE_BIG_CS=<code file>) runs a retail program both ways. A program translate_compact refuses (e.g. its table limit) is SKIPPED; when the driver cannot create translate's pipeline (e.g. E_OUTOFMEMORY), the A/B comparison is SKIPPED and the compact form must still compile and run. Needs the compact backend (compact.rs and `pub mod compact`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PACT_CS) The switch XCL_COMPACT_CS: unset / auto = the programs compact_wanted picks, 0 = none, 1 = every compute program; another value logs a warning and acts as auto. `translate_routed` gives a compute program to translate_compact where the switch says so and uses `translate` when that returns an error or an incomplete translation. The PSO path (console_translation, both FSPX and FSSM), `xcl shaders` statistics and precompile, and the shader dump's recompile use it. The on-disk translation cache names an entry of a program routed to the compact backend `..._c.bin`, so a compact and a normal translation of one program never share a file; the file name of a normal entry is unchanged. compact.rs is added to the translator sources that identify compatible cache entries (this commit changes that identity, so existing entries are translated again once). One INFO line per compute program routed to the compact backend, the first time: instructions and HLSL bytes, or why it fell back. When dxc::compile_cached fails on a compute program's compact-form HLSL, the program is compiled in the normal form (or taken from the normal form's translation-cache entry when that is on disk), and the result is kept under the normal entry, never the `_c` one; one WARN line is logged before that. A cached-only attempt is not retried: its DXIL is not refused, only not made yet. A refusal is not remembered between runs. A driver (CreateComputePipelineState) rejection of a compact pipeline is not retried in the normal form. With XCL_DIRECT_DXIL (xcl-dev#1426) on, a compute program XCL_COMPACT_CS routes to the compact form goes to the HLSL path's compact form first, not to the direct translator; if DXC refuses that HLSL, the retry in the normal form goes to the direct translator first, then to translate. Every other compute program goes to the direct translator as before, and to the HLSL path when that falls back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The compact form keyed a block's case on its text with the branch offset in it, so blocks with the same code but different targets were separate cases. ActivateRays (95cc13288a27a96e) has 19,949 blocks and got 11,909 cases. Its table was over MAX_TABLE_WORDS, so the program fell back to the normal form. A case is now keyed on the block's code and branch condition, and the target is data. A case whose blocks all jump by one offset keeps `xcl_b +/- K`. Otherwise it takes the offset most of its blocks jump by and sets each other block's target with `xcl_t = select(xcl_b == k, target, xcl_t)`. ActivateRays has 2,516 cases. At 12 bits, the usual packing (two cases to a word) still needs 9,975 words, so a table over MAX_TABLE_WORDS is now packed across words: bits from bit `xcl_b * bits`, two reads, one word of padding. ActivateRays fits in 7,482 words. A case evaluates at most MAX_SELECTS (32) of those selects. Past that, the list is split by `[branch] if (xcl_b < pivot)` until each leaf has at most 32. `xcl_b` is wave-uniform, so the branch is too. Without the bound, a case that 1,799 blocks share runs 1,799 selects on every visit: on milesah3ad's probe (a8eebfd, 3,600 rounds, targets that differ per copy) a dispatch took 13.5 ms against 9.8 ms on the parent, and 10.4 ms with the bound. DXC keeps the branches (92 conditional branches in the DXIL against 36). Cases with 32 or fewer differing targets emit the same text as before. Which programs take the compact form does change: ActivateRays had 11,909 cases and a 9,975-word table, so it fell back to the normal form, and it now takes the compact form through the across-word table. ActivateProbes and ActivateProbesTarget were compact before and keep the usual packing. Measured on an RTX 4090 (driver 617.42), release, a fresh DXIL cache and a new exe path per run (so the driver's cache missed): - ActivateRays: DXC 20-24 s, 2.89 MB DXIL. The driver made it in 175, 190, 215 and 233 s (peak private 8.1 GB). The same build without the bound: 2.85 MB, 162, 162, 164 and 201 s, interleaved with those runs. K = 64 took 200-216 s, no better. - ActivateProbes: 751 cases (906 before), 0.94 MB DXIL, driver 12.6 s. - ActivateProbesTarget: 698 cases (851 before), 0.85 MB DXIL, driver 9.9 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013qV4hiM5Sx9hBkPpgAarKX
|
@t4l03 heads-up: #1448 has a new head, AI use: Claude Code with Claude Opus 5.5. |
Factor up to two decoded literal values out of repeated compact bodies. Keep lookup records sorted by block and count their storage and the dispatch table against the existing word limit. Retain standard compact routing and exercise the opt-in API against the standard translator on the GPU. Prior experiment: a local HLSL prototype written with GLM-5.3 motivated this independent Rust implementation. Assisted-by: Codex (gpt-6.2-sol)
Treat the exact low dword of S_GETPC_B64 as an eligible runtime parameter. Test distinct PCs in two shared blocks against the standard translator, including the first block's saved PC and the final pair. Assisted-by: Codex (gpt-6.2-sol)
Route eligible compute shaders through immediate sharing when explicitly requested and keep the translated cache separate from the normal and compact forms. Preserve standard compact fallback on translation errors. Assisted-by: Codex (gpt-6.2-sol)
9c26337 to
2f9d88f
Compare
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
2f9d88f to
b391e9c
Compare
Stacked on #1448 (through #1315 and #1316). Only the three commits after
57d7574belong to this PR.Part of #1269. Compact compute shaders can have repeated bodies with different scalar literals or embedded program-counter values. With
XCL_COMPACT_IMMEDIATES=1, eligible bodies can share a case while preserving their original operands and branch targets.What is in it
Tested
Windows 11 build 26300, Ryzen 7 7800X3D, RTX 4070 Ti driver 617.14, integrated Radeon driver 32.0.21042.62, Rust 1.100.0, DXC 1.9.2609.5.
cargo test --workspace --locked --offline -j 4 --no-fail-fast -- --test-threads=4 --show-outputon the RTX 4070 Ti, debug: Cargo reported 988 passed, 0 failed, 42 ignored. The harness logged 24 skipped tests or subcases: 19 without native wave64, three per-lane opcode refusals, one with heap windows unavailable, and one PSO measurement requiring Windows Developer Mode.cargo test --locked --offline -p xcl --lib -j 4 gpu_compact -- --nocaptureon the integrated Radeon: 21 passed, 0 failed, 0 ignored, zero skips. This includes GPU readback comparisons for operand sharing and the upstream many-target case.Before the metadata-only rewrite, the release CLI exported and precompiled ActivateRays in both modes with compact compute, Direct DXIL and four descriptor-heap windows enabled (
--split 0). Both selected compact HLSL and produced separate_ci.binand_c.binentries in the same cache. The case count fell from 2,516 to 2,281; the 7,482-word block table plus the 708-word literal table stayed under the 8,192-word limit. The longest target-select leaf was 32 in both forms, preserving Recompiler: compact cases share code whose branch targets differ #1448's bound.Earlier standalone
ActivateRaysPSO from the first immediate-sharing revision on this 4070 Ti with Recompiler: memory windows from the descriptor heap (no per-access switch) #680's heap accessors: 64.76 / 63.26 s and 3.509 / 3.492 GiB. The matching Recompiler: compact cases share code whose branch targets differ #1448 heap control took 81.49 / 78.11 s and 4.340 / 4.338 GiB. The switch-window experiment hit the 6 GiB process cap. Separate XCL caches, NVIDIA global DXCache enabled.Independent RTX 4090 (617.42) testing completed both forms on the first immediate-sharing revision with Recompiler: memory windows from the descriptor heap (no per-access switch) #680 applied locally. Switch windows used 6.81 GB versus about 8.2 GB in the earlier control. The 194.6 s result was inside the earlier range. The heap arm used 3.55 GB and took 113.5 s, one run with historical controls. Report.
Regression run
scripts/smoke.ps1 -Game <title folder> -Seconds 60, release, default routing.main:
this PR:
Not tested
AI use
Codex (gpt-6.2-sol) wrote the Rust implementation and tests, rebased onto 57d7574, ran validation, and drafted this report. GLM-5.3 wrote a separate local HLSL research prototype that motivated this implementation. That prototype and its generated shader artifacts are outside this PR.