I'd like to mess around with some AVX intrinsic functions. I'd like gcc to use AVX exclusively if possible similar to /arch:AVX
in visual studio. Is there a way to do this in gcc with mex?
I tried using something like:
mex -g -O $CFLAGS='$CFLAGS -march=corei7-avx' ncorr_alg_rgdic.cpp standard_datatypes.o ncorr_datatypes.o
But the compiler says eval: 1: = -march=corei7-avx: not found
. Does anyone know which flag I should use and how to get mex to accept it? By default it seems to be using SSE instructions (looking at the assembly output I see some mulsd
s) but I don't want to mix SSE with AVX as I've read here that it can cause problems.
EDIT1:
I'm using ubuntu 11.04 with gcc 4.6.1.
EDIT2:
Compiling with:
mex CXXOPTIMFLAGS='-mtune=corei7-avx -S' ncorr_alg_rgdic.cpp standard_datatypes.o ncorr_datatypes.o
Yields:
movsd -304(%rbp), %xmm1
movsd .LC16(%rip), %xmm0
mulsd %xmm0, %xmm1
Compiling with:
mex CXXOPTIMFLAGS='-mavx -S' ncorr_alg_rgdic.cpp standard_datatypes.o ncorr_datatypes.o
and mex CXXOPTIMFLAGS='-march=corei7-avx -S' ncorr_alg_rgdic.cpp standard_datatypes.o ncorr_datatypes.o
Both yield:
vmovsd -304(%rbp), %xmm1
vmovsd .LC16(%rip), %xmm0
vmulsd %xmm0, %xmm1, %xmm1
Now I'm pretty sure mulsd
is an sse instruction. Is vmulsd
an AVX instruction (strangely googling it didn't yield any results)? I also don't see an ymm
registers being used which is strange.