1

现在我正在使用 icc 来编译和运行我的 ANSI C 代码。

当我打开 -O2 优化时,一切正常。但是当我更改为 -fast 时,结果会出现分歧(有很多 nan)。

我google了一下,发现-fast中存在-xHOST的错误原因。

我想知道 -xHOST 在编译中是如何工作的。以及如何避免我的代码中出现这种错误?

4

1 回答 1

1

-fast 打开下面的许多激进编译器选项来自英特尔文档

Description
This option maximizes speed across the entire program. It sets the following options:
• On Itanium®-based systems: Windows: /O3 and /Qipo Linux: -ipo, -O3, and -static
• On IA-32 and Intel® EM64T systems:
Mac OS: -ipo, -O3, -no-prec-div, and -static
Windows: /O3, /Qipo, /Qprec-div-, and /QxP
Linux: -ipo, -O3, -no-prec-div, -static, and -xP
Note that programs compiled with the -xP (Linux) or /QxP (Windows) option will detect non-compatible processors and generate an error message during execution.
On IA-32 and Intel® EM64T systems, the -xP or /QxP option that is set by the fast option cannot be overridden by other command line options. If you specify the fast option and a different processor-specific option, such as -xN (Linux) or /QxN (Windows)

其中 -xHost

Generates instruction sets up to the highest that is supported by the compilation host. On Intel processors, this corresponds to the most suitable /Qx (-x) option; on compatible, non-Intel processors, this corresponds to the most suitable of the /arch (-m) options IA32, SSE2 or SSE3. This option may result in additional optimizations for Intel microprocessors that are not
performed for non-Intel microprocessors.‡

因此,如果问题出在 -xHost 上,请查看是否为您的处理器的正确架构类型强制执行 -march 可以修复错误或仅使用 -O3

于 2012-10-03T04:33:38.037 回答