Document: WG14/N1367
Date: 2009/02/27
References: WG14/N1336
Authors: Jim
Thomas and Fred Tydeman (
Reply
to: Jim Thomas <jim.thomas2@hp.com>
Subject:
contractions and expression evaluation methods
This paper notes an ambiguity in the
specification of contractions and the effect of expression evaluation methods
on them, and it proposes text changes for resolution. The relevant portions of
text in C1x draft N1336 are
6.5 #8
A floating expression may be contracted,
that is, evaluated as though it were an atomic operation, thereby omitting
rounding errors implied by the source code and the expression evaluation
method.79)
79) A contracted expression might
also omit the raising of floating-point exceptions.
F.6 Contracted expressions
A contracted expression treats
infinities, NaNs, signed zeros, subnormals,
and the rounding directions in a manner consistent with the basic arithmetic
operations covered by IEC 60559.
Recommended practice
A contracted expression should raise
floating-point exceptions in a manner generally consistent with the basic
arithmetic operations. A contracted expression should deliver the same value as
its uncontracted counterpart, else should be
correctly rounded (once).
Problem: The
definition in 6.5 #8 implies that contraction entails omitting rounding errors.
This is the case when contractions are implemented by machine instructions that
round just once. However, the second sentence of the recommended practice in F.6, implies that contractions might not omit rounding
errors and, alternatively, might round intermediate values in unspecified ways.
This latter interpretation would introduce more potential variability for the
user to cope with. Also, it’s unclear how wide expression evaluation might fit
with this latter interpretation of contractions.
Resolving
the ambiguity in favor of contractions that round just once results in a more
manageable model for users and allows a natural fit with wide expression
evaluation. It appears (without thorough investigation) that instructions that
might support contractions on surviving and new hardware round just once. The
fused multiply add and so-called formatOf operations (which round results to formats
different from the operand formats) required by 754-2008 are suitable for contractions
that round just once.
Recommended changes:
Footnote
79: Insert at the beginning “The intermediate operators in the contraction are
evaluated as if to infinite precision and range, while the final operator is
rounded to the format determined by the expression evaluation method.”
F.6: change
to “A contracted expression is correctly rounded (once) and treats infinities, NaNs, signed zeros, subnormals,
and the rounding directions in a manner consistent with the basic arithmetic
operations covered in IEC 60559.”
F.6,
Recommended practice: remove the second sentence.