Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Testing your CFLAGS
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
thebigslide
l33t
l33t


Joined: 23 Dec 2004
Posts: 790
Location: under a car or on top of a keyboard

PostPosted: Wed Mar 02, 2005 3:27 am    Post subject: Reply with quote

mencoder, I compiled by hand because of how ebuild wonks the CFLAGS:

CFLAGS="-march=athlon-xp -O2 -s -w -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -ftracer -mfpmath=sse"
time mencoder -nosound -ovc libdv randomporno.mpg -o /incoming/randomporno.dv
real 1m17.181s
user 1m12.578s (+/-.011) over 10 results
sys 0m1.545s

CFLAGS="-march=pentium -O2 -s -w -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -ftracer -mfpmath=387"
time mencoder -nosound -ovc libdv randomporno.mpg -o /incoming/randomporno.dv
real 1m33.064s
user 1m27.494s (+/-.022) over 10 results
sys 0m1.730s

for an improvement with SSE, MMX, 3Dnow and 3Dnow+ of 20.5%

Now to see if 3dnow or 3dnow+ did anything
CFLAGS="-mtune=athlon-xp -O2 -s -w -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -ftracer -mfpmath=sse -march=pentium3"
time mencoder -nosound -ovc libdv randomporno.mpg -o /incoming/randomporno.dv
real 1m19.201s
user 1m14.099s (+/-.019) over 10 results
sys 0m1.677s

3Dnow and 3Dnow+ ARE being used and they're worth about 2% in this benchmark

Finally, a test to see if O2 is of benefit over O1
CFLAGS="-march=athlon-xp -O1 -s -w -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -ftracer -mfpmath=sse"
time mencoder -nosound -ovc libdv randomporno.mpg -o /incoming/randomporno.dv
real 1m19.287s
user 1m13.990s (+/-.006) over 10 results
sys 0m1.596s

This is kinda dumb, but let's see what O3 does for us
CFLAGS="-march=athlon-xp -O1 -s -w -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -ftracer -mfpmath=sse"
time mencoder -nosound -ovc libdv randomporno.mpg -o /incoming/randomporno.dv
real 1m19.786s
user 1m13.788s (+/-.012) over 10 results
sys 0m1.649s

****Notice that O3 made it SLOWER than O2
Back to top
View user's profile Send private message
nerdbert
l33t
l33t


Joined: 09 Feb 2003
Posts: 981
Location: Berlin

PostPosted: Wed Mar 02, 2005 10:54 am    Post subject: Re: Testing your CFLAGS Reply with quote

_never_ wrote:
  • -ftracer (doesn't seem to do anything; it's a rather new flag - don't use it)


-ftracer was introduced in 3.4. It's not optimizing code itself, but it is looking at different "paths" of codes seperately, which can help to find more optimizations. If you have a condition called a which either leads to code b or c, which both lead to d, it looks at a-b-d and a-c-d seperately before compilation, thus giving the compiler more hints what could be optimized.
(don't flame me if the terms I use aren't accurate - I'm not really into compilers)

I just read an article comparing various compiler flags for gcc 2.95, 3.2.3, 3.4.3, 3.5 and 4.0 (snapshot from January). They compiled SPECint2000 and SPECfp2000 for several CPUs (including 64 bit). For most of the benchmarks -ftracer provided a minimal speedup, but some actually ran slower.
_________________
I'm really wondering what Lovechild is doing nowadays...
Back to top
View user's profile Send private message
_never_
Apprentice
Apprentice


Joined: 10 Jun 2004
Posts: 285
Location: BW, Germany

PostPosted: Wed Mar 02, 2005 12:32 pm    Post subject: Re: Testing your CFLAGS Reply with quote

nerdbert wrote:
_never_ wrote:
  • -ftracer (doesn't seem to do anything; it's a rather new flag - don't use it)


-ftracer was introduced in 3.4. It's not optimizing code itself, but it is looking at different "paths" of codes seperately, which can help to find more optimizations. If you have a condition called a which either leads to code b or c, which both lead to d, it looks at a-b-d and a-c-d seperately before compilation, thus giving the compiler more hints what could be optimized.
(don't flame me if the terms I use aren't accurate - I'm not really into compilers)


Not because of inaccurate terms, but because of wrong version information. The -ftracer option is already present in GCC 3.3, which I do own. I have had bad experiences with it. It makes code slower sometimes. And what's even worse, some programs crash when compiled with this flag.
_________________
Knowledge is Power.
Back to top
View user's profile Send private message
koder
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jan 2005
Posts: 83
Location: Belgium

PostPosted: Tue May 10, 2005 1:24 pm    Post subject: Reply with quote

I have seen a significant boost by using -O3 instead of -O2 and -O1 on my system. I am using an Intel Pentium4 2.4b (that's the one on a FSB533 and without HT on socket 478).

I was writing a small tool to calculate something for my dad, it used a lot of nested loops. Compiling with -march=pentium4 -O3 increased the speed by up to 60% for this application. But once again, this is no real-world situation.

For that, I refer to my system. I compiled a Gentoo 2004.3 from stage 1 and optimized from the beginning. And I can tell you that having an optimized gcc really does make a difference! glibc, kernel,... if all runs at full speed, you get a faster system.

And yes, it may increase filesize, but my entire system still fits in 3 GB, and that includes every single thing I use or may need soon!! That may have been pretty large (back in the days where we had harddisks of less that 100 MB), but on an average system with a harddrive of 200 GB and a RAM of 768 MB... it's not really that much of a problem.


I would like to add one strange thing however:

I recently migrated to lk 2.6, and I emerged glibc (to go with the NPTL feature), and strage enough, the compilation doesn't seem to use $CFLAGS as defined in /etc/make.conf! That surpised me...



greetz
koder
_________________
game not over - www.mame.be
Back to top
View user's profile Send private message
thebigslide
l33t
l33t


Joined: 23 Dec 2004
Posts: 790
Location: under a car or on top of a keyboard

PostPosted: Tue May 10, 2005 8:37 pm    Post subject: Reply with quote

Some packages filter flags which are known to cause issues. If you would like to live on the edge, you can make a copy of the particular ebuild in a portage overlay and modify to your hearts content. It will probably break, though.
Back to top
View user's profile Send private message
kimchi_sg
Advocate
Advocate


Joined: 26 Nov 2004
Posts: 2915
Location: Singapore

PostPosted: Tue May 10, 2005 8:48 pm    Post subject: Reply with quote

koder wrote:

I recently migrated to lk 2.6, and I emerged glibc (to go with the NPTL feature), and strage enough, the compilation doesn't seem to use $CFLAGS as defined in /etc/make.conf! That surpised me...

That's because glibc is one of the packages which have
Code:
strip-flags
in the ebuild.

This will pare down your CFLAGS to nothing more than -march, -O2 -fomit-frame-pointer and -pipe.

Remove that line from the ebuild at your own peril.
_________________
Murphy's Law of Gentoo installation: If a compile can fail, it will.

MacGillicuddy's Corollary: At the most inopportune time.

Please search and read the FAQs before posting.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum