Elffuss BraidHub

kikocis/kleidiai public

655592420abd · 3.9 KiBRawPermalink
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
9cmake_minimum_required(VERSION 3.13)
10project(
11 KleidiAIOps
12 VERSION 0.0.1
13 DESCRIPTION "Benchmark GEMM kernels of various flavours for AArch64"
14 LANGUAGES C CXX)
15
16if(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()
22endif()
23
24# Search for additional CMake helpers in the cmake/ subdir
25list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
26
27# -------------------------------------------------------------------------------------------------
28# cmake-format: off
29
30# Default option values
31set(_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT OFF)
32set(_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT OFF)
33set(_KLEIDIAI_OPS_SVE_ARCH_DEFAULT armv8.2-a+sve+fp16+dotprod)
34
35# Enable threading support by default on Linux and macOS
36if(LINUX OR APPLE)
37 set(_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT ON)
38endif()
39
40# Enable thread binding support by default on Linux
41if(LINUX)
42 set(_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT ON)
43endif()
44
45# Darwin clang needs SME2 enabled when compiling the combined SVE/SME/SME2 source bucket.
46if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
47 set(_KLEIDIAI_OPS_SVE_ARCH_DEFAULT armv9.2-a+nosve+sme2+fp16+dotprod)
48endif()
49
50# Configuration options
51option(KLEIDIAI_OPS_ENABLE_CCACHE_SUPPORT "Enable use of 'ccache' for build" OFF)
52option(KLEIDIAI_OPS_ENABLE_NATIVE "Enable native build" ON)
53option(KLEIDIAI_OPS_ENABLE_AARCH32 "Enable AArch32 mode" OFF)
54option(KLEIDIAI_OPS_ENABLE_BARE_METAL "Enable bare-metal mode" OFF)
55option(KLEIDIAI_OPS_ENABLE_ANDROID "Enable Android build" OFF)
56option(KLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK "Enable build of 'gemm' benchmarking executable" ${PROJECT_IS_TOP_LEVEL})
57option(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
60option(KLEIDIAI_OPS_ENABLE_THREADS "Enable for threading support (not allowed for bare-metal)" ${_KLEIDIAI_OPS_ENABLE_THREADS_DEFAULT})
61option(KLEIDIAI_OPS_ENABLE_BIND_THREADS "Enable for threading binding support (Linux-only API)" ${_KLEIDIAI_OPS_ENABLE_BIND_THREADS_DEFAULT})
62option(KLEIDIAI_OPS_ENABLE_CYCLE_TIMING "Enable cycle timing on Linux; not compatible with threading support." OFF)
63option(KLEIDIAI_OPS_ENABLE_SILENT "Enable minimal output (used for 'xraytools')" OFF)
64
65# The C++ standard
66set(KLEIDIAI_OPS_C_STANDARD 11 CACHE STRING "C Standard to use for the library.")
67set(KLEIDIAI_OPS_CXX_STANDARD 11 CACHE STRING "CXX Standard to use for the library.")
68
69# Set architecture flags
70set(KLEIDIAI_OPS_ARCH armv8-a CACHE STRING "Architecture for the core library.")
71set(KLEIDIAI_OPS_FP16_ARCH armv8.2-a+fp16 CACHE STRING "Architecture for the fp16-specific library components.")
72set(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
77include(KleidiAIOpsCheckOptions)
78include(KleidiAIOpsSetup)
79
80# -------------------------------------------------------------------------------------------------
81
82add_subdirectory(kai/ops)
83
84# -------------------------------------------------------------------------------------------------
85
86if(KLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK)
87 add_subdirectory(benchmark)
88endif()
89
90# -------------------------------------------------------------------------------------------------
91
92set(KLEIDIAI_OPS_TARGETS_TO_INSTALL kleidiai_ops)
93include(KleidiAIOpsInstallProject)
94
95# -------------------------------------------------------------------------------------------------