From c778011f1420a1e0e2984ed21de954d88d2bf5b3 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 30 Dec 2014 20:11:42 +0300 Subject: [PATCH] More accurate AVX and AVX2 control. - Previous version just checked option support, but not enable it. - Also OpenCV tests reports invalid AVX and AVX2 support status. --- cmake/OpenCVCompilerOptions.cmake | 4 ++-- modules/ts/src/ts_func.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 1f13b2156c..9477d9cff0 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -144,11 +144,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) # SSE3 and further should be disabled under MingW because it generates compiler errors if(NOT MINGW) if(ENABLE_AVX) - ocv_check_flag_support(CXX "-mavx" _varname) + add_extra_compiler_option("-mavx") endif() if(ENABLE_AVX2) - ocv_check_flag_support(CXX "-mavx2" _varname) + add_extra_compiler_option("-mavx2") endif() # GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed. diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index 428a5f8128..39907edac4 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -3002,8 +3002,12 @@ void printVersionInfo(bool useStdOut) #if CV_SSE4_2 if (checkHardwareSupport(CV_CPU_SSE4_2)) cpu_features += " sse4.2"; #endif +#if CV_AVX if (checkHardwareSupport(CV_CPU_AVX)) cpu_features += " avx"; +#endif +#if CV_AVX2 if (checkHardwareSupport(CV_CPU_AVX2)) cpu_features += " avx2"; +#endif #if CV_NEON cpu_features += " neon"; // NEON is currently not checked at runtime #endif