Repository navigation
rdna2spirv: wave64 emulation resets shared words with OpAtomicStore (SHADER-W64-SINK-RACE) - #382
natterman12 wants to merge 1 commit into
Conversation
The emulated scheduler resets %x_buf words every round. The lane that owns a word stores to it and every other lane aims the same store at one sink word; the prologue's zeroing clamps its index the same way. Several invocations therefore store to one Workgroup word at once: a data race, harmless because the word is never read, but GPU-assisted validation reports it in every emulated shader and so hides any real race. Those 16 stores are now OpAtomicStore (Workgroup scope, relaxed), the same operands as the OpAtomicOr already used on this buffer. The values written are unchanged. On an RTX 3080 Ti, run_gpu_tests.py with LEONIDA_W64_EMULATE=1 under GPU-assisted validation goes from 44 failed fixtures to 12; without it the result is unchanged (229/248). Two test-local interpreters learn OpAtomicStore, and a new case checks that no plain OpStore targets a shared %x_buf word. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested 5cb32c2 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, regression check Runtime built at this head with
|
|
Tested 5cb32c2 (cherry-picked onto main d42773d) on an NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Home (build 26300): the targeted reports are gone, no regression. Runtime built from main d42773d with Full With
32 tests stop failing and none start. The 12 that still fail are the same on main: the two
AI-assisted (Claude Code ran the tests and wrote this comment). |
|
Tested 5cb32c2 on AMD Radeon RX 6900 XT (RADV NAVI21 / GFX1030, Mesa 26.2.5, Linux 7.3.1 CachyOS, Vulkan 1.4.328, subgroup 32..64): pass. Discrete desktop RDNA2 verification:
AI-assisted: yes |
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.
maind478a92. 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