(j3.2006) IEEE question

Bill Long longb
Mon Nov 12 18:08:29 EST 2012

On 11/12/12 3:22 PM, Van Snyder wrote:
> I have been told by a colleague that he observed that the x87 and SSE
> mxcsr registers can be set independently in several cases.  I don't know
> what compiler he was using.
> So the function IEEE_GET_ROUNDING_MODE() may be faced with returning not
> one but two different results.
> Does this (and maybe some similar stuff in Clause 14) need attention?

Perhaps, but not for this reason.  I don't think the standard should be 
involved with the level of hardware specific detail implied here.  The 
simple solution (increasingly common) is just don't use the x87 
instructions.  If your compiler does use them, the programmer has no way 
to know whether a particular statement's floating point operations would 
occur in the x87 or sse registers.  It has to be the responsibility of 
the implementation to make sure the routine to SET the rounding mode 
keeps the mode values consistent.

There are similar problems with the flag values.  If you have a mixed 
x87/sse program, the GET for a flag will probably have to read both 
registers and .or. the flag results together.   Again, much too 
hardware-specific to be relevant for the standard.

On the bright side (at least from one point of view), the cost of 
reading or changing these registers is high, and most programmers are 
not willing to take the performance hit. For programs that do not set or 
get a rounding mode, the issue is moot.



Bill Long                                           longb at cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101

More information about the J3 mailing list