mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #2183] loop guard: one total of loop visits per invocation, on top of each loop's limit (SHADER-LOOP-TOTAL) #2186
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2186
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2183
Author: @QemmHD
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:claude/loop-total📝 Commits (1)
88abd16loop guard: one total of loop visits an invocation, on top of each loop's limit📊 Changes
8 files changed (+110 additions, -11 deletions)
View changed files
📝
docs/design.md(+1 -0)📝
make_game.py(+9 -1)📝
tests/semantic/test_control_flow_branches.py(+6 -0)📝
tests/semantic/test_loop_ballot_barrier.py(+4 -1)📝
tests/semantic/test_loop_iteration_guard.py(+38 -0)📝
tests/semantic/test_wave64_emulate_opt.py(+2 -0)📝
tools/rdna2spirv.py(+8 -2)📝
tools/spirv_loop_guard.py(+42 -7)📄 Description
tools/spirv_loop_guard.pycaps 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.pypasses the flag through and records it with the other translator flags.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.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.run_semantic_testssuite 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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.