无法使用AVX512编译C ++程序?

时间:2017-01-03 03:52:49

标签: g++ avx

编译程序(test.cpp)时,我收到错误:

> 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.hg++版本为4.9.3

如何解决编译问题并使用_mm_rorv_epi32

1 个答案:

答案 0 :(得分:3)

  

_mm_rorv_epi32

根据_mm_rorv_epi32上的Intel page,此内在要求avx512favx512vl。您需要使用-mavx512vl进行编译才能启用它(并且您的gcc 太旧 - -mavx512vladded in gcc-5.1)。