Merge pull request #24698 from tomoaki0705:support_arm64_windows

build: prepare to build for ARM64 on Windows with Visual Studio
This commit is contained in:
Alexander Smorkalov 2023-12-19 13:19:54 +03:00 committed by GitHub
commit 283407e1ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 14 deletions

View File

@ -349,12 +349,18 @@ elseif(ARM OR AARCH64)
ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16;NEON_DOTPROD;NEON_FP16;NEON_BF16")
ocv_update(CPU_NEON_FLAGS_ON "")
ocv_update(CPU_FP16_IMPLIES "NEON")
ocv_update(CPU_NEON_DOTPROD_FLAGS_ON "-march=armv8.2-a+dotprod")
ocv_update(CPU_NEON_DOTPROD_IMPLIES "NEON")
ocv_update(CPU_NEON_FP16_FLAGS_ON "-march=armv8.2-a+fp16")
ocv_update(CPU_NEON_FP16_IMPLIES "NEON")
ocv_update(CPU_NEON_BF16_FLAGS_ON "-march=armv8.2-a+bf16")
ocv_update(CPU_NEON_BF16_IMPLIES "NEON")
if(MSVC)
ocv_update(CPU_NEON_DOTPROD_FLAGS_ON "")
ocv_update(CPU_NEON_FP16_FLAGS_ON "")
ocv_update(CPU_NEON_BF16_FLAGS_ON "")
else()
ocv_update(CPU_NEON_DOTPROD_FLAGS_ON "-march=armv8.2-a+dotprod")
ocv_update(CPU_NEON_FP16_FLAGS_ON "-march=armv8.2-a+fp16")
ocv_update(CPU_NEON_BF16_FLAGS_ON "-march=armv8.2-a+bf16")
endif()
set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}")
set(CPU_DISPATCH "NEON_FP16;NEON_BF16;NEON_DOTPROD" CACHE STRING "${HELP_CPU_DISPATCH}")
endif()
@ -478,20 +484,22 @@ macro(ocv_check_compiler_optimization OPT)
endmacro()
macro(ocv_cpu_aarch64_baseline_merge_feature_options FEATURE_NAME_LIST FLAG_STRING COMMON_OPTION)
if(NOT MSVC)
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()
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}")
set(${FLAG_STRING} "${${FLAG_STRING}} ${COMMON_OPTION}${_POSTFIX}")
endif()
endif()
endmacro()
foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})

View File

@ -11,7 +11,7 @@ int test()
_mm_storel_epi64((__m128i*)dst, v_dst);
return (int)dst[0];
}
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#elif (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64)
#include "arm_neon.h"
int test()
{

View File

@ -1,4 +1,4 @@
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64)
#include <stdio.h>
#include "arm_neon.h"

View File

@ -1,6 +1,6 @@
#include <stdio.h>
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64)
#include "arm_neon.h"
int test()
{

View File

@ -1,6 +1,6 @@
#include <stdio.h>
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64)
#include "arm_neon.h"
float16x8_t vld1q_as_f16(const float* src)