Do you know which of the GCC optimization flags are the most appropriate to build an application, which uses double floating point and calculates a lot in real-time and it uses -lm. A target hardware is two Dual-Xeons with Linux on-board. Thanks in advance!
views:
58answers:
2Depending on whether it is safe and appropriate for your given application you could consider -ffast-math
. Please read the warnings on the man page for this before using it though.
I know from experience that it can make quite a difference with programs running numerical simulations. Of course you have to do some sanity checks to make sure the output is not altered.
"Dual-Xeon" is not a precise specification of the processors you're targetting - "Xeon" is more a marketing brand name than a specific model. "Xeon" doesn't even tell you if you're targetting the IA32 or x86-64 architecture.
This is important, because the optimisation can be significantly improved by targetting a specific CPU family. There are many options described in the GCC documentation; in particular, start with -march
to generate code for a particular instruction set.
If you are not targetting x86-64, then use -mfpmath=sse
(if supported by your CPU type) to use SSE instructions for floating point, rather than 387 (this option is the default on x86-64). Likewise, -malign-double
can give a speedup (but is only default on x86-64).
Also, if the functions you use in libmath
are shown as a hotspot when you profile, then recompiling that library with more specific optimisation flags may be of benefit.