Does x86/x64 use SIMD register for high precision floating point operations or dedicated FP registers?
I mean the high precision version, not regular double
precision.
Does x86/x64 use SIMD register for high precision floating point operations or dedicated FP registers?
I mean the high precision version, not regular double
precision.
The FPU stack is still available and exposes a 80-bits precision arithmetic as @EricPostpischil points out (not sure though if the processor still has the full logic or if this part got emulated at hardware level). It is made available to the developper in GCC with the long double
type. For example, the generated assembly for method
long double f(long double a, long double b)
{
return a*b ;
}
Will be
fldt 16(%rbp)
fldt 32(%rbp)
fmulp %st, %st(1)
This archive email provides useful elements for using such data e.g.:
long double my_logl(long double x) { long double y; __asm__ volatile( "fldln2\n" "fldl %1\n" "fyl2x" : "=t" (y) : "m" (x)); return y; }
When compiling code without SSE, AVX or other vector extension, your code will likely generate such instructions using the 80bits FPU, and probably will output different values. Here is an example code to illustrate:
double epstest(long double a, long double b)
{
long double y ;
y = a + b ;
y = y - a ;
return y ;
}
#include <cstdio>
int main()
{
double x = 1.0 ;
double y = 1e-17 ;
double z = x + y ;
z = z - x ;
printf ("double: %lf + %le - %lf = %le\n", x, y, x, z);
double res = epstest (x, y) ;
printf ("long double: %lf + %le - %lf = %le\n", x, y, x, res);
return 0 ;
}
And the output:
double: 1.000000 + 1.000000e-17 - 1.000000 = 0.000000e+00
long double: 1.000000 + 1.000000e-17 - 1.000000 = 9.974660e-18
Higher precision (beyond long double
) is implemented in software for x86_64.
The FPU (Floating-Point Unit) has registers for 80-bit floating-point values (in an Intel format that is the IEEE 754 format with slight changes).
The various SIMD units (SSE, AVX et cetera) have larger registers that are usable for a number of things, but there are only instructions for using them as 32-bit and 64-bit floating-point.