From d0f34d50f7ee6b6d778cadd435553ba0e0d0cdc5 Mon Sep 17 00:00:00 2001 From: nihui Date: Wed, 16 Aug 2023 21:37:36 +0800 Subject: [PATCH] detect msvc features --- CMakeLists.txt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7647a67b2c8..35a586ecda2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,15 +408,21 @@ else() check_cxx_compiler_flag("/arch:AVX" NCNN_COMPILER_SUPPORT_X86_XOP) check_cxx_compiler_flag("/arch:AVX" NCNN_COMPILER_SUPPORT_X86_F16C) check_cxx_compiler_flag("/arch:AVX2" NCNN_COMPILER_SUPPORT_X86_AVX2) - check_cxx_compiler_flag("/arch:AVX2" NCNN_COMPILER_SUPPORT_X86_AVX_VNNI) check_cxx_compiler_flag("/arch:AVX512" NCNN_COMPILER_SUPPORT_X86_AVX512) - check_cxx_compiler_flag("/arch:AVX512" NCNN_COMPILER_SUPPORT_X86_AVX512_VNNI) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.16) - # vs2017+ supports avx512 and vnni - set(NCNN_COMPILER_SUPPORT_X86_AVX_VNNI OFF) - set(NCNN_COMPILER_SUPPORT_X86_AVX512 OFF) - set(NCNN_COMPILER_SUPPORT_X86_AVX512_VNNI OFF) - endif() + + set(CMAKE_REQUIRED_FLAGS "/arch:AVX2") + check_cxx_source_compiles("#include \nint main() { __m256i _s, _a, _b; _s = _mm256_dpwssd_epi32(_s, _a, _b); return 0; }" NCNN_COMPILER_SUPPORT_X86_AVX_VNNI) + + set(CMAKE_REQUIRED_FLAGS "/arch:AVX512") + check_cxx_source_compiles("#include \nint main() { __m512i _s, _a, _b; _s = _mm512_dpwssd_epi32(_s, _a, _b); return 0; }" NCNN_COMPILER_SUPPORT_X86_AVX512_VNNI) + + set(CMAKE_REQUIRED_FLAGS "/arch:AVX512") + check_cxx_source_compiles("#include \nint main() { __m256bh _s; __m512bh _a, _b; _s = _mm512_cvtneps_pbh(_mm512_dpbf16_ps(_mm512_cvtpbh_ps(_s), _a, _b)); return 0; }" NCNN_COMPILER_SUPPORT_X86_AVX512_BF16) + + set(CMAKE_REQUIRED_FLAGS "/arch:AVX512") + check_cxx_source_compiles("#include \nint main() { __m512h _s, _a, _b; _s = _mm512_fmadd_ph(_s, _a, _b); __m512 _s2; _s2 = _mm512_cvtxph_ps(_mm512_cvtxps_ph(_s2)); return 0; }" NCNN_COMPILER_SUPPORT_X86_AVX512_FP16) + + unset(CMAKE_REQUIRED_FLAGS) else() check_cxx_compiler_flag("-mavx" NCNN_COMPILER_SUPPORT_X86_AVX)