This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Possible Enhancement - Forcing double prec. on Intel FPUs


Hi there,

there was a discussion on comp.lang.fortran on Intel x86 vs. 
workstation FPUs lately. It was about advantages/disadvantages
one has from the IEEE extended arithmetic that Intel x86 proc.
provide and others don't. I had a couple of e-mail exchanges on that
issue later and this suggestion is the result.

Higher prec. usually improves the computations but sometimes gives
strange problems. I found that most problems one faces come from
the fact, that double prec. code is executed in extended prec.
On my homepage under

http://www.math.tu-dresden.de/~loesche/matlab.html

you can find just one example, where problems arise from running
"double code" (Matlab-4.2c for Linux) in extended prec.
You also find a list of possible fixes there.

There are, however, other cases where the source code is available
but the executable does not compute the right answers. 

The easiest way to make the Intel FPU behave as it is expected
to, is to compile the code with -ffloat-store.
That option ensures that ALL intermediate results are stored in their
appropriate memory locations and thereby getting rounded properly.
Using -ffloat-store in turn causes, by stalling the FPU pipeline,
a large performance decrease. 

Therefore, another compiler switch seems to be more appropriate:

-fforce-double  (or something like that)

that puts on Intel machines the FPU in double prec. mode and is
ignored on other architectures. Pipelining would not be affected
by that. As the Linux libc provides the function __setfpucw() 
this option should be easy to implement. I am not a compiler
developer and currently do not have the time to dig into the
compiler sources and hack in the appropriate changes. I am sure, 
someone can do this in a fraction of time that it would take me.

By now I fix most problems by calling __setfpucw() from libc manually.
This, however, makes source code (Fortran) less portable. 

What is your opinion on that?

Greetings, Ralf Loesche



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]