View previous topic :: View next topic |
Author |
Message |
MaximeG l33t
Joined: 15 Apr 2008 Posts: 722 Location: Belgium
|
Posted: Wed May 06, 2009 8:47 am Post subject: [Answered] "native" Cflag question |
|
|
Hi,
I was wondering whether the '-march=native' Cflag works well for an Intel Core i7 CPU ?
Regards,
Maxime _________________ Future is wide open.
Last edited by MaximeG on Wed May 06, 2009 12:15 pm; edited 1 time in total |
|
Back to top |
|
|
Veldrin Veteran
Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Wed May 06, 2009 8:58 am Post subject: |
|
|
Without having hands on experience, consider the following.
the -march=native flags looks at the cpu specs and then decide from a table what optimisations should be taken (or are considered useful form the developers point of view). It basically simplifies the selection process for the "best" -march=XXX option.
IIRC gcc-4.3 has no profiles for corei7, thus the best optimisation you will get is (probably) core2.
and you can test it for yourself. (To be honest, I do not remember where the code comes from, but I guess from somewhere in this forum)
Code: | $ echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test |
I basically show what optimisations are used.
Below is a example run on my core2 machine.
Quote: | nicolasc@ifirn ~ $ echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --disable-libgcj --enable-objc-gc --enable-languages=c,c++,objc,obj-c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.1, pie-10.1.5'
Thread model: posix
gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.1, pie-10.1.5)
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/cc1 -v test.c -D_FORTIFY_SOURCE=2 -march=core2 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=core2 -dumpbase test.c -auxbase test -O2 -version -o /tmp/.private/nicolasc/ccYeI2UT.s
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/include-fixed
/usr/include
End of search list.
GNU C (Gentoo 4.3.3-r2 p1.1, pie-10.1.5) version 4.3.3 (x86_64-pc-linux-gnu)
compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.4.1-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
options passed: -v test.c -D_FORTIFY_SOURCE=2 -march=core2 -mcx16 -msahf
--param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=core2 -O2
options enabled: -falign-labels -falign-loops -fargument-alias
-fasynchronous-unwind-tables -fauto-inc-dec -fbranch-count-reg
-fcaller-saves -fcommon -fcprop-registers -fcrossjumping
-fcse-follow-jumps -fdefer-pop -fdelete-null-pointer-checks
-fearly-inlining -feliminate-unused-debug-types -fexpensive-optimizations
-fforward-propagate -ffunction-cse -fgcse -fgcse-lm
-fguess-branch-probability -fident -fif-conversion -fif-conversion2
-finline-functions-called-once -finline-small-functions -fipa-pure-const
-fipa-reference -fivopts -fkeep-static-consts -fleading-underscore
-fmath-errno -fmerge-constants -fmerge-debug-strings
-fmove-loop-invariants -fomit-frame-pointer -foptimize-register-move
-foptimize-sibling-calls -fpeephole -fpeephole2 -freg-struct-return
-fregmove -freorder-blocks -freorder-functions -frerun-cse-after-loop
-fsched-interblock -fsched-spec -fsched-stalled-insns-dep
-fschedule-insns2 -fsigned-zeros -fsplit-ivs-in-unroller
-fsplit-wide-types -fstrict-aliasing -fstrict-overflow -fthread-jumps
-ftoplevel-reorder -ftrapping-math -ftree-ccp -ftree-ch -ftree-copy-prop
-ftree-copyrename -ftree-cselim -ftree-dce -ftree-dominator-opts
-ftree-dse -ftree-fre -ftree-loop-im -ftree-loop-ivcanon
-ftree-loop-optimize -ftree-parallelize-loops= -ftree-pre -ftree-reassoc
-ftree-salias -ftree-scev-cprop -ftree-sink -ftree-sra -ftree-store-ccp
-ftree-ter -ftree-vect-loop-version -ftree-vrp -funit-at-a-time
-funwind-tables -fvar-tracking -fvect-cost-model -fzero-initialized-in-bss
-m128bit-long-double -m64 -m80387 -maccumulate-outgoing-args
-malign-stringops -mcx16 -mfancy-math-387 -mfp-ret-in-387 -mfused-madd
-mglibc -mieee-fp -mmmx -mno-sse4 -mpush-args -mred-zone -msahf -msse
-msse2 -msse3 -mssse3 -mtls-direct-seg-refs
Compiler executable checksum: 83749307ac6549c660cf69756c6cf1e5
main
Analyzing compilation unit
Performing interprocedural optimizations
<visibility> <early_local_cleanups> <inline> <static-var> <pure-const>Assembling functions:
main
Execution times (seconds)
expand : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (33%) wall 6 kB ( 1%) ggc
TOTAL : 0.00 0.00 0.03 1120 kB
Internal checks disabled; compiler is not suited for release.
Configure with --enable-checking=release to enable checks.
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy -o /tmp/.private/nicolasc/ccqwywtW.o /tmp/.private/nicolasc/ccYeI2UT.s
GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtbegin.o-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../.. /tmp/.private/nicolasc/ccqwywtW.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/crtn.o
|
cheers
V. |
|
Back to top |
|
|
MaximeG l33t
Joined: 15 Apr 2008 Posts: 722 Location: Belgium
|
Posted: Wed May 06, 2009 9:04 am Post subject: |
|
|
All right.
I'm currently using 'core2' with sse4, sse4.1, sse4.2.
I'll do the command for both core2 and native, trying to spot the differences
Thanks,
Maxime _________________ Future is wide open. |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Wed May 06, 2009 11:35 am Post subject: |
|
|
For my concern, I use -march=native, because if Gcc release a new Cflags that is valid for my CPU, then I will use it automagically. |
|
Back to top |
|
|
Veldrin Veteran
Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Wed May 06, 2009 11:51 am Post subject: |
|
|
fair enough
@MaximeG:
I completely forgot about the new instrucation sets in Corei7 - thus native could simplify the your config (resp CFLAGS line)
@d2_racing:
true - I sort of start to wonder why I stopped using it. (IIRC native can cause some ugly problems when used in cross-compiling over different archs [i.e core2 and athlon64])
Note to myself: switch to native.
cheers
V. |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Wed May 06, 2009 12:09 pm Post subject: |
|
|
I think that GCC 4.4 will be optimised for CoreI7 or I wish that a release of it will include that CPU.
Right now, I think that -march=native will see a CoreI7 as a Core2 arch. |
|
Back to top |
|
|
MaximeG l33t
Joined: 15 Apr 2008 Posts: 722 Location: Belgium
|
Posted: Wed May 06, 2009 12:11 pm Post subject: |
|
|
Yes, that's what I tought.
However I was wondering if native would behave as if it was Core2, or wouldn't behave at all
Thanks,
Maxime _________________ Future is wide open. |
|
Back to top |
|
|
jmartos Tux's lil' helper
Joined: 23 Mar 2008 Posts: 76
|
Posted: Thu May 07, 2009 10:41 am Post subject: |
|
|
I tried the above code with both "core2" and "native" on my system with dual Xeon E5530's and the only additional parameters that "native" added were the following.
Code: | --param l1-cache-size=32 --param l1-cache-line-size=64 |
|
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Thu May 07, 2009 1:31 pm Post subject: |
|
|
And right now, I have no idea if core2 is faster then native or the opposite. |
|
Back to top |
|
|
hielvc Advocate
Joined: 19 Apr 2002 Posts: 2805 Location: Oceanside, Ca
|
Posted: Sat May 09, 2009 5:49 pm Post subject: |
|
|
If you use "native" or in my case k8-see3 and your running a 32bit system built with march=athlon-xp, does this change whats compiled to 64bits _________________ An A-Z Index of the Linux BASH command line |
|
Back to top |
|
|
Martux Veteran
Joined: 04 Feb 2005 Posts: 1917
|
Posted: Sat May 09, 2009 5:57 pm Post subject: |
|
|
hielvc wrote: | If you use "native" or in my case k8-see3 and your running a 32bit system built with march=athlon-xp, does this change whats compiled to 64bits |
No.
That depends on what' s defined by the chost variable in /etc/make.conf:
CHOST="x86_64-pc-linux-gnu"
for a 64bit system. _________________ "Coincidence is God's way of remaining anonymous."
Albert Einstein
"The road to success is always under construction" |
|
Back to top |
|
|
hielvc Advocate
Joined: 19 Apr 2002 Posts: 2805 Location: Oceanside, Ca
|
Posted: Sun May 10, 2009 5:41 pm Post subject: |
|
|
Thanks that what I thought, but I didnt want to spend the day rebuilding and then reboot into a nightmare
Still it set off one my pet pives. The last thing "emerge system" built was gcc. So if you want save time build gcc first, check gcc-config and select gcc-4.3.3 . now emerge -1 linux-headers glibc binutils. Now do a emerge -e world . Im being a good boy running portage 2.1.16. If you using portage-2.2 then then a --emptyree system and the world will work without recompileing a bunch of stuff. Or third choise would be emerge gcc and do you normal -uDN and after a couple of months most everything rebuilt with "native" _________________ An A-Z Index of the Linux BASH command line |
|
Back to top |
|
|
|