Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
-march=native vs -march=<specific-cpu>
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue May 04, 2021 12:44 pm    Post subject: -march=native vs -march=<specific-cpu> Reply with quote

Which one of the two produces more customized binaries?
Also for compiling gentoo-sources with USE="experimental"
CONFIG_MNATIVE_INTEL vs CONFIG_M<specific-cpu>
Are they identical?
Thanks a lot guys!
_________________
:)
Back to top
View user's profile Send private message
redfish
n00b
n00b


Joined: 27 Apr 2021
Posts: 22

PostPosted: Tue May 04, 2021 1:30 pm    Post subject: Reply with quote

-march=native is the same as -march=<cpufamily>, 'native' is a shortcut for selecting the cpu family of the build host.

Quote:

‘native’

This selects the CPU to generate code for at compilation time by determining the processor type of the compiling machine. Using -march=native enables all instruction subsets supported by the local machine (hence the result might not run on different machines). Using -mtune=native produces code optimized for the local machine under the constraints of the selected instruction set.


https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30916
Location: here

PostPosted: Tue May 04, 2021 1:51 pm    Post subject: Reply with quote

Remeber only if you use distcc you can't use -march=native, see https://wiki.gentoo.org/wiki/Distcc#-march.3Dnative
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Tue May 04, 2021 1:55 pm    Post subject: Reply with quote

alamahant,

Ask gcc.
Code:
gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'


From gcc 11.1.0 I get
Code:
$ gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'
-march=amdfam10 -mmmx -mpopcnt -msse -msse2 -msse3 -msse4a -m3dnow -mabm -mcx16 -mfxsr -msahf -mlzcnt -mprfchw --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10 -dumpbase -
which looks broken due to the trailing '-'

That may not really answer the question as -march=<cpu> may infer everything that -march=native sets explicitly.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue May 04, 2021 2:01 pm    Post subject: Reply with quote

Neddy
That is precisely why I posted.
If I run the above command with -march=native vs -march=hashwell in my case I get
Code:

gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'
-march=haswell -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mfma -mbmi -mbmi2 -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrdrnd -mf16c -mfsgsbase -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=haswell


gcc -### -E - -march=hashwell 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'
-march=nhashwell

-march=native seems more comprehensive.
I do have also
Code:

*/* CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3

still "native" seems more detailed.
_________________
:)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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