Recompiler: XCL_LOOP_BUDGET sets the loop iteration budget of a lane #1274
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1284"
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 upipibi on 2026-11-24T14:19:25Z.
LOOP_GUARDcaps every lane at 65 536 loop iterations. In the stops of #505, the GPU runs translated compute loops at 100 % for tens of seconds. The current reading there is that the loops run on data a skipped dispatch never wrote:If that reading holds, the budget is what finally ends those loops. There was no way to try a lower one without editing the prelude, so this adds a switch for it. It is a diagnostic, not a fix: the default does not change.
Part of #505.
What is in it
dxil::lower::LOOP_BUDGET(gpu/dxil/lower.rs:36, 65 536), whateverXCL_LOOP_BUDGETsays. The README doesn't list the variable; it is a diagnostic for #505.region_budget_limits. Whichever of the two lands second has to pass the configured budget there too (throny's merge check).gpu/recomp/mod.rs:loop_budget()readsXCL_LOOP_BUDGET. A whole number from 1 sets the budget; anything else keeps 65 536. Documented atLOOP_GUARD.gpu/recomp/emit.rs: with the variable set to anything but 65 536, the prelude'sstatic uint xcl_budget = 1u << 16;becomesstatic uint xcl_budget = <n>u;. Unset, the HLSL is byte for byte as onmain, so DXIL cache keys and driver blobs stay valid (an earlier head wrote a#defineinto every prelude; changed after @not-rex's point on #505).gpu/recomp/pso.rs:XCL_LOOP_BUDGETjoins the switches whose translations are not cached in memory or on disk (cache_allowed, and its test). DXC's cache is keyed by the HLSL, so it stays correct. The first run with a new value recompiles every shader it meets.gpu/recomp/tests.rs:loop_budget_reads_a_whole_number_from_onechecks the parser.gpu_loop_budget_caps_a_loopruns a loop whose exit never comes (s_cmp_lgagainst 0 after the first increment). It checks that the unset translation keepsmain's prelude line, then that the loop stops after 4 096 iterations with the budget at 4096, and 61 440 iterations later at 65 536.Tested
At the current head
8fc2816(rebased ontomaine99b0bdon 2026-12-03; Foniass's indentation nit ingpu_loop_budget_caps_a_loopfixed): NVIDIA GeForce RTX 3070, driver 621.40, Windows 11 Pro, rustc 1.100.0, debug.cargo test -p xcl --lib -- --test-threads=4: 2865 passed, 0 failed, 37 ignoredgpu_loop_budget_caps_a_loop, 3 runs each withXCL_DIRECT_DXIL=0and=1: 1 passed, 0 failed every run (the test compiles the HLSL prelude, so it checks the HLSL path)Limit since the rebase: the direct-DXIL backend is now the default (
dxil/kernel.rs:43-64), and it has its own fixed budget,LOOP_BUDGET = 1 << 16(dxil/lower.rs:45, used at:135andkernel.rs:1311). SoXCL_LOOP_BUDGETchanges the budget only for programs that take the HLSL path (XCL_DIRECT_DXIL=0, or the HLSL fallback). Wiring it into the direct path would also need a test that can set the budget without the process environment; I have not done that here.Earlier, at
998dda8:maine429936cas998dda8(main addedXCL_SAFE_BARRIERto the two lists inpso.rswhere this addsXCL_LOOP_BUDGET; both kept). RTX 3070 (616.56), Windows 11 Pro 10.0.26100, debug:cargo test -p xcl --lib -- --test-threads=4: 1997 passed, 6 failed, 28 ignored; main alone: 1995 passed, 6 failed, 28 ignored. The 6 are threedispatch_chain_*,gpu_heap_flat_reads_match_guarded_and_root_output,gpu_compute_mode_dispatch_abiandgpu_float_cas_uses_ieee_equality, the same as on main (#3093). This PR's own tests pass. The smoke pairs below are for the previous head; this one needs a new pair (I have no title).f3eb053applied onmain1a0bbe3, debug, Windows 11,cargo test -p xcl --lib -- gpu:: --test-threads=4. RX 9070 XT (RDNA4, native wave64):gpu_loop_budget_caps_a_looppasses; 631 passed, 2 failed, 22 ignored (the 2 are #2115's AMD fuzz seeds, the same onmain). RTX 3060: the new test passes; 633 passed, 0 failed, 22 ignored.f3eb053f(rebased ontomain426a5a74, the firstmainwith green CI after5478c4a7, whose two failing tests main fixed in0d13b071), RTX 3070 (616.56):gpu_suite (--skip gpu_sparse_vram) 144 passed, 0 failed withXCL_DIRECT_DXIL=0and with=1.main426a5a74gives 143 passed on both.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4:3980a81(before the rebases; the current head isf3eb053): 753 passed, 0 failed, 41 ignored;main930e8b4: 751 passed, 0 failed, 41 ignored, same machine.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.XCL_LOOP_BUDGET=4096 cargo test -p xcl --lib loop_budget: 2 passed. The budget follows the variable.Dispatch(4,1,1)to reach 65 536 iterations. At 4 096 it is 16 times shorter.Regression run
The pairs below are for earlier heads; a pair on
8fc2816is needed.Pair for the current head
f3eb053againstmain1a0bbe3, run by thehollowedone (comment, thanks): RTX 3080 Ti (621.35), stockscripts/smoke.ps1, clean release builds, 60 s. Pasted unedited. Their note: it checks the default startup path; the world load and a non-defaultXCL_LOOP_BUDGETwere outside these runs.Earlier pair, for the old head
0b28a6b, from Kalmarv's run (thanks):From Kalmarv's run on an RTX 5070 Ti (NVIDIA 610.74),
main20cf130and this head0b28a6b, 60 s each (https://github.com/xcl-dev/xcl/pull/1284#issuecomment-7148089060), thanks:Not tested
mainsends enormous compute programs to the direct DXIL translator, which uses its fixeddxil::lower::LOOP_BUDGET.XCL_LOOP_BUDGETsets only the HLSL path's budget, so it doesn't reach those programs.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:34:01Z.
Full-suite run, since this PR has no test report yet. Tested exact head
e1573e3(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.loop_budget_reads_a_whole_number_from_one,gpu_loop_budget_define_caps_a_loop.Not tested
AI use
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T15:25:30Z.
Regression pair for
3980a81againstmain930e8b4(this PR's base), on a retail title, for the Regression run section. Both runs pass: no device removal, no crash, 101 % ofmain's frames, 105 % of its peak commit.Tested
scripts/smoke.ps1, the same retail title for 60 s each:mainat930e8b4(this PR's base) first, then this PR's head, one after the other on the same machine.XCL_LOOP_BUDGETwas unset, so the PR's run used the default budget.main930e8b4:this PR,
3980a81:For #505 (earlier runs, not this pair). On this machine the 100 % phase before the removal is one dispatch: the BVH builder's refit program (
cs b6043104de672057), whose threads climb parent links, and a local build ofmainthat skipped it had no device removal. A lowerXCL_LOOP_BUDGETcaps exactly that climb.Not tested
XCL_PSO_WAIT_MS=50+XCL_LOOP_BUDGET=4096for 300 s (one1573e3, before the last push): it ended at 118 s in the known title crash at+0x2215c35(#1270), before the point where #505 stops. It may have reused cached programs built with the default budget, so it does not show the 4096 budget applied. There is nomainrun with these settings.AI use: Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by not-rex on 2026-11-24T19:14:39Z.
RTX 3080 (10 GB, driver 610.88, Windows 11), retail 1.0.2.1 into the world: with
XCL_LOOP_BUDGET=4096the GPU no longer hangs; it works in bounded bursts and the title keeps presenting for about 110 s longer, until a different fault in the title.Tested
main930e8b4+ #1123 + #1254 (diagnostics) + this PR at3980a81(clean merge), release. Warm DXIL cache and save from earlier runs, no full pipeline precompile.XCL_PSO_WAIT_MS=50, A pressed at 30 and 40 s,XCL_ACTIVITY=1,XCL_NETWORK=0, 400 s limit, GPU sampled withnvidia-smievery 2 s. One run with the budget; the comparison run is the same tree without this PR (without the variable this PR leaves the HLSL unchanged).maintree)XCL_LOOP_BUDGET=4096ListX #101#101GPU queue.Wait … did not complete within 5000 ms0x887A0006(hung) at 168.5 s0xC0000005at+0x4e8b4be(read at -1, about ten threads at once) at 241.3 sWith the budget, the title limps on at about 1 present and 40-60 submissions per 2 s for ~110 s after the point where the tree without it hangs, and the GPU keeps coming back between bursts. That fits the reading on #505 that the stop is loops running long on data a skipped dispatch never wrote. The title then faults at
+0x4e8b4be, which I haven't seen in any other run on this machine; it may be what a capped loop leaves behind.Not tested: other budgets (4096 only); more than one run; without
XCL_PSO_WAIT_MS; AMD.AI use: Claude Code (Claude Opus 5.5) ran the runs on my machine through a scripted runner and wrote this report.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:32:09Z.
Rebased onto
main20cf130(now0b28a6b). One conflict inrecomp/mod.rs: #1307'sSTRUCTURED_BYTES_PER_CODE_BYTElanded next toloop_budget; both are kept, unchanged. RTX 3070, driver 616.56: tests matchingloop_budget/loop, 23 passed, 0 failed, with and withoutXCL_DIRECT_DXIL=1.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:39:58Z.
The rebase onto
20cf130moved the head to0b28a6b, so thePR descriptioncheck now wants the Regression-run pair made on that head. The pair in the description (Kalmarv's, thanks) is for3980a81. The rebase changed only the conflict lines inrecomp/mod.rs;loop_budgetis untouched and the suite passes. I can't make a smoke run here (no title). If someone with one has a minute, ascripts/smoke.ps1pair ofmain20cf130and0b28a6bwould clear it, and I'll paste it in with credit.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T23:45:48Z.
@upipibi on it: a
scripts/smoke.ps1pair ofmain20cf130and0b28a6bon an RTX 5070 Ti is queued behind a run that's using the GPU now. I'll post both blocks here within the hour.AI use: Claude Code (Claude Opus 5.5) wrote this.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-25T00:03:25Z.
@upipibi here is the pair.
scripts/smoke.ps1, the same retail title for 60 s each, one after the other, release builds from clean trees. RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200. A separate NVIDIA driver build was running in another process during both runs.main20cf130:#1284
0b28a6b:1289 / 1279 frames (101 %), peak commit 27396 / 26967 MB (102 %), no device removal or crash on either run. No out-of-memory or exception lines in either log.
AI use: Claude Code (Claude Opus 5.5) ran the pair and wrote this.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:00:46Z.
XCL PR #1284 — Intel Arc A770 loop budget compatibility
Tested
81745f8d18. GitHub showed the PR open at that head before and after the run. I checked the seven existing comments and found no Arc report for this head. PR #1284Commands
Process environment for both commands (XCL_LOOP_BUDGET unset).
Prebuilt the library test executable outside the Arc lock (Cargo reported 1m 02s).
Exact test arguments for the Cargo-reported executable.
The GPU command ran in a child Windows PowerShell with -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -EncodedCommand, with the test executable path passed through XCL_PR1284_LIBTEST_EXE. RemoteSigned applied to that process only. The machine policy was unchanged.
Logs beside this report include prebuild.log, prebuild.jsonl, parser.stdout.log, parser.stderr.log, gpu.stdout.log, gpu.stderr.log, and run-status.log.
Not tested
AI use
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T12:14:30Z.
Here is the requested pair from the stock
scripts/smoke.ps1on clean release builds of main 1a0bbe3 and PR head f3eb053.RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC. Both runs used separate copies of the same starting profile and DXIL cache seed, networking and PSO preload off, a 16 GiB job commit cap, and a 12 GiB system commit floor.
XCL_LOOP_BUDGETwas unset and no input was sent. Both runs completed normally.This checks the default startup path. World load and the non-default loop budget were outside these runs.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the smoke pair and drafted this report.
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T13:26:49Z.
Update for head
998dda8(onmaine429936):cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture, head againstmain, card picked withXCL_ADAPTER:main: the #2115 fuzz seeds, the five from #3093 andgpu_ps_readfirstlane_loop_on_a_primitive), 6 SKIPPED.main), 24 SKIPPED.gpu_loop_budget_caps_a_loopandloop_budget_reads_a_whole_number_from_one, both ok.With
XCL_LOOP_BUDGET=4096set for the whole run, there's one more failure on both cards:console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(pso.rs:2420, cacheentries.len()0, expected 1). It also fails withXCL_LOOP_BUDGET=1. That looks expected rather than a bug: this PR addsXCL_LOOP_BUDGETtocache_allowed's bypass list, and the test reads the real environment.mainfails the same test the same way withXCL_SAFE_BARRIER=1(checked on the RX 9070 XT). So if anyone runs the suite with the variable set, that failure is the cache bypass doing its job.AMD run (listed as untested), plus an RTX 3060: the new GPU test passes on both.
Head
f3eb053applied onmain1a0bbe3, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_loop_budget_caps_a_loopok. 631 passed, 2 failed, 22 ignored, 6 SKIPPED; the 2 failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: a title with or without
XCL_LOOP_BUDGET, Wine.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
upstream-sync referenced this pull request2026-11-25 16:10:51 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:17:33Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T02:24:10Z.
Source-review note on the current #1284 diff:
XCL_LOOP_BUDGETchanges the HLSL prelude inrecomp/emit.rs, but the direct DXIL compute backend initializesVAR_BUDGETfrom its separate fixedLOOP_BUDGET = 1 << 16(gpu/dxil/lower.rs). A compute program routed through direct DXIL therefore still has the 65,536-iteration budget when this switch is set to 4,096; HLSL fallbacks use the requested value. The checked-in GPU test callstranslateand compiles its HLSL, so running that test withXCL_DIRECT_DXIL=1does not exercise the direct backend.This need not expand this diagnostic PR. I suggest stating the HLSL-only scope in its description/README and, if the switch is intended to govern all routes, covering the direct path separately with a test that enters through production backend selection and checks a non-default value. #2769 adds the default loop guard to the per-lane path; it does not make the value configurable.
AI use: OpenAI Codex (GPT-6.2 Sol) traced the current source and drafted this note. No runtime measurement is claimed.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:30:36Z.
merge-check claim
head:
f3eb053f93Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:45:21Z.
merge-check
base:
753e8b1ahead:
f3eb053f93merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1514 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: no blocking finding. Opt-in: with the variable unset the generated HLSL is byte-identical, and when it is set the cache is skipped. Scope, open from the thread: it covers the HLSL path only; the direct-DXIL path keeps its own constant, so the description and README should say so (the README does not document the variable yet). Style: one unindented line and a raw newline inside a string literal in tests.rs. With #2793 (safe from my side): no textual conflict, but one in meaning: #2793's loop guard and translate pass a fixed budget to its helper region_budget_limits, so programs with two or more loop regions would reset the budget per region and ignore this variable. Whichever of the two lands second must pass the configured budget to that helper in both places.
performance: no default cost (one env read per translation). It changes translator sources: every tester re-translates all shaders once.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-28T08:50:59Z.
@thehollowedone @throny Thanks, both right. The description now says the switch covers the HLSL path only, so direct-DXIL programs keep
dxil::lower::LOOP_BUDGET(lower.rs:36). It also notes the meaning conflict with #2793 for whichever of the two lands second. I'm leaving the head as is, since a new commit would drop the existing smoke pair.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-28T10:38:53Z.
@thehollowedone @throny Correction to my note above: the head did move after all. The branch conflicted with
main(XCL_SAFE_BARRIERwas added to the same two lists inpso.rs), so it couldn't merge as it was. It's now998dda8one429936c, with both entries kept. On the RTX 3070,cargo test -p xcl --lib -- --test-threads=4gives 1997 passed, 6 failed, 28 ignored, against 1995 / 6 / 28 onmain, with the same 6 failures (#3093). This PR's tests pass. The old smoke pair is for the previous head, so this one needs a new pair.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:19:56Z.
Triage (#1607) – head
998dda8No open or merged PR adds this variable. #2793 (per-region loop budgets) and #2769 (LOOP_BUDGET at loop headers in per-lane lowering) work on the same guard, and #2793 refers to this PR's
XCL_LOOP_BUDGETas the value to pass to its region budgets. They complement each other, not duplicates.No problems found in the logic: the default leaves the prelude, and so the HLSL and the cache key, unchanged, and
cache_allowedbypasses the cache when the variable is set. In tests.rs,let mut stingpu_loop_budget_caps_a_looplost its indentation.The
Build and testcheck failed on the last run, and the branch conflicts with main; it needs a rebase and a green run.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 Foniass on 2026-12-03T17:17:04Z.
Follow-up review of
8fc28165, since998dda8(code reading only, not a merge-check;PR descriptionred) · 2 mediumIn short: Rebased onto
maine99b0bd. The indentation nit from the earlier triage is fixed. The rest of the range-diff is the doc comment on the loop guard, merged with the per-dispatch loop budgetmaingained meanwhile. The logic is unchanged and still right for the HLSL path. But the direct-DXIL backend is now the default, and it keeps its own fixed budget, soXCL_LOOP_BUDGETno longer reaches most programs. The description says so.Medium
On the default backend,
XCL_LOOP_BUDGETdoes nothing.VAR_BUDGETfrom the fixeddxil::lower::LOOP_BUDGET(65 536). The guard indxil/kernel.rs~581 never readsloop_budget(). That backend is now the default.XCL_DIRECT_DXIL=0is also set. A user who sets it and sees no change cannot tell that.Either make the direct path start its budget from
loop_budget(), keeping the cache bypasspso::cache_allowedalready gives the variable, or log once when the variable is set while the direct backend is on.The whole workspace is not reported on this head. Tested gives
cargo test -p xcl --libon8fc28165(2865 passed, 0 failed, 37 ignored). CONTRIBUTING.md asks forcargo test --workspace -- --test-threads=4on the head under review.Checked and fine
let mut stingpu_loop_budget_caps_a_loopis indented again.xcl_budget(XCL_LOOP_BUDGETor 65 536), and the per-entrydispatch_loop_budgetthatmainadded for compute loops.dispatch_loop_budgetis untouched, and the two are independent.static uint xcl_budget = 1u << 16;, so the HLSL and its cache key are as onmain. The test checks that line.XCL_LOOP_BUDGETis in bothpso.rslists next toXCL_SAFE_BARRIER, so a translation made with it set is neither cached nor loaded.main.Written by Claude Code (Claude Opus 5.5) and 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.