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

Re: [fpu] Architecture



> So if we just support  80-bits for internal and intermediate calculations
and
> not as operands we will not be conformed to IEEE 754 for the double
precision,
> am I right?.

I'm not sure. In fact I don't know what do you mean by "internal and
intermediate". The idea behind this requirement is that if you want to prove
that evaluating some expression yields a result with a required precision
you sometimes need to have all calculations made with higher precision.
Ideally this applies not only to the internal elementary steps (e.g.
calculating sine requires a number of additions and multiplications), but
also to intermediate results of the whole expression. So if you write
double a, b, c, d;
a = a*b+c*d;
the results of two multiplications should be kept using extended (long
double) precision until they are added (at least you sometimes may want it).
In Intel processors it is done automatically as long as all operands are in
FPU stack and no explicit rounding is requested. Sometimes you may have to
state this requirement explicitly, it's a compiler's responsibility to give
programmer the choice. I guess even this is impossible with 64-bit
registers. Anyway you still need to compute the elementary operations using
several more bits than usual to have results correctly rounded as stated by
the standard, but this is another matter and is out of the scope. Another
question is what to call elementary. Some functions are widely used in some
sort of applications and have no sense in most others. It's impossible to
implement everything in hardware so you need to make a software library. And
if you want to have results correctly rounded you should internally use the
extended precision, giving results in basic.

At last the standard only "strongly recommends" this. We need to implement
this if we really want to have a good floating point. But, of course, all
realization principles are the same and if now it requires to much to change
in the existent architecture... I just want to say that we can change a lot
of things in the next version.

> Is there any specific implementation "algorithm" for all IEEE 754
calculations
> and rounding. I think this is important so as to get the same results from
all
> IEEE 754 fpus.

I think not. But there are requirements. All basic operations (add, sub,
mul, div and (?)sqrt) must be corectly rounded so the result rendered should
be the representable number closest to the exact result. If there are two
equal possibilities they should be rounded to the number with even mantissa
(the last digit is 0). This rule does not apply to transcendental functions:
exp, log, sin, etc. (I should check it for sqrt).

Vladimir Ushakov