View previous topic :: View next topic |
Author |
Message |
Thaidog Veteran
Joined: 19 May 2004 Posts: 1053
|
Posted: Sun Dec 13, 2009 9:22 am Post subject: -march=native |
|
|
Just wondering if this is now a fully supported method for compiling? If so is it now the "preferred" way? _________________ Registered Linux User: 437619
"I'm a big believer in technology over politics" - Linus Torvalds |
|
Back to top |
|
|
Ahenobarbi Retired Dev
Joined: 02 Apr 2009 Posts: 345 Location: Warsaw, PL
|
Posted: Sun Dec 13, 2009 11:12 am Post subject: |
|
|
http://en.gentoo-wiki.com/wiki/Safe_Cflags#-march.3Dnative
Quote: | GCC 4.2 introduces a new -march option, -march=native, which automatically detects the features your CPU supports and sets the options appropriately. If you have an Intel or AMD CPU and are using >=sys-devel/gcc-4.2.3, using -march=native is recommended. Do not use -march=native if you use distcc on nodes with different architectures as this may produce unusable code. |
|
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Sun Dec 13, 2009 4:09 pm Post subject: |
|
|
Of course and I use it all the time.
Code: |
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j5 -l5"
|
|
|
Back to top |
|
|
Ahenobarbi Retired Dev
Joined: 02 Apr 2009 Posts: 345 Location: Warsaw, PL
|
Posted: Sun Dec 13, 2009 5:48 pm Post subject: |
|
|
Remeber to check if march enables all flags it sholud.
SlashBeast wrote: |
Code: | slashbeast@ragnarok ~ % gcc -Q -c -v -march=core2 --help=target -mssse3 > core2
slashbeast@ragnarok ~ % grep sse core2
-mno-sse4 [enabled]
-msse [enabled]
-msse2 [enabled]
-msse2avx [disabled]
-msse3 [enabled]
-msse4 [disabled]
-msse4.1 [disabled]
-msse4.2 [disabled]
-msse4a [disabled]
-msse5 [disabled]
-msseregparm [disabled]
-mssse3 [enabled]
slashbeast@ragnarok ~ % gcc -Q -c -v -march=core2 --help=target > core2
slashbeast@ragnarok ~ % grep sse core2
-mno-sse4 [enabled]
-msse [disabled]
-msse2 [disabled]
-msse2avx [disabled]
-msse3 [disabled]
-msse4 [disabled]
-msse4.1 [disabled]
-msse4.2 [disabled]
-msse4a [disabled]
-msse5 [disabled]
-msseregparm [disabled]
-mssse3 [disabled] |
|
|
|
Back to top |
|
|
Mike Hunt Watchman
Joined: 19 Jul 2009 Posts: 5287
|
Posted: Sun Dec 13, 2009 6:36 pm Post subject: |
|
|
Oooh, that's complicated, this is easier: Code: | gcc -### -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1" |
|
|
Back to top |
|
|
Evileye l33t
Joined: 06 Aug 2003 Posts: 782 Location: Toronto
|
Posted: Sun Dec 13, 2009 6:51 pm Post subject: |
|
|
d2_racing wrote: | Of course and I use it all the time.
Code: |
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j5 -l5"
|
|
I know what -j5 is but what is -l5? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21605
|
Posted: Sun Dec 13, 2009 7:14 pm Post subject: |
|
|
Given that $MAKEOPTS is just passed to make, you could answer this by reading the manual.
From info make: Code: | `-l [LOAD]'
`--load-average[=LOAD]'
`--max-load[=LOAD]'
Specifies that no new jobs (commands) should be started if there
are other jobs running and the load average is at least LOAD (a
floating-point number). With no argument, removes a previous load
limit. *Note Parallel Execution: Parallel. |
By using both, make can be restricted to starting fewer than 5 jobs if starting those jobs would increase system load beyond an unacceptable level. |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Mon Dec 14, 2009 2:06 am Post subject: |
|
|
-l5 is for GCC, it tell him to stop after 5 process, it's like a load balancing parameters.
Zac Medico told that on his blog. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21605
|
Posted: Tue Dec 15, 2009 3:33 am Post subject: |
|
|
d2_racing wrote: | -l5 is for GCC, it tell him to stop after 5 process, it's like a load balancing parameters. |
Then how do you link to lib5.a? |
|
Back to top |
|
|
Yamakuzure Advocate
Joined: 21 Jun 2006 Posts: 2284 Location: Adendorf, Germany
|
Posted: Tue Dec 15, 2009 9:54 am Post subject: |
|
|
Ahenobarbi wrote: | Remeber to check if march enables all flags it sholud.
(...) | Or like this: Code: | sed-notebook tmp # gcc -Q -c -v -march=core2 --help=target -mssse3 1> core2 2>/dev/null
sed-notebook tmp # gcc -Q -c -v -march=native --help=target 1> native 2>/dev/null
sed-notebook tmp # diff -y --suppress-common-lines core2 native
-mcx16 [disabled] | -mcx16 [enabled]
-msahf [disabled] | -msahf [enabled]
-msse [enabled] | -msse [disabled]
-msse2 [enabled] | -msse2 [disabled]
-msse3 [enabled] | -msse3 [disabled]
-mssse3 [enabled] | -mssse3 [disabled]
-mtune= | -mtune= core2
sed-notebook tmp #
sed-notebook tmp # gcc -Q -c -v -march=native --help=target -mssse3 1> nativesse 2>/dev/null
sed-notebook tmp # diff -y --suppress-common-lines core2 nativesse
-mcx16 [disabled] | -mcx16 [enabled]
-msahf [disabled] | -msahf [enabled]
-mtune= | -mtune= core2
| left side is with -march=core2, right side is with -march=native, plus optional -mssse3 on second run.
So I daresay that -march=native does not turn on everything the cpu is capable of by itself.
...and now I know that it is completely unneccessary to add -mcx16 and -msahf in make.conf CFLAGS. *pfft* I never expected this! _________________ Important German:- "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
- "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
|
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Tue Dec 15, 2009 12:56 pm Post subject: |
|
|
Hu wrote: | d2_racing wrote: | -l5 is for GCC, it tell him to stop after 5 process, it's like a load balancing parameters. |
Then how do you link to lib5.a? |
I don't have a clue |
|
Back to top |
|
|
bornmw n00b
Joined: 13 Apr 2009 Posts: 46
|
Posted: Sat Oct 23, 2010 3:47 pm Post subject: |
|
|
Yamakuzure wrote: |
So I daresay that -march=native does not turn on everything the cpu is capable of by itself.
|
A little investigation on #gcc showed that -march=native sets everything that you need and the output produced by gcc -Q --help=target gives irrelevant info
(07:19:32 PM) The topic for #gcc is: GNU Compiler Collection User Help. http://gcc.gnu.org/ || Be patient. _very_ patient. || Manual: http://gcc.gnu.org/onlinedocs/gcc/
(07:22:13 PM) bornmw: hi guys, when I set -march=native do I still need to explicitly set stuff like -msse3 -mmmx etc?
(07:23:02 PM) bornmw: I'm very patient
(07:30:34 PM) a-v: bornmw, no
(07:32:24 PM) bornmw: a-v: that's what I thought, but gcc -Q --help=target -march=native says -mssse3 [disabled] but I have it for sure (core i3)
(07:33:36 PM) bornmw: and some people here https://forums.gentoo.org/viewtopic-t-806996-view-next.html?sid=8f8d66d842dbb3df24a48dbd14184222 say that "-march=native does not turn on everything the cpu is capable of by itself"
(07:36:10 PM) Zordan: bornmw: yes that is confusing ... afair when you check the preprocessor output you can see sse3 being enabled even though --help=target says otherwise
(07:36:55 PM) Zordan: e.g. echo | gcc -dM -E - -march=native
(07:37:42 PM) a-v: bornmw, run gcc -c -x c - -o /dev/null -v -march=native </dev/null . You can then see the options passed to cc1. What does -march or -mtune say?
(07:38:00 PM) bornmw: yes, it says __SSSE3__ 1
(07:41:10 PM) bornmw: a-v: -march=core2 -mtune=core2 but nothing about ssse3, but since gcc -dM -E - -march=native says __SSSE3__ 1 I think that everything is ok
(07:41:35 PM) a-v: -march=core2 enables SSSE3, read http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
(07:42:53 PM) bornmw: yes thanks, I just was confused by gcc -Q --help=target -march=native output
(07:44:16 PM) bubu^ left the room (quit: Quit: Leaving, bye bye).
(07:45:37 PM) a-v: thus for your Gentoo CFLAGS "-O2 -march=native -pipe" is sufficient
(07:46:57 PM) bornmw: a-v: that's what I have |
|
Back to top |
|
|
|