View previous topic :: View next topic |
Author |
Message |
tomee n00b
Joined: 05 Sep 2006 Posts: 38 Location: Poland
|
Posted: Thu Oct 19, 2006 11:49 pm Post subject: Best compilation flags (CFLAGS, LDFLAGS) |
|
|
Hi,
I think this is a crucial issue for any Gentoo fan - how to tweak the CFLAGS and LDFLAGS for the programs to run faster?
This is such a basic question but I found contradictory reports concerning the use of -Ox, in particular some recommend -O2, some -O3 and some -Os. I have never gotten myself to do a real benchmark of the difference, maybe one of you have?
As far as my system goes, I am using CFLAGS="-march=pentium-m -Os -mfpmath=sse -fomit-frame-pointer -pipe -ffast-math"
(apart from python and openoffice, where -ffast-math breaks things) and am wondering if this is the optimal flag set for my processor.
For the LDFLAGS I use "-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=both" and prelinking, but I can't say that the result is spectacular. Maybe I am missing something?
I was also wondering which packages it is possible to compile with Intel C/C++ Compiler, as this one seems to give a ~20% boost in typical algorithm run time. bzip2/gzip and perl might be a good starting point, I guess it's impossible to compile KDE or OpenOffice that way. Has anyone tried ICC with any bigger packages? Yes, I have read the wiki. |
|
Back to top |
|
|
jmbsvicetto Moderator
Joined: 27 Apr 2005 Posts: 4734 Location: Angra do Heroísmo (PT)
|
Posted: Fri Oct 20, 2006 3:42 am Post subject: |
|
|
Moved from Documentation, Tips & Tricks to Portage & Programming.
[mod]As you're asking some support questions, I've moved this thread to P&P.[/mod] _________________ Jorge.
Your twisted, but hopefully friendly daemon.
AMD64 / x86 / Sparc Gentoo
Help answer || emwrap.sh
|
|
Back to top |
|
|
synss Apprentice
Joined: 08 Mar 2006 Posts: 282 Location: Dijon > Berlin > Tokyo > Nürnberg > München
|
Posted: Fri Oct 20, 2006 12:50 pm Post subject: |
|
|
Briefly, I believe all pentium-m have a large cache (mine has 2MB L2 cache) so -Os is useless and -O2 is better. For the rest, "-pipe -fomit-frame-pointer" is enough.
leaving Code: | CFLAGS="-march=pentium-m -O2 -pipe -fomit-frame-pointer" |
Rice in a chroot if you want to and benchmark, results obviously vary from computer to computer. _________________ Compress portage tree
Elog viewer
Autodetect swap |
|
Back to top |
|
|
RoundsToZero Guru
Joined: 17 Nov 2003 Posts: 478 Location: New York, NY
|
Posted: Wed Oct 25, 2006 8:52 pm Post subject: |
|
|
Could someone speak on the performance/stability issues with -mfpmath=sse? On the one hand, the gcc manpage doesn't describe it as an "experimental" feature, but on the other hand, it's not automatically enabled with -march=pentium3 and higher, or with -mssex, which seem like the only things it depends on.
Edit: That looked less like "sex" when I typed it originally.
Last edited by RoundsToZero on Wed Oct 25, 2006 9:15 pm; edited 1 time in total |
|
Back to top |
|
|
yngwin Retired Dev
Joined: 19 Dec 2002 Posts: 4572 Location: Suzhou, China
|
Posted: Wed Oct 25, 2006 8:54 pm Post subject: |
|
|
You should not set the -mfpmath option. It's best to let the compiler figure it out by itself. _________________ "Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF |
|
Back to top |
|
|
bubbl07 Apprentice
Joined: 06 Feb 2005 Posts: 237 Location: New York City
|
Posted: Thu Oct 26, 2006 3:54 am Post subject: |
|
|
-fomit-frame-pointer is redundant (at least in GCC 4) when using the -O* flags. Code: | -fomit-frame-pointer
Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. It also makes debugging impossible on some machines.
On some machines, such as the VAX, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag. See Register Usage.
Enabled at levels -O, -O2, -O3, -Os. |
(http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Optimize-Options.html#Optimize-Options) |
|
Back to top |
|
|
Dlareh Advocate
Joined: 06 Aug 2005 Posts: 2102
|
Posted: Thu Oct 26, 2006 4:00 am Post subject: |
|
|
-fomit-frame-pointer does not appear to have changed from previous versions of gcc.
it's always had an effect on x86 beyond the -O's, because it breaks debugging _________________ "Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet? |
|
Back to top |
|
|
yngwin Retired Dev
Joined: 19 Dec 2002 Posts: 4572 Location: Suzhou, China
|
Posted: Thu Oct 26, 2006 12:24 pm Post subject: |
|
|
Quote: | -O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging. | from the same link.
On x86 it interferes with debugging, so it is not included in any -Ox flag. On amd64 it is included. _________________ "Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF |
|
Back to top |
|
|
geekounet Bodhisattva
Joined: 11 Oct 2004 Posts: 3772 Location: Wellington, Aotearoa
|
Posted: Thu Oct 26, 2006 12:33 pm Post subject: |
|
|
RoundsToZero wrote: | Could someone speak on the performance/stability issues with -mfpmath=sse? On the one hand, the gcc manpage doesn't describe it as an "experimental" feature, but on the other hand, it's not automatically enabled with -march=pentium3 and higher, or with -mssex, which seem like the only things it depends on.
Edit: That looked less like "sex" when I typed it originally. |
Never had a problem with -mfpmath=sse,387, both on a pentium3 and a pentium-m computer. |
|
Back to top |
|
|
tboloo Guru
Joined: 20 Jan 2006 Posts: 403 Location: Grodzisq, Poland
|
Posted: Thu Oct 26, 2006 6:46 pm Post subject: |
|
|
After some time of playing with C/LDFLAGS you'll try some Ubuntu or other distro and you'll that it's only maybe 10percent slower and hell more stable. I used to experience a lot with various flags and ended with -O2 -march=pentium-m -pipe which is quite sufficient and what's more everything comiles flawlessly. _________________ The clock is ticking, brothers and sisters, counting down to Armageddon. |
|
Back to top |
|
|
stahlsau Guru
Joined: 09 Jan 2004 Posts: 584 Location: WildWestwoods
|
Posted: Sun Nov 05, 2006 9:05 am Post subject: |
|
|
Quote: | After some time of playing with C/LDFLAGS you'll try some Ubuntu or other distro and you'll that it's only maybe 10percent slower and hell more stable. I used to experience a lot with various flags and ended with -O2 -march=pentium-m -pipe which is quite sufficient and what's more everything comiles flawlessly. |
ACK, except for the other distribution. Screw it, you can change every damn cflag out there and you wouldn't even notice the difference. Leaving alone measure it. |
|
Back to top |
|
|
|