Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Robin_C_1
Beginner
49 Views

c++ math function arcsin(double) result difference in different Linux system

==== problem descreption ====

1) we have 2 systems: system_old vs. system_new.
- OS: RHEL 6.4 (Kernel 2.6.32-358.11.1.el6.x86_64) vs. RHEL 6.6 (Kernel 2.6.32-504.el6.x86_64)
- Hardware (CPU): intel xeon E5-2690 vs. E5-2697.v2
- C++ compiler: intel compiler 2016 (icc (ICC) 16.0.3 20160415) (manually confirm the libimf.*, libm.* as identical)

2) we test the below simple code in different Linux 

----------------------------------

#include <stdio.h>
#include <math.h>

int main()
{
long htmp = 0xbf44475f40d65a8a;
double dtmp0 = *(double *)&htmp;
printf("dtmp0,asin(dtmp0)=%lf,%40.25e\n",dtmp0,asin(dtmp0));
return 0;
}

----------------------------------

2.1) the results are different (compiled by command line: icc -g -o asin_test asin.cpp)
### all the tests have been checked with the below scenario
- compile in old system, and copy the executable to new system, run both
- compile separately in both system, and run both

system_old output:
dtmp0,asin(dtmp0)=-0.000619, -6.1885981732138822721672744e-04
system_new output:
dtmp0,asin(dtmp0)=-0.000619, -6.1885981732138811879651019e-04


2.2) also, the below compiler options are tested, all the results are as above (the difference is still there)
icc -g -shared-intel -fp-model strict -fimf-arch-consistency=true -fimf-precision=high -std=c++11 -O0 -o asin_test asin.cpp
icc -g -static-intel -fp-model strict -fimf-arch-consistency=true -fimf-precision=high -std=c++11 -O0 -o asin_test asin.cpp

2.3) when compile with g++ as (g++ -g -o asin_test asin.cpp) the results are identical. (-6.1885981732138822721672744e-04)
2.4) when compile with icc (ICC) 15.0.3 20150407, the results are identical

==== solution request ==== 
1) what's the cause the above differences?
2) are there any compiler options which can make the runtime results identical?
3) what's the recommended options for balance between FP consistency and performance?

0 Kudos
0 Replies