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

Closed
leonida/mandy
ambroseautomation wants to merge 0 commits from carry/old-10011-w64x-image-order into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

ambroseautomation commented 2026-11-24 19:37:40 +00:00

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)
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 approved these changes 2026-11-24 19:40:43 +00:00
abnalstlll-byte left a comment

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.

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

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

**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

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

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 approved these changes 2026-11-25 18:23:02 +00:00
tiguan26 left a comment

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).

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).
Sign in to join this conversation.
No description provided.