本文介绍了在启用严格GCC浮点模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尚未创建一个程序,看是否GCC将需要它过去了,当我这样做,我想知道我怎么会去有关启用严格的浮点模式,这将使运行和计算机之间的重复的结果,谢谢你。

I haven't yet created a program to see whether GCC will need it passed, When I do I'd like to know how I'd go about enabling strict floating point mode which will allow reproducible results between runs and computers, Thanks.

推荐答案

-msse2 编译。不要让任何库把FPU在保税区/ DNZ模式,你将主要设置(处理器缺陷仍然)。

Compiling with -msse2 on an Intel/AMD processor that supports it will get you almost there. Do not let any library put the FPU in FTZ/DNZ mode, and you will be mostly set (processor bugs notwithstanding).

有关其他架构,答案会有所不同。不提供任何方便的方式来获得精确的IEEE 754语义的achitectures(例如,pre-SSE2 IA32处理器)将需要使用浮点仿真库来获得你想要的结果,在一个非常高性能损失。

For other architectures, the answer would be different. Those achitectures that do not offer any convenient way to get exact IEEE 754 semantics (for instance, pre-SSE2 IA32 CPUs) would require the use of a floating-point emulation library to get the result you want, at a very high performance penalty.

如果您的目标体系结构支持 fmadd (乘法和加法无中间四舍五入)指令,确保当你有明确的乘法和加法编译器不使用它来源$ C ​​$ C。 GCC是不应该,除非您使用-ffast,数学选项来做到这一点。

If your target architecture supports the fmadd (multiplication and addition without intermediate rounding) instruction, make sure your compiler does not use it when you have explicit multiplications and additions in the source code. GCC is not supposed to do this unless you use the -ffast-math option.

这篇关于在启用严格GCC浮点模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:46