| 1 | # |
| 2 | # SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | # |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | |
| 7 | # ------------------------------------------------------------------------------------------------- |
| 8 | |
| 9 | cmake_minimum_required(VERSION 3.13) |
| 10 | project( |
| 11 | KleidiAIOps |
| 12 | VERSION 0.0.1 |
| 13 | DESCRIPTION "Benchmark GEMM kernels of various flavours for AArch64" |
| 14 | LANGUAGES C CXX) |
| 15 | |
| 16 | if(NOT DEFINED PROJECT_IS_TOP_LEVEL) |
| 17 | if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) |
| 18 | set(PROJECT_IS_TOP_LEVEL ON) |
| 19 | else() |
| 20 | set(PROJECT_IS_TOP_LEVEL OFF) |
| 21 | endif() |
| 22 | endif() |
| 23 | |
| 24 | # Search for additional CMake helpers in the cmake/ subdir |
| 25 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
| 26 | |
| 27 | # ------------------------------------------------------------------------------------------------- |
| 28 | # cmake-format: off |
| 29 | |
| 30 | # Default option values |
| 31 | set(_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT OFF) |
| 32 | set(_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT OFF) |
| 33 | set(_KLEIDIAI_OPS_SVE_ARCH_DEFAULT armv8.2-a+sve+fp16+dotprod) |
| 34 | |
| 35 | # Enable threading support by default on Linux and macOS |
| 36 | if(LINUX OR APPLE) |
| 37 | set(_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT ON) |
| 38 | endif() |
| 39 | |
| 40 | # Enable thread binding support by default on Linux |
| 41 | if(LINUX) |
| 42 | set(_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT ON) |
| 43 | endif() |
| 44 | |
| 45 | # Darwin clang needs SME2 enabled when compiling the combined SVE/SME/SME2 source bucket. |
| 46 | if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 47 | set(_KLEIDIAI_OPS_SVE_ARCH_DEFAULT armv9.2-a+nosve+sme2+fp16+dotprod) |
| 48 | endif() |
| 49 | |
| 50 | # Configuration options |
| 51 | option(KLEIDIAI_OPS_ENABLE_CCACHE_SUPPORT "Enable use of 'ccache' for build" OFF) |
| 52 | option(KLEIDIAI_OPS_ENABLE_NATIVE "Enable native build" ON) |
| 53 | option(KLEIDIAI_OPS_ENABLE_AARCH32 "Enable AArch32 mode" OFF) |
| 54 | option(KLEIDIAI_OPS_ENABLE_BARE_METAL "Enable bare-metal mode" OFF) |
| 55 | option(KLEIDIAI_OPS_ENABLE_ANDROID "Enable Android build" OFF) |
| 56 | option(KLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK "Enable build of 'gemm' benchmarking executable" ${PROJECT_IS_TOP_LEVEL}) |
| 57 | option(KLEIDIAI_OPS_ENABLE_CYCLE_PROFILING "Enable cycle based profiling on the 'new' kernels; reports stats per-thread if threading support is enabled." OFF) |
| 58 | |
| 59 | # Benchmarking-specific configuration flags |
| 60 | option(KLEIDIAI_OPS_ENABLE_THREADS "Enable for threading support (not allowed for bare-metal)" ${_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT}) |
| 61 | option(KLEIDIAI_OPS_ENABLE_BIND_THREADS "Enable for threading binding support (Linux-only API)" ${_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT}) |
| 62 | option(KLEIDIAI_OPS_ENABLE_CYCLE_TIMING "Enable cycle timing on Linux; not compatible with threading support." OFF) |
| 63 | option(KLEIDIAI_OPS_ENABLE_SILENT "Enable minimal output (used for 'xraytools')" OFF) |
| 64 | |
| 65 | # The C++ standard |
| 66 | set(KLEIDIAI_OPS_C_STANDARD 11 CACHE STRING "C Standard to use for the library.") |
| 67 | set(KLEIDIAI_OPS_CXX_STANDARD 11 CACHE STRING "CXX Standard to use for the library.") |
| 68 | |
| 69 | # Set architecture flags |
| 70 | set(KLEIDIAI_OPS_ARCH armv8-a CACHE STRING "Architecture for the core library.") |
| 71 | set(KLEIDIAI_OPS_FP16_ARCH armv8.2-a+fp16 CACHE STRING "Architecture for the fp16-specific library components.") |
| 72 | set(KLEIDIAI_OPS_SVE_ARCH ${_KLEIDIAI_OPS_SVE_ARCH_DEFAULT} CACHE STRING "Architecture for the sve-specific library components.") |
| 73 | |
| 74 | # cmake-format: on |
| 75 | # ------------------------------------------------------------------------------------------------- |
| 76 | |
| 77 | include(KleidiAIOpsCheckOptions) |
| 78 | include(KleidiAIOpsSetup) |
| 79 | |
| 80 | # ------------------------------------------------------------------------------------------------- |
| 81 | |
| 82 | add_subdirectory(kai/ops) |
| 83 | |
| 84 | # ------------------------------------------------------------------------------------------------- |
| 85 | |
| 86 | if(KLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK) |
| 87 | add_subdirectory(benchmark) |
| 88 | endif() |
| 89 | |
| 90 | # ------------------------------------------------------------------------------------------------- |
| 91 | |
| 92 | set(KLEIDIAI_OPS_TARGETS_TO_INSTALL kleidiai_ops) |
| 93 | include(KleidiAIOpsInstallProject) |
| 94 | |
| 95 | # ------------------------------------------------------------------------------------------------- |