Recompiler: skip scalar-load analysis for direct compact emission #2756
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2766"
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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T11:15:56Z.
The direct DXIL backend ran
reload::analyzefor every compute and kernel entry, including those it then emits in the compact form. Only the plain block loop reads the result, and that loop runs only whenplan.is_none(). Compact emission lowers its blocks without the analysis, so on that path the fixed-point pass over the whole CFG was thrown away. The call is now guarded withplan.is_none(). Fixes #2746.What is in it
crates/xcl/src/gpu/dxil/kernel.rs: runreload::analyzeonly when there is no compact plan (one line, plus the comment above it).crates/xcl/src/gpu/dxil/compact_tests.rs:scalar_load_compact_reload_comparison, taken from #2805 with its author (@CryingLaughing) as co-author. It checks that a generated program with repeated scalar loads has live repeats for the reload analysis and takes both the ordinary and the compact path; withXCL_2746_*set it also compares the DXIL with a baseline and times the automatic compact translation.Tested
AMD Ryzen 5 3600XT, NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), Windows 11 build 26300, rustc 1.100.0.
cargo test --workspace -- --test-threads=4(debug) at5ef14a32: 1436 passed, 0 failed, 47 ignored. 25SKIPPED: 21no wave64, 3 refused wave32 per-lane forms, 1no heap windows.Probe (a throwaway in-crate
#[cfg(test)]module, not part of this PR), release build, medians of 5 passes. Synthetic wave32 kernels with 28,673 instructions and 8,193 reachable blocks, 16 / 128 / 256 distincts_load_dwordx4offsets. For each program, automatic selection and forced compact (translate_full_as(.., true)) give the same bytes.main(b49be183)reload::analyzealone takes 114 / 816 / 1,614 ms on these programs, the difference between the two columns. Full numbers are in https://github.com/xcl-dev/xcl/issues/2746#issuecomment-7189794278.The smoke title translates two compute shaders in the compact form (14,377 and 13,890 blocks), in both runs.
Regression run
Both runs:
XCL_PRESS_AT=25:A,XCL_PREPARE=0. Frame counts vary from run to run on this title (earlier heads of this PR with the same runtime code showed 1185 and 1414, against 978 onmainb49be183); the change only skips an analysis whose result the compact path never reads, and its DXIL output is byte-identical, so I do not attribute the difference to it. The PR's head is based onmain10d27297; themainrun is on the newer9dfbe3ea. the suite counts above are from5ef14a32, before that rebase.Not tested
maintoo. The plain path's reload reuse is still covered byreload::tests::the_translator_emits_a_repeated_load_once.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by MatyEjsr on 2026-11-26T12:17:59Z.
Updated independent verification of PR #2766 at head
5ef14a321b15ff9baca95345c39a901a7307c4d7(based onmainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7; merges cleanly with currentmain8b957becwith no conflicts).Follow-up & duplicate check
crates/xcl/src/gpu/dxil/kernel.rsis unchanged from previously verifiedf276e58d: guardingreload::analyze(&cfg)withplan.is_none()preserves plain lowering while removing unused CFG analysis on compact emission. Neither currentmain(8b957bec) nornvidia-dev(eae01502) has superseded this change.5ef14a32addsrepeated_scalar_loadsandscalar_load_compact_reload_comparisonincrates/xcl/src/gpu/dxil/compact_tests.rsfrom still-open duplicate PR #2805 (group D129) with co-authorship credit, so #2766 now includes both the fix and the comparison test.Tested
rustc 1.100.0(0ef1bc386 2026-11-09), DXC1.9.2602.17.cargo build --workspace -j 8(debug) andcargo build --release --workspace -j 8(release): passed.cargo test --workspace -j 8 -- --test-threads=8(debug): 1436 passed, 0 failed, 47 ignored across 37 targets.SKIPPED(28): 21no wave64(dispatch_chain_native_wave64_builds_whole,gpu::recomp::lower/lower_dxil/testswave64 variants), 3 refused wave32 per-lane forms (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32for#1426), 2no d3d12SDKLayers.dll(the title under the debug layer), 1no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form), 1no D3D12 debug layer(uploads_start_from_each_subresources_state).5ef14a32(--test-threads=1):cargo test -p xcl --lib gpu::dxil::reload::tests: 6 passed, 0 failed, 0 ignored, 0SKIPPED.cargo test -p xcl --lib gpu::dxil::compact_tests -- --nocapture: 14 passed, 0 failed, 0 ignored, 0SKIPPED(scalar_load_compact_reload_comparison:ordinary=8200 B, compact=4616 B).XCL_DIRECT_DXIL=1andXCL_DIRECT_DXIL=allcargo test -p xcl --test gpu_compute_e2e: 7 passed, 0 failed, 0 ignored, 1SKIPPED(no heap windows) in both modes.scalar_load_compact_reload_comparisonwithXCL_2746_BENCH=1(automatic plan: blocks=16385, representatives=131, words=5128): self-roundtrip determinism (XCL_2746_DXIL_DIRwrite pass ->XCL_2746_BASELINE_DIRverify pass at5ef14a32) matched all bytes forkernel-ordinary.dxil(8,200 B),kernel-compact.dxil(4,616 B), andcompute-automatic.dxil(24,980 B); automatic compact whole translation median 39,558 µs (write) / 38,852 µs (verify).f276e58dvsmainb49be183, release,--direct --validate;kernel.rsis unchanged at5ef14a32):--sample 256 --seed 1 --validate --threads 8, 41 over cap skipped): 215/215 validated and 100% byte-identical (0diffs).--threads 1, byte-identical DXIL):95cc13288a27a96e675.15 ms -> 232.41 ms (2.91x),56c0cd3b82a00c6e337.87 ms -> 157.07 ms (2.15x).Regression run
c1cc91a4, shared DXIL cache):main:PR #2766 head:
Not tested
#1426refused f16/f32 per-lane forms, missing D3D12 debug layer, andXCL_HEAP_WINDOWS=1), comparingXCL_2746_BASELINE_DIRagainst an unpatchedmainbaseline, and re-running the per-shader retail corpus timing/byte-identity comparison at5ef14a32(kernel.rsis unchanged fromf276e58d).AI use
main, ran the workspace, targeted, Direct DXIL, release benchmark, and smoke checks on the hardware above, and drafted/audited this updated report.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T13:40:32Z.
Independent Windows/NVIDIA check of #2766 head
f276e58, based onmainb49be183. I tested a clean detached checkout of the exact head.Source check: the changed
reload::analyzeresult is read by the plain block loop, which executes only whenplan.is_none(). Compact emission runs onSome(plan), and its lowering does not setlw.reload. The guard leaves the plain path's analysis in place and removes work the compact path does not consume.Tested: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GiB (NVIDIA 621.35), rustc 1.99.1 MSVC, DXC 1.8.2502.11;
XCL_ADAPTER=3080, writable localXCL_DXIL_CACHE.cargo build --offline --locked --workspace: passed.cargo test --offline --locked -p xcl --lib gpu::dxil::reload::tests -- --nocapture --test-threads=1: 6 passed, 0 failed, 0 ignored.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,435 passed, 0 failed, 47 ignored across 37 targets. There were 25 GPUSKIPPEDnotices (21 no wave64, three refused per-lane cases, one no heap windows); those are not GPU coverage. The suite log identifies the real RTX 3080 Ti backend.Not tested: independent translation timing or byte-for-byte output comparison for a compact shader, a retail title smoke run, AMD wave64, and the skipped cases. This report verifies this revision's build and regression suite; it does not independently establish the reported translation speedup.
AI use: Codex (GPT-6.2 Sol) checked the source path, ran the tests, and drafted this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-26T17:18:55Z.
Two contributors checked independently and found that this PR makes the same change as #2805 (for #2746): #1607, group D129. They suggest keeping #2805. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-26T17:22:38Z.
AMD Windows, translation side only, for #2766: on an RX 9070 XT this PR leaves all 2,689 retail compute programs byte for byte the same as
mainb49be18. It makes the two that take the compact form translate about 2.5× faster.mainb49be18, with a local patch inxcl shadersthat writes each program's DXIL size and translation time.xcl shaders <retail shaders.rpf> --precompile --only cs,XCL_DIRECT_DXIL=1, switch windows, a fresh translation cache per run, 8 threads. Two runs per build.mainruns 1 and 2 → this PR runs 1 and 2):56c0cd3b82a00c6e: 617, 708 → 241, 254958400d2caf07244: 573, 680 → 241, 25795cc13288a27a96eincluded, are not compact here and stay within run-to-run noise. Summed over all 2,689 programs, translation time is noise-dominated with 8 threads, so I'd only claim the per-program numbers above.AI use: Claude Code (Claude Opus 5.5) built the binary, ran the measurements and wrote this; I posted it.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T17:37:35Z.
Ran the compact-DXIL emission tests at
f276e58don an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All 13 pass here, including the GPU tests in that module that compile and run compact DXIL on the real adapter with DXC 1.9.2609.5. The thread has an independent Windows/NVIDIA report and AMD reports, but no 5070 Ti; this adds a Blackwell desktop datapoint for the guard around
reload::analyze. I did not repeat the author's release timing probe.Not tested: the synthetic 28,673-instruction timing probe, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T17:50:21Z.
@throny thanks for the triage. The fix is the same as #2805's, but I'd ask to keep this one:
5ef14a32), with @CryingLaughing as co-author. This PR now has everything #2805 has.@CryingLaughing your test is credited here. If you're fine with it, closing #2805 in favour of this PR would save the maintainers a review. I'll add a note for D129 in #1607.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T20:44:11Z.
Independent desktop NVIDIA verification of PR #2766 at head
5ef14a321b15ff9baca95345c39a901a7307c4d7(2commitsf276e58d -> 5ef14a32on merge-baseb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555ancestor ofmain; parentf276e58d0fd307e0654aae45fe664eee956f0818).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
5ef14a32)cargo test --release -p xcl --lib scalar_load_compact_reload_comparison -- --nocapture1 passed; 0 failed; 0 ignored; 1336 filtered out(0.01s)cargo test --release -p xcl --lib gpu::dxil::(3 consecutive runs)185 passed; 0 failed; 3 ignored; 1149 filtered out× 3 (3.31s,3.37s,3.44s;1Wave64-only test self-skipped on Wave32-only RTX 4060)cargo test --release -p xcl --lib gpu::recomp::401 passed; 0 failed; 20 ignored; 916 filtered out(5.03s; Wave64-only and#1426-refused subcases self-skipped as expected)cargo build --release -p xcl --bin xcl1m 12s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Merge-base (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):PR #2766 (
5ef14a321b15ff9baca95345c39a901a7307c4d7):Runtime log observations (
xcl.log)9220log lines,0[ERROR]/ device-removal / panic lines.19624 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14010 MB committed by the process; video memory 6116 MB local, 4682 MB non-local.Limits of coverage
scalar_load_compact_reload_comparison, 3×gpu::dxil::, fullgpu::recomp::, and a paired 60 s retail smoke (title: 29640639with existing warm shader cache). It did not run a separateXCL_2746_*before/after compact-translation timing sweep or byte-identity diff against an exported baseline directory.gpu::dxil::(dispatch_chain_native_wave64_builds_whole) andgpu::recomp::self-skipped on the Wave32-only RTX 4060, and the existing#[ignore]dump/fuzz/benchmark tests remained ignored.1621vs.1518frames) reflects normal single-run startup variance and is not attributed to this PR.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-30T03:39:34Z.
Hey @KOLESNiii — we tested this stacked with the Direct DXIL compile speedup batch and the Windows build/tests are green, it's just blocked on the
PR descriptioncheck (missing/stalexcl-smokeor required sections). If you update the description we can get it queued in #3041!Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-30T14:02:28Z.
@Kalmarv the regression smoke is done and this is unblocked. Both
xcl-smokeblocks are in Regression run:main9dfbe3eaand this PR's head2e146f94, same title, 60 s, RTX 2070 SUPER. Neither run had a device removal or a crash. The PR run showed 1278 frames againstmain's 1591 and a peak commit of 15061 MB against 17442 MB. Both required checks (CI,PR description) are green.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T07:30:31Z.
merge-check claim
head:
2e146f9403Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T07:47:11Z.
merge-check
base:
493dbd3dd0head:
2e146f9403merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test
scalar_load_compact_reload_comparisonran and passed (its benchmark and file-output parts are off unlessXCL_2746_*variables are set; they were not set).review: no blocking finding; two files (+95/-2), every line read.
translate_on_this_threadno longer runsreload::analyzewhen a compact plan was chosen. I checked the claim on the merge result:reloadsis read only in the per-block loop that is filtered byplan.is_none(), so the compact path never used the result and the emitted DXIL cannot change. The test writes files only into a directory named byXCL_2746_DXIL_DIR. Not measured here: the translation time saved.performance: none by default; saves one analysis pass for programs that take the compact form (not measured here).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:54:41Z.
Triage (#1607) – head
2e146f9#2805 made the same
kernel.rschange (noreload::analyzewhen a compact plan is used) with the same test and was closed. Intranslate_on_this_thread,reloadsis read only in the non-compact block loop, so skipping the analysis for the compact form does not change the output. Not on main yet (main still runsreload::analyzeunconditionally).scalar_load_compact_reload_comparisonis mostly a benchmark/fixture behindXCL_2746_*variables. By default it checks only that the two emission paths differ, so it would not fail without the change. Acceptable for a pure performance change.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T14:39:21Z.
Thanks @Kalmarv, @BBareth (merge check) and @Foniass. Rebased onto
maindf0cfef6with no conflicts; new head3fff5bdd. The smoke runs (main and this head) and the suite are queued, and the description will get both blocks and the counts when they finish, which should clearPR description. On the test: as Foniass says, by defaultscalar_load_compact_reload_comparisonchecks only that the two emission paths differ, so it would not fail without the change. The change is a skipped analysis whose result the compact path never reads, so its output cannot differ. A test that would fail would have to countreload::analyzecalls, which needs instrumentation that this PR does not otherwise add.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:40:37Z.
Follow-up review (head
3fff5bdd, since2e146f9, diff read, not a merge-check; checks red):git range-diffshows both commits the same apart from context wheremainmoved under them (the newloop_passesline next to this PR'sreload::analyzegate); this push is a rebase.New: none.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.