mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:00:52 +01:00
[PR #382] [CLOSED] rdna2spirv: wave64 emulation resets shared words with OpAtomicStore (SHADER-W64-SINK-RACE) #434
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#434
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/382
Author: @natterman12
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:rdna2spirv/w64-emulate-atomic-sink📝 Commits (1)
5cb32c2rdna2spirv: 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 (#14)
What and why
Under
--wave64-emulatethe scheduler resets words of%x_bufevery round. The lane that owns a word stores to it; every other lane aims the same store at one sink word:x_prologuezeroes the mask and schedule words with an index clamped byUMin, which lands several invocations on the last word in the same way.So several invocations store to one Workgroup word with no synchronization between them. That is a data race. It is harmless in effect, because the sink is never read and the clamped stores all write 0, but GPU-assisted validation reports it in every emulated shader:
docs/testing.mddocuments this run (LEONIDA_VK_VALIDATION=1 VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1 python scripts/run_gpu_tests.py) as the way to see what the translated shaders do at run time. With 30+ fixtures failing on this one report, a real race in the emulation would not stand out.The 16 stores (in
Gen.x_round_pre,x_round_head,x_mini_schedulerandx_prologue) becomeOpAtomicStorewith Workgroup scope and relaxed semantics, the operands theOpAtomicOron the same buffer already uses. The values written, the buffer layout and the control flow are unchanged, and native wave64 translation is untouched (a test pins that). No contract-table row: no instruction's translation rule changes, only how the emulation's own bookkeeping stores are emitted; say so if you want a row anyway.Tests
tests/semantic/test_wave64_emulate_opt.py, newSharedWordStoresTests: for one wave and for two, no plainOpStoremay target a%x_bufelement whose index comes from anOpSelect(the sink) or the prologue'sUMin, and the atomic ones must carry the expected operands. Fails onmainwith the fourOpStore %x_mp5 / %x_mp6 / ...lines.test_wave64_emulate_opt.pyandtest_loop_ballot_barrier.py(the latter also used bytest_lds_addtid.py) did not knowOpAtomicStore; they execute it as a store.tests/semantic/spirv_mini_interp.pyalready did.Tested
Windows 11 10.0.26300.9974, NVIDIA GeForce RTX 3080 Ti (subgroup 32..32), driver 621.24, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.15.2.
maind478a92d. No game files.run_gpu_tests.py,LEONIDA_W64_EMULATE=1LEONIDA_VK_VALIDATION=1VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1All 257 fixtures translate and pass
spirv-valin each run. The two failures without GPU-assisted validation arecs_imgload_tfeandcs_imgload_d16_tfe(#31).The 12 left under GPU-assisted validation are not this report: those two, nine LDS fixtures (
cs_lds_atomics_ext,cs_lds_b64_cmpst,cs_lds_xchg64_ext,cs_w32_fcmpswap,cs_w32_lds_subdword,cs_w32_lds_u8_d16,cs_w32_lds_wide,cs_w32_misc_ext,cs_w32_new_ops), where the layer reports a race between anOpAtomicLoadand a plainOpLoadof the LDS variable, andcs_pk_mul_lo_const, which I have not looked into. I am posting those as a finding rather than widening this change.python -I scripts/run_semantic_tests.py tests/semantic: 463 files, 6075 tests, 1 file failed:test_image_cube_store_glc(FileNotFoundErrorin its llvm-mc round trip), which fails the same way onmainhere.python -I tests/test_text_write_line_endings.py,test_text_encoding.py: OK.tests/test_translate.pyand others; no pytest on this machine), any other GPU, and the game's own shader corpus (no game files here), so I have no translated/valid counts for it before and after.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (no new rule; see above)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.