Tests: check bit-scan, reverse, bitfield and byte-permute ops on the GPU #1217

Open
plentilha wants to merge 1 commit from upstream-pr/1226 into main
plentilha commented 2026-11-24 13:24:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by plentilha on 2026-11-24T13:24:39Z.


Adds GPU execution tests for nine translated bitwise and bitfield VALU instructions that had no existing GPU test coverage: v_not_b32, v_xnor_b32, v_bfrev_b32, v_ffbh_u32, v_ffbh_i32, v_ffbl_b32, v_bfm_b32, v_bfi_b32 and v_perm_b32. Test-only change.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_bitwise_and_bitfield_ops exercising zero, all-ones, sign-bit, bitmask wrap, and all v_perm_b32 selector classes (byte picks, half/word sign extensions, 0x00 and 0xFF fills) through gpu_waves().

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 (driver 32.0.16.2124, wave32 only), Intel Core i7-9700K, Windows 11 x64, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug
  • ./scripts/test.ps1: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64))
  • cargo test -p xcl --lib -- gpu_bitwise_and_bitfield_ops --nocapture: 1 passed, 0 failed (wave32 pass on this adapter)

Regression run

  • Not needed: test-only change.

Not tested

  • Native wave64 pass (AMD/Intel GPUs), retail game runs (XCL_SAMPLE_* unset), Wine, release build.

AI use

  • Antigravity (Gemini 4 Hydrogen): checked emit.rs coverage, wrote the test and PR description, and ran the test suite locally.
<!-- greyfinch-sync:ivall/xcl:issue:5472996025 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226). Originally posted by [plentilha](https://github.com/plentilha) on 2026-11-24T13:24:39Z. --- Adds GPU execution tests for nine translated bitwise and bitfield VALU instructions that had no existing GPU test coverage: `v_not_b32`, `v_xnor_b32`, `v_bfrev_b32`, `v_ffbh_u32`, `v_ffbh_i32`, `v_ffbl_b32`, `v_bfm_b32`, `v_bfi_b32` and `v_perm_b32`. Test-only change. **What is in it** - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_bitwise_and_bitfield_ops` exercising zero, all-ones, sign-bit, bitmask wrap, and all `v_perm_b32` selector classes (byte picks, half/word sign extensions, `0x00` and `0xFF` fills) through `gpu_waves()`. **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 (driver 32.0.16.2124, wave32 only), Intel Core i7-9700K, Windows 11 x64, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug - `./scripts/test.ps1`: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64)) - `cargo test -p xcl --lib -- gpu_bitwise_and_bitfield_ops --nocapture`: 1 passed, 0 failed (wave32 pass on this adapter) **Regression run** - Not needed: test-only change. **Not tested** - Native wave64 pass (AMD/Intel GPUs), retail game runs (`XCL_SAMPLE_*` unset), Wine, release build. **AI use** - Antigravity (Gemini 4 Hydrogen): checked `emit.rs` coverage, wrote the test and PR description, and ran the test suite locally.
DavidM1911 commented 2026-11-24 14:06:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:39:21Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib recomp: 190 passed, 0 failed, 18 ignored (new GPU checks included).

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133143607 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1226#issuecomment-7133143607). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:39:21Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib recomp`: 190 passed, 0 failed, 18 ignored (new GPU checks included). Thanks!
upipibi commented 2026-11-24 15:05:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T14:09:17Z.


I checked the expected values against the RDNA2 definitions (read from the ISA, not run on AMD hardware). All 9 match:

  • v_perm_b32: over {S0, S1} with S1 the low dword, a selector of 0–3 picks an S1 byte and 4–7 an S0 byte. 8, 9, 10 and 11 give the sign of bit 15 and bit 31 of S1, then of S0. 12 gives 0x00; 13 and above give 0xFF.
  • v_ffbh_i32: the position, counted from the MSB, of the first bit that differs from the sign bit, and -1 for 0 and -1.
  • v_bfm_b32: 0 at width 0.

perm_ref and ffbh_i_ref encode exactly these. No changes needed from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ivall/xcl:comment:7133924251 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1226#issuecomment-7133924251). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T14:09:17Z. --- I checked the expected values against the RDNA2 definitions (read from the ISA, not run on AMD hardware). All 9 match: - `v_perm_b32`: over `{S0, S1}` with S1 the low dword, a selector of 0–3 picks an S1 byte and 4–7 an S0 byte. 8, 9, 10 and 11 give the sign of bit 15 and bit 31 of S1, then of S0. 12 gives `0x00`; 13 and above give `0xFF`. - `v_ffbh_i32`: the position, counted from the MSB, of the first bit that differs from the sign bit, and `-1` for 0 and -1. - `v_bfm_b32`: 0 at width 0. `perm_ref` and `ffbh_i_ref` encode exactly these. No changes needed from my side. AI-assisted (Claude Code).
DavidM1911 commented 2026-11-26 05:05:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:17:15Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7182461577 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226#issuecomment-7182461577). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:17:15Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Luislariosss commented 2026-11-26 23:04:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Luislariosss on 2026-11-26T23:04:25Z.


Compatibility note, in case it saves a conflict later: I have a local change to Shader::bfrev (crates/xcl/src/gpu/dxil/ops.rs) that reverses a dynamic Bfrev.i32 with shifts instead of dx.op unary 30, because amdxc64 returns x | bfrev(x) when the operand descends from a 64-bit op (#2115, fuzz seed 1599's dynamic form). It is posted as a patch in https://github.com/xcl-dev/xcl/issues/2115#issuecomment-7205170040 and is not a PR yet (it needs a retail smoke run I cannot do).

I merged this PR on top of it and ran cargo test -p xcl --lib gpu::recomp::tests on an RX 9060 XT (driver 32.0.32029.2010): 168 passed, 0 failed, 17 ignored. So the v_bfrev_b32 coverage here still passes when the direct path stops using the native Bfrev.i32 for dynamic operands - the tests exercise the translated output, not the dx.op.

<!-- greyfinch-sync:ivall/xcl:comment:7205230137 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226#issuecomment-7205230137). Originally posted by [Luislariosss](https://github.com/Luislariosss) on 2026-11-26T23:04:25Z. --- Compatibility note, in case it saves a conflict later: I have a local change to `Shader::bfrev` (`crates/xcl/src/gpu/dxil/ops.rs`) that reverses a **dynamic** `Bfrev.i32` with shifts instead of `dx.op unary` 30, because amdxc64 returns `x | bfrev(x)` when the operand descends from a 64-bit op (#2115, fuzz seed 1599's dynamic form). It is posted as a patch in https://github.com/xcl-dev/xcl/issues/2115#issuecomment-7205170040 and is not a PR yet (it needs a retail smoke run I cannot do). I merged this PR on top of it and ran `cargo test -p xcl --lib gpu::recomp::tests` on an RX 9060 XT (driver 32.0.32029.2010): **168 passed, 0 failed, 17 ignored**. So the `v_bfrev_b32` coverage here still passes when the direct path stops using the native `Bfrev.i32` for dynamic operands - the tests exercise the translated output, not the dx.op.
JJAutoCompare commented 2026-11-27 00:24:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:24:46Z.


Tested: Clean f09c1d44ac0185521ac98be091d7914902d7514c, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. cargo test -j 2 -p xcl --lib --locked --no-run then exact gpu::recomp::tests::gpu_bitwise_and_bitfield_ops, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, and gpu::recomp::dxc::version_tests::the_loaded_dxc_is_identified with --nocapture --test-threads=1. One GPU fixture passed all nine VOP3 operations across 32 lanes, and the DXC identity test passed. The native-wave64 fixture emitted SKIPPED … no wave64 and counted as a pass in libtest. No failures or ignores.

Not tested: Native wave64, direct DXIL, full workspace suite and retail smoke.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7206438717 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226#issuecomment-7206438717). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-27T00:24:46Z. --- **Tested:** Clean `f09c1d44ac0185521ac98be091d7914902d7514c`, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. `cargo test -j 2 -p xcl --lib --locked --no-run` then exact `gpu::recomp::tests::gpu_bitwise_and_bitfield_ops`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`, and `gpu::recomp::dxc::version_tests::the_loaded_dxc_is_identified` with `--nocapture --test-threads=1`. One GPU fixture passed all nine VOP3 operations across 32 lanes, and the DXC identity test passed. The native-wave64 fixture emitted `SKIPPED … no wave64` and counted as a pass in libtest. No failures or ignores. **Not tested:** Native wave64, direct DXIL, full workspace suite and retail smoke. **AI use:** T3 Code / Codex (`gpt-6.2-sol`) ran and reran the checks and wrote this report.
Decodere commented 2026-11-27 10:45:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T10:45:20Z.


Independent desktop NVIDIA verification of PR #1226 at head f09c1d44ac0185521ac98be091d7914902d7514c (1 commit; exact parent & merge-base: 47efa2ecea0a12934719ae69b81930cf02a4b1c3, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted GPU tests & build (f09c1d44)

Command Result
cargo test --release -p xcl --lib gpu_bitwise_and_bitfield_ops -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 719 filtered out × 3 (0.28s, 0.23s, 0.22s, 0 skipped; live RTX 4060 execution compiled with DXC 1.9.2609.5)
cargo build --release -p xcl Clean build (1m 20s test compile + 0.06s incremental --release build, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

(Note: scripts/smoke.ps1 at 47efa2ec predates 9683e7a6 and printed the local folder basename on title:; replaced below with the standard 9683e7a6 title hash 29640639, with all measured fields verbatim.)

Exact parent & merge-base (47efa2ecea0a12934719ae69b81930cf02a4b1c3):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1527 (PresentX 1527)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14723 MB

PR #1226 (f09c1d44ac0185521ac98be091d7914902d7514c):

xcl-smoke v1
commit: f09c1d44ac0185521ac98be091d7914902d7514c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1596 (PresentX 1596)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14713 MB

Limits of coverage

  • This PR is test-only (crates/xcl/src/gpu/recomp/tests.rs, 0 production-code changes); gpu_bitwise_and_bitfield_ops compiled and executed 3/3 on desktop RTX 4060 (Wave32-only Ada; native Wave64 paths are not exercised).
  • The 60 s retail smoke confirms non-regression of the unchanged runtime binary at this commit (single-run frame/commit delta vs. parent reflects normal startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ivall/xcl:comment:7216265714 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226#issuecomment-7216265714). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T10:45:20Z. --- Independent desktop NVIDIA verification of **PR #1226** at head `f09c1d44ac0185521ac98be091d7914902d7514c` (`1` commit; exact parent & merge-base: `47efa2ecea0a12934719ae69b81930cf02a4b1c3`, pre-`#2555` ancestor of `main`). ### Environment - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12, Wave32-only Ada), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6C / 12T), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` (Developer Mode off) - **Toolchain:** `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC, DXC `1.9.2609.5`, `--release` ### Targeted GPU tests & build (`f09c1d44`) | Command | Result | | --- | --- | | `cargo test --release -p xcl --lib gpu_bitwise_and_bitfield_ops -- --nocapture` (3 consecutive runs) | `1 passed; 0 failed; 0 ignored; 719 filtered out` × 3 (`0.28s`, `0.23s`, `0.22s`, `0` skipped; live RTX 4060 execution compiled with DXC `1.9.2609.5`) | | `cargo build --release -p xcl` | Clean build (`1m 20s` test compile + `0.06s` incremental `--release` build, exit `0`, `0` new warnings) | ### Paired quiet 60 s retail smoke (`title: 29640639`) *(Note: `scripts/smoke.ps1` at `47efa2ec` predates `9683e7a6` and printed the local folder basename on `title:`; replaced below with the standard `9683e7a6` title hash `29640639`, with all measured fields verbatim.)* Exact parent & merge-base (`47efa2ecea0a12934719ae69b81930cf02a4b1c3`): ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1527 (PresentX 1527) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14723 MB ``` PR #1226 (`f09c1d44ac0185521ac98be091d7914902d7514c`): ``` xcl-smoke v1 commit: f09c1d44ac0185521ac98be091d7914902d7514c gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1596 (PresentX 1596) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14713 MB ``` ### Limits of coverage - This PR is test-only (`crates/xcl/src/gpu/recomp/tests.rs`, `0` production-code changes); `gpu_bitwise_and_bitfield_ops` compiled and executed `3/3` on desktop RTX 4060 (Wave32-only Ada; native Wave64 paths are not exercised). - The 60 s retail smoke confirms non-regression of the unchanged runtime binary at this commit (single-run frame/commit delta vs. parent reflects normal startup variance, not this PR). *AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).*
Foniass commented 2026-12-01 05:10:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:10:18Z.


Triage (#1607) – head f09c1d4

Overlaps the open GPU test PRs of #1607 group D171 for some ops: v_bfi_b32, v_bfm_b32 and v_perm_b32 are also tested by #445 and #1576, v_perm_b32 by #1057, and v_ffbh_u32/v_ffbh_i32/v_ffbl_b32 by #1576. v_not_b32, v_xnor_b32 and v_bfrev_b32 are tested by none of them and none of these ops is tested on main. Unlike #1576 (wave64 only), this test also runs wave32 through gpu_waves().
The reference functions (byte selectors 8-12 in perm_ref, all-same-bits = -1 in ffbh_i_ref, width & 31 in bfm) match the RDNA2 definitions.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301492595 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1226#issuecomment-7301492595). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:10:18Z. --- **Triage (#1607)** – head f09c1d4 Overlaps the open GPU test PRs of #1607 group D171 for some ops: v_bfi_b32, v_bfm_b32 and v_perm_b32 are also tested by #445 and #1576, v_perm_b32 by #1057, and v_ffbh_u32/v_ffbh_i32/v_ffbl_b32 by #1576. v_not_b32, v_xnor_b32 and v_bfrev_b32 are tested by none of them and none of these ops is tested on main. Unlike #1576 (wave64 only), this test also runs wave32 through `gpu_waves()`. The reference functions (byte selectors 8-12 in `perm_ref`, all-same-bits = -1 in `ffbh_i_ref`, width & 31 in bfm) match the RDNA2 definitions. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1226:upstream-pr/1226'
git switch 'upstream-pr/1226'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1226'
git switch 'upstream-pr/1226'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1226'
git switch 'upstream-pr/1226'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1226'
git switch 'main'
git merge --squash 'upstream-pr/1226'
git switch 'main'
git merge --ff-only 'upstream-pr/1226'
git switch 'main'
git merge 'upstream-pr/1226'
git push origin 'main'
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
xcl-dev/xcl!1217
No description provided.