Mar*_*ing 6 c++ gcc cross-compiling intrinsics
我有生产代码,其中包含为各种SIMD指令集实现的内核,包括AVX,AVX2和AVX512.可以在目标机器上为目标机器编译代码./configure --enable-proc=AVX CXXFLAGS="-mavx".
这也适用于暴露AVX内在函数的Travis CI.我想至少编译AVX2和AVX512版本,以查看是否所有文件都已签入.但似乎编译不同的ISA并不容易.
一个简单的AVX2测试程序:
#include <immintrin.h>
int main(int argc, char **argv) {
__m256d a;
__m256d b;
__m256d c;
_mm256_fnmadd_pd(a, b, c);
}
Run Code Online (Sandbox Code Playgroud)
在我的AVX机器(英特尔酷睿i5-2520M)上,它无法编译:
$ 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)
^~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
有没有办法编译代码?我不关心跑步,我只想要一个烟雾测试.