From 56222f35bb8457ecef550c235c4b30dc9322350a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 26 Apr 2018 16:03:45 +0300 Subject: [PATCH] cmake: fix CPU_BASELINE_FINAL filling - remove duplicates - restore "always on" missing entries - fix FP16 detection on MSVC --- cmake/OpenCVCompilerOptimizations.cmake | 8 +++++++- cmake/checks/cpu_fp16.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake index 9190222..def9672 100644 --- a/cmake/OpenCVCompilerOptimizations.cmake +++ b/cmake/OpenCVCompilerOptimizations.cmake @@ -234,6 +234,7 @@ if(X86 OR X86_64) elseif(MSVC) ocv_update(CPU_AVX2_FLAGS_ON "/arch:AVX2") ocv_update(CPU_AVX_FLAGS_ON "/arch:AVX") + ocv_update(CPU_FP16_FLAGS_ON "/arch:AVX") if(NOT MSVC64) # 64-bit MSVC compiler uses SSE/SSE2 by default ocv_update(CPU_SSE_FLAGS_ON "/arch:SSE") @@ -422,6 +423,9 @@ foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS}) if(__is_disabled) set(__is_from_baseline 0) else() + if(CPU_${OPT}_SUPPORTED AND CPU_BASELINE_DETECT) + list(APPEND CPU_BASELINE_FINAL ${OPT}) + endif() ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE_REQUIRE}) if(NOT __is_from_baseline) ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE}) @@ -441,7 +445,9 @@ foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS}) if(";${CPU_DISPATCH};" MATCHES ";${OPT};" AND NOT __is_from_baseline) list(APPEND CPU_DISPATCH_FINAL ${OPT}) elseif(__is_from_baseline) - list(APPEND CPU_BASELINE_FINAL ${OPT}) + if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};") + list(APPEND CPU_BASELINE_FINAL ${OPT}) + endif() ocv_append_optimization_flag(CPU_BASELINE_FLAGS ${OPT}) endif() endif() diff --git a/cmake/checks/cpu_fp16.cpp b/cmake/checks/cpu_fp16.cpp index 6951f1c..f12cb10 100644 --- a/cmake/checks/cpu_fp16.cpp +++ b/cmake/checks/cpu_fp16.cpp @@ -1,6 +1,6 @@ #include -#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700) || (defined __INTEL_COMPILER && defined __AVX__) +#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700 && defined __AVX__) || (defined __INTEL_COMPILER && defined __AVX__) #include int test() { -- 2.7.4