From e0c42ef651709fd284da3bedd2c98d420bd6fd1a Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Thu, 15 Dec 2022 16:25:57 +0000 Subject: Bazel and CMake builds Resolves: ONCPUML-1110, ONCPUML-1109 Co-authored-by: Georgios Pinitas Co-authored-by: Joe Ramsay Signed-off-by: David Svantesson Change-Id: Iea693dbe53bf0af87867d6a9e0d1fd9fbe59ef3a Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8981 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Jakub Sujak Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins --- cmake/Options.cmake | 123 +++++++++++++++++++++++++ cmake/Version.cmake | 40 ++++++++ cmake/toolchains/aarch64_linux_toolchain.cmake | 27 ++++++ 3 files changed, 190 insertions(+) create mode 100644 cmake/Options.cmake create mode 100644 cmake/Version.cmake create mode 100644 cmake/toolchains/aarch64_linux_toolchain.cmake (limited to 'cmake') diff --git a/cmake/Options.cmake b/cmake/Options.cmake new file mode 100644 index 0000000000..20cf0e42c8 --- /dev/null +++ b/cmake/Options.cmake @@ -0,0 +1,123 @@ +# Copyright (c) 2023 Arm Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +include(CMakeDependentOption) + +# --------------------------------------------------------------------- + +option(BUILD_SHARED_LIBS "Build shared libraries" ON) + +option(DEBUG "Enable ['-O0','-g','-gdwarf-2'] compilation flags" OFF) +option(WERROR "Enable the -Werror compilation flag" OFF) +option(EXCEPTIONS "Enable C++ exception support" ON) +option(LOGGING "Enable logging" OFF) + +option(GEMM_TUNER "Build gemm_tuner programs" OFF) # Not used atm +option(BUILD_EXAMPLES "Build example programs" OFF) + +option(BUILD_TESTING "Build tests" OFF) +option(CPPTHREADS "Enable C++11 threads backend" OFF) +option(OPENMP "Enable OpenMP backend" ON) + +# +if(CPPTHREADS) + add_definitions(-DARM_COMPUTE_CPP_SCHEDULER) +endif() +# +if(LOGGING) + add_definitions(-DARM_COMPUTE_LOGGING_ENABLED) +endif() + +# --------------------------------------------------------------------- +# Backends + +# TODO Add help string for each setting (Should user be able to ) +option(ENABLE_NEON "Enable Arm® Neon™ support" ON) +option(ARM_COMPUTE_CPU_ENABLED "" ON) +option(ARM_COMPUTE_ENABLE_NEON "" ON) +option(ARM_COMPUTE_ENABLE_FP16 "" ON) +option(ARM_COMPUTE_ENABLE_I8MM "" ON) +option(ENABLE_FP16_KERNELS "" ON) +option(ENABLE_FP32_KERNELS "" ON) +option(ENABLE_QASYMM8_KERNELS "" ON) +option(ENABLE_QASYMM8_SIGNED_KERNELS "" ON) +option(ENABLE_QSYMM16_KERNELS "" ON) +option(ENABLE_INTEGER_KERNELS "" ON) +option(ENABLE_NHWC_KERNELS "" ON) +option(ENABLE_NCHW_KERNELS "" ON) +option(ARM_COMPUTE_GRAPH_ENABLED "" ON) +option(ARM_COMPUTE_ENABLE_BF16 "" ON) +option(ARM_COMPUTE_ENABLE_SVEF32MM "" ON) +option(ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS "" ON) + +# TODO Check if this is required +if(ENABLE_NEON) + add_definitions(-DENABLE_NEON) +endif() +if(ARM_COMPUTE_CPU_ENABLED) + add_definitions(-DARM_COMPUTE_CPU_ENABLED) +endif() +if(ARM_COMPUTE_ENABLE_NEON) + add_definitions(-DARM_COMPUTE_ENABLE_NEON) +endif() +if(ARM_COMPUTE_ENABLE_FP16) + add_definitions(-DARM_COMPUTE_ENABLE_FP16) +endif() +if(ARM_COMPUTE_ENABLE_I8MM) + add_definitions(-DARM_COMPUTE_ENABLE_I8MM) +endif() +if(ENABLE_FP16_KERNELS) + add_definitions(-DENABLE_FP16_KERNELS) +endif() +if(ENABLE_FP32_KERNELS) + add_definitions(-DENABLE_FP32_KERNELS) +endif() +if(ENABLE_QASYMM8_KERNELS) + add_definitions(-DENABLE_QASYMM8_KERNELS) +endif() +if(ENABLE_QASYMM8_SIGNED_KERNELS) + add_definitions(-DENABLE_QASYMM8_SIGNED_KERNELS) +endif() +if(ENABLE_QSYMM16_KERNELS) + add_definitions(-DENABLE_QSYMM16_KERNELS) +endif() +if(ENABLE_INTEGER_KERNELS) + add_definitions(-DENABLE_INTEGER_KERNELS) +endif() +if(ENABLE_NHWC_KERNELS) + add_definitions(-DENABLE_NHWC_KERNELS) +endif() +if(ENABLE_NCHW_KERNELS) + add_definitions(-DENABLE_NCHW_KERNELS) +endif() +if(ARM_COMPUTE_GRAPH_ENABLED) + add_definitions(-DARM_COMPUTE_GRAPH_ENABLED) +endif() +if(ARM_COMPUTE_ENABLE_BF16) + add_definitions(-DARM_COMPUTE_ENABLE_BF16) +endif() +if(ARM_COMPUTE_ENABLE_SVEF32MM) + add_definitions(-DARM_COMPUTE_ENABLE_SVEF32MM) +endif() +if(ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS) + add_definitions(-DARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS) +endif() diff --git a/cmake/Version.cmake b/cmake/Version.cmake new file mode 100644 index 0000000000..d01a588824 --- /dev/null +++ b/cmake/Version.cmake @@ -0,0 +1,40 @@ +# Copyright (c) 2023 Arm Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +find_package(Git) + +if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE ACL_VERSION_SHA + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(NOT GIT_FOUND OR RESULT) + set(ACL_VERSION_HASH "Unknown") +endif() + +file(WRITE "arm_compute_version.embed" "\"${ACL_VERSION_SHA}\"") + +# TODO: List build options diff --git a/cmake/toolchains/aarch64_linux_toolchain.cmake b/cmake/toolchains/aarch64_linux_toolchain.cmake new file mode 100644 index 0000000000..2c0a554c57 --- /dev/null +++ b/cmake/toolchains/aarch64_linux_toolchain.cmake @@ -0,0 +1,27 @@ +# Copyright (c) 2023 Arm Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) -- cgit v1.2.1