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)
hw_oracle_drm.c refused every compute engine but version 10, so on an
RX 9070 (gfx1201, engine 12.0) `f32_fuzz.py --oracle hw` could not run
at all: 'hardware oracle unavailable: compute engine 12.0: only version
10 (GFX10, RDNA1 and RDNA2) is supported'.
The registers the launcher writes sit at the same SH offsets on GFX10,
GFX11 and GFX12 — Mesa's register JSON and AMD's PAL offset headers
(gfx9_plus_merged_offset.h, gfx12_merged_offset.h) agree on them, and
PAL's gfx12CmdUtil.cpp still builds plain SET_SH_REG — so only the
preamble and the cu-mask writes branch:
- Engines 11 and 12 take the gfx11 init of libdrm's own dispatch test
(tests/amdgpu/shader_test_util.c, 2.4.115): REQ_CTRL on its own, the
four COMPUTE_USER_ACCUM registers, no CP_COHER_START_DELAY. The
checksum stays in the SH space, as PAL writes it on GFX11
(gfx9PipelineChunkCs.cpp): libdrm's gfx11 path sends it as UCONFIG
0x22a, which does not reach the register.
- The indexed COMPUTE_STATIC_THREAD_MGMT_SE0..3 writes stop at engine 11:
GFX12's SE masks reset to 0xffffffff (AMD's gfx12_merged_default.h) and
neither PAL nor RADV touches them there.
- arch_name covers the GC 11 and GC 12 families with Mesa's
ac_identify_chip and amdgpu_asic_addr.h ranges (NV4 also needs the IP
minor, for gfx1210; amd_family.c names GFX1156 gfx1153 too); a chip
only labelable by generation gets a representative, which drm.py maps
the way it already mapped gfx10xx. The engine-version check takes 10,
11 and 12; the gfx10 stream itself is unchanged.
drm.py's ELF and descriptor parsing needed nothing: the code-object-v5
layout it reads is generation-independent, and COMPUTE_PGM_RSRC2's
LDS_SIZE is bits 15..23 in 512-byte units on all three generations
(Mesa ac_binary.c). asm.py already documents GFX12 (b94733a04).
tests/test_hw_oracle.py: the device-line-to-arch mapping with the new
fallbacks, and a launcher build test that compiles hw_oracle_drm.c
exactly as drm.py does, wherever gcc and the libdrm_amdgpu headers are
installed and without a GPU.
Verified on hardware: the author's RX 9070 (gfx1201, engine 12.0,
Linux/RADV) ran --oracle hw over the five min/max/med3 ops, 583 f32
programs: 451 match, 0 mismatch, 2 known deviation, 0 assembler
rejections; a curated 39-program run before it matched on all 14 judged.
No RDNA3 hardware was dispatched — the gfx11 stream mirrors libdrm's
hw-proven gfx11 test. CPU: tests/test_hw_oracle.py 59 OK (3 skips),
tests/test_f32_fuzz.py 29 OK (1 skip), tests/test_f32_fuzz_gfx12.py
7 OK, compileall clean.
AI-assisted (GLM-5.3).
main's 8599cfcc starts build_hw_oracle.cmd from the work folder; keep its paths and
this branch's UTF-8 reads of the script (its /Fo folder is under %TEMP%).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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).
The rocm-sdk wheels put `amdclang` in the Python environment's Scripts (bin)
folder. find_clang() takes it first, because it is on PATH and lists the amdgcn
target, but ld.lld and amdgpu-arch sit beside the real clang, in the folder the
launcher reports as InstalledDir. With the wheels in a Python outside the
checkout the oracle then stopped with "no ld.lld next to the AMD clang", also
when HIP_PATH named a complete toolchain, and LEONIDA_AMD_CLANG was the only
way around it.
find_clang() now returns the clang in InstalledDir when the one it found has no
ld.lld beside it. A clang that has its linker is used where it was found, and a
launcher that names a folder without a clang is kept, so every setup that
worked resolves to the same compiler as before.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
test_report_paths' macOS normcase fix landed on main as f7c7d57b; take main's
version of the file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build_command() returned `cmd.exe /d /c <full path of build_hw_oracle.cmd>`
for the vcvars toolchain. cmd.exe loses a full path's quotes when it holds
& or ^ (and list2cmdline adds none when there is no space), so from a work
folder such as `a & b`, `a&b` or `x^y` the script never ran and the oracle
reported that hw_oracle.c did not build. The only caller already runs the
command with cwd=self.workdir, the folder the script is written to, so it
now starts `.\build_hw_oracle.cmd`, which NoDefaultCurrentDirectoryInExePath
does not block either.
tests/test_hw_oracle.py runs the returned command on a stub vcvars from
plain, `sp (x)`, `a & b`, `a&b`, `x^y` and Turkish-named work folders with
that variable set, and the tests that read the script open it from the work
folder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hw_oracle's vcvars script is fixed on main by #2667 (UTF-8 + chcp 65001), so this
branch takes main's runner.py and drops its own 8.3-name version. Two of main's
new hw_oracle tests decoded that UTF-8 script as ASCII, which fails when %TEMP%
holds a non-ASCII user name; they now decode it as UTF-8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A full run with the temp folder in a profile named in Cyrillic found:
- tools/hw_oracle/runner.py wrote build_hw_oracle.cmd with encoding
"ascii", so any non-ASCII path (the temp work folder, Visual Studio,
the source) raised UnicodeEncodeError before hw_oracle compiled
anything. Non-ASCII paths now go in as their 8.3 short names, the file
in the OEM code page cmd.exe reads it with (UTF-8 elsewhere). New check
in test_hw_oracle: a work folder named "Пользователь".
- test_spirv_metal_set0_extra: its subprocess stubs didn't take the
errors= argument this branch added to tools/spirv_metal_set0.py.
- test_user_sgpr_census, test_anim_index, test_awc_manifest,
test_gamedata_graph, test_manifest_verifier, test_world_build: they
decoded the Python child's output as UTF-8, but the tool writes in the
locale encoding (the ANSI code page on Windows), so a non-ASCII temp
path never matched; test_awc_manifest's reader thread died (no errors=).
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amdgpu-arch prints 'gfx1010:xnack-' on some GPUs; detect_arch handed that to
asm.family(), which rejects it, so the oracle was skipped unless
LEONIDA_HW_ARCH was set.
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.
Without gcc or cl on PATH, the host launcher is built through a .cmd that calls vcvars64.bat. It was written as
ASCII, and it holds the checkout, %TEMP% and Visual Studio paths, so a character outside ASCII in any of them
(a Windows user name, the Turkish default folder name "Yeni klasör") raised UnicodeEncodeError: a traceback
instead of a build, and not the Unavailable that callers turn into exit code 77. The script is now UTF-8 with
`chcp 65001`, as scripts/build_runtime.ps1 writes its own, and the compiler's output is decoded leniently.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
- #1617 and #1620 both handle the float MODE fields gfx1170+ can't set. #1620's runner returns the reason for
that kernel and runs the rest; #1617's test still expected Unavailable for the whole run. The test now checks
the per-kernel reason.
- fspx_unpack.py, user_sgpr_census.py, world_lights_paths.py: new tools without #1428's stdout errors='replace'.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
find_cc() accepted only gcc, so a Windows contributor with Visual Studio (already required for the runtime)
got "hardware oracle unavailable: no MinGW gcc". hw_oracle.c builds cleanly with cl /O1.
- Order: LEONIDA_HOST_CC (gcc, or cl.exe / clang-cl), gcc on PATH or in C:\msys64, then on Windows a cl on
PATH (Developer shell), then the Visual Studio vswhere finds, through its vcvars64.bat in a .cmd script.
- cl's objects go to the oracle's work folder, its errors (on stdout) reach the Unavailable message, and the
temporary launcher name ends in .exe so cl doesn't append another one.
- Unit tests for the choice and the commands; docs/shader_validation.md says the runtime's VS is enough.
Checked end to end on an RX 9070 with no gcc and no cl on PATH: the launcher is built through vcvars64.bat,
salu_diff and crosslane_fuzz --oracle hw run with 0 mismatches.
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>
- 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>