- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When running the small piece of code given below, NaN's are reported as 0 when compiling with icpx in any optimization other than -O0.
Any other compiler (eg: g++, icpc, clang++) works as expected printing "nan" where required.
I'm using latest icpx (2022.1.0.20220316) and armadillo (11.2.1) on linux.
Already reported it at Armadillo's developer but I've been sent here!
Any help will be really appreciated,
thank
Daniel
#define ARMA_DONT_USE_WRAPPER
// Compile with eg: icpx -O3 -qmkl=sequential
#include <armadillo>
int main() {
arma::Col<double> raw_vec;
raw_vec.randu(4);
raw_vec.print();
std::cout << std::endl;
raw_vec[0] = arma::datum::nan;
// Same with raw_vec[0] = std::numeric_limits<double>::quiet_NaN()
raw_vec.print();
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As -O2 is the default optimization level for the Intel compilers, sometimes we might get some changes in the results. To overcome this issue, we can use the "-fp-model=precise" flag which tells the compiler to strictly adhere to value-safe optimizations when implementing floating-point calculations. It disables optimizations that can change the result of floating-point calculations, which is required for strict ANSI conformance.
For more information please refer to the below link:
Use the below command to get the correct results:
icpx -fp-model=precise sample.cpp
./a.out
We tried at our end and we are getting the correct results. Please find the attachment(icpx_log.txt) below.
If this resolves your issue, make sure to accept this as a solution. This would help others with a similar issue. Thank you!
Best Regards,
Santosh
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
We were able to reproduce your issue at our end. We are working on your issue and will get back to you soon.
Thanks & Regards,
Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As -O2 is the default optimization level for the Intel compilers, sometimes we might get some changes in the results. To overcome this issue, we can use the "-fp-model=precise" flag which tells the compiler to strictly adhere to value-safe optimizations when implementing floating-point calculations. It disables optimizations that can change the result of floating-point calculations, which is required for strict ANSI conformance.
For more information please refer to the below link:
Use the below command to get the correct results:
icpx -fp-model=precise sample.cpp
./a.out
We tried at our end and we are getting the correct results. Please find the attachment(icpx_log.txt) below.
If this resolves your issue, make sure to accept this as a solution. This would help others with a similar issue. Thank you!
Best Regards,
Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Santosh,
It indeed solves the problem.
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks & Regards,
Santosh

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page