rdna2spirv: global_atomic_add/sub_x2 and buffer_atomic_add/sub_x2 #174

Closed
github-bot wants to merge 5 commits from gh-pr/174/head into gh-pr/174/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:35 UTC · original
ubiquitarianism:old-pr/9909 → main · +73 −19 · 5 files · 5 commits · closed without merging

Carried over from old PR 9909 by LouisRiverstone in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9909, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
LouisRiverstone: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

global_atomic_add_x2/sub_x2 and buffer_atomic_add_x2/sub_x2 raised Unsupported. This is the global and buffer counterpart of #2738, which does the same for ds_add/sub_u64. The global and buffer _x2 paths weren't in #2738, and no one had claimed them.

Re-submission of #3065. #3065 was closed unmerged during the 2026-11-23 22:45 UTC cleanup, along with the other open PRs. This is the same branch, now merged with current main.

Checked on #3065 by: TheMrBeez (the GPU), bobcatchris (Pro V540), zzEmmazz (main 16282101), theswiss24 (RTX 2060 SUPER), DenRakEiw (Windows 11), kapitche (native Windows), DavidM1911 (two Vulkan devices), tylerstraub (RTX 5090), GustawMatuszewski (two devices. Ubuntu 26.04.1), Sangonapou (RTX 3080 Ti Laptop), YordiLorenzo (RTX 5090), leonidassupporter (RTX 3060 Ti) and 2 more.

No game files.

AI-assisted (Claude Code): I reviewed the change and re-ran its tests on the merge with main.

**@⁠Andretuta** on GitHub · 2026-11-24 02:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/174) `ubiquitarianism:old-pr/9909` → `main` · +73 −19 · 5 files · 5 commits · closed without merging > Carried over from **old PR 9909** by `LouisRiverstone` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9909`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `LouisRiverstone`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): `global_atomic_add_x2`/`sub_x2` and `buffer_atomic_add_x2`/`sub_x2` raised `Unsupported`. This is the global and buffer counterpart of `#2738`, which does the same for `ds_add/sub_u64`. The global and buffer `_x2` paths weren't in `#2738`, and no one had claimed them. Re-submission of `#3065`. `#3065` was closed unmerged during the 2026-11-23 22:45 UTC cleanup, along with the other open PRs. This is the same branch, now merged with current `main`. Checked on `#3065` by: TheMrBeez (the GPU), bobcatchris (Pro V540), zzEmmazz (main 16282101), theswiss24 (RTX 2060 SUPER), DenRakEiw (Windows 11), kapitche (native Windows), DavidM1911 (two Vulkan devices), tylerstraub (RTX 5090), GustawMatuszewski (two devices. Ubuntu 26.04.1), Sangonapou (RTX 3080 Ti Laptop), YordiLorenzo (RTX 5090), leonidassupporter (RTX 3060 Ti) and 2 more. No game files. AI-assisted (Claude Code): I reviewed the change and re-ran its tests on the merge with `main`.
Both pairs raised Unsupported. A 64-bit add/sub is exact with two 32-bit
atomics: the low dword's atomic returns its old value, which gives this op's
own carry (borrow), and the high dword then takes DATA.hi + carry. Addition
commutes, so memory is exact under contention; only the returned high dword
can be torn. x2_atomic_words holds both the carry pair and the per-dword
bitwise/swap ops; the global and buffer _x2 paths (with main's alignment
guard) call it.

Tests: test_global_atomics_x2.py / test_buffer_atomics_x2.py add the carry
and borrow cases and 32 lanes adding to one element; test_global_atomics.py's
rejected list uses smin_x2. docs/design.md rows updated.
# Conflicts:
#	docs/design.md
# Conflicts:
#	tools/rdna2spirv.py
# Conflicts:
#	docs/design.md
# Conflicts:
#	docs/design.md
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:47:25 +00:00
github-bot closed this pull request 2026-11-26 08:47:26 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:49 UTC · original

Thanks for carrying this over, and thanks to the original author for the work. I'm closing this draft in favour of #865 (#865):

  • #865 lowers every global_atomic_*_x2 and buffer_atomic_*_x2 op (including min/max and cmpswap_x2) to one native 64-bit SPIR-V atomic, so the returned old value no longer tears either.
  • It already says it supersedes this PR, under the OLD-9909 claim.
  • Your carry/borrow lowering in x2_atomic_words is still useful as the fallback for GPUs without shaderBufferInt64Atomics. It's worth porting into #865.
  • The 32-lane add_x2 test passes against #865's translator too, so it is worth keeping there.
  • The branch stays as old-pr/9909 if anything else is needed from it.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/174#issuecomment-7142651132) Thanks for carrying this over, and thanks to the original author for the work. I'm closing this draft in favour of #865 (https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/865): - #865 lowers every `global_atomic_*_x2` and `buffer_atomic_*_x2` op (including `min/max` and `cmpswap_x2`) to one native 64-bit SPIR-V atomic, so the returned old value no longer tears either. - It already says it supersedes this PR, under the `OLD-9909` claim. - Your carry/borrow lowering in `x2_atomic_words` is still useful as the fallback for GPUs without `shaderBufferInt64Atomics`. It's worth porting into #865. - The 32-lane `add_x2` test passes against #865's translator too, so it is worth keeping there. - The branch stays as `old-pr/9909` if anything else is needed from it. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.