-ffast-math: Math critical applications?

Jim Gettys jg at laptop.org
Fri Oct 6 13:13:32 EDT 2006


On Wed, 2006-10-04 at 22:13 -0400, John Richard Moser wrote: 
> -----BEGIN PGP SIGNED MESSAGE-----
> This sheds a lot more light on the situation than I previously had
> access to.  I was considering blacklisting breakable applications if
> feasible; clearly this is not a maintainable plan of attack.  Possibly,
> though, it may be acceptable to attack specific points of interest.
> 
> Considerations thus lead me to ask:  Can the JPEG and PNG decoders used
> by the Web page renderer, and the renderer itself, be -ffast-math
> compiled safely?  As far as I am aware, these only calculate visual
> elements such as alpha blend for PNG with alpha channel, and discrete
> cosine transforms for JPEG, so pretty much failures here should result
> in slightly fudged visual elements.

You have to look at the algorithms on a case by case basis,
individually.

It defaults "off" for a very good reason.

If you truncate rather than gradual underflow, you can cause results to
become unpredictable in many algorithms.


> 
> This leaves me with the question of whether outright failures will occur
> due to -ffast-math inherently.  If it just spits out bad values that can
> be used, that's fine; if it spits out results that when accessed cause
> an error (i.e. {a = invalidly_calculated_float;} causes segfaults... I
> can't imagine how), this is not feasible.
> 
> 

Bad values is a mis-nomer: typically, this option is turning off gradual
underflow and similar features of IEEE.

And yes, you can get outright failure in algorithms that depend on
correct IEEE floating point behavior.
                                       - Jim


> 
> 
> > For openssl, mcrypt, mpfr and gmp, the applications had decent
> > testsuites, and the bug was easy to catch, but in the other cases it
> > wasn't caught until much later.
> > 
> > 
> > 
> 
> - --
> All content of all messages exchanged herein are left in the
> Public Domain, unless otherwise explicitly stated.
> 
>     Creative brains are a valuable, limited resource. They shouldn't be
>     wasted on re-inventing the wheel when there are so many fascinating
>     new problems waiting out there.
>                                                  -- Eric Steven Raymond
> 
>     We will enslave their women, eat their children and rape their
>     cattle!
>                   -- Bosc, Evil alien overlord from the fifth dimension
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iQIVAwUBRSRqUws1xW0HCTEFAQJWQQ//VWkdRn0q88rlHMyvGoxMqTJcVgTbP0EL
> 1f3s3K3nUlJlHagmPaD3DSzfiigirIwM9hGh+rjVEphMUk7cKO0czGPfhY0cTeF0
> HnHN4ypLvTxl01vAyHZzsovWlsZ8Fb/8vPeq8hM1qP0pOjVPhZrCgGCFfmP2mLpD
> fQmG6rRw5/r4wIP7CRC3BancGra85cB0Ed0qqA1mahTyKuqMcYfaJWDdvIc1fDKG
> d8DC1liQZnQn6IBZrXkbdlsFV8rP5w5ZG1talXMy9FFwuTDsUypOcSEPF4sjCQGq
> LeqIVJECS1M58riFbG/VPcI5BelT0R/TVR0i2TFMafbU+I4TaFIZZIne2nbOnRn4
> SofFZ21JEmbwuftsGsDiFTM6RsFFETA8iQUFpatsMbchjS/HbiCfM04lhHcTXvB2
> samR3fT+LmvD9QYW7YYueG1r3xC5xPFQjUioOiKCf0xaza0szR57yJffKWAiWRHa
> H1q5dAddN23ODI/YfSwVdjQKbqe6NZNWPrdWo1QOcGyyKpoW9aRICbwFRmGKmOKC
> YK5WFRfbNrEJYXn+NKMLPRRI5O7tlW5dEI06nDrQ9zD7Tuo7rjq1mYOAIjfC0VxW
> gz2sIVW/I71VIyW42UCFyYN9SSUt7+5fMoT3cjOTSad660DbIwX5r7Gf0O2f96JB
> KGWFZ/NHFz4=
> =QK0X
> -----END PGP SIGNATURE-----
> _______________________________________________
> Devel mailing list
> Devel at laptop.org
> http://mailman.laptop.org/mailman/listinfo/devel
-- 
Jim Gettys
One Laptop Per Child





More information about the Devel mailing list