Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
-march=native
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Thaidog
Veteran
Veteran


Joined: 19 May 2004
Posts: 1036
Location: Hilton Head, SC

PostPosted: Sun Dec 13, 2009 9:22 am    Post subject: -march=native Reply with quote

Just wondering if this is now a fully supported method for compiling? If so is it now the "preferred" way?
_________________
www.LinuxDNA.com
http://groups.google.com/group/linuxdna
Registered Linux User: 437619
"I'm a big believer in technology over politics" - Linus Torvalds
Back to top
View user's profile Send private message
Ahenobarbi
Developer
Developer


Joined: 02 Apr 2009
Posts: 345
Location: Warsaw, PL

PostPosted: Sun Dec 13, 2009 11:12 am    Post subject: Reply with quote

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
View user's profile Send private message
d2_racing
Moderator
Moderator


Joined: 25 Apr 2005
Posts: 13046
Location: Ste-Foy,Canada

PostPosted: Sun Dec 13, 2009 4:09 pm    Post subject: Reply with quote

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"

_________________
Sysadmin of GentooQuébec.org
Wiki
Signature
IRC on Freenode : #gentoo-quebec
Back to top
View user's profile Send private message
Ahenobarbi
Developer
Developer


Joined: 02 Apr 2009
Posts: 345
Location: Warsaw, PL

PostPosted: Sun Dec 13, 2009 5:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Sun Dec 13, 2009 6:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
JC99
l33t
l33t


Joined: 06 Aug 2003
Posts: 782
Location: Toronto

PostPosted: Sun Dec 13, 2009 6:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8855

PostPosted: Sun Dec 13, 2009 7:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
d2_racing
Moderator
Moderator


Joined: 25 Apr 2005
Posts: 13046
Location: Ste-Foy,Canada

PostPosted: Mon Dec 14, 2009 2:06 am    Post subject: Reply with quote

-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.
_________________
Sysadmin of GentooQuébec.org
Wiki
Signature
IRC on Freenode : #gentoo-quebec
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8855

PostPosted: Tue Dec 15, 2009 3:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Yamakuzure
Veteran
Veteran


Joined: 21 Jun 2006
Posts: 1347
Location: Bardowick, Germany

PostPosted: Tue Dec 15, 2009 9:54 am    Post subject: Reply with quote

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!
_________________
I *do* know that I easily aggravate people due to my condensed writing. Rule of thumb: If I wrote anything that can be understood in two different ways, and one way offends you, then I meant the other! ;)
Back to top
View user's profile Send private message
d2_racing
Moderator
Moderator


Joined: 25 Apr 2005
Posts: 13046
Location: Ste-Foy,Canada

PostPosted: Tue Dec 15, 2009 12:56 pm    Post subject: Reply with quote

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 :P
_________________
Sysadmin of GentooQuébec.org
Wiki
Signature
IRC on Freenode : #gentoo-quebec
Back to top
View user's profile Send private message
bornmw
n00b
n00b


Joined: 13 Apr 2009
Posts: 43

PostPosted: Sat Oct 23, 2010 3:47 pm    Post subject: Reply with quote

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 http://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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing 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