Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
MMX & EXTMMX flags
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
f4c3m3l70r
n00b
n00b


Joined: 19 Jul 2011
Posts: 47

PostPosted: Sat Feb 23, 2013 12:18 pm    Post subject: MMX & EXTMMX flags Reply with quote

After deep look into safe cflags wiki, gcc tells me that mmx is disabled Intel 3820X CPU.
Some packages in portage still use the "mmx flag", should I disable it or force gcc to use mmx, or disable both?
Few experiments with lame had shown that enabling mmx is a bit slower but Im not sure if this applies to the other packages too.
_________________
i7-4820X | ROG RIVE | 16GB 2400MHz CL10 | SSD 850 Pro | Essence STX | GTX970
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 23, 2013 1:00 pm    Post subject: Reply with quote

f4c3m3l70r,

If your flags line in /proc/cpuinfo does not include mmx then your CPU does not have native support for mmx,
You should disable the mmx USE flag, since specially crafted code sections that take advantage of mmx are less useful to you, if they run at all.

What to do in CFLAGS is more complex. If you use -march=native, gcc may just 'get it right'.
If not, you should disable mmx here too.
Its worth checking what -march=native does, there are lots of one liners for that around.

The above holds true for mmxext too
_________________
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
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sat Feb 23, 2013 3:40 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Its worth checking what -march=native does, there are lots of one liners for that around.

for example:

Code:
# gcc '-###' -e -v -march=native /usr/include/stdlib.h

best ... khay
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Sat Feb 23, 2013 4:24 pm    Post subject: Reply with quote

Code:
echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep /dev/null | egrep -o -- '-+(m|param )\S+')

will print out exactly what -march=native expands to on your machine.
Back to top
View user's profile Send private message
f4c3m3l70r
n00b
n00b


Joined: 19 Jul 2011
Posts: 47

PostPosted: Sat Feb 23, 2013 8:46 pm    Post subject: Reply with quote

Code:
cat /proc/cpuinfo

processor   : 7
vendor_id   : GenuineIntel
cpu family   : 6
model      : 45
model name   : Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz
stepping   : 7
microcode   : 0x70c
cpu MHz      : 3601.000
cache size   : 10240 KB
physical id   : 0
siblings   : 8
core id      : 3
cpu cores   : 4
apicid      : 7
initial apicid   : 7
fpu      : yes
fpu_exception   : yes
cpuid level   : 13
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips   : 7185.61
clflush size   : 64
cache_alignment   : 64
address sizes   : 46 bits physical, 48 bits virtual


Code:
gcc -Q --help=target -march=native
The following options are target specific:
  -m128bit-long-double              [disabled]
  -m32                              [disabled]
  -m3dnow                           [disabled]
  -m3dnowa                          [disabled]
  -m64                              [enabled]
  -m80387                           [enabled]
  -m8bit-idiv                       [disabled]
  -m96bit-long-double               [enabled]
  -mabi=                            sysv
  -mabm                             [disabled]
  -maccumulate-outgoing-args        [disabled]
  -maes                             [enabled]
  -malign-double                    [disabled]
  -malign-functions=                0
  -malign-jumps=                    0
  -malign-loops=                    0
  -malign-stringops                 [enabled]
  -mandroid                         [disabled]
  -march=                           corei7-avx
  -masm=                            att
  -mavx                             [enabled]
  -mavx2                            [disabled]
  -mavx256-split-unaligned-load    [disabled]
  -mavx256-split-unaligned-store    [disabled]
  -mbionic                          [disabled]
  -mbmi                             [disabled]
  -mbmi2                            [disabled]
  -mbranch-cost=                    0
  -mcld                             [disabled]
  -mcmodel=                         32
  -mcpu=                            
  -mcrc32                           [disabled]
  -mcx16                            [enabled]
  -mdispatch-scheduler              [disabled]
  -mf16c                            [disabled]
  -mfancy-math-387                  [enabled]
  -mfentry                          [enabled]
  -mfma                             [disabled]
  -mfma4                            [disabled]
  -mforce-drap                      [disabled]
  -mfp-ret-in-387                   [enabled]
  -mfpmath=                         387
  -mfsgsbase                        [disabled]
  -mfused-madd                      
  -mglibc                           [enabled]
  -mhard-float                      [enabled]
  -mieee-fp                         [enabled]
  -mincoming-stack-boundary=        0
  -minline-all-stringops            [disabled]
  -minline-stringops-dynamically    [disabled]
  -mintel-syntax                    
  -mlarge-data-threshold=           0x10000
  -mlwp                             [disabled]
  -mlzcnt                           [disabled]
  -mmmx                             [disabled]
  -mmovbe                           [disabled]
  -mms-bitfields                    [disabled]
  -mno-align-stringops              [disabled]
  -mno-fancy-math-387               [disabled]
  -mno-push-args                    [disabled]
  -mno-red-zone                     [disabled]
  -mno-sse4                         [disabled]
  -momit-leaf-frame-pointer         [disabled]
  -mpc32                            [disabled]
  -mpc64                            [disabled]
  -mpc80                            [disabled]
  -mpclmul                          [enabled]
  -mpopcnt                          [enabled]
  -mprefer-avx128                   [disabled]
  -mpreferred-stack-boundary=       0
  -mpush-args                       [enabled]
  -mrdrnd                           [disabled]
  -mrecip                           [disabled]
  -mrecip=                          
  -mred-zone                        [enabled]
  -mregparm=                        0
  -mrtd                             [disabled]
  -msahf                            [enabled]
  -msoft-float                      [disabled]
  -msse                             [enabled]
  -msse2                            [enabled]
  -msse2avx                         [disabled]
  -msse3                            [enabled]
  -msse4                            [enabled]
  -msse4.1                          [enabled]
  -msse4.2                          [enabled]
  -msse4a                           [disabled]
  -msse5                            
  -msseregparm                      [disabled]
  -mssse3                           [enabled]
  -mstack-arg-probe                 [disabled]
  -mstackrealign                    [enabled]
  -mstringop-strategy=              [default]
  -mtbm                             [disabled]
  -mtls-dialect=                    gnu
  -mtls-direct-seg-refs             [enabled]
  -mtune=                           corei7-avx
  -muclibc                          [disabled]
  -mveclibabi=                      [default]
  -mvect8-ret-in-mem                [disabled]
  -mvzeroupper                      [disabled]
  -mx32                             [disabled]
  -mxop                             [disabled]



Code:
#echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep /dev/null | egrep -o -- '-+(m|param )\S+')

-march=corei7-avx -mcx16 -msahf -mno-movbe -maes -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-rdrnd -mno-f16c -mno-fsgsbase --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=10240 -mtune=corei7-avx


Code:
gcc '-###' -e -v -march=native /usr/include/stdlib.h

COLLECT_GCC_OPTIONS='-e' '-v' '-march=native'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/cc1 -quiet /usr/include/stdlib.h "-march=corei7-avx" -mcx16 -msahf -mno-movbe -maes -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-rdrnd -mno-f16c -mno-fsgsbase --param "l1-cache-size=32" --param "l1-cache-line-size=64" --param "l2-cache-size=10240" "-mtune=corei7-avx" -quiet -dumpbase stdlib.h -auxbase stdlib -o /tmp/.private/f4c3m3l70r/ccW1Fcel.s "--output-pch=/usr/include/stdlib.h.gch"


So from my understanding, MMX is supported by CPU but not used during compiling and USE flags can be removed.
_________________
i7-4820X | ROG RIVE | 16GB 2400MHz CL10 | SSD 850 Pro | Essence STX | GTX970
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 23, 2013 9:04 pm    Post subject: Reply with quote

f4c3m3l70r,

As you say, mmx is supported on yur I7 CPU, but gcc will not generate code that uses it.

However the USE=mmx flag has a different purpose.
Some packages have special optional sections that are written to use mmx. Usually multimedia packages.
USE=mmx builds these optional sections. They are often hand crafted assembler routines, so gcc won't know the mxx instructions are present.

Leave the mmx in your USE flags but you do not have mmxext so that should be removed, if its present.
_________________
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
f4c3m3l70r
n00b
n00b


Joined: 19 Jul 2011
Posts: 47

PostPosted: Sat Feb 23, 2013 10:08 pm    Post subject: Reply with quote

Thanks for enlightening me again guys!
So theoretically I can use "-mmmx" per package just for testing but I have a feeling that mmx was disabled for a good reason.
_________________
i7-4820X | ROG RIVE | 16GB 2400MHz CL10 | SSD 850 Pro | Essence STX | GTX970
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 23, 2013 10:37 pm    Post subject: Reply with quote

f4c3m3l70r,

I suspect that the other SIMD instruction sets you have are more efficient, so mmx is not used, by gcc anyway.

if you set CFLAGS=-mmmx, that tells gcc that it is permitted to use it, it is not compelled to use it, so it may make no difference anyway.
_________________
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
f4c3m3l70r
n00b
n00b


Joined: 19 Jul 2011
Posts: 47

PostPosted: Sat Feb 23, 2013 10:54 pm    Post subject: Reply with quote

Indeed, converting full dvd took 3 minutes longer than usual when using mmx with ffmpeg.
_________________
i7-4820X | ROG RIVE | 16GB 2400MHz CL10 | SSD 850 Pro | Essence STX | GTX970
Back to top
View user's profile Send private message
megabaks
Apprentice
Apprentice


Joined: 22 Jan 2012
Posts: 253
Location: Russia && Saint-Petersburg

PostPosted: Sun Feb 24, 2013 7:58 am    Post subject: Reply with quote

Quote:
gcc -Q --help=target -march=native
no way!:
-mmmx disabled ----> lie: mmx enabled by any *sse*
man gcc
Code:
[ megabaks@desktop ] ~ $ LANG=en gcc -Q --help=target -march=native | grep mmx
  -mmmx                             [disabled]
[ megabaks@desktop ] ~ $ echo "int main() { return 0; }" |LANG=en gcc -march=native -v -Q -x c - 2>&1 | cut -d":" -f1 | grep "^ -"| tr " " "\n" | grep mmx
-mmmx
[ megabaks@desktop ] ~ $
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Tue Feb 26, 2013 12:46 pm    Post subject: Reply with quote

I have AMD E-450 and it's supported by GCC 4.6 as -march='btver1' and -mtune="btver1" but native produce:
Code:
gopher tmp # echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep /dev/null | egrep -o -- '-+(m|param )\S+')
-march=btver1 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -mno-sse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=btver1

So maybe I should copy-paste it to my make.conf instead current settings:
Code:
CFLAGS="-march=btver1 -mtune=btver1"
CXXFLAGS="${CFLAGS}"

What you think?
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Tue Feb 26, 2013 1:01 pm    Post subject: Reply with quote

so generally -march=native is preferred, yes? from http://wiki.gentoo.org/wiki/CFLAGS
Quote:
To see what -march=native or -mtune=native enables for your specific CPU, run gcc -march=native -E -v - </dev/null 2>&1 | grep cc1. Simply using this whole output instead of -march=native is not recommended, but cache parameters can be used safely.

That's a pitty I re-emerge almost whole world after upgrade to gcc-4.6.3 and set -march=btver1, so I will set natvie right now and and use it for new and upgraded packages.
Back to top
View user's profile Send private message
megabaks
Apprentice
Apprentice


Joined: 22 Jan 2012
Posts: 253
Location: Russia && Saint-Petersburg

PostPosted: Tue Feb 26, 2013 1:12 pm    Post subject: Reply with quote

emc wrote:
I have AMD E-450 and it's supported by GCC 4.6 as -march='btver1' and -mtune="btver1" but native produce:
Code:
gopher tmp # echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep /dev/null | egrep -o -- '-+(m|param )\S+')
-march=btver1 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -mno-sse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=btver1

So maybe I should copy-paste it to my make.conf instead current settings:
Code:
CFLAGS="-march=btver1 -mtune=btver1"
CXXFLAGS="${CFLAGS}"

What you think?
-O2 -march=btver1
mtune == march by default
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Tue Feb 26, 2013 1:30 pm    Post subject: Reply with quote

Yes for got for optimization so finally I setup:
Code:
CFLAGS="-march=btver1 -O2 -mtune=btver1 -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

I just want to know if maybe setting to -march=native use more CPU features than btver1 in my case
Back to top
View user's profile Send private message
megabaks
Apprentice
Apprentice


Joined: 22 Jan 2012
Posts: 253
Location: Russia && Saint-Petersburg

PostPosted: Tue Feb 26, 2013 2:09 pm    Post subject: Reply with quote

again: you DONT need mtune!
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Thu Feb 28, 2013 11:16 am    Post subject: Reply with quote

megabaks wrote:
again: you DONT need mtune!

Yes, I know copy-paste bug.
I how quick question if I got:
Code:
gopher ~ # echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep /dev/null | egrep -o -- '-+(m|param )\S+')
-march=btver1 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -mno-sse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=btver1

better use in my make.conf:
Code:
CFLAGS="-march=btver1 -O2 -fomit-frame-pointer -pipe -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -mno-sse4.1"

or:
Code:
CFLAGS="-march=native -O2 -fomit-frame-pointer -pipe"

Or both are exactly the same?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Thu Feb 28, 2013 4:43 pm    Post subject: Reply with quote

emc,

They are nominally identical. However, if you use distcc, you need to use the expanded form of CFLAGS, or you will get code built on helper systems for the helpers native CPU.
Thats something you probably won't like.

If you don't use distcc, you will be called a Ricer if you use the expanded form :)
_________________
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
f4c3m3l70r
n00b
n00b


Joined: 19 Jul 2011
Posts: 47

PostPosted: Thu Feb 28, 2013 5:56 pm    Post subject: Reply with quote

After all the confusion I decided to add "-v" to my CFLAGS.
Now I can see in "the expanded form" which flags are being used during compilation.
Interesting part is: mmx isnt listed but always enabled with SSE.
I think the info output of gcc should be fixed properly.
_________________
i7-4820X | ROG RIVE | 16GB 2400MHz CL10 | SSD 850 Pro | Essence STX | GTX970
Back to top
View user's profile Send private message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Fri Mar 01, 2013 3:22 am    Post subject: Reply with quote

NeddySeagoon wrote:
emc,

They are nominally identical. However, if you use distcc, you need to use the expanded form of CFLAGS, or you will get code built on helper systems for the helpers native CPU.
Thats something you probably won't like.

I will keep.... native
Quote:

If you don't use distcc, you will be called a Ricer if you use the expanded form :)

... because of this ! :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things 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