What optimizaton flags should i use (g++-4.3.3,Linux,Core2Duo)?

Tim Prince TimothyPrince@sbcglobal.net
Sun Apr 19 17:50:00 GMT 2009


Martin Ettl wrote:

> i am playing around with g++-4.3.3 on Ubuntu Linux. The project i am working does a lot of floating point arithmetic (based on double variables). The testplattform i use, is a intel core 2 duo processor. So what optimization flags are good for this plattform? Currently i am using -O3 -funroll-loops, but there are a plenty other. 
> 
If you are using the 64-bit compiler, this may be sufficient, but
--param max-unrolled-insns=<your choice>
or
--param max-unroll-times=4
may be useful to make the unrolling less aggressive.

I suppose you're not using the 32-bit compiler, where you would set
-march=pentium-m
or
-march=prescott
or some other option, to enable partial or full use of sse2.

Add -msse3 if you like (either 32- or 64-bit), but you probably have no
use for it.

-fassociative-math (or, if it doesn't work, -ffast-math) are required for
vectorization of sum reductions.  Otherwise, they may be undesirable.
They are saner in gfortran than in g++.

If you use OpenMP, of course you would set -fopenmp.



More information about the Gcc-help mailing list