Gcc46 and 128 Bit Floating Point
Thomas D. Dean
tomdean at speakeasy.org
Fri Feb 17 21:04:15 UTC 2012
On 02/17/12 11:31, Peter Wemm wrote:
> On Fri, Feb 17, 2012 at 10:59 AM, Thomas D. Dean<tomdean at speakeasy.org> wrote:
> [..]
>> gcc46 is generating 80-bit floating point instructions.
>>
>> The gcc docs state gcc46 will generate 128-bit instructions.
>>
>> I can get gfortran46 to generate 128-bit instructions.
>>
>> How do I get gcc46 to generate 128-bit floating point instructions?
>
> "As of gcc 4.3, a quadruple precision is also supported on x86, but as
> the nonstandard type __float128 rather than long double."
>
AS it turns out, gcc46 does not support long double. Or, is it just
because the port lang/gcc46 uses the system libc, which is gcc 4.2.1?
#include <quadmath.h>
#include <stdio.h>
int main() {
__float128 f128;
long double ld;
char s[512];
f128 = (__float128)1.0;
f128 += ((__float128)2.0) * FLT128_EPSILON;
ld = (long double)f128;
quadmath_snprintf(s, sizeof s, "%.70Qe", f128);
printf("%s\n%.70Le\n",s,ld);
if (ld != f128) printf("not equal\n");
return 0;
}
> env | grep LD
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/gcc46:/lib
> which gcc46
/usr/local/bin/gcc46
> locate libquadmath.so
/usr/local/lib/gcc46/libquadmath.so
/usr/local/lib/gcc46/libquadmath.so.0
> gcc46 -march=corei7 -msse2 -Wall quadtest.c -o quadtest -lquadmath
> ./quadtest
1.0000000000000000000000000000000003851859888774471706111955885169854637e+00
1.0000000000000000000000000000000000000000000000000000000000000000000000e+00
not equal
Oops!
Tom Dean
More information about the freebsd-amd64
mailing list