Re: altering a makefile


Subject: Re: altering a makefile
From: Charles Lepple (charles@ghz.cc)
Date: Sat May 19 2001 - 13:33:21 MDT


--On Friday, May 18, 2001 05:28:42 PM -0700 Murias O'Ceallagh
<linux@dragonsblood.net> wrote:

> CC=gcc -c -m486 -O3 -finline-functions -fomit-frame-pointer -funroll-loops
> # This option is available for gcc-2.8.x
> #CC=gcc -c -mcpu=pentiumpro -malign-double -O6 -fstrength-reduce
> -fexpensive-optimizations -finline-functions -fomit-frame-p
> ointer -funroll-loops
> # This option is available for gcc-2.95.1, gcc-2.95.2, gcc-2.95.3,... on
> P6 or later
> #CC=gcc -c -mcpu=pentiumpro -march=pentiumpro -O9 -fstrength-reduce
> -fexpensive-optimizations -finline-functions -fomit-frame
> -pointer -funroll-loops -ffast-math -foptimize-register-move -fdefer-pop
> -mfancy-math-387
> CFLAGS=-Wall $(PROF) -DNDEBUG $(E3DN) $(VBR) -DRAW_INPUT

From the looks of the CFLAGS line, I'm guessing that the author of this
code just played around with the optimizations until the code ran as fast
as they wanted.

Don't let the -f... options confuse you -- a lot of those are activated
anyway once the optimization level (x in the '-Ox' option) is greater than
a given threshold.

One good way to get a starting point for optimization options is to look at
some PPC-specific code in the kernel (RAID comes to mind as a good
candidate, though I haven't looked recently). The thing is that you don't
want to just throw in all of the available PPC optimization flags because
there may be interactions between them (especially for very recent gcc
snapshots).

> From reading the man for gcc ( I am using 2.95.2) I was thinking about
> uncommenting the last CC, then of course commenting out the first one,
> replacing '-mcpu=pentiumpro' with -mcpu=ppc and deleting the
> -march=pentiumpro.

'-mcpu=ppc' is probably too general a choice for something
performance-critical. If you're just trying to get this to run as fast as
possible on your box, you can use your CPU type (the three-digit one, e.g.
603e, 740, 750 -- cat /proc/cpuinfo for yours). Otherwise, you can hint the
target processor type by using '-mtune=750' or whatever. See the gcc info
page for details (Invoking GCC -> Submodel options -> RS/6000 and PowerPC
Options).

To get this to compile for the first time (and to give you a baseline for
performance), you can just leave out the CC= def'n and you will get the
default options (probably gcc -c).

Depending on what this code is (and how much you want to dive into
optimization) you may also want to look at profiling support (info gprof).

-- 
Charles Lepple <charles@ghz.cc>
http://ghz.cc/charles/



This archive was generated by hypermail 2a24 : Sat May 19 2001 - 12:37:56 MDT