Improvements related to arm support (#16892)

This commit is contained in:
Ilya Lavrenov 2023-04-12 23:02:57 +04:00 committed by GitHub
parent bee357bcf8
commit 418f70abb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 62 deletions

View File

@ -31,14 +31,6 @@ pr:
- 'tools/*'
- 'tests/layer_tests/*'
resources:
repositories:
- repository: openvino_contrib
type: github
endpoint: openvinotoolkit
name: openvinotoolkit/openvino_contrib
ref: master
variables:
- group: github
@ -56,7 +48,6 @@ jobs:
VSTS_HTTP_TIMEOUT: 200
BUILD_TYPE: Release
OPENVINO_REPO_DIR: $(Build.Repository.LocalPath)
OPENVINO_CONTRIB_REPO_DIR: $(OPENVINO_REPO_DIR)/../openvino_contrib
WORK_DIR: $(Pipeline.Workspace)/_w
BUILD_DIR: $(WORK_DIR)/build
ANDROID_TOOLS: $(WORK_DIR)/android_tools
@ -121,11 +112,6 @@ jobs:
submodules: 'true'
path: openvino
- checkout: openvino_contrib
clean: 'true'
submodules: 'true'
path: openvino_contrib
- script: |
set -e
sudo -E $(OPENVINO_REPO_DIR)/install_build_dependencies.sh
@ -156,11 +142,7 @@ jobs:
-DANDROID_STL=c++_shared
-DANDROID_PLATFORM=$(ANDROID_SDK_VERSION)
-DENABLE_TESTS=ON
-DBUILD_java_api=ON
-DBUILD_nvidia_plugin=OFF
-DBUILD_custom_operations=OFF
-DENABLE_INTEL_GPU=ON
-DOPENVINO_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
-DCMAKE_CXX_LINKER_LAUNCHER=ccache
-DCMAKE_C_LINKER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

View File

@ -198,7 +198,6 @@ jobs:
-DTHREADING=TBB
-DTBB_DIR=$(INSTALL_ONETBB)/lib/cmake/TBB
-DCMAKE_VERBOSE_MAKEFILE=ON
-DOPENVINO_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules/arm_plugin
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_LINKER_LAUNCHER=ccache

View File

@ -83,6 +83,13 @@ ie_add_plugin(NAME ${TARGET_NAME}
VERSION_DEFINES_FOR src/plugin.cpp
SOURCES ${SOURCES} ${HEADERS})
# give a different file name depending on target platform architecture
if(ARM OR AARCH64)
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "openvino_arm_cpu_plugin")
elseif(RISCV64)
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "openvino_risv_cpu_plugin")
endif()
set_ie_threading_interface_for(${TARGET_NAME})
ie_mark_target_as_cc(${TARGET_NAME})

@ -1 +1 @@
Subproject commit 1b3192e8a23513031163dc14d248f47671986121
Subproject commit d8bf9b53752a4f573120cf51b31055de8b3c7d29

View File

@ -1,4 +1,4 @@
# Copyright (C) 2018-2022 Intel Corporation
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
@ -22,38 +22,37 @@ if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR)
set_target_properties(arm_compute PROPERTIES
IMPORTED_LOCATION ${ARM_COMPUTE_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR})
find_library(
ARM_COMPUTE_CORE_LIB
arm_compute_core-static
PATHS ${ARM_COMPUTE_LIB_DIR}
)
message(STATUS "Found arm_compute_core-static: ${ARM_COMPUTE_CORE_LIB}")
add_library(arm_compute_core STATIC IMPORTED GLOBAL)
set_target_properties(arm_compute_core PROPERTIES
IMPORTED_LOCATION ${ARM_COMPUTE_CORE_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR})
endif()
add_library(half INTERFACE IMPORTED GLOBAL)
set_target_properties(half PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_INCLUDE_DIR})
else()
set(ARM_COMPUTE_SOURCE_DIR ${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary)
set(ARM_COMPUTE_BINARY_DIR ${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary)
message(STATUS "Configure to build ${ARM_COMPUTE_SOURCE_DIR}")
find_host_program(SCONS scons)
if(NOT SCONS)
message(FATAL_ERROR "Scons tool is not found!")
endif()
set(ARM_COMPUTE_SOURCE_DIR ${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary)
set(ARM_COMPUTE_BINARY_DIR ${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary)
file(GLOB_RECURSE SOURCES
${ARM_COMPUTE_SOURCE_DIR}/*.cpp
${ARM_COMPUTE_SOURCE_DIR}/*.hpp
${ARM_COMPUTE_SOURCE_DIR}/*.h
)
set(extra_cxx_flags "-fPIC ${CMAKE_CXX_FLAGS} -Wno-undef")
set(extra_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-undef")
if(MSVC64)
# clang-cl does not recognize /MP option
string(REPLACE "/MP " "" extra_cxx_flags "${extra_cxx_flags}")
else()
# -fPIC is not applicable for clang-cl
set(extra_cxx_flags "${extra_cxx_flags} -fPIC")
endif()
set(ARM_COMPUTE_OPTIONS
neon=1
@ -72,20 +71,32 @@ else()
# build_config=<file>
# TODO: use data_type_support to disable useless kernels
data_layout_support=all
build_dir=${ARM_COMPUTE_BINARY_DIR}
install_dir=${ARM_COMPUTE_BINARY_DIR}/install
arch=${ARM_COMPUTE_TARGET_ARCH}
)
if(NOT MSVC64)
list(APPEND ARM_COMPUTE_OPTIONS
build_dir=${ARM_COMPUTE_BINARY_DIR}
install_dir=${ARM_COMPUTE_BINARY_DIR}/install)
endif()
if(ARM_COMPUTE_SCONS_JOBS)
list(APPEND ARM_COMPUTE_OPTIONS --jobs=${ARM_COMPUTE_SCONS_JOBS})
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND ARM_COMPUTE_OPTIONS
debug=1
asserts=1
logging=1)
set(ARM_COMPUTE_DEBUG_OPTIONS
debug=1
asserts=1
logging=1)
# cmake older 3.20 does not support generator expressions in add_custom_command
# https://cmake.org/cmake/help/latest/command/add_custom_command.html#examples-generating-files
if(OV_GENERATOR_MULTI_CONFIG AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
foreach(option IN LISTS ARM_COMPUTE_DEBUG_OPTIONS)
list(APPEND ARM_COMPUTE_OPTIONS $<$<CONFIG:Debug>:${option}>)
endforeach()
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND ARM_COMPUTE_OPTIONS ${ARM_COMPUTE_DEBUG_OPTIONS})
endif()
if(EMSCRIPTEN OR LINUX)
@ -94,6 +105,8 @@ else()
list(APPEND ARM_COMPUTE_OPTIONS os=android)
elseif(APPLE)
list(APPEND ARM_COMPUTE_OPTIONS os=macos)
elseif(WIN32)
list(APPEND ARM_COMPUTE_OPTIONS os=windows)
endif()
if(CMAKE_CROSSCOMPILING)
@ -138,6 +151,7 @@ else()
get_filename_component(cxx_compiler "${CMAKE_CXX_COMPILER}" NAME)
get_filename_component(c_compiler "${CMAKE_C_COMPILER}" NAME)
get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY)
set(cmake_build_env
CC=${c_compiler}
CXX=${cxx_compiler})
@ -183,6 +197,16 @@ else()
set(extra_cxx_flags "${extra_cxx_flags} -arch ${arch}")
endforeach()
endif()
elseif(MSVC64)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
set(extra_cxx_flags "${extra_cxx_flags} $<IF:$<CONFIG:Release>,/MD,/MDd>")
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(extra_cxx_flags "${extra_cxx_flags} /MDd")
else()
set(extra_cxx_flags "${extra_cxx_flags} /MD")
endif()
endif()
endif()
if(ENABLE_LTO)
@ -192,6 +216,10 @@ else()
endif()
endif()
if(SUGGEST_OVERRIDE_SUPPORTED)
set(extra_cxx_flags "${extra_cxx_flags} -Wno-suggest-override")
endif()
if(extra_link_flags)
list(APPEND ARM_COMPUTE_OPTIONS extra_link_flags=${extra_link_flags})
endif()
@ -203,17 +231,20 @@ else()
list(APPEND ARM_COMPUTE_OPTIONS --silent)
endif()
set(arm_compute ${ARM_COMPUTE_BINARY_DIR}/libarm_compute-static.a)
set(arm_compute_core ${ARM_COMPUTE_BINARY_DIR}/libarm_compute_core-static.a)
if(MSVC64)
set(arm_compute build/arm_compute-static.lib)
set(arm_compute_full_path "${ARM_COMPUTE_SOURCE_DIR}/${arm_compute}")
else()
set(arm_compute ${ARM_COMPUTE_BINARY_DIR}/libarm_compute-static.a)
set(arm_compute_full_path "${arm_compute}")
endif()
add_custom_command(
OUTPUT
${arm_compute}
${arm_compute_core}
${arm_compute_full_path}
COMMAND ${CMAKE_COMMAND} -E env ${cmake_build_env}
${SCONS} ${ARM_COMPUTE_OPTIONS}
${arm_compute}
${arm_compute_core}
WORKING_DIRECTORY ${ARM_COMPUTE_SOURCE_DIR}
COMMENT "Build Arm Compute Library"
DEPENDS ${SOURCES}
@ -223,32 +254,26 @@ else()
# Import targets
add_custom_target(arm_compute_static_libs
DEPENDS
${arm_compute}
${arm_compute_core}
)
add_custom_target(arm_compute_static_libs DEPENDS ${arm_compute_full_path})
add_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL)
set_target_properties(arm_compute::arm_compute PROPERTIES
IMPORTED_LOCATION ${arm_compute}
IMPORTED_LOCATION ${arm_compute_full_path}
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR})
add_dependencies(arm_compute::arm_compute arm_compute_static_libs)
add_library(arm_compute::arm_compute_core STATIC IMPORTED GLOBAL)
set_target_properties(arm_compute::arm_compute_core PROPERTIES
IMPORTED_LOCATION ${arm_compute_core}
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR})
add_dependencies(arm_compute::arm_compute_core arm_compute_static_libs)
add_library(arm_compute::half INTERFACE IMPORTED GLOBAL)
set_target_properties(arm_compute::half PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}/include)
# Compute Library uses cppthreads=1
# if one day will rely on TBB only, we can omit this dependency
find_package(Threads REQUIRED)
set_target_properties(arm_compute::arm_compute PROPERTIES
INTERFACE_LINK_LIBRARIES Threads::Threads)
set(ACL_FOUND ON)
set(ACL_LIBRARIES arm_compute::arm_compute
arm_compute::arm_compute_core
arm_compute::half)
set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half)
foreach(acl_library IN LISTS ACL_LIBRARIES)
list(APPEND ACL_INCLUDE_DIRS