[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reproducibility of fma() when the addend is qNaN



This is one of the two ambiguities in the standard that is supposed to
be resolved in a particular way by the "reproducible results" attribute.

In my IEEE-SA ballot response I will argue that this conformance be
dropped (see my previous ballot-preview post), because (a) it is just
one of the ways non-standardised NaN propagation rules can lead to
non-reproducibility, and (b) because the fixup could be expensive.

It so happens that the proposed mandated behaviour (reflect an Invalid
exception signalled by the multiplication even when the addend is QNaN)
is what IBM platforms (both z and p) do -- but providing this behaviour
when the native fma() would quietly propagate the addend QNaN can be
expensive.

I'll admit that the extra expense is perhaps not as big as I thought at
first:  one has to precheck the addend to see if it is a QNaN, and take
special action when it is.  Since this would presumably be rare, the
cost is that of a test and a successfully-predicted-not-taken branch.

If default exception handling is in effect, and the Invalid flag is
known to be set already, no extra test would be needed, but the effect
would still fall under normal NaN-propagation unpredictability.

If a QNaN addend is detected, the multiplication operands have to be
pretested too to know whether Invalid needs to be signalled -- or a
dummy fma() multiplication with a zero addend carried out (it would
have to be fma, as ordinary multiplication could overflow or underflow).

I conclude that this particular issue is perhaps not as bad as I thought,
but I still wonder whether it is necessary, given that NaN propagation
is in general still a reproducibility issue.

Michel.
Sent: 2007-10-13 22:02:04 UTC

754 | revision | FAQ | references | list archive