From c5a80193a8de6a3d70fbe184e21513836851e54a Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 26 Feb 2015 12:53:37 +0300 Subject: [PATCH] aarch64 support --- 3rdparty/libpng/CMakeLists.txt | 2 +- CMakeLists.txt | 4 ++-- cmake/OpenCVDetectCUDA.cmake | 9 +++++++-- cmake/OpenCVDetectCXXCompiler.cmake | 4 +++- modules/core/include/opencv2/core/cvdef.h | 2 +- modules/core/src/system.cpp | 6 +++++- modules/cudalegacy/test/TestHaarCascadeApplication.cpp | 6 +++--- modules/cudalegacy/test/test_precomp.hpp | 2 +- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index 0abb68f9f..7e0243c45 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -14,7 +14,7 @@ ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS}) file(GLOB lib_srcs *.c) file(GLOB lib_hdrs *.h) -if(NEON AND CMAKE_SIZEOF_VOID_P EQUAL 4) +if(NEON AND ARM) list(APPEND lib_srcs arm/filter_neon.S) add_definitions(-DPNG_ARM_NEON) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 5146a12bd..3e158e569 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,8 +225,8 @@ OCV_OPTION(ENABLE_POPCNT "Enable POPCNT instructions" OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_AVX2 "Enable AVX2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_FMA3 "Enable FMA3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) -OCV_OPTION(ENABLE_NEON "Enable NEON instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR IOS) ) -OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR IOS) ) +OCV_OPTION(ENABLE_NEON "Enable NEON instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) ) +OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) ) OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF ) OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF ) OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 ) diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index e633acffa..7c3294916 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -80,8 +80,13 @@ if(CUDA_FOUND) if(NOT DEFINED __cuda_arch_bin) if(ANDROID) - set(__cuda_arch_bin "3.2") - set(__cuda_arch_ptx "") + if(ARM) + set(__cuda_arch_bin "3.2") + set(__cuda_arch_ptx "") + elseif(AARCH64) + set(__cuda_arch_bin "5.2") + set(__cuda_arch_ptx "") + endif() else() if(${CUDA_VERSION} VERSION_LESS "5.0") set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0") diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index 819c2e0c5..55156ddf8 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -107,8 +107,10 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") set(X86_64 1) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*") set(X86 1) -elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*|ARM.*") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") set(ARM 1) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") + set(AARCH64 1) endif() diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 3fdaa6954..bd0e44e7c 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -191,7 +191,7 @@ # include "arm_neon.h" # define CV_NEON 1 # define CPU_HAS_NEON_FEATURE (true) -#elif defined(__ARM_NEON__) +#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) # include # define CV_NEON 1 #endif diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 43d5bd0a0..0fd9f084a 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -319,6 +319,9 @@ struct HWFeatures } #if defined ANDROID || defined __linux__ + #ifdef __aarch64__ + f.have[CV_CPU_NEON] = true; + #else int cpufile = open("/proc/self/auxv", O_RDONLY); if (cpufile >= 0) @@ -337,7 +340,8 @@ struct HWFeatures close(cpufile); } - #elif (defined __clang__ || defined __APPLE__) && defined __ARM_NEON__ + #endif + #elif (defined __clang__ || defined __APPLE__) && (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__)) f.have[CV_CPU_NEON] = true; #endif diff --git a/modules/cudalegacy/test/TestHaarCascadeApplication.cpp b/modules/cudalegacy/test/TestHaarCascadeApplication.cpp index 121f31e43..b7c389e55 100644 --- a/modules/cudalegacy/test/TestHaarCascadeApplication.cpp +++ b/modules/cudalegacy/test/TestHaarCascadeApplication.cpp @@ -52,7 +52,7 @@ namespace ~FpuControl(); private: - #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) + #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) && !defined(__aarch64__) fpu_control_t fpu_oldcw, fpu_cw; #elif defined(_WIN32) && !defined(_WIN64) unsigned int fpu_oldcw, fpu_cw; @@ -61,7 +61,7 @@ namespace FpuControl::FpuControl() { - #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) + #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) && !defined(__aarch64__) _FPU_GETCW(fpu_oldcw); fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_DOUBLE & ~_FPU_SINGLE) | _FPU_SINGLE; _FPU_SETCW(fpu_cw); @@ -74,7 +74,7 @@ namespace FpuControl::~FpuControl() { - #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) + #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) && !defined(__aarch64__) _FPU_SETCW(fpu_oldcw); #elif defined(_WIN32) && !defined(_WIN64) _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC); diff --git a/modules/cudalegacy/test/test_precomp.hpp b/modules/cudalegacy/test/test_precomp.hpp index 727b40d83..41314da52 100644 --- a/modules/cudalegacy/test/test_precomp.hpp +++ b/modules/cudalegacy/test/test_precomp.hpp @@ -51,7 +51,7 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) +#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__arm__) && !defined(__aarch64__) #include #endif