Closed alchzh closed 10 months ago
Thanks for looking into this! I think you are probably right.
If it's just a few percent, say less than 10%, I'm not sure if it's worth the trouble. In any case, the important thing is that the simulations remain bit-wise identical with these optimizations. So no floating-point operations should be rearranged.
Some compilers have started to turn on fp-contract by default (clang). That breaks reproducibility and some unit tests. I've added a new flag to setup.py to turn off fp-contract manually at least while running the unit tests.
I think it should be save to turn on most optimization flags, but I'll close this issue for now. If you want to look into it more, feel free to reopen it once you have done some benchmarking.
I was modifying rebound this summer and played around with compiler flags to speed up our long running simulations.
-ffast-math
is too aggressive and breaks some simulations completely, but I think some other flags are totally safe to put inMakefile.defs
. In particular, rebound shouldn't be affected by-fno-trapping-math
(there's no code that catches signals) and-fno-math-errno
(errno is never checked), so I think they can be enabled for small but "free" performance gains of a few percent.There are also some flags that seem to not break rebound but could change results slightly (e.g.
-ffp-contrast=fast
)I can do some benchmarking after this AAS is over-- my overheating prone laptop can't record consistent times.
(I see that there's a note explicitly disabling
-march=native
)