View previous topic :: View next topic |
Author |
Message |
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Tue May 04, 2021 12:44 pm Post subject: -march=native vs -march=<specific-cpu> |
|
|
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 |
|
|
redfish n00b
Joined: 27 Apr 2021 Posts: 22
|
Posted: Tue May 04, 2021 1:30 pm Post subject: |
|
|
-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 |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30916 Location: here
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Tue May 04, 2021 1:55 pm Post subject: |
|
|
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 |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Tue May 04, 2021 2:01 pm Post subject: |
|
|
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 |
|
|
|