To compile for a target with AVX2, use -mavx2
.
Compiling AVX2 program on Mavericks
Frage
I try to compile a dummy AVX2 program on my Mac OS 10.9 with gcc version 4.9.0 20131201
//dummy program
#include <immintrin.h> // AVX2
#include <stdio.h>
int main(int argc, char* argv[]) {
__m256i reg = _mm256_set1_epi8(1);
__m256i result = _mm256_max_epu8(reg,reg);
printf("%d",((int *)&result)[0]);
}
I used this command to compile
gcc -mavx -O0 test.C
and I get this error
In function 'int main(int, char**)':
avx2intrin.h:373:1:
error: inlining failed in call to always_inline
'__m256i _mm256_max_epu8(__m256i, __m256i)': target specific option mismatch
_mm256_max_epu8 (__m256i __A, __m256i __B)
The _mm256_max_epu8 uses an always_inline attribute. Is this the problem?
I also get the problem if I compile with O3.
What am I doing wrong?
Lösung
Andere Tipps
I can compile the program with
g++ -mavx2 -Wa,-q test.C
In this thread is discussed why -Wa,q is also needed
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow