Cannot compile a C++ program using AVX512?

2.8k Views Asked by At

I got an error below when a program (test.cpp) is compiled:

> 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);
                                          ^

The program (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;
}

I did include the header file immintrin.h according to the Intel manual. The g++ version is 4.9.3.

How can I solve the compiling problem and use _mm_rorv_epi32?

1

There are 1 best solutions below

0
On BEST ANSWER

_mm_rorv_epi32

According to Intel page on _mm_rorv_epi32, this intrinsic requires avx512f and avx512vl. You need to compile with -mavx512vl to enable it (and your gcc is too old -- -mavx512vl was added in gcc-5.1).