rdna2spirv: extract per-lane bits for non-mask special sources in s_mov_b32 exec_hi (SHADER-EXEC-HI-SPECIAL-SRC) #1994

Merged
ShotTechOp merged 1 commit from upstream-pr/1994 into main 2026-11-30 16:02:07 +00:00
ShotTechOp commented 2026-11-25 17:43:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-25T17:43:14Z.


Claimed in #1608 as SHADER-EXEC-HI-SPECIAL-SRC.

What and why

  • In tools/rdna2spirv.py, s_mov_b32 exec_lo, <special> falls through to Gen.dst -> Gen.exec_bit, which extracts bit (lane & 31) for every non-mask source (m0, scc/src_scc, plain-data vcc_lo/vcc_hi, etc.).
  • By contrast, the special-cased s_mov_b32 exec_hi, <src> branch only extracted per-lane bits when src["k"] == "sgpr" and otherwise passed raw self.src_u(src) straight into Gen.exec_half_write(1, val, None). Because exec_half_write tests val != 0, any non-zero bit in m0, src_scc, or plain-data vcc_lo/vcc_hi silently activated all 32 upper lanes (32..63) instead of only the lanes whose bits were set.
  • Routing non-mask sources through self.exec_bit(self.src_u(src)) while keeping lane-mask sources (self.holds_lane_mask(src)) on self.src_u(src) brings exec_hi into parity with exec_lo and hardware (both native wave64 and --wave64-emulate).
  • Updated the Constant lane masks / SHADER-1264 contract row in docs/design.md.

Testing

  • AI-assisted: yes.
  • Environment: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally).
  • New regression suite: tests/semantic/test_exec_hi_special_src.py — tests s_mov_b32 exec_hi from m0, plain-data vcc_lo, plain-data vcc_hi (native wave64 and --wave64-emulate), src_scc (0 and 1), and a lane-mask vcc_hi control while confirming exec_lo is preserved.
  • RED control on origin/main (fd33a31): tests/semantic/test_exec_hi_special_src.py fails on origin/main (proving m0, plain-data vcc_lo/vcc_hi, and src_scc = 1 turn on all 32 upper lanes instead of the set bits).
  • GREEN checks on branch:
    • python -I tests/semantic/test_exec_hi_special_src.py -v
    • python -m unittest discover -s tests/semantic -p test_exec_computed.py
    • python -m unittest discover -s tests/semantic -p test_wave64_mov_b32_cross_half.py
    • python -m unittest discover -s tests -p "test_docs_*.py"
    • python -I tests/test_text_write_line_endings.py
    • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_exec_hi_special_src.py
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_exec_hi_special_src.py
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496242799 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1994). Originally posted by [ShotTechOp](https://github.com/ShotTechOp) on 2026-11-25T17:43:14Z. --- Claimed in #1608 as `SHADER-EXEC-HI-SPECIAL-SRC`. ## What and why - In `tools/rdna2spirv.py`, `s_mov_b32 exec_lo, <special>` falls through to `Gen.dst` -> `Gen.exec_bit`, which extracts bit `(lane & 31)` for every non-mask source (`m0`, `scc`/`src_scc`, plain-data `vcc_lo`/`vcc_hi`, etc.). - By contrast, the special-cased `s_mov_b32 exec_hi, <src>` branch only extracted per-lane bits when `src["k"] == "sgpr"` and otherwise passed raw `self.src_u(src)` straight into `Gen.exec_half_write(1, val, None)`. Because `exec_half_write` tests `val != 0`, any non-zero bit in `m0`, `src_scc`, or plain-data `vcc_lo`/`vcc_hi` silently activated all 32 upper lanes (`32..63`) instead of only the lanes whose bits were set. - Routing non-mask sources through `self.exec_bit(self.src_u(src))` while keeping lane-mask sources (`self.holds_lane_mask(src)`) on `self.src_u(src)` brings `exec_hi` into parity with `exec_lo` and hardware (both native wave64 and `--wave64-emulate`). - Updated the `Constant lane masks` / `SHADER-1264` contract row in `docs/design.md`. ## Testing - **AI-assisted**: yes. - **Environment**: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally). - **New regression suite**: `tests/semantic/test_exec_hi_special_src.py` — tests `s_mov_b32 exec_hi` from `m0`, plain-data `vcc_lo`, plain-data `vcc_hi` (native wave64 and `--wave64-emulate`), `src_scc` (`0` and `1`), and a lane-mask `vcc_hi` control while confirming `exec_lo` is preserved. - **RED control on `origin/main` (`fd33a31`)**: `tests/semantic/test_exec_hi_special_src.py` fails on `origin/main` (proving `m0`, plain-data `vcc_lo`/`vcc_hi`, and `src_scc = 1` turn on all 32 upper lanes instead of the set bits). - **GREEN checks on branch**: - `python -I tests/semantic/test_exec_hi_special_src.py -v` - `python -m unittest discover -s tests/semantic -p test_exec_computed.py` - `python -m unittest discover -s tests/semantic -p test_wave64_mov_b32_cross_half.py` - `python -m unittest discover -s tests -p "test_docs_*.py"` - `python -I tests/test_text_write_line_endings.py` - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_exec_hi_special_src.py` - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_exec_hi_special_src.py`
ecox982745 commented 2026-11-25 17:45:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T17:45:43Z.


I confirmed the EXEC high-half fix on an RTX 4090, Windows 11, NVIDIA 616.64. I ran the same seven synthetic compute shaders on parent fd33a31a2 and head 37d433c79, using --wave64-emulate with 32-wide hardware subgroups. Each dispatch writes one word for each of the 64 logical lanes.

GPU check Parent Head
m0, plain-data vcc_lo and plain-data vcc_hi, six masks per source 6/18 18/18
src_scc, false and true 1/2 2/2
Compare-generated mask controls, including low-to-high copies from vcc_lo and s8 3/3 3/3

For example, writing m0 = 0x80000002 to exec_hi enabled all 32 upper lanes on the parent. On the head it enabled exactly lanes 33 and 63. Across the 23 dispatches, incorrect output words fell from 364 to zero out of 1,472. The low-half mask stayed at 0x00000003 and all 16 trailing guard words were intact on every readback. All seven shaders passed Vulkan 1.2 SPIR-V validation on both revisions.

Separately, the head passed all three CPU interpreter tests in test_exec_hi_special_src.py. Hardware coverage here is emulated wave64 on NVIDIA. AI-assisted verification with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169961897 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1994#issuecomment-7169961897). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T17:45:43Z. --- I confirmed the EXEC high-half fix on an RTX 4090, Windows 11, NVIDIA 616.64. I ran the same seven synthetic compute shaders on parent `fd33a31a2` and head `37d433c79`, using `--wave64-emulate` with 32-wide hardware subgroups. Each dispatch writes one word for each of the 64 logical lanes. | GPU check | Parent | Head | | --- | ---: | ---: | | `m0`, plain-data `vcc_lo` and plain-data `vcc_hi`, six masks per source | 6/18 | 18/18 | | `src_scc`, false and true | 1/2 | 2/2 | | Compare-generated mask controls, including low-to-high copies from `vcc_lo` and `s8` | 3/3 | 3/3 | For example, writing `m0 = 0x80000002` to `exec_hi` enabled all 32 upper lanes on the parent. On the head it enabled exactly lanes 33 and 63. Across the 23 dispatches, incorrect output words fell from **364 to zero out of 1,472**. The low-half mask stayed at `0x00000003` and all 16 trailing guard words were intact on every readback. All seven shaders passed Vulkan 1.2 SPIR-V validation on both revisions. Separately, the head passed all three CPU interpreter tests in `test_exec_hi_special_src.py`. Hardware coverage here is emulated wave64 on NVIDIA. AI-assisted verification with OpenAI Codex.
zmasi commented 2026-11-28 12:19:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:19:14Z.


Native wave64 confirmation on physical gfx906 (RADV Mesa 26.0.8), complementing the earlier emulated-wave64 check. Same 11 shaders and six runtime inputs against main d48a957bb and 37d433c79 merged with it. All translated, passed spirv-val and dispatched on both builds.

Main matched 49/66 readbacks; the merge matched 66/66 (488 wrong output words to zero). With only bits 1 and 31 set in M0, main enabled every upper lane; the merge enabled only lanes 33 and 63, leaving the lower half unchanged. With src_scc = 1, only lane 32 was enabled in the upper half on the merge. The 42 control dispatches, including same-half and opposite-half tagged mask copies, were byte-identical between builds. All guards matched; no Khronos validation errors or synchronization hazards in the shader runs.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239144941 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7239144941). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T12:19:14Z. --- Native wave64 confirmation on physical gfx906 (RADV Mesa 26.0.8), complementing the earlier emulated-wave64 check. Same 11 shaders and six runtime inputs against main `d48a957bb` and `37d433c79` merged with it. All translated, passed `spirv-val` and dispatched on both builds. Main matched 49/66 readbacks; the merge matched 66/66 (488 wrong output words to zero). With only bits 1 and 31 set in M0, main enabled every upper lane; the merge enabled only lanes 33 and 63, leaving the lower half unchanged. With `src_scc = 1`, only lane 32 was enabled in the upper half on the merge. The 42 control dispatches, including same-half and opposite-half tagged mask copies, were byte-identical between builds. All guards matched; no Khronos validation errors or synchronization hazards in the shader runs. AI-assisted.
TheGeogeo commented 2026-11-29 00:00:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:00:35Z.


Tested 37d433c79 merged (no commit) with main aa918e5d9. Python 3.12.4, Windows 11 10.0.26300, CPU only, with LLVM_MC (conda-forge llvm-tools) and SPIRV-Tools from the Vulkan SDK 1.4.363.1. check_no_game_data.py is clean.

  • Green: tests/semantic/test_exec_hi_special_src.py, 3 tests pass.
  • Red: with tools/rdna2spirv.py back to main, it fails (the upper lanes read 0 instead of their own bit).

Overlap check across #1973, #1977, #1990, #1943, #1994, #1996 and #1803 (same translator area):

  • None is a stack or a duplicate. They are independent single commits, and each covers a different reader:
    • plain 64-bit VCC data: #1973 for the b64 bit ops, #1977 for s_wqm, #1990 for src64_data/is_mask_op;
    • per-lane bits from non-mask sources: #1943 for VCC data, #1994 for s_mov into exec_hi, #1996 for m0/scc;
    • #1803: wave32 lane slots.
  • The only textual conflict is docs/design.md, between #1990, #1943 and #1994.
  • With all 7 merged together on main (docs/design.md taken from main), each PR's own test file passes. The full semantic suite (scripts/run_semantic_tests.py tests/semantic -j 4, 528 files, 6513 tests) fails in 2 files:
    • test_valu_cvt_f16_int16_mods, which fails on plain main too;
    • test_wave64_emulate_opt, which comes from #1990 alone (see #1990).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247808994 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7247808994). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:00:35Z. --- Tested `37d433c79` merged (no commit) with `main` `aa918e5d9`. Python 3.12.4, Windows 11 10.0.26300, CPU only, with `LLVM_MC` (conda-forge llvm-tools) and SPIRV-Tools from the Vulkan SDK 1.4.363.1. `check_no_game_data.py` is clean. - Green: `tests/semantic/test_exec_hi_special_src.py`, 3 tests pass. - Red: with `tools/rdna2spirv.py` back to `main`, it fails (the upper lanes read `0` instead of their own bit). Overlap check across #1973, #1977, #1990, #1943, #1994, #1996 and #1803 (same translator area): - None is a stack or a duplicate. They are independent single commits, and each covers a different reader: - plain 64-bit VCC data: #1973 for the b64 bit ops, #1977 for `s_wqm`, #1990 for `src64_data`/`is_mask_op`; - per-lane bits from non-mask sources: #1943 for VCC data, #1994 for `s_mov` into `exec_hi`, #1996 for `m0`/`scc`; - #1803: wave32 lane slots. - The only textual conflict is `docs/design.md`, between #1990, #1943 and #1994. - With all 7 merged together on `main` (`docs/design.md` taken from `main`), each PR's own test file passes. The full semantic suite (`scripts/run_semantic_tests.py tests/semantic -j 4`, 528 files, 6513 tests) fails in 2 files: - `test_valu_cvt_f16_int16_mods`, which fails on plain `main` too; - `test_wave64_emulate_opt`, which comes from #1990 alone (see #1990). No blocker from my side. AI-assisted (Claude Code).
OreoFR commented 2026-11-29 08:33:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:33:54Z.


@ShotTechOp this PR now conflicts with main (docs/design.md). Could you merge main into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7247808994. 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:7253186284 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7253186284). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:33:54Z. --- @ShotTechOp this PR now conflicts with `main` (`docs/design.md`). Could you merge `main` into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7247808994. 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:24:58 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7279812195 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1994#issuecomment-7279812195). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:24:58Z. --- Carried as #2723 because of the conflict with main after #2566; @ShotTechOp, 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!1994
No description provided.