[PR #1697] rdna2spirv: translate s_sethalt before s_endpgm as the end of the wave (SHADER-SETHALT) #1711

Open
opened 2026-11-26 20:22:11 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1697
Author: @kawaii-shakal
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: shader-sethalt


📝 Commits (4)

  • 5d440c8 rdna2spirv: translate s_sethalt before s_endpgm as the end of the wave (SHADER-SETHALT)
  • a2f6613 rdna2spirv: keep branch destinations when lowering s_sethalt
  • f8cbebd Merge commit 'refs/leonida-fix/main' into codex/fix-1697
  • 661ec78 Merge upstream main into shader-sethalt

📊 Changes

3 files changed (+96 additions, -1 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/test_sethalt.py (+67 -0)
📝 tools/rdna2spirv.py (+28 -0)

📄 Description

Claim: SHADER-SETHALT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157294504

What and why

s_sethalt sets the wave's HALT bit to SIMM16[0] (RDNA2 ISA, SOPP). 1 stops the wave until a debugger or the host clears it. Nothing clears it in a translated dispatch. The translator refused the instruction outright.

In the 1.0.2.1 pipeline library one compute program has it: s_sethalt 1 right before s_endpgm, after its only store. It is a 24-byte-prologue FSPX program (#583). It is the one s_sethalt left in #674's table and the library's last refusal on current main.

  • tools/rdna2spirv.py: drop_final_halts, called in translate() before code generation.
    • Drops s_sethalt 1 when the next instruction is s_endpgm. The wave ends there anyway, after the same memory writes.
    • Drops s_sethalt 0 anywhere.
    • Still refuses s_sethalt 1 with more code after it, as s_sethalt 1 before more code. On the console that wave would hang; an invocation cannot.
    • Still refuses a non-immediate operand.
  • docs/design.md: the no-op SOPP row says this.

Test

tests/test_sethalt.py, with hand-written compute listings and no game data:

  • A store followed by s_sethalt 1; s_endpgm gives the same SPIR-V as the store followed by s_endpgm.
  • s_sethalt 0 is a no-op.
  • s_sethalt 1 before more code is refused.

All 3 fail on main and pass with the change. test_sopp_noops, test_printed_encoding and test_isa_coverage also pass. Run with Python 3.13 and pytest 9 on Windows 11 Pro 26300.

Count on the 1.0.2.1 library (2,684 compute programs, make_game on main 237deb64c's translator with --wave64-emulate, LLVM 23):

  • Before: 2,683 translate and pass spirv-val.
  • After: 2,684.
  • The 26,503 main-corpus listings, 52 BVH programs and 12 exe programs translate as before.
  • Pipelines (vk_pipeline_check, RTX 5070 Ti, NVIDIA driver on Windows): 0 failures so far on this run; this program's module was not compiled through the GPU on its own.

Two FidelityFX DLL programs (03 and 18) are refused for a separate reason: the exact re-anchor path does not try restore_dot4_inline_sel. #1662 already fixes that, so it is not in this PR.

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

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1697 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-sethalt` --- ### 📝 Commits (4) - [`5d440c8`](https://github.com/ubiquitarianism/leonida/commit/5d440c8a6ee245ac4d4f72c8e5544c0265e16b16) rdna2spirv: translate s_sethalt before s_endpgm as the end of the wave (SHADER-SETHALT) - [`a2f6613`](https://github.com/ubiquitarianism/leonida/commit/a2f6613b63497ffe79761f374790dc30cf1f238a) rdna2spirv: keep branch destinations when lowering s_sethalt - [`f8cbebd`](https://github.com/ubiquitarianism/leonida/commit/f8cbebd72df6111fc65929b26e06bba2b812590b) Merge commit 'refs/leonida-fix/main' into codex/fix-1697 - [`661ec78`](https://github.com/ubiquitarianism/leonida/commit/661ec787ff04040dc57470be2989127236facfa5) Merge upstream main into shader-sethalt ### 📊 Changes **3 files changed** (+96 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/test_sethalt.py` (+67 -0) 📝 `tools/rdna2spirv.py` (+28 -0) </details> ### 📄 Description Claim: SHADER-SETHALT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157294504 ### What and why `s_sethalt` sets the wave's HALT bit to SIMM16[0] (RDNA2 ISA, SOPP). 1 stops the wave until a debugger or the host clears it. Nothing clears it in a translated dispatch. The translator refused the instruction outright. In the 1.0.2.1 pipeline library one compute program has it: `s_sethalt 1` right before `s_endpgm`, after its only store. It is a 24-byte-prologue FSPX program (#583). It is the one `s_sethalt` left in #674's table and the library's last refusal on current main. - `tools/rdna2spirv.py`: `drop_final_halts`, called in `translate()` before code generation. - Drops `s_sethalt 1` when the next instruction is `s_endpgm`. The wave ends there anyway, after the same memory writes. - Drops `s_sethalt 0` anywhere. - Still refuses `s_sethalt 1` with more code after it, as `s_sethalt 1 before more code`. On the console that wave would hang; an invocation cannot. - Still refuses a non-immediate operand. - `docs/design.md`: the no-op SOPP row says this. ### Test `tests/test_sethalt.py`, with hand-written compute listings and no game data: - A store followed by `s_sethalt 1; s_endpgm` gives the same SPIR-V as the store followed by `s_endpgm`. - `s_sethalt 0` is a no-op. - `s_sethalt 1` before more code is refused. All 3 fail on main and pass with the change. `test_sopp_noops`, `test_printed_encoding` and `test_isa_coverage` also pass. Run with Python 3.13 and pytest 9 on Windows 11 Pro 26300. Count on the 1.0.2.1 library (2,684 compute programs, `make_game` on main 237deb64c's translator with `--wave64-emulate`, LLVM 23): - Before: 2,683 translate and pass `spirv-val`. - After: 2,684. - The 26,503 main-corpus listings, 52 BVH programs and 12 exe programs translate as before. - Pipelines (`vk_pipeline_check`, RTX 5070 Ti, NVIDIA driver on Windows): 0 failures so far on this run; this program's module was not compiled through the GPU on its own. Two FidelityFX DLL programs (03 and 18) are refused for a separate reason: the exact re-anchor path does not try `restore_dot4_inline_sel`. #1662 already fixes that, so it is not in this PR. AI-assisted: yes (Claude Code, Claude Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1711
No description provided.