(j3.2006) Interval arithmetic

Van Snyder Van.Snyder
Thu Mar 12 14:48:10 EDT 2009

As a consequence of my involvement with P1788, I have concluded that it
is impossible in general to provide reliable interval arithmetic with
other than an intrinsic type.

The killer is register spill.  When a compiler has a value in a register
that is wider than the memory representation of that variable, and needs
the register for other purposes, it generates spill code.  Storing from
registers to memory rounds (or, worse, truncates).  If intervals are not
intrinsic types, the compiler can't know how to round the high-precision
register to a lower-precision memory representation.  Ensuring that the
compiler respects the current rounding mode when it spills (I have heard
that some version of gcc did not) isn't enough, because it's impossible
for the program to know when the spill will take place, and set the
rounding mode appropriately.

Attributes for variables that say "always round thus when storing this
into memory" would seem to solve the problem, but it doesn't tackle
anonymous temporaries.

That's not to say that intrinsic interval arithmetic should therefore
necessarily be a part of a revision of Fortran in the immediate future.
Rather, it demonstrates that our hope in 2003 that we could cater for it
by providing adequate facilities to implement it using functions and
defined operations was a fool's errand.

Van Snyder                    |  What fraction of Americans believe 
Van.Snyder at jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.

More information about the J3 mailing list