Compile C ++ code with built-in AVX2 / AVX512 to AVX

I have production code that implements kernels for various SIMD instruction sets, including AVX, AVX2, and AVX512. The code can be compiled on the target machine for the target machine with something like ./configure --enable-proc=AVX CXXFLAGS="-mavx".

It also works well on Travis CI, which provides AVX capabilities. I would like to at least compile the versions of AVX2 and AVX512 to make sure all files are checked. But it seems that compiling for another ISA is not so simple.

Simple test program AVX2:

#include <immintrin.h>

int main(int argc, char **argv) {
    __m256d a;
    __m256d b;
    __m256d c;

    _mm256_fnmadd_pd(a, b, c);
}

On my AVX machine (Intel Core i5-2520M) it does not compile:

$ g++ -Wall -Wpedantic --std=c++11 cpp.cpp -mavx2
In file included from /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include/immintrin.h:79:0,
                 from cpp.cpp:3:
/usr/lib/gcc/x86_64-redhat-linux/6.3.1/include/fmaintrin.h:143:1: error: inlining failed in call to always_inline '__m256d _mm256_fnmadd_pd(__m256d, __m256d, __m256d)': target specific option mismatch
 _mm256_fnmadd_pd (__m256d __A, __m256d __B, __m256d __C)
 ^~~~~~~~~~~~~~~~

Is there a way to compile the code? I don't care about starting, I just want to pass the smoke test.

+4
1

-march=sandybridge, -march=haswell -march=knl .

0

Source: https://habr.com/ru/post/1675617/


All Articles