GFX12 dropped v_cmp_{t,f}_{i32,u32,i64,u64} and their v_cmpx_ forms: AMD LLVM 23
(rocm-sdk-core 10.0.0) assembles all sixteen for gfx1036, gfx1100 and gfx1150 and rejects
every one for gfx1201. wint_diff emits v_cmp_t_u32 and v_cmp_f_i32 (and the v_cmpx_ forms),
so on an RX 9070 XT those programs were counted as "assembler rejected", and the whole batch
carried the first error's text: on main all 69 skips of seed 1 read "... v_cmp_t_u32",
including the programs that only use v_cmp_f_i32.
- tools/hw_oracle/asm.py: GFX12_VALU_REMOVED lists the sixteen. valu_skip_reason() names
them on gfx12xx (and ignores an _e32/_e64 suffix); program_skip_reason() returns the
first such reason of a program's lines. The GFX10.1-only mads are unchanged.
- tools/wint_diff.py: hw_results() sends only the programs the GPU can run; the others get
their reason and are never assembled. The run and the shrinker both use it.
- Tests: the sixteen, the suffixes, gfx1013/1036/1100/1150 unchanged, and hw_results with a
fake oracle (gfx1201 assembles only the program it can run; gfx1036/1150 run all four).
RX 9070 XT, `wint_diff.py --oracle hw --programs 500 --wave both`: seeds 1 and 2 give the
same 431 / 426 passes and 69 / 74 skips as main, 0 mismatch; the skips now read v_cmp_f_i32
29, v_cmp_t_u32 25, v_cmpx_f_i32 8, v_cmpx_t_u32 7 (seed 1) and 25 / 25 / 12 / 12 (seed 2).
gfx1036: 500/500 on both seeds, as on main.
AI-assisted (Claude Code).
(cherry picked from commit 32a9427ba4)
Why merged: indented SALU lines are now parsed for literals and removed opcodes.
Why it's good: security-reviewed; tested on Windows 11 merged onto main c023a36: the new regression test fails on main and passes here; test_hw_oracle's 59 tests still pass.
AI-assisted (Claude Code, Claude Opus 5.5).
asm.rdna23_skip_reason refused every family of valu_fuzz.py and lds_fuzz.py
on gfx1170+ with "the kernels here do not assemble for it" (fef61b247), which
is false for most of what they emit. Checked by assembling what the
generators produce with AMD clang 23 (300 programs per wave size each):
- lds_fuzz assembles clean for gfx1150, gfx1170 and gfx1201 and runs there:
on an RX 9070 (gfx1201, RADV/Mesa 26.2.6, the Linux DRM launcher) the
default --oracle hw run gives wave32 500/500 match, wave64 250 match plus
250 skipped for the committed wave64 bpermute reason, 0 mismatch,
0 rejected. The blanket gate is gone; the per-program hw_skip_reason is
the mechanism.
- valu_fuzz --family f16 assembles clean for gfx1150, gfx1170 and gfx1201
(its op_sel lines are respelled by the runner's asm.opsel16_spelling
there, which the assemble test now applies as well): 500 programs (1,000
kernels, both wave sizes) 1,000/1,000 match, 0 rejected, and the negative
control catches all six wrong models.
- valu_fuzz --family mem assembles clean for gfx1150 AND gfx1170 (every op
kind, 0 of 600 kernels rejected per arch) but genuinely cannot on gfx12xx:
GFX12 has no s_waitcnt_vscnt ("instruction not supported on this GPU")
and rejects every buffer_load/store_b32/b64/b96/b128 form the generator
writes ("operands are not valid for this GPU or mode"). The new
hw_family_skip_reason refuses exactly that, naming both rejects, and
--family mem --oracle hw exits 77 with them on gfx1201.
Running the lds hardware suite un-skipped on gfx1201 found one more
difference: a wave64 ds_permute_b32 reaches all 64 lanes on GFX12, like
ds_bpermute_b32. Measured on the RX 9070: every lane sending to lane
(l + 32) & 63 delivers its value to lane l ^ 32, all 64 lanes, with
lane-to-itself sending as the control; a masked wave64 ds_swizzle keeps
its halves there (0 mismatches in a 40-program --swizzle-exec run). Those
programs are skipped on gfx12xx now too, and the new perturbation
permute_wave64_cross models the crossing: under it every wave64 program
that runs in the --extended seed-1 run matches (23 of 40, 0 mismatch). The
lds negative control on gfx1201 reports the two wave64_cross perturbations
as not detected -- on GFX12 they are the measured behaviour, so the canary
cannot trip there; every other perturbation is caught.
asm.rdna23_skip_reason stays for the OnHardware guards of f32_fuzz and
f16_trans_sweep, whose MODE probes set IEEE and DX10_CLAMP, which gfx1170+
cannot encode (FUZZ-43); its docstring now says that instead of claiming
the fuzzers use it.
CPU: tests/test_valu_fuzz.py 88 OK, tests/test_lds_fuzz.py 37 OK,
tests/test_lds_fuzz_hw.py 44 OK (its OnHardware class runs on the RX 9070:
44 OK), tests/test_lds_fuzz_cli.py 8 OK, tests/test_hw_oracle.py 59 OK
(3 skips), tests/test_f32_fuzz.py 28 OK (1 skip), compileall clean,
scripts/check_no_game_data.py clean. The AMD-clang tests ran with
LEONIDA_AMD_CLANG=/opt/rocm/llvm/bin/clang. The semantic suite is
unchanged: its 47 failures (test_image_atomics_guard,
test_image_store_d16) are on the base commit too; nothing here touches
the translator.
AI-assisted (GLM-5.3).
On an RX 9070 XT (gfx1201) `lds_fuzz.py --oracle hw` stopped with "the assembler rejected
every program in a chunk: ... s_barrier", and programs with a ds_cmpst were skipped because
ds_cmpstore's operand order was only measured on gfx1150.
- asm.sync_lines: GFX12 has no s_barrier, so a barrier is `s_barrier_signal -1` then
`s_barrier_wait -1`, and the LDS wait is `s_wait_dscnt 0` instead of the legacy
`s_waitcnt lgkmcnt(0)` encoding. lds_fuzz's hardware kernels go through it.
- asm.ds_line swaps ds_cmpstore[_rtn]_b32's data operands on GFX12 as on GFX11. Measured on
gfx1201: with 7 in the dword, data v1 = 9, v2 = 7 stores 9 and v1 = 7, v2 = 9 keeps 7, for
the rtn and the non-returning form (gfx1036's ds_cmpst does the opposite).
- Measured on the way: a wave64 ds_bpermute_b32 reaches all 64 lanes on GFX12, where RDNA2
and gfx1150 keep each 32-lane half separate (every lane asking for lane (l + 32) mod 64:
gfx1201 returns lane l ^ 32, gfx1036 lane l). The model describes RDNA2, so on gfx12xx a
wave64 program with a ds_bpermute is skipped with that reason; under
--perturb bpermute_wave64_cross all of them match.
RX 9070 XT, AMD 26.11.2, --programs 1000, seeds 1 and 2: wave32 1000/1000; wave64 537 and 506
match, 0 mismatch, the rest skipped for the bpermute reason. --perturb bpermute_wave64_cross:
wave64 1000/1000. --perturb cmpst_swap: 275 of 1000 wave32 programs mismatch. gfx1036
unchanged: 1000/1000 in both wave sizes and both seeds.
AI-assisted (Claude Code).
AMD LLVM 23 (rocm-sdk-core 10.0.0) rejects `v_max_u16_e64 v14, s12, v5 op_sel:[1,0,0]`
on gfx1100, gfx1150 and gfx1201 ("operands are not valid for this GPU or mode") and takes
`v_max_u16_e64 v14.l, s12, v5.l op_sel:[1,0,0]`. So `pk16_diff --oracle hw` skipped every
op_sel form of v_lshlrev/lshrrev/ashrrev_b16/i16, v_min/max_u16/i16 and v_mul_lo_u16 there:
80 of 200 programs on an RX 9070 XT.
asm.opsel16_spelling() writes each VGPR operand of those lines as the half its op_sel bit
picks and keeps the op_sel list for SGPR and constant sources. The runner applies it on
every non-gfx10 architecture, apart from the true16 probe: this assembler takes a bare
`v_cvt_f16_f32 v8, v1` on GFX11/12, so that probe says no.
All 2,551 distinct op_sel lines pk16_diff generates for the eight ops now assemble for
gfx1100, gfx1150 and gfx1201, with the same op_sel bits and operands as gfx1036's bare form.
RX 9070 XT: pk16_diff --oracle hw 200 programs 120 pass / 80 skipped -> 200 pass, 0 skipped;
2000 programs 2000 pass, 0 mismatch. gfx1036 unchanged (200/200, 2000/2000).
AI-assisted (Claude Code).
The libdrm launcher refused a kernel whose descriptor has a group segment
and capped its output at 4096 words, so lds_fuzz --oracle hw was exit 77
on Linux and no LDS program ran on RDNA2 outside Windows. Both are now
gone; docs/shader_validation.md records the gfx1036 counts.
- drm.py: program COMPUTE_PGM_RSRC2.LDS_SIZE (bits 15..23, 512-byte
units) from the descriptor's group segment instead of refusing it. The
assembler leaves that field 0 (measured: 4096 bytes of LDS give group
4096 and rsrc2 0x84), so the launcher fills it as the HIP runtime does.
Only scratch memory (private) and COMPUTE_PGM_RSRC3 stay unsupported.
- hw_oracle_drm.c: the output buffer takes 1..16384 words, matching the
Windows launcher, so a 64x64 image_fuzz case (16384 words) fits.
- asm.py: a wrapped (non-raw) kernel's LDS goes into its descriptor too,
so the Linux launcher has a group segment to read.
- lds_fuzz.py: the "more than 4096 words" wording no longer applies.
Tests: test_hw_oracle.py gains a descriptor unit test (group segment to
LDS_SIZE, 65536 ceiling) and two OnHardware tests (a kernel that writes,
barriers and reads back LDS; 8192 words from 1024 threads), plus a check
that LDS reaches the descriptor and metadata of a wrapped kernel. Verified
on the integrated Radeon of a Ryzen 7 7700X (gfx1036, RDNA2, Linux
7.3.5-zen1-1-zen, libdrm 2.4.134, AMD clang 23.1.5): lds_fuzz --oracle hw
--programs 500 --seed 1 matches 0 of 1000 (wave32+wave64) mismatches,
image_fuzz --oracle hw --programs 120 --seed 1 0 of 120.
AI-assisted (OpenCode).
ds_line already converts ds_cmpst_rtn_b32 to ds_cmpstore_rtn_b32 and swaps the two data
operands, but the non-returning ds_cmpst_b32 was left as-is, and GFX11 has no such mnemonic.
Measured on gfx1100 that ds_cmpstore_b32 takes the value to store before the compare value.
kernel_text() wrote a fixed descriptor: 16 VGPRs, 32 SGPRs, wave32. On
gfx1036 v16 and up read back 0, and Kernel(wave=64) ran as wave32 (lane
40 of a full EXEC's lane ids read 8), so wave64 results of wrapped
kernels were wave32 runs.
The descriptor now follows the Kernel's wave, vgprs and sgprs, and every
descriptor is raised to the highest register its lines name. Callers and
defaults are unchanged. Tests in tests/test_hw_oracle.py, including one on
hardware for the wave size and v16 / v200.
AI-assisted.
AMD clang rejects .amdhsa_ieee_mode and .amdhsa_dx10_clamp on gfx1170+
(GFX11.7 and GFX12, where the behaviour is fixed). A kernel asking for
either reached the assembler, and when a chunk held only such kernels the
run died with 'the assembler rejected every program in a chunk'.
asm.mode_skip_reason names the field and the architecture; Oracle.run
returns that reason for those kernels and never assembles them, so the
others still run and the MODE probes fail with a clear message. The
denormal and rounding fields are unaffected.
tests/test_hw_oracle.py covers the reason per architecture, a mixed run
and a run where every kernel is skipped. docs/shader_validation.md notes
it.
AMD clang rejects .amdhsa_ieee_mode and .amdhsa_dx10_clamp on gfx1170 and later, but the oracle emitted both whenever a fuzz run asked for them. The assembler then rejected every kernel in a chunk and the caller only saw a generic rejection.
Raise ModeUnavailable before emitting those directives, and have Oracle.run turn it into Unavailable so the existing exit-77 path reports the requested fields as unavailable. The denormal and rounding fields are still emitted. Add text tests for gfx1170/gfx1200/gfx1201, a gfx1150 control and the runner's skip conversion.
The focused tests pass (33 tests, one hardware skip). No RDNA4 GPU was available to confirm the hardware side; this is the directive-level fix. No game files.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
asm.py keeps main's lds/vgprs validation, lists in metadata and the 1024 workgroup size and adds sgprs per kernel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LLVM 23 writes code object v6, which amdhip64_6.dll refuses with error
209: retry the probe as v5 and keep that version for the run.
LLVM 23 also wants v8.l for 16-bit operands on GFX11: ask the assembler
once, and use that spelling for the f16 ops the oracle's tools run.
Tested on a Radeon 780M (gfx1103), driver 32.0.11020.1002.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mem translator path ran on the Radeon 880M: 400 of 400 match. Docs: --show line back in the options list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges #1265 (libdrm backend, gfx10_spelling) keeping both raw_kernel_text changes. The kernel
metadata's .max_flat_workgroup_size is now 1024 (was 256) so 256-thread groups launch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hw_oracle: kernels carry their LDS size and VGPR count; ds_* mnemonics and the
ds_cmpstore operand order are respelled for GFX11/GFX12; launcher accepts up to 16384 words.
lds_fuzz: --oracle hw|translator,hw, --permute/--swizzle-exec/--threads/--extended,
--only, --minimize, --keep, --perturb, --negative-control. Default programs unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/hw_oracle ran only on Windows, through the HIP runtime in the AMD
driver, and so far only on gfx1150. On Linux the same kernels now run as
raw compute dispatches through the kernel driver: no ROCm, only clang
with the amdgcn target, gcc and the libdrm headers.
- hw_oracle_drm.c is the launcher. Its command stream is libdrm's own
compute dispatch test for GFX10 (amdgpu_test_dispatch_memset), with
what belongs to the kernel put in: the entry point, the group size,
the kernarg pointer in two user SGPRs, and COMPUTE_PGM_RSRC1,
COMPUTE_PGM_RSRC2 and the wave size as the kernel's descriptor has
them. So the .amdhsa_* directives (register counts, float rounding
and denormal modes, IEEE, DX10 clamp) take effect as under the HIP
runtime. It prints the same lines as hw_oracle.c. Compute engine
version 10 only (RDNA1 and RDNA2).
- drm.py is the backend: it assembles with clang, takes .text, the
kernel offsets and the kernel descriptors out of the object, and runs
the launcher. A descriptor that asks for what the launcher does not
provide (LDS, scratch, more user SGPRs) is refused. The render node
must be named in LEONIDA_HW_DRM_NODE, and a node with a display
connected is refused unless LEONIDA_HW_DRM_ALLOW_DISPLAY=1.
- runner.open_oracle() picks the backend for the platform. The Windows
path is unchanged.
- asm.raw_kernel_text puts the GFX10 names of the global memory
instructions back for gfx10xx. crosslane_fuzz stores with
global_store_b32, which a GFX10 assembler does not have, so on RDNA2
every one of its programs was rejected.
One thing the launcher had to learn: while it rewrote one command buffer
in place, the second kernel of every process ran the first kernel's
commands (200 of 200 runs). Every submission now gets command memory of
its own; 24,500 distinct kernels in both wave sizes then each returned
their own words, and a test runs 300 of them.
Results on the integrated GPU of a Ryzen 9 7950X3D (Raphael, gfx1036),
Linux 7.3.5, libdrm 2.4.134, clang 23.1.5:
- salu_diff --oracle hw: 70,000 programs, 69,021 run, 0 mismatches
(seeds 1-8; seeds 1-4 with --bfe-any; seeds 1-2 with --inline64). The
s_bfe_i32 rule measured on gfx1150 holds on RDNA2, and s_ff0_i32_b32
and s_ff0_i32_b64, which gfx1150 lacks, match (2,000 programs).
--oracle translator,hw: 3,000 programs pass.
- crosslane_fuzz --oracle hw: 32,000 programs, 0 mismatches: seeds 1-6
(12,000 wave32, 12,000 wave64, 6,586 with the permlane hypothesis)
and seeds 1-2 with --dpp (8,000, 972 with the DPP hypothesis).
- f32_fuzz --oracle hw, seeds 1-6: 38,858 programs, 28,671 match, 0
mismatches, 56 known deviations (an output modifier turns -0 into +0,
as on gfx1150), the rest skipped or not judged. The four MODE settings
read back as the descriptors set them.
- Controls: a reference with s_min_i32's SCC changed from < to <= gives
2 mismatches in 5,000 programs, minimized to that instruction;
crosslane_fuzz --permlane-fetch-inactive mismatches in 239 of 1,000;
f32_fuzz --negative-control catches all six wrong models.
- No GPU fault, timeout or reset in the kernel log.
Tests: tests/test_hw_oracle.py gains tests of the backend that need no
GPU (reading the object and its descriptors, tokens, the display check,
the platform choice, the GFX10 mnemonics) and two on hardware: 300
distinct kernels, and an f32 rounding mode set in the descriptor that
must change a sum. The HIP-only test skips on Linux.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Kernel(mode=...) writes the .amdhsa_ieee_mode / dx10_clamp / float_denorm_mode / float_round_mode
directives; valu_skip_reason lists the f32 opcodes GFX11 and gfx1030 do not have.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a gfx1201 card asm.family() raised ValueError out of Oracle(), so runner.py and salu_diff --oracle hw
crashed and tests/test_hw_oracle.py errored in setUpClass on any RDNA4 machine with the tools installed.
- family() accepts gfx12xx. The kernels use GFX11's spellings there (s_load_b64, global_store_b128).
- GFX12_REMOVED adds the twelve SOPK compares, which AMD clang (rocm-sdk-core 10.0.0) assembles for gfx1150
and rejects for gfx1201. They are now named skips, not generic assembler rejections.
- Oracle() turns an unsupported architecture into Unavailable (exit 77), as the module docstring promises.
Measured on a Radeon RX 9070 (gfx1201, driver 26.11.2): salu_diff --oracle hw, 10,000 programs, 0 mismatches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs each FUZZ-7 program natively on the AMD GPU in wave32 and native
wave64, with its real group size and EXEC setup, every thread storing its
14 words, and compares them with the model. hw_oracle gains raw kernels
(own stores), per-kernel workgroup size and wave64 code objects; the
launcher takes name:threads:words tokens.
24,000 programs on gfx1150: 0 mismatches; the permlane FI=0 and DPP8
inactive-source hypotheses hold on the hardware too. Translator mismatches
all trace to masks read as data (#293) and permlane (#580).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LEONIDA_HIP_DLL is now passed to the launcher and loaded
- an all-rejected chunk is a RuntimeError (harness error), not skips
- -1 and 0xffffffff count as one literal; clang is no longer found by
globbing */.venv under the cwd (env, PATH, HIP_PATH, ROCM_PATH, repo .venv)
- s_bfe past bit 31: say "analogous to LLVM's v_bfe fold", rule rests on the
gfx1150 measurement; contract row in docs/design.md; Linux/ROCm note
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/hw_oracle wraps the generated scalar programs in GFX10/GFX11 kernels,
assembles them with AMD clang and runs them through the HIP runtime of the
AMD Windows driver (hw_oracle.c, loaded with LoadLibrary, no SDK). salu_diff
compares the hardware's three SGPRs + SCC with the reference, alone or
together with the translator. A missing tool prints "unavailable" and exits 77.
First finding: s_bfe_i32 with offset + width > 32 stops the field at bit 31
on gfx1150 (width = min(width, 32 - offset)); the reference followed the
pseudocode literally. The translator already did the hardware thing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>