如何在x86和x86_64上使用Gcc 4.6.0 libquadmath和__float128 [英] How to use Gcc 4.6.0 libquadmath and __float128 on x86 and x86_64

查看:353
本文介绍了如何在x86和x86_64上使用Gcc 4.6.0 libquadmath和__float128的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有中等大小的C99程序,它使用 long double type(80bit)来进行浮点运算。我想用新的GCC 4.6扩展 __ float128 来提高精度。就像我得到的那样,这是一个软件模拟的128位精度数学。

我应该如何将我的程序从经典的80位双精度浮点数转换为128浮点数与完全精确的软件仿真?
我需要改变什么?编译器的标志,源?

我的程序读取完整的精度值与 strtod ,做了很多不同的操作(例如+ - * / sin,cos,exp和其他来自< math.h> )和 printf

PPS:有是C语言gcc模式的文档: http://gcc.gnu.org/onlinedocs/gcc /Floating-Types.html
$ b


GNU C编译器支持128位(TFmode)浮动类型。其他类型包括算术运算符:加,减,乘,除;一元算术运算符;关系运算符;相等运算符...在i386,x86_64上支持__float128类型$ b $我应该如何将我的程序从80位的经典长双倍数据转换为四倍数据浮点数128位软件仿真的全精度?我需要改变什么?编译器标志,源代码?

您需要最新的软件,支持 __ float128 类型(4.6和更新)和libquadmath(仅在 x86和x86_64目标上受支持; IA64和HPPA与更新的GCC)。你应该添加链接器标记 -lquadmath 找不到-lquadmath'会显示你没有安装libquadmath) / p>



您应该也知道,既然4.6 Gfortran将使用DOUBLE PRECISION的 __ float128 类型,如果 -fdefault-real-8 被给出了,没有选项 -fdefault-double-8 。这可能是个问题,因为在软件计算中,128位双精度比许多平台上的标准精度双精度要慢得多。 (感谢glennglockwood http://glennklockwood.blogspot.com/2014/ 02 / linux-perf-libquadmath-and-gfortrans.html

I have medium size C99 program which uses long double type (80bit) for floating-point computation. I want to improve precision with new GCC 4.6 extension __float128. As I get, it is a software-emulated 128-bit precision math.

How should I convert my program from classic long double of 80-bit to quad floats of 128 bit with software emulation of full precision? What need I change? Compiler flags, sources?

My program have reading of full precision values with strtod, doing a lot of different operations on them (like +-*/ sin, cos, exp and other from <math.h>) and printf-ing of them.

PS: despite that float128 is declared only for Fortran (REAL*16), the libquadmath is written in C and it uses float128. I'm unsure will GCC convert operations on float128 to runtime library or not and I'm unsure how to migrate from long double to __float128 in my sources.

PPS: There is a documentation on "C" language gcc mode: http://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html

"GNU C compiler supports ... 128 bit (TFmode) floating types. Support for additional types includes the arithmetic operators: add, subtract, multiply, divide; unary arithmetic operators; relational operators; equality operators ... __float128 types are supported on i386, x86_64"

解决方案

How should I convert my program from classic long double of 80-bit to quad floats of 128 bit with software emulation of full precision? What need I change? Compiler flags, sources?

You need recent software, GCC version with support of __float128 type (4.6 and newer) and libquadmath (supported only on x86 and x86_64 targets; in IA64 and HPPA with newer GCC). You should add linker flag -lquadmath (the cannot find -lquadmath' will show that you have no libquadmath installed)

You should also know, that since 4.6 Gfortran will use __float128 type for DOUBLE PRECISION, if the option -fdefault-real-8 was given and there were no option -fdefault-double-8. This may be problem, since 128 long double is much slower than standard long double on many platforms due to software computation. (Thanks to post by glennglockwood http://glennklockwood.blogspot.com/2014/02/linux-perf-libquadmath-and-gfortrans.html)

这篇关于如何在x86和x86_64上使用Gcc 4.6.0 libquadmath和__float128的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆