models16() and models32() are pure functions of (kind, bits, value), but a
sweep, classify() and the tests ask for the same 16-bit values many times:
about 955,000 calls for 131,000 inputs in tests/test_d16_format_probe.py.
Cache the exact arithmetic per input (as tuples, a third of a dict's
memory) and hand each caller a fresh dict, so an edit cannot reach the
cache. Same bits for every input of every format.
tests/test_d16_format_probe.py: 26.7 s -> 7.7 s; tests/test_d16_image_probe.py
(which uses the same models): 21.8 s -> 13.1 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
round_frac built Fractions for 2^e (twice), for the ulp and for the
quotient on every call, and models16/models32 call it five times per
value. The tool and tests/test_d16_format_probe.py sweep all 65,536
UNORM16 and SNORM16 values per instruction, so that file was among the
slowest in the check job.
The same exact rounding now runs on the numerator and denominator:
floor(log2) from the bit lengths and one comparison, then divmod and a
half-to-even check. The result is the same Fraction.
- models16 and models32 give identical results to origin/main for every
value of all five non-f16 formats (133,376 values).
- New test: round_frac against the Fraction form it replaced, for f16
and f32 in both modes. It covers 16-bit quotients, exact values, ties
and just-under-ties at the ends of a binade (including the carry into
the next one) and in the denormal range, powers of two down past the
smallest denormal, random fractions, and their negations. It fails
for ties away from zero, ties up, a missing exponent correction and a
missing denormal clamp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sweep() zipped its kernel list with the oracle's results, so a shorter list
dropped the missing kernels' values and the sweep still succeeded (an empty
list: exit 0 with nothing checked), and a None entry crashed with a
TypeError. It now raises a RuntimeError (main's "harness error", exit 2)
when the counts differ or an entry is missing.
hw_oracle's Oracle.run() preallocates one entry per kernel, so the short
list cannot happen with the in-repo runner today (as @Kosmabb8 noted when
releasing the item); the check keeps that contract explicit for any other
runner. FakeOracle gains drop/none_at, and two tests cover one missing
kernel, an empty list and a None entry; they fail on the old sweep().
The --json report was opened after the hardware sweep, so a missing
folder raised FileNotFoundError (old tool: "No such file or
directory"), a folder raised IsADirectoryError, and a failed write a
traceback. Refuse a folder as --json before the run, create the parent
folder, and report write failures as one ERROR line with exit 2.
- int_hw_probe: VOP3 clamp on the carry-out add/sub ops (#1831) and v_cvt_rpi/flr's exact floor(x+0.5) and NaN
sign saturation (#1856) now translate as gfx1035 measured, so KNOWN_DIVERGENCES is empty. The known-divergence
test reports a synthetic entry. shader_validation.md says so, and design.md loses the stale duplicate
v_cvt_flr/rpi row a "both" merge left that still called them open.
- docs/README.md: one Other languages line (fr, pt-BR, zh-CN, pl-PL, tr, ru, ja); docs/i18n/README.md: one row
each for pt-BR and zh-CN (the newer).
- anim_rigs, d16_format_probe, pe_shader_containers: text writes name newline="\n" (#1615);
pe_shader_containers guards stdout (#1428).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/design.md narrowed the f16 of a typed d16 buffer load from the f32 decode with round to nearest even, and
called that rounding inferred, not measured. tools/d16_format_probe.py measures it through tools/hw_oracle: every
UNORM8, SNORM8, UNORM10, UNORM16 and SNORM16 value through buffer_load_format_d16_x, tbuffer_load_format_d16_x
and buffer_load_format_x, in wave32 and wave64, against several candidate rules, with a 16_FLOAT load, the kept
high half of d16_x and the staged inputs as controls.
On an RX 6700 (gfx1031) the hardware rounds the exact quotient once, straight to f16. Rounding to f32 first is
1 ulp high on exactly four values (UNORM16 0xffaf and 0xffef, SNORM16 0x7ff7 and 0x8009); over every width up to
16 bits only two f32 quotients land on an f16 halfway point (0x3f7ff000, 0x3f7fb000). Gen.d16_norm_f16 takes the
f16 below for those two, for normalized formats only. The f32 (non-d16) result was already right.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>