View previous topic :: View next topic |
Author |
Message |
DiskDoc Apprentice
Joined: 25 Apr 2002 Posts: 196 Location: Finland
|
Posted: Sat Aug 27, 2005 9:38 pm Post subject: Testing GCC optimization with test.c program |
|
|
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 |
|
|
nbkolchin Apprentice
Joined: 07 Feb 2004 Posts: 290 Location: Russia, Saint-Petersburg
|
Posted: Sat Aug 27, 2005 10:40 pm Post subject: |
|
|
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 |
|
|
|