On Wed, Sep 3, 2014 at 1:21 PM, James Crist <[email protected]> wrote: > Can you point me to some examples from your experience when >> -ffast-math may result in loss of precision? I use it all the time in >> all my production codes. So I would like to learn more about the >> pitfalls. > > > Personally, I've never had an issue arise from using it, but a number of > people more knowledgable than myself have warned against it. -ffast-math is > just an easy way of setting a number of compiler flags that may result in > more optimized math operations. Most of these result in code that is > functional, and does what is intended, but no longer follows the IEEE > floating point standard exactly. As the GCC manual says: > >> This option should never be turned on by any -O option since it can result >> in incorrect output for programs which depend on an exact implementation of >> IEEE or ISO rules/specifications for math functions. > > > Looking through the flags that -ffast-math sets, it seems that > -funsafe-math-operations is the big one that may cause issues. This allows a > larger set of transformations on the computations to be used, which may > result in changes to summation error, over/underflow behavior, and > differences in rounding behavior from the code *as written*. For many things > these may not matter, but for some they may.
Yes, I am aware of this. Note that the Fortran language gives compilers some freedom anyway in rearranging your expression when evaluating. In practice, I never had any issue with -ffast-math, because a good algorithm in my opinion shouldn't really depend on details of IEEE implementation. I could be wrong of course, that's why I was curious if you actually have an example. Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVCjoKu%3Dhch%3Dhnvyr0aGRZjbPp7bd2Y6KMzPm8bXqEf-dw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
