Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Optimization question

Izaak_Beekman
New Contributor II
742 Views

Hi,

Under what conditions, if any, will (current versions of) ifort assume associativity of arithmatic when working with floating point variables, and optimize away corrections such as those found in the Kahan summation algorithm: ( http://en.wikipedia.org/wiki/Compensated_summation )

i.e. Does the compiler assume associativity of arithmatic by default? When -O3 is passed? Is there a way to turn it off, if it's on?

Thanks,

Zaak

0 Kudos
2 Replies
TimP
Honored Contributor III
742 Views

The default will break Kahan summation except at -O0.  I would suggest setting "-assume protect_parens" so you will not require O0.  -fp-model source|precise also ought to work.

If the compiler ignored parentheses consistently (but in violation of the standard) the Kahan summation would collapse into an ordinary sum with no Kahan corrections, but with correct results at lower accuracy.

0 Kudos
Izaak_Beekman
New Contributor II
742 Views

Thanks Tim,

Good to know.

0 Kudos
Reply