compute: lower s_andn2_wrexec_b64 for wave64 direct compute #3247

Merged
Leyukaka merged 2 commits from upstream-pr/3247 into main 2026-11-28 03:25:19 +00:00
Leyukaka commented 2026-11-28 01:43:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T01:43:03Z.


Part of #2935, claimed in #3224 (item 2 of my third comment there). Target branch main.

Change (src/gfx1013_direct_compute.inl): with the wave64 model from #3006, direct compute lowers s_andn2_wrexec_b64.

  • It computes EXEC = S0 & ~EXEC over 64 bits and writes the new mask to EXEC and to the destination pair. SCC is set to EXEC != 0.
  • The operand order (S0 & ~EXEC) and the destination receiving the new mask match op_s_andn2_wrexec_b64 in tools/startup/gfx2hlsl.py, which models it per lane.
  • It reuses the 64-bit SAVEEXEC path. Each host half holds both EXEC words, so the replicated computation is the same in both halves.
  • Aligned general SGPR pairs only.
  • The wave32 model keeps refusing the b64 form.
  • s_andn1_wrexec_b64 stays refused: the repository has only its name and opcode (ISA table, disassembler), with no semantics to check against.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main 7364e6a9 plus this commit.

  • New native_wrexec64_hardware covers wave64 requests with 64 and 128 threads, two groups each.
  • It sets an explicit 64-bit EXEC whose two words are both nonzero, then runs s_andn2_wrexec_b64 with a source pair whose high word is nonzero.
  • It stores the destination pair, SCC and per-lane stores, and checks them against expected words.
  • With main's compile_dxil, the new test stops at "unsupported wave64 scalar operation".
  • 16 tests pass with -R "native_wrexec64|native_wave64|native_salu|native_direct_container".
  • Mutation check by hand: writing the old EXEC to the destination, as SAVEEXEC does, fails the new test.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, main 7364e6a9 against this commit.

  • Local capture of 2,689 requests: 494 to 525 compile.
  • Requests of one start-up run: 507 to 538.
  • The 882 requests of #3224: 128 to 132. The 4 new programs account for 17,133 dispatches.
  • All new programs used to stop at "unsupported wave64 scalar operation".
  • My claim in #3224 counted 13 programs on #3006 as pushed then. On 7364e6a9 that bucket holds 8 of the 882: 4 compile, 2 move on ("invalid s_cselect_b64 source" and "unbound numeric SGPR"), and 2 stay.
  • No program that compiled before stops compiling.
  • Counts and instruction shape only.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5535473966 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3247). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T01:43:03Z. --- Part of #2935, claimed in #3224 (item 2 of my third comment there). Target branch `main`. **Change** (`src/gfx1013_direct_compute.inl`): with the wave64 model from #3006, direct compute lowers `s_andn2_wrexec_b64`. - It computes `EXEC = S0 & ~EXEC` over 64 bits and writes the new mask to EXEC and to the destination pair. SCC is set to `EXEC != 0`. - The operand order (`S0 & ~EXEC`) and the destination receiving the new mask match `op_s_andn2_wrexec_b64` in `tools/startup/gfx2hlsl.py`, which models it per lane. - It reuses the 64-bit SAVEEXEC path. Each host half holds both EXEC words, so the replicated computation is the same in both halves. - Aligned general SGPR pairs only. - The wave32 model keeps refusing the b64 form. - `s_andn1_wrexec_b64` stays refused: the repository has only its name and opcode (ISA table, disassembler), with no semantics to check against. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on `main` `7364e6a9` plus this commit. - New `native_wrexec64_hardware` covers wave64 requests with 64 and 128 threads, two groups each. - It sets an explicit 64-bit EXEC whose two words are both nonzero, then runs `s_andn2_wrexec_b64` with a source pair whose high word is nonzero. - It stores the destination pair, SCC and per-lane stores, and checks them against expected words. - With `main`'s `compile_dxil`, the new test stops at "unsupported wave64 scalar operation". - 16 tests pass with `-R "native_wrexec64|native_wave64|native_salu|native_direct_container"`. - Mutation check by hand: writing the old EXEC to the destination, as SAVEEXEC does, fails the new test. **Measured** with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`, `main` `7364e6a9` against this commit. - Local capture of 2,689 requests: 494 to 525 compile. - Requests of one start-up run: 507 to 538. - The 882 requests of #3224: 128 to 132. The 4 new programs account for 17,133 dispatches. - All new programs used to stop at "unsupported wave64 scalar operation". - My claim in #3224 counted 13 programs on #3006 as pushed then. On `7364e6a9` that bucket holds 8 of the 882: 4 compile, 2 move on ("invalid s_cselect_b64 source" and "unbound numeric SGPR"), and 2 stay. - No program that compiled before stops compiling. - Counts and instruction shape only. AI-assisted.
tedin7 commented 2026-11-28 03:24:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T03:24:10Z.

Review: COMMENTED


Review of head d397e49f (the PR's own change is the same as 573c3b7c; the new head only merges current main).

What I checked:

  • src/gfx1013_direct_compute.inl: s_andn2_wrexec_b64 computes S0 & ~EXEC over both words, writes that new mask to EXEC (126/127) and to the destination pair, and sets SCC to EXEC != 0. That matches the ISA description of the instruction (the result goes to both EXEC and the destination, unlike SAVEEXEC) and op_s_andn2_wrexec_b64 in tools/startup/gfx2hlsl.py.
  • The new path is gated on compute && wave64; other models keep the old refusal (a SOP1 op that is not SAVEEXEC still hits unsupported wave64 scalar operation). Only aligned general SGPR pairs are accepted as source and destination, so VCC/EXEC/constants stay refused. The name is also added to the SCC-writer list used by uses_scc_after, next to its SAVEEXEC siblings.
  • Test native_wrexec64_hardware: real D3D12 readback of per-lane stores under the new EXEC, both destination words and SCC, for 64 and 128 threads, plus the EXEC-to-zero case and three operand refusals. The expected words are written out by hand, not derived from the translator.

Commands run:

  • Linux: python3 tests/docs_links_check.py ok, python3 tests/bidi_controls_check.py ok, git diff --check origin/main...HEAD clean, python3 -m py_compile tests/native_wrexec64_check.py ok.
  • Windows Server 2025, D3D12 WARP 1.0.22 (the test ran on WARP, it did not skip), -R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$': dev 4/4 passed, release 4/4 passed.
  • Mutation 1 (destination gets the old EXEC, as SAVEEXEC does): native_wrexec64_hardware fails (word 264, got 0x80000012, want 0x84).
  • Mutation 2 (EXEC not updated by WREXEC): native_wrexec64_hardware fails (word 9, lane stored under the old EXEC).

Side note, not caused by this PR: native_or_saveexec_hardware (wave32 s_or_saveexec_b32, #3193) fails on WARP 1.0.22 at the 8-thread all case, with the same assertion on current main without this change.

No blocking findings. The receipt follows in a separate comment.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095417245 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3247#pullrequestreview-6095417245). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T03:24:10Z. **Review:** COMMENTED --- Review of head `d397e49f` (the PR's own change is the same as `573c3b7c`; the new head only merges current `main`). What I checked: - `src/gfx1013_direct_compute.inl`: `s_andn2_wrexec_b64` computes `S0 & ~EXEC` over both words, writes that new mask to EXEC (126/127) and to the destination pair, and sets SCC to `EXEC != 0`. That matches the ISA description of the instruction (the result goes to both EXEC and the destination, unlike SAVEEXEC) and `op_s_andn2_wrexec_b64` in `tools/startup/gfx2hlsl.py`. - The new path is gated on `compute && wave64`; other models keep the old refusal (a SOP1 op that is not SAVEEXEC still hits `unsupported wave64 scalar operation`). Only aligned general SGPR pairs are accepted as source and destination, so VCC/EXEC/constants stay refused. The name is also added to the SCC-writer list used by `uses_scc_after`, next to its SAVEEXEC siblings. - Test `native_wrexec64_hardware`: real D3D12 readback of per-lane stores under the new EXEC, both destination words and SCC, for 64 and 128 threads, plus the EXEC-to-zero case and three operand refusals. The expected words are written out by hand, not derived from the translator. Commands run: - Linux: `python3 tests/docs_links_check.py` ok, `python3 tests/bidi_controls_check.py` ok, `git diff --check origin/main...HEAD` clean, `python3 -m py_compile tests/native_wrexec64_check.py` ok. - Windows Server 2025, D3D12 WARP 1.0.22 (the test ran on WARP, it did not skip), `-R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$'`: dev 4/4 passed, release 4/4 passed. - Mutation 1 (destination gets the old EXEC, as SAVEEXEC does): `native_wrexec64_hardware` fails (word 264, got `0x80000012`, want `0x84`). - Mutation 2 (EXEC not updated by WREXEC): `native_wrexec64_hardware` fails (word 9, lane stored under the old EXEC). Side note, not caused by this PR: `native_or_saveexec_hardware` (wave32 `s_or_saveexec_b32`, #3193) fails on WARP 1.0.22 at the 8-thread `all` case, with the same assertion on current `main` without this change. No blocking findings. The receipt follows in a separate comment. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-28 03:24:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T03:24:20Z.


Win2025 WARP receipt for head d397e49f after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit d397e49f459d5270ab8119c91d50b2325cf69915:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target compile_dxil native_store_replay -- -j 4): 3.10s (configure 0.00s)
    • Test (ctest --preset dev -R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$' --parallel 5 --no-tests=error --output-on-failure): 4/4 passed (14.45s: native_compute_clear 0.31s, native_wrexec64_hardware 0.80s, native_descriptor_scc_warp 0.82s, native_direct_container 13.95s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target compile_dxil native_store_replay -- -j 4): 5.61s (configure 0.00s)
    • Test (ctest --preset release -R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$' --parallel 5 --no-tests=error --output-on-failure): 4/4 passed (12.99s: native_compute_clear 0.25s, native_wrexec64_hardware 0.68s, native_descriptor_scc_warp 0.72s, native_direct_container 12.52s)
  • sccache: 4/5 hits; wall 23.5s
    tested: d397e49f via fetch (pull/3247/head, no patch)

The new test native_wrexec64_hardware ran on WARP (not skipped) in both legs.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7233047502 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3247#issuecomment-7233047502). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T03:24:20Z. --- Win2025 WARP receipt for head d397e49f after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `d397e49f459d5270ab8119c91d50b2325cf69915`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target compile_dxil native_store_replay -- -j 4`): `3.10s` (configure `0.00s`) - Test (`ctest --preset dev -R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$' --parallel 5 --no-tests=error --output-on-failure`): **4/4 passed** (`14.45s`: `native_compute_clear` `0.31s`, `native_wrexec64_hardware` `0.80s`, `native_descriptor_scc_warp` `0.82s`, `native_direct_container` `13.95s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target compile_dxil native_store_replay -- -j 4`): `5.61s` (configure `0.00s`) - Test (`ctest --preset release -R '^native_(wrexec64_hardware|compute_clear|direct_container|descriptor_scc_warp)$' --parallel 5 --no-tests=error --output-on-failure`): **4/4 passed** (`12.99s`: `native_compute_clear` `0.25s`, `native_wrexec64_hardware` `0.68s`, `native_descriptor_scc_warp` `0.72s`, `native_direct_container` `12.52s`) - `sccache`: 4/5 hits; wall `23.5s` tested: d397e49f via fetch (pull/3247/head, no patch) The new test `native_wrexec64_hardware` ran on WARP (not skipped) in both legs. AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!3247
No description provided.