upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorerrusso <s.russo06@icloud.com>2026-11-22 23:40:40 +0100
committererrusso <s.russo06@icloud.com>2026-11-22 23:40:40 +0100
commitf23b69060cc3dd953a26e23f6cd81627f054e4b5 (patch)
treeb946e9dc090df40223a31d23fe6e81aa0b4b9916 /docs
parentaa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff)
hw_oracle (Linux): run the LDS fuzzers through libdrm
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).
Diffstat (limited to 'docs')
-rw-r--r--docs/shader_validation.md40
1 files changed, 27 insertions, 13 deletions
diff --git a/docs/shader_validation.md b/docs/shader_validation.md
index b7fad4106..93ee7ff7d 100644
--- a/docs/shader_validation.md
+++ b/docs/shader_validation.md
@@ -220,8 +220,13 @@ through the kernel driver (`libdrm_amdgpu`), so nothing sits between the instruc
220 object, so the `.amdhsa_*` directives take effect as they do under the HIP runtime: register counts, float 220 object, so the `.amdhsa_*` directives take effect as they do under the HIP runtime: register counts, float
221 rounding and denormal modes, IEEE mode, DX10 clamp. A test checks that an f32 rounding mode set there changes 221 rounding and denormal modes, IEEE mode, DX10 clamp. A test checks that an f32 rounding mode set there changes
222 a sum on the hardware. 222 a sum on the hardware.
223 - A descriptor that asks for something the launcher does not provide (LDS, scratch memory, more than the 223 - The descriptor's group segment becomes `COMPUTE_PGM_RSRC2.LDS_SIZE` (bits 15..23, 512-byte units). The
224 kernarg pointer in the user SGPRs) is refused instead of being run differently. 224 assembler leaves that field 0, so the launcher programs it from the group segment, as the HIP runtime does;
225 a kernel with LDS reads back what it wrote there (`tests/test_hw_oracle.py`, measured on gfx1036).
226 - A descriptor that asks for something the launcher does not provide (scratch memory, more than the kernarg
227 pointer in the user SGPRs, more than 65,536 bytes of LDS) is refused instead of being run differently.
228 - The output buffer takes up to 16,384 words, as the Windows launcher does, so a 64x64 `image_fuzz` case (16,384
229 words) runs here too.
225 - Every submission gets command memory of its own. While one buffer was rewritten in place, the second kernel of 230 - Every submission gets command memory of its own. While one buffer was rewritten in place, the second kernel of
226 a process ran the first one's commands, every time; `tests/test_hw_oracle.py` runs 300 distinct kernels to 231 a process ran the first one's commands, every time; `tests/test_hw_oracle.py` runs 300 distinct kernels to
227 catch that. 232 catch that.
@@ -563,10 +568,20 @@ hardware gives 0 (the swizzle hypothesis above). So the translator differs from
563fixed here. Partial-wave programs (`--threads` 32 568fixed here. Partial-wave programs (`--threads` 32
564in wave64) are skipped for the translator, which cannot launch them. NVIDIA was not run. 569in wave64) are skipped for the translator, which cannot launch them. NVIDIA was not run.
565 570
566**Other backends.** The Linux libdrm launcher of #1265 (`tools/hw_oracle/drm.py`) does not run these programs yet: 571**Other backends.** The Linux libdrm launcher of #1265 (`tools/hw_oracle/drm.py`) now runs these programs too. It
567it refuses a kernel with LDS and caps the output at 4096 words, and `lds_fuzz` turns that refusal into exit 77 572programs `COMPUTE_PGM_RSRC2.LDS_SIZE` from the descriptor's group segment (the assembler leaves that field 0, so the
568("unavailable"). Linux RDNA2 results need LDS and a larger word count in that backend first; the gfx1036 numbers 5734,096 bytes of LDS `lds_fuzz` asks for reach the hardware) and its output buffer takes 16,384 words like the Windows
569above come from the Windows HIP launcher. 574launcher's, so a 64x64 `image_fuzz` case fits. On the integrated Radeon of a Ryzen 7 7700X (gfx1036, RDNA2, Linux
5757.3.5-zen1-1-zen, libdrm 2.4.134, AMD clang 23.1.5):
576
577| Run | Programs / cases | Mismatches |
578| --- | --- | --- |
579| `lds_fuzz.py --oracle hw --programs 500 --seed 1` (wave32 and wave64) | 1,000 | 0 |
580| `image_fuzz.py --oracle hw --programs 120 --seed 1` (60 cases per wave; 8 to 64 per side, four 64x64 cases) | 120 | 0 |
581
582`lds_fuzz --oracle hw` no longer exits 77 on Linux for LDS or the word count. The gfx1036 numbers earlier in this
583section are still from the Windows HIP launcher; these two runs put the same model on the same architecture through
584libdrm.
570 585
571**Overlap with #789.** #789 adds `ds_permute_b32` to the default op mix of `lds_fuzz.py`; here it is opt-in 586**Overlap with #789.** #789 adds `ds_permute_b32` to the default op mix of `lds_fuzz.py`; here it is opt-in
572(`--permute`) so that existing seeds keep their programs. Whichever lands second reconciles the two. 587(`--permute`) so that existing seeds keep their programs. Whichever lands second reconciles the two.
@@ -775,11 +790,10 @@ Negative control (`--oracle hw --programs 180 --seed 1 --negative-control`): the
775`sint_unsigned` 30, `alpha_zero` 16, `dmask_in_place` 132, `no_sentinels` 168, `transpose` 166), and a kernel built 790`sint_unsigned` 30, `alpha_zero` 16, `dmask_in_place` 132, `no_sentinels` 168, `transpose` 166), and a kernel built
776with the next format's `FORMAT` code is caught on every format (24 to 30 of 30 cases each). So the GFX10 T# words of 791with the next format's `FORMAT` code is caught on every format (24 to 30 of 30 cases each). So the GFX10 T# words of
777`hw_oracle/tsharp.py` and the texel-fetch model hold on RDNA2 for these formats; `--oracle translator,hw` was not run 792`hw_oracle/tsharp.py` and the texel-fetch model hold on RDNA2 for these formats; `--oracle translator,hw` was not run
778there. The Linux libdrm backend of #1265 793there. The Linux libdrm backend of #1265 (`tools/hw_oracle/drm.py`) now runs these cases too: `--oracle hw
779(`tools/hw_oracle/drm.py`) was not tried: it copies only `.text` (the texture is in `.text`, so that works in 794--programs 120 --seed 1` on the same gfx1036 iGPU matched on 120 of 120 cases (60 per wave), four of them 64x64 and
780principle, but it needs the loaded code to be 256-byte aligned, which the kernel checks and reports) and the LDS 795therefore 16,384 words, with no rejections (Linux 7.3.5-zen1-1-zen, libdrm 2.4.134, AMD clang 23.1.5). It copies
781section above records a 4096-word output cap there, while a 64x64 case stores 16,384 words. The RDNA2 results above 796only `.text`, which is where the texture lives, and the loaded code is 256-byte aligned.
782are from the Windows HIP launcher only.
783 797
784### 32-bit integer VALU in every encoding (`tools/vint_diff.py`) 798### 32-bit integer VALU in every encoding (`tools/vint_diff.py`)
785 799
@@ -1214,8 +1228,8 @@ The `16-bit results` row of `docs/design.md` listed `v_exp_f16`/`v_log_f16` and
1214unverified. f16 has only 65,536 bit patterns, so instead of sampling, this tool runs every one of them through 1228unverified. f16 has only 65,536 bit patterns, so instead of sampling, this tool runs every one of them through
1215`v_exp_f16`, `v_log_f16`, `v_rcp_f16`, `v_rsq_f16`, `v_sqrt_f16`, `v_sin_f16` and `v_cos_f16` on the hardware 1229`v_exp_f16`, `v_log_f16`, `v_rcp_f16`, `v_rsq_f16`, `v_sqrt_f16`, `v_sin_f16` and `v_cos_f16` on the hardware
1216oracle (setup above; exit 77 without it). Each op is 8 raw kernels of 1,024 threads. Each thread computes 8 inputs 1230oracle (setup above; exit 77 without it). Each op is 8 raw kernels of 1,024 threads. Each thread computes 8 inputs
1217and stores them packed two to a dword, which is 4,096 words per kernel, the launcher's limit. The op runs in wave32 1231and stores them packed two to a dword, which is 4,096 words per kernel; 8 kernels cover every input. The op runs in
1218and wave64 and under five MODEs, and MODE is read back with `s_getreg_b32` first: 1232wave32 and wave64 and under five MODEs, and MODE is read back with `s_getreg_b32` first:
1219 1233
1220| Mode | IEEE | f16 denormals | f16 rounding | 1234| Mode | IEEE | f16 denormals | f16 rounding |
1221|---|---|---|---| 1235|---|---|---|---|