fix(rdna2spirv): order image_sample, image_gather4, image_bvh and ignore ds_nop in --wave64-emulate #282

Merged
Andretuta merged 1 commit from upstream-pr/282 into main 2026-11-30 16:02:24 +00:00
Andretuta commented 2026-11-24 02:58:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:58:48Z.


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

Summary

Fixes two memory-ordering gaps in --wave64-emulate (tools/rdna2spirv.py and its mirror tools/wave64_emulate_opt.py):

  1. Order image_sample*, image_gather4*, and image_bvh* as "mem" reads: Both Gen.x_memory_order() (tools/rdna2spirv.py:5717) and _x_memory_order_access() (tools/wave64_emulate_opt.py:777) tracked image_load, image_store, and image_atomic, but omitted image_sample, image_gather4, and image_bvh. Under --wave64-emulate, an image_store/buffer_store followed by image_sample*/image_gather4*/image_bvh* (or vice versa) stayed in the same round without a barrier between the two 32-lane halves.
  2. Sync ds_nop parity: Adds "ds_nop" to Gen.x_memory_order()'s ignore tuple (tools/rdna2spirv.py:5713), matching _x_memory_order_access() (tools/wave64_emulate_opt.py:773) so ds_nop no longer marks LDS read+write dirty.

Testing

  • Fail-first proof: Added RAW (image_store -> image_sample_lz), WAR (image_sample_lz -> image_store), and mirror-parity (image_sample*, image_gather4*, image_bvh*, ds_nop) tests in tests/semantic/test_w64x_scalar_load_order.py. Before the fix, both image_store and image_sample_lz landed in the same round (%blk0) with no separating barrier and _x_memory_order_access("image_sample") returned None.
  • Semantic tests (-W default -W error::ResourceWarning):
    • python -I -W default -W error::ResourceWarning tests/semantic/test_w64x_scalar_load_order.py: 8/8 OK
    • python -I -W default -W error::ResourceWarning tests/semantic/test_wave64_emulate_opt.py: 30/30 OK
  • SPIR-V validation: Assembled and validated both emitted RAW and WAR shaders with spirv-as --target-env vulkan1.2 + spirv-val --target-env vulkan1.2 (0 errors).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465240505 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/282). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:58:48Z. --- > Carried over from **old PR 10011** by `totonicpu` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10011`, 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. > `totonicpu`: 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): ## Summary Fixes two memory-ordering gaps in `--wave64-emulate` (`tools/rdna2spirv.py` and its mirror `tools/wave64_emulate_opt.py`): 1. **Order `image_sample*`, `image_gather4*`, and `image_bvh*` as `"mem"` reads:** Both `Gen.x_memory_order()` (`tools/rdna2spirv.py:5717`) and `_x_memory_order_access()` (`tools/wave64_emulate_opt.py:777`) tracked `image_load`, `image_store`, and `image_atomic`, but omitted `image_sample`, `image_gather4`, and `image_bvh`. Under `--wave64-emulate`, an `image_store`/`buffer_store` followed by `image_sample*`/`image_gather4*`/`image_bvh*` (or vice versa) stayed in the same round without a barrier between the two 32-lane halves. 2. **Sync `ds_nop` parity:** Adds `"ds_nop"` to `Gen.x_memory_order()`'s ignore tuple (`tools/rdna2spirv.py:5713`), matching `_x_memory_order_access()` (`tools/wave64_emulate_opt.py:773`) so `ds_nop` no longer marks LDS read+write dirty. ## Testing - **Fail-first proof:** Added RAW (`image_store -> image_sample_lz`), WAR (`image_sample_lz -> image_store`), and mirror-parity (`image_sample*`, `image_gather4*`, `image_bvh*`, `ds_nop`) tests in `tests/semantic/test_w64x_scalar_load_order.py`. Before the fix, both `image_store` and `image_sample_lz` landed in the same round (`%blk0`) with no separating barrier and `_x_memory_order_access("image_sample")` returned `None`. - **Semantic tests (`-W default -W error::ResourceWarning`):** - `python -I -W default -W error::ResourceWarning tests/semantic/test_w64x_scalar_load_order.py`: **8/8 OK** - `python -I -W default -W error::ResourceWarning tests/semantic/test_wave64_emulate_opt.py`: **30/30 OK** - **SPIR-V validation:** Assembled and validated both emitted RAW and WAR shaders with `spirv-as --target-env vulkan1.2` + `spirv-val --target-env vulkan1.2` (0 errors).
GeorgiyDemo commented 2026-11-24 07:32:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-24T07:32:32Z.


Checked 1826e888 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main d42773d07:

  • Regression tests are real: tests/semantic/test_w64x_scalar_load_order.py has 8 tests at this head and all pass; the same file applied to main's translator fails 3 of 8 with AssertionError: None != ('mem', True, False) : image_sample.
  • GPU, LEONIDA_W64_EMULATE=1, MoltenVK 1.4.2: ps_sample* 6/6, gather 4/4, cs_bvh/cs_bvh32 2/2, identical to main on the same filters — no regression. To be explicit, these fixtures pass before and after here, so on this driver they do not by themselves distinguish the revisions; the semantic tests are what show the fix.

Note: the PR currently shows CONFLICTING against main; this check is on the head as-is. Binaries from main. llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125104160 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/282#issuecomment-7125104160). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-24T07:32:32Z. --- Checked `1826e888` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `d42773d07`: - **Regression tests are real:** `tests/semantic/test_w64x_scalar_load_order.py` has 8 tests at this head and all pass; the same file applied to `main`'s translator fails 3 of 8 with `AssertionError: None != ('mem', True, False) : image_sample`. - **GPU, `LEONIDA_W64_EMULATE=1`, MoltenVK 1.4.2:** `ps_sample*` 6/6, gather 4/4, `cs_bvh`/`cs_bvh32` 2/2, identical to `main` on the same filters — no regression. To be explicit, these fixtures pass before and after here, so on this driver they do not by themselves distinguish the revisions; the semantic tests are what show the fix. Note: the PR currently shows CONFLICTING against `main`; this check is on the head as-is. Binaries from `main`. llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.
OreoFR commented 2026-11-29 17:01:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:01:26Z.


@totonicpu this carried-over PR (your old PR 10011) now conflicts with main (tools/rdna2spirv.py). Could you merge main into it, by pushing to its branch or in your own PR from it (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/282#issuecomment-7125104160. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259359037 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/282#issuecomment-7259359037). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T17:01:26Z. --- @totonicpu this carried-over PR (your old PR 10011) now conflicts with `main` (`tools/rdna2spirv.py`). Could you merge `main` into it, by pushing to its branch or in your own PR from it (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/282#issuecomment-7125104160. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
OreoFR commented 2026-11-30 13:25:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:25:00Z.


Carried as #2724 because of the conflict with main after #2566; @totonicpu, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7279812749 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/282#issuecomment-7279812749). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:25:00Z. --- Carried as #2724 because of the conflict with main after #2566; @totonicpu, if you come back, say so and the carry is dropped.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!282
No description provided.