Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
sci.math.*
»
sci.math.numanalysis
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
forcing intel floating registers to use 64bit arithmetic
Replies:
5
Last Post:
Feb 3, 2013 10:48 PM




Re: forcing intel floating registers to use 64bit arithmetic
Posted:
Feb 3, 2013 10:48 PM


On 20130111 12:46, Tom Stockfisch wrote: > I need to force all double precision calculations to proceed strictly in 64bit  no 80bit > intel register arithmetic. Can someone tell me the current function calls or > command line settings to achieve this on both MacOS and linux? > > I need this to be able to track down platformdependent differences in numerical code. >
You have two options:  Use compiler switches to force intermediates to memory, look for switches called strict or something like that. This will affect the computation of expressions like r = a*b+c. Here the result of a*b will be stored in a 64 bit memory location and reloaded prior to adding c. Of course these additional stores and loads are not efficient and this mode is precisely for the type of inter platform comparisons which you plan on doing.  Use single SSE registers but you will probably have to use Assembler.
Note that the "precision setting" controls the original Intel FPU only and, contrary to what many posters claim, affects only the precision of floating point division and square root which are computed using iterative algorithms. The remaining arithmetic operations [+,,*] are always done in extended precision as are all transcendentals other than square root such as [cos,sin,log,2^x] and a few others. Unless you must do billions of divisions or square roots and the precision really does not matter take my advice and leave the FPU in extended precision.
If your code contains no transcendentals you may get identical results between different architectures using these two approaches. Considering transcendentals keep in mind that the Intel FPU supports only the minimum required set of transcendentals and that all transcendentals which you call from your program will be library functions which are built on top of the former or which are simple wrappers which do range and error checking. I am not sure whether "strict" compiler switches imply the use of less precise transcendentals, you should check. Good luck consolidating transcendentals between machines.
As a previous poster remarked, small differences may occur between compilers because the language standard leaves the order of evaluation of expressions unspecified. So you use parentheses when needed to remove such ambiguities.
I could say a lot more but have not much time so I will leave it at this. Hope this helps!



