Recompiler: reuse scratch slots across disjoint payload lifetimes #2322
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2322
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2322"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@akimfomin on GitHub · 2026-11-25 14:21 UTC · original
akimfomin:codex/compact-scratch-afc5ee8→main· +141 −23 · 2 files · 1 commits · draftPart of #1269 and a follow-up to Kalmarv’s merged #2126. The PortBridge allocator reuses scratch slots after their last carrying stage and keeps the fixed layout when reuse saves no space.
What is in it
Tested
Windows 11, RTX 4070 Ti SUPER driver 617.14, Rust 1.100.0 gnullvm, DXC/DXIL 1.9.2609.5. The exact tree at
b3f7ab5574c4489761141e2de0ce31d2eb216412passed 10 targeted split tests with zero skips. The open Wave32 fixture used 256 DWORDs per group and matched the whole-shader and CPU outputs. The same check on the fixed allocator reported 288.ettehn independently reported 47,712 to 20,064 DWORDs per group on one translation record and eight passing checks on an RTX 5070 Ti Laptop. Report
nnonno91 independently passed all 10 targeted tests with zero skips on each of AMD Radeon Graphics and RTX 5090. luckyteagirl independently passed the same 10 without skips on a Radeon RX 6800M. All three runs used the exact PR head. The split readbacks matched and the Wave32 fixture reported 256 DWORDs. The guest-Wave64 split fixture executes as hardware Wave32 halves.
On the same Git tree (
0e3b7fd2c023d3935f7d4e0b5725751409062e62), the open RTX 4070 Ti SUPER workspace build usedcargo build --offline --locked --workspace -j 2.cargo test --offline --locked --workspace -j 2 --no-fail-fast -- --test-threads=4reported 1,265 passed, 0 failed and 46 ignored. The harness printed 27 additional runtime skip lines inside those totals: 21 unavailable Wave64 paths, three lowering refusals, two missing debug-layer paths and one missing heap-window path.Regression run
The paired retail
xcl-smokeblocks on main and the exact PR head are pending. The PR remains a draft.Not tested
Paired retail smoke and matched GPU time, cold driver compilation, and scratch sizes for the three workloads Kalmarv requested. The 57.9% scratch reduction above concerns one unnamed translation record. Aggregate-only review package
AI use
OpenAI Codex (GPT-6 family; the exact serving variant was unavailable) assisted with rebasing, testing and drafting.
@nnonno91 on GitHub · 2026-11-25 14:25 UTC · original
Independent Radeon and RTX 5090 check on
b3f7ab5574c4489761141e2de0ce31d2eb216412.Tested
cargo test --locked -p xcl --lib gpu::dxil::module::split::tests -- --nocapture --test-threads=1withXCL_ADAPTER=AMD RadeonandXCL_ADAPTER=NVIDIA GeForce RTX 5090in separate processes. The runner printed each adapter. Each run gave 10 passed, 0 failed, 0 ignored and no skips.Not tested
Retail records, compile or GPU timing, title smoke and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the checks, verified the logs and wrote this report.
@luckyteagirl on GitHub · 2026-11-25 14:48 UTC · original
Independent RX 6800M verification of exact PR head
b3f7ab5574c4489761141e2de0ce31d2eb216412.Environment: Windows 11 build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64; isolated debug Cargo target.cargo test --locked -p xcl --lib gpu::dxil::module::split::tests:: -- --test-threads=1 --show-outputpassed 10 passed, 0 failed, 0 ignored, with noSKIPPEDline on the clean head. The suite includes the new slot-lifetime/compaction checks, whole-vs-split GPU readback for Wave32, a guest wave64 program split across hardware wave32 halves, oversized loops, persistent payloads across skipped stages, and divergent 3D forward edges. The suite loggedCHAIN_GPU=AMD Radeon RX 6800M. The Wave32 compaction fixture asserted 256 scratch DWORDs per group and passed.The guest-wave64 split fixture uses
KernelOptions { wave64: true, split: true }and runs on wave32 hardware waves; this result is not a test of a native-wave64 dispatch chain. I did not run the full workspace suite, an owned-title smoke pair, the requested three matched GPU measurements, or a shader-pack size survey on this head. A separate title smoke attempt for another PR had just stopped under the available-commit memory guard, so I kept this check focused.AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the native Windows suite, checked the exact head and clean worktree, and drafted this report. No game data was used.
@anes66 on GitHub · 2026-11-25 14:58 UTC · original · edited 2026-11-25 15:21 UTC
CPU-only allocator and planner checks passed on exact head
b3f7ab5574c4489761141e2de0ce31d2eb216412. Optional companion d039ce5, with parent 440b261, contains tests only: the independent partition/liveness fixture from main plus exhaustive allocator intervals and checks throughModule::scratch_slots.Tested
scratch_slotsresult is checked against the definition stage and last carrying destination for every value; overlapping inclusive lifetimes cannot share words. A no-saving result must preserve the original fixed offsets.payload_slot_intervals_never_overlap_while_both_values_are_live,dispatch_plan_matches_forward_liveness_and_independent_sccs,payload_slots_reopen_only_after_the_last_consumer,oversized_loop_occupies_one_piece_up_to_the_hard_ceiling, anddispatch_chain_wave32_reuses_scratch_before_gpu_run, usingcargo test --locked -p xcl --lib -j 2 -- --exact <full names> --nocapture --test-threads=1: 5 passed / 0 failed / 0 ignored / 0 skips.run_gpu=falsepath. It builds/validates synthetic pieces and checks the 256-DWORD group layout, then returns before GPU execution.last < firsttolast <= firstmakes the interval test fail immediately with three simultaneously-live values assigned to slot 1. Restored before final passing runs and commit.Not tested
GPU output or timing, the requested matched GPU measurements, real scratch-memory savings, full workspace, release or a title. The CPU checks do not replace those remaining adoption requirements.
Integration follow-up: footprint expectation
With #1906/#1972 optimizer changes in a local combined tree, the existing
run_gpu=falsefixture has 320 fixed / 288 compact DWORDs per group, with a peak-live-word lower bound of 288. It still saves a full wave plane, but the literal256assertion fails. On standaloneb3f7ab5, the corresponding values remain 288 / 256, peak 256.Optional test-only e17bf0b, directly on this head, derives the exact expected footprint from inclusive live intervals plus the continuation tag, requires attaining that lower bound, and separately requires a reduction from the fixed layout. It passes 1/0/0/0 standalone and in the combined snapshot. As a negative control, returning the fixed layout makes it fail at 288 versus the 256-DWORD lower bound; restored before the final passing run. No GPU execution or title run.
@akimfomin on GitHub · 2026-11-25 15:26 UTC · original
Thanks to nnonno91, luckyteagirl, and anes66 for checking the exact head. The combined-tree result from anes66 is useful for integration: it still saves a full wave plane, while the literal 256-DWORD fixture assertion depends on the optimizer stack. I’m keeping the head pinned for the current comparisons.
@Kalmarv, if your authorized setup is available and you want to run the comparison, the remaining measurements are scratch DWORDs per group and matched GPU timestamps for the full dispatch chains for
ef008c0f(early and late inputs),c3ae6819, andfb1c6d2d. The PortBridge aggregate-only kit checks equal grids, piece counts, and matching outputs for main versus the exact candidate. Please keep workloads and raw inputs on your own machine.The two standard paired
xcl-smokesummary blocks and approval of the fork CI are separate review requirements. This remains a draft. OpenAI Codex assisted with verification and drafting.@Kalmarv on GitHub · 2026-11-25 15:29 UTC · original
@akimfomin yes, I'll run it. It matters for us too: porting #2097 onto #2126's fixed slots made the seven cascade-shadow programs need 4.4–6× more scratch per group (6d1e4583: about 1.4 MB per 16×16 group), so slot reuse is exactly what those chains need.
Our GPU is busy with world-load stall runs for the next few hours, so it comes after those. Plan: your kit on
mainand onb3f7ab5foref008c0f(early and late inputs),c3ae6819andfb1c6d2d, comparing scratch DWORDs per group, piece counts, matching outputs and timestamps per full chain. Plus a smoke pair. Workloads and raw inputs stay on this machine, and I'll post aggregates only.AI use: Claude Code (Claude Opus 5.5).
@DavidM1911 on GitHub · 2026-11-25 17:52 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@akimfomin on GitHub · 2026-11-25 15:55 UTC · original · edited 2026-11-26 01:33 UTC
Thanks, Kalmarv. I checked the live revisions before you start. For the allocator-only pair, please use the exact parent
afc5ee86ae3a9521c9f15d96505cd73fe72f2191and this draftb3f7ab5574c4489761141e2de0ce31d2eb216412. Current main already changed the splitter and chain dispatch, so a current-main comparison would need the candidate on that same commit. The updated PortBridge kit records both actual build revisions. The aggregate-only plan you described is enough. (Codex-assisted revision check.)After #2371, the original head conflicts in
split.rs. For current-main integration I published a separate candidate on b49be18. The original pair above remains available for your ongoing measurements. On an RTX 4070 Ti SUPER, all 11 split tests passed in each of two fresh processes, with the production allocator and with the upstream offline first-fit comparator. The new four-stage regression uses four words per lane in the first layout and six in the second. The divergent GPU fixture had matching output in both modes. The three workload timings and paired title smoke are still pending. OpenAI Codex (GPT-6) assisted with the adaptation and verification.@akimfomin on GitHub · 2026-11-26 02:25 UTC · original
Kalmarv, thank you for explaining what scratch pressure means for the seven cascade-shadow programs. ettehn’s footprint comparison, the exact-head runs from nnonno91 and luckyteagirl, anes66’s interval checks and DavidM1911’s 3060 Ti run are all preserved here.
I’m stepping back from regular development of PortBridge. The draft stays pinned for anyone continuing the measurement. The two exact comparison revisions and separate post-#2371 patch are ready to use. The open question is scratch per group and GPU time per full chain on the three agreed workloads with matching outputs. Results can come here whenever the setup is free. Only aggregates are needed. The paired smoke and review remain with XCL.
I’ll still read incoming notes when I can. Project handover. Codex helped prepare this note.
@Kalmarv on GitHub · 2026-11-26 08:45 UTC · original
@akimfomin thank you for the allocator, the kit and for pinning the exact pair. Here's the comparison you asked for, aggregates only, on
afc5ee86ae3a9521c9f15d96505cd73fe72f2191(baseline) againstb3f7ab5574c4489761141e2de0ce31d2eb216412(candidate). Each was a clean release build in its own target directory.Setup: RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 26200, DXC 1.9.2609, unlocked clocks. For each workload: the same grid (64×1×1 groups) and seeded input for both builds, the whole program as the reference, 3 s warm-up, then 4 interleaved rounds of 20 timed runs per form. A timestamp brackets the full chain, internal barriers included. Everything ran twice, once with the baseline chain timed first in each round (ab) and once with the candidate first (ba). Your
compare_merged.pyat64a3e569returned exit 0 on both orders:output_check: pass,scratch_nonincrease_check: pass.The candidate cuts scratch per group by 51 to 61 %, with the same piece counts and identical outputs. Its full-chain time is within −1.8 % to +0.2 % of the baseline on every input and order. The per-round spread (round medians) stays within about ±0.5 % of each median.
Regression run (
scripts/smoke.ps1, 60 s each, the same retail title,XCL_DIRECT_DXIL=1, each side with its own fresh XCL cache starting from the same pipeline list, one after the other in one job; two other test jobs of ours ran beside both runs, and one of them ended 13 s before the candidate's run did):Candidate against baseline: 1364 / 1366 frames (99.9 %), peak commit 15226 / 18882 MB (81 %), no crash or device removal. Both runs logged
compute split: 11 programs split, 66 pieces built, 0 chained dispatches, so in 60 s the title builds chains but doesn't dispatch them, and this pair is a regression check only. This is our second pair. In the first one, the candidate showed 642 against 1328 frames (peak 15229 / 18370 MB, no crash). That run had the driver's cache warm for the baseline's pipelines but cold for the candidate's re-laid-out pieces. After one run of each, they are level as above.Not tested: AMD or Intel; the three workloads on title inputs other than these seeds; chained dispatches in a title run (none in 60 s); the post-#2371 candidate on
b49be18.AI use: Claude Code (Claude Opus 5.5) ran the builds, timings, comparator and smoke pairs on our machine and wrote this. The kit's comparator was run unchanged as a separate tool.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.