ICC 与 GCC - 优化和 CPU 架构
我有兴趣了解 GCC 在优化级别和迎合特定处理器架构方面与英特尔的 ICC 有何不同。我正在使用适用于 Linux 的 GCC 4.1.2 20070626 和 ICC v11.1。
ICC 的优化级别(O1 到 O3)与 GCC 有何不同(如果有的话)?
ICC 能够专门满足不同的体系结构(IA-32、intel64 和 IA-64)。我读到 GCC 有 -march
编译器选项,我认为它是相似的,但我找不到要使用的选项列表。我使用的是 64 位 Intel Xeon X5570。我可以使用任何其他 GCC 编译器选项来满足我的 64 位 Intel CPU 的应用程序的需求吗?
I'm interested in knowing how GCC differs from Intel's ICC in terms of the optimization levels and catering to specific processor architecture. I'm using GCC 4.1.2 20070626 and ICC v11.1 for Linux.
How does ICC's optimization levels (O1 to O3) differ from GCC, if they differ at all?
The ICC is able to cater specifically to different architectures (IA-32, intel64 and IA-64). I've read that GCC has the -march
compiler option which I think is similar, but I can't find a list of the options to use. I'm using Intel Xeon X5570, which is 64-bit. Are there any other GCC compiler options I could use that would cater my applications for 64-bit Intel CPUs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
icc -O2 -unroll2
大致相当于gcc -O3 -ffast-math -fno-cx-limited-range -funroll-loops --param max-unroll-times=2
代码>gcc -O1 不会为任一编译器启用 SIMD 自动矢量化,因此差异较小。
没有选项的 ICC 默认启用优化并且
-fp-model=fast=1
(比gcc -ffast-math
稍微不那么激进),但 GCC 默认为-O0
。 (即使使用gcc -O3
,-fno-fast-math
也是如此。只有gcc -Ofast
才能像 ICC 默认值一样启用快速数学。) code>-march=native 是使用构建机器的完整指令集的 GCC 选项。 ICC 支持
-march=native
,相当于其自己的-xHost
选项。在提出这个问题时,该 ICC 选项可能仅适用于 Intel CPU。GCC 可以默认配置为
-m64
或-m32
,但同一编译器可以编译任一位数的二进制文件。 ICC 提供单独构建的编译器以针对 64 位或 32 位模式;如果两者均已安装,icc 希望您通过获取其路径设置脚本来进行选择。icc -O2 -unroll2
is roughly equivalent togcc -O3 -ffast-math -fno-cx-limited-range -funroll-loops --param max-unroll-times=2
gcc -O1 doesn't enable SIMD auto-vectorization for either compiler, so there is less difference.
ICC with no options defaults to optimization enabled and
-fp-model=fast=1
(a bit less aggressive thangcc -ffast-math
), but GCC defaults to-O0
. (Also-fno-fast-math
even withgcc -O3
. Onlygcc -Ofast
enables fast-math like the ICC default.)-march=native
is the GCC option to use the full instruction set of the build machine. ICC supports-march=native
as equivalent to its own-xHost
option. At the time of this question, that ICC option may have worked only for Intel CPUs.GCC can be configured with either
-m64
or-m32
as the default, but the same compiler can compile binaries of either bitness. ICC provides separately built compilers to target 64-bit or 32-bit mode; icc expects you to choose, if both are installed, by sourcing their path setting script.请参阅 GCC 手册中的第 3.17.15 节, ie386 和 x86-64 选项,获取适用于这些体系结构的所有选项的完整列表和说明(IA-64 是 Itanium,您不太可能拥有其中之一)。
在这种情况下最重要的选项是:
-m64
生成 64 位代码;-march=
生成特定CPU类型的指令;和-mtune=
调整特定CPU 类型的代码。See section 3.17.15 in the GCC manual, ie386 and x86-64 Options for the full list and description of all the options applicable to those architectures (IA-64 is Itanium, and it's unlikely you have one of those).
The most important options in this context are:
-m64
Generate 64-bit code;-march=
Generate instructions for a specific CPU type; and-mtune=
Tune the code for a specific CPU type.