Repository navigation
Conversation
A lane may run 65 536 loop passes before LOOP_GUARD ends its loops, so that console code looping on a count XCL gave it wrong does not keep the GPU busy for minutes. That bound is per lane: the work it allows grows with the dispatch, and a large dispatch outlasts the 2 s Windows waits before it removes the device. WindNew:CS_AdvectFromParentStep (a542b07e605c8fd7, 4 x 4 x 4 threads) is dispatched as 16 x 16 x 16 groups and loops while a counter differs from a count in title memory. Run alone on an RTX 3060 Ti with synthetic inputs, the translated program takes 1.0 ms with a count of 0, 6.7 ms with 64, 25 ms with 256 – and with a count that never comes 111 ms when the loop is ended after 256 passes and 485 ms after 1024 (0.47 ms a pass), which is 31 s for 65 536. That is the dispatch left open when the device was removed (xcl-dev#1452). A compute dispatch whose group counts are known now passes its share of 2^28 loop passes for one group in a free io slot (IO_LOOP_BUDGET), and in a compute program every entry of a loop has its own count of passes: that share among the group's threads, between 1024 and 65 536 a lane. Up to 4096 lanes nothing changes; at 16 x 16 x 16 groups of 64 threads one entry of a loop ends after 1024 passes. The lane's budget of 65 536 for all its loops stays, so loops inside one another are not cut to one loop's share: only a loop that runs away on its own is ended early. A slot of 0 (an indirect dispatch, the test runner) leaves 65 536, and programs without a loop, other stages and the direct translator emit what they did. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@Prime1997 A heads-up from our #1284 (
If the upper bound of the clamp (and AI-assisted (Claude Code). Read from the two diffs only; nothing run. |
|
AMD targeted tests on clean head
No SKIPPED messages. The first is the small single-group GPU fixture covering wave32 and wave64 program options and the different loop limits; the other two are CPU checks. 60 s retail smoke comparison: clean release builds; PR run first, then main. Same title, Main: PR: Not tested: the large wind dispatch, progression past the loading hang, full workspace, or a controlled cache/profile comparison. Repeat after main: Same settings and no reset; PR/main/PR run order. The repeated PR run showed 1577 frames, compared with 1556 on main. This makes the first result non-reproducible in this sequence but does not identify its cause. AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the tests and smoke pair and drafted this report. |
|
AMD RDNA3 (native wave64) test report for exact head Tested
Not tested
AI use: Claude Code (Claude Sonnet 5.5) ran the build and tests and wrote this report; the numbers are from the runs above. |
|
@upipibi agreed, and thanks for reading both diffs. The two compose the way you describe: the cap's default and the clamp's upper bound are the prelude's literal 65 536 only because Thanks @Lum7nt, @oni-swr and @nnonno91 for the runs on AMD (native wave64 included) and the boundary cases at 1024 / 1025 passes. Two updates from my side:
AI use: Claude Code (Claude Fable 5.2) wrote this and ran the measurements on Prime's machine. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Independent synthetic RTX 3080 Ti check of #2291 head The fixture launches only one group and supplies the slot value that production calculates for a 16×16×16-group, 64-thread dispatch. It verifies the per-lane HLSL behavior without making a large dispatch or claiming a title result. This demonstrates a valid finite loop can silently produce a different output under the new default cap. The existing endless-loop test proves the cutoff works, but cannot establish output parity for valid counts above it. I would keep the dispatch-sized cutoff out of the default correctness path. For the reported world-load hang, #2205 can help trace the count passed to the affected dispatch; the value the GPU actually consumes and its producer ordering still need verification. A general threshold cannot distinguish stale input from a valid long loop. Current-main integration, the full suite and clean-head smoke still need rechecking. Failing PR-head GPU regression (passes on its parent with slot 113 = 65,536)diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 3433d5f8..1df211d9 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -7306,6 +7306,37 @@ fn gpu_compute_loop_passes_follow_the_dispatch() {
}
}
+/// A finite console loop must finish at its own exit, even when dispatched in many groups.
+#[test]
+fn gpu_finite_loop_keeps_its_result_above_the_dispatch_share() {
+ if !gpu_ready() {
+ return;
+ }
+ let p = prog(&[
+ ("S_MOV_B32", "ENC_SOP1", &[("SDST", 11), ("SSRC0", 255)], Some(1025)),
+ ("S_MOV_B32", "ENC_SOP1", &[("SDST", 10), ("SSRC0", 128)], None),
+ ("S_ADD_U32", "ENC_SOP2", &[("SDST", 10), ("SSRC0", 10), ("SSRC1", 129)], None),
+ ("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 10), ("SSRC1", 11)], None),
+ ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFD)], None),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 4), ("SRC0", 10)], None),
+ ("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 6), ("SRC0", 130), ("VSRC1", 0)], None),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 7), ("SRC0", 128)], None),
+ ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 6), ("DATA", 4), ("SADDR", 0x7D)], None),
+ ]);
+ let cs = super::CsInterface { threads: [64, 1, 1], user_sgprs: 2, tgid: [false; 3], tg_size: false, tid_components: 1 };
+ let opt = on_gpu(Options { mode: Mode::Compute(cs), wave64: false, ..Default::default() });
+ let t = translate(&p, &opt).unwrap();
+ assert!(t.complete(), "{:?}", t.unsupported_why);
+ let dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap();
+ let mut io = [0u32; 128];
+ let input = vec![0xffff_ffff; 64];
+ let uncapped = runner::dispatch(&dxil, [1, 1, 1], &io, &input).unwrap();
+ assert_eq!(uncapped[0], 1025, "control: finite loop exits by its own count");
+ io[super::IO_LOOP_BUDGET] = super::dispatch_loop_budget([16, 16, 16]);
+ let capped = runner::dispatch(&dxil, [1, 1, 1], &io, &input).unwrap();
+ assert_eq!(capped[0], 1025, "the dispatch size must not truncate a finite loop");
+}
+
/// v_fract_f32 at the edges, as RDNA computes it (x - floor(x) kept below 1.0): ±inf gives
/// NaN and a NaN stays NaN – a `min()` clamp returned 0.99999994 there on NVIDIA (HLSL min
/// returns its non-NaN operand); a tiny negative value rounds to the largest float below 1.AI use: Codex (GPT-6.2 Sol) built and ran both GPU checks and wrote this report; Codex (GPT-6.2 Astra) independently traced the loop-cap and dispatch paths. |
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head 4bad5056. Blocking semantic regression: the dispatch-size cap can terminate a valid finite loop before its expected 1,025th iteration in a 16×16×16 dispatch. The independent GPU fixture passed on the parent and failed on this head when the per-dispatch budget was active. A watchdog heuristic must not change a shader's correct result based on dispatch size. Please make the reduced cap opt-in/diagnostic or prove a safe bound for the affected program, and retain the finite-loop regression. This branch also conflicts with main. No local GPU run.
|
Review (head 4bad505, diff read, not a merge-check; it conflicts with main, so not built or run):
Fine: the per-entry counter leaves nested loops the lane's full budget, and indirect dispatches keep 65,536. Recommendation: close as superseded by 2536d2f. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Closing as superseded: this change is already on Two independent checks found this: Foniass's close list on #1607 and ours against current AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents. |
Requested by Prime · project thread
A lane may run 65 536 loop passes before
LOOP_GUARDends its loops, so that console code looping on a count XCL gave it wrong does not keep the GPU busy. The bound is per lane, so the work it allows grows with the dispatch:WindNew:CS_AdvectFromParentStep(a542b07e605c8fd7) runs as 16 x 16 x 16 groups of 64 threads, and with a loop count that never comes that is about 31 s on an RTX 3060 Ti, where Windows removes the device after 2 s (the open dispatch of #1452; measurements in this comment). With this change every entry of a loop in a compute program has its own count of passes that shrinks with the dispatch's size, so a loop that runs away on its own ends in time. Part of #1452.What is in it
crates/xcl/src/gpu/recomp/mod.rs:IO_LOOP_BUDGET(io slot 113, free in the trap-temp range),DISPATCH_LOOP_PASSES(2^28),dispatch_loop_budget(groups); the two loop emitters askEm::loop_guardfor what goes before a loop and at its top.crates/xcl/src/gpu/recomp/emit.rs:Em::loop_guard. In a compute program a loop getsuint xcl_nK = xcl_cap;before it andif (xcl_nK == 0u) break; xcl_nK--;in front of the existing guard; the entry point setsxcl_cap = clamp(slot / threads per group, 1024, 65536)when the slot is not 0. The lane's budget of 65 536 for all its loops stays, so loops inside one another are not cut to one loop's share. Other stages and programs without a loop emit the HLSL they did.crates/xcl/src/hle/d3d12x/bind.rs,console_list.rs: a direct dispatch writes its share (2^28 / groups) into the slot. An indirect dispatch leaves 0: 65 536 as before.crates/xcl/src/gpu/recomp/tests.rs:dispatch_loop_budget_shrinks_with_the_groups,only_compute_programs_with_a_loop_read_the_dispatch_loop_budget(no GPU),gpu_compute_loop_passes_follow_the_dispatch.Up to 4096 lanes nothing changes. At 16 x 16 x 16 groups of 64 threads one entry of a loop ends after 1024 passes.
Tested
cargo test -p xcl --lib -- gpu_compute_loop_passes_follow_the_dispatch dispatch_loop_budget_shrinks only_compute_programs_with_a_loop: 3 passed, 0 failed, no SKIPPED. The GPU test runs a loop that never ends as a wave32 and as a split wave64 program: it stops after 65 536 passes with the slot at 0, after 5000 and 1024 for shares of that size, and entered three times it runs 3 x 1024.cargo test --workspace -- --test-threads=4: 1157 passed, 0 failed, 46 ignored (SKIPPED GPU tests: 25 – 20 need 64-lane waves, 3 are cases the direct per-lane form refuses,heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows),pso_measurement_compiles_an_exact_synthetic_record(needs Windows Developer Mode)).Regression run
Seeded 60 s runs without input (the same copied profile and shader cache for each, release builds from clean checkouts of the two commits,
XCL_HEAP_WINDOWS=1 XCL_LAZY_PSO=1 XCL_LAZY_COMPUTE=1 XCL_PSO_PRELOAD=0 XCL_DXC_THREADS=2). The main run is from earlier the same day, not back to back.main:
PR:
Not tested
AI use
🤖 Generated with Claude Code