Dan Hollis wrote:

On Mon, 12 Jul 2004, Meghazi Fabien wrote:


I would like to compile xmame for my AMD k7 Athlon with the best options, I'm trying to use a good combination in configure before building but as I don't know much about optimization I'm trying to get the best by trial/failure. For me to find the best optimization, I would like to be able to benchmark the result after each compilation. Does someone have an idea about how to benchmark accurately my compilations (so I can also benchmark sdl against xv, gl, etc ...)?



This one works pretty well for me:

CFLAGS = -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math 
-malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing 
-fstrength-reduce

-Dan

I don't want to offend you, but I'd say those flags are rather odd. First, setting anything higher than -O3 in gcc has the same result as -O3. Using both -march and -mcpu at the same time is usually not what you want (although it might be supported, I'm not sure). Instead, just using -march=pentiumpro is probably what you want. This won't work for the guy asking the original question though, he likely wants -march=athlon or -march=athlon-xp instead.

-fstrength-reduce is redundant, since it is turned on by -O3.

-fno-strict-aliasing might be required to compile xmame (I don't have the documentation handy) but otherwise I wouldn't use it, since -fstrict-aliasing (which is turned on by -O3) is usually a safe optimization.

-malign-loops, -malign-jumps and -malign-functions are obsolete in recent versions of gcc, and it is recommended to use their corresponding -f flags instead. Even then, all these are set to a good processor-specific default by gcc, and you should probably not touch them unless you have tried and have found these faster.

-ffast-math is nice if and when it works. It might give odd results though.

Also, adding -pipe will make compilation faster if you have enough memory for it.

This leaves us with the following:
CFLAGS = -O3 -march=pentiumpro -pipe -fomit-frame-pointer -ffast-math
(or, since the original question involved an Athlon:
CFLAGS = -O3 -march=athlon -pipe -fomit-frame-pointer -ffast-math)

What more can be done? Using -Os instead of -O3 can produce faster code in many cases. Sometimes, -O2 can actually result in faster code than -O3.

I'd recommend having a look at the following links for more information. The first two are from the gcc manual, and tend to be rather technical. The last two might be easier to grasp:
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/gcc/Optimize-Options.html#Optimize%20Options
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/gcc/i386-and-x86-64-Options.html#i386%20and%20x86-64%20Options
http://freshmeat.net/articles/view/730/
http://www.coyotegulch.com/acovea/index.html


All this is assuming gcc 3.4.0 or higher but most of it, if not everything, is applicable to any gcc >= 3.0.0.

Regards,
Anders

_______________________________________________
Xmame mailing list
[EMAIL PROTECTED]
http://toybox.twisted.org.uk/mailman/listinfo/xmame

Reply via email to