简体   繁体   English

GCC针对双精度浮点算术的特殊优化选项

[英]GCC special optimization options for double precision floating point arithmetics

Do you know which of the GCC optimization flags are the most appropriate to build an application, which uses double floating point and calculates a lot in real-time and it uses -lm . 您是否知道哪个GCC优化标志最适合构建应用程序,它使用双浮点并实时进行大量计算,并且使用-lm A target hardware is two Dual-Xeons with Linux on-board. 目标硬件是两个板载Linux的Dual-Xeon。 Thanks in advance! 提前致谢!

"Dual-Xeon" is not a precise specification of the processors you're targetting - "Xeon" is more a marketing brand name than a specific model. “ Dual-Xeon”不是您要针对的处理器的精确规格-“ Xeon”更多是营销品牌名称,而不是特定型号。 "Xeon" doesn't even tell you if you're targetting the IA32 or x86-64 architecture. “ Xeon”甚至不会告诉您目标是IA32还是x86-64体系结构。

This is important, because the optimisation can be significantly improved by targetting a specific CPU family. 这很重要,因为可以通过针对特定的CPU系列显着改善优化。 There are many options described in the GCC documentation ; 在GCC文档中有许多选项; in particular, start with -march to generate code for a particular instruction set. 特别是,从-march开始为特定的指令集生成代码。

If you are not targetting x86-64, then use -mfpmath=sse (if supported by your CPU type) to use SSE instructions for floating point, rather than 387 (this option is the default on x86-64). 如果您未针对x86-64,请使用-mfpmath=sse (如果您的CPU类型支持)将SSE指令用于浮点,而不是387(x86-64上的默认选项)。 Likewise, -malign-double can give a speedup (but is only default on x86-64). 同样, -malign-double可以提高速度(但仅在x86-64上是默认设置)。

Also, if the functions you use in libmath are shown as a hotspot when you profile, then recompiling that library with more specific optimisation flags may be of benefit. 另外,如果在配置文件时在libmath中使用的功能显示为热点,则使用更具体的优化标志重新编译该库可能会有所帮助。

Depending on whether it is safe and appropriate for your given application you could consider -ffast-math . 根据它是否安全以及是否适合您的给定应用程序,您可以考虑-ffast-math Please read the warnings on the man page for this before using it though. 请在使用前阅读手册页上的警告。

I know from experience that it can make quite a difference with programs running numerical simulations. 我从经验中知道,它与运行数值模拟的程序有很大的不同。 Of course you have to do some sanity checks to make sure the output is not altered. 当然,您必须进行一些健全性检查,以确保输出未更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM