Release Building and /etc/make.conf

Erik Trulsson ertr1013 at student.uu.se
Tue Jan 20 07:32:20 PST 2004


On Wed, Jan 21, 2004 at 01:41:26AM +1100, Bruce Evans wrote:
> 
> bsd.cpu.mk should rarely be edited, but /etc.make.conf is per-machine so
> you can put anything you want in it.  However, defaulting to
> -mcpu=pentiumpro is just a bug, so I edit it out of bsd.cpu.mk.  It
> just micro-pessimizes for all CPUs that aren't pentium pros.  This is
> almost harmless for i386's because no one uses them, and almost harmless
> for P3's and maybe P4's because they share some bottlenecks with pentiumpros,
> but Athlons handle naive i386 code better than pentiums so many of the
> pentiumpro optimizations are pessimizations for athlons.

Considering that the PentiumII and PentiumIII are based on the same
microarchitecture as the Pentium Pro, optimizing for the Pentium Pro,
should give fairly good performance on a large number of CPUs.
Optimizing for any given CPU will pessimize for some other CPUs, and
today it is probably better to optimize for the P6 architecture than to
optimize for a '486 which is what gcc at least used to do as default.

> 
> Note that CPUTYPE has worse bugs for i386's.  Setting it to a supported
> CPU gives -march instead of -mcpu, so using it gives unportable binaries,
> and bsd.cpu.mk provides no way to get the corresponding -mcpu settings.
> OTOH, CPUTYPE for alphas gives only -mcpu.


Note that the meaning of -mcpu is different for x86 and Alpha.
-mcpu on alpha is equivalent to -march for x86, in that it allows new
instructions to be used.  -mtune is the option you need to use for
alpha to get the same behaviour as -mcpu gives for x86 (i.e. optimize
for a certain CPU, but make sure the code still runs on older CPUs.) 

The GCC people seem to have never quite managed to make up their minds
on what the options for this should be named. Sparc and PowerPC also
uses -mcpu/-mtune while MIPS uses -march/-mtune, HPPA uses
-march/-mscheduling and M68k doesn't really have any equivalent of
-mtune.  All in all a complete mess which doesn't seem likely to be
fixed any time soon.


> 
> Some times for an integer crunching application (searching a game tree)
> compiled with various options and running on an Athlon-XP:
> 
> -O3 -fomit-frame-pointer -mcpu=i586:        11.21 seconds
> -O3 -fomit-frame-pointer -mcpu=athlon-xp:   11.23
> -O3 -fomit-frame-pointer -mcpu=i386:        11.93 (-mcpu=i386 is the default)
> -O3 -fomit-frame-pointer -mcpu=i486         12.72
> -O3 -fomit-frame-pointer -mcpu=pentium3:    14.71
> -O3 -fomit-frame-pointer -mcpu=pentium-pro  14.72
> -O3 -fomit-frame-pointer -mcpu=pentium2:    14.72
> -O3 -fomit-frame-pointer -mcpu=pentium4:    18.19
> 
> I think my normal application (cc) is not affected by -mcpu nearly as much
> as this, and don't use -mcpu for building worlds.  The above shows that
> -mcpu=i386 is not too bad for athlons (but this might change for FP
> crunching applications).

But -mcpu=i586 seems to give results on that particular test, and seems
likely to give better performance than -mcpu=i386 in general when used on
other benchmarks and CPUs.



-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at student.uu.se


More information about the freebsd-current mailing list