Skip to content

GPU test cs_w32_atomic_contend: buffer_atomic_inc/dec under contention - #178

Closed
Andretuta wants to merge 7 commits into
mainfrom
old-pr/9912
Closed

Andretuta wants to merge 7 commits into
mainfrom
old-pr/9912

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

Carried over from old PR 9912 by LouisRiverstone in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9912, 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):

buffer_atomic_inc/dec (#2448) are OpAtomicCompareExchange loops. Their tests run them in one lane, or in the CPU interpreter, which runs lanes in lockstep. @TheMrBeez checked the loops under contention by hand on #3097, but nothing in the suite does. This GPU fixture, runtime/test/shaders/cs_w32_atomic_contend.asm, has all 32 lanes of a wave32 group run every op on the same dwords, so the loops race for real on a GPU.

Re-submission of #4331. #4331 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 #4331 by: theswiss24 (two NVIDIA GPUs), vibryxcx (RX 6800), radv-tinker (AMD Radeon RX 9070 XT), javdc (Steam Deck LCD), sovljanskii (Apple M4), nicknickalive (RTX 5090), Mortify7612 (AMD Radeon RX 9060 XT), Itschotsch (RTX 4090), lukasas74 (RTX 5080), YordiLorenzo (RTX 5090), matheusfermiano-source (main 867d922)), nicolasabosch (RTX 4070 Laptop GPU).

No game files.

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

All 32 lanes of a wave32 group run each op on the same dwords, so the
translated CAS loops race for real on a GPU (the CPU interpreter runs lanes in
lockstep). Same op on every lane: the final words are order-independent,
including inc/dec wrapping at a small D. Each lane adds 1 << (old - fill)
into another word, so a lost or doubled update changes the sum; umax/umin
of the returned values check the extremes. Registered in check.py,
run_gpu_tests.py and regen_fixtures.py; tests/semantic/
test_atomic_contend_fixture.py runs it on the CPU against 32 sequential ops.
python -I on the file failed with ModuleNotFoundError: support, as the folder
was not on sys.path (found by @justr4mzi on #4323, the same template). It is
now inserted, as test_cs_shared_memory_limit does.
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
…give the same word

@sovljanskii on #4331: with 32 ops and D = 20, inc ends at 31 mod 21 = 10 and
dec at 20 - (31 mod 21) = 10, so swapping buffer_atomic_inc v8 for a dec
still passed on the GPU (D = 2, 6 and 8 coincide the same way). With D = 19
inc gives 31 mod 20 = 11 (0xB) and dec would give 8. Fixture, header, both
expected-word lists and the CPU reference updated; the test now also checks
that inc and dec differ at that D. llvmpipe: PASS with 11 in word 2.
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
@ImLele69

Copy link
Copy Markdown
Contributor

Tested on Linux, merged onto main 21625bca8 (PR head ce27f4dfe, merges cleanly).

GPU: NVIDIA GeForce RTX 2070 SUPER (Turing, subgroup 32), proprietary driver 620.70.06, Fedora 44, llvm-mc 22.1.8, SPIRV-Tools 2026.1.

Run This PR main alone
run_gpu_tests.py native 198/249 passed, 49 skipped 197/248 passed, 49 skipped
LEONIDA_W64_EMULATE=1 230/249 passed, 17 skipped 229/248 passed, 17 skipped
run_semantic_tests.py tests/semantic 466 files, 6112 tests, 0 files failed in 105 s with 16 jobs 465 files, 6108 tests, 0 files failed

New fixture cs_w32_atomic_contend: PASS in both modes.

The only failures in both runs are the known cs_imgload_tfe / cs_imgload_d16_tfe pair (#31), as on main. No regressions.

AI-assisted: yes (Claude Code ran the build and tests on my machine; numbers are the runners' own output).

@aslan2142

Copy link
Copy Markdown
Collaborator

This carry-over of old upstream PR 9912 has been taken over in #868, so I'm closing this draft as #17 describes. The branch old-pr/9912 stays.

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

@aslan2142 aslan2142 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants