This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: Problems with IEEE rounding mode on x86_64
> At Tue, 17 Apr 2007 21:57:56 +0200,
> Reinhold Bader wrote:
> > I've tried the example ieeeround.c from the GSL reference manual on
> > an x86_64 system and find that setting the GSL_IEEE_MODE
> > environment variable does not have any effect at all. E.g.
> >
> > export GSL_IEEE_MODE="round-up"
> >
> > does not yield a divergent series as described in the manual.
> >
> > For x86 and IA64 things are OK, however. The effect seems to be
> > limited to Opteron and EM64T type systems, using 64 bit libraries.
I've updated the configure script and ieee-utils/fp-gnux86.c to
control the IEEE settings for the SSE floating-point operations as
well.
SSE floating-point is the default when compiling with gcc on 64-bit
systems. Otherwise it only shows up when compiling with -fpmath=sse.
Below is the relevant change to fp-gnux86.c, it requires
HAVE_FPU_X86_SSE to be defined to switch it on.
--
Brian Gough
diff -u gsl/ieee-utils/fp-gnux86.c:1.2 gsl/ieee-utils/fp-gnux86.c:1.3
--- gsl/ieee-utils/fp-gnux86.c:1.2 Sun Jun 26 14:27:02 2005
+++ gsl/ieee-utils/fp-gnux86.c Mon Apr 23 14:44:07 2007
@@ -95,5 +95,17 @@
_FPU_SETCW(mode) ;
+#if HAVE_FPU_X86_SSE
+#define _FPU_SETMXCSR(cw_sse) asm volatile ("ldmxcsr %0" : : "m" (*&cw_sse))
+ {
+ unsigned int mode_sse = 0;
+
+ mode_sse |= (mode & 0x3f)<<7; /* exception masks */
+ mode_sse |= (mode & 0xc00)<<3; /* rounding control */
+
+ _FPU_SETMXCSR(mode_sse);
+ }
+#endif
+
return GSL_SUCCESS ;
}