g77, g95, optimization

Tobias Burnus burnus@net-b.de
Mon Jun 18 21:47:00 GMT 2007


Terry Frankcombe schrieb:
>> With gfortran, try "-march=native -O3 -ffast-math -ftree-vectorize
>> -funroll-loops"  I don't normally recommend -ffast-math, but you
>> asked for the fastest execution (without specifying if you wanted
>> correct results. :-)
>>     
> ...and now Tobias has given another, different(!) long set of flags...
>   
Not really:

-march=nocona -ffast-math -funroll-loops -O3 -msse3 -ftree-vectorize

is essentially the same. -march=nocona is the right -march option,
but GCC 4.2 (on some platforms) makes it easy by allowing "-march=native".
As this version does not work with 4.1.x I decided to use -march=nocona.

-msse3 is actually not needed as "nocona" implies this. ("opteron" does
not which is why I tend to add it always for my system.)


> I humbly submit Steve's email as evidence for my assertion that
> gfortran/gcc dislikes simple flags to obtain simple results.  -fast,
> anyone?  ;-)
>   
Well, using "ifort -fast" does not run on my AMD (don't ask me why, it
does supports SSE3). The problem with such simple options is that they
don't work well. Essentially you need:
- architecture option (e.g. "-march=native" or "-march=opteron -msse3")
- Optimization option: -O3 (whatever default; -O0 as in GCC or -O2 as in
ifort)
- Precision option: "-ffast-math" to allow for unsafe math optimizations

This leaves: -funroll-loops and -ftree-vectorize; at least the latter
might  be merged into -O3 at some point. As with some code it still
produces ICEs or wrong code, it is not yet enabling it by default with -O3.

Tobias



More information about the Fortran mailing list