1- # Detect hardware AVX-512 support
2- include (CheckCXXCompilerFlag )
1+ # Step 1: Check compiler support for AVX-512DQ
2+ check_cxx_compiler_flag( "-mavx512dq" COMPILER_SUPPORTS_AVX512DQ )
33
4- # Step 1: Check compiler support for AVX-512
5- check_cxx_compiler_flag( "-mavx512dq" COMPILER_SUPPORTS_AVX512 )
4+ if (COMPILER_SUPPORTS_AVX512DQ)
5+ message ( STATUS "Compiler supports AVX-512DQ." )
66
7- if (COMPILER_SUPPORTS_AVX512)
8- message (STATUS "Compiler supports AVX512." )
9-
10- # Write the test program
11- file (WRITE "${CMAKE_BINARY_DIR} /check_avx512.cpp"
7+ # Write the test program to check for AVX-512DQ support
8+ file (WRITE "${CMAKE_BINARY_DIR} /check_avx512dq.cpp"
129 "#include <immintrin.h>
13- int main() {
14- __m512i x = _mm512_set1_epi32(1);
15- return 0;
16- }"
10+ int main() {
11+ __m512d x = _mm512_set1_pd(1.0); // AVX-512DQ specific intrinsic for double-precision
12+ return 0;
13+ }"
1714 )
1815
19- try_compile (HAS_AVX512_SUPPORT
16+ try_compile (HAS_AVX512DQ_SUPPORT
2017 "${CMAKE_BINARY_DIR} "
21- "${CMAKE_BINARY_DIR} /check_avx512 .cpp"
18+ "${CMAKE_BINARY_DIR} /check_avx512dq .cpp"
2219 COMPILE_DEFINITIONS -mavx512dq
2320 )
2421
25- if (HAS_AVX512_SUPPORT )
26- message (STATUS "Hardware supports AVX-512 . Adding AVX-512 flags." )
27- set (AVX512_FLAG "-mavx512dq" )
22+ if (HAS_AVX512DQ_SUPPORT )
23+ message (STATUS "Hardware supports AVX-512DQ . Adding AVX-512DQ flags." )
24+ set (AVX512DQ_FLAG "-mavx512dq" )
2825 else ()
29- message (STATUS "Hardware does not support AVX-512 ." )
26+ message (STATUS "Hardware does not support AVX-512DQ ." )
3027 endif ()
3128else ()
32- message (STATUS "Compiler does not support AVX-512 ." )
29+ message (STATUS "Compiler does not support AVX-512DQ ." )
3330endif ()
3431
3532# Define the library
@@ -42,7 +39,7 @@ add_library(ALP
4239 fastlanes_unffor.cpp
4340 )
4441
45- # Add AVX-512 flag if supported
46- if (AVX512_FLAG )
47- target_compile_options (ALP PUBLIC ${AVX512_FLAG } )
42+ # Add AVX-512DQ flag if supported
43+ if (AVX512DQ_FLAG )
44+ target_compile_options (ALP PUBLIC ${AVX512DQ_FLAG } )
4845endif ()
0 commit comments