From 1f674dcdb4ab57aac6883af3a37d6f45307b73af Mon Sep 17 00:00:00 2001 From: Kumataro Date: Thu, 12 Jun 2025 21:32:28 +0900 Subject: [PATCH] Merge pull request #27416 from Kumataro:fix27413 Close https://github.com/opencv/opencv/issues/27413 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- cmake/checks/cpu_neon.cpp | 2 +- cmake/checks/cpu_neon_bf16.cpp | 2 +- cmake/checks/cpu_neon_dotprod.cpp | 2 +- cmake/checks/cpu_neon_fp16.cpp | 2 +- modules/core/include/opencv2/core/cv_cpu_dispatch.h | 6 +++--- modules/core/include/opencv2/core/cvdef.h | 2 +- modules/core/include/opencv2/core/fast_math.hpp | 2 +- modules/core/include/opencv2/core/hal/intrin_neon.hpp | 8 ++++---- modules/core/src/matmul.simd.hpp | 2 +- modules/core/src/parallel.cpp | 2 +- modules/core/src/system.cpp | 2 +- modules/dnn/src/op_inf_engine.cpp | 2 +- modules/flann/include/opencv2/flann/dist.h | 2 +- modules/highgui/src/window_w32.cpp | 2 +- modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmake/checks/cpu_neon.cpp b/cmake/checks/cpu_neon.cpp index 7af16f5ffc..30c144cdf8 100644 --- a/cmake/checks/cpu_neon.cpp +++ b/cmake/checks/cpu_neon.cpp @@ -1,6 +1,6 @@ #include -#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) # define _ARM64_DISTINCT_NEON_TYPES # include # include diff --git a/cmake/checks/cpu_neon_bf16.cpp b/cmake/checks/cpu_neon_bf16.cpp index a9045d7117..5aaf8f051f 100644 --- a/cmake/checks/cpu_neon_bf16.cpp +++ b/cmake/checks/cpu_neon_bf16.cpp @@ -1,4 +1,4 @@ -#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64) +#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && (defined _M_ARM64 || defined _M_ARM64EC)) #include #include "arm_neon.h" diff --git a/cmake/checks/cpu_neon_dotprod.cpp b/cmake/checks/cpu_neon_dotprod.cpp index 74f44a1832..2db6c4b1cc 100644 --- a/cmake/checks/cpu_neon_dotprod.cpp +++ b/cmake/checks/cpu_neon_dotprod.cpp @@ -1,6 +1,6 @@ #include -#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64) +#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && (defined _M_ARM64 || defined _M_ARM64EC)) #include "arm_neon.h" int test() { diff --git a/cmake/checks/cpu_neon_fp16.cpp b/cmake/checks/cpu_neon_fp16.cpp index bba5b97026..45f5b05906 100644 --- a/cmake/checks/cpu_neon_fp16.cpp +++ b/cmake/checks/cpu_neon_fp16.cpp @@ -1,6 +1,6 @@ #include -#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && defined _M_ARM64) +#if (defined __GNUC__ && (defined __arm__ || defined __aarch64__)) || (defined _MSC_VER && (defined _M_ARM64 || defined _M_ARM64EC)) #include "arm_neon.h" float16x8_t vld1q_as_f16(const float* src) diff --git a/modules/core/include/opencv2/core/cv_cpu_dispatch.h b/modules/core/include/opencv2/core/cv_cpu_dispatch.h index 607f286615..b920ba349e 100644 --- a/modules/core/include/opencv2/core/cv_cpu_dispatch.h +++ b/modules/core/include/opencv2/core/cv_cpu_dispatch.h @@ -72,7 +72,7 @@ # define CV_AVX 1 #endif #ifdef CV_CPU_COMPILE_FP16 -# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) +# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) # include # else # include @@ -137,7 +137,7 @@ # define CV_FMA3 1 #endif -#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) # include # include # define CV_NEON 1 @@ -230,7 +230,7 @@ struct VZeroUpperGuard { # define CV_MMX 1 # define CV_SSE 1 # define CV_SSE2 1 -#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) # include # include # define CV_NEON 1 diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 0e6d6ff49b..96445a3abb 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -368,7 +368,7 @@ enum CpuFeatures { #include "cv_cpu_dispatch.h" -#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64)) +#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) // int*, int64* should be propertly aligned pointers on ARMv7 #define CV_STRONG_ALIGNMENT 1 #endif diff --git a/modules/core/include/opencv2/core/fast_math.hpp b/modules/core/include/opencv2/core/fast_math.hpp index a28c3fbedf..6f0ad67bc4 100644 --- a/modules/core/include/opencv2/core/fast_math.hpp +++ b/modules/core/include/opencv2/core/fast_math.hpp @@ -303,7 +303,7 @@ CV_INLINE int cvIsInf( double value ) { #if defined CV_INLINE_ISINF_DBL CV_INLINE_ISINF_DBL(value); -#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__) || defined(__loongarch64) +#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__PPC64__) || defined(__loongarch64) Cv64suf ieee754; ieee754.f = value; return (ieee754.u & 0x7fffffffffffffff) == diff --git a/modules/core/include/opencv2/core/hal/intrin_neon.hpp b/modules/core/include/opencv2/core/hal/intrin_neon.hpp index 64fb7d73bc..3c1630148b 100644 --- a/modules/core/include/opencv2/core/hal/intrin_neon.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_neon.hpp @@ -56,7 +56,7 @@ namespace cv CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN #define CV_SIMD128 1 -#if defined(__aarch64__) || defined(_M_ARM64) +#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) #define CV_SIMD128_64F 1 #else #define CV_SIMD128_64F 0 @@ -72,7 +72,7 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN // // [1] https://developer.arm.com/documentation/101028/0012/13--Advanced-SIMD--Neon--intrinsics // [2] https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros -#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64) +#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64) || defined(_M_ARM64EC) #define CV_NEON_AARCH64 1 #else #define CV_NEON_AARCH64 0 @@ -1080,7 +1080,7 @@ OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32) -#if defined(__aarch64__) || defined(_M_ARM64) +#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) static inline uint64x2_t vmvnq_u64(uint64x2_t a) { uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF)); @@ -1822,7 +1822,7 @@ inline v_int32x4 v_load_expand_q(const schar* ptr) return v_int32x4(vmovl_s16(v1)); } -#if defined(__aarch64__) || defined(_M_ARM64) +#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) #define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ { \ diff --git a/modules/core/src/matmul.simd.hpp b/modules/core/src/matmul.simd.hpp index 09847d4a4b..f089c90a01 100644 --- a/modules/core/src/matmul.simd.hpp +++ b/modules/core/src/matmul.simd.hpp @@ -1598,7 +1598,7 @@ transform_32f( const float* src, float* dst, const float* m, int len, int scn, i // Disabled for RISC-V Vector (scalable), because of: // 1. v_matmuladd for RVV is 128-bit only but not scalable, this will fail the test `Core_Transform.accuracy`. // 2. Both gcc and clang can autovectorize this, with better performance than using Universal intrinsic. -#if (CV_SIMD || CV_SIMD_SCALABLE) && !defined(__aarch64__) && !defined(_M_ARM64) && !(CV_TRY_RVV && CV_RVV) +#if (CV_SIMD || CV_SIMD_SCALABLE) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(_M_ARM64EC) && !(CV_TRY_RVV && CV_RVV) int x = 0; if( scn == 3 && dcn == 3 ) { diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 5799d73599..09c86e94d2 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -947,7 +947,7 @@ int getNumberOfCPUs_() #if defined _WIN32 SYSTEM_INFO sysinfo = {}; -#if (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501 +#if (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501 GetNativeSystemInfo( &sysinfo ); #else GetSystemInfo( &sysinfo ); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 98f26d5118..beb552ea74 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -676,7 +676,7 @@ struct HWFeatures #if defined _ARM_ && (defined(_WIN32_WCE) && _WIN32_WCE >= 0x800) have[CV_CPU_NEON] = true; #endif - #if defined _M_ARM64 + #if defined _M_ARM64 || defined _M_ARM64EC have[CV_CPU_NEON] = true; #endif #ifdef __riscv_vector diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index b4707434c1..c95075c855 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -365,7 +365,7 @@ cv::String getInferenceEngineCPUType() { auto& networkBackend = dnn_backend::createPluginDNNNetworkBackend("openvino"); CV_UNUSED(networkBackend); -#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) +#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) return CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE; #else return CV_DNN_INFERENCE_ENGINE_CPU_TYPE_X86; diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h index 3029ebb5ef..b0c0ec820f 100644 --- a/modules/flann/include/opencv2/flann/dist.h +++ b/modules/flann/include/opencv2/flann/dist.h @@ -45,7 +45,7 @@ typedef unsigned __int64 uint64_t; #include "defines.h" -#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)) # include #endif diff --git a/modules/highgui/src/window_w32.cpp b/modules/highgui/src/window_w32.cpp index 4423ea5311..b1f6d0c884 100644 --- a/modules/highgui/src/window_w32.cpp +++ b/modules/highgui/src/window_w32.cpp @@ -78,7 +78,7 @@ using namespace cv; static const char* trackbar_text = " "; -#if defined _M_X64 || defined __x86_64 || defined _M_ARM64 +#if defined _M_X64 || defined __x86_64 || defined _M_ARM64 || defined _M_ARM64EC #define icvGetWindowLongPtr GetWindowLongPtr #define icvSetWindowLongPtr(hwnd, id, ptr) SetWindowLongPtr(hwnd, id, (LONG_PTR)(ptr)) diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp index 66e12d77d6..f6145a0993 100644 --- a/modules/ts/include/opencv2/ts/ts_ext.hpp +++ b/modules/ts/include/opencv2/ts/ts_ext.hpp @@ -128,7 +128,7 @@ struct SkipThisTest : public ::testing::Test { } \ // Special type of tests which require / use or validate processing of huge amount of data (>= 2Gb) -#if defined(_M_X64) || defined(_M_ARM64) || defined(__x86_64__) || defined(__aarch64__) +#if defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__x86_64__) || defined(__aarch64__) #define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, test_name, ::testing::Test, Body,, CV__TEST_BIGDATA_BODY_IMPL) #else #define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, DISABLED_ ## test_name, ::testing::Test, Body,, CV__TEST_BIGDATA_BODY_IMPL)