![](/img/trans.png)
[英]Issues Installing Intel's Decimal Floating-Point Math Library on Mac OS Monterey
[英]Fast floating point model broken on next-generation intel compiler
我正在尝试从使用英特尔 OneAPI 工具包的经典英特尔编译器切换到下一代 DPC/C++ 编译器,但处理浮点运算的默认行为似乎已损坏或不同,因为comparison with infinity always evaluates to false in fast floating point modes
。 以上既是编译器警告,也是我现在使用 ICX 遇到的行为,但不是经典编译器遇到的行为(对于使用的相同最小编译器标志集)。
#include <iostream>
#include <cmath>
int main()
{
double a = 1.0/0.0;
if (std::isinf(a))
std::cout << "is infinite";
else
std::cout << "is not infinite;";
}
编译器标志: -O3 -Wall -fp-model=fast
ICC 2021.5.0 Output: is infinite
(也在几个旧版本上测试过)
ICX 2022.0.0 Output: is not infinite
(也在 2022.0.1 上测试过)
编译器浏览器上的现场演示: https://godbolt.org/z/vzeYj1Wa3
默认情况下,两个编译器都启用了-fp-model=fast
。 如果我手动指定-fp-model=precise
我可以恢复行为但不能恢复性能。
有谁知道使用下一代编译器保持快速浮点 model 先前行为和性能的潜在解决方案?
如果您将-fp-speculation=safe
添加到-fp-model=fast
,您仍然会收到警告,如果您想检查无穷大,您不应该使用-fp-model=fast
,但条件将正确评估:天旋地转。
在英特尔 ICC 用户到 DPCPP 或 ICX 的移植指南中指出:
FP Strictness:不支持比默认值更严格的内容。 不支持 -fp-model strict、-fp-speculation=safe、#pragma fenv_access 等。实现对这些的支持是开源社区正在进行的工作。
即使它适用于测试编译器的当前版本(icx 2022.0.0),也存在差异:文档已过时(更有可能),或者此功能是偶然工作的(不太可能)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.