0

On running this program, in the output Nan"s are being reported as 0, when building with icpx V2022.1, it is working fine with other compilers.

Compiling with the command:  icpx -O3 -qmkl=sequential

#define ARMA_DONT_USE_WRAPPER

#include <armadillo>

int main() {
  
  arma::Col<double> var;

  var.randu(4);
  var.print();
  
  std::cout << std::endl;
  
  var[0] = arma::datum::nan; 
  // Same with var[0] = std::numeric_limits<double>::quiet_NaN()
  var.print();
  
  return 0;
}
Pksingh
  • 53
  • 4
  • If ICPX is like ICC, it might be defaulting to `-fp-model=fast=1`. ([performance of icc main.cpp == g++ -ffast-math main.cpp](https://scicomp.stackexchange.com/q/20815)). So it might not be respecting NaN, maybe try compiling with `-fno-fast-math` or `-fp-model=precise` to see if that fixes it. – Peter Cordes Nov 11 '22 at 20:34

1 Answers1

2

The Intel compilers' default optimization setting is -O2. As suggested by Peter Cordes in the above comment, You can use the command"-fp-model=precise" flag, to instruct the compiler to strictly follow value-safe optimizations when implementing floating-point computations. Hope this solves the issue.

Santosh-Intel
  • 156
  • 2
  • 6