3 ms·
Especially the fact that loading a library compiled with GCC and fast math on, can modify the global state of the program... It's one of the most baffling decis
by vchuravy 5y ago
Especially the fact that loading a library compiled with GCC and fast math on, can modify the global state of the program... It's one of the most baffling decisions made in the name of performance.
I would really like for someone to take fast math seriously, and to provide well scoped and granular options to programmers. The Julia `@fastmath` macro gets close, but it is two broad. I want to control the flags individually.
Also the question how that interacts with IPO/inlining...
- mhh__ 5y agoD (LDC) lets you control the flags on a per function basis. So one can (and we do at work) have @optmath which is a specific set of flags (just a value we defined at compile time, the compiler recognizes it as a UDA) we want as opposed to letting the compiler bulldoze everything.
- physicsguy 5y agoYou can do that on a per-compiler basis for e.g. with #pragma GCC optimize(“fast-math")
- mhh__ 5y agoHopefully it still works as an attribute but my point is that you can (say) opt in to allowing more liberal use of FMA without (say) opting in to aggressive NaN assumptions
- gnufx 5y agoGCC attributes give you per-function control over both target and optimization options (unfortunately not with Fortran). I'd have to look up what's available, but some per-loop control is possible with OpenMP pragmas too (perhaps with GCC's -fopenmp-simd if you don't want the threading).
- physicsguy 5y agoFast math is a collection of optimisations, you can enable them individually. You just have to look up what the appropriate ones are
- mhh__ 5y agoAs I have said above the whole point I am making is that you want to turn a set of them on for only one function.
- physicsguy 5y agoYou can, that is exactly what the pragma allows you to do?
- titzer 5y agoIt should always have been a bit in the instruction encoding, never global state.