mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #522] SHADER-LDS-MSKOR-ATOMIC: preserve masked-OR atomicity under contention #570
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#570
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/522
Author: @csmith105
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:codex/lds-mskor-atomic📝 Commits (1)
a509b37Make LDS masked-OR updates atomic under contention📊 Changes
3 files changed (+82 additions, -11 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_lds_mskor.py(+61 -3)📝
tools/rdna2spirv.py(+20 -7)📄 Description
Claimed as SHADER-LDS-MSKOR-ATOMIC.
Depends on: #413 (documentation-row overlap only; no code dependency). Whichever merges second should retain that PR's fixture attribution and this corrected atomicity contract. Draft #173 adds a separate single-active-lane fixture and is not a dependency.
What and why
The operation is specified in the AMD RDNA2 ISA guide, section 12.13. Two lanes updating the same LDS word with
ds_mskor[_rtn]_b32can currently produce a value no atomic execution permits. From zero, lane 0 clears bit 0 and sets bit 1, while lane 1 clears bit 1 and sets bit 0. A complete masked-OR operation must leave 1 or 2. The translator's separate atomic AND and OR leave 3; both lanes return zero.Replace the split operations with a Workgroup-scope atomic load/compare-exchange loop. A failed exchange supplies the next old word, and the loop recomputes the entire update. The returning form exposes the old word of its successful exchange. Existing EXEC and LDS-bound guards remain around the operation; address/mask/data are captured before a potentially aliasing destination is written.
The regression checks both valid serial orders, both instruction forms and offsets 0/12. Additional coverage checks destination aliasing and inactive lanes. Update the existing contract row with measured translator results and the limitation that host atomic ordering does not promise the lane order measured on native RDNA2.
Tested
Native RTX 3080, one hand-written 32-thread wave with two active update lanes; fields below are
[old0, final0, old1, final1]:[0,3,0,3][0,1,2,1]Both modules translated, assembled and passed
spirv-valfor Vulkan 1.2. Both native dispatches completed with GPU-assisted validation enabled and zero validation errors; only the old translation violated the result oracle. Used SPIRV-Tools 2026.4, Khronos validation layers 1.4.357.0,LEONIDA_VK_VALIDATION=1,VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1and subgroup size 32.No retail/game data was used. These measurements establish synthetic shader translation behavior, not a retail-game rendering result.
GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 610.88, Windows 11 build 26300.
AI-assisted: yes (Codex); independently reviewed by a second agent.
Checklist
main; code and tests merge cleanly. Documentation overlap with #413 noted above.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.