OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU][ARM] Refactor ACL build process (#31517)
Nesterov Alexander8495cbab6d9a
diff --git a/.gitignore b/.gitignoreindex a875a0b93b5..f0a0ea2c2d2 100644--- a/.gitignore+++ b/.gitignore@@ -64,5 +64,5 @@ coverage# Artifacts/tools/commit_slider/*.json/tools/commit_slider/slider_cache/*-/src/plugins/intel_cpu/thirdparty/ComputeLibrary/build/*-.github/GITHUB_OUTPUT\ No newline at end of file+/src/plugins/intel_cpu/thirdparty/ComputeLibrary/build/arm_compute_version.embed+.github/GITHUB_OUTPUTdiff --git a/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake b/src/plugins/intel_cpu/thirdparty/ACLConfig.cmakeindex 617be73dfdd..9caba914e62 100644--- a/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake+++ b/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake@@ -2,12 +2,30 @@# SPDX-License-Identifier: Apache-2.0#+include(ExternalProject)++# ==============================================================================+# ARM Compute Library Configuration+# ==============================================================================+# This file configures ARM Compute Library (ACL) for OpenVINO CPU plugin.+# It supports three modes:+# 1. Using pre-built ACL library (ARM_COMPUTE_LIB_DIR is set)+# 2. Building ACL using CMake (ENABLE_ARM_COMPUTE_CMAKE is set)+# 3. Building ACL using SCons (default)+# ==============================================================================++# ------------------------------------------------------------------------------+# Mode 1: Use pre-built ARM Compute Library+# ------------------------------------------------------------------------------if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR)set(ARM_COMPUTE_INCLUDE_DIR "" CACHE PATH "Path to ARM Compute Library headers" FORCE)if(NOT ARM_COMPUTE_LIB_DIR)message(FATAL_ERROR "Undefined ARM_COMPUTE_LIB_DIR input variable should be set manually")- elseif(NOT TARGET arm_compute::arm_compute)+ endif()++ if(NOT TARGET arm_compute::arm_compute)+ # Find library with proper configurationif(WIN32 OR APPLE)if(OV_GENERATOR_MULTI_CONFIG)set(extra_args PATH_SUFFIXES ${CMAKE_CONFIGURATION_TYPES})@@ -24,6 +42,7 @@ if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR)message(STATUS "Found arm_compute-static: ${ARM_COMPUTE_LIB}")+ # Create imported targetsadd_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL)set_target_properties(arm_compute::arm_compute PROPERTIESIMPORTED_LOCATION ${ARM_COMPUTE_LIB})@@ -36,8 +55,7 @@ if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR)endif()endif()- # for oneDNN integration-+ # Setup for oneDNN integrationset(ACL_FOUND ON)set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half)@@ -45,19 +63,21 @@ if(ARM_COMPUTE_INCLUDE_DIR OR ARM_COMPUTE_LIB_DIR)list(APPEND ACL_INCLUDE_DIRS$<TARGET_PROPERTY:${acl_library},INTERFACE_INCLUDE_DIRECTORIES>)endforeach()++# ------------------------------------------------------------------------------+# Mode 2: Build ACL using CMake+# ------------------------------------------------------------------------------elseif(ENABLE_ARM_COMPUTE_CMAKE)set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary")set(ARM_COMPUTE_BINARY_DIR "${intel_cpu_thirdparty_BINARY_DIR}/ComputeLibrary")function(ov_build_compute_library)- # build ComputeLibrary as static libraries+ # Configure ComputeLibrary buildset(BUILD_SHARED_LIBS OFF)- # ComputeLibrary settingsset(ARM_COMPUTE_GRAPH_ENABLED OFF CACHE BOOL "" FORCE)- # disable OpenMPset(OPENMP OFF CACHE BOOL "" FORCE)- # and use std::threads insteadset(CPPTHREADS OFF CACHE BOOL "" FORCE)+# SVE is not supported on Darwinif(CMAKE_HOST_APPLE)set(ENABLE_SVE OFF CACHE BOOL "" FORCE)@@ -74,8 +94,7 @@ elseif(ENABLE_ARM_COMPUTE_CMAKE)ov_build_compute_library()- # Helpers for oneDNN intergation-+ # Setup for oneDNN integrationset(ACL_FOUND ON)set(ACL_LIBRARIES arm_compute_core ArmCompute::Half)@@ -84,311 +103,380 @@ elseif(ENABLE_ARM_COMPUTE_CMAKE)$<TARGET_PROPERTY:${acl_library},INTERFACE_INCLUDE_DIRECTORIES>)endforeach()- # required by oneDNN to attempt to parse ACL versionset(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}")-elseif(NOT TARGET arm_compute::arm_compute)- #- # Options- #- set(ARM_COMPUTE_SCONS_JOBS "8" CACHE STRING "Number of parallel threads to build ARM Compute Library")+# ------------------------------------------------------------------------------+# Mode 3: Build ACL using SCons (default)+# ------------------------------------------------------------------------------+elseif(NOT TARGET arm_compute::arm_compute)- #- # Configure & build- #+ # ==========================================================================+ # Initial Setup+ # ==========================================================================+ set(ARM_COMPUTE_SCONS_JOBS "8" CACHE STRING "Number of parallel threads to build ARM Compute Library")set(ARM_COMPUTE_SOURCE_DIR "${intel_cpu_thirdparty_SOURCE_DIR}/ComputeLibrary")message(STATUS "Configure to build ${ARM_COMPUTE_SOURCE_DIR}")+ # Find SCons build toolif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)list(APPEND find_scons_extra_options REQUIRED)endif()find_host_program(SCONS scons ${find_scons_extra_options})-if(NOT SCONS)message(FATAL_ERROR "Scons tool is not found!")endif()- file(GLOB_RECURSE SOURCES- ${ARM_COMPUTE_SOURCE_DIR}/*.cpp- ${ARM_COMPUTE_SOURCE_DIR}/*.hpp- ${ARM_COMPUTE_SOURCE_DIR}/*.h- )-- 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}")- elseif(CMAKE_POSITION_INDEPENDENT_CODE)- # -fPIC is not applicable for clang-cl- set(extra_cxx_flags "${extra_cxx_flags} -fPIC")+ # Set build directory+ if(DEFINED intel_cpu_thirdparty_BINARY_DIR)+ set(ARM_COMPUTE_BUILD_DIR "${intel_cpu_thirdparty_BINARY_DIR}/acl_build" CACHE PATH "Path to ARM Compute Library build directory")+ else()+ set(ARM_COMPUTE_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/acl_build" CACHE PATH "Path to ARM Compute Library build directory")endif()- set(ARM_COMPUTE_OPTIONS- neon=1- opencl=0- examples=0- Werror=0- gemm_tuner=0- reference_openmp=0- validation_tests=0- benchmark_tests=0- # TODO: use CC for ARM compute library to minimize binary size- # build_config=<file>- # TODO: use data_type_support to disable useless kernels- data_layout_support=all- arch=${OV_CPU_ARM_TARGET_ARCH}- build_dir=${OV_CPU_ARM_TARGET_ARCH}- )+ # ==========================================================================+ # Helper Functions+ # ==========================================================================++ # Helper function to add ARM Compute options with consistent formatting+ function(ov_arm_compute_add_option key value)+ list(APPEND ARM_COMPUTE_OPTIONS "${key}=${value}")+ set(ARM_COMPUTE_OPTIONS "${ARM_COMPUTE_OPTIONS}" PARENT_SCOPE)+ endfunction()++ # Helper function to configure platform-specific settings+ function(ov_arm_compute_configure_platform)+ # Android configuration+ if(ANDROID)+ if(ANDROID_PLATFORM_LEVEL LESS 18)+ message(FATAL_ERROR "ARM compute library requires Android API 18 level and higher"+ "Please, specify -DANDROID_PLATFORM=android-18 at least")+ endif()++ if(ANDROID_NDK_REVISION LESS "23.0")+ ov_arm_compute_add_option("toolchain_prefix" "${ANDROID_TOOLCHAIN_PREFIX}")+ else()+ string(REGEX REPLACE "/bin/[^/]+-" "/bin/llvm-" ANDROID_TOOLCHAIN_PREFIX_FIXED "${ANDROID_TOOLCHAIN_PREFIX}")+ message(STATUS "SCONS: using ANDROID_TOOLCHAIN_PREFIX=${ANDROID_TOOLCHAIN_PREFIX_FIXED}")+ ov_arm_compute_add_option("toolchain_prefix" "${ANDROID_TOOLCHAIN_PREFIX_FIXED}")+ endif()++ ov_arm_compute_add_option("compiler_prefix" "${ANDROID_TOOLCHAIN_ROOT}/bin/")++ set(extra_cc_flags "--target=${ANDROID_LLVM_TRIPLE}" PARENT_SCOPE)+ set(extra_flags "${extra_flags} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT}" PARENT_SCOPE)+ set(extra_flags "${extra_flags} --sysroot=${CMAKE_SYSROOT}" PARENT_SCOPE)++ # Linux configuration+ elseif(LINUX)+ 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} PARENT_SCOPE)+ ov_arm_compute_add_option("compiler_prefix" "${compiler_prefix}/")++ # Emscripten configuration+ elseif(EMSCRIPTEN)+ set(cmake_build_env+ CC=emcc+ CXX=em+++ RANLIB=emranlib+ AR=emar PARENT_SCOPE)++ get_filename_component(toolchain_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY)+ ov_arm_compute_add_option("toolchain_prefix" "${toolchain_prefix}/")++ # Apple/macOS configuration+ elseif(APPLE)+ 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} PARENT_SCOPE)++ ov_arm_compute_add_option("compiler_prefix" "${compiler_prefix}/")+ endif()++ set(ARM_COMPUTE_OPTIONS "${ARM_COMPUTE_OPTIONS}" PARENT_SCOPE)+ endfunction()++ # Helper function to configure compiler flags+ function(ov_arm_compute_configure_flags)+ set(local_extra_cxx_flags "${extra_cxx_flags}")+ set(local_extra_link_flags "${extra_link_flags}")+ set(local_extra_cc_flags "${extra_cc_flags}")++ # Platform-specific flags+ if(ANDROID)+ set(extra_flags "${extra_flags} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT}")+ set(extra_flags "${extra_flags} --sysroot=${CMAKE_SYSROOT}")+ set(local_extra_link_flags "${local_extra_link_flags} ${extra_flags}")+ set(local_extra_cxx_flags "${local_extra_cxx_flags} ${extra_flags}")++ elseif(EMSCRIPTEN)+ # EMSDK: Passing any of -msse, -msse2, -msse3, -mssse3, -msse4.1, -msse4.2,+ # -msse4, -mavx, -mfpu=neon flags also requires passing -msimd128 (or -mrelaxed-simd)!+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -msimd128")+ # clang-16: error: argument unused during compilation: '-mthumb' [-Werror,-Wunused-command-line-argument]+ # clang-16: error: argument unused during compilation: '-mfloat-abi=hard' [-Werror,-Wunused-command-line-argument]+ set(local_extra_cxx_flags "${local_extra_cxx_flags} \+ -Wno-unused-command-line-argument \+ -Wno-unknown-warning-option \+ -Wno-unused-function \+ -Wno-unused-but-set-variable")++ elseif(APPLE)+ if(CMAKE_OSX_DEPLOYMENT_TARGET)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")+ endif()++ if(HOST_X86_64 AND CMAKE_OSX_SYSROOT)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} --sysroot ${CMAKE_OSX_SYSROOT}")+ endif()++ if(OV_COMPILER_IS_CLANG)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -Wno-error=return-stack-address")+ endif()++ if(CMAKE_OSX_ARCHITECTURES)+ foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -arch ${arch}")+ endforeach()+ endif()++ elseif(MSVC64)+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} $<IF:$<CONFIG:Release>,/MD,/MDd>")+ else()+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")+ set(local_extra_cxx_flags "${local_extra_cxx_flags} /MDd")+ else()+ set(local_extra_cxx_flags "${local_extra_cxx_flags} /MD")+ endif()+ endif()+ endif()++ # LTO configuration+ if(ENABLE_LTO AND NOT CMAKE_CROSSCOMPILING)+ if(CMAKE_COMPILER_IS_GNUCXX)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -flto -fno-fat-lto-objects")+ set(local_extra_link_flags "${local_extra_link_flags} -flto -fno-fat-lto-objects")+ elseif(OV_COMPILER_IS_CLANG)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -flto=thin")+ set(local_extra_link_flags "${local_extra_link_flags} -flto=thin")+ endif()+ endif()++ # Warning suppression+ if(SUGGEST_OVERRIDE_SUPPORTED)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -Wno-suggest-override")+ endif()++ # Multi-ISA support+ if(NOT ARM AND OV_CPU_AARCH64_USE_MULTI_ISA)+ set(local_extra_cxx_flags "${local_extra_cxx_flags} -DENABLE_SME -DARM_COMPUTE_ENABLE_SME -DARM_COMPUTE_ENABLE_SME2")+ endif()++ # Export flags+ set(extra_cxx_flags "${local_extra_cxx_flags}" PARENT_SCOPE)+ set(extra_link_flags "${local_extra_link_flags}" PARENT_SCOPE)+ set(extra_cc_flags "${local_extra_cc_flags}" PARENT_SCOPE)+ endfunction()+ # ==========================================================================+ # Configure Build Options+ # ==========================================================================++ set(ARM_COMPUTE_OPTIONS)++ # Basic configuration options+ ov_arm_compute_add_option("neon" "1")+ ov_arm_compute_add_option("opencl" "0")+ ov_arm_compute_add_option("examples" "0")+ ov_arm_compute_add_option("Werror" "0")+ ov_arm_compute_add_option("gemm_tuner" "0")+ ov_arm_compute_add_option("reference_openmp" "0")+ ov_arm_compute_add_option("validation_tests" "0")+ ov_arm_compute_add_option("benchmark_tests" "0")+ ov_arm_compute_add_option("data_layout_support" "all")+ ov_arm_compute_add_option("arch" "${OV_CPU_ARM_TARGET_ARCH}")+ ov_arm_compute_add_option("build_dir" "${OV_CPU_ARM_TARGET_ARCH}")++ # Threading configurationif(THREADING STREQUAL "OMP")- list(APPEND ARM_COMPUTE_OPTIONS openmp=1- cppthreads=0)+ ov_arm_compute_add_option("openmp" "1")+ ov_arm_compute_add_option("cppthreads" "0")else()- list(APPEND ARM_COMPUTE_OPTIONS openmp=0- cppthreads=1)+ ov_arm_compute_add_option("openmp" "0")+ ov_arm_compute_add_option("cppthreads" "1")endif()+ # Architecture configurationif(ARM)- list(APPEND ARM_COMPUTE_OPTIONS estate=32)+ ov_arm_compute_add_option("estate" "32")else()- list(APPEND ARM_COMPUTE_OPTIONS estate=64)+ ov_arm_compute_add_option("estate" "64")if(OV_CPU_AARCH64_USE_MULTI_ISA)- list(APPEND ARM_COMPUTE_OPTIONS multi_isa=1)- # let's additionally enable SME as well- set(extra_cxx_flags "${extra_cxx_flags} -DENABLE_SME -DARM_COMPUTE_ENABLE_SME -DARM_COMPUTE_ENABLE_SME2")+ ov_arm_compute_add_option("multi_isa" "1")endif()endif()+ # Install directoryif(NOT MSVC64)- list(APPEND ARM_COMPUTE_OPTIONS- install_dir=install)+ ov_arm_compute_add_option("install_dir" "install")endif()+ # Build jobsif(ARM_COMPUTE_SCONS_JOBS)- list(APPEND ARM_COMPUTE_OPTIONS --jobs=${ARM_COMPUTE_SCONS_JOBS})+ ov_arm_compute_add_option("--jobs" "${ARM_COMPUTE_SCONS_JOBS}")endif()- set(ARM_COMPUTE_DEBUG_OPTIONS- debug=1- asserts=1- logging=1)+ # Debug options+ 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-filesif(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}>- $<$<CONFIG:RelWithDebInfo>:${option}>)- endforeach()- foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)- string(TOUPPER "${config}" config_upper)- set(flags ${CMAKE_CXX_FLAGS_${config_upper}})- set(extra_cxx_flags "${extra_cxx_flags} $<$<CONFIG:${config}>:${flags}>")+ list(APPEND ARM_COMPUTE_OPTIONS+ $<$<CONFIG:Debug>:${option}>+ $<$<CONFIG:RelWithDebInfo>:${option}>)endforeach()elseif(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")- list(APPEND ARM_COMPUTE_OPTIONS ${ARM_COMPUTE_DEBUG_OPTIONS})+ foreach(option IN LISTS ARM_COMPUTE_DEBUG_OPTIONS)+ list(APPEND ARM_COMPUTE_OPTIONS ${option})+ endforeach()endif()+ # OS configurationif(EMSCRIPTEN OR LINUX)- list(APPEND ARM_COMPUTE_OPTIONS os=linux)+ ov_arm_compute_add_option("os" "linux")elseif(ANDROID)- list(APPEND ARM_COMPUTE_OPTIONS os=android)+ ov_arm_compute_add_option("os" "android")elseif(APPLE)- list(APPEND ARM_COMPUTE_OPTIONS os=macos)+ ov_arm_compute_add_option("os" "macos")elseif(WIN32)- list(APPEND ARM_COMPUTE_OPTIONS os=windows)+ ov_arm_compute_add_option("os" "windows")endif()+ # Build typeif(CMAKE_CROSSCOMPILING)- list(APPEND ARM_COMPUTE_OPTIONS build=cross_compile)+ ov_arm_compute_add_option("build" "cross_compile")else()- list(APPEND ARM_COMPUTE_OPTIONS build=native)+ ov_arm_compute_add_option("build" "native")endif()- if (CMAKE_CXX_COMPILER_LAUNCHER)- list(APPEND ARM_COMPUTE_OPTIONS compiler_cache=${CMAKE_CXX_COMPILER_LAUNCHER})+ # Compiler cache+ if(CMAKE_CXX_COMPILER_LAUNCHER)+ ov_arm_compute_add_option("compiler_cache" "${CMAKE_CXX_COMPILER_LAUNCHER}")endif()- # used to build for yocto+ # Toolchain prefix (for Yocto builds)if(ARM_COMPUTE_TOOLCHAIN_PREFIX)- list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix=${ARM_COMPUTE_TOOLCHAIN_PREFIX})+ ov_arm_compute_add_option("toolchain_prefix" "${ARM_COMPUTE_TOOLCHAIN_PREFIX}")endif()- if(ANDROID)- if(ANDROID_PLATFORM_LEVEL LESS 18)- message(FATAL_ERROR "ARM compute library requires Android API 18 level and higher"- "Please, speficy -DANDROID_PLATFORM=android-18 at least")- endif()+ # ==========================================================================+ # Platform-specific Configuration+ # ==========================================================================- if(ANDROID_NDK_REVISION LESS "23.0")- list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX}")- else()- string(REGEX REPLACE "/bin/[^/]+-" "/bin/llvm-" ANDROID_TOOLCHAIN_PREFIX_FIXED "${ANDROID_TOOLCHAIN_PREFIX}")- message(STATUS "SCONS: using ANDROID_TOOLCHAIN_PREFIX=${ANDROID_TOOLCHAIN_PREFIX_FIXED}")- list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${ANDROID_TOOLCHAIN_PREFIX_FIXED}")- endif()-- list(APPEND ARM_COMPUTE_OPTIONS- compiler_prefix="${ANDROID_TOOLCHAIN_ROOT}/bin/")-- set(extra_cc_flags "--target=${ANDROID_LLVM_TRIPLE}")- set(extra_flags "${extra_flags} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT}")- set(extra_flags "${extra_flags} --sysroot=${CMAKE_SYSROOT}")-- set(extra_link_flags "${extra_link_flags} ${extra_flags}")- set(extra_cxx_flags "${extra_cxx_flags} ${extra_flags}")- elseif(LINUX)- # we need to bypass this information in case of custom compiler is passed- # to cmake call. Such compiler and compiler prefix need to be passed to scons- 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})- list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/")- elseif(EMSCRIPTEN)- set(cmake_build_env- CC=emcc- CXX=em++- RANLIB=emranlib- AR=emar)- # EMSDK: Passing any of -msse, -msse2, -msse3, -mssse3, -msse4.1, -msse4.2,- # -msse4, -mavx, -mfpu=neon flags also requires passing -msimd128 (or -mrelaxed-simd)!- set(extra_cxx_flags "${extra_cxx_flags} -msimd128")- # clang-16: error: argument unused during compilation: '-mthumb' [-Werror,-Wunused-command-line-argument]- # clang-16: error: argument unused during compilation: '-mfloat-abi=hard' [-Werror,-Wunused-command-line-argument]- set(extra_cxx_flags "${extra_cxx_flags} \- -Wno-unused-command-line-argument \- -Wno-unknown-warning-option \- -Wno-unused-function \- -Wno-unused-but-set-variable")-- get_filename_component(toolchain_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY)- list(APPEND ARM_COMPUTE_OPTIONS toolchain_prefix="${toolchain_prefix}/")- elseif(APPLE)- # we need to bypass this information in case of custom compiler is passed- # to cmake call. Such compiler and compiler prefix need to be passed to scons- 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})-- if(CMAKE_OSX_DEPLOYMENT_TARGET)- set(extra_cxx_flags "${extra_cxx_flags} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")- set(minos_added ON)- endif()-- if(HOST_X86_64)- if(NOT minos_added)- message(FATAL_ERROR "Please, specify either env MACOSX_DEPLOYMENT_TARGET or cmake CMAKE_OSX_DEPLOYMENT_TARGET variables")- endif()- set(extra_cxx_flags "${extra_cxx_flags} --sysroot ${CMAKE_OSX_SYSROOT}")- endif()- if(OV_COMPILER_IS_CLANG)- set(extra_cxx_flags "${extra_cxx_flags} -Wno-error=return-stack-address")- endif()- get_filename_component(compiler_prefix "${CMAKE_CXX_COMPILER}" DIRECTORY)- list(APPEND ARM_COMPUTE_OPTIONS compiler_prefix="${compiler_prefix}/")-- if(CMAKE_OSX_ARCHITECTURES)- foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES)- set(extra_cxx_flags "${extra_cxx_flags} -arch ${arch}")- endforeach()- endif()- elseif(MSVC64)- # required for clang-cl compiler- 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()+ # Initialize flags+ set(extra_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-undef")+ if(MSVC64)+ string(REPLACE "/MP " "" extra_cxx_flags "${extra_cxx_flags}")+ elseif(CMAKE_POSITION_INDEPENDENT_CODE)+ set(extra_cxx_flags "${extra_cxx_flags} -fPIC")endif()- if(ENABLE_LTO)- if(NOT CMAKE_CROSSCOMPILING)- if(CMAKE_COMPILER_IS_GNUCXX)- set(extra_cxx_flags "${extra_cxx_flags} -flto -fno-fat-lto-objects")- set(extra_link_flags "${extra_link_flags} -flto -fno-fat-lto-objects")- elseif(OV_COMPILER_IS_CLANG)- set(extra_cxx_flags "${extra_cxx_flags} -flto=thin")- set(extra_link_flags "${extra_link_flags} -flto=thin")- endif()- endif()- endif()+ # Configure platform+ ov_arm_compute_configure_platform()- if(SUGGEST_OVERRIDE_SUPPORTED)- set(extra_cxx_flags "${extra_cxx_flags} -Wno-suggest-override")- endif()+ # Configure compiler flags+ ov_arm_compute_configure_flags()+ # Add extra flags to optionsif(extra_link_flags)- list(APPEND ARM_COMPUTE_OPTIONS extra_link_flags=${extra_link_flags})+ ov_arm_compute_add_option("extra_link_flags" "${extra_link_flags}")endif()if(extra_cxx_flags)- list(APPEND ARM_COMPUTE_OPTIONS extra_cxx_flags=${extra_cxx_flags})+ ov_arm_compute_add_option("extra_cxx_flags" "${extra_cxx_flags}")endif()if(extra_cc_flags)- list(APPEND ARM_COMPUTE_OPTIONS extra_cc_flags=${extra_cc_flags})+ ov_arm_compute_add_option("extra_cc_flags" "${extra_cc_flags}")endif()+ # Verbosityif(NOT CMAKE_VERBOSE_MAKEFILE)- list(APPEND ARM_COMPUTE_OPTIONS --silent)+ list(APPEND ARM_COMPUTE_OPTIONS "--silent")endif()+ # Fixed format kernels+ ov_arm_compute_add_option("fixed_format_kernels" "True")++ # ==========================================================================+ # Build Configuration+ # ==========================================================================++ # Set output library nameif(MSVC64)set(arm_compute build/${OV_CPU_ARM_TARGET_ARCH}/arm_compute-static.lib)else()set(arm_compute build/${OV_CPU_ARM_TARGET_ARCH}/libarm_compute-static.a)endif()- set(arm_compute_full_path "${ARM_COMPUTE_SOURCE_DIR}/${arm_compute}")-- list(APPEND ARM_COMPUTE_OPTIONS fixed_format_kernels=True)-- add_custom_command(- OUTPUT- ${arm_compute_full_path}- COMMAND ${CMAKE_COMMAND} -E env ${cmake_build_env}- ${SCONS} ${ARM_COMPUTE_OPTIONS}- ${arm_compute}- WORKING_DIRECTORY ${ARM_COMPUTE_SOURCE_DIR}- COMMENT "Build Arm Compute Library"- DEPENDS ${SOURCES}- ${CMAKE_CURRENT_LIST_FILE}- ${ARM_COMPUTE_SOURCE_DIR}/SConscript- ${ARM_COMPUTE_SOURCE_DIR}/SConstruct)-- # Compute Library uses cppthreads=1- # if one day will rely on TBB only, we can omit this dependency- find_package(Threads REQUIRED)- # Import targets+ # Configure and build ACL using ExternalProject+ ExternalProject_Add(arm_compute_build+ PREFIX ${ARM_COMPUTE_BUILD_DIR}+ SOURCE_DIR ${ARM_COMPUTE_SOURCE_DIR}+ CONFIGURE_COMMAND ""+ BUILD_COMMAND ${CMAKE_COMMAND} -E env ${cmake_build_env}+ ${SCONS} ${ARM_COMPUTE_OPTIONS} ${arm_compute}+ BUILD_IN_SOURCE 1+ BUILD_BYPRODUCTS ${ARM_COMPUTE_BUILD_DIR}/${arm_compute}+ INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${ARM_COMPUTE_BUILD_DIR}/build/${OV_CPU_ARM_TARGET_ARCH}+ COMMAND ${CMAKE_COMMAND} -E copy_if_different+ ${ARM_COMPUTE_SOURCE_DIR}/build/${OV_CPU_ARM_TARGET_ARCH}/libarm_compute-static.a+ ${ARM_COMPUTE_BUILD_DIR}/build/${OV_CPU_ARM_TARGET_ARCH}/libarm_compute-static.a+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${ARM_COMPUTE_SOURCE_DIR}/build+ LOG_BUILD ${ENABLE_DEBUG_CAPS}+ )++ # Get the full path to the built library+ set(arm_compute_full_path "${ARM_COMPUTE_BUILD_DIR}/${arm_compute}")- add_custom_target(arm_compute_static_libs DEPENDS ${arm_compute_full_path})+ # Debug messages+ message(DEBUG "ACL build configuration:")+ message(DEBUG " ARM_COMPUTE_BUILD_DIR: ${ARM_COMPUTE_BUILD_DIR}")+ message(DEBUG " arm_compute: ${arm_compute}")+ message(DEBUG " arm_compute_full_path: ${arm_compute_full_path}")+ # ==========================================================================+ # Create Imported Targets+ # ==========================================================================++ find_package(Threads REQUIRED)++ # Create imported targetsadd_library(arm_compute::arm_compute STATIC IMPORTED GLOBAL)set_target_properties(arm_compute::arm_compute PROPERTIESIMPORTED_LOCATION ${arm_compute_full_path}INTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}INTERFACE_LINK_LIBRARIES Threads::ThreadsOSX_ARCHITECTURES arm64)- add_dependencies(arm_compute::arm_compute arm_compute_static_libs)+ add_dependencies(arm_compute::arm_compute arm_compute_build)add_library(arm_compute::half INTERFACE IMPORTED GLOBAL)set_target_properties(arm_compute::half PROPERTIESINTERFACE_INCLUDE_DIRECTORIES ${ARM_COMPUTE_SOURCE_DIR}/include)- # Helpers for oneDNN intergation+ # ==========================================================================+ # Setup for oneDNN Integration+ # ==========================================================================set(ACL_FOUND ON)set(ACL_LIBRARIES arm_compute::arm_compute arm_compute::half)@@ -398,6 +486,8 @@ elseif(NOT TARGET arm_compute::arm_compute)$<TARGET_PROPERTY:${acl_library},INTERFACE_INCLUDE_DIRECTORIES>)endforeach()- # required by oneDNN to attempt to parse ACL version+ # Required by oneDNN to parse ACL versionset(ACL_INCLUDE_DIR "${ARM_COMPUTE_SOURCE_DIR}")+ set(ENV{ACL_ROOT_DIR} "${ARM_COMPUTE_SOURCE_DIR}")endif()+diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txtindex a99dbc3bd61..d32a2b0088d 100644--- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt+++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt@@ -22,7 +22,9 @@ function(ov_create_acl_version_file)string(REGEX MATCH "v([0-9]+\\.[0-9]+\\.?[0-9]*)" ACL_VERSION "${ACL_SCONSCRIPT_FILE_CONTENT}")set(ACL_VERSION "${CMAKE_MATCH_1}")- set(ACL_VERSION_FILE_PATH "${ACL_ROOT_DIR}/build/${OV_CPU_ARM_TARGET_ARCH}/src/core/arm_compute_version.embed")+ # Create version file in build subdirectory where oneDNN expects it (glob pattern */arm_compute_version.embed)+ file(MAKE_DIRECTORY "${ACL_ROOT_DIR}/build")+ set(ACL_VERSION_FILE_PATH "${ACL_ROOT_DIR}/build/arm_compute_version.embed")file(WRITE ${ACL_VERSION_FILE_PATH} "\"arm_compute_version=v${ACL_VERSION}\"")endfunction()