Recompiler: signal Partner::Spin exit bit (0x4000_0000) in @xcl.spin.wait #3652
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3652"
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 Kalmarv on 2026-12-02T03:49:46Z.
Prevent GPU stalls in direct-DXIL split-wave64 compute/mesh shaders when one hardware half exits early while its partner enters a
Partner::Spinexchange.When one half exits early, its partner previously polled
@xcl.spin.waitfor the full1 << 20(1,048,576) live-partner cap before timing out. This PR signals bit 30 (0x4000_0000,EXITED) on the departing half's counter so the partner bails out immediately on the first poll after exit, while keepingmain's1 << 20live-partner poll cap and leavingbarrier_arrive/safe_barrier_syncuntouched.What is in it
crates/xcl/src/gpu/dxil/module.rs(Module::spin_wait): in@xcl.spin.wait, check(c & 0x3FFF_FFFF) >= needbefore inspecting bit 30 (0x4000_0000) so a convergent partner exiting immediately after its final exchange never corrupts a valid rendezvous; bail immediately to the fail-markingcmpxchgwhen bit 30 is observed with(c & 0x3FFF_FFFF) < need; reject bits 30..31 in the entry bounds check. The live-partner poll cap stays1 << 20(1048576), andbarrier_arriveis unchanged.crates/xcl/src/gpu/dxil/lanes.rs,lower.rs,kernel.rs: addLw::spin_exchange_exit()(called at programtailright aftersafe_barrier_exit()), reusinghas_spin_exchangeandspin_basesfrom#3655. Guarded bycompute_gate's entry predicate (spin_entered) so out-of-limit lanes cannot signal exit while active lanes in the same hardware wave are still running under Independent Thread Scheduling. Updateslanes.rscomments to note this is direct DXIL only (the HLSLrecomp::emitxcl_x_meetpath is separate).crates/xcl/src/gpu/dxil/module/split.rs: allowRmwOp::Oronxcl_xcalongsideRmwOp::Addso split-wave64 compute shaders withspin_exchange_exit()keep dispatch-chain splitting.crates/xcl/src/gpu/dxil/lanes.rs,core_tests.rs: add GPU testgpu_spin_exchange_early_exit_bails_immediatelycovering (1) divergent early-exit bailout (0.0038 msmedian across 256 groups vs31.1890 mswhenspin_exchange_exitis removed — verified to fail without the exit bit — plus IR checks forCOUNT_MASK,EXITED, and the1 << 20cap), (2) convergenttranslate_computeV_READLANE_B32+ immediate exit, and (3) thespin_enteredITS guard under partialIO_THREAD_LIMIT = 112(16 active + 16 out-of-limit lanes in wave 3, 64-iteration scalar delay loop, 8 iterations). Updatecore_tests.rssplit_lds_reads_meet_after_writesfor the singleatomicrmw or.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC1.9.2609.5, debug tests + release build (cargo build --release -p xcl: 39 warnings, 0 new vsmainbaseline of 39).scripts/test.ps1(workspace build,cargo bench -p xcl --bench '*' -- --test,cargo test --workspace -- --test-threads=4): 2975 passed, 0 failed, 52 ignored across 43 targets; 24 SKIPPED GPU tests (22no wave64, 2no heap windows).cargo test -p xcl --lib gpu_spin_exchange_early_exit_bails_immediately -- --nocapture: passed (SPIN_EARLY_EXIT256 groups median0.0038 ms; temporarily removinglw.spin_exchange_exit()in Case 1 failed at31.1890 ms > 2.0 ms).Regression run
main:
PR:
(Note: the first smoke run after changing
crates/xcl/src/gpu/dxil/*hit a cold shader cache due toXCL_DIRECT_DXIL_SOURCE_ID— 1316 frames, 0 removals, 0 crashes; the PR block above is the second warm run matching the warmmainbaseline.)Not tested
22 SKIPPED), heap-window GPU tests (2 SKIPPED), HLSLrecomp::emit(xcl_x_meet) path (left untouched and out of scope for this direct-DXIL PR), in-world title gameplay beyond the 60 s smoke, Wine/Linux, and game-data sample tests (XCL_SAMPLE_*unset).AI use
origin/main(5eaadb54c, including#3655), ported only the bit-30EXITEDsignal into@xcl.spin.waitwhile restoring the1 << 20live-partner cap and dropping the barrier cap change, allowedRmwOp::Oronxcl_xcinmodule/split.rs, strengthenedgpu_spin_exchange_early_exit_bails_immediately(including thespin_enteredtest and without-exit-bit failure verification), ran the build/test/smoke suite, and updated this PR description.Imported from ivall/xcl. Originally posted by SavageCore on 2026-12-02T04:30:49Z.
Review: COMMENTED
Comment (not blocking, needs CI confirm): spin-exchange EXIT bit (0x40000000) + timeout caps address GPU hangs in the right place, and arrived-before-EXITED ordering looks right. Concerns before merge: (1) caps 1<<20->1<<12 (spin) / ->1<<16 (barrier) are aggressive - premature timeout on loaded slow-partner rendezvous vs TDR tradeoff not quantified. (2) Exit signal only wired at normal tail - S_BARRIER-leave / loop-budget early-outs bypass it, leaving spin-to-timeout. spin_entered==None fallback is unguarded. (3) CI shows one success (04:05:59) and one prior failure (03:50:00) on Build and test - confirm failure was prior push/flake; get_status is pending.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T04:36:59Z.
Thanks for the review @SavageCore! Addressing each point directly against the current code:
Timeout caps (
1 << 12spin /1 << 16safe-barrier):EXITEDsignaling, divergent early exits no longer hit the timeout path at all (they bail on the first poll after exit;0.0017 msmedian for 256 groups ingpu_spin_exchange_early_exit_bails_immediately).4096serialized LDSatomicrmwiterations for a cross-half exchange (spin_exchange) and65536iterations for a multi-wave workgroup barrier (safe_barrier_sync) are sized to leave room for a live co-scheduled partner while cutting worst-case runaway stall duration by 256x / 16x vs1 << 20(which can trip the 2 s Windows TDR across dense dispatches).1 << 14= 16384 forspin_exchangenow that bit 30 handles early exits immediately), I am happy to adjust and re-verify.Exit paths and
spin_entered == None:translate_on_this_threadroutes to the singleexit->tailblock (kernel.rs:596-600, right aftersafe_barrier_exit()):Term::End(S_ENDPGM): branches toend == exit(kernel.rs:517, 569).VAR_LOOP_PASSES): branches toend == exit(kernel.rs:528-530).VAR_BUDGET): branches toend == exit(kernel.rs:540-543).compact::emit/emit_with_nest): bothS_ENDPGMandVAR_BUDGETbranch toexit(compact.rs:976, 992).compute_gate(S_BARRIER/leave):kernel.rs:483-486setslw.spin_entered = Some(runs)and branches toexit. WhenS_BARRIERis present (leave == false),compute_gatereturns group-uniformst.runs(kernel.rs:1233-1234), so either the entire group skips together (runs == false, nobody waits) or all lanes enter together (runs == true) and signalEXITEDattail. Whenleave == true, out-of-limit lanes haveruns == falseand are already excluded from the partner'sxnviast.partner_lanes, so guardingspin_exchange_exitonspin_enteredprevents them from setting bit 30 early under ITS while active lanes in the same warp are still executing.spin_entered == Noneonly occurs whengroup_runsisNone— forPartner::Spin, that is strictlyEntry::Mesh, which has nocompute_gate(every lane in the mesh threadgroup entersh0together).CI status:
03:49:53ZBuild and test (Windows, no GPU)failure (job143202141589) on the same commit032557e79was an unrelated runner flake (xcl.exehit0xc0000005insideD3D12Core.dllduringgpu::dxil::compact_tests::gpu_compact_form_runs_as_the_plain_formright aftereh::tests::the_process_ends_while_another_thread_holds_the_heap, beforecore_testsorlanestests started).032557e79via close/reopen passed cleanly (job143205667464), and all 5 latest check-runs (Build and test (Windows, no GPU),PR description,triage,mirror,publish) arecompleted / success. (The legacy commit/statusendpoint reportspendingwithstatuses: []because this repo uses Actions check-runs.)Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T08:08:40Z.
merge-check
base:
1c8b551475head:
032557e79bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same tests as on the base (2909 passed there); failing: none.
gpu_spin_exchange_early_exit_bails_immediatelyran and passed on this wave32 adapter.review: whole diff read. One point that blocks for me. (1) The exit bit is sound as far as I can see: the count is compared under
COUNT_MASKbefore bit 30 is looked at, and a half's own counter cannot carry the bit before its own exit. (2) Separately from the exit bit, the wait for a partner that has NOT exited drops from1 << 20to1 << 12polls (andsafe_barrier_syncfrom1 << 20to1 << 16). A timed-out half marks the partner's counter, and from then on both halves stop consuming exchanged values for the rest of the dispatch (they read zeros). So a partner half that is alive but late (scheduled later, or in a long stretch before its next exchange) now fails the exchange 256 times sooner, and that shows as wrong output, not as a hang. The new test covers a partner that exited and a pair that meets at once; nothing covers a live partner that arrives late, and the 60 s smoke does not reach a title's world, where split wave64 programs with long bodies run (on this card several of them take 10 to 20 ms a dispatch). The exit bit alone already removes the long spin in the case the PR describes.performance: no cost by default in the 60 s smoke: base 1608 frames, peak commit 19911 MB; merged tree 1696 frames, 18123 MB (91 %), presents 60 60 61, 0 device removals, 0 crashes. Not measured: a title's world (the change retranslates every split program, which is a cold shader cache of well over 25 minutes here; I did not run it).
verdict: not yet: the lower poll caps for a live partner are an unmeasured correctness risk; either keep
1 << 20for a partner that has not exited (the exit bit gives the early bail-out), or show with a late-partner test or an in-world comparison that 4096 polls are enough.hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0 / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:07:30Z.
Review (head
032557e7, diff read, not a merge-check):crates/xcl/src/gpu/dxil/lanes.rs ~547drops the wait from 2^20 to 4096 polls for every exchange, including ones where the partner has not exited. When the cap runs out, the half marks the partner's counter FAIL. Both halves then setVAR_XDEADand read 0 for every exchange until the dispatch ends, so the result is wrong output, not a hang. The exit bit already handles the case the description gives (a departed half), and nothing measures a slow live partner: the new test only covers a partner that exited and a pair that meets at once. Keeping 2^20 when the EXITED bit is clear would fix the early-exit case without this risk.safe_barrier_exitalready decrementsXCL_BAR_ALIVEwhen a wave leaves, so a departed wave never holdssafe_barrier_sync. The 2^16 cap atlanes.rs ~741therefore only cuts the wait for waves that are still running. A wave that times out goes past the barrier and setsVAR_BAR_ALIVEto 0, so it skips every later barrier and its LDS accesses are no longer synchronised. The description does not justify this cap and nothing measures it.crates/xcl/src/gpu/recomp/emit.rs ~6671(xcl_x_meet) and~6772(PRELUDE_SAFE_BARRIER) still poll 2^20 times and have no exit bit, yet the comments atlanes.rs ~439and~679still say the DXIL code matches them. A split program that goes through the HLSL path keeps the stall this PR fixes, and the same program now times out differently depending on which translator built it.med_ms < 2.0check (lanes.rs ~1484) would both pass. Only theatomicrmw orstring check notices if the exit bit is missing. Thespin_enteredguard is untested too, since case 2 runs every lane. A fixed 2 ms wall-clock limit also depends on the GPU.lanes.rs ~547,~741) with the opposite policy: it keeps 2^20 in programs that have a loop because there a wave can rightly wait for another wave's loop, and it covers the HLSL preludes as well. At most one of the two policies can land. #3655 replaces both loops withmodule::spin_wait/barrier_arrivehelpers (module.rs ~540, still 2^20) and has its ownhas_spin_exchange, so the exit bit would have to be rewritten inside that helper. #3667 changes the dispatch loop budget, a different layer, and does not conflict.Fine: the exit bit itself looks sound by reading. Arrival is compared under
COUNT_MASKbefore bit 30 is checked, so a partner that exits right after its last exchange does not break the meet. A half's own counter cannot carry bit 30 before that half exits. Every exit (S_ENDPGM, the loop-pass and budget caps, the compact form, the compute gate) goes throughtail, where the gate'srunsdominates. The entry bounds check now refuses bits 30 and 31.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:36:03Z.
merge-check
base:
1c8b551475head:
032557e79bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3652#issuecomment-7340412886 and its findings stand. Most serious: the 2^12 spin and 2^16 barrier caps also cut partners that are still running, giving silently wrong output.
performance: 60 s smoke of a retail title, main
1c8b5514vs this merge (032557e7): 1652 -> 1586 frames shown (96 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 15729 MB, 0 device removals, 0 crashes.verdict: not yet: the 2^12 spin and 2^16 barrier caps also cut partners that are still running, giving silently wrong output (see the review)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T14:55:34Z.
Thanks @vasanex, @Foniass, and @SavageCore for the thorough reviews and merge-checks! Rebased onto
origin/main(5eaadb54c, which includes merged#3655) and updated to4b77d6a70addressing every point:Restored
1 << 20live-partner poll cap and dropped barrier cap change (@vasanex,@Foniass,@SavageCore):EXITEDsignal (0x4000_0000) into#3655's shared@xcl.spin.waithelper (crates/xcl/src/gpu/dxil/module.rs), keepinglimit = 1 << 20unchanged for partners that have not exited.safe_barrier_sync/barrier_arrive2^16cap change completely (barrier_arriveandsafe_barrier_syncare untouched).RmwOp::Oronxcl_xcincrates/xcl/src/gpu/dxil/module/split.rsso split-wave64 compute shaders usingspin_exchange_exit()keep dispatch-chain splitting.Honest
lanes.rscomments on HLSL scope (@Foniass):exchange_spin/spin_exchange_exitdoc comments inlanes.rsto state clearly that bit-30 exit signaling is direct DXIL only and that the HLSLrecomp::emitxcl_x_meetpath is separate (not claiming parity with HLSL).Strengthened GPU test + without-exit-bit failure check +
spin_enteredcoverage (@Foniass,@SavageCore):1 << 20restored, verified Case 1 genuinely fails withoutspin_exchange_exit(): temporarily disablinglw.spin_exchange_exit()in Case 1 made the 256-group divergent dispatch stall to31.1890 msmedian (failing the< 2.0 msassertion by >15x), vs0.0038 msmedian with bit-30 exit signaling (~8,200x faster).COUNT_MASK(0x3FFF_FFFF),EXITED(0x4000_0000), and the1 << 20live-partner cap (1048576) inside@xcl.spin.wait.spin_enteredITS guard under partialIO_THREAD_LIMIT[0] = 112on a 128-thread group (wave 3 has 16 active + 16 out-of-limit lanes, 64-iteration scalar delay loop beforeV_READLANE_B32lane 32, 8 iterations verifying0..63 -> 0x1020,64..111 -> 0x1060,112..127 -> 0).Verification on
4b77d6a70(RTX 5070 Ti, driver 610.74,rustc 1.99.0, DXC1.9.2609.5):cargo build --release -p xcl: 39 warnings (0 new vsmain5eaadb54c).scripts/test.ps1:2975 passed, 0 failed, 52 ignoredacross 43 targets;24 SKIPPED(22 no wave64,2 no heap windows).title: ea3b5e4d):5eaadb54c1698frames (60 61 60,15798 MB) vs4b77d6a701672frames (62 60 60,16344 MB),0device removals,0crashes,exit: 0x0.python scripts/pr_check.py --local:description ok.Ready for re-review! (Updated and verified with Antigravity, Gemini 4 Neon.)
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T15:04:03Z.
merge-check
base:
5eaadb54c1head:
4b77d6a701merge: clean (
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2975 passed, 0 failed, 52 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same tests as on the base (2974 passed there); failing: none. The new GPU test
gpu_spin_exchange_early_exit_bails_immediatelyran on this card (wave32) and passed, and so did the editedsplit_lds_reads_meet_after_writes.review: whole diff read (6 files, +182/-14). The blocker of my check of
032557e7is gone:@xcl.spin.waitkeeps1 << 20polls for a partner that has not exited, and the barrier waits are untouched. No finding in the new head. Checked by reading: the wait tests the arrived count under the 30-bit mask before it looks at the exit bit, so a partner that leaves right after its last exchange still gives a valid meeting; on a seen exit bit the half goes through the same compare-exchange as a timeout and polls again when the partner's counter moved meanwhile; the own-counter guard now refuses bits 30 and 31, which only stops a half that has itself left; the exit bit is set once per half (first lane) and only by lanes that passed the launch gate (spin_entered), which the test's third case covers;split.rslets theoronxcl_xcthrough so such programs still split. The comments now say that the HLSL path does not signal the exit. Not covered by anything here: wave64 hardware, and a program in a title that reaches a divergent exit.performance: one atomic
orper half at program exit, and a faster bail-out where a partner has left. 60 s smoke, release, same title and settings: base 1697 frames, peak commit 17749 MB; merged tree 1685 frames, 17859 MB (101 %), presents 60 60 60, 0 device removals, 0 crashes. The smoke's title did not visibly depend on the path either way.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0 / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:02:19Z.
merge-check
base:
5eaadb54c1head:
4b77d6a701merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2975 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: follow-up on
4b77d6a7(reworked and rebased from032557e7, my last review's head). Rebased onto main5eaadb54(which has #3655): the exit bit moved intoModule::spin_waitand the live-partner cap is back to 1 << 20 (module.rs~566-630); the barrier cap is gone andbarrier_arriveis untouched;spin_exchange_exitruns at the program tail right aftersafe_barrier_exit(kernel.rs~642,lanes.rs~663), guarded by the newspin_entered(compute_gate'sruns,kernel.rs~527);module/split.rs~194 now acceptsRmwOp::Oronxcl_xc; the test has three cases (lanes.rs~1438-1547). Earlier findings: (1) the 2^12 cap cutting a live but late partner: fixed; the cap is 1 << 20 again and a partner is cut short only when bit 30 is set. (2) the unrelated barrier cap: fixed (dropped). (3) the HLSL translator: partly fixed; the comments now say the exit bit is direct DXIL only, butemit.rsxcl_x_meethas no exit bit, so a split program built through the HLSL path still waits the full 2^20 polls when one half exits early. (4) the test not proving the exit bit: mostly fixed; with the 2^20 cap, case 1 stalls without the exit bit (31.19 ms against 0.0038 ms) and case 2 checks a convergent exchange followed by an immediate exit; the 2 ms wall-clock limit (~1488) depends on the GPU, with a large margin. (5) overlaps: #3655 is merged and the exit bit sits in its helper; open #3668 targets the samelimitin@xcl.spin.wait, so whichever lands second needs a rebase there, but the policies no longer contradict. New: the one-linesplit.rs~194 change is untested; every translated split-wave64 compute program with a spin exchange now carries the newatomicrmw or, and without that linesplit_computewould silently stop building dispatch chains for them, but no test translates such a program and checks a chain is still built. Case 3 (thespin_enteredguard withIO_THREAD_LIMIT= 112) isn't shown to fail without the guard. Fine: the arrival count is compared underCOUNT_MASKbefore bit 30 is read; a peer setting bit 30 between a timeout poll and the cmpxchg goes throughracedand fails correctly; the fallback own-counter pointer matchesexchange_bases(self.half);runsdominates the tail; a half entirely past the thread limit gives its partnerxnfrompartner_lanes, so it doesn't wait; geometry phases end with a partner other than Spin, so they don't signal. One logical change of about 180 lines, most of them test.performance: 60 s smoke of a retail title, main
5eaadb54vs this merge (4b77d6a7): 1422 -> 1440 frames shown (101 %; last presents per 2 s: 61 60 60), peak commit 17184 -> 16116 MB, 0 device removals, 0 crashes. This run is lower than most today: the PC was in use at the time (a browser and Discord running), and main's own runs on this machine today ranged from 1370 to 1652 frames, so the difference isn't clearly from this PR.verdict: safe to merge: no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:39:38Z.
Code review location:
crates/xcl/src/gpu/dxil/lanes.rs; line 684Medium: Not certain about this one, because it depends on ITS scheduling: the
spin_enteredguard excludes only compute_gate's out-of-limit lanes, and the exit signal still comes fromwave_is_first_lane()among whichever entered lanes reachtailfirst. So a hardware wave whose entered lanes haven't reconverged attailcan publish EXITED while other lanes of that half are still running. On NVIDIA ITS, the non-leader lanes of@xcl.spin.waitbranch straight toexitand can run ahead, as can lanes split by per-lane guarded regions. If they OR 0x4000_0000 into this half's counter while the half still has exchanges to do, the partner's next exchange fails at once, VAR_XDEAD latches, and every later exchange returns 0 instead of the real value. Signalling only when all entered lanes are present (wave_all_bit_countagainst the entered-lane count taken at entry) would remove the dependence.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:39:38Z.
Review: COMMENTED
Review of
4b77d6a7: 2 finding(s) (2 medium), most severe first.crates/xcl/src/gpu/dxil/lanes.rs:684: Not certain about this one, because it depends on ITS scheduling: thespin_enteredguard excludes only compute_gate's out-of-limit lanes, and the exit signal still comes fromwave_is_first_lane()among whichever entered lanes reach `.... (inline)crates/xcl/src/gpu/dxil/module.rs:597: The entry bounds check now rejects bit 30 as well as bit 31 inold | after | need, which halves the counter's headroom: an exchange fails once epoch*partners or the own count reaches 2^30 instead of 2^31. (inline)These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:39:39Z.
Code review location:
crates/xcl/src/gpu/dxil/module.rs; line 597Medium: The entry bounds check now rejects bit 30 as well as bit 31 in
old | after | need, which halves the counter's headroom: an exchange fails once epoch*partners or the own count reaches 2^30 instead of 2^31. A 32-lane half in a loop with many exchanges per iteration (VAR_XK counts every exchange the program runs) gets bit 30 set inneedafter about 2^25 exchanges, takesbadwith no peer exit or timeout, latches VAR_XDEAD and returns 0 from every later exchange. Before this PR the limit was twice as high. Masking bit 30 out of the bounds check (it's checked separately as EXITED) would keep the old headroom.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T18:39:40Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T18:47:46Z.
Thanks for checking
4b77d6a7@bmjask! Checked both automated findings against the implementation — both are non-issues, so4b77d6a7does not need changes:lanes.rs:684(spin_entered/ ITS scheduling):@xcl.spin.wait(module.rs:590, 633-636), non-leader lanes branch to the helper's internalexitmerge block (not programtail), wheredx.op.waveReadLaneFirstimmediately broadcasts the leader's result (SHFL.SYNCon NVIDIA) before the trailingTGSM_FENCE; non-leader lanes cannot run ahead of the leader out of@xcl.spin.waitto programtail.S_CBRANCH_*),VAR_LOOP_PASSES, andVAR_BUDGETare wave-uniform across the entered lanes of a 32-lane half, and per-laneguarded(...)regions reconverge locally without branching to programtail. Onlycompute_gatebranches per-lane to programexit -> tail, whichspin_enteredguards (matchingsafe_barrier_exit()right above atlanes.rs:721).wave_all_bit_count == entered_countattailwould drop the exit signal entirely if lanes ever arrived unsynchronized (neither subset would equalentered_count).module.rs:597(rejecting bit 30 inold | after | need):0xC000_0000) is required for soundness because bit 30 isEXITED(0x4000_0000): masking bit 30 out would letowncarry into bit 30 while alive (spontaneously settingEXITEDand wrappingc & 0x3FFF_FFFFto 0) and letneed >= 0x4000_0000become unsatisfiable against the 30-bitarrived = c & 0x3FFF_FFFF.2^25(~33.5M) exchanges for a 32-lane half, which is far beyondLOOP_BUDGET(1 << 16= 65,536 iterations inlower.rs:45).(Checked and drafted with Antigravity, Gemini 4 Neon; no code changed on
4b77d6a70, so bothverdict: safe to mergechecks from@vasanexand@Foniassremain current for @Prime1997.)Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T21:42:20Z.
merge-check
base:
5ad98adbc3head:
4b77d6a701merge: clean (merge commit 7762c81f9c2e80495e706eda18a23f600dd152e8;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; SKIPPED: 24 (22 no wave64, 2 no heap windows); failing: none
title run: Newer Retail Game, release build of this merge, Series S settings (
XCL_DEVICE_TYPE=lockhart,XCL_COHERENT_MB=512,XCL_UMA_WINDOWS=16,XCL_SPARSE_LAZY=1), scripted A presses, 240 s planned: into the world at 92 s, 147 s there with no frame presented (as in main's first run), no crash, no device removal; ran to the 240 s limit.review: none found that blocks. Nit: the GPU test asserts a median under 2.0 ms of wall-clock time, which could flake on a loaded GPU.
performance: one extra groupshared atomic per spin kernel; the wait loop can now leave early when the partner has exited. World frame rate not compared: on this 32 GB PC the runs of main and of the PRs end 30 to 150 s into the world (RAM guard or time limit).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26300 / Claude Code with Claude Opus 5.5
Same settings on main
5ad98adb, two runs: into the world at 94 s with 145 s there and no frame presented (ran to the 240 s limit); into the world at 80 s with 59 s there and 90 frames, then stopped by our RAM guard (free RAM under 1 GB). "In the world" here means the first 2 s window of the activity log with 5,000+ draws and dispatches.AI use: Claude Code (Claude Opus 5.5) ran the build, tests and title runs and wrote this; a Claude Sonnet subagent read the diff and I checked its points.
~Tiago