Skip to content

compute: lower s_andn2_wrexec_b64 in the narrow wave64 model - #3335

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:compute-wave64-wrexec-same-reg
Nov 28, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:compute-wave64-wrexec-same-reg

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #3224. Follows #3314.

s_andn2_wrexec_b64 was refused with unsupported wave64 scalar operation in a guest wave64 request of at most 32 threads. That request runs on the wave32 model (src/gfx1013_compute_native.cpp, the wave64 comment in translate_program), and the b64 path only accepted wrexec with the full wave64 model.

  • translate_program records the narrow model (!stage && direct_dxil && !request.wave32 && !wave64). s_andn2_wrexec_b64 is lowered there as in full wave64: D = S0 & ~EXEC and EXEC = D, on both words, with SCC = D != 0. EXEC_HI starts at zero.
  • In that model a V_CMPX also writes 0 to EXEC_HI: lanes 32-63 hold no thread. This is exact when EXEC_HI was 0; if scalar code set bits there, the hardware result depends on VGPRs of lanes without threads.
  • transfer(): compute: forget EXEC symbols after 64-bit saveexec and wrexec #3314 already clears the EXEC symbols after every _wrexec_b64. The V_CMPX branch now also drops the s127 symbol in the narrow model.

Tests (Windows 11, RTX 5080, SDK 10.0.26100 DXC, Release, main 3f780716 plus #3314 and this commit; after the rebase on 7e5c378d the 27 targeted tests pass again):

  • native_scalar_mask64_controls compiles s_andn2_wrexec_b64 s[28:29], s[28:29] in a 32-thread wave64 request in three variants: EXEC_HI left at zero, set by a scalar move, and set by a scalar move then reset by v_cmpx_eq_u32 0, v0 before the WREXEC (EXEC_HI 0, 0x40000009 and 0 before the WREXEC). It checks the two and/xor words, the EXEC stores and SCC. An odd destination stays refused. The test also keeps three s_bcnt1_i32_b64 refusals that pass on main too.
  • On main the three positive programs are refused with unsupported wave64 scalar operation.
  • native_scalar_mask64_hardware replays the three variants and compares the lane stores, the destination words and SCC.
  • ctest -R "native_|startup_compute|compile_dxil|salu": 528 of 529. native_scalar_lds_hardware fails as on main.
  • 882 captured compute requests, compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests: 250 to 252. The added programs weigh 4,998 dispatches in that run. None is lost. Two programs that already compiled change only by the added store i32 0 to EXEC_HI after a V_CMPX.

Not covered: in the narrow model a V_CMP into an SGPR pair writes only the low word, so a WREXEC whose source pair comes from a V_CMP reads a stale high word (the same gap exists for s_and_b64 on main). In the two programs added above, the source pair comes from s_and_saveexec_b64 or s_mov_b64 ..., exec. No source mutations were run.

A guest wave64 request of at most 32 threads runs on the wave32 model,
where EXEC_HI starts at zero. s_andn2_wrexec_b64 is now lowered there as
in full wave64: D = S0 & ~EXEC and EXEC = D on both words. A V_CMPX that
writes EXEC also writes 0 to EXEC_HI in that model, since the guest has
no upper lanes.
@Leyukaka
Leyukaka force-pushed the compute-wave64-wrexec-same-reg branch from 8c2aaf8 to d62f93a Compare November 28, 2026 11:06

@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 7c5ecc3b (the PR's own change is unchanged; the new head only merges current main). The base #3314 is merged.

What I checked:

  • src/gfx1013_compute_native.cpp: a new narrow_wave64 flag (guest wave64 request that runs on the wave32 model) is threaded through parse and transfer; the V_CMPX-into-EXEC carry/compare destination is treated as a 64-bit pair only in that model. Wave64 and wave32 behaviour is unchanged.
  • src/gfx1013_direct_compute.inl: s_andn2_wrexec_b64 is accepted in the narrow model (s_andn1_wrexec_b64 stays wave64-only), and a V_CMPX into EXEC zeroes EXEC_HI in that model. The destination and source alignment limits are kept.
  • Tests native_scalar_mask64_controls (DXIL and refusals) and native_scalar_mask64_hardware (real D3D12 readback on WARP, which ran and did not skip) check lanes, EXEC words and the stored pair against a CPU reference.
  • No other open PR covers this slice.

Commands run:

  • Linux: git diff --check origin/main...HEAD clean, python3 -m py_compile tests/native_scalar_mask64_check.py ok.
  • Windows Server 2025, D3D12 WARP 1.0.22, -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$': dev 6/6 passed, release 6/6 passed.
  • Mutation 1 (the EXEC_HI zeroing after V_CMPX removed): native_scalar_mask64_controls and native_scalar_mask64_hardware fail (the cmpx case).
  • Mutation 2 (wrexec no longer accepted in the narrow model): both fail with unsupported wave64 scalar operation.

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 7c5ecc3 after updating with main.

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target compile_dxil native_store_replay -- -j 6): 6.87s (configure 0.00s)
    • Test (ctest --preset dev -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (1.70s: native_salu64_controls 0.22s, native_exec_symbol_b64_controls 0.26s, native_scalar_mask64_hardware 0.39s, native_scalar_mask64_controls 0.55s, native_wave64_exec_salu_hardware 1.11s, native_salu64_hardware 1.34s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target compile_dxil native_store_replay -- -j 6): 33.98s (configure 0.00s)
    • Test (ctest --preset release -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (1.37s: native_salu64_controls 0.16s, native_exec_symbol_b64_controls 0.20s, native_scalar_mask64_hardware 0.30s, native_scalar_mask64_controls 0.40s, native_wave64_exec_salu_hardware 0.88s, native_salu64_hardware 1.00s)
  • sccache: 0/4 hits; wall 39.6s

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 24fcd0b into R0Y00:main Nov 28, 2026
5 checks passed
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