-ffast-math: Math critical applications?
John Richard Moser
nigelenki at comcast.net
Wed Oct 4 22:13:41 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robin H. Johnson wrote:
> On Wed, Oct 04, 2006 at 03:35:12PM -0400, John Richard Moser wrote:
>> Currently of interest to me is applying -ffast-math generally. This
>> should not be a problem in most cases; -ffast-math only produces defects
>> in floating point calculations, and the defects are apparently often
>> minor enough to go unnoticed. Critical calculations like TCP/IP packet
>> size, byte offsets in files, and physical pixel locations are all
>> discrete anyway and thus will all be integer.
> This is a slight tangent to your original point, but it came up recently
> with regards to -ffast-math, and is related to your correctness
> questions below.
>
> The one sentence background is that I'm a Gentoo developer.
>
> In the last month, I've seen several separate Gentoo bugs filed for
> cases where -ffast-math was causing incorrect operation or outright
> segmentation faults - with a stable GCC.
>
> We're putting an item into our next GWN, but a quick survey of Gentoo
> developers indicated that -ffast-math has broken a lot of stuff in the
> past: openssl, libmcrypt, kde-libs, openoffice, apache2, postgresql,
> mpfr, gmp, nss_ldap (a subset of the complete list).
>
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.
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.
> 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-----
More information about the Devel
mailing list