1
我得到時的程序(TEST.CPP)被編譯下面的錯誤:無法使用AVX512編譯C++程序?
> g++ -o test test.cpp -O2 -mavx -msse4.1
test.cpp: In function ‘int main(int, char**)’:
test.cpp:18:42: error: ‘_mm_rorv_epi32’ was not declared in this scope
indice = _mm_rorv_epi32(indice, offset4);
^
程序(main.cpp中):
#include <stdio.h>
#include <stdlib.h>
#include <immintrin.h>
int main(int argc, char* argv[]) {
float values[4] = {1., 2., 3., 4.};
__m128i offset4 = _mm_set_epi32(0, 2, 4, 6);
__m128i mask4 = _mm_set_epi32(3, 3, 3, 3);
__m128 value4 = _mm_load_ps(&values[0]);
__m128 res;
float result[4];
// load a constant integer 4 times
__m128i indice = _mm_set1_epi32(123); // 123 is a fake example
// shift
indice = _mm_rorv_epi32(indice, offset4);
// and
indice = _mm_and_si128(indice, mask4);
// lookup
res = _mm_permutevar_ps(value4, indice);
// store
_mm_store_ps(result, res);
for (int i = 0; i < 4; i++) {
printf("result[%d] = %g\n", i, result[i]);
}
return 0;
}
我幷包括根據頭文件immintrin.h
英特爾手冊。 g++
版本是4.9.3
。
如何解決編譯問題並使用_mm_rorv_epi32
?