loop guard: one total of loop visits per invocation, on top of each loop's limit (SHADER-LOOP-TOTAL) #2183

Closed
QemmHD wants to merge 1 commit from upstream-pr/2183 into main
QemmHD commented 2026-11-26 03:05:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-26T03:05:51Z.


tools/spirv_loop_guard.py caps each loop at 65,536 visits, so nested loops multiply their caps. A loop bound computed by a float divide whose divisor is 0 becomes +inf, converts to 0xFFFFFFFF, and an inclusive exit test against it never fails once the counter wraps. A compute program with nested loops of that shape ran at the caps for seconds per dispatch, and the device was lost with no faulting address.

  • --loop-total N (default 1,048,576; 0 = none) adds one count of every guarded back edge per invocation, in a Private variable listed by the entry point. No back edge passes once it reaches N. Each loop keeps its own limit, so a loop that ends by itself is only cut after the whole invocation made N visits.
  • make_game.py passes the flag through and records it with the other translator flags.
  • The default changes the translation of every program with a loop, so a shader library picks it up when it is translated again.

Tests

  • tests/semantic/test_loop_iteration_guard.py: two nested loops that never end stop at the total, in wave32 and emulated wave64; loops that end by themselves are untouched; without a total the per-loop counts multiply.
  • Three test-local SPIR-V interpreters (test_loop_ballot_barrier, test_control_flow_branches, test_wave64_emulate_opt) now give each invocation its Private globals, which every module with a loop has from now on.
  • Full run_semantic_tests suite green on this branch. On an RTX 4070 SUPER, the GPU loop-cap ctests pass, including an inner loop that never ends stopping at the total.

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5503241958 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-26T03:05:51Z. --- `tools/spirv_loop_guard.py` caps each loop at 65,536 visits, so nested loops multiply their caps. A loop bound computed by a float divide whose divisor is 0 becomes +inf, converts to 0xFFFFFFFF, and an inclusive exit test against it never fails once the counter wraps. A compute program with nested loops of that shape ran at the caps for seconds per dispatch, and the device was lost with no faulting address. - `--loop-total N` (default 1,048,576; 0 = none) adds one count of every guarded back edge per invocation, in a Private variable listed by the entry point. No back edge passes once it reaches N. Each loop keeps its own limit, so a loop that ends by itself is only cut after the whole invocation made N visits. - `make_game.py` passes the flag through and records it with the other translator flags. - The default changes the translation of every program with a loop, so a shader library picks it up when it is translated again. **Tests** - `tests/semantic/test_loop_iteration_guard.py`: two nested loops that never end stop at the total, in wave32 and emulated wave64; loops that end by themselves are untouched; without a total the per-loop counts multiply. - Three test-local SPIR-V interpreters (`test_loop_ballot_barrier`, `test_control_flow_branches`, `test_wave64_emulate_opt`) now give each invocation its Private globals, which every module with a loop has from now on. - Full `run_semantic_tests` suite green on this branch. On an RTX 4070 SUPER, the GPU loop-cap ctests pass, including an inner loop that never ends stopping at the total. AI-assisted (Claude Code, Claude Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
djrolfes commented 2026-11-26 08:43:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-26T08:43:06Z.


Spotted a workgroup-barrier deadlock hazard in tools/spirv_loop_guard.py when --loop-total instruments the outer scheduler loop (%loop_head / %loop_cont) of x_scheduler, x_mini_scheduler, and bar_scheduler:

  • %loop_guard_total is a per-invocation Private counter incremented at every guarded back edge (both inner loops and the outer round loop).
  • In x_scheduler / x_mini_scheduler / bar_scheduler, %loop_cont contains a workgroup OpControlBarrier (%loop_head is explicitly required to stay in workgroup-uniform control flow).
  • If wave A in a workgroup spends more inner-loop iterations than wave B, wave A hits %loop_guard_total first and exits %loop_head to %loop_exit at %loop_cont, while wave B still has %loop_guard_total < total and loops back to %loop_head to wait at %loop_cont's OpControlBarrier forever -> workgroup barrier deadlock on the GPU.

Note also a related bug in bar_scheduler_tail (tools/rdna2spirv.py): when the per-loop guard cuts the inner %xb_in_head loop at LOOP_LIMIT, it exits to %xb_in_merge without setting %done = true (since %xb_stop is still false), so the outer %loop_head sees the invocation as still active and re-enters %xb_in_head with its per-loop count reset, multiplying to LOOP_LIMIT * LOOP_LIMIT (reproduced synthetically with LOOP_LIMIT=8: bar_scheduler executes 55 iterations instead of <= 8).

Keeping %loop_guard_total out of loops whose body contains OpControlBarrier (and marking %done = true / %x_ldone = true on inner-loop guard cut in bar_scheduler_tail / x_scheduler_tail / x_mini_scheduler_tail so the outer round loop exits uniformly) avoids both the barrier deadlock and the N * N multiplication.

AI-assisted review (synthetic repro only, no game data).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7186932954 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2183#issuecomment-7186932954). Originally posted by [djrolfes](https://github.com/djrolfes) on 2026-11-26T08:43:06Z. --- Spotted a workgroup-barrier deadlock hazard in `tools/spirv_loop_guard.py` when `--loop-total` instruments the outer scheduler loop (`%loop_head` / `%loop_cont`) of `x_scheduler`, `x_mini_scheduler`, and `bar_scheduler`: - `%loop_guard_total` is a per-invocation `Private` counter incremented at every guarded back edge (both inner loops and the outer round loop). - In `x_scheduler` / `x_mini_scheduler` / `bar_scheduler`, `%loop_cont` contains a workgroup `OpControlBarrier` (`%loop_head` is explicitly required to stay in workgroup-uniform control flow). - If wave A in a workgroup spends more inner-loop iterations than wave B, wave A hits `%loop_guard_total` first and exits `%loop_head` to `%loop_exit` at `%loop_cont`, while wave B still has `%loop_guard_total < total` and loops back to `%loop_head` to wait at `%loop_cont`'s `OpControlBarrier` forever -> workgroup barrier deadlock on the GPU. Note also a related bug in `bar_scheduler_tail` (`tools/rdna2spirv.py`): when the per-loop guard cuts the inner `%xb_in_head` loop at `LOOP_LIMIT`, it exits to `%xb_in_merge` without setting `%done = true` (since `%xb_stop` is still false), so the outer `%loop_head` sees the invocation as still active and re-enters `%xb_in_head` with its per-loop count reset, multiplying to `LOOP_LIMIT * LOOP_LIMIT` (reproduced synthetically with `LOOP_LIMIT=8`: `bar_scheduler` executes 55 iterations instead of <= 8). Keeping `%loop_guard_total` out of loops whose body contains `OpControlBarrier` (and marking `%done = true` / `%x_ldone = true` on inner-loop guard cut in `bar_scheduler_tail` / `x_scheduler_tail` / `x_mini_scheduler_tail` so the outer round loop exits uniformly) avoids both the barrier deadlock and the `N * N` multiplication. AI-assisted review (synthetic repro only, no game data).
real-rusher commented 2026-11-26 10:20:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T10:20:00Z.


Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly into main. Changed semantic tests with this PR, each via unittest discover: test_loop_iteration_guard 6 OK, test_control_flow_branches 33 OK, test_loop_ballot_barrier 15 OK, test_wave64_emulate_opt 33 OK. test_loop_iteration_guard.py against main's translator: 2 errors, so it fails on main and passes with the change; the other three pass on both. compileall clean.

Not run: the whole semantic suite and the translated / spirv-val counts over a corpus (no game data here).

Note for review: it conflicts with #2155 in tools/rdna2spirv.py, so whichever lands later needs a rebase.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7189224454 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2183#issuecomment-7189224454). Originally posted by [real-rusher](https://github.com/real-rusher) on 2026-11-26T10:20:00Z. --- Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly into main. Changed semantic tests with this PR, each via unittest discover: test_loop_iteration_guard 6 OK, test_control_flow_branches 33 OK, test_loop_ballot_barrier 15 OK, test_wave64_emulate_opt 33 OK. test_loop_iteration_guard.py against main's translator: 2 errors, so it fails on main and passes with the change; the other three pass on both. compileall clean. Not run: the whole semantic suite and the translated / spirv-val counts over a corpus (no game data here). Note for review: it conflicts with #2155 in tools/rdna2spirv.py, so whichever lands later needs a rebase. AI-assisted: yes (Claude Code)
Tauwni commented 2026-11-26 12:02:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-26T12:02:16Z.


Tested 88abd1609 on an Apple M3 (macOS 26.5.1) with the three Vulkan drivers there. I ran the full scripts/run_gpu_tests.py in auto mode, against main a73a57e13, with test programs built from main.

Driver main this PR
MoltenVK 1.4.2 195 pass, 70 skip 195 pass, 70 skip
MoltenVK, LEONIDA_W64_EMULATE=1 229 pass, 36 skip 229 pass, 36 skip
KosmicKrisp (Mesa 26.3.1) 190 pass, 73 skip 190 pass, 73 skip
llvmpipe (Mesa 26.3.1) 177 pass, 90 skip 177 pass, 90 skip
llvmpipe, LEONIDA_W64_EMULATE=1 212 pass, 55 skip 212 pass, 55 skip

So the loop-visit total changes nothing for the 268 fixtures on these drivers. The failures are the same on both sides, none new: cs_fma_fused (#1724), cs_imgatomic_ext (#1518) and ps_ssharp (#1774) on MoltenVK; cs_bvh/cs_bvh32, ps_cndmask_sign_mods and ps_valu16_mad_sel (KosmicKrisp's (NAN) constants, #2229) on KosmicKrisp; cs_imgatomic_ext on llvmpipe.

AI-assisted (Claude Code). No game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7191485325 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2183#issuecomment-7191485325). Originally posted by [Tauwni](https://github.com/Tauwni) on 2026-11-26T12:02:16Z. --- Tested `88abd1609` on an Apple M3 (macOS 26.5.1) with the three Vulkan drivers there. I ran the full `scripts/run_gpu_tests.py` in auto mode, against `main` `a73a57e13`, with test programs built from `main`. | Driver | `main` | this PR | |---|---|---| | MoltenVK 1.4.2 | 195 pass, 70 skip | 195 pass, 70 skip | | MoltenVK, `LEONIDA_W64_EMULATE=1` | 229 pass, 36 skip | 229 pass, 36 skip | | KosmicKrisp (Mesa 26.3.1) | 190 pass, 73 skip | 190 pass, 73 skip | | llvmpipe (Mesa 26.3.1) | 177 pass, 90 skip | 177 pass, 90 skip | | llvmpipe, `LEONIDA_W64_EMULATE=1` | 212 pass, 55 skip | 212 pass, 55 skip | So the loop-visit total changes nothing for the 268 fixtures on these drivers. The failures are the same on both sides, none new: `cs_fma_fused` (#1724), `cs_imgatomic_ext` (#1518) and `ps_ssharp` (#1774) on MoltenVK; `cs_bvh`/`cs_bvh32`, `ps_cndmask_sign_mods` and `ps_valu16_mad_sel` (KosmicKrisp's `(NAN)` constants, #2229) on KosmicKrisp; `cs_imgatomic_ext` on llvmpipe. AI-assisted (Claude Code). No game data.
qhukz13 commented 2026-11-26 19:05:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-26T19:05:06Z.


I tested djrolfes' scheduler-barrier concern on 88abd1609 and it reproduces. In the wave64 round-loop form, --loop-total can make invocations of one workgroup leave the round loop at different rounds.

Setup: CPU only, no game data. I used 24 hand-written NGG mesh programs with 128 threads, so 2 waves. They have loops of every common shape: waterfall v_readfirstlane, execnz and VCC-vote latches, s_barrier + LDS in a loop, loops whose trip count differs between the two waves, and loops that never end. I translated them with --wave64-emulate in the forced round-loop form (STRUCTURED = False, the emulated wave64 rounds the world-load hangs report). Each workgroup ran in spirv_mini_interp.run_workgroup on 32-wide subgroups. It raises when a subgroup op or an OpControlBarrier is not reached by every invocation at the same point.

--loop-total programs that broke uniformity
40 2 of 24: inf_wave1_vote, inf_wave1_barrier
12 3 of 24: vote_exec, wave_rfl_loop, inf_wave1_barrier
5 0 (everyone leaves in the first rounds)

Each failure is subgroup operation not reached by every invocation at the same point. All of them are programs where one wave does more work than the other:

  • a loop that runs forever only in wave 1;
  • a vote loop under an EXEC narrowed to part of wave 0;
  • a v_readfirstlane loop with a different trip count per wave.

The total counts every guarded back edge of the invocation, the chain loop inside the round included. So the busier wave's invocations reach it first and take the round loop's exit, while the other wave's invocations go on to the next exchange and barrier. On a GPU that is a non-uniform OpControlBarrier: undefined behaviour, and in practice usually a hang. That is the thing the total is meant to prevent.

For comparison, main's per-loop guard on the same programs (--loop-limit 40, including the never-ending ones) broke none. Every invocation counts the round loop's iterations identically, so they all leave it together.

A way to keep the total without the hazard: don't let it end a loop that holds a workgroup barrier on its own, invocation by invocation.

  • One option: exempt the round loops (x_scheduler, x_mini_scheduler, bar_scheduler) from the total, so only their per-loop guard applies.
  • The other: make the decision to leave them uniform, for example OR-ing "any invocation over the total" into the counts the round already exchanges after its barrier, so everyone leaves in the same round.

For context: HasiKe's finding in #1608 shows the world-load TDR goes away when the nested loops are bounded tightly. The inner loop there has no barrier. The first option would still bound that inner loop by the total, with no risk to the round loop's barrier.

The harness is test-local Python, about 300 lines. I can contribute it as a semantic test if it helps.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7201178176 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2183#issuecomment-7201178176). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-26T19:05:06Z. --- I tested djrolfes' scheduler-barrier concern on `88abd1609` and it reproduces. In the wave64 round-loop form, `--loop-total` can make invocations of one workgroup leave the round loop at different rounds. **Setup:** CPU only, no game data. I used 24 hand-written NGG mesh programs with 128 threads, so 2 waves. They have loops of every common shape: waterfall `v_readfirstlane`, `execnz` and VCC-vote latches, `s_barrier` + LDS in a loop, loops whose trip count differs between the two waves, and loops that never end. I translated them with `--wave64-emulate` in the forced round-loop form (`STRUCTURED = False`, the `emulated wave64 rounds` the world-load hangs report). Each workgroup ran in `spirv_mini_interp.run_workgroup` on 32-wide subgroups. It raises when a subgroup op or an `OpControlBarrier` is not reached by every invocation at the same point. | `--loop-total` | programs that broke uniformity | |---|---| | 40 | 2 of 24: `inf_wave1_vote`, `inf_wave1_barrier` | | 12 | 3 of 24: `vote_exec`, `wave_rfl_loop`, `inf_wave1_barrier` | | 5 | 0 (everyone leaves in the first rounds) | Each failure is `subgroup operation not reached by every invocation at the same point`. All of them are programs where one wave does more work than the other: - a loop that runs forever only in wave 1; - a vote loop under an EXEC narrowed to part of wave 0; - a `v_readfirstlane` loop with a different trip count per wave. The total counts every guarded back edge of the invocation, the chain loop inside the round included. So the busier wave's invocations reach it first and take the round loop's exit, while the other wave's invocations go on to the next exchange and barrier. On a GPU that is a non-uniform `OpControlBarrier`: undefined behaviour, and in practice usually a hang. That is the thing the total is meant to prevent. For comparison, main's per-loop guard on the same programs (`--loop-limit 40`, including the never-ending ones) broke none. Every invocation counts the round loop's iterations identically, so they all leave it together. A way to keep the total without the hazard: don't let it end a loop that holds a workgroup barrier on its own, invocation by invocation. - One option: exempt the round loops (`x_scheduler`, `x_mini_scheduler`, `bar_scheduler`) from the total, so only their per-loop guard applies. - The other: make the decision to leave them uniform, for example OR-ing "any invocation over the total" into the counts the round already exchanges after its barrier, so everyone leaves in the same round. For context: HasiKe's finding in #1608 shows the world-load TDR goes away when the nested loops are bounded tightly. The inner loop there has no barrier. The first option would still bound that inner loop by the total, with no risk to the round loop's barrier. The harness is test-local Python, about 300 lines. I can contribute it as a semantic test if it helps. AI-assisted (Claude Code).
sodove commented 2026-11-28 09:14:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:14:46Z.


#2183 | head 88abd160991ff7954896752ec76bed18995df14e | python3 -I tests/semantic/test_control_flow_branches.py -v, python3 -I tests/semantic/test_loop_ballot_barrier.py -v, python3 -m pytest -q -rA tests/semantic/test_loop_iteration_guard.py, python3 -I tests/semantic/test_wave64_emulate_opt.py -v | red: 88 tests, 7 assertion failures, 4 pytest failures | green: 88 passed | Red → green

Three of the four changed files failed on main. After merging, all four passed. The merged versions picked up test changes from main.

Pinned main 4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237113235 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183#issuecomment-7237113235). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T09:14:46Z. --- #2183 | head `88abd160991ff7954896752ec76bed18995df14e` | `python3 -I tests/semantic/test_control_flow_branches.py -v`, `python3 -I tests/semantic/test_loop_ballot_barrier.py -v`, `python3 -m pytest -q -rA tests/semantic/test_loop_iteration_guard.py`, `python3 -I tests/semantic/test_wave64_emulate_opt.py -v` | red: 88 tests, 7 assertion failures, 4 pytest failures | green: 88 passed | **Red → green** Three of the four changed files failed on main. After merging, all four passed. The merged versions picked up test changes from main. Pinned main `4938673668d807bf365b61284bf22b1ff8d02cc4`, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7236982945).
TheGeogeo commented 2026-11-29 04:50:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:50:21Z.


Checked 88abd1609 against main ef3299584 on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.

  • Conflict: tools/spirv_loop_guard.py. 65055ca54 (2026-11-25, "preserve CRLF boundaries, validate limits and add unit tests") changed the same lines: the instruction regex ([^;\r\n]*) and add_guards' limit check. This PR adds TypePointer|EntryPoint to that regex and a total parameter.
  • Still needed (STALE, needs a rebase). main has no --loop-total. The rebase must keep main's CRLF and limit checks, and apply the same validation to total.
  • Open before a merge, as far as I can see in the thread: djrolfes' workgroup-barrier hazard when the total cuts the outer scheduler round loop, which qhukz13 reproduced on this head. I see no answer to it yet.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250891782 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183#issuecomment-7250891782). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T04:50:21Z. --- Checked `88abd1609` against `main` `ef3299584` on Windows 11 10.0.26300: it does not merge (`git merge-tree --write-tree`), so I ran no tests. - Conflict: `tools/spirv_loop_guard.py`. `65055ca54` (2026-11-25, "preserve CRLF boundaries, validate limits and add unit tests") changed the same lines: the instruction regex (`[^;\r\n]*`) and `add_guards`' `limit` check. This PR adds `TypePointer|EntryPoint` to that regex and a `total` parameter. - Still needed (STALE, needs a rebase). `main` has no `--loop-total`. The rebase must keep `main`'s CRLF and limit checks, and apply the same validation to `total`. - Open before a merge, as far as I can see in the thread: djrolfes' workgroup-barrier hazard when the total cuts the outer scheduler round loop, which qhukz13 reproduced on this head. I see no answer to it yet. AI-assisted (Claude Code).
OreoFR commented 2026-11-30 13:40:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:33Z.


Carried as #2736 because of the conflict with main after #2566; @QemmHD, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7280190895 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183#issuecomment-7280190895). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:40:33Z. --- Carried as #2736 because of the conflict with main after #2566; @QemmHD, if you come back, say so and the carry is dropped.
aslan2142 commented 2026-12-01 11:49:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:49:03Z.

Review: CHANGES_REQUESTED


This PR cannot merge in its current state:

  1. Reproduced workgroup-barrier deadlock hazard: incrementing per-invocation %loop_guard_total in tools/spirv_loop_guard.py on outer wave64 round-scheduler loops (%loop_head/%loop_cont in x_scheduler/x_mini_scheduler/bar_scheduler) or other loops containing OpControlBarrier lets busier waves hit the total first and exit while other waves wait at OpControlBarrier forever (non-uniform OpControlBarrier / SPIR-V UB, independently reproduced in spirv_mini_interp).
  2. Merge conflict with main in tools/spirv_loop_guard.py and failing CI (note #2736 carries this branch onto current main, though it still reproduces the same barrier non-uniformity hazard).

Please exempt barrier-containing / round-scheduler outer loops from %loop_guard_total (or make the exit workgroup-uniform), resolve the conflict (and coordinate with #2736), and get a green CI run.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130642306 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183#pullrequestreview-6130642306). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:49:03Z. **Review:** CHANGES_REQUESTED --- This PR cannot merge in its current state: 1. **Reproduced workgroup-barrier deadlock hazard**: incrementing per-invocation `%loop_guard_total` in `tools/spirv_loop_guard.py` on outer wave64 round-scheduler loops (`%loop_head`/`%loop_cont` in `x_scheduler`/`x_mini_scheduler`/`bar_scheduler`) or other loops containing `OpControlBarrier` lets busier waves hit the total first and exit while other waves wait at `OpControlBarrier` forever (non-uniform `OpControlBarrier` / SPIR-V UB, independently reproduced in `spirv_mini_interp`). 2. **Merge conflict** with `main` in `tools/spirv_loop_guard.py` and **failing CI** (note `#2736` carries this branch onto current `main`, though it still reproduces the same barrier non-uniformity hazard). Please exempt barrier-containing / round-scheduler outer loops from `%loop_guard_total` (or make the exit workgroup-uniform), resolve the conflict (and coordinate with `#2736`), and get a green CI run. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 11:49:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:49:04Z.


Closing this PR in favor of #2736 (reprend #2183), which preserves your commit 88abd1609 intact while resolving the conflicts and regressions against current main.

Side-by-side comparison:

  • #2183: conflicts with main in tools/spirv_loop_guard.py, has failing CI, and breaks tests/semantic/test_wave64_single_wave_barrier.py ({'%pc', '%loop_guard_total'}).
  • #2736: keeps your commit 88abd1609 untouched, cleanly merges main (preserving main's CRLF handling and isinstance(..., bool) validation for both limit and total), updates tests/semantic/test_wave64_single_wave_barrier.py, is MERGEABLE, and has all CI checks green (verified across all 549 semantic test files / 6,677 tests).

Note: we are holding #2736 from merge until the wave64 scheduler-barrier uniformity defect reproduced by @qhukz13 above is addressed. Thanks @QemmHD for the original implementation!

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310187056 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2183#issuecomment-7310187056). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:49:04Z. --- Closing this PR in favor of **#2736** (`reprend #2183`), which preserves your commit `88abd1609` intact while resolving the conflicts and regressions against current `main`. **Side-by-side comparison:** - **#2183**: conflicts with `main` in `tools/spirv_loop_guard.py`, has failing CI, and breaks `tests/semantic/test_wave64_single_wave_barrier.py` (`{'%pc', '%loop_guard_total'}`). - **#2736**: keeps your commit `88abd1609` untouched, cleanly merges `main` (preserving `main`'s CRLF handling and `isinstance(..., bool)` validation for both `limit` and `total`), updates `tests/semantic/test_wave64_single_wave_barrier.py`, is `MERGEABLE`, and has all CI checks green (verified across all 549 semantic test files / 6,677 tests). Note: we are holding **#2736** from merge until the wave64 scheduler-barrier uniformity defect reproduced by `@qhukz13` above is addressed. Thanks `@QemmHD` for the original implementation! *(AI-assisted review.)*

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2183
No description provided.