Description
I'm trying to switch over from using the classic intel compiler from the Intel OneAPI toolkit to the next-generation DPC/C++ compiler, but the default behaviour for handling floating point operations appears broken or different, in that comparison with infinity always evaluates to false in fast floating point modes
. The above is both a compiler warning and the behaviour I now experience with ICX, but not a behaviour experienced with the classic compiler (for the same minimal set of compiler flags used).
Minimally reproducible example
#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;";
}
Compiler Flags:
-O3 -Wall -fp-model=fast
ICC 2021.5.0 Output:
is infinite
(also tested on several older versions)
ICX 2022.0.0 Output:
is not infinite
(also tested on 2022.0.1)
Live demo on compiler-explorer: https://godbolt.org/z/vzeYj1Wa3
By default -fp-model=fast
is enabled on both compilers. If I manually specify -fp-model=precise
I can recover the behaviour but not the performance.
Does anyone know of a potential solution to both maintain the previous behaviour & performance of the fast floating point model using the next-gen compiler?
-ffinite-math-only
, enabled by-ffast-math
, enabled by-Ofast
, godbolt. It makes optimisations based on the assumption that NaNs do not ever occur. – Rectum-ffinite-math-only
assumes that arguments and results are not NaNs or Infs. – Hadria-fp-model=fast
is defined to include IEEE-754 compliant handling of Infs (and I can find no such guarantee in the Intel docs, but may be looking in the wrong place), nothing seems broken. – Hadria