Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

2025.1 floating point issue

may_ka
Beginner
977 Views

Hi,

 

after installing the 2025.1 oneapi basekit and hpckit release I have stumbled over substantial differences in calculation results.

 

After some digging it turned out that the culprit is icpx.

Doing some comparisons for the respective calculations I found that g++ 14.2, clang++ 19.1, icpx 2024.0.2 all deliver the same results irrespective of the floating point model (i.e. irrespective of whether "-ffast-math" is set or not). icpx 2025.1 also delivers the same results but only when using "-O0 -g", or "-O3 -fno-fast-math".

 

Is this a bug ....... or is icpx 2025.1 requiring different flags?

 

The calculations involve multiplication, addition, subtraction, square root, power, and absolute value, where for the last there std::sqrt, std::pow and std::abs is used.

 

Any idea?

 

Thanks

 

OS: Linux

Kernel: 6.14

0 Kudos
5 Replies
Sravani_K_Intel
Moderator
899 Views

Could you provide a test case that demonstrates the differences in results?

0 Kudos
may_ka
Beginner
780 Views

Hi.

 

I tried hard but could not isolate the problem into a small reproducer. My current code base is >100,000 lines. However, I got to the point that there is something wrong with loop optimization.

 

What I have found so far is that options "-O0", "-O1" and "-O2" without any "fp-model" specification do not exhibit the same problem. My understanding is that "-fp-model=fast" is the default invariably of the "-O" setting.

 

However "-O2 -qopenmp" produces wrong results, but "-O2 -qopenmp -fp-model=precise" produces the correct results.

 

I was wondering whether I can run test with "-O2" plus successively all options which "-O3" sets.

I have tried to identify all options which "-O3" is setting, but the manual says nothing about it:

"Performs O2 optimizations and enables more aggressive loop
transformations such as Fusion, Block-Unroll-and-Jam, and collapsing IF
statements.
This option may set other options. This is determined by the compiler,
depending on which operating system and architecture you are using. The
options that are set may change from release to release."

 

Maybe you can provide those options.

0 Kudos
Sravani_K_Intel
Moderator
736 Views

The default behavior of fp-model=fast in the oneAPI C/C++ compiler 2024.2 has been updated to honor NaNs and infinities. This is a change from versions 2024.1 and earlier, where fp-model=fast assumed NaN and infinite values would not appear as inputs or outputs. Can you try the options -fno-honor-nans -fno-honor-infinities to see if that helps your case?

0 Kudos
may_ka
Beginner
721 Views

Hi,

 

I tried with compile flags

 

icpx -march=cascadelake -std=c++20 -fPIE -std=gnu++20 -ferror-limit=4 -frelaxed-template-template-args -O3 -qopenmp -fno-honor-nans -fno-honor-infinities

and

icpx -march=cascadelake -std=c++20 -fPIE -std=gnu++20 -ferror-limit=4 -frelaxed-template-template-args -O3 -fno-honor-nans -fno-honor-infinities

and

icpx -march=cascadelake -std=c++20 -fPIE -std=gnu++20 -ferror-limit=4 -frelaxed-template-template-args -g -D_GLIBCXX_DEBUG_PEDANTIC -g -O0 -fp-model=precise -c

where 1 and 2 produce results different from 3 and using g++ and clang++. I.e. your proposed flags did not resolve the issue.

0 Kudos
Sravani_K_Intel
Moderator
702 Views

Thanks for trying. As for the fp-model, the above-mentioned change is the only one that was made in 2024.2 release. We will need a test case to further investigate the behavior you are observing. 

0 Kudos
Reply