Merge pull request #24642 from tomoaki0705:merge_features_aarch64

build: merge multiple features specified at once
pull/24698/head
Alexander Smorkalov 1 year ago committed by GitHub
commit 7892517b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      cmake/OpenCVCompilerOptimizations.cmake

@ -353,7 +353,7 @@ elseif(ARM OR AARCH64)
ocv_update(CPU_NEON_DOTPROD_IMPLIES "NEON") ocv_update(CPU_NEON_DOTPROD_IMPLIES "NEON")
ocv_update(CPU_NEON_FP16_FLAGS_ON "-march=armv8.2-a+fp16") ocv_update(CPU_NEON_FP16_FLAGS_ON "-march=armv8.2-a+fp16")
ocv_update(CPU_NEON_FP16_IMPLIES "NEON") ocv_update(CPU_NEON_FP16_IMPLIES "NEON")
ocv_update(CPU_NEON_BF16_FLAGS_ON "-march=armv8.2-a+fp16+bf16") ocv_update(CPU_NEON_BF16_FLAGS_ON "-march=armv8.2-a+bf16")
ocv_update(CPU_NEON_BF16_IMPLIES "NEON") ocv_update(CPU_NEON_BF16_IMPLIES "NEON")
set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}") set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}")
set(CPU_DISPATCH "NEON_FP16;NEON_BF16;NEON_DOTPROD" CACHE STRING "${HELP_CPU_DISPATCH}") set(CPU_DISPATCH "NEON_FP16;NEON_BF16;NEON_DOTPROD" CACHE STRING "${HELP_CPU_DISPATCH}")
@ -477,6 +477,23 @@ macro(ocv_check_compiler_optimization OPT)
endif() endif()
endmacro() endmacro()
macro(ocv_cpu_aarch64_baseline_merge_feature_options FEATURE_NAME_LIST FLAG_STRING COMMON_OPTION)
unset(_POSTFIX)
# Check each feature option
foreach(OPT IN LISTS ${FEATURE_NAME_LIST})
string(FIND "${${FLAG_STRING}}" "${CPU_${OPT}_FLAGS_ON}" OPT_FOUND)
if(NOT ${OPT_FOUND} EQUAL -1)
string(REPLACE "${COMMON_OPTION}" "" TRAILING_PART "${CPU_${OPT}_FLAGS_ON}")
string(APPEND _POSTFIX "${TRAILING_PART}")
string(REPLACE " ${CPU_${OPT}_FLAGS_ON}" "" ${FLAG_STRING} ${${FLAG_STRING}})
endif()
endforeach()
# If more than one option found, merge them
if(NOT "x${_POSTFIX}" STREQUAL "x")
set(${FLAG_STRING} "${${FLAG_STRING}} ${COMMON_OPTION}${_POSTFIX}")
endif()
endmacro()
foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS}) foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "") set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "")
if("${CPU_${OPT}_FLAGS_ON}" STREQUAL "disabled") if("${CPU_${OPT}_FLAGS_ON}" STREQUAL "disabled")
@ -570,6 +587,13 @@ foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
endif() endif()
endforeach() endforeach()
if(AARCH64)
# Define the list of NEON options to check
set(NEON_OPTIONS_LIST NEON_DOTPROD NEON_FP16 NEON_BF16)
set(BASE_ARCHITECTURE "-march=armv8.2-a")
ocv_cpu_aarch64_baseline_merge_feature_options(NEON_OPTIONS_LIST CPU_BASELINE_FLAGS ${BASE_ARCHITECTURE})
endif()
foreach(OPT ${CPU_BASELINE_REQUIRE}) foreach(OPT ${CPU_BASELINE_REQUIRE})
if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};") if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
message(SEND_ERROR "Required baseline optimization is not supported: ${OPT} (CPU_BASELINE_REQUIRE=${CPU_BASELINE_REQUIRE})") message(SEND_ERROR "Required baseline optimization is not supported: ${OPT} (CPU_BASELINE_REQUIRE=${CPU_BASELINE_REQUIRE})")

Loading…
Cancel
Save