[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tune gcc



On Mon, Mar 17, 2003 at 01:42:20PM +0000, Klaus Imgrund wrote:
> Cflags are some kind of black magic thing as it appears to me.

Everyone seems to have got caught up on the CFLAGS thing here.  All
we're trying to do is set some command line switches for gcc, and CFLAGS
is a common way of doing it.  Effectively, most makefiles/build systems
call gcc thusly:

gcc -o filename $CFLAGS ./filename.c

CFLAGS can contain whatever GCC command line switches you want; the gcc
info docs (in gcc-doc) document them all.

> I got an
> AMD Durom 900 so you should think I need to use the duron flag - naah
> it's athlon-tbird.

Well, yeah; a Duron is, as far as I know, just a slightly crippled and
much cheaper Athlon Thunderbird chip.  The changes make no (or little)
difference to the sorts of things GCC does to try to improve performance
on this particular chip.

> For reasons like that I don't think you can just have
> default flags that are guaranteed to work - exept you use i386.

Yeah.  Upstream obviously can't set particular -march options, since
they have no idea what CPU their users will have.  Well, they could play
some autoconf games (like mplayer does, I think), but they generally
don't.  It's your compiler, so you can give it whatever flags you want.

The other important thing to remember is that processor-specific
optimisations are generally not very useful.  I've not seen any
benchmarks claiming more than ~5% overall CPU utilisation reduction;
even my fairly old p3-450 is VERY rarely CPU bound, so that 5% gain
doesn't buy me much at all.

Of course, if you find some convincing evidence that using processor
specific optimisations does get a large gain, post them here!  It'll at
least quell the stupid 'Debian needs a separate archive for every CPU
model in existence!!!1' one or the other.  Well, we can dream :)

> If you set the flag with -mcpu=CPU it still generates code that also
> runs on i386 boxes.Only if you use -march=CPU the code only works on the
> type of CPU you specify.

Yup.

-- 
Rob Weir <rweir@ertius.org>				http://ertius.org/

Attachment: pgpVl6p0oyT9V.pgp
Description: PGP signature


Reply to: