3

What happens when I use GCC and do computations with double values.

GCC uses on (x64 platforms which I assume here) https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/i386-and-x86-64-Options.html#i386-and-x86-64-Options

-mfpmath=sse (default)  (use sse instructions)
-mpc80       (default)  (rounding mode to 80bit extended precision)

I am confused, when I used 64bit double values in a simple C++ program. is the computations now performed in extended precision (because of mpc80 default on) or does it use sse instructions (where there is not extended precision stuff going on)

What exactly happens? And what do I need to do on 64bit platforms, to ensure that in certain parts of the code only "double precision" is used, so assuming GCC by default does 80bit extended precision computations, then I need to set the the FPU unit to "double precision" in this part of the code manually?

Gabriel
  • 8,990
  • 6
  • 57
  • 101

1 Answers1

2

No. On 64-bit mode, SSE instructions are used. -mpc80 (and other like options) only target 32-bit systems. (AFAIK)

If you want to be sure, do a runtime precision check.

In general, you should not rely on any degree of precision, though you can generally assume that double is, in fact, double precision.

Dúthomhas
  • 8,200
  • 2
  • 17
  • 39
  • thanks for the reply, in the docs there is nothing said about this, ? i need to rely on precision because of geometric predicates by Shewchuk https://www.cs.cmu.edu/~quake/robust.html – Gabriel Nov 29 '15 at 16:07
  • Alas, I'm not going to read the paper. [Have you tried this answer?](http://stackoverflow.com/a/1076218/2706707) – Dúthomhas Nov 29 '15 at 19:33
  • @Gabriel - when you're adding more than 2 terms as a 'running sum', as used in determinants or inner products, you might want to investigate [Kahan summation](https://en.wikipedia.org/wiki/Kahan_summation_algorithm) for mitigating cancellation errors, etc. This might be sufficient for your needs, before implementing arbitrary precision or interval arithmetic. – Brett Hale Nov 30 '15 at 03:54
  • good point, did not know about kahan summation, the concerns above arised during developing ApproxMVBB (https://github.com/gabyx/ApproxMVBB) So far on 64bit platforms the Shewchuck algorithm can be used since SSE isntruction sets are used by default which means, no extended floating point operations which IS good for Shewchuck algorithms to work properly – Gabriel Nov 30 '15 at 17:45