-
Notifications
You must be signed in to change notification settings - Fork 939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manylinux: disable -ffast-math #1820
Conversation
Thanks for this PR. Can you rebase on current gevent master, please? That should give the CI a chance to run and pass. |
Thanks! |
p.s. here's a gcc bug for this gotcha: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55522 Without understanding what the scipy code does, I suspect the scipy code got impacted because of some iterative algorithm converging to the exit condition slower when denormalized numbers are clamped to zero (perhaps never converging "for real" but hitting some maximum iteration count). |
This also disables the use of -Ofast. Not only is -Ofast detrimental to floating-point accuracy but can in fact affect other code that is dynamically linked! That's really bad as it has the potential to break things like SciPy at runtime. See also these references: - https://simonbyrne.github.io/notes/fastmath/ - gevent/gevent#1820
This also disables the use of -Ofast. Not only is -Ofast detrimental to floating-point accuracy but can in fact affect other code that is dynamically linked! That's really bad as it has the potential to break things like SciPy at runtime. See also these references: - https://simonbyrne.github.io/notes/fastmath/ - gevent/gevent#1820
This code runs in under 1 second:
but if you import
gevent
then it takes many seconds to complete.
I don't entirely understand the culprit, i.e. how it affects the execution of scipy's Fortran code. From randomly breaking with gdb, in the 2nd case, the scipy code doesn't seem to use
libm
. I've narrowed it down to gevent being compiled with-ffast-math
(due to-Ofast
, introduced in 59478eb, first released in 20.6) and thus changing process-wide floating point flags. The change happens immediately when gevent's shared libraries are loaded, since the C runtime'sset_fast_math
code is set to run as a library constructor.I've checked it by running the following function after
import gevent
to "fix" the problem: