Community
cancel
Showing results for 
Search instead for 
Did you mean: 
xuzheng97
Beginner
115 Views

How to handle trivial precision differences with different compiler optimizations

Hello All,

Recently I met some result differences when I tried to use compier options from O0 to O3.
Though theyare trvial and even can be ignored, I still want to know more clear about them.

1. one variable value is 2.468057e-18for O0 and 1.676039e-18for O3.

This variable looks very small.
I tried '-ftz/-zero/-no-bss-init' options with O3 but no any influence.

2. variable F=4867459.8367both for O0 and O3
While F-ksi=-9.31323e-10 for O0 and -1.86265e-09 for O3

All data here are double.
In my memory double stype data has 15-16 valid numbers, then F-ksi e-9 should not make sense at all.


But how to eliminate these differences from compiler site?

Thanks & Best Regards
0 Kudos
4 Replies
Om_S_Intel
Employee
115 Views

Could you please try the following:

Linux and Mac OS X: -fp-modelprecise

Windows: /fp:precise

If the above does not work then you may try

Linux and Mac OS X: -fp-model source

Windows: /fp:source


xuzheng97
Beginner
115 Views

Om Sachan,

Thanks, I forget fp-model option :-)
In fact fp-model precise worked and eliminated these difference.

To my unstandings, fp-model precise may decrease performance.
Based my upper decription, could these difference be ignored?

Thanks
Om_S_Intel
Employee
115 Views

Yes, the fp-model precise may decrease performance.

The error tolerance depends on the application. The application owner should know better.
mecej4
Black Belt
115 Views

Quoting xuzheng97

1. one variable value is 2.468057e-18for O0 and 1.676039e-18for O3.

This variable looks very small.

"Small" compared to what? 1 ? How about compared to 0 ? The diameter of an electron in light-years ?

2. variable F=4867459.8367both for O0 and O3
While F-ksi=-9.31323e-10 for O0 and -1.86265e-09 for O3

... then F-ksi e-9 should not make sense at all.

We have no idea what "F-ksi" is; therefore, any judgements about its value making sense are premature.

But how to eliminate these differences from compiler site?

You cannot, except in a contrived and pointless way. You would benefit by reading books and articles about what to expect from finite-precision calculations. For starters, Google "perfidious polynomial" and read some of the articles related to that.

Reply