0

I imported the immintrin.h header file in my C++ project and tried to use the _mm256_cos_pd function, but encountered the error "Use of undeclared identifier '_mm256_cos_pd'".

According to Intel's documentation(https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-8/mm-cos-pd-mm256-cos-pd.html), the _mm256_cos_pd function is a function that calculates the cosine of a 256-bit floating-point (double-precision) vector. It is part of the Intel AVX extended instruction set.

I can successfully use other commands (such as _mm256_add_pd and _mm256_mul_pd) but not _mm256_cos_pd.

I did the following tests:

  1. The compiler used is gcc (13.1), which supports the AVX2 instruction set.

  2. the compiler's build options enable the AVX2 instruction set. I used set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") in the CMakeLists.txt file to enable the AVX2 instruction set.

  3. Make sure the CPU supports the AVX2 instruction set.

Oran
  • 1
  • I have some doubts that `_mm256_cos_pd` is located in the header `immintrin.h`. There are several header with SSE instructions, each contains a different set of functions. – ALX23z Aug 14 '23 at 11:18
  • duplicates: [Where is Clang's `_mm256_pow_ps` intrinsic?](https://stackoverflow.com/q/36636159/995714), [AVX log intrinsics `_mm256_log_ps` missing in g++-4.8?](https://stackoverflow.com/q/18747768/995714), [`_mm512_exp_pd` with GNU compiler](https://stackoverflow.com/q/50467355/995714), [VC2012 where to find _mm256_pow_pd?](https://stackoverflow.com/q/32204876/995714) – phuclv Aug 14 '23 at 11:30

1 Answers1

0

This doesn't map to a real instruction, so AVX, etc, is irrelevent. This is a SVML (pseudo) instruction.

See C++ error: ‘_mm_sin_ps’ was not declared in this scope

MSVC and ICC both support SVML, GCC or Clang do not.

Mike Vine
  • 9,468
  • 25
  • 44