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).
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).
A clean single-thread kernel on gfx1100 shows both exchanges complete before vdst is written, so
vdst may hold the address or the data: the data still lands in LDS and vdst takes the old words.
The model already read the pair first, so only the generator had to stop avoiding the shape.
The fuzzer only emitted ds_wrxchg_rtn_b32, so the pair forms and their 64-element st64 step were
never compared against the translator. The model follows the gfx1100 measurement in #3147:
offsets count elements, st64 steps 64 of them, the data pair is read before vdst is written, and a
repeated offset returns data0. vdst is kept clear of the data registers because aliasing them is
not modelled.
Add --pc-tail-ubo (also honoured via LEONIDA_PC_TAIL_UBO=1) to both
tools/valu_fuzz.py and tools/lds_fuzz.py so they pass --pc-tail-ubo to
rdna2spirv.py and LEONIDA_PC_TAIL_UBO=1 to vk_compute_test. Without this,
128-byte push-constant GPUs hit VUID-VkPushConstantRange-size-00298 /
VUID-vkCmdPushConstants-size-00371 (144 > 128) or skip/fail when fuzzing.
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.
AI-assisted (Claude), on behalf of dev-ewann.
valu_fuzz.py, lds_fuzz.py and crosslane_fuzz.py ask vk_compute_test for
32-lane subgroups (VKC_SUBGROUP_SIZE=32) for wave32 programs, but they
ignored its "compute subgroup size: 32 not available" line. On a device
that can't pin that size (Mesa llvmpipe: 8 lanes) every wave32 program
was judged at the driver's size and its cross-lane results came out as
translator mismatches. On main f85582e with llvmpipe, lds_fuzz --emulate
--programs 400 --seed 5150 gave 215 mismatches, all wave32, and
crosslane_fuzz --wave 32 --no-maskdata gave 68 of 100.
Those wave32 programs are now skips, as check.py's unpinned_subgroup_skip
does for its lane-mask dumps. Programs translated with --wave64-emulate
use no subgroup operations, so they are still compared at any size
(400 of 400 match on llvmpipe). crosslane_fuzz counts the skips in its
summary and exits 2 when every program was skipped, as the other two
fuzzers already do.
The line is parsed by compute_fixture.unpinned_subgroup, shared by the
three fuzzers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
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>
Without llvm-mc, run_gpu_tests.py, valu_fuzz.py, lds_fuzz.py,
image_fuzz.py, crosslane_fuzz.py and runtime/test/shaders/build.py
ended in 'FileNotFoundError: [WinError 2]' from subprocess.run: the first
step of TEST-71 on a Windows machine without one. Only shader_disasm.py
said what was missing. mc_command.run() starts an llvm-mc command and
turns a command that can't be started into shader_disasm.py's message
(set LLVM_MC or --llvm-mc, build_llvm_mc.ps1, the WSL form); the six
llvm-mc call sites use it. tests/test_mc_command.py covers run() and
each tool with a nonexistent LLVM_MC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
valu_fuzz.py and lds_fuzz.py ran <build>/vk_compute_test, so with the Visual
Studio generator (runtime/build/RelWithDebInfo) every program stopped with a
FileNotFoundError traceback. They now look in <build> and then its
RelWithDebInfo/Release folder, as run_gpu_tests.py does, and stop with one line
when it isn't built. crosslane_fuzz.py's default --exe gets the same fallback.
ds_read_u8_d16, ds_read_u8_d16_hi, ds_read_i8_d16 and ds_read_i8_d16_hi
(RDNA2 DS opcodes 162-165) were rejected. They reuse the u8/i8/u16_d16
path: the byte is zero- or sign-extended 8->16 into one half of the
destination and the other half is kept.
Tests: CPU value test on the new cs_w32_lds_u8_d16 fixture (mini
interpreter now accepts Workgroup variables for one invocation), GPU
dump cs_w32_lds_u8_d16.asm registered in check.py and run_gpu_tests.py,
lds_fuzz generates the four reads. Contract row in docs/design.md and
shader_validation.md updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/lds_fuzz.py generates seeded 64-thread compute programs (wave64 or wave32, 4 KiB LDS) over the ds_*
instructions the translator accepts: every read width (also u16 d16/d16_hi), byte/short writes (also d16_hi),
read2/write2 (+st64), the add/sub/min/max/and/or/xor atomics with and without return, wrxchg, cmpst, ds_swizzle
and ds_bpermute, under random EXEC masks. It translates them, runs them with vk_compute_test and compares every
thread's 16 result VGPRs and the whole LDS bit for bit with a model written from the ISA, naming the op that last
wrote a wrong register. vk_compute_test gets VKC_OUT_WORDS / VKC_DUMP to read the whole buffer back.
On an RX 6700 XT the only mismatch is the wave32 ds_bpermute inactive-source case #253 fixes. docs/design.md no
longer claims the 8-bit d16 reads, which the translator rejects.