eigeneigen3intel-mkl

Eigen3 Optimize for AVX2 instruction set error


I'm trying to use Eigen3 frontend with Intel MKL backend.
I'm optimizing the program for AVX2 instruction set.
When I define AVX2, I get the bellow mentioned.
If I don't define AVX2, I get SSE and SSE2 instruction set enabled message.

CMakeList.txt

cmake_minimum_required(VERSION 3.6)

project(mkl_example)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_C_STANDARD 23)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)

include(/home/admin/vcpkg/scripts/buildsystems/vcpkg.cmake)

find_package(MKL CONFIG REQUIRED)

set(
    SRC_CPP
    main.cpp
)

add_compile_options("-g")

add_link_options("-march=native -mavx2")

add_executable(
    ${PROJECT_NAME}
    ${SRC_CPP}
)

target_link_libraries(
    ${PROJECT_NAME} 
    PRIVATE MKL::MKL
)

Code :

#define EIGEN_USE_MKL_ALL
#define EIGEN_NO_CUDA
#define __AVX2__
#define __FMA__
#define EIGEN_HAS_OPENMP
#define EIGEN_MAX_CPP_VER 17
#include <iostream>
#include "Eigen/Eigen"

int main(int argc, char const *argv[])
{
    std::cout << Eigen::SimdInstructionSetsInUse();
    return 0;
}

Error :

admin@22lt24:~/mkl_example/build$ make -j4
[ 50%] Building CXX object CMakeFiles/mkl_example.dir/main.cpp.o
<built-in>: warning: "__AVX2__" redefined
/home/admin/mkl_example/main.cpp:4:9: note: this is the location of the previous definition
    4 | #define __AVX2__
      |         ^~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/14/include/immintrin.h:117,
                 from /home/admin/mkl_example/Eigen/src/Core/util/ConfigureVectorization.h:361,
                 from /home/admin/mkl_example/Eigen/Core:22,
                 from /home/admin/mkl_example/Eigen/Dense:1,
                 from /home/admin/mkl_example/Eigen/Eigen:1,
                 from /home/admin/mkl_example/main.cpp:9:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmadd_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:41:19: error: ‘__builtin_ia32_vfmaddpd’ was not declared in this scope; did you mean ‘__builtin_ia32_4fmaddps’?
   41 |   return (__m128d)__builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_4fmaddps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fmadd_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:49:19: error: ‘__builtin_ia32_vfmaddpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_vfmaddcph256’?
   49 |   return (__m256d)__builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_vfmaddcph256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmadd_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:57:18: error: ‘__builtin_ia32_vfmaddps’ was not declared in this scope; did you mean ‘__builtin_ia32_4fmaddps’?
   57 |   return (__m128)__builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_4fmaddps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fmadd_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:65:18: error: ‘__builtin_ia32_vfmaddps256’ was not declared in this scope; did you mean ‘__builtin_ia32_vfmaddcph256’?
   65 |   return (__m256)__builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_vfmaddcph256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmadd_sd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:73:20: error: ‘__builtin_ia32_vfmaddsd3’ was not declared in this scope; did you mean ‘__builtin_ia32_4fmaddss’?
   73 |   return (__m128d) __builtin_ia32_vfmaddsd3 ((__v2df)__A, (__v2df)__B,
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~
      |                    __builtin_ia32_4fmaddss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmadd_ss(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:81:19: error: ‘__builtin_ia32_vfmaddss3’ was not declared in this scope; did you mean ‘__builtin_ia32_4fmaddss’?
   81 |   return (__m128) __builtin_ia32_vfmaddss3 ((__v4sf)__A, (__v4sf)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_4fmaddss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmsub_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:89:19: error: ‘__builtin_ia32_vfmsubpd’ was not declared in this scope; did you mean ‘__builtin_ia32_subpd’?
   89 |   return (__m128d)__builtin_ia32_vfmsubpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subpd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fmsub_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:97:19: error: ‘__builtin_ia32_vfmsubpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_subpd256’?
   97 |   return (__m256d)__builtin_ia32_vfmsubpd256 ((__v4df)__A, (__v4df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subpd256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmsub_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:105:18: error: ‘__builtin_ia32_vfmsubps’ was not declared in this scope; did you mean ‘__builtin_ia32_subps’?
  105 |   return (__m128)__builtin_ia32_vfmsubps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fmsub_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:113:18: error: ‘__builtin_ia32_vfmsubps256’ was not declared in this scope; did you mean ‘__builtin_ia32_subps256’?
  113 |   return (__m256)__builtin_ia32_vfmsubps256 ((__v8sf)__A, (__v8sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subps256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmsub_sd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:121:19: error: ‘__builtin_ia32_vfmsubsd3’ was not declared in this scope; did you mean ‘__builtin_ia32_subsd’?
  121 |   return (__m128d)__builtin_ia32_vfmsubsd3 ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subsd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmsub_ss(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:129:18: error: ‘__builtin_ia32_vfmsubss3’ was not declared in this scope; did you mean ‘__builtin_ia32_subss’?
  129 |   return (__m128)__builtin_ia32_vfmsubss3 ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fnmadd_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:137:19: error: ‘__builtin_ia32_vfnmaddpd’ was not declared in this scope; did you mean ‘__builtin_ia32_4fnmaddps’?
  137 |   return (__m128d)__builtin_ia32_vfnmaddpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_4fnmaddps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fnmadd_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:145:19: error: ‘__builtin_ia32_vfnmaddpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_vfmaddcph256’?
  145 |   return (__m256d)__builtin_ia32_vfnmaddpd256 ((__v4df)__A, (__v4df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_vfmaddcph256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fnmadd_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:153:18: error: ‘__builtin_ia32_vfnmaddps’ was not declared in this scope; did you mean ‘__builtin_ia32_4fnmaddps’?
  153 |   return (__m128)__builtin_ia32_vfnmaddps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_4fnmaddps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fnmadd_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:161:18: error: ‘__builtin_ia32_vfnmaddps256’ was not declared in this scope; did you mean ‘__builtin_ia32_vfmaddcph256’?
  161 |   return (__m256)__builtin_ia32_vfnmaddps256 ((__v8sf)__A, (__v8sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_vfmaddcph256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fnmadd_sd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:169:19: error: ‘__builtin_ia32_vfnmaddsd3’ was not declared in this scope; did you mean ‘__builtin_ia32_4fnmaddss’?
  169 |   return (__m128d)__builtin_ia32_vfnmaddsd3 ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_4fnmaddss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fnmadd_ss(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:177:18: error: ‘__builtin_ia32_vfnmaddss3’ was not declared in this scope; did you mean ‘__builtin_ia32_4fnmaddss’?
  177 |   return (__m128)__builtin_ia32_vfnmaddss3 ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_4fnmaddss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fnmsub_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:185:19: error: ‘__builtin_ia32_vfnmsubpd’ was not declared in this scope; did you mean ‘__builtin_ia32_subpd’?
  185 |   return (__m128d)__builtin_ia32_vfnmsubpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subpd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fnmsub_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:193:19: error: ‘__builtin_ia32_vfnmsubpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_subpd256’?
  193 |   return (__m256d)__builtin_ia32_vfnmsubpd256 ((__v4df)__A, (__v4df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subpd256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fnmsub_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:201:18: error: ‘__builtin_ia32_vfnmsubps’ was not declared in this scope; did you mean ‘__builtin_ia32_subps’?
  201 |   return (__m128)__builtin_ia32_vfnmsubps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fnmsub_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:209:18: error: ‘__builtin_ia32_vfnmsubps256’ was not declared in this scope; did you mean ‘__builtin_ia32_subps256’?
  209 |   return (__m256)__builtin_ia32_vfnmsubps256 ((__v8sf)__A, (__v8sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subps256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fnmsub_sd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:217:19: error: ‘__builtin_ia32_vfnmsubsd3’ was not declared in this scope; did you mean ‘__builtin_ia32_subsd’?
  217 |   return (__m128d)__builtin_ia32_vfnmsubsd3 ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_subsd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fnmsub_ss(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:225:18: error: ‘__builtin_ia32_vfnmsubss3’ was not declared in this scope; did you mean ‘__builtin_ia32_subss’?
  225 |   return (__m128)__builtin_ia32_vfnmsubss3 ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_subss
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmaddsub_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:233:19: error: ‘__builtin_ia32_vfmaddsubpd’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubpd’?
  233 |   return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_addsubpd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fmaddsub_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:241:19: error: ‘__builtin_ia32_vfmaddsubpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubpd256’?
  241 |   return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_addsubpd256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmaddsub_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:250:18: error: ‘__builtin_ia32_vfmaddsubps’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubps’?
  250 |   return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_addsubps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fmaddsub_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:258:18: error: ‘__builtin_ia32_vfmaddsubps256’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubps256’?
  258 |   return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_addsubps256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128d _mm_fmsubadd_pd(__m128d, __m128d, __m128d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:267:19: error: ‘__builtin_ia32_vfmaddsubpd’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubpd’?
  267 |   return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_addsubpd
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256d _mm256_fmsubadd_pd(__m256d, __m256d, __m256d)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:275:19: error: ‘__builtin_ia32_vfmaddsubpd256’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubpd256’?
  275 |   return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   __builtin_ia32_addsubpd256
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m128 _mm_fmsubadd_ps(__m128, __m128, __m128)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:284:18: error: ‘__builtin_ia32_vfmaddsubps’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubps’?
  284 |   return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_addsubps
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h: In function ‘__m256 _mm256_fmsubadd_ps(__m256, __m256, __m256)’:
/usr/lib/gcc/x86_64-linux-gnu/14/include/fmaintrin.h:292:18: error: ‘__builtin_ia32_vfmaddsubps256’ was not declared in this scope; did you mean ‘__builtin_ia32_addsubps256’?
  292 |   return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  __builtin_ia32_addsubps256
In file included from /home/admin/mkl_example/Eigen/Core:199:
/home/admin/mkl_example/Eigen/src/Core/arch/AVX/PacketMath.h: In function ‘Packet Eigen::internal::pset1(const typename unpacket_traits<T>::type&) [with Packet = __vector(8) float; typename unpacket_traits<T>::type = float]’:
/home/admin/mkl_example/Eigen/src/Core/arch/AVX/PacketMath.h:240:75: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
  240 | template<> EIGEN_STRONG_INLINE Packet8f pset1<Packet8f>(const float&  from) { return _mm256_set1_ps(from); }
      |                                                                           ^
make[2]: *** [CMakeFiles/mkl_example.dir/build.make:76: CMakeFiles/mkl_example.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/mkl_example.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Solution

  • Updated CMakeLists.txt to add CMAKE_CXX_FLAGS

    set(CLANG_AVX_FLAGS             "-O3 -march=native -ffast-math") 
    set(CMAKE_CXX_FLAGS             "${CLANG_AVX_FLAGS} -Wall -pedantic")
    set(CMAKE_CXX_FLAGS_RELEASE     "${CLANG_AVX_FLAGS} -O3 -DEIGEN_NO_DEBUG")
    

    CMakeFile

    cmake_minimum_required(VERSION 3.6)
    
    project(mkl_example)
    
    set(CMAKE_CXX_STANDARD 23)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    set(CMAKE_C_STANDARD 23)
    set(CMAKE_C_EXTENSIONS OFF)
    set(CMAKE_C_STANDARD_REQUIRED ON)
    
    include(/home/ishaan/vcpkg/scripts/buildsystems/vcpkg.cmake)
    
    find_package(MKL CONFIG REQUIRED)
    
    find_package(OpenMP)
    if (OPENMP_FOUND)
        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
    endif()
    
    set(
        SRC_CPP
        main.cpp
    )
    
    set(CLANG_AVX_FLAGS             "-O3 -march=native -ffast-math") # Added Flags
    set(CMAKE_CXX_FLAGS             "${CLANG_AVX_FLAGS} -Wall -pedantic") # Added Flags
    set(CMAKE_CXX_FLAGS_RELEASE     "${CLANG_AVX_FLAGS} -O3 -DEIGEN_NO_DEBUG") # Added Flags
    
    # add_compile_options("-g")
    
    # add_link_options("-march=native -mavx2 -O3")
    
    add_executable(
        ${PROJECT_NAME}
        ${SRC_CPP}
    )
    
    target_link_libraries(
        ${PROJECT_NAME} 
        PRIVATE MKL::MKL
    )
    

    Removed #define __AVX2__ and #define __FMA__

    Code :

    #define EIGEN_USE_MKL_ALL
    #define EIGEN_NO_CUDA
    #define EIGEN_HAS_OPENMP
    #define EIGEN_MAX_CPP_VER 17
    #include <iostream>
    #include "Eigen/Eigen"
    
    int main(int argc, char const *argv[])
    {
        std::cout << Eigen::SimdInstructionSetsInUse();
        return 0;
    }