Tests: check v_alignbit_b32, v_alignbyte_b32 and v_perm_b32 on the GPU #1050

Closed
KarolKurzyna wants to merge 1 commit from upstream-pr/1057 into main
KarolKurzyna commented 2026-11-24 11:03:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KarolKurzyna on 2026-11-24T11:03:29Z.


v_alignbit_b32, v_alignbyte_b32 and v_perm_b32 had no unit or GPU test coverage in recomp/tests.rs. Their HLSL helpers (alignbit and perm_b32 in emit.rs) handle shift-by-zero guards, shift/byte-offset masking, and all four sign-extension and constant selector classes by hand. This adds a per-instruction GPU test checking all three against the RDNA2 ISA pseudocode.

Test-only: nothing outside crates/xcl/src/gpu/recomp/tests.rs changes. Searched open PRs and issues for v_perm_b32, v_alignbit, and v_alignbyte and found no existing PR or issue covering them.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs (gpu_alignbit_alignbyte_and_perm_b32):
    • Assembles V_ALIGNBIT_B32, V_ALIGNBYTE_B32, and V_PERM_B32 with VGPR, inline-constant (0, 3), and SGPR SRC2 operands, checks that translate completes cleanly, and runs via gpu_waves() (wave32, plus wave64 where supported).
    • 32 distinct per-lane vectors verified bit-for-bit against pure-Rust ISA references: shift = 0 and masked counts (32..64, 0xFC..0xFF, 0xFFFF_FFE0..0xFFFF_FFFF), byte offsets 0..3 and masked offsets (4, 36, 64), distinct-byte shuffles across src0/src1, one-hot and one-cold sign bits isolating v_perm_b32 selectors 8..11 (s1[15], s1[31], s0[15], s0[31]), near-miss bits (14/30), selector 12 (0x00) on all-ones, and selectors 13/20/28/255 (0xFF) to catch & 15 masking.

Tested

  • NVIDIA GeForce RTX 3070 Ti 8 GB (driver 621.24 / 32.0.16.2124, wave32, SM 6.6), Intel Core i5-14600K, Windows 11 26H2 (build 26300.9974), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17 (21d28f72), debug build
  • cargo test -p xcl --lib gpu_alignbit_alignbyte_and_perm_b32 -- --nocapture: 1 passed, 0 failed, 0 ignored (0.24 s)
  • Negative control on temporary local edits to emit.rs (reverted before commit): dropping alignbit's s == 0u guard failed on lane 0 (shift = 0), and swapping perm_b32 selectors 8 and 9 failed on lane 19 (s1 = 0x0000_8000)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 738 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests on this adapter (expected on wave32-only NVIDIA):
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
  • python scripts/pr_check.py --local: description ok

Regression run

  • Not needed: test-only change in crates/xcl/src/gpu/recomp/tests.rs (no runtime code changes).

Not tested

  • AMD / native wave64 GPUs (gpu_waves() wave64 branch), Intel GPUs, Wine, release test build
  • Retail titles (no XCL_SAMPLE_* variables set)

AI use

  • Google Antigravity, Gemini 4 Neon: audited untested recompiler instructions, checked open PRs for duplicates, wrote the test and this description, and ran the test suite and negative-control checks on the hardware listed above.
<!-- greyfinch-sync:ivall/xcl:issue:5470911349 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1057). Originally posted by [KarolKurzyna](https://github.com/KarolKurzyna) on 2026-11-24T11:03:29Z. --- `v_alignbit_b32`, `v_alignbyte_b32` and `v_perm_b32` had no unit or GPU test coverage in `recomp/tests.rs`. Their HLSL helpers (`alignbit` and `perm_b32` in `emit.rs`) handle shift-by-zero guards, shift/byte-offset masking, and all four sign-extension and constant selector classes by hand. This adds a per-instruction GPU test checking all three against the RDNA2 ISA pseudocode. Test-only: nothing outside `crates/xcl/src/gpu/recomp/tests.rs` changes. Searched open PRs and issues for `v_perm_b32`, `v_alignbit`, and `v_alignbyte` and found no existing PR or issue covering them. **What is in it** - `crates/xcl/src/gpu/recomp/tests.rs` (`gpu_alignbit_alignbyte_and_perm_b32`): - Assembles `V_ALIGNBIT_B32`, `V_ALIGNBYTE_B32`, and `V_PERM_B32` with VGPR, inline-constant (`0`, `3`), and SGPR `SRC2` operands, checks that `translate` completes cleanly, and runs via `gpu_waves()` (`wave32`, plus `wave64` where supported). - 32 distinct per-lane vectors verified bit-for-bit against pure-Rust ISA references: `shift = 0` and masked counts (`32..64`, `0xFC..0xFF`, `0xFFFF_FFE0..0xFFFF_FFFF`), byte offsets `0..3` and masked offsets (`4`, `36`, `64`), distinct-byte shuffles across `src0`/`src1`, one-hot and one-cold sign bits isolating `v_perm_b32` selectors `8..11` (`s1[15]`, `s1[31]`, `s0[15]`, `s0[31]`), near-miss bits (`14`/`30`), selector `12` (`0x00`) on all-ones, and selectors `13`/`20`/`28`/`255` (`0xFF`) to catch `& 15` masking. **Tested** - NVIDIA GeForce RTX 3070 Ti 8 GB (driver `621.24` / `32.0.16.2124`, wave32, SM 6.6), Intel Core i5-14600K, Windows 11 26H2 (build 26300.9974), `rustc 1.100.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.9.2602.17` (`21d28f72`), debug build - `cargo test -p xcl --lib gpu_alignbit_alignbyte_and_perm_b32 -- --nocapture`: 1 passed, 0 failed, 0 ignored (0.24 s) - Negative control on temporary local edits to `emit.rs` (reverted before commit): dropping `alignbit`'s `s == 0u` guard failed on lane 0 (`shift = 0`), and swapping `perm_b32` selectors `8` and `9` failed on lane 19 (`s1 = 0x0000_8000`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 738 passed, 0 failed, 41 ignored - `SKIPPED` GPU tests on this adapter (expected on wave32-only NVIDIA): - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64` - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` - `python scripts/pr_check.py --local`: `description ok` **Regression run** - Not needed: test-only change in `crates/xcl/src/gpu/recomp/tests.rs` (no runtime code changes). **Not tested** - AMD / native wave64 GPUs (`gpu_waves()` wave64 branch), Intel GPUs, Wine, release test build - Retail titles (no `XCL_SAMPLE_*` variables set) **AI use** - Google Antigravity, Gemini 4 Neon: audited untested recompiler instructions, checked open PRs for duplicates, wrote the test and this description, and ran the test suite and negative-control checks on the hardware listed above.
mynzjerko commented 2026-11-24 12:05:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mynzjerko on 2026-11-24T11:53:55Z.


Tested on native Windows + AMD RDNA4 (both wave64 and wave32 paths via gpu_waves()): the new test and full suite passed with 0 skips.

Tested

  • Commit: bf22429c3076f69657f79ace079e6fc61c2f7770
  • Hardware / OS: AMD Radeon RX 9070 (RDNA4, native wave64, driver 32.0.32029.2010), AMD Ryzen 5 7500F, Windows 11 Pro 10.0.26300, rustc 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17, debug build
  • cargo build --workspace: ok
  • cargo test -p xcl --lib -- gpu_alignbit_alignbyte_and_perm_b32 --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored (0 SKIPPED)
  • cargo test --workspace -- --test-threads=4: 738 passed, 0 failed, 41 ignored (xcl --lib: 695 passed, 0 failed, 21 ignored; SKIPPED GPU tests: 0)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine, release build, retail titles (scripts/smoke.ps1)

AI use

  • Google Antigravity (Gemini 4 Neon) checked out the PR, ran the builds and tests locally, and drafted this report; I verified the results before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7130692840 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1057#issuecomment-7130692840). Originally posted by [mynzjerko](https://github.com/mynzjerko) on 2026-11-24T11:53:55Z. --- Tested on native Windows + AMD RDNA4 (both `wave64` and `wave32` paths via `gpu_waves()`): the new test and full suite passed with 0 skips. **Tested** - Commit: `bf22429c3076f69657f79ace079e6fc61c2f7770` - Hardware / OS: AMD Radeon RX 9070 (RDNA4, native wave64, driver `32.0.32029.2010`), AMD Ryzen 5 7500F, Windows 11 Pro 10.0.26300, `rustc 1.100.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.9.2602.17`, debug build - `cargo build --workspace`: ok - `cargo test -p xcl --lib -- gpu_alignbit_alignbyte_and_perm_b32 --nocapture --test-threads=1`: 1 passed, 0 failed, 0 ignored (`0 SKIPPED`) - `cargo test --workspace -- --test-threads=4`: 738 passed, 0 failed, 41 ignored (`xcl --lib`: 695 passed, 0 failed, 21 ignored; `SKIPPED` GPU tests: 0) **Not tested** - NVIDIA / Intel GPUs, Linux / Wine, release build, retail titles (`scripts/smoke.ps1`) **AI use** - Google Antigravity (Gemini 4 Neon) checked out the PR, ran the builds and tests locally, and drafted this report; I verified the results before posting.
DavidM1911 commented 2026-11-25 09:08:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:04:45Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7157845284 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1057#issuecomment-7157845284). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T09:04:45Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-29 07:41:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:41:05Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252625795 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1057#issuecomment-7252625795). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:41:05Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:42:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:42:53Z.


Triage (#1607) – head bf22429

#445 (opened earlier the same day) adds gpu_vop3_integer_bit_and_minmax3 in the same file, which checks V_ALIGNBIT_B32, V_ALIGNBYTE_B32 and V_PERM_B32 against the same CPU definitions (funnel shift with the count masked to 5 bits, byte offset masked to 2 bits, perm selectors 0-7 / 8-11 sign bits of S1 then S0 / 12 = 0x00 / 13+ = 0xFF), over edge operands including shift counts 31-33 and the selector words 0x0B0A0908 and 0xFF0E0D0C, on both wave sizes. #1576 also tests all three ops.
The references in gpu_alignbit_alignbyte_and_perm_b32 are correct; the only thing it adds over #445 is the inline-constant and SGPR forms of SRC2, which go through the generic operand path.
Recommendation: close (superseded by #445).

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:7301022256 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1057#issuecomment-7301022256). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:42:53Z. --- **Triage (#1607)** – head bf22429 #445 (opened earlier the same day) adds `gpu_vop3_integer_bit_and_minmax3` in the same file, which checks V_ALIGNBIT_B32, V_ALIGNBYTE_B32 and V_PERM_B32 against the same CPU definitions (funnel shift with the count masked to 5 bits, byte offset masked to 2 bits, perm selectors 0-7 / 8-11 sign bits of S1 then S0 / 12 = 0x00 / 13+ = 0xFF), over edge operands including shift counts 31-33 and the selector words 0x0B0A0908 and 0xFF0E0D0C, on both wave sizes. #1576 also tests all three ops. The references in `gpu_alignbit_alignbyte_and_perm_b32` are correct; the only thing it adds over #445 is the inline-constant and SGPR forms of SRC2, which go through the generic operand path. Recommendation: close (superseded by #445). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 15:57:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:57:11Z.


Closing as superseded: the same change is in #445 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7316789789 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1057#issuecomment-7316789789). Originally posted by [throny](https://github.com/throny) on 2026-12-01T15:57:11Z. --- Closing as superseded: the same change is in #445 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5).

Pull request closed

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!1050
No description provided.