I have production code that has kernels implemented 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"
.
This also works well on Travis CI which exposes AVX intrinsics. I would like to at least compile the AVX2 and AVX512 versions in order to see whether all files are checked in. But it seems that compiling for a different ISA is not that easy.
A simple AVX2 test program:
#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 some way to compile the code? I do not care about running, I just want a smoke-test.
Supplying -march=sandybridge
, -march=haswell
or -march=knl
enables all the needed features to translate the code.