Repository navigation
Recompiler: signal Partner::Spin exit bit (0x4000_0000) in @xcl.spin.wait - #3652
Conversation
There was a problem hiding this comment.
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.
|
Thanks for the review @SavageCore! Addressing each point directly against the current code:
|
|
merge-check |
|
Review (head 032557e, diff read, not a merge-check):
Fine: the exit bit itself looks sound by reading. Arrival is compared under AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
…wait When one hardware half of a split-wave64 compute or mesh shader exits early while its partner enters a Partner::Spin exchange, the partner previously polled the full 1 << 20 live-partner cap before timing out. Port only the bit-30 EXITED signal (0x4000_0000) into @xcl.spin.wait while keeping main's 1 << 20 live-partner poll cap and leaving barrier_arrive / safe_barrier_sync untouched: - Emit Lw::spin_exchange_exit() at program tail (after safe_barrier_exit), guarded by compute_gate's entry predicate (spin_entered) so out-of-limit lanes cannot signal exit while active lanes in the same wave are still running under ITS. - In Module::spin_wait (@xcl.spin.wait), check (c & 0x3FFF_FFFF) >= need before inspecting bit 30 so a convergent partner exiting right after its final exchange never corrupts a valid rendezvous, and reject bits 30..31 in the entry bounds check. - Allow RmwOp::Or on xcl_xc in module/split.rs so split-wave64 compute shaders using spin_exchange_exit keep dispatch-chain splitting. - Add GPU test gpu_spin_exchange_early_exit_bails_immediately covering divergent early-exit bailout (0.0038 ms vs 31.1890 ms without the exit bit across 256 groups on RTX 5070 Ti), convergent exchange + exit, and the spin_entered guard under partial IO_THREAD_LIMIT. Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com>
032557e to
4b77d6a
Compare
|
Thanks @vasanex, @Foniass, and @SavageCore for the thorough reviews and merge-checks! Rebased onto
Ready for re-review! (Updated and verified with Antigravity, Gemini 4 Neon.) |
|
merge-check |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 4b77d6a7: 2 finding(s) (2 medium), most severe first.
- Medium
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) - Medium
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.
| Ok(()) | ||
| }) | ||
| }; | ||
| if let Some(entered) = self.spin_entered { |
There was a problem hiding this comment.
Medium: Not certain about this one, because it depends on ITS scheduling: the spin_entered guard excludes only compute_gate's out-of-limit lanes, and the exit signal still comes from wave_is_first_lane() among whichever entered lanes reach tail first. So a hardware wave whose entered lanes haven't reconverged at tail can publish EXITED while other lanes of that half are still running. On NVIDIA ITS, the non-leader lanes of @xcl.spin.wait branch straight to exit and 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_count against the entered-lane count taken at entry) would remove the dependence.
| let bounds = emit(word, Op::Bin(BinOp::Or, old, after, 0)); | ||
| let bounds = emit(word, Op::Bin(BinOp::Or, bounds, need, 0)); | ||
| let bad = emit(bit, Op::Cmp(Pred::SLt, bounds, zero)); | ||
| let bounds_high = emit(word, Op::Bin(BinOp::And, bounds, hi2, 0)); |
There was a problem hiding this comment.
Medium: 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 in need after about 2^25 exchanges, takes bad with 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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
|
Thanks for checking
(Checked and drafted with Antigravity, Gemini 4 Neon; no code changed on |
|
merge-check Same settings on main 5ad98ad, 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. |
…barrier timeouts (port of xcl-dev/xcl#3652) Prevent TDRs when one half of a split-wave64 compute/mesh wave exits early while its partner enters a Partner::Spin exchange or safe_barrier_sync: - Signal bit 30 (0x4000_0000) on this half's spin counter in spin_exchange_exit() at program exit (guarded by compute_gate's per-lane entry predicate so out-of-limit lanes cannot race under Independent Thread Scheduling). - Check (c & 0x3FFF_FFFF) >= need before inspecting bit 30 in spin_exchange so a convergent partner that exits right after its final exchange never corrupts a successful rendezvous, and bail immediately to timeout/FAIL when bit 30 is observed before need is met. - Cap spin_exchange polling at 4096 (1 << 12) iterations and safe_barrier_sync polling at 65536 (1 << 16) iterations instead of 1 << 20. - Add GPU test gpu_spin_exchange_early_exit_bails_immediately covering both divergent early-exit bailout and convergent exchange + immediate exit. Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com> (cherry picked from commit 032557e79bcc68a45846b55c8dac91f216dff8f6)
…7d6a70 Upstream rewrote #3652 on top of #3655 (head 4b77d6a70, "signal Partner::Spin exit bit (0x4000_0000) in @xcl.spin.wait"): a half leaving the program sets bit 30 on its arrival counter (`Lw::spin_exchange_exit`, guarded by `compute_gate`'s `spin_entered`), and the shared wait helper `@xcl.spin.wait` checks the arrived count first, then bit 30, so a partner that left is seen at once while a live partner keeps the `1 << 20` poll cap; the barrier's poll cap is no longer changed; the split splitter allows the `atomicrmw or` on `xcl_xc` (module/split.rs). The Lw-level `has_spin_exchange` goes (the module's, from #3655, is the one), and the exit takes its counter from `spin_bases` (or the half's counter, `cbase + half`) and does nothing without a partner half (`xn` 0). Port note (by hand): stage c had already moved the old #3652's exit bit into #3655's `@xcl.spin.wait` and allowed the `or` in split.rs, so the bit exists once in the build, where the new head has it. This commit aligns the helper with the new head (names, order of its constants, comments), replaces `spin_exchange_exit` and the exchange's doc with the new head's, and drops the Lw flag. Ours stays: `XCL_SPIN_POLLS` and `XCL_BARRIER_POLLS` set the polls, and their defaults are now the new head's `1 << 20` both (unset: no cache tag; another count still tags the identity). Upstream's GPU test gpu_spin_exchange_early_exit_bails_immediately (its new case 3, the `spin_entered` guard under a partial thread limit) runs in #3655's outlined form and in our default, the helpers inline; split_lds_reads_meet_after_writes counts as the new head does (the exit `or` left out of the per-exchange count) in both forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.