|
|
|
@ -8,6 +8,7 @@ |
|
|
|
|
# CPU_{opt}_SUPPORTED=ON/OFF - compiler support (possibly with additional flag) |
|
|
|
|
# CPU_{opt}_IMPLIES=<list> |
|
|
|
|
# CPU_{opt}_FORCE=<list> - subset of "implies" list |
|
|
|
|
# CPU_{opt}_GROUP=<list> - similar to "implies" list, but additionally merges compiler flags |
|
|
|
|
# CPU_{opt}_FLAGS_ON="" |
|
|
|
|
# CPU_{opt}_FEATURE_ALIAS - mapping to CV_CPU_* HWFeature enum |
|
|
|
|
|
|
|
|
@ -26,7 +27,7 @@ |
|
|
|
|
# |
|
|
|
|
# CPU_DISPATCH_FLAGS_${opt} - flags for source files compiled separately (<name>.avx2.cpp) |
|
|
|
|
|
|
|
|
|
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F") |
|
|
|
|
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX") |
|
|
|
|
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16) |
|
|
|
|
list(APPEND CPU_ALL_OPTIMIZATIONS VSX) |
|
|
|
|
list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS) |
|
|
|
@ -145,7 +146,9 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ") |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
if(X86 OR X86_64) |
|
|
|
|
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F") |
|
|
|
|
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F;AVX512_SKX") |
|
|
|
|
|
|
|
|
|
ocv_update(CPU_AVX512_SKX_GROUP "AVX_512F;AVX_512CD;AVX_512BW;AVX_512DQ;AVX_512VL") |
|
|
|
|
|
|
|
|
|
ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp") |
|
|
|
|
ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp") |
|
|
|
@ -158,6 +161,7 @@ if(X86 OR X86_64) |
|
|
|
|
ocv_update(CPU_AVX2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp") |
|
|
|
|
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp") |
|
|
|
|
ocv_update(CPU_AVX_512F_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp") |
|
|
|
|
ocv_update(CPU_AVX512_SKX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512skx.cpp") |
|
|
|
|
|
|
|
|
|
if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE) |
|
|
|
|
ocv_update(CPU_AVX_512F_IMPLIES "AVX2") |
|
|
|
@ -206,6 +210,7 @@ if(X86 OR X86_64) |
|
|
|
|
ocv_intel_compiler_optimization_option(SSE "-msse" "/arch:SSE") |
|
|
|
|
endif() |
|
|
|
|
ocv_intel_compiler_optimization_option(AVX_512F "-march=common-avx512" "/arch:COMMON-AVX512") |
|
|
|
|
ocv_intel_compiler_optimization_option(AVX512_SKX "-march=core-avx512" "/arch:CORE-AVX512") |
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCXX) |
|
|
|
|
ocv_update(CPU_AVX2_FLAGS_ON "-mavx2") |
|
|
|
|
ocv_update(CPU_FP16_FLAGS_ON "-mf16c") |
|
|
|
@ -221,6 +226,7 @@ if(X86 OR X86_64) |
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") |
|
|
|
|
# -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi |
|
|
|
|
ocv_update(CPU_AVX_512F_FLAGS_ON "-mavx512f") |
|
|
|
|
ocv_update(CPU_AVX512_SKX_FLAGS_ON "-mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq") |
|
|
|
|
endif() |
|
|
|
|
elseif(MSVC) |
|
|
|
|
ocv_update(CPU_AVX2_FLAGS_ON "/arch:AVX2") |
|
|
|
@ -348,6 +354,18 @@ endmacro() |
|
|
|
|
|
|
|
|
|
foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS}) |
|
|
|
|
set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "") |
|
|
|
|
if(DEFINED CPU_${OPT}_GROUP) |
|
|
|
|
if(NOT DEFINED CPU_${OPT}_IMPLIES) |
|
|
|
|
set(CPU_${OPT}_IMPLIES "${CPU_${OPT}_GROUP}") |
|
|
|
|
endif() |
|
|
|
|
if(NOT DEFINED CPU_${OPT}_FLAGS_ON) |
|
|
|
|
set(__flags "") |
|
|
|
|
foreach(OPT2 ${CPU_${OPT}_GROUP}) |
|
|
|
|
set(__flags "${__flags} ${CPU_${OPT2}_FLAGS_ON}") |
|
|
|
|
endforeach() |
|
|
|
|
set(CPU_${OPT}_FLAGS_ON "${__flags}") |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
if(NOT DEFINED CPU_${OPT}_FORCE) |
|
|
|
|
set(CPU_${OPT}_FORCE "${CPU_${OPT}_IMPLIES}") |
|
|
|
|
endif() |
|
|
|
|