Claimed in the coordination issue as: PROBE-MODEROUND-ORACLE-CLOSE (#14)
Wrap hardware oracle execution in tools/mode_round_probe.py in a
try/finally block so oracle.close() is called on normal completion,
non-GFX10 exit (code 77), report write errors, and probe exceptions.
Add unit tests in tests/test_mode_round_probe.py verifying oracle closure
on normal success, non-GFX10 skip, and probe exceptions.
AI-assisted: yes
agent: yes
Merged from the TreXito/mangrove copy of the original repository, which carried
contributor pull requests that were never merged here.
Kept: rdna2spirv fixes (ds_append/ds_consume, v_ldexp_f16 under MODE.FP_ROUND,
thread-group SGPR, fma exact), the differential fuzzers (dot, vint, wint, vrel, cvt,
f16misc, salu, mode) with their tests, the exe/import fail-fast and int3 cause tools,
Zen 2 instruction emulation (cpu_emulation.h) and the xapu.dll/chad.dll shims.
Not taken, because they conflict with different implementations already on main:
the D3D12 Xbox-ABI layer, xmem, acphal, loader TLS, f64_diff, DirectStorage (needs the
typed-error zlib inflate), and the copy's own MANGROVE.md and README changes.
Conflict in docs/design.md: kept main's wording for the three rows and re-added the v_ldexp_f16 sentence to the MODE.FP_ROUND row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 3 every VALU f16 result
except the transcendentals rounds toward zero (docs/design.md), but the
v_ldexp_f16 branch never read %mode_r16: an overflow still gave +-inf
(0x7c00 for 0x7bff * 2, want 0x7bff) and a denormal result still rounded
to nearest even (0x3c03 * 2^-15 gave 0x0202, want 0x0201).
When the program writes the field, overflow now gives +-65504 and the
denormal rounding increment is dropped while the mode is 3. Programs that
never write MODE emit the same code as before.
tests/semantic/test_ldexp_f16_mode_round.py: edge cases, a seeded sweep
against an exact rational reference in both modes, and a check that every
f16 case of tools/mode_round_probe.py is the translator's word. The probe
gets two ldexp cases so an RDNA2 GPU can confirm the toward-zero words,
which are not measured on hardware.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-wave summary line said 'norm exact across 5 formats + snorm2 ties' and
'7/7 f16 transcendentals 0/65536 RNE/RTZ diffs' whatever the hardware returned.
Count the exact UNORM/SNORM sweeps, the SNORM2 ties and the transcendentals from
the results, and print one line per failing sweep or op. Tests drive main() with
a fake oracle that answers from the probes' own tables and models.