[PR #1110] [MERGED] rdna2spirv: wave64 emulation resets shared words with OpAtomicStore (SHADER-W64-SINK-RACE-CARRY) #1146

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1110
Author: @klikso
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: carry/shader-w64-sink-race


📝 Commits (1)

  • 19e42d6 rdna2spirv: wave64 emulation resets shared words with OpAtomicStore

📊 Changes

3 files changed (+83 additions, -16 deletions)

View changed files

📝 tests/semantic/test_loop_ballot_barrier.py (+3 -0)
📝 tests/semantic/test_wave64_emulate_opt.py (+60 -0)
📝 tools/rdna2spirv.py (+20 -16)

📄 Description

Claimed in the coordination issue as: SHADER-W64-SINK-RACE-CARRY

What and why

This carries #382 by @natterman12 onto current main: one commit, 5cb32c2b3, cherry-picked with its author kept and no change of mine. #382 was closed by its author on 24 November along with his other open pull requests, after three independent GPU verifications (RTX 3080 Ti Laptop, RTX 4080, Radeon RX 6900 XT on RADV). main still has the plain stores, and no open pull request carries the fix.

The wave64 emulation resets words of %x_buf every round. The lane that owns a word stores to it and every other lane aims the same store at one sink word, so several invocations write one Workgroup word at once. The word is never read, but GPU-assisted validation reports the race in every emulated shader, which hides any real one. Those 16 stores become OpAtomicStore (Workgroup scope, relaxed), the same operands as the OpAtomicOr already used on the buffer. The values written do not change.

@natterman12: this is your work. If you reopen #382 or want this branch, say so and I will close this.

Tested

Windows 11 26200.9974, Python 3.13.14, llvm-mc 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built from main 3aa975421 with MSVC 19.44; this change does not touch runtime/.

main with this commit
tests/semantic/test_wave64_emulate_opt.py with the new SharedWordStoresTests 33 run, 2 fail (the plain OpStore lines) 33 pass
tests/semantic/test_loop_ballot_barrier.py not rerun 15 pass
scripts/run_semantic_tests.py tests/semantic not rerun 470 files, 6170 tests, 0 files failed
run_gpu_tests.py, native 261/261 translated and valid; 203/252 passed, 49 skipped, 0 failed the same
run_gpu_tests.py, LEONIDA_W64_EMULATE=1 235/252 passed, 17 skipped, 0 failed the same

The first row's main column is the new test file run against main's translator. I do not have VK_LAYER_KHRONOS_validation installed, so the GPU-assisted validation count (44 failed fixtures down to 12 on the author's RTX 3080 Ti) is the original measurement, not mine; what I measured is that the emulated run is unchanged on a 32-wide-subgroup device.

  • python -I scripts/check_no_game_data.py on the three changed files: no hits. git diff --check: clean.

GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Vulkan 1.4.357, Windows 11 26200

AI-assisted: yes (Claude Code; run and measured on the machine above)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed: n/a (no new rule; the stores write the same values).

🤖 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/1110 **Author:** [@klikso](https://github.com/klikso) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `carry/shader-w64-sink-race` --- ### 📝 Commits (1) - [`19e42d6`](https://github.com/ubiquitarianism/leonida/commit/19e42d6de7b0588a70db8114920d6ba39723e09c) rdna2spirv: wave64 emulation resets shared words with OpAtomicStore ### 📊 Changes **3 files changed** (+83 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_loop_ballot_barrier.py` (+3 -0) 📝 `tests/semantic/test_wave64_emulate_opt.py` (+60 -0) 📝 `tools/rdna2spirv.py` (+20 -16) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-W64-SINK-RACE-CARRY ### What and why This carries #382 by @natterman12 onto current `main`: one commit, `5cb32c2b3`, cherry-picked with its author kept and no change of mine. #382 was closed by its author on 24 November along with his other open pull requests, after three independent GPU verifications (RTX 3080 Ti Laptop, RTX 4080, Radeon RX 6900 XT on RADV). `main` still has the plain stores, and no open pull request carries the fix. The wave64 emulation resets words of `%x_buf` every round. The lane that owns a word stores to it and every other lane aims the same store at one sink word, so several invocations write one Workgroup word at once. The word is never read, but GPU-assisted validation reports the race in every emulated shader, which hides any real one. Those 16 stores become `OpAtomicStore` (Workgroup scope, relaxed), the same operands as the `OpAtomicOr` already used on the buffer. The values written do not change. @natterman12: this is your work. If you reopen #382 or want this branch, say so and I will close this. ### Tested Windows 11 26200.9974, Python 3.13.14, `llvm-mc` 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built from `main` `3aa975421` with MSVC 19.44; this change does not touch `runtime/`. | | `main` | with this commit | |---|---|---| | `tests/semantic/test_wave64_emulate_opt.py` with the new `SharedWordStoresTests` | 33 run, 2 fail (the plain `OpStore` lines) | 33 pass | | `tests/semantic/test_loop_ballot_barrier.py` | not rerun | 15 pass | | `scripts/run_semantic_tests.py tests/semantic` | not rerun | 470 files, 6170 tests, 0 files failed | | `run_gpu_tests.py`, native | 261/261 translated and valid; 203/252 passed, 49 skipped, 0 failed | the same | | `run_gpu_tests.py`, `LEONIDA_W64_EMULATE=1` | 235/252 passed, 17 skipped, 0 failed | the same | The first row's `main` column is the new test file run against `main`'s translator. I do not have `VK_LAYER_KHRONOS_validation` installed, so the GPU-assisted validation count (44 failed fixtures down to 12 on the author's RTX 3080 Ti) is the original measurement, not mine; what I measured is that the emulated run is unchanged on a 32-wide-subgroup device. - `python -I scripts/check_no_game_data.py` on the three changed files: no hits. `git diff --check`: clean. GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Vulkan 1.4.357, Windows 11 26200 AI-assisted: yes (Claude Code; run and measured on the machine above) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed: n/a (no new rule; the stores write the same values). 🤖 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>
4ld0 2026-11-26 20:20:14 +01:00
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#1146
No description provided.