Skip to content

fpu: NV in sign injection and fmin/fmax of two NaNs; dotproduct reference bound - #485

Open
tinebp wants to merge 2 commits into
masterfrom
fix/fp-flags-nv
Open

tinebp wants to merge 2 commits into
masterfrom
fix/fp-flags-nv

Conversation

@tinebp

@tinebp tinebp commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Impact and evidence

Impact class: R2 (ci/change_impact.py classify)

Contracts touched: none

evidence status detail
functional tests (simx / rtlsim / xrt) run fp_flags: SimX and rtlsim with DPI, STD and DSP, at XLEN 32 and 64 (DSP at 32 only). It fails on master: 4 min/max cases on SimX, 5 sign-injection cases on STD. dotproduct (float and int): SimX, plus float on rtlsim, at -n4096.
model_parity n/a flags only, no cycles move
perf_gate not run no instruction or cycle change in the perf kernels
Beacon logic_gate not run one AND gate on a flag bit in VX_fncp_unit
synthesis not run as above
XLEN 64 build run rtlsim -Wall lint at XLEN 32 and 64 (default, A+Zacas, L1 line 8, 2x2 cores + L2/L3 + PERF, STD/DSP/FPNEW); SimX with -DSIMX_FUNCTIONAL
  • No test silenced without a root-cause plan. The dotproduct reference was wrong, and its bound is derived in the commit message.
  • No golden data changed.
  • No cycle-moving RTL change.
  • No toolchain pin change.

🤖 Generated with Claude Code

tinebp and others added 2 commits November 19, 2026 03:37
…f two NaNs with an sNaN

fsgnj/fsgnjn/fsgnjx share the compare arm of the non-computational unit and
took the compare's NV verdict, so a signaling NaN operand set fflags.NV.
Sign injection never raises a flag. Gate NV on the compare select in the
STD/DSP unit (VX_fncp_unit) and on is_fcmp in the DPI backend.

fmin/fmax with two NaN operands returned the canonical NaN through an early
exit that skipped the signaling check, so NV was lost when either input was
an sNaN. rvfloats is shared by SimX and the DPI backend, so both were wrong;
the RTL STD unit was already correct.

New regression fp_flags checks results and fflags of sign injection,
min/max and compares on NaN operands against values from the F/D
specification (not softfloat, which the simulators share), single and,
at XLEN 64, double precision. CI runs it on SimX and on rtlsim with the
DPI, STD and DSP backends. On the old code it fails 4 min/max cases on
SimX and 5 sign-injection cases on STD. At XLEN 64 it also runs
single-precision ops on raw 64-bit register values: an improperly
NaN-boxed operand must read as the canonical NaN and every result must
come back NaN-boxed; SimX, DPI and STD pass them.

Fixes #444, fixes #449.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… error bound

The check summed the products sequentially in float on the host and allowed
a fixed 6 ulp. A float sum's rounding error grows with n, so -n4096 failed
even though the device result (one product per thread, grid-stride
accumulation, block tree reduction) was closer to the exact sum than the
reference.

Compute the reference and the sum of the block partials in double, and
accept |device - exact| <= gamma_depth * sum|a*b|, where depth counts the
float roundings on any product's path to its block sum (the product, the
grid-stride accumulations, the tree levels). The bound is rigorous for any
IEEE-correct device and stays tight: at -n4096 it is about 6 ulp of the
result, far below a single dropped product. The integer variant keeps the
exact comparison, now in unsigned arithmetic, so the reference wraps
modulo 2^32 as the device does instead of overflowing a signed int. The partials buffer is now sized in elements, not bytes.

Fixes #450.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant