tools: record the f32 compares on an RDNA 2 card (T5) #652
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/652"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_*_f32for all sixteen conditions,v_cmp_class_f32, and thev_cmpx_*_f32forms, 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 withs_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 ofcheck_float.py.v_cmp_class_f32reads 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
lt,eq,le,gt,lg,geand their negations, asv_cmpandv_cmpx0x010(f32 denormal sources kept)f,tru,o,u,class, asv_cmpandv_cmpx0xc0, a denormal source reads as a zero. Sov_cmp_eq_f32of0x00000001and 0 holds under0xc0and not under0xf0, andv_cmp_lt_f32of0x807fffffand 0 is the other way round. On these inputs bit 4 changes 9 of the 1,024 lanes forlt,le,gt,geand their negations, and 18 foreq,neq,lgandnlg. No other bit changes a result, f32 denormal results (bit 5) included.v_cmp_class_f32does not flush. It classes a denormal as a denormal under every MODE value:0x00000001sets only the +denormal bit,0x807fffffonly the -denormal bit.A NaN source, signaling or quiet, makes
oand the six ordered conditions false anduand the six negations true. Everyv_cmpxform gave the results of itsv_cmpform under every MODE value.The Vulkan witness
vulkan_compare.pyruns 15 GLSL entries through RADV on the same card, under the five SPIR-V float modes: fourteen conditions, andisinf(a)forv_cmp_class_f32(mask0x204). 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:a <= bv_cmp_le_f32v_cmp_ge_f32a > bv_cmp_gt_f32v_cmp_lt_f32!(a <= b)v_cmp_nle_f32v_cmp_nge_f32!(a > b)v_cmp_ngt_f32v_cmp_nlt_f32isinf(a)v_cmp_class_f32v_cmp_eq_f32I 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,truor anyv_cmpxform.What's still open
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.pyevidence/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 receiptsdocs/CONSOLE_REFERENCE.md, the README intools/native_rdna2Tested
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 rancheck_compare.pyandvulkan_compare.pypluscheck --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/rocmwithHSA_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.pyandvulkan_compare.py, nottuxbox.py check; both ran on this head (8213419d). Thecheck --no-gpuline is below.Commands run and their results:
ProjectScarlett, one run on this branch before its last rebase (
07fe7c1d, on6d4f1cd7; 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 around0x8005d2b60000), 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.mdanddocs/progress.svgdon't change; I regenerated both and neither moved, so they aren't in this pull request.