6 Commits

Author SHA1 Message Date
0294aed3dd buffer_format_fuzz: validate --budget
--budget is a count of random elements per format, and a negative one was
accepted with exit 0 and no message. `for _ in range(budget)` simply does not
run, so -1, -100 and -1000000 produced exactly the run of 0 -- 1026 instead of
1106 elements for 8_8_8_8_UNORM -- and every format still reported "ok".
--self-test was worse: it builds its own patterns with a hardcoded budget of 2
and never reads the option, so `--self-test --budget -100` and `--budget
1000000` both printed the same "self-test: ok" in the same 1.4 s.

Before:
  $ python -I tools/buffer_format_fuzz.py --self-test --budget -1
  self-test: ok                                # exit 0
  $ python -I tools/buffer_format_fuzz.py --oracle hw --budget -3
  hardware oracle unavailable: ...             # exit 77, no GPU needed to know

After, one check next to the other argument guards and before both the
self-test and the oracle, so the value is validated even where it is not used:

  $ python -I tools/buffer_format_fuzz.py --self-test --budget -1
  buffer_format_fuzz.py: error: --budget cannot be negative   # exit 2
  $ python -I tools/buffer_format_fuzz.py --self-test --budget 0
  self-test: ok                                # 0 stays legal: sweeps only

tests/test_buffer_format_fuzz.py (CPU only, hw_oracle stubbed) covers the
negative value on both paths, that it is refused before the oracle is opened,
that 0 stays legal and that -1 is otherwise indistinguishable from 0.
3 of its 7 tests fail without this change, 7 pass with it.
2026-11-25 07:06:02 +01:00
a8c0d157db buffer_format_fuzz: exit 77 on GFX11 when only GFX10-only formats are given 2026-11-23 21:18:41 +00:00
e6573b3dde buffer_format_fuzz: an unknown --formats is a usage error before the GPU oracle (EGEN-BUFFMT-EXPLICIT-FIRST) (#6310)
Squash-merged after diff review of PR #6310 - buffer_format_fuzz: an unknown --formats is a usage error before the GPU oracle (EGEN-BUFFMT-EXPLICIT-FIRST)
2026-11-23 08:22:43 -06:00
4945add25f rdna2spirv: typed stores follow the hardware (f16 toward zero, one NORM rounding, two-component routing), all 77 codes
@AwkGrep256 ran tools/buffer_format_fuzz.py on a real RDNA2 (gfx1036, #2022): the same totals as the
Radeon 880M, 0 mismatches, and 199,144 elements of the 14 GFX10-only codes, also 0. This follows both.

- 16_FLOAT, 16_16_FLOAT and 16_16_16_16_FLOAT format stores round toward zero, saturate at +-65504 and
  keep a NaN a NaN (Gen.ufloat_encode_bits, now with an optional sign). d16 data rounding (#1759) is
  not touched.
- Every UNORM, SNORM and SCALED store rounds the exact product once (Gen.norm_encode_exact): 0.3 *
  65535 stores 19661, not 19660.
- A two-component format stored through a V# takes channel y as its second component when DST_SEL_Y is
  Y and DST_SEL_Z a constant (the runtime's X,Y,0,1: gfx1036 narrow-integer fixtures, gfx1150), and
  channel w otherwise (identity XYZW, @AwkGrep256 and gfx1150); _xy then writes (x, 0). tbuffer keeps
  (x, y). A probe with XYZW alone would have shown (x, w) for every V# and broken the runtime's
  selectors, which the oracle now also covers (XY01 runs for the two-component formats).
- Gen.FORMATS has all 77 codes: 30-35 and 37-42 (10_11_11 and 11_11_10 with UNORM..SINT) join.
- buffer_format_fuzz: the model has one store route per path, select_formats runs all 77 codes by
  default on a GFX10 device, the known-difference count is gone (0 on the 880M).

The three expectedFailure tests pass; the fixtures that baked the old behaviour (cs_fmt_sint32, test_translate
f16 and int32 store tests, test_value_semantics) take the measured words. Sizes: cs_store 206 KB on
main, 125 KB here.

Co-Authored-By: AwkGrep256 <AwkGrep256@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 17:55:37 +01:00
a93da2c185 buffer_format_fuzz: distinct y and w in the store probe; count the (x, w) routing apart
store_inputs() gave y and w the same value for two-component formats, so run_stores could not
tell the translator's (x, y) from the Radeon 880M's (x, w) for buffer_store_format_*; the zero
mismatches did not validate the second component. The probe now uses a different value in every
register and also runs _xy stores. The hardware model routes a two-component
buffer_store_format_* to (x, w) (_xy: (x, 0)); tbuffer_store_format_* takes (x, y) like the
translator. Those stores are counted as known-difference elements, outside the validated count:
1,330,469 validated elements, 0 mismatches, plus 26,523 known-difference elements.

The translator is unchanged (RDNA2 unmeasured); the difference is pinned as an expectedFailure
in test_buffer_formats_all.py. docs/buffer_formats.md and the design.md row say so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 16:58:26 +01:00
f2ee6b5778 buffer_format_fuzz: a hardware oracle for every GFX10 buffer data format
Raw buffer_load_format_xyzw, tbuffer_load_format_xyzw and buffer_store_format_xyzw /
tbuffer_store_format_xyzw kernels per format on the AMD GPU (tools/hw_oracle), compared word for
word with a CPU model. Formats are mapped by name because GFX11 numbers them differently; the
twelve 10_11_11 / 11_11_10 non-FLOAT codes and the two SCALED 10_10_10_2 codes have no GFX11
spelling. On a Radeon 880M (gfx1150, RDNA3.5, not RDNA2): 1,264,744 elements over 63 formats,
V# and tbuffer, loads and stores, 0 mismatches; --negative-control shows a wrong V# format is
caught.

docs/buffer_formats.md records the measured rules (SCALED stores convert as NORM, float stores
round toward zero and saturate, a 2-bit SNORM half rounds away, NaN payloads, channel fill) and
where the translator's older stores differ.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 16:29:16 +01:00