tools: record the f32 compares on an RDNA 2 card (T5) #652

Merged
JeffreyBytes merged 5 commits from upstream-pr/652 into main 2026-12-02 21:30:52 +00:00
JeffreyBytes commented 2026-12-02 12:38:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-02T12:38:26Z.


Summary

Next piece of T5 (#412): what the f32 compares return on an RDNA 2 card under every MODE value. That's v_cmp_*_f32 for all sixteen conditions, v_cmp_class_f32, and the v_cmpx_*_f32 forms, which write EXEC instead.

I picked this family from a census of the recorded shaders. I sampled every fourth of the 53,697 recorded programs and translated 10,631 of them. The compares were the largest family with no native RDNA 2 reference yet: 9,167 of those 10,631 programs use them, 565,885 static uses in all. The next one, the conversions and packs, had 262,658.

Same route as #420, #437 and #469: hand-written kernels through ROCm, MODE[9:0] set with s_setreg_b32, all 1,024 MODE values, on an RX 6700 XT. 34 kernels, each writing 1 where its condition holds. The sixteen conditions read the 1,024 f32 lanes of check_float.py. v_cmp_class_f32 reads 320 lanes: each of the 28 f32 edge values against each class bit alone and against all ten, then seeded random masks. rdna2_float.compare() is the model and matched all 57,984 comparisons, 0 mismatches.

What the card does

Instructions MODE bits that matter
lt, eq, le, gt, lg, ge and their negations, as v_cmp and v_cmpx 0x010 (f32 denormal sources kept)
f, tru, o, u, class, as v_cmp and v_cmpx none
  • A compare flushes its sources. Where MODE bit 4 is clear, as under the starting value 0xc0, a denormal source reads as a zero. So v_cmp_eq_f32 of 0x00000001 and 0 holds under 0xc0 and not under 0xf0, and v_cmp_lt_f32 of 0x807fffff and 0 is the other way round. On these inputs bit 4 changes 9 of the 1,024 lanes for lt, le, gt, ge and their negations, and 18 for eq, neq, lg and nlg. No other bit changes a result, f32 denormal results (bit 5) included.
  • v_cmp_class_f32 does not flush. It classes a denormal as a denormal under every MODE value: 0x00000001 sets only the +denormal bit, 0x807fffff only the -denormal bit.

A NaN source, signaling or quiet, makes o and the six ordered conditions false and u and the six negations true. Every v_cmpx form gave the results of its v_cmp form under every MODE value.

The Vulkan witness

vulkan_compare.py runs 15 GLSL entries through RADV on the same card, under the five SPIR-V float modes: fourteen conditions, and isinf(a) for v_cmp_class_f32 (mask 0x204). GLSL can't name most conditions, so the tool only records an entry when the driver's disassembly shows the named instruction.

Ten entries held their instruction under all five modes (lt, eq, lg, ge, o, u, nge, nlg, neq, nlt), and their results are the model's under the MODE value each float mode maps to (0xc0, 0xf0, 0x00). For the other five, ACO emitted a different compare under all five modes, so the receipt names that compare and keeps no results:

GLSL Wanted ACO emitted
a <= b v_cmp_le_f32 v_cmp_ge_f32
a > b v_cmp_gt_f32 v_cmp_lt_f32
!(a <= b) v_cmp_nle_f32 v_cmp_nge_f32
!(a > b) v_cmp_ngt_f32 v_cmp_nlt_f32
isinf(a) v_cmp_class_f32 v_cmp_eq_f32

I left those five in the tool's table rather than dropping them, so a driver that does emit them gets recorded. Only the ROCm route covers them for now, and the doc and README say so. The Vulkan route has no entry for f, tru or any v_cmpx form.

What's still open

  • One card. The Vulkan run agrees with it but goes through the same GPU. A second RDNA 2 card would help; 1093i3511 offered one on #412.
  • I haven't checked what the translator emits for compares, or whether it flushes denormal sources under a flushing MODE. That's a Lanes check for a follow-up.
  • Not measured: the console itself (same GFX10.3-only caveat as #420), NVIDIA, the f16 and f64 compares.

Size and layout

The diff is about 3,500 lines, but 2,969 of them are the two receipts. Code, tests and docs are about 540. Tools, tests, docs and evidence only; nothing in the translator or a provider changes, and no cached shader needs recompiling.

  • tools/native_rdna2/compare.hip, check_compare.py; rdna2_float.compare()
  • tools/native_rdna2/vulkan_compare.py
  • evidence/native-rdna2-compare.json (62 KB), evidence/native-rdna2-vulkan-compare.json (39 KB)
  • tests/test_native_rdna2_compare.py, no GPU: the model on its own, then against both receipts
  • a section in docs/CONSOLE_REFERENCE.md, the README in tools/native_rdna2

Tested

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them:

No Lanes scenario: this adds reference tools and a model, and changes no behavior of the translator or a provider. A Lanes check of what the translator emits for compares is the follow-up above.

No row of the table covers tools/native_rdna2/. The line under it says one tool's own check script needs only that check, so I ran check_compare.py and vulkan_compare.py plus check --no-gpu, not the full check. Everything was measured on one RX 6700 XT, through ROCm and RADV. No second card yet, and NVIDIA can't run the native route.

GPU, driver and backend: AMD Radeon RX 6700 XT (1002:73df, gfx1031), Linux 7.3.6, ROCm 10.1.0 under /opt/rocm with HSA_OVERRIDE_GFX_VERSION=10.3.0 (set by the script); RADV, Mesa 26.3.1 for the Vulkan route. No Proton involved.

This pull request's own checks are check_compare.py and vulkan_compare.py, not tuxbox.py check; both ran on this head (8213419d). The check --no-gpu line is below.

Evidence: TuxBox check of 8213419d52e4, no uncommitted changes, no GPU checks: 12 passed, 1 failed, 0 not run

Commands run and their results:

python tools/native_rdna2/check_compare.py --work build/native-rdna2-compare --output build/native-rdna2-compare.json
  PASS 57984 model comparisons, 0 mismatches
  (results and kernel hashes identical to the committed receipt)

python tools/native_rdna2/vulkan_compare.py verify
  PASS 15 instructions under 5 modes

python -m unittest tests.test_native_rdna2_compare
  Ran 10 tests, OK

python -m unittest discover -s tests -q
  Ran 846 tests, OK (skipped=25)

python tuxbox.py check --no-gpu
  12 passed; FAILED Clippy:
  error: use of deprecated method `std::sync::atomic::Atomic::<u8>::fetch_update`: renamed to `try_update`
    at runtime/d3d12/src/device/shader_cache/native_doubles.rs:27
  main fails Clippy the same way with this toolchain (rustc 1.99.0; I ran it on 6d4f1cd7); this PR has no Rust changes

ProjectScarlett, one run on this branch before its last rebase (07fe7c1d, on 6d4f1cd7; same changes), RX 6700 XT, RADV Mesa 26.3.1, GE-Proton11-15, cold shader cache: it reached the account picker about 27 minutes in, went through the setup screens, and was still presenting frames when the GPU faulted about 11 minutes after the picker. The kernel logged gfxhub permission faults (TCP and SQC clients, addresses around 0x8005d2b60000), a gfx ring timeout, then "Ring gfx_0.0.0 reset failed" and "GPU mode1 reset failed", so the machine needed a reboot. This pull request doesn't touch the translator or a provider, so it can't be the cause, but I haven't checked which known fault this was.

Checks

docs/RESULTS.md and docs/progress.svg don't change; I regenerated both and neither moved, so they aren't in this pull request.

<!-- greyfinch-sync:brcly/TuxBox:issue:5606544796 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/652). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-02T12:38:26Z. --- ## Summary Next piece of T5 (#412): what the f32 compares return on an RDNA 2 card under every MODE value. That's `v_cmp_*_f32` for all sixteen conditions, `v_cmp_class_f32`, and the `v_cmpx_*_f32` forms, which write EXEC instead. I picked this family from a census of the recorded shaders. I sampled every fourth of the 53,697 recorded programs and translated 10,631 of them. The compares were the largest family with no native RDNA 2 reference yet: 9,167 of those 10,631 programs use them, 565,885 static uses in all. The next one, the conversions and packs, had 262,658. Same route as #420, #437 and #469: hand-written kernels through ROCm, `MODE[9:0]` set with `s_setreg_b32`, all 1,024 MODE values, on an RX 6700 XT. 34 kernels, each writing 1 where its condition holds. The sixteen conditions read the 1,024 f32 lanes of `check_float.py`. `v_cmp_class_f32` reads 320 lanes: each of the 28 f32 edge values against each class bit alone and against all ten, then seeded random masks. `rdna2_float.compare()` is the model and matched all 57,984 comparisons, 0 mismatches. ### What the card does | Instructions | MODE bits that matter | | --- | --- | | `lt`, `eq`, `le`, `gt`, `lg`, `ge` and their negations, as `v_cmp` and `v_cmpx` | `0x010` (f32 denormal sources kept) | | `f`, `tru`, `o`, `u`, `class`, as `v_cmp` and `v_cmpx` | none | - A compare flushes its sources. Where MODE bit 4 is clear, as under the starting value `0xc0`, a denormal source reads as a zero. So `v_cmp_eq_f32` of `0x00000001` and 0 holds under `0xc0` and not under `0xf0`, and `v_cmp_lt_f32` of `0x807fffff` and 0 is the other way round. On these inputs bit 4 changes 9 of the 1,024 lanes for `lt`, `le`, `gt`, `ge` and their negations, and 18 for `eq`, `neq`, `lg` and `nlg`. No other bit changes a result, f32 denormal results (bit 5) included. - `v_cmp_class_f32` does not flush. It classes a denormal as a denormal under every MODE value: `0x00000001` sets only the +denormal bit, `0x807fffff` only the -denormal bit. A NaN source, signaling or quiet, makes `o` and the six ordered conditions false and `u` and the six negations true. Every `v_cmpx` form gave the results of its `v_cmp` form under every MODE value. ### The Vulkan witness `vulkan_compare.py` runs 15 GLSL entries through RADV on the same card, under the five SPIR-V float modes: fourteen conditions, and `isinf(a)` for `v_cmp_class_f32` (mask `0x204`). GLSL can't name most conditions, so the tool only records an entry when the driver's disassembly shows the named instruction. Ten entries held their instruction under all five modes (`lt`, `eq`, `lg`, `ge`, `o`, `u`, `nge`, `nlg`, `neq`, `nlt`), and their results are the model's under the MODE value each float mode maps to (`0xc0`, `0xf0`, `0x00`). For the other five, ACO emitted a different compare under all five modes, so the receipt names that compare and keeps no results: | GLSL | Wanted | ACO emitted | | --- | --- | --- | | `a <= b` | `v_cmp_le_f32` | `v_cmp_ge_f32` | | `a > b` | `v_cmp_gt_f32` | `v_cmp_lt_f32` | | `!(a <= b)` | `v_cmp_nle_f32` | `v_cmp_nge_f32` | | `!(a > b)` | `v_cmp_ngt_f32` | `v_cmp_nlt_f32` | | `isinf(a)` | `v_cmp_class_f32` | `v_cmp_eq_f32` | I left those five in the tool's table rather than dropping them, so a driver that does emit them gets recorded. Only the ROCm route covers them for now, and the doc and README say so. The Vulkan route has no entry for `f`, `tru` or any `v_cmpx` form. ### What's still open - One card. The Vulkan run agrees with it but goes through the same GPU. A second RDNA 2 card would help; 1093i3511 offered one on #412. - I haven't checked what the translator emits for compares, or whether it flushes denormal sources under a flushing MODE. That's a Lanes check for a follow-up. - Not measured: the console itself (same GFX10.3-only caveat as #420), NVIDIA, the f16 and f64 compares. ### Size and layout The diff is about 3,500 lines, but 2,969 of them are the two receipts. Code, tests and docs are about 540. Tools, tests, docs and evidence only; nothing in the translator or a provider changes, and no cached shader needs recompiling. - `tools/native_rdna2/compare.hip`, `check_compare.py`; `rdna2_float.compare()` - `tools/native_rdna2/vulkan_compare.py` - `evidence/native-rdna2-compare.json` (62 KB), `evidence/native-rdna2-vulkan-compare.json` (39 KB) - `tests/test_native_rdna2_compare.py`, no GPU: the model on its own, then against both receipts - a section in `docs/CONSOLE_REFERENCE.md`, the README in `tools/native_rdna2` ## Tested - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [x] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: No Lanes scenario: this adds reference tools and a model, and changes no behavior of the translator or a provider. A Lanes check of what the translator emits for compares is the follow-up above. No row of the table covers `tools/native_rdna2/`. The line under it says one tool's own check script needs only that check, so I ran `check_compare.py` and `vulkan_compare.py` plus `check --no-gpu`, not the full check. Everything was measured on one RX 6700 XT, through ROCm and RADV. No second card yet, and NVIDIA can't run the native route. GPU, driver and backend: AMD Radeon RX 6700 XT (`1002:73df`, gfx1031), Linux 7.3.6, ROCm 10.1.0 under `/opt/rocm` with `HSA_OVERRIDE_GFX_VERSION=10.3.0` (set by the script); RADV, Mesa 26.3.1 for the Vulkan route. No Proton involved. This pull request's own checks are `check_compare.py` and `vulkan_compare.py`, not `tuxbox.py check`; both ran on this head (`8213419d`). The `check --no-gpu` line is below. ```text Evidence: TuxBox check of 8213419d52e4, no uncommitted changes, no GPU checks: 12 passed, 1 failed, 0 not run ``` Commands run and their results: ```text python tools/native_rdna2/check_compare.py --work build/native-rdna2-compare --output build/native-rdna2-compare.json PASS 57984 model comparisons, 0 mismatches (results and kernel hashes identical to the committed receipt) python tools/native_rdna2/vulkan_compare.py verify PASS 15 instructions under 5 modes python -m unittest tests.test_native_rdna2_compare Ran 10 tests, OK python -m unittest discover -s tests -q Ran 846 tests, OK (skipped=25) python tuxbox.py check --no-gpu 12 passed; FAILED Clippy: error: use of deprecated method `std::sync::atomic::Atomic::<u8>::fetch_update`: renamed to `try_update` at runtime/d3d12/src/device/shader_cache/native_doubles.rs:27 main fails Clippy the same way with this toolchain (rustc 1.99.0; I ran it on 6d4f1cd7); this PR has no Rust changes ``` ProjectScarlett, one run on this branch before its last rebase (`07fe7c1d`, on `6d4f1cd7`; same changes), RX 6700 XT, RADV Mesa 26.3.1, GE-Proton11-15, cold shader cache: it reached the account picker about 27 minutes in, went through the setup screens, and was still presenting frames when the GPU faulted about 11 minutes after the picker. The kernel logged gfxhub permission faults (TCP and SQC clients, addresses around `0x8005d2b60000`), a gfx ring timeout, then "Ring gfx_0.0.0 reset failed" and "GPU mode1 reset failed", so the machine needed a reboot. This pull request doesn't touch the translator or a provider, so it can't be the cause, but I haven't checked which known fault this was. ## Checks `docs/RESULTS.md` and `docs/progress.svg` don't change; I regenerated both and neither moved, so they aren't in this pull request.
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
brcly/TuxBox!652
No description provided.