Recompiler: preserve a split candidate when direct compact lowering selects a whole PSO #2745

Open
opened 2026-11-26 11:14:36 +00:00 by github-bot · 1 comment
Owner

@⁠KOLESNiii on GitHub · 2026-11-26 09:47 UTC · original

Part of #2088 and #2508. Related to #2741, #2301 and #2080.

What happens on main

The direct translator selects a compact or ordinary lowering before it asks the dispatch splitter to plan pieces. The compact emitter keeps the current and next block indices in local alloca slots, and uses the same scheme for loop budget and guest register state. XCL's optimizer leaves the live dispatch locals in the module. Shader::split_compute rejects Alloca and ordinary local loads/stores before it reaches the CFG planner. As a result, choosing compact emission can turn a shader with a valid ordinary chain into a whole-only build. Native wave64, group shape, barriers and other split restrictions still apply. Form selection · Dispatch-local state · Optimize then split · Split restrictions

There is a second constraint even if the locals are promoted to SSA. Compact emission sends every class around the same dispatcher back edge. The resulting strongly connected component stays together in the partitioner, which refuses a component above four times its instruction target. In a standalone Linux probe using the extracted main optimizer and partitioner, the optimizer kept two live dispatch-index allocas. Separately, an artificial acyclic graph with 40 bodies produced 14 pieces at a test limit of 32, and the same body sizes behind a shared dispatcher back edge produced no plan at that limit. This checks the two mechanisms on synthetic IR. Retail eligibility and latency remain to be measured. Loop emission · Partitioner

Proposed work

  1. Test a synthetic guest compute program for which the ordinary form yields a valid chain and compact emission yields a valid whole PSO. Log the selected form and the actual split rejection condition. Respect forced compact, forced plain and split-disabled settings.
  2. On automatic selection, compare compact whole with the eligible ordinary chain on records observed before world entry. Keep the ordinary chain and optional whole fallback separately measurable. Reuse the existing descriptor and ABI checks, including #2741's proposed request identity for fallback capture. Measure native creation and peak commit, plus GPU time with the real dispatch slabs and barriers. Include the cost of a cold whole fallback wherever the caller can need one.
  3. If a combined representation is worth pursuing, try partitioning the ordinary CFG first and applying compact lowering only within selected legal regions. Promotion of compact scalar locals can be investigated independently. The work in itsSio/xcl#3 promotes static scratch arrays, which is adjacent to the local-memory check. A partitioning experiment also needs to preserve cross-piece liveness, barrier legality and dispatch semantics.

#2301's proposed size retry is a useful independent whole-form candidate. A comparison should track whether a smaller whole artifact replaces a useful chain, because the whole byte count alone omits the lost execution option. The end point is time to the first textured world frame with matching output and no increase in skipped work or device removals.

AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static analysis, standalone Linux probes and drafting.

**@⁠KOLESNiii** on GitHub · 2026-11-26 09:47 UTC · [original](https://github.com/xcl-dev/xcl/issues/2745) Part of #2088 and #2508. Related to #2741, #2301 and #2080. ## What happens on main The direct translator selects a compact or ordinary lowering before it asks the dispatch splitter to plan pieces. The compact emitter keeps the current and next block indices in local `alloca` slots, and uses the same scheme for loop budget and guest register state. XCL's optimizer leaves the live dispatch locals in the module. `Shader::split_compute` rejects `Alloca` and ordinary local loads/stores before it reaches the CFG planner. As a result, choosing compact emission can turn a shader with a valid ordinary chain into a whole-only build. Native wave64, group shape, barriers and other split restrictions still apply. [Form selection](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/kernel.rs#L281-L289) · [Dispatch-local state](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/compact.rs#L239-L258) · [Optimize then split](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/kernel.rs#L619-L635) · [Split restrictions](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/module/split.rs#L89-L135) There is a second constraint even if the locals are promoted to SSA. Compact emission sends every class around the same dispatcher back edge. The resulting strongly connected component stays together in the partitioner, which refuses a component above four times its instruction target. In a standalone Linux probe using the extracted `main` optimizer and partitioner, the optimizer kept two live dispatch-index allocas. Separately, an artificial acyclic graph with 40 bodies produced 14 pieces at a test limit of 32, and the same body sizes behind a shared dispatcher back edge produced no plan at that limit. This checks the two mechanisms on synthetic IR. Retail eligibility and latency remain to be measured. [Loop emission](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/compact.rs#L296-L364) · [Partitioner](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/module/split.rs#L596-L642) ## Proposed work 1. Test a synthetic guest compute program for which the ordinary form yields a valid chain and compact emission yields a valid whole PSO. Log the selected form and the actual split rejection condition. Respect forced compact, forced plain and split-disabled settings. 2. On automatic selection, compare compact whole with the eligible ordinary chain on records observed before world entry. Keep the ordinary chain and optional whole fallback separately measurable. Reuse the existing descriptor and ABI checks, including #2741's proposed request identity for fallback capture. Measure native creation and peak commit, plus GPU time with the real dispatch slabs and barriers. Include the cost of a cold whole fallback wherever the caller can need one. 3. If a combined representation is worth pursuing, try partitioning the ordinary CFG first and applying compact lowering only within selected legal regions. Promotion of compact scalar locals can be investigated independently. The work in [itsSio/xcl#3](https://github.com/itsSio/xcl/pull/3) promotes static scratch arrays, which is adjacent to the local-memory check. A partitioning experiment also needs to preserve cross-piece liveness, barrier legality and dispatch semantics. #2301's proposed size retry is a useful independent whole-form candidate. A comparison should track whether a smaller whole artifact replaces a useful chain, because the whole byte count alone omits the lost execution option. The end point is time to the first textured world frame with matching output and no increase in skipped work or device removals. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static analysis, standalone Linux probes and drafting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:36 +00:00
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 11:30 UTC · original

I tested an opt-in implementation that keeps the compact whole fallback and retains compatible ordinary dispatch pieces. The branch is fe87896d84ad581ac8a25b275d0889eaf938f2b0, based on b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. It requires matching ordered static samplers and gives the option its own cache identity.

  • Normal compute entry point. Five fresh, CPU-only synthetic runs passed. The automatically selected compact whole was byte-identical with the preference off and on (4,524 bytes). Turning the preference on retained the same 24 pieces and 384 scratch dwords per group as forced ordinary lowering. The pieces matched byte for byte. A zero split limit suppressed the chain.
  • Native RTX 4080 readback. A smaller test-only fixture matched 784/784 UAV words through both the five-piece path and the compact whole fallback. The first route made zero whole PSOs. The fallback made exactly one. 1 passed, 0 failed, 0 ignored, 0 capability skips.
  • Exact-head suite. cargo build --workspace --locked -j 4 and cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output passed. 1,437 passed, 0 failed, 47 ignored, including 29 capability skips in the pass count.

RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. The 24-piece case exercised CPU translation and DXIL validation. Retail smoke and native compile timings for large shaders remain untested.

**@⁠CryingLaughing** on GitHub · 2026-11-26 11:30 UTC · [original](https://github.com/xcl-dev/xcl/issues/2745#issuecomment-7190813314) I tested an opt-in implementation that keeps the compact whole fallback and retains compatible ordinary dispatch pieces. The branch is [`fe87896d84ad581ac8a25b275d0889eaf938f2b0`](https://github.com/CryingLaughing/xcl/commit/fe87896d84ad581ac8a25b275d0889eaf938f2b0), based on `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`. It requires matching ordered static samplers and gives the option its own cache identity. - **Normal compute entry point.** Five fresh, CPU-only synthetic runs passed. The automatically selected compact whole was byte-identical with the preference off and on (**4,524 bytes**). Turning the preference on retained the same **24 pieces** and **384 scratch dwords per group** as forced ordinary lowering. The pieces matched byte for byte. A zero split limit suppressed the chain. - **Native RTX 4080 readback.** A smaller test-only fixture matched **784/784 UAV words** through both the five-piece path and the compact whole fallback. The first route made zero whole PSOs. The fallback made exactly one. **1 passed, 0 failed, 0 ignored, 0 capability skips**. - **Exact-head suite.** `cargo build --workspace --locked -j 4` and `cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output` passed. **1,437 passed, 0 failed, 47 ignored**, including 29 capability skips in the pass count. RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. The 24-piece case exercised CPU translation and DXIL validation. Retail smoke and native compile timings for large shaders remain untested.
This discussion has been locked. Commenting is limited to contributors.
No description provided.