rdna2spirv: order image_sample, image_gather4, image_bvh and ignore ds_nop in --wave64-emulate (OLD-10011) #1175

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1175 into main
ambroseautomation commented 2026-11-24 19:37:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T19:37:40Z.


Claimed in the coordination issue as: OLD-10011 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142121243)

What and why

Carries forward old-pr/10011 (draft #282, original commit author totonii preserved; indexed in #17), rebased cleanly onto current main.

Fixes memory-ordering coverage under --wave64-emulate in tools/rdna2spirv.py (Gen.x_memory_order) and tools/wave64_emulate_opt.py (_x_memory_order_access):

  • Counts image_sample*, image_gather4*, and image_bvh* as memory reads so RAW/WAR hazards against earlier or later stores in the same wave trigger an ordering round/barrier across emulated halves.
  • Ignores ds_nop alongside ds_swizzle_b32/ds_bpermute_b32/ds_permute_b32 so it is not misclassified as an LDS write.
  • Adds regression tests in tests/semantic/test_w64x_scalar_load_order.py for image_store -> image_sample_lz (RAW), image_sample_lz -> image_store (WAR), and mirror parity between Gen.x_memory_order and wave64_emulate_opt._x_memory_order_access.

Tested

  • python -m unittest discover -s tests/semantic -p test_w64x_scalar_load_order.py -v: 8 tests, OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6,171 tests, 0 files failed.
  • python -m compileall -q make_game.py tools tests: exit 0.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tools/wave64_emulate_opt.py tests/semantic/test_w64x_scalar_load_order.py: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — --wave64-emulate memory ordering parity)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479023109 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1175). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T19:37:40Z. --- Claimed in the coordination issue as: OLD-10011 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142121243) ### What and why Carries forward `old-pr/10011` (draft #282, original commit author `totonii` preserved; indexed in #17), rebased cleanly onto current `main`. Fixes memory-ordering coverage under `--wave64-emulate` in `tools/rdna2spirv.py` (`Gen.x_memory_order`) and `tools/wave64_emulate_opt.py` (`_x_memory_order_access`): - Counts `image_sample*`, `image_gather4*`, and `image_bvh*` as memory reads so RAW/WAR hazards against earlier or later stores in the same wave trigger an ordering round/barrier across emulated halves. - Ignores `ds_nop` alongside `ds_swizzle_b32`/`ds_bpermute_b32`/`ds_permute_b32` so it is not misclassified as an LDS write. - Adds regression tests in `tests/semantic/test_w64x_scalar_load_order.py` for `image_store -> image_sample_lz` (RAW), `image_sample_lz -> image_store` (WAR), and mirror parity between `Gen.x_memory_order` and `wave64_emulate_opt._x_memory_order_access`. ### Tested - `python -m unittest discover -s tests/semantic -p test_w64x_scalar_load_order.py -v`: 8 tests, OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 470 files, 6,171 tests, 0 files failed. - `python -m compileall -q make_game.py tools tests`: exit 0. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tools/wave64_emulate_opt.py tests/semantic/test_w64x_scalar_load_order.py`: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — `--wave64-emulate` memory ordering parity)
abnalstlll-byte commented 2026-11-24 19:40:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:40:43Z.

Review: APPROVED


Reviewed and verified. Fixes memory hazard tracking under --wave64-emulate in tools/rdna2spirv.py and tools/wave64_emulate_opt.py by classifying image_sample*, image_gather4*, and image_bvh* as memory reads against RAW/WAR store hazards, and properly ignoring ds_nop from LDS writes. Verified via tests/semantic/test_w64x_scalar_load_order.py (8/8 PASS). 100% clean-room.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6046114581 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1175#pullrequestreview-6046114581). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:40:43Z. **Review:** APPROVED --- Reviewed and verified. Fixes memory hazard tracking under `--wave64-emulate` in `tools/rdna2spirv.py` and `tools/wave64_emulate_opt.py` by classifying `image_sample*`, `image_gather4*`, and `image_bvh*` as memory reads against RAW/WAR store hazards, and properly ignoring `ds_nop` from LDS writes. Verified via `tests/semantic/test_w64x_scalar_load_order.py` (8/8 PASS). 100% clean-room.
Deedlyy commented 2026-11-24 20:10:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:10:14Z.


Recommendation: [MERGE]

Reasoning: Carries #282: under --wave64-emulate, image_sample*, image_gather4* and image_bvh* count as memory reads for hazard ordering, and ds_nop is ignored. Tiny translator change (+3/-3 in each tool) with a 75-line test. Missing ordering here could produce RAW/WAR races, so it's a worthwhile fix. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143138908 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1175#issuecomment-7143138908). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:10:14Z. --- **Recommendation:** [MERGE] **Reasoning:** Carries #282: under `--wave64-emulate`, `image_sample*`, `image_gather4*` and `image_bvh*` count as memory reads for hazard ordering, and `ds_nop` is ignored. Tiny translator change (+3/-3 in each tool) with a 75-line test. Missing ordering here could produce RAW/WAR races, so it's a worthwhile fix. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10
madhyn commented 2026-11-24 20:10:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T20:10:21Z.


Verified 3a6b0ccd7 on Arch Linux (Python 3.14):

  • PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_w64x_scalar_load_order.py: 8 tests passed (0.027 s)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143141768 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1175#issuecomment-7143141768). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T20:10:21Z. --- Verified `3a6b0ccd7` on Arch Linux (Python 3.14): - `PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_w64x_scalar_load_order.py`: **8 tests passed** (0.027 s) AI-assisted: yes
tiguan26 commented 2026-11-25 18:23:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T18:23:02Z.

Review: APPROVED


Approving. Merged into current main (b9320a1) with no conflicts. The new test_w64x_scalar_load_order.py passes, the wave64 tests in tests/test_wave64*.py pass (69 tests), and the full translator suite gives 490 files / 6,295 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13).

The same three prefixes (image_sample, image_gather4, image_bvh) are added to both memory-order classifiers, the one in rdna2spirv.py and the one in wave64_emulate_opt.py, so the emulation and its optimiser agree on which instructions are ordered reads.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6062818048 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1175#pullrequestreview-6062818048). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T18:23:02Z. **Review:** APPROVED --- Approving. Merged into current main (b9320a1) with no conflicts. The new `test_w64x_scalar_load_order.py` passes, the wave64 tests in `tests/test_wave64*.py` pass (69 tests), and the full translator suite gives 490 files / 6,295 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). The same three prefixes (`image_sample`, `image_gather4`, `image_bvh`) are added to both memory-order classifiers, the one in `rdna2spirv.py` and the one in `wave64_emulate_opt.py`, so the emulation and its optimiser agree on which instructions are ordered reads. AI-assisted (Claude).

Pull request closed

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!1175
No description provided.