(j3.2006) Interval arithmetic
Malcolm Cohen
malcolm at nag-j.co.jp
Thu Mar 12 20:36:09 EDT 2009
Van Snyder wrote:
> 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.
>
You might have concluded that, but that doesn't mean that it's true.
And you're conflating "intrinsic type" with "type the compiler knows
about". A Fortran 2003 compiler of necessity knows about types other
than intrinsic type, viz C_PTR and C_FUNPTR.
> The killer is register spill.
This is an implementation detail. With all due respects, you are not an
implementor and even implementors get these things wrong ... especially
frequently when they are using words like "impossible".
> When a compiler has a value in a register
> that is wider than the memory representation of that variable,
Why should that happen? Most hardware does not require that.
> and needs
> the register for other purposes, it generates spill code. Storing from
> registers to memory rounds (or, worse, truncates).
That is just *SO* not true. It's a compiler decision how to spill.
It's perfectly easy to generate spill code that preserves values. The
only widespread decision otherwise in recent times was (as Bill said)
the x87 where preserving the value costs performance (well, memory anyway).
> 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)
Right, if gcc does something wrong it must be impossible for anyone to
do it right. Like it's unheard of for gcc to have a bug - if it
disagrees with the C standard then it's the C standard that's wrong, not
gcc.
> isn't enough, because it's impossible
> for the program to know when the spill will take place, and set the
> rounding mode appropriately.
>
So you are saying that John Reid's IEEE modules are totally useless
because the compiler can just ignore what the user writes and spill
anywhere violating the IEEE standard? That's news to everyone who
implemented them.
Also news to the C99 IEEE support; my opinion of those technical
facilities might not be very high, but certainly the goal was to provide
ways to evaluate stuff in an IEEE-compliant mode. Given rounding mode
changes, that *necessarily* entails getting the rounding mode right!
> 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.
>
Nothing of the sort.
Cheers,
--
.........................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list