Skip to content

compute: lower s_andn2_wrexec_b64 for wave64 direct compute - #3247

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:andn2-wrexec-b64
Nov 28, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:andn2-wrexec-b64

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

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.

AI-assisted.

s_andn2_wrexec_b64 computes EXEC = S0 & ~EXEC over 64 bits, writes the
new mask to EXEC and to the destination pair, and sets SCC to
(EXEC != 0). The operand order and the destination receiving the new
mask match tools/startup/gfx2hlsl.py op_s_andn2_wrexec_b64, which models
it per lane.
In the wave64 model each host half holds both EXEC words, so the
replicated 64-bit computation reuses the SAVEEXEC path. Aligned general
SGPR pairs only; the wave32 model keeps refusing the b64 form, and
s_andn1_wrexec_b64 stays refused.

New test native_wrexec64_hardware: wave64 64- and 128-thread groups with
an explicit 64-bit EXEC, the source pair, the destination pair, SCC and
per-lane stores against expected words.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

tedin7 commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head d397e49 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: d397e49 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.

@tedin7
tedin7 merged commit a44e1f9 into R0Y00:main Nov 28, 2026
5 checks passed
tedin7 added a commit to tedin7/Xbox2Windows that referenced this pull request Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants