现在我使用I C C来编译和运行我的ansic代码。
当我打开-O2优化时,一切正常。但当我换成-快时,结果就不同了(有很多nan)。
我Google尝试过,发现-XHOST在-FAST中存在错误的原因。
我想知道-xHOST如何编译。如何避免我的代码中出现这种错误?

最佳答案

-下面的许多agreessive编译器选项都是从英特尔文档中快速打开的

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)

其中as-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以获得正确的arch类型的处理器来修复错误,或者只使用-O3

09-10 01:39