| 1 | # |
| 2 | # SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | # |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | |
| 7 | # https://github.com/google/benchmark/issues/351 |
| 8 | if(NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ARM")) |
| 9 | set(CMAKE_CROSSCOMPILING TRUE CACHE INTERNAL "") |
| 10 | set(HAVE_POSIX_REGEX FALSE CACHE INTERNAL "") |
| 11 | endif() |
| 12 | |
| 13 | set(BENCHMARK_DOWNLOAD_DEPENDENCIES "OFF") |
| 14 | set(BENCHMARK_ENABLE_TESTING "OFF") |
| 15 | set(BENCHMARK_ENABLE_GTEST_TESTS "OFF") |
| 16 | |
| 17 | include(FetchGBench) |
| 18 | |
| 19 | # Single benchmark binary combining matmul, pack_matmul, imatmul and dwconv |
| 20 | add_executable(kleidiai_benchmark |
| 21 | benchmark/main.cpp |
| 22 | benchmark/dwconv/dwconv_registry.cpp |
| 23 | benchmark/matmul/matmul_registry.cpp |
| 24 | benchmark/pack_matmul/pack_matmul_registry.cpp |
| 25 | benchmark/imatmul/imatmul_registry.cpp |
| 26 | test/common/cpu_info.cpp |
| 27 | test/common/data_type.cpp |
| 28 | ) |
| 29 | |
| 30 | set_source_files_properties(benchmark/matmul/matmul_registry.cpp |
| 31 | PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-fno-tree-slp-vectorize;-march=armv8-a+sve+sve2${KLEIDIAI_INTERNAL_EXTRA_ARCH}") |
| 32 | set_source_files_properties(benchmark/pack_matmul/pack_matmul_registry.cpp |
| 33 | PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-fno-tree-slp-vectorize;-march=armv8-a+sve+sve2${KLEIDIAI_INTERNAL_EXTRA_ARCH}") |
| 34 | set_source_files_properties(benchmark/imatmul/imatmul_registry.cpp |
| 35 | PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-fno-tree-slp-vectorize;-march=armv8-a+sve+sve2${KLEIDIAI_INTERNAL_EXTRA_ARCH}") |
| 36 | |
| 37 | target_link_libraries(kleidiai_benchmark |
| 38 | PRIVATE |
| 39 | kleidiai |
| 40 | benchmark::benchmark |
| 41 | ) |
| 42 | |
| 43 | if(APPLE) |
| 44 | find_library(KPERF_FRAMEWORK kperf |
| 45 | PATHS /System/Library/PrivateFrameworks |
| 46 | NO_DEFAULT_PATH |
| 47 | ) |
| 48 | find_library(KPERFDATA_FRAMEWORK kperfdata |
| 49 | PATHS /System/Library/PrivateFrameworks |
| 50 | NO_DEFAULT_PATH |
| 51 | ) |
| 52 | |
| 53 | if(KPERF_FRAMEWORK AND KPERFDATA_FRAMEWORK) |
| 54 | target_link_libraries(kleidiai_benchmark |
| 55 | PRIVATE |
| 56 | "${KPERF_FRAMEWORK}" |
| 57 | "${KPERFDATA_FRAMEWORK}" |
| 58 | ) |
| 59 | target_compile_definitions(kleidiai_benchmark PRIVATE KAI_BENCHMARK_KPERF=1) |
| 60 | else() |
| 61 | target_compile_definitions(kleidiai_benchmark PRIVATE KAI_BENCHMARK_KPERF=0) |
| 62 | endif() |
| 63 | endif() |