Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Testing GCC optimization with test.c program
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
DiskDoc
Apprentice
Apprentice


Joined: 25 Apr 2002
Posts: 196
Location: Finland

PostPosted: Sat Aug 27, 2005 9:38 pm    Post subject: Testing GCC optimization with test.c program Reply with quote

From what I've gathered, using -O3 on a CPU with only 64KiB cache generally results in slower binaries due to larger code (loops?) not fitting into the cache. People seem to feel -O2 is more suitable for the K6-2 which is what I'm playing around with here.

I found this little test:

http://www.network-theory.co.uk/docs/gccintro/gccintro_50.html

Testing -O2 and -O3 parameters on my K6-2@380 yields:

Code:
localhost ~ # gcc -Wall -lm -march=k6-2 -O2 test.c
localhost ~ # time ./a.out
sum = 4e+38

real    0m14.727s
user    0m14.649s
sys     0m0.036s

localhost ~ # gcc -Wall -lm -march=k6-2 -O3 test.c
localhost ~ # time ./a.out
sum = 4e+38

real    0m6.713s
user    0m6.688s
sys     0m0.013s


What do you think about this? Is the difference only due to the code fitting into the cache where -O3 still usually produces too large binaries?
_________________
"So slay me now! I have little magic left."
- Kallak, leader of the royal mystics
Back to top
View user's profile Send private message
nbkolchin
Apprentice
Apprentice


Joined: 07 Feb 2004
Posts: 290
Location: Russia, Saint-Petersburg

PostPosted: Sat Aug 27, 2005 10:40 pm    Post subject: Reply with quote

function inline, (possible) better register allocation: this are two main reasons. Larger code is nothing, 5% of application usually take 95% of cpu time.

Read GCC info on "optimize options".
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
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