Repository navigation
Tools: a Linux backend for the hardware oracle (libdrm_amdgpu), and its first runs on RDNA2 - #1265
Conversation
|
Merge-order flag with #1255 (both open, both touching These are separate items (MSVC compiler discovery vs the Linux drm backend), so no work is duplicated — but the later PR should be rebased after the earlier one lands, and the |
414e3bc to
c335dcc
Compare
|
Rebased onto New since the first push
Re-run on the rebased head
As @ray3242 noted, whichever of this and #1255 lands second needs one more rebase in AI-assisted (Claude Code, Claude Fable 5.2). |
|
Tested The PR conflicts with
The device reports No game files. AI-assisted (Claude Code). |
… and its first runs on RDNA2 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>
c335dcc to
d3ca882
Compare
|
Rebased onto Changed in the rebase
Re-run on the rebased head
AI-assisted (Claude Code, Claude Fable 5.2). |
|
The red
AI-assisted (Claude Code, Claude Fable 5.2). |
…only cmpstore swap, perturb scoping, docs wording 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>
Claimed in the coordination issue as: new item, "Linux backend for
tools/hw_oracle" (#1218)What and why
tools/hw_oracleruns the fuzzers' programs natively on an AMD GPU, but only on Windows through the HIP runtime, and so far only on gfx1150.docs/shader_validation.mdsaid "only an RDNA2 card settles RDNA2". This adds a Linux backend and the first RDNA2 runs.hw_oracle_drm.c: a second launcher. It runs each kernel as a raw compute dispatch through the kernel driver (libdrm_amdgpu). No ROCm:clangwith the amdgcn target,gccand the libdrm headers are enough.drm.py: the backend. It assembles with clang, then takes.text, the kernel offsets and the kernel descriptors out of the object.runner.open_oracle()picks the backend by platform. The Windows path is unchanged.COMPUTE_PGM_RSRC1,COMPUTE_PGM_RSRC2and the wave size come from each kernel's descriptor, so the.amdhsa_*float modes take effect as under HIP (Tools: hardware oracle for f32_fuzz — 46,967 f32 VALU programs on real AMD hardware, 0 model mismatches; omod turns -0 into +0 #1248 will need that). What the launcher can't provide (LDS, scratch memory) is refused.LEONIDA_HW_DRM_NODE(no default device); a GPU with a display connected is refused unlessLEONIDA_HW_DRM_ALLOW_DISPLAY=1; GFX10 only (compute engine 10); waits are bounded.asm.raw_kernel_text:crosslane_fuzzstores withglobal_store_b32, which a GFX10 assembler doesn't have, so on RDNA2 every program was rejected. The GFX10 names are put back forgfx10xx.One thing worth knowing for anyone writing such a launcher: rewriting one command buffer in place made the second kernel of every process run the first kernel's commands (200 of 200 runs). Each submission now gets command memory of its own, and a test runs 300 distinct kernels.
Tested
Hardware: the integrated GPU of a Ryzen 9 7950X3D (Raphael, RDNA2, gfx1036), Linux 7.3.5, amdgpu, libdrm 2.4.134, clang 23.1.5 from the distribution.
salu_diff --oracle hw, seeds 1–8--bfe-any, seeds 1–4--inline64, seeds 1–2s_ff0_i32_b32ands_ff0_i32_b64onlysalu_diff --oracle translator,hwcrosslane_fuzz --oracle hw, seeds 1–6hyp_permlane--dpp, seeds 1–2hyp_dpps_min_i32's SCC changed from<to<=gives 2 mismatches in 5,000 programs;--permlane-fetch-inactivemismatches in 239 of 1,000.tests/test_hw_oracle.py: 16 tests without a device, 21 with it (the HIP-only test skips).compileall, the stdlib test loop (140 files),pytest tests --ignore=tests/semantic(3,034 passed),tests/semantic(1,139).open_oracle()andmain()), and any GPU other than this one.Checklist
AI-assisted (Claude Code, Claude Fable 5.2).