Skip to content

compute: accept VCC as source in 64-bit scalar bit-count and bit-scan - #3456

Merged
JohnConnorNPC merged 3 commits into
R0Y00:mainfrom
Leyukaka:takeover-3402-salu-bitscan64-vcc
Nov 29, 2026
Merged

JohnConnorNPC merged 3 commits into
R0Y00:mainfrom
Leyukaka:takeover-3402-salu-bitscan64-vcc

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Takeover of #3402 by @Ammmae0x.

Change

  • 414874b6 (@Ammmae0x, unchanged): the s0_pair guard in src/gfx1013_direct_compute.inl accepts s0 == 106 (VCC) as the 64-bit source of s_bcnt0_i32_b64, s_bcnt1_i32_b64, s_ff0_i32_b64, s_ff1_i32_b64, s_flbit_i32_b64 and s_flbit_i32_i64. It adds native_salu_bitscan64_vcc_controls / native_salu_bitscan64_vcc_hardware, switches two existing VCC refusals to M0, and updates docs/experiments/native-direct-salu-bitscan64.md.
  • 863e9549: merge of main c04e0dd6, no conflict.
  • ee117c4f (tests only, 2 files):
    • tests/native_scalar_mask64_check.py: removes the comment VCC stays refused as a 64-bit count source and the two count_program() cases (64 and 32 threads) that expected invalid s_bcnt1_i32_b64 source. count_program() defaults to src=106; the guard change stops refusing that source, so the two cases no longer hold (not run on 414874b6 alone; this is from reading the guard). count_program(src=107) stays.
    • tests/native_salu_bitscan64_vcc_check.py: adds a refusal case sop1(FF1_64, 24, VCC + 1) expecting invalid s_ff1_i32_b64 source, so the new controls also refuse vcc_hi (107) as a source. The printed count goes from 6 to 7 invalid forms.

git diff --stat c04e0dd6 ee117c4f: 7 files, +268 -8. git merge-tree --write-tree --name-only origin/main ee117c4f against main 17b662a2 exits 0.

Verification

Head ee117c4f, Windows, network off, dev preset configured with -DX2W_WITH_OPUS=OFF, full build (exit 0), a hardware adapter.

ctest --preset dev --no-tests=error -R '^(native_salu_bitscan64|native_wave64_exec_salu|native_scalar_mask64_)' -> exit 0

native_salu_bitscan64_controls        Passed    1.86 s
native_salu_bitscan64_hardware        Passed   27.16 s
native_salu_bitscan64_vcc_controls    Passed    1.86 s
native_salu_bitscan64_vcc_hardware    Passed   57.59 s
native_scalar_mask64_controls         Passed    1.75 s
native_scalar_mask64_hardware         Passed    2.72 s
native_wave64_exec_salu_hardware      Passed    7.05 s
100% tests passed, 0 tests failed out of 7

compiled 64-bit scalar counts and scans (adjacent s32 descriptor preserved); 6 invalid forms refused; 6 reference mutants differ
compiled 6 ops with VCC source (plus lane-compare VCC); 7 invalid forms refused; 5 reference mutants differ

Not covered

  • No WARP leg: the four cmake files register only _controls and _hardware tests.
  • native_salu_bitscan64_vcc_hardware took 57.59 s here against its 60 s TIMEOUT.
  • release preset not run on this head.
  • The "reference mutants" mutate the Python reference, not the translator.
  • The wave32 cmp_lt16 / cmp_eq0 cases expect vcc_hi == 0 without setting it.
  • The gfx2hlsl text translator and the pixel path are untouched.
  • No run of the application.

Refs #3402, #3224, #2935

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Review of head ee117c4f. Its merge-base is c04e0dd6. git merge-tree --write-tree origin/main ee117c4f against main 4b0586d4 exits 0. No commit on main since c04e0dd6 touches src/gfx1013_direct_compute.inl. I only read the change. Nothing was built here; the native tests need Windows and DXC.

BLOCKED: this was CI still running. The run started at 13:32Z. At 13:38Z, Build and test on Windows, Run platform-independent Python checks on Linux and Assemble and translate gfx1013 fixtures had all passed, and the PR showed MERGEABLE CLEAN.

Checked:

  • The only source edit is the guard (|| s0 == 106 ||). operand32(i, 106) and operand32(i, 107) lift sgpr_limit to 108 for VCC. This is the same pair read that pair_high and the other 64-bit SALU guards on main already accept (s0 == 106 in the s_*_b64 mask lowerings). In wave32, initialize writes s107 = 0, which is why the cmp_lt16/cmp_eq0 wave32 cases expect hi = 0. The lowering after the guard is unchanged. It uses unaryBits 31/32/33 = Countbits/FirstbitLo/FirstbitHi.
  • The blocking point from the compute: accept VCC as source in 64-bit scalar bit-count and bit-scan #3402 review is fixed. The two count_program() cases that expected invalid s_bcnt1_i32_b64 source for VCC are removed. count_program(src=107) stays. On the merged tree, git grep -n 'invalid s_(bcnt[01]_i32_b64|ff[01]_i32_b64|flbit_i32_[bi]64) source' finds only non-VCC sources (M0, odd SGPR, exec_hi, vcc_hi, float).
  • Default path: since runtime: default to native shaders and Opus decoding #3449 these six ops with a VCC source are lowered in default runs instead of refused. The new hardware leg compares the result, the neighbour word, SCC and the guard words for all 6 ops × 6 VCC values, plus lane-compare VCC, in wave32 and wave64. By reading, controls fails on main: its first compile uses S0 = VCC and asserts returncode == 0.

SHOULD

  1. native_salu_bitscan64_vcc_hardware took 57.59 s in the posted run, against TIMEOUT 60 in tests/cmake/native_salu_bitscan64_vcc.cmake. It starts one native_store_replay per case, 102 in all (2 wave sizes × 51 cases). A slower adapter or a debug-layer run would hit the timeout, and ctest reports that as a failure, not a skip. A follow-up could raise the timeout, for example to 180 as tests/cmake/native_image_atomic_binops.cmake does, or batch the cases into fewer dispatches.

NIT

  1. docs/experiments/native-direct-salu-bitscan64.md says the controls check "6 invalid destination/source refusals (vcc/exec/m0 dst, …)". The refused tuple in tests/native_salu_bitscan64_check.py has no M0 destination case. The two destination cases are VCC and EXEC, and M0 is used only as a source.

Nothing blocks. Merging at ee117c4f.

AI-assisted.

@JohnConnorNPC
JohnConnorNPC merged commit c3cae61 into R0Y00:main Nov 29, 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.

3 participants