1*c217d954SCole Faust# Copyright (c) 2023 Arm Limited. 2*c217d954SCole Faust# 3*c217d954SCole Faust# SPDX-License-Identifier: MIT 4*c217d954SCole Faust# 5*c217d954SCole Faust# Permission is hereby granted, free of charge, to any person obtaining a copy 6*c217d954SCole Faust# of this software and associated documentation files (the "Software"), to 7*c217d954SCole Faust# deal in the Software without restriction, including without limitation the 8*c217d954SCole Faust# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9*c217d954SCole Faust# sell copies of the Software, and to permit persons to whom the Software is 10*c217d954SCole Faust# furnished to do so, subject to the following conditions: 11*c217d954SCole Faust# 12*c217d954SCole Faust# The above copyright notice and this permission notice shall be included in all 13*c217d954SCole Faust# copies or substantial portions of the Software. 14*c217d954SCole Faust# 15*c217d954SCole Faust# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16*c217d954SCole Faust# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17*c217d954SCole Faust# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18*c217d954SCole Faust# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19*c217d954SCole Faust# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20*c217d954SCole Faust# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21*c217d954SCole Faust# SOFTWARE. 22*c217d954SCole Faust 23*c217d954SCole Faustcmake_minimum_required(VERSION 3.13 FATAL_ERROR) 24*c217d954SCole Faust 25*c217d954SCole Faust# --------------------------------------------------------------------- 26*c217d954SCole Faust# Project ArmCompute 27*c217d954SCole Faust 28*c217d954SCole Faustlist(APPEND CMAKE_MESSAGE_CONTEXT ArmCompute) 29*c217d954SCole Faustproject( 30*c217d954SCole Faust ArmCompute 31*c217d954SCole Faust VERSION 28.0.8 32*c217d954SCole Faust DESCRIPTION 33*c217d954SCole Faust "The Arm Compute Library is a collection of low-level machine learning functions optimized for Arm® Cortex®-A CPU and Arm® Mali™ GPU architectures" 34*c217d954SCole Faust LANGUAGES C CXX ASM) 35*c217d954SCole Faust 36*c217d954SCole Faustinclude(GNUInstallDirs) 37*c217d954SCole Faust 38*c217d954SCole Faustset(CMAKE_C_STANDARD 99) 39*c217d954SCole Faustset(CMAKE_C_STANDARD_REQUIRED ON) 40*c217d954SCole Faustset(CMAKE_C_EXTENSIONS OFF) 41*c217d954SCole Faust 42*c217d954SCole Faustset(CMAKE_CXX_STANDARD 14) 43*c217d954SCole Faustset(CMAKE_CXX_STANDARD_REQUIRED ON) 44*c217d954SCole Faustset(CMAKE_CXX_EXTENSIONS OFF) 45*c217d954SCole Faust 46*c217d954SCole Faustlist(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 47*c217d954SCole Faustinclude(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Options.cmake) 48*c217d954SCole Faustinclude(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.cmake) 49*c217d954SCole Faust 50*c217d954SCole Faust# Require at least gcc/g++ 11) CMAKE_CXX_COMPILER_VERSION OR 51*c217d954SCole Faustif(CMAKE_C_COMPILER_VERSION VERSION_LESS 10.2 OR CMAKE_CXX_COMPILER_VERSION 52*c217d954SCole Faust VERSION_LESS 10.2) 53*c217d954SCole Faust message( 54*c217d954SCole Faust FATAL_ERROR "gcc and g++ version => 10.2 is required for building project!") 55*c217d954SCole Faustendif() 56*c217d954SCole Faust 57*c217d954SCole Faust# --------------------------------------------------------------------- 58*c217d954SCole Faust# Configuration 59*c217d954SCole Faust 60*c217d954SCole Faust# Default to Release Build 61*c217d954SCole Faustif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 62*c217d954SCole Faust set(CMAKE_BUILD_TYPE 63*c217d954SCole Faust "Release" 64*c217d954SCole Faust CACHE 65*c217d954SCole Faust STRING 66*c217d954SCole Faust "Choose build type, available options are: Debug, Release, RelWithDebInfo" 67*c217d954SCole Faust FORCE) 68*c217d954SCole Faustendif() 69*c217d954SCole Faust 70*c217d954SCole Faust# --------------------------------------------------------------------- 71*c217d954SCole Faust# Information 72*c217d954SCole Faust 73*c217d954SCole Faustmessage(STATUS "Arm Compute Library ${PROJECT_VERSION}") 74*c217d954SCole Faust 75*c217d954SCole Faustmessage(VERBOSE "-----------------------------------------------------") 76*c217d954SCole Faustmessage(VERBOSE "Build information:") 77*c217d954SCole Faustlist(APPEND CMAKE_MESSAGE_INDENT " ") 78*c217d954SCole Faustmessage(VERBOSE "Host system: ${CMAKE_SYSTEM_NAME}") 79*c217d954SCole Faustmessage(VERBOSE "Host processor: ${CMAKE_SYSTEM_PROCESSOR}") 80*c217d954SCole Faustmessage(VERBOSE "Build path: ${CMAKE_CURRENT_BINARY_DIR}") 81*c217d954SCole Faustmessage(VERBOSE "Enable OpenCL acceleration: ${ENABLE_OPENCL}") 82*c217d954SCole Faustmessage(VERBOSE "Enable CPU acceleration: ${ENABLE_NEON}") 83*c217d954SCole Faustlist(POP_BACK CMAKE_MESSAGE_INDENT) 84*c217d954SCole Faustmessage(VERBOSE "-----------------------------------------------------") 85*c217d954SCole Faust 86*c217d954SCole Faust# --------------------------------------------------------------------- 87*c217d954SCole Faust# Compile options and features 88*c217d954SCole Faust 89*c217d954SCole Faustset(COMMON_CXX_FLAGS 90*c217d954SCole Faust -Wall 91*c217d954SCole Faust -DARCH_ARM 92*c217d954SCole Faust -Wextra 93*c217d954SCole Faust -Wdisabled-optimization 94*c217d954SCole Faust -Wformat=2 95*c217d954SCole Faust -Winit-self 96*c217d954SCole Faust -Wstrict-overflow=2 97*c217d954SCole Faust -Wswitch-default 98*c217d954SCole Faust -Woverloaded-virtual 99*c217d954SCole Faust -Wformat-security 100*c217d954SCole Faust -Wctor-dtor-privacy 101*c217d954SCole Faust -Wsign-promo 102*c217d954SCole Faust -Weffc++ 103*c217d954SCole Faust -Wno-overlength-strings 104*c217d954SCole Faust -Wno-ignored-attributes 105*c217d954SCole Faust -Wlogical-op 106*c217d954SCole Faust -Wnoexcept 107*c217d954SCole Faust -Wstrict-null-sentinel 108*c217d954SCole Faust -Wno-misleading-indentation 109*c217d954SCole Faust -O3) 110*c217d954SCole Faust 111*c217d954SCole Faust# Disable note popups on compiler ABI changes 112*c217d954SCole Faustif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 113*c217d954SCole Faust add_compile_options("-Wno-psabi") 114*c217d954SCole Faustendif() 115*c217d954SCole Faust 116*c217d954SCole Faust# Compile with -Werror if WERROR set 117*c217d954SCole Faustif(WERROR) 118*c217d954SCole Faust add_compile_options("-Werror") 119*c217d954SCole Faustendif() 120*c217d954SCole Faust 121*c217d954SCole Faust# Compile with debug flags and define ARM_COMPUTE_ASSERTS_ENABLED if DEBUG set 122*c217d954SCole Faustif(DEBUG) 123*c217d954SCole Faust add_compile_options("-O0" "-g" "-gdwarf-2") 124*c217d954SCole Faust add_definitions(-DARM_COMPUTE_ASSERTS_ENABLED) # ARM_COMPUTE_DEBUG_ENABLED ?? 125*c217d954SCole Faustendif() 126*c217d954SCole Faust 127*c217d954SCole Faust# Compile with -fno-exceptions flag and define ARM_COMPUTE_EXCEPTIONS_DISABLED 128*c217d954SCole Faust# if DEBUG set 129*c217d954SCole Faustif(NOT EXCEPTIONS) 130*c217d954SCole Faust add_compile_options("-fno-exceptions") 131*c217d954SCole Faust add_definitions(-DARM_COMPUTE_EXCEPTIONS_DISABLED) 132*c217d954SCole Faustendif() 133*c217d954SCole Faust 134*c217d954SCole Faust# Link OpenMP libraries if OPENMP flag on 135*c217d954SCole Faustif(OPENMP) 136*c217d954SCole Faust find_package(OpenMP) 137*c217d954SCole Faust if(OpenMP_CXX_FOUND) 138*c217d954SCole Faust link_libraries(OpenMP::OpenMP_CXX) 139*c217d954SCole Faust add_definitions(-DARM_COMPUTE_OPENMP_SCHEDULER) 140*c217d954SCole Faust else() 141*c217d954SCole Faust message(FATAL_ERROR "OPENMP was set but no OpenMP library was found!") 142*c217d954SCole Faust endif() 143*c217d954SCole Faustendif() 144*c217d954SCole Faust 145*c217d954SCole Faust# --------------------------------------------------------------------- 146*c217d954SCole Faust# SVE Library 147*c217d954SCole Faust 148*c217d954SCole Faustadd_library(arm_compute_sve "") 149*c217d954SCole Fausttarget_compile_options(arm_compute_sve 150*c217d954SCole Faust PRIVATE "-march=armv8.2-a+sve+fp16+dotprod") 151*c217d954SCole Fausttarget_compile_definitions(arm_compute_sve PRIVATE ARM_COMPUTE_ENABLE_BF16) 152*c217d954SCole Fausttarget_include_directories( 153*c217d954SCole Faust arm_compute_sve 154*c217d954SCole Faust PUBLIC $<INSTALL_INTERFACE:include> 155*c217d954SCole Faust $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 156*c217d954SCole Faust ${CMAKE_CURRENT_SOURCE_DIR} 157*c217d954SCole Faust PUBLIC src 158*c217d954SCole Faust src/core/NEON/kernels/arm_conv 159*c217d954SCole Faust src/core/NEON/kernels/arm_gemm 160*c217d954SCole Faust src/core/NEON/kernels/assembly 161*c217d954SCole Faust src/core/cpu/kernels/assembly 162*c217d954SCole Faust src/cpu/kernels/assembly 163*c217d954SCole Faust src/core/NEON/kernels/arm_gemm/merges) 164*c217d954SCole Faust 165*c217d954SCole Faust# --------------------------------------------------------------------- 166*c217d954SCole Faust# SVE2 Library 167*c217d954SCole Faust 168*c217d954SCole Faustadd_library(arm_compute_sve2 "") 169*c217d954SCole Fausttarget_compile_options(arm_compute_sve2 170*c217d954SCole Faust PRIVATE "-march=armv8.6-a+sve2+fp16+dotprod") 171*c217d954SCole Fausttarget_compile_definitions(arm_compute_sve2 PRIVATE ARM_COMPUTE_ENABLE_SVE2) 172*c217d954SCole Fausttarget_compile_definitions(arm_compute_sve2 PRIVATE ARM_COMPUTE_ENABLE_BF16) 173*c217d954SCole Fausttarget_include_directories( 174*c217d954SCole Faust arm_compute_sve2 175*c217d954SCole Faust PUBLIC $<INSTALL_INTERFACE:include> 176*c217d954SCole Faust $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 177*c217d954SCole Faust ${CMAKE_CURRENT_SOURCE_DIR} 178*c217d954SCole Faust PUBLIC src 179*c217d954SCole Faust src/core/NEON/kernels/arm_conv 180*c217d954SCole Faust src/core/NEON/kernels/arm_gemm 181*c217d954SCole Faust src/core/NEON/kernels/assembly 182*c217d954SCole Faust src/core/cpu/kernels/assembly 183*c217d954SCole Faust src/cpu/kernels/assembly 184*c217d954SCole Faust src/core/NEON/kernels/arm_gemm/merges) 185*c217d954SCole Faust 186*c217d954SCole Faust# --------------------------------------------------------------------- 187*c217d954SCole Faust# Core Library 188*c217d954SCole Faust 189*c217d954SCole Faustadd_library(arm_compute_core "") 190*c217d954SCole Fausttarget_compile_options(arm_compute_core PRIVATE "-march=armv8.2-a+fp16") 191*c217d954SCole Fausttarget_compile_definitions(arm_compute_core PRIVATE ARM_COMPUTE_ENABLE_BF16) 192*c217d954SCole Fausttarget_include_directories( 193*c217d954SCole Faust arm_compute_core 194*c217d954SCole Faust PUBLIC $<INSTALL_INTERFACE:include> 195*c217d954SCole Faust $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 196*c217d954SCole Faust ${CMAKE_CURRENT_SOURCE_DIR} 197*c217d954SCole Faust PRIVATE src 198*c217d954SCole Faust src/cpu/kernels/assembly 199*c217d954SCole Faust src/core/NEON/kernels/assembly 200*c217d954SCole Faust src/core/NEON/kernels/convolution/common 201*c217d954SCole Faust src/core/NEON/kernels/arm_conv/depthwise 202*c217d954SCole Faust src/core/NEON/kernels/convolution/winograd) 203*c217d954SCole Fausttarget_compile_options(arm_compute_core PUBLIC ${COMMON_CXX_FLAGS}) 204*c217d954SCole Faust 205*c217d954SCole Faustadd_library(ArmCompute::Core ALIAS arm_compute_core) 206*c217d954SCole Fausttarget_link_libraries( 207*c217d954SCole Faust arm_compute_core PUBLIC arm_compute_sve arm_compute_sve2) 208*c217d954SCole Faust 209*c217d954SCole Faust# --------------------------------------------------------------------- 210*c217d954SCole Faust# Graph Library 211*c217d954SCole Faust 212*c217d954SCole Faustadd_library(arm_compute_graph "") 213*c217d954SCole Fausttarget_compile_options(arm_compute_graph PRIVATE "-march=armv8.2-a+fp16") 214*c217d954SCole Faust# add_subdirectory(src/graph) 215*c217d954SCole Faust 216*c217d954SCole Fausttarget_include_directories( 217*c217d954SCole Faust arm_compute_graph 218*c217d954SCole Faust PUBLIC $<INSTALL_INTERFACE:include> 219*c217d954SCole Faust $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 220*c217d954SCole Faust ${CMAKE_CURRENT_SOURCE_DIR} 221*c217d954SCole Faust PRIVATE src 222*c217d954SCole Faust src/cpu/kernels/assembly 223*c217d954SCole Faust src/core/NEON/kernels/assembly 224*c217d954SCole Faust src/core/NEON/kernels/convolution/common 225*c217d954SCole Faust src/core/NEON/kernels/arm_conv/depthwise 226*c217d954SCole Faust src/core/NEON/kernels/convolution/winograd) 227*c217d954SCole Fausttarget_compile_options(arm_compute_graph PUBLIC ${COMMON_CXX_FLAGS}) 228*c217d954SCole Faust 229*c217d954SCole Faustadd_library(ArmCompute::Graph ALIAS arm_compute_graph) 230*c217d954SCole Faust 231*c217d954SCole Faust# --------------------------------------------------------------------- 232*c217d954SCole Faust# Library Target Sources 233*c217d954SCole Faustadd_subdirectory(src) 234*c217d954SCole Faust 235*c217d954SCole Faust# --------------------------------------------------------------------- 236*c217d954SCole Faust# Validation Framework Library 237*c217d954SCole Faustadd_library(arm_compute_validation_framework "") 238*c217d954SCole Faust# target_compile_options(arm_compute_validation_framework PRIVATE 239*c217d954SCole Faust# "-march=armv8.2-a") 240*c217d954SCole Fausttarget_compile_options(arm_compute_validation_framework 241*c217d954SCole Faust PRIVATE "-march=armv8.2-a+fp16") 242*c217d954SCole Faust 243*c217d954SCole Faustadd_subdirectory(tests) 244*c217d954SCole Fausttarget_include_directories( 245*c217d954SCole Faust arm_compute_validation_framework 246*c217d954SCole Faust PUBLIC $<INSTALL_INTERFACE:include> 247*c217d954SCole Faust $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 248*c217d954SCole Faust ${CMAKE_CURRENT_SOURCE_DIR}) 249*c217d954SCole Fausttarget_compile_options(arm_compute_validation_framework 250*c217d954SCole Faust PUBLIC ${COMMON_CXX_FLAGS}) 251*c217d954SCole Faust target_link_libraries( 252*c217d954SCole Faust arm_compute_validation_framework 253*c217d954SCole Faust PUBLIC arm_compute_core arm_compute_graph) 254*c217d954SCole Faust 255*c217d954SCole Faust# --------------------------------------------------------------------- 256*c217d954SCole Faust# Validation Binary 257*c217d954SCole Faust 258*c217d954SCole Faustif(BUILD_TESTING) 259*c217d954SCole Faust 260*c217d954SCole Faust add_executable(arm_compute_validation "") 261*c217d954SCole Faust target_compile_options(arm_compute_validation PRIVATE "-march=armv8.2-a+fp16") 262*c217d954SCole Faust if(ENABLE_BF16_VALIDATION) 263*c217d954SCole Faust target_compile_definitions(arm_compute_validation PRIVATE ARM_COMPUTE_ENABLE_BF16) 264*c217d954SCole Faust endif() 265*c217d954SCole Faust add_subdirectory(tests/validation) 266*c217d954SCole Faust target_compile_options(arm_compute_validation PUBLIC ${COMMON_CXX_FLAGS}) 267*c217d954SCole Faust set_target_properties( 268*c217d954SCole Faust arm_compute_validation PROPERTIES RUNTIME_OUTPUT_DIRECTORY 269*c217d954SCole Faust "${CMAKE_BINARY_DIR}/validation") 270*c217d954SCole Faust target_link_libraries( 271*c217d954SCole Faust arm_compute_validation 272*c217d954SCole Faust PUBLIC arm_compute_core arm_compute_graph arm_compute_validation_framework 273*c217d954SCole Faust arm_compute_sve) 274*c217d954SCole Faust target_link_directories(arm_compute_validation PUBLIC tests) 275*c217d954SCole Faust 276*c217d954SCole Faust # --------------------------------------------------------------------- 277*c217d954SCole Faust # Benchmark Binary 278*c217d954SCole Faust 279*c217d954SCole Faust add_executable(arm_compute_benchmark) 280*c217d954SCole Faust target_compile_options(arm_compute_benchmark PRIVATE "-march=armv8.2-a+fp16") 281*c217d954SCole Faust 282*c217d954SCole Faust add_subdirectory(tests/benchmark) 283*c217d954SCole Faust target_compile_options(arm_compute_benchmark PUBLIC ${COMMON_CXX_FLAGS}) 284*c217d954SCole Faust set_target_properties( 285*c217d954SCole Faust arm_compute_benchmark PROPERTIES RUNTIME_OUTPUT_DIRECTORY 286*c217d954SCole Faust "${CMAKE_BINARY_DIR}/validation") 287*c217d954SCole Faust target_link_libraries( 288*c217d954SCole Faust arm_compute_benchmark PUBLIC arm_compute_core arm_compute_graph 289*c217d954SCole Faust arm_compute_validation_framework) 290*c217d954SCole Faust 291*c217d954SCole Faustendif() # BUILD_TESTING 292*c217d954SCole Faust# --------------------------------------------------------------------- 293*c217d954SCole Faust# Examples Binaries 294*c217d954SCole Faust 295*c217d954SCole Faustif(BUILD_EXAMPLES) 296*c217d954SCole Faust 297*c217d954SCole Faust add_subdirectory(examples) 298*c217d954SCole Faust 299*c217d954SCole Faust # Graph Examples 300*c217d954SCole Faust foreach(test_name ${EXAMPLE_GRAPH_NAMES}) 301*c217d954SCole Faust add_executable( 302*c217d954SCole Faust ${test_name} "examples/${test_name}.cpp" utils/Utils.cpp 303*c217d954SCole Faust utils/GraphUtils.cpp utils/CommonGraphOptions.cpp) 304*c217d954SCole Faust target_compile_options(${test_name} PRIVATE "-march=armv8.2-a+fp16") 305*c217d954SCole Faust set_target_properties( 306*c217d954SCole Faust ${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY 307*c217d954SCole Faust "${CMAKE_BINARY_DIR}/examples") 308*c217d954SCole Faust target_link_libraries(${test_name} PUBLIC arm_compute_core 309*c217d954SCole Faust arm_compute_graph arm_compute_sve) 310*c217d954SCole Faust endforeach() 311*c217d954SCole Faust 312*c217d954SCole Faust # NEON Examples 313*c217d954SCole Faust foreach(test_name ${EXAMPLE_NEON_NAMES}) 314*c217d954SCole Faust add_executable(${test_name} "examples/${test_name}.cpp" utils/Utils.cpp) 315*c217d954SCole Faust target_compile_options(${test_name} PRIVATE "-march=armv8.2-a+fp16") 316*c217d954SCole Faust set_target_properties( 317*c217d954SCole Faust ${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY 318*c217d954SCole Faust "${CMAKE_BINARY_DIR}/examples") 319*c217d954SCole Faust target_link_libraries(${test_name} PUBLIC arm_compute_core) 320*c217d954SCole Faust endforeach() 321*c217d954SCole Faust 322*c217d954SCole Faustendif() # BUILD_EXAMPLES 323