wave64_emulate_opt: ds_append and ds_consume always barrier under --wave64-emulate #106

Open
github-bot wants to merge 1 commit from github-bot/gh-106 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:19 UTC · original
ubiquitarianism:old-pr/9838 → main · +12 −0 · 2 files · 1 commits · draft

Carried over from old PR 9838 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9838, 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.
This branch conflicts with the current main and needs a rebase.
tedin7: 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):

@ItsNotRexed: an exe PR, as you asked.

What

ds_append and ds_consume join _ALWAYS_BARRIER_OPS in tools/wave64_emulate_opt.py, with a unit test on the classification (_insn_may_barrier and _classify_block_body).

Why

Under --wave64-emulate these two ops hand the LDS counter's old value to every lane through an exchange round, which emits OpControlBarrier. Without the entry, a block holding one can be classed sync-free in a 128+ thread group and make_game.py --stages shaders aborts with "unexpected OpControlBarrier in sync-free multi-wave block". @autogenes-sudo reported this on #7154 with the #3976 translator; an independent check with the same one-line fix is in the #3976 thread.
Honest scope: today's origin/main translator does not emit ds_append/ds_consume (#3976 was closed in the org migration), so this prepares the classification for when it lands; it does not change output on current main.

Tested

python3 -I tests/semantic/test_wave64_emulate_opt.py on origin/main 2d53a8055 + this commit: 31 tests OK. Negative control: without the one-line change the new test fails ("False is not true : ds_append"). Synthetic data only; no game files.

**@⁠Andretuta** on GitHub · 2026-11-24 02:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/106) `ubiquitarianism:old-pr/9838` → `main` · +12 −0 · 2 files · 1 commits · draft > Carried over from **old PR 9838** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9838`, 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. > This branch conflicts with the current `main` and needs a rebase. > `tedin7`: 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): `@ItsNotRexed`: an exe PR, as you asked. ## What `ds_append` and `ds_consume` join `_ALWAYS_BARRIER_OPS` in `tools/wave64_emulate_opt.py`, with a unit test on the classification (`_insn_may_barrier` and `_classify_block_body`). ## Why Under `--wave64-emulate` these two ops hand the LDS counter's old value to every lane through an exchange round, which emits `OpControlBarrier`. Without the entry, a block holding one can be classed sync-free in a 128+ thread group and `make_game.py --stages shaders` aborts with "unexpected OpControlBarrier in sync-free multi-wave block". `@autogenes-sudo` reported this on `#7154` with the `#3976` translator; an independent check with the same one-line fix is in the `#3976` thread. Honest scope: today's `origin/main` translator does not emit `ds_append`/`ds_consume` (`#3976` was closed in the org migration), so this prepares the classification for when it lands; it does not change output on current main. ## Tested `python3 -I tests/semantic/test_wave64_emulate_opt.py` on `origin/main` 2d53a8055 + this commit: 31 tests OK. Negative control: without the one-line change the new test fails ("False is not true : ds_append"). Synthetic data only; no game files.
ds_append/ds_consume broadcast the LDS counter's old value through an exchange round (OpControlBarrier) under --wave64-emulate. Listing them in _ALWAYS_BARRIER_OPS keeps a block holding one from being classed sync-free in a multi-wave group, which aborted make_game.py --stages shaders with "unexpected OpControlBarrier in sync-free multi-wave block" once a translator emits them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:44:38 +00:00
Author
Owner

@⁠Len1k on GitHub · 2026-11-24 09:05 UTC · original

Ran this pull request's own tests, then put tools/wave64_emulate_opt.py back to the branch's base version (9ec34cdff) and ran them again — green both times, so the tests do not pin the change.

baseline (head sources, head tests)   tests/semantic/test_wave64_emulate_opt.py  rc=0  OK   (31 tests)
swapped tools/wave64_emulate_opt.py to its base version
mutation (base sources, head tests)   tests/semantic/test_wave64_emulate_opt.py  rc=0  OK   (31 tests)

This is not "already merged": head is 68,014 B, base is 67,935 B, current main is 68,965 B — three different files. So the source change is real and present, and the 31 tests simply do not observe the ds_append/ds_consume barrier under --wave64.

To make the test guard the fix, at least one case has to fail on the base source — e.g. translate a shader that uses ds_append with --wave64 and assert on the emitted barrier, not only that translation succeeds. Worth checking on review, because a reviewer reading 31 green tests will assume the behaviour is covered.

The change itself may be perfectly correct — I only measure whether the test would notice if it were gone.

AI-assisted. Standard library only, no game files, no GPU.

**@⁠Len1k** on GitHub · 2026-11-24 09:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/106#issuecomment-7126941833) Ran this pull request's own tests, then put `tools/wave64_emulate_opt.py` back to the branch's base version (`9ec34cdff`) and ran them again — **green both times**, so the tests do not pin the change. ``` baseline (head sources, head tests) tests/semantic/test_wave64_emulate_opt.py rc=0 OK (31 tests) swapped tools/wave64_emulate_opt.py to its base version mutation (base sources, head tests) tests/semantic/test_wave64_emulate_opt.py rc=0 OK (31 tests) ``` This is not "already merged": head is 68,014 B, base is 67,935 B, current `main` is 68,965 B — three different files. So the source change is real and present, and the 31 tests simply do not observe the `ds_append`/`ds_consume` barrier under `--wave64`. To make the test guard the fix, at least one case has to fail on the base source — e.g. translate a shader that uses `ds_append` with `--wave64` and assert on the emitted barrier, not only that translation succeeds. Worth checking on review, because a reviewer reading 31 green tests will assume the behaviour is covered. The change itself may be perfectly correct — I only measure whether the test would notice if it were gone. *AI-assisted.* Standard library only, no game files, no GPU.
This pull request has changes conflicting with the target branch.
  • tools/wave64_emulate_opt.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/106/head:github-bot/gh-106'
git switch 'github-bot/gh-106'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-106'
git switch 'github-bot/gh-106'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-106'
git switch 'github-bot/gh-106'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-106'
git switch 'main'
git merge --squash 'github-bot/gh-106'
git switch 'main'
git merge --ff-only 'github-bot/gh-106'
git switch 'main'
git merge 'github-bot/gh-106'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.