现在我正在使用icc来编译和运行我的ANSI C代码。
当我打开-O2优化时,一切正常。但是当我改为-fast时,结果会有所不同(有大量的纳米)。
我用Google搜索并尝试,发现错误存在-fast中的-xHOST原因。
我想知道-xHOST在编译时是如何工作的。以及如何在我的代码中避免这种错误?
答案 0 :(得分: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