Commit Graph

7 Commits

Author SHA1 Message Date
e7192663f7 f16_trans_sweep: harden CLI tokens, atomic JSON writes, and oracle result count guards 2026-11-25 07:58:19 +01:00
f23b69060c 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).
2026-11-22 23:40:40 +01:00
5ffb5e30ed f16_trans_sweep: reject empty selections 2026-11-22 19:55:11 +00:00
a6d78ba353 f16_trans_sweep: validate --json before sweeping, create parent folders and report write errors
Validate --json (refusing empty paths, NUL bytes, existing directories, and non-directory parent ancestors) before opening the hardware oracle, create missing parent folders before writing LF-terminated JSON, and catch OSError cleanly with exit code 1. Adds 5 CLI/unit tests in tests/test_f16_trans_sweep.py.
2026-11-22 17:11:05 +01:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
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.
2026-11-22 14:20:30 +00:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
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>
2026-11-22 11:27:00 +00:00
7c0bb5e17b Tools: every f16 input through the f16 transcendentals on the hardware oracle (FUZZ-29)
tools/f16_trans_sweep.py runs all 65,536 f16 bit patterns through v_exp/log/rcp/rsq/sqrt/sin/cos_f16 natively
(8 raw kernels of 1,024 threads per op), in wave32 and wave64 and five MODEs (IEEE, f16 denormal mode, f16
round toward zero), reads MODE back first, and compares each word with the exact result correctly rounded to
f16 (decimal, 60 digits; sin/cos reduced in turns). It counts bit-exact, 1 ulp, >1 ulp, denormals read or
written as zero, signalling NaNs kept or quieted, and the inputs where SPIR-V is undefined, and lists the words
of 23 special inputs.

On an RX 6700 XT (gfx1031): the five non-trigonometric ops are correctly rounded on every non-NaN input; sin/cos
are exact in turns over the whole f16 range (14 and 4 results 1 ulp off, all at |x| <= 1), while the f32
product 6.2831855 * x is >1 ulp off on 16,366 sin and 2,036 cos inputs (#594). denorm_mode_16_64 = 0 flushes
denormal operands and results, FP_ROUND's f16 field is ignored, IEEE only quiets signalling NaNs. The results
go into docs/design.md (a new f16 transcendentals row) and docs/shader_validation.md.
2026-11-22 11:57:04 +02:00