[cfp-interest 3461] reproducibility vs conformance in 754 floating point
David Hough CFP
pcfp at oakapple.net
Wed May 14 21:05:27 PDT 2025
This is a high-level overview of my thoughts about 754 rather than a set
of specific recommendations.
While the 754-1985 standard was very closely oriented toward hardware,
the 2008 and 2019 revisions were more like meta-standards for programming
languages rather than hardware standards.
Most of the programs ever written are only run once or a few times, to answer
some specific question. For them,
neither reproducibility nor performance are top of mind, though if the
program is run on different platforms, reproducibility becomes more urgent.
But most of the economically important programs have a very intense interest
in either reproducibility or performance. Some would like both but most
have to make a choice. Their economic importance warrants careful study
and design and implementation, considering various choices carefully.
But casual programs should be easy to write and easy to check - relatively
speaking. So the ideal default for progamming languages would be to
specify that their default execution would be as reproducible as possible,
with rules on topics like a+b+c and a*b+a*c and
converting a/b to a*(1/b) where 1/b is computed once outside the loop,
and correctly-rounded common elementary transcendental functions.
Then there need to be ways of changing the defaults to obtain performance,
whether on a single operation or an entire program - by for instance
allowing value-changing optimizations and not-quite-correctly-rounded
elementary transcendental functions. The syntax of those specifications
is necessarily language-dependent and scope-dependent. For C it seemed like
the best approach was to rely on compiler command-line options for global
specifications and on pragmas or something similar for narrower scopes.
Since the cross-section for difficult-to-debug anomalies is about the same
for rarely-executed code as for inner loops, it seems reasonable that
reproducibility should be reduced only in the parts of the program where
performance matters, rather than globally on all parts of the program.
That's why command-line options and other global specifications are not
sufficient.
In addition to controlling optimization vs reproducibility, the same kinds
of global and local specifications can control floating-point environmental
parameters such as rounding direction, rounding precision on extended precision,
and alternate exception handling.
Alternate exception handling is a whole other topic - already addressed at
https://754r.ucbtest.org/background/traps-and-wraps.txt
David Hough
More information about the cfp-interest
mailing list