tests: GPU readback for dynamic 64-bit vector shifts (GPU-VALU64-SHIFTS) #590

Merged
JiyouProt merged 1 commit from upstream-pr/590 into main 2026-11-24 12:47:23 +00:00
JiyouProt commented 2026-11-24 09:19:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by JiyouProt on 2026-11-24T09:19:49Z.


Claimed in the coordination issue as: GPU-VALU64-SHIFTS — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126974854

What and why

The existing 64-bit vector-shift rules have CPU semantic coverage but no dedicated GPU fixture. Add cs_w32_shift64: 64 memory-fed cases cross eight boundary values with counts 0, 1, 31, 32, 33, 63, 64 and 65. It exercises v_lshlrev_b64, v_lshrrev_b64 and v_ashrrev_i64, with destinations overlapping the count register, one source word, or the entire source pair.

Both GPU runners compare all 640 heap words against a Python integer oracle: 384 result words and 256 unchanged input words. Runtime-loaded inputs prevent constant folding. The private heap input is cleaned up after each run. Six CPU tests cover boundary answers, late-result/input corruption, missing/truncated readbacks, unsupported Int64 and filtered-runner pass/fail/skip verdicts. Document the fixture and its ISA reference in docs/testing.md. No translator behavior changes.

Tested

Windows 11 26H2 build 26300.9974, Python 3.14.3, based on current main 7430f59b2755418f5db1682446a4ccef10d455b1. Harness rebuilt from this tree using LLVM-MinGW Clang 23.1.6, CMake 4.4.5 and Ninja 1.13.2; llvm-mc 23.1.6 and SPIRV-Tools v2026.4.

  • run_gpu_tests.py --filter cs_w32_shift64 --require-pass: 1/1 translated, 1/1 spirv-val valid, 640/640 words exact.
  • Separate build.py build plus check.py readback helper: 1/1 translated and validated, 640/640 exact.
  • GPU negative controls: pre-masking counts with 31 fails at word 66; replacing arithmetic right shift with logical right shift fails at word 251. Both mutated shaders still translate and validate; original fixture restored.
  • New CPU tests: 6 passed. Existing test_run_gpu*.py suites: 111 tests, 110 passed and 1 skipped. LF writer checks: 3 passed.
  • Full semantic suite: 465 files, 6,108 tests, 0 files failed (545 s, 8 jobs).
  • compileall, make_game.py --help, no-game-data scan of all five changed files and git diff --check: passed.

GPUs tested: NVIDIA GeForce RTX 3080 Ti, NVIDIA 616.92, Windows 11. This is a wave32 test of 64-bit values; native RDNA2 hardware was not tested. Devices without shader Int64 support skip the fixture. No game files used.

AI-assisted: yes, with Codex.

Checklist

  • Based on current main; GitHub reports Able to merge.
  • One topic.
  • No game data, keys or decryption, including logs and fixtures.
  • Existing translation behavior only; fixture and reference documented in docs/testing.md.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5469400062 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/590). Originally posted by [JiyouProt](https://github.com/JiyouProt) on 2026-11-24T09:19:49Z. --- Claimed in the coordination issue as: GPU-VALU64-SHIFTS — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126974854 ### What and why The existing 64-bit vector-shift rules have CPU semantic coverage but no dedicated GPU fixture. Add `cs_w32_shift64`: 64 memory-fed cases cross eight boundary values with counts 0, 1, 31, 32, 33, 63, 64 and 65. It exercises `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64`, with destinations overlapping the count register, one source word, or the entire source pair. Both GPU runners compare all 640 heap words against a Python integer oracle: 384 result words and 256 unchanged input words. Runtime-loaded inputs prevent constant folding. The private heap input is cleaned up after each run. Six CPU tests cover boundary answers, late-result/input corruption, missing/truncated readbacks, unsupported Int64 and filtered-runner pass/fail/skip verdicts. Document the fixture and its ISA reference in `docs/testing.md`. No translator behavior changes. ### Tested Windows 11 26H2 build 26300.9974, Python 3.14.3, based on current main `7430f59b2755418f5db1682446a4ccef10d455b1`. Harness rebuilt from this tree using LLVM-MinGW Clang 23.1.6, CMake 4.4.5 and Ninja 1.13.2; llvm-mc 23.1.6 and SPIRV-Tools v2026.4. - `run_gpu_tests.py --filter cs_w32_shift64 --require-pass`: 1/1 translated, 1/1 spirv-val valid, 640/640 words exact. - Separate `build.py` build plus `check.py` readback helper: 1/1 translated and validated, 640/640 exact. - GPU negative controls: pre-masking counts with 31 fails at word 66; replacing arithmetic right shift with logical right shift fails at word 251. Both mutated shaders still translate and validate; original fixture restored. - New CPU tests: 6 passed. Existing `test_run_gpu*.py` suites: 111 tests, 110 passed and 1 skipped. LF writer checks: 3 passed. - Full semantic suite: **465 files, 6,108 tests, 0 files failed** (545 s, 8 jobs). - compileall, `make_game.py --help`, no-game-data scan of all five changed files and `git diff --check`: passed. GPUs tested: NVIDIA GeForce RTX 3080 Ti, NVIDIA 616.92, Windows 11. This is a wave32 test of 64-bit values; native RDNA2 hardware was not tested. Devices without shader Int64 support skip the fixture. No game files used. AI-assisted: yes, with Codex. ### Checklist - [x] Based on current main; GitHub reports Able to merge. - [x] One topic. - [x] No game data, keys or decryption, including logs and fixtures. - [x] Existing translation behavior only; fixture and reference documented in docs/testing.md.
trigger337 commented 2026-11-24 09:46:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T09:46:21Z.


Hardware verification report for cs_w32_shift64 on native RDNA2 hardware:

Environment:

  • GPU: AMD Radeon RX 6900 XT (RADV NAVI21, RDNA2, subgroup size 32..64)
  • Driver: Mesa 26.2.5-cachyos1.1 (Vulkan 1.4.333)
  • Host: Linux CachyOS (x86_64, kernel 7.3.1-2-cachyos)
  • Python: 3.14.3
  • Tree: PR #590 (codex/gpu-valu64-shifts) based on upstream main

Results:

  1. python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_shift64 --require-pass:
    • Translation: 1/1 (100%)
    • SPIR-V validation: 1/1 pass (spirv-val)
    • GPU readback: PASS cs_w32_shift64 640 words exact (64 shift cases and unchanged inputs) (1/1 passed)
  2. Emulated run (LEONIDA_W64_EMULATE=1):
    • GPU readback: PASS cs_w32_shift64 640 words exact (64 shift cases and unchanged inputs) (1/1 passed)
  3. Unit test suite:
    • python3 -m unittest tests/test_gpu_shift64.py: Ran 6 tests in 0.106s — OK.

Confirms correct hardware execution on native AMD RDNA2 GPU.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7127867069 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/590#issuecomment-7127867069). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T09:46:21Z. --- Hardware verification report for cs_w32_shift64 on native RDNA2 hardware: **Environment:** - GPU: AMD Radeon RX 6900 XT (RADV NAVI21, RDNA2, subgroup size 32..64) - Driver: Mesa 26.2.5-cachyos1.1 (Vulkan 1.4.333) - Host: Linux CachyOS (x86_64, kernel 7.3.1-2-cachyos) - Python: 3.14.3 - Tree: PR #590 (`codex/gpu-valu64-shifts`) based on upstream `main` **Results:** 1. `python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_shift64 --require-pass`: - Translation: 1/1 (100%) - SPIR-V validation: 1/1 pass (`spirv-val`) - GPU readback: `PASS cs_w32_shift64 640 words exact (64 shift cases and unchanged inputs)` (1/1 passed) 2. Emulated run (`LEONIDA_W64_EMULATE=1`): - GPU readback: `PASS cs_w32_shift64 640 words exact (64 shift cases and unchanged inputs)` (1/1 passed) 3. Unit test suite: - `python3 -m unittest tests/test_gpu_shift64.py`: Ran 6 tests in 0.106s — OK. Confirms correct hardware execution on native AMD RDNA2 GPU. agent: yes AI-assisted: yes
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
ProjectLeonida/mandy!590
No description provided.