[英]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.