-
Notifications
You must be signed in to change notification settings - Fork 108
Handle -ffast-math
#329
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
Comments
So if I happen to use a case conversion routine from stdlib I cannot build with -ffast-math. That strongly discourages someone from using a lot of packages. Most such options can be used on a single file/routine without adverse affects in being mixed with other routines. I can compile up all my code with fast-math and still use standard system libraries and X11 Windows for example. Not all compiler options are like that, but most that have that issue are creating a specific file type, especially if a lot of package owners do not bother verifying their package can work with -ffast-math. Some options might be able to be flagged as "safe to mix". In those cases you could compile all the packages marked as --fast-math compatible instead of compiling nothing with the optimzation flag if one package indicates it is a problem. You would also want a relatively easy way to query the package, hopfully before incorporating into your package, to decide if you want to use it. I have not used gfortran for heavy lifting and primarily use it at home so I am not positive what can be mixed, but the same can apply to optimization levels, unrolling levels for loops, ... so for large packages there has to be more than an on-for-everyone, off-for-everyone option. |
I would suggest we get #112 working for something simple like optimization levels and than extend on the syntax. |
Hi, I would like to work on this issue as part of my GSoC preparation. Could you please provide some pointers on where to start? |
#315 removed
-ffast-math
from default flags because it can cause problems. However, I still want to use it in my projects that work with it and makes them a lot faster. I opened this issue to brainstorm some ways to fix this.One proposal is this: there will be a flag
fast-math
infpm.toml
that isfalse
by default (if you omit it). If you set it totrue
, then you signal tofpm
that your package works both with and without the-ffast-math
flag.When you run
fpm build --release
on a package,fpm
will examine thefast-math
flag in the current package as well as all the dependencies. If they are alltrue
, then it builds everything with-ffast-math
. If one of them isfalse
, then it will not use the flag.This proposal should get me what I would like, without breaking things for others. As an example, until we fix
stdlib
, we would not set itsfast-math
flag totrue
which will cause all programs that use it to be compiled without-ffast-math
. Package maintainers and end users who do not want to be worried about this simply omit thefast-math
flag in theirfpm.toml
which makesfpm
never to compile with-ffast-math
.Possible issues:
fast-math
means for each compiler. We can overcome this by being practical: for each compiler that we support, we identify these so-called "unsafe" optimizations, and package maintainers that want to take advantage offast-math
(such as myself) will ensure that their package works with it.The text was updated successfully, but these errors were encountered: