Repository navigation
Conversation
|
Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022, Vulkan; Python 3.10, llvm-mc (AMDGPU) and spirv-val on PATH. Head
No failures. (No runtime/ctest targets in this PR, so nothing built.) |
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Audited and verified. Implements structured loop iteration bounding in ools/spirv_loop_guard.py, instrumenting loop headers with iteration counter phis and redirecting back edges to the loop merge block when the iteration budget is exhausted. Correctly handles split latches and OpPhi incoming values. Approved.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean-Room Audit — PR #1101 (SHADER-LOOP-GUARD)
Clean loop visit bound injection (tools/spirv_loop_guard.py) guarding structured loop merge blocks (default 65,536 iterations) with --loop-limit configuration wired cleanly through rdna2spirv.py and make_game.py. Synthetic .asm fixture and semantic tests verified clean-room (0 game data).
Verdict: APPROVED
|
AI-assisted independent GPU verification (overnight shift, worker w4). Environment: Windows, Git Bash; runtime built RelWithDebInfo (Ninja, VS2022 BuildTools, SDK 10.0.26100, Vulkan SDK 1.4.363.0, LLVM_MC=WSL llvm-21, spirv-val/glslangValidator on PATH so the translated-draw ctest targets were built). AMD Radeon iGPU (RDNA2 gfx1035, driver 24.10.24, Vulkan 1.3.280, 128B push constants):
NVIDIA RTX 4070 SUPER (driver 610.88):
Translator tests:
Verdict: verified. Loop-visit bounding at the structured exit causes no regressions on either GPU; the only AMD failures are the documented mesh-shader driver crashes. |
|
AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo. Head
|
|
Recommendation: [MERGE] Reasoning: Adds a structured loop-iteration guard pass ( Impact level: 6/10 |
|
Moriz82, PortBridge used the boundary work from the merged XCL #2034 to check Continued's loop guard on exact One different result appears only on a forced exit. A finite synthetic Wave64 loop would naturally leave after five visits. With At the forced merge, native64 checks the retained guest PC before entering the post-loop block. Emulated64 enters that block directly. Both generated modules passed Vulkan 1.3 validation. The exact checks executed in the CPU interpreter. Is the difference in post-loop side effects intended when the limit fires? Fixture and exact logs Vulkan follow-up on RTX 4070 Ti SUPER (driver 617.14). On exact AI assistance from OpenAI Codex (GPT-6 family) for the cross-project review and synthetic verification. |
A loop with an unreachable exit can keep a translated invocation running. Count header visits per invocation and loop entry. At the configured bound, take the structured merge. The default is 65536 visits and zero disables the guard. The unbounded dispatch fixture timed out at both wave widths on main. The guarded fixture terminated and preserved finite results in budget. All 6171 semantic tests ran with no failing files. The Windows runtime build, tracked-file guard and dependency checks passed. AI-assisted (Codex and Claude Code agents). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
10ad880 to
30baacf
Compare
|
@akimfomin Thanks for the boundary fixture. I reran it on current main at AI-assisted. |
Rebased onto
bfef489cat30baacf9. Main already includes the loop guard. This diff tests the build flag forwarding and documents the native and emulated forced-exit behavior reported below. The three focused suites passed 71 tests.Claimed in the coordination issue as: SHADER-LOOP-GUARD (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. This child merges cleanly beside #1068 and #1073. Either can land first.
What and why
A compute invocation can keep taking a loop back edge when its input makes the exit condition unreachable. On Linux, a synthetic shader that added two on each visit could never reach its odd target. With the guard disabled, both the 32-lane and 64-lane cases exceeded the interpreter's 10,000-step limit in structured and dispatch modes.
The translator now counts visits to each structured loop header per invocation. Entering the loop starts a fresh counter. At the configured limit, a back edge goes to the loop's merge block. A dispatch-loop visit counts one dispatch iteration. Both the translator and the shader build accept
--loop-limit N. The default is 65,536. Set it to zero to restore the unbounded output.This also truncates finite loops that need more visits. With a budget of 16, every lane reached a target of 6 normally. For targets of 1 and 34, every lane reported 32 in structured mode and 30 in dispatch mode. For nested loops with three visits to each header per entry, every lane reported all nine inner iterations. A merge phi with no value on a newly forced exit receives an undefined value on that edge.
The structured-branch test interpreter now reads header phis from the entering edge, as the new counters require. The build digest, fixture build dependencies and runtime workflow path filters include the new translator module.
Tested
Applied only the new tests and their synthetic fixture to pristine main
3aa975421for the regression comparison. The child has one commit on that base.LoopGuardTests.test_finite_and_nonterminatingLoopGuardTests.test_dispatch_loop_also_stopsLoopGuardTests.test_inner_budget_resets_on_each_entryMainWiringTest.test_explicit_loop_limit_reaches_the_shaders_stagepython3 -I scripts/run_semantic_tests.py tests/semantic -p test_loop_iteration_guard.py -j 2python3 -I scripts/run_semantic_tests.py tests/semantic -p test_control_flow_branches.py -j 2python3 -I tests/test_make_game_translator_flags.pypython3 -I tests/test_cmake_translator_deps.pyandpython3 -I tests/test_runtime_paths.pypython3 -I -m compileall -q make_game.py tools testspython3 -I <file>orpython3 -I -m pytest -q <file>tests/test_imhex_patterns.py. The same 6 of its 9 cases failed. Zero new failing files.python3 -I scripts/run_semantic_tests.py tests/semantic -j 2python3 -I scripts/check_no_game_data.pycmake -S runtime -B runtime/build/bootandcmake --build runtime/build/boot --target gta6rt -j6For the synthetic loop,
spirv-valaccepted all 24 combinations of lane width, structured or dispatch lowering, peephole optimization on or off, and limits 0, 16 or 65,536. Nine additional modules with exit phis validated at limits 0, 1 and 4,294,967,295. A loop-free control was byte-identical. On the translator CLI, limit zero reproduced main's 7,116-byte binary and shader index. The default and explicit 65,536 produced the same 7,220-byte binary and index.The following repository fixtures were also built on main and the child:
All 11 synthetic modules translated and validated on each tree. Nine contained loops. Main had zero guard counters across 41 loop headers, and the default child had 41 across the same 41 headers.
GPUs tested: none. Validation used CPU interpreters and SPIRV-Tools on Linux. Native Windows, Wine, NVIDIA GPU, AMD GPU, Intel GPU and game boots were not run.
AI-assisted: yes
Checklist
docs/design.md.🤖 Generated with Claude Code