gpt4 book ai didi

c - icc -fast 标志的错误结果

转载 作者:太空宇宙 更新时间:2023-11-04 04:00:06 24 4
gpt4 key购买 nike

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

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

我搜索并尝试,发现错误存在于-xHOST in -fast 的原因。

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

最佳答案

-fast turns on many aggressive compiler options below is from the intel docs

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

关于c - icc -fast 标志的错误结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12701544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com