Custom Gentoo Compile

Alexander Henry alexanderhenry at cox.net
Sun Jun 4 21:52:20 MST 2006


On Fri, 02 Jun 2006 00:51:25 -0700, Wagner, Steven G <digital9ja at cox.net>  
wrote:

> I came across this article,
> http://www.cpuplanet.com/news/article.php/3111051, and was wondering if
> there was a way I could compile Gentoo with this company's compilers  
> rather
> than GCC. Their compilers are designed to optimize code for Opteron  
> chips,
> so I was thinking that it would be nice to build a 64-bit Linux cluster  
> with
> Opteron servers running Gentoo custom-compiled for Opterons. They claim  
> that
> their compilers boost performance by 40%. Maybe I'm way off-base here,  
> but
> it's late and I just got home from work :)
>
> Thanks,
>
> Steve

Gentoo is already made so that you zero in on a particular microprocessor.

http://gentoo-wiki.com/Safe_Cflags

The table in the web page above has recommended flags for all of the CPUs  
out there.  You usually just stick those settings in make.conf, and the  
settings are applied to all compiled packages.  You can also specify  
different compile flags for each package, if you wish, though I've not yet  
gotten that paranoid.  I searched briefly, it looks like you do it with a  
combination of settings in /etc/portage/package.keywords and a program  
called flagedit, and I see some scripts you put in your make.conf.

All Linux distros are compiled to be compatible, not optimized for speed  
on a particular CPU.  The -mtune flag compiles for compatibility.  Leaving  
out -mtune and using -march will compile for exactly that CPU  
architecture.  So you'd already be getting a performance boost versus the  
Fedoras and Suses just by using Gentoo with the entry in Safe_Cflags for  
ther opteron.

I've never seen instructions in Gentoo forums, wiki, or handbook on using  
anything except gcc!

People consider compilers to be an academic problem rather than a business  
one.  They're mostly concerned about how to make data structures with  
trees and lattices to build and optimize the instructions.  A graduate  
student spends two semesters making a new algorithm, then it's publish or  
perish.  GCC being open source, you publish an implementation there  
first.  I took an advanced compiler course, and there are LOTS of obscure  
compiler flags to turn on and off different compiler features.  The -O2  
and -O3 flags encompass "safer" sets of these.  man gcc, then search for  
-O2, you'll see the list here.  The ones you see here are "safe", there  
are plenty of "unsafe" ones that pop in to GCC as time passes.  If you  
want a nice non-narcotic trip, search again for one of the options listed  
under -O2, and read what they do :)  Then try finding stuff not listed  
under -O2 or -O3 with really nasty warnings by them or other non-sensical  
language like "not supported in GCC".

I'm willing to bet that once you find out what compiler algorithms  
PathScale uses, you could just turn on those switches in GCC.  It may be  
that GCC doesn't implement one or another feature well, but then you could  
pull the white paper on the algorithm, recode it, and it'll be done.  I  
think PathScale is trying to cyphon some of those big bioinformatics  
bucks.  That money will dry up once they realize the work was already done  
in GCC long before PathScale did it.  That's just a guess, but I think  
that's more likely the situation.

You'd also get a performance boost when your kernel and programs are  
compiled without all the hooks for all the stuff on a desktop, and made  
just for running jobs on a network cluster.  That's more a matter of the  
environment than the compiler itself, but then that wouldn't be the first  
time a piece of company marketing had some "slight" misnomers in it :)

-- 
Alexander


More information about the PLUG-discuss mailing list