- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
there seems to be a bug with infinity numbers.
See this minimal example
#include <iostream>
#include <limits>
#include <cmath>
int main()
{
std::cout << std::isinf(std::numeric_limits<double>::infinity());
}
If -O1
or higher is enabled, this puts out 0
with is wrong.
I am using the Intel(R) oneAPI DPC++/C++ Compiler 2021.3.0 (2021.3.0.20210619)
Here is a link to the code on compiler explorer:
https://godbolt.org/z/rvvcd4dfY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for contacting Intel support.
The behavior you have experienced is expected. Let me explain in more details:
When you execute the compiler with -O1 or higher, the default compiler options are passed to compiler driver.
There is an option fp-model (https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html), which controls the semantics of floating-point calculations.
OneAPI 2021.2.0 has changed the default value for this option to -fp-model=fast (please see this page this this and other changes: https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpc-c-compiler-release-notes.html), which means the compiler can make various out-of-box optimizations for floating-point math (float or double). This made the compiler to use more aggressive optimizations on floating-point calculations compared to previous release. That is why you may observe 1 being returned with Intel® oneAPI DPC++/C++ Compiler 2021.1.2 and 0 being returned with Intel® oneAPI DPC++/C++ Compiler 2021.2 and newer.
If you wish to get the desired result (1 in your case), then you can use "-fp-model=strict" or "-fno-finite-math-only" options as follows:
$ icpx -O1 test.cpp -o test
$ ./test
0
$ icpx -O1 -fp-model=strict test.cpp -o test
$ ./test
1
$ icpx -O1 -fno-finite-math-only test.cpp -o test
$ ./test
1
However, we now understand that users may face this issue and if so, then they would like to understand why they get incorrect results. Therefore, A new warning would be introduced for such cases in the upcoming Intel® oneAPI release.
Hope that this helps.
Regards,
Khalik.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reporting us.
We are able to reproduce your issue. We are working on this internally and will get back to you soon.
Thanks & Regards
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for contacting Intel support.
The behavior you have experienced is expected. Let me explain in more details:
When you execute the compiler with -O1 or higher, the default compiler options are passed to compiler driver.
There is an option fp-model (https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html), which controls the semantics of floating-point calculations.
OneAPI 2021.2.0 has changed the default value for this option to -fp-model=fast (please see this page this this and other changes: https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpc-c-compiler-release-notes.html), which means the compiler can make various out-of-box optimizations for floating-point math (float or double). This made the compiler to use more aggressive optimizations on floating-point calculations compared to previous release. That is why you may observe 1 being returned with Intel® oneAPI DPC++/C++ Compiler 2021.1.2 and 0 being returned with Intel® oneAPI DPC++/C++ Compiler 2021.2 and newer.
If you wish to get the desired result (1 in your case), then you can use "-fp-model=strict" or "-fno-finite-math-only" options as follows:
$ icpx -O1 test.cpp -o test
$ ./test
0
$ icpx -O1 -fp-model=strict test.cpp -o test
$ ./test
1
$ icpx -O1 -fno-finite-math-only test.cpp -o test
$ ./test
1
However, we now understand that users may face this issue and if so, then they would like to understand why they get incorrect results. Therefore, A new warning would be introduced for such cases in the upcoming Intel® oneAPI release.
Hope that this helps.
Regards,
Khalik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread.
Any further interaction in this thread will be considered community only.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page