rdna2spirv: wave64 emulation resets shared words with OpAtomicStore (SHADER-W64-SINK-RACE-CARRY) #1110
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1110
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1110/head"
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?
@klikso on GitHub · 2026-11-24 18:42 UTC · original
klikso:carry/shader-w64-sink-race→main· +83 −16 · 3 files · 1 commits · merged 2026-11-25 02:38 UTCClaimed 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).mainstill has the plain stores, and no open pull request carries the fix.The wave64 emulation resets words of
%x_bufevery 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 becomeOpAtomicStore(Workgroup scope, relaxed), the same operands as theOpAtomicOralready 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-mc23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built frommain3aa975421with MSVC 19.44; this change does not touchruntime/.maintests/semantic/test_wave64_emulate_opt.pywith the newSharedWordStoresTestsOpStorelines)tests/semantic/test_loop_ballot_barrier.pyscripts/run_semantic_tests.py tests/semanticrun_gpu_tests.py, nativerun_gpu_tests.py,LEONIDA_W64_EMULATE=1The first row's
maincolumn is the new test file run againstmain's translator. I do not haveVK_LAYER_KHRONOS_validationinstalled, 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.pyon 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed: n/a (no new rule; the stores write the same values).🤖 Generated with Claude Code
@abnalstlll-byte on GitHub · 2026-11-24 18:49 UTC · original · approved these changes
Reviewed and verified. Eliminates Vulkan validation layer data race errors by using OpAtomicStore (Workgroup scope, relaxed semantics) when zeroing the %x_buf sink word across multiple lanes during wave64 emulation. Verified with ests/semantic/test_wave64_emulate_opt.py and semantic suite. 100% clean-room compliant.
@Deedlyy on GitHub · 2026-11-24 20:16 UTC · original
Recommendation: [MERGE]
Reasoning: Carries #382: wave64 emulation resets shared
%x_bufwords withOpAtomicStore, removing a data race where several lanes store to one sink word. The original was verified on RTX 3080 Ti, RTX 4080 and RX 6900 XT (RADV); it is cherry-picked unchanged with author kept and a regression test added. A correctness fix in a hot translator path. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict withmain. Merge once the queued checks are green.Impact level: 5/10
@klikso on GitHub · 2026-11-24 21:52 UTC · original
Follow-up measurement: the description says I had no validation layer and quoted the author's GPU-assisted validation count. I have the layer now (
VK_LAYER_KHRONOS_validation1.4.357 from conda-forge), so here is the count on this machine.run_gpu_tests.pywithLEONIDA_W64_EMULATE=1, the layer loaded for every test program throughVK_INSTANCE_LAYERS,VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1, on currentmain4a50cafc7, and the same with this commit cherry-picked onto it (clean, no conflict). Test programs built from thatmainwith MSVC 19.44.main4a50cafc7main+ this commitSharedMemoryDataRace-RaceOnStoremessagescs_w32_lds_wide)The 32 fixtures that become clean are the wave64-emulated ones (
cs_w64x_*,cs_wm_*,cs_wqm_w64*,cs_w64_mask_*,cs_w64_exec_computed,cs_wave64_ballot,cs_wavemask,cs_exec64,cs_dpp_w64), sixRaceOnStoremessages each onmain.The 8 that remain are the same 8 a native run (no emulation) reports on
main, so they are not the sink:cs_pk_mul_lo_const(VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819, which #481 addresses),cs_w32_lds_wide(equal-address LDS stores), andRaceOnLoadStoreVsAtomiconce each incs_lds_atomics_ext,cs_lds_b64_cmpst,cs_lds_xchg64_ext,cs_w32_fcmpswap,cs_w32_misc_extandcs_w32_new_ops.A control run confirmed the setup reports errors: a compute module given to
vk_harnessas a vertex shader printsVUID-VkShaderModuleCreateInfo-pCode-08740. In a native run, core and synchronization validation without GPU-AV print nothing for any of the 277 runs.GPU: NVIDIA GeForce RTX 3060 Ti, driver 621.14, Vulkan 1.4.357, Windows 11 26200 (32-wide subgroups). AI-assisted (Claude Code); measured on that machine.
@aslan2142 on GitHub · 2026-11-25 02:38 UTC · original
Merged. Thanks for carrying this, and to natterman12 for the original (#382).
SHADER-W64-SINK-RACE-CARRY, valid.OpAtomicStore. They write the same values; the author measured data-race validation messages falling from 197 to 5.main; all pass with the change.--wave64-emulateslice of 60 shaders translates and validates the same as onmain.main85ece6847+19e42d6de: the semantic suite passes (485 files, 6,272 tests, 0 files failed); the 14 docs and writer tests pass;check_no_game_data.pyis clean on the 3 changed files.AI-assisted (Claude Code, Claude Opus 5.5).