Skip to content

[upstream #1057] Tests: check v_alignbit_b32, v_alignbyte_b32 and v_perm_b32 on the GPU - #93

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1057
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1057

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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.

Mirror of xcl-dev#1057 (auto-synced, do not edit).

Add a per-instruction GPU test covering the three 64-bit-window VOP3
bit/byte alignment and permutation ops (`v_alignbit_b32`, `v_alignbyte_b32`,
`v_perm_b32`) against pure-Rust AMD RDNA2 ISA reference functions.

Covers shift=0 (guarding against HLSL `s0 << 32` wrap), masked upper bits
on shift/byte counts, all `v_perm_b32` selector classes (bytes 0..7,
sign-extension selectors 8..11 isolated with one-hot and one-cold sign
bits, constant 0x00 selector 12, constant 0xFF selectors 13..255 catching
4-bit masking), and both VGPR and scalar/inline-constant `SRC2` operands.

Assisted-by: Google Antigravity (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1057 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1057 branch November 25, 2026 00:11
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