[PR #1012] [MERGED] tests: GPU readback for the binary64 vector compares, v_cmp_*_f64 and v_cmpx_*_f64 (GPU-CMP-F64) #1049

Closed
opened 2026-11-26 20:19:55 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1012
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: gpu-test/cmp-f64


📝 Commits (2)

  • 5040782 tests: GPU readback for the binary64 vector compares, v_cmp_f64 and v_cmpx_f64 (GPU-CMP-F64)
  • d366ee2 Merge main into gpu-test/cmp-f64

📊 Changes

7 files changed (+560 additions, -4 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 docs/testing.md (+16 -0)
📝 runtime/test/shaders/check.py (+63 -0)
➕ runtime/test/shaders/cs_w32_cmp_f64.asm (+270 -0)
📝 scripts/run_gpu_tests.py (+5 -0)
➕ tests/test_gpu_cmp_f64.py (+194 -0)
📝 tests/test_shader_checks.py (+11 -3)

📄 Description

Claimed in the coordination issue as: GPU-CMP-F64 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137637578)

What and why

The v_cmp_*_f64, v_cmpx_*_f64 row of docs/design.md is CPU-checked and measured on native gfx1100, and said Not GPU-verified: no fixture in runtime/test/shaders used a binary64 compare, so the SPIR-V those 32 ops translate to (an ordering built from 32-bit integer ops, no Float64) had not run on a driver.

This adds cs_w32_cmp_f64, a memory-fed fixture in the style of cs_w32_shift64 (#590):

  • check.py seeds 256 operand pairs through VKC_HEAP_INIT: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword, a negative quiet NaN). Each of 128 threads loads two pairs at run time, so neither the translator nor the driver can fold a compare.
  • Per pair a thread stores a v_cmp_ word (through VCC) and a v_cmpx_ word (through EXEC): bits 0..15 are the 16 predicates in opcode order, bit 16 is tru run with the odd threads turned off (an inactive lane gets VCC 0 from v_cmp_ and stays off through v_cmpx_), bits 17 and 18 are lt and nge with VOP3 abs/neg.
  • The expected words come from Python floats (cmp_f64_words). Both GPU runners compare all 1536 heap words, the 1024 unchanged input words included.
  • tests/test_gpu_cmp_f64.py needs no GPU: it checks the oracle against an independent restatement of the 16 predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the readback and runner verdicts against a fake harness. tests/test_shader_checks.py counts and fakes the new case.
  • docs/testing.md describes the fixture and the contract row names it.

No translator or runtime change. The SGPR-pair and constant operand forms are not in the fixture; they stay CPU-checked by tests/semantic/test_cmp_f64.py.

Tested

At this head (50407827c on main 82a2aabcc), test programs rebuilt at this head, llvm-mc 23.1.4, SPIRV-Tools v2026.4:

  • python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass on the RTX 4070 Ti: PASS natively and with LEONIDA_W64_EMULATE=1 ("1536 words exact").
  • The same on llvmpipe (subgroup 8..8): PASS. The runner asks for 32-wide subgroups, the device says "not available", and the words are exact, so no step of the fixture depends on the subgroup width.
  • python -I tests/test_gpu_cmp_f64.py (9 tests), tests/test_shader_checks.py (87), tests/test_run_gpu_tests.py (64), tests/test_gpu_shift64.py, tests/test_docs_design_rows.py, tests/test_docs_links.py, tests/test_docs_repo_paths.py, tests/test_text_write_line_endings.py, tests/test_regen_fixtures.py: OK. python -m compileall -q make_game.py tools tests and scripts/check_no_game_data.py on the changed files: OK.

Before the rebase (the same change on main 42d705c85):

  • Negative controls on the RTX 4070 Ti, one translator rule broken at a time and the fixture rebuilt; each failed at the word the oracle predicts: no -0 canonicalization (word 206), a NaN test that ignores the low dword (28), an ordering key without the low dword (70), the raw result written to an inactive lane's VCC (2), v_cmpx_ replacing EXEC instead of narrowing it (3), abs ignored (0), nlt lowered as the negation of le (0).
  • Full run_gpu_tests.py on the RTX 4070 Ti: 260 shaders, 260 translated, 260 pass spirv-val; native 200/251 passed, 49 skipped, 2 failed; LEONIDA_W64_EMULATE=1 232/251 passed, 17 skipped, 2 failed. The two failures are cs_imgload_tfe and cs_imgload_d16_tfe, already recorded for this GPU in gpu-test-results/RTX4070Ti.txt.
  • Every standalone standard-library test file (490): all pass except tests/test_tool_stdout_encoding.py, which fails the same way without this change (tools/native_pso_hashes.py; #883 and #948 are open for it).

Not run: llvm-mc 19, which the linux-gpu-tools job assembles with (not installed here); the translator suite (nothing under tools/ or tests/semantic/ changes); Windows; AMD hardware. The 4070 Ti run checks the translated SPIR-V on a driver against IEEE-754. What ties the predicates to RDNA2 is the row's native gfx1100 measurement, which this does not repeat.

GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule; the existing row now names the fixture.)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1012 **Author:** [@milk4sale](https://github.com/milk4sale) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `gpu-test/cmp-f64` --- ### 📝 Commits (2) - [`5040782`](https://github.com/ubiquitarianism/leonida/commit/50407827cd2cb73313c585cdf3d3d40ed7918bae) tests: GPU readback for the binary64 vector compares, v_cmp_*_f64 and v_cmpx_*_f64 (GPU-CMP-F64) - [`d366ee2`](https://github.com/ubiquitarianism/leonida/commit/d366ee248992db80d03ac1e5ce323058c6ac9e5d) Merge main into gpu-test/cmp-f64 ### 📊 Changes **7 files changed** (+560 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `docs/testing.md` (+16 -0) 📝 `runtime/test/shaders/check.py` (+63 -0) ➕ `runtime/test/shaders/cs_w32_cmp_f64.asm` (+270 -0) 📝 `scripts/run_gpu_tests.py` (+5 -0) ➕ `tests/test_gpu_cmp_f64.py` (+194 -0) 📝 `tests/test_shader_checks.py` (+11 -3) </details> ### 📄 Description Claimed in the coordination issue as: GPU-CMP-F64 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137637578) ### What and why The `v_cmp_*_f64`, `v_cmpx_*_f64` row of `docs/design.md` is CPU-checked and measured on native gfx1100, and said **Not GPU-verified**: no fixture in `runtime/test/shaders` used a binary64 compare, so the SPIR-V those 32 ops translate to (an ordering built from 32-bit integer ops, no `Float64`) had not run on a driver. This adds `cs_w32_cmp_f64`, a memory-fed fixture in the style of `cs_w32_shift64` (#590): - `check.py` seeds 256 operand pairs through `VKC_HEAP_INIT`: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword, a negative quiet NaN). Each of 128 threads loads two pairs at run time, so neither the translator nor the driver can fold a compare. - Per pair a thread stores a `v_cmp_` word (through VCC) and a `v_cmpx_` word (through EXEC): bits 0..15 are the 16 predicates in opcode order, bit 16 is `tru` run with the odd threads turned off (an inactive lane gets VCC 0 from `v_cmp_` and stays off through `v_cmpx_`), bits 17 and 18 are `lt` and `nge` with VOP3 `abs`/`neg`. - The expected words come from Python floats (`cmp_f64_words`). Both GPU runners compare all 1536 heap words, the 1024 unchanged input words included. - `tests/test_gpu_cmp_f64.py` needs no GPU: it checks the oracle against an independent restatement of the 16 predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the readback and runner verdicts against a fake harness. `tests/test_shader_checks.py` counts and fakes the new case. - `docs/testing.md` describes the fixture and the contract row names it. No translator or runtime change. The SGPR-pair and constant operand forms are not in the fixture; they stay CPU-checked by `tests/semantic/test_cmp_f64.py`. ### Tested At this head (`50407827c` on `main` `82a2aabcc`), test programs rebuilt at this head, llvm-mc 23.1.4, SPIRV-Tools v2026.4: - `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass` on the RTX 4070 Ti: PASS natively and with `LEONIDA_W64_EMULATE=1` ("1536 words exact"). - The same on llvmpipe (subgroup 8..8): PASS. The runner asks for 32-wide subgroups, the device says "not available", and the words are exact, so no step of the fixture depends on the subgroup width. - `python -I tests/test_gpu_cmp_f64.py` (9 tests), `tests/test_shader_checks.py` (87), `tests/test_run_gpu_tests.py` (64), `tests/test_gpu_shift64.py`, `tests/test_docs_design_rows.py`, `tests/test_docs_links.py`, `tests/test_docs_repo_paths.py`, `tests/test_text_write_line_endings.py`, `tests/test_regen_fixtures.py`: OK. `python -m compileall -q make_game.py tools tests` and `scripts/check_no_game_data.py` on the changed files: OK. Before the rebase (the same change on `main` `42d705c85`): - Negative controls on the RTX 4070 Ti, one translator rule broken at a time and the fixture rebuilt; each failed at the word the oracle predicts: no `-0` canonicalization (word 206), a NaN test that ignores the low dword (28), an ordering key without the low dword (70), the raw result written to an inactive lane's VCC (2), `v_cmpx_` replacing EXEC instead of narrowing it (3), `abs` ignored (0), `nlt` lowered as the negation of `le` (0). - Full `run_gpu_tests.py` on the RTX 4070 Ti: 260 shaders, 260 translated, 260 pass `spirv-val`; native 200/251 passed, 49 skipped, 2 failed; `LEONIDA_W64_EMULATE=1` 232/251 passed, 17 skipped, 2 failed. The two failures are `cs_imgload_tfe` and `cs_imgload_d16_tfe`, already recorded for this GPU in `gpu-test-results/RTX4070Ti.txt`. - Every standalone standard-library test file (490): all pass except `tests/test_tool_stdout_encoding.py`, which fails the same way without this change (`tools/native_pso_hashes.py`; #883 and #948 are open for it). Not run: llvm-mc 19, which the `linux-gpu-tools` job assembles with (not installed here); the translator suite (nothing under `tools/` or `tests/semantic/` changes); Windows; AMD hardware. The 4070 Ti run checks the translated SPIR-V on a driver against IEEE-754. What ties the predicates to RDNA2 is the row's native gfx1100 measurement, which this does not repeat. GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No new rule; the existing row now names the fixture.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:55 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1049
No description provided.