What are the appropriate architecture-specific options for the Pentium based on Sandy Bridge?

I am trying to figure out how to set the -march parameter -march to see how much the performance difference between the enabled and disabled option can occur on my PC using gcc 4.7.2.

Before trying to compile, I tried to find the best option -march for my PC. My computer has a Pentium G850 whose architecture is Sandy Bridge. So I mentioned the gcc 4.7.2 manual and found that -march=corei7-avx seems to be the best.
However, I recalled that the Sandy Bridge-based Pentium does not support the AVX and AES-NI instruction set support, which is true for the Pentium G850 . Therefore, -march=corei7-avx not a suitable option.

I came up with some possible options:

  • -march=corei7-avx -mno-avx -mno-aes
  • -march=corei7 -mtune=corei7-avx
  • -march=native

The first option looks reasonable, given the information I have, but I'm worried that there may be a feature other than AVX and AES-NI. The second option looks safe, but it may miss some minor features on Sandy Bridge due to -march=corei7 . The third option will take care of all my problems, but I heard that this option sometimes incorrectly evaluates the functions of the processor, so I would like to know how to do it manually.
I googled and searched for StackOverflow and SuperUser, but I cannot find clear solutions ...
What parameters should be set?

+7
source share
3 answers

How about detection through GCC, for me (gcc-5.3.0) on the i5-2450M CPU (Lenovo e520), the following is shown:

 gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 /usr/libexec/gcc/x86_64-pc-linux-gnu/5.3.0/cc1 -E -quiet -v - -march=sandybridge -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -maes -mno-sha -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-vx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=3072 -mtune=sandybridge -fstack-protector-strong 
+6
source

I would suggest using -march=corei7-avx -mtune=corei7-avx -mno-avx -mno-aes . It is important to specify -mtune , because this option tells gcc which processor model it should use to schedule instructions in the generated code.

+2
source

I have an Intel G530 Celeron (R) processor based on Sandy Bridge based on Sandy Bridge.

When using -march=native in gentoo CFLAGS, then compile media-video / ffmpeg-1.2.6 (current stable version in Gentoo), something is wrong when playing videos with mplayer (illegal instruction). In the same way as you said, -mtune=native sometimes incorrectly defines the features of the processor.

Then I go to -march=corei7-avx -mtune=corei7-avx -mno-avx -mno-aes and recompile ffmpeg-1.2.6 and mplayer, now everything is fine.

+1
source

All Articles