From 2cb8be1318765839ccd01fc766cabea3ec8f0591 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Wed, 2 Apr 2025 14:03:04 +0100 Subject: [PATCH 1/2] Remove FP16 and BF16 requirement to build and run tests * FP16 and BF16 classes are implemented in assembly so the rest of the test framework doesn't need to be compiled with FP16 and BF16 support anymore. It allows the test to be run on system with base architecture. * Remove unnecessary feature guard in kernel header file. The user of our API must not need to compile their code with BF16 support. Signed-off-by: Viet-Hoa Do --- CMakeLists.txt | 2 +- ..._matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.h | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aecb07e..511f9fe3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,7 +301,7 @@ if(KLEIDIAI_BUILD_TESTS) target_compile_options(kleidiai_test_framework PUBLIC ${KLEIDIAI_WARNING_FLAGS} - PUBLIC $<$>:-march=armv8.2-a+fp16+bf16${KLEIDIAI_INTERNAL_EXTRA_ARCH}> + PUBLIC $<$>:-march=armv8-a${KLEIDIAI_INTERNAL_EXTRA_ARCH}> ) if(MSVC) diff --git a/kai/ukernels/matmul/matmul_clamp_f32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.h b/kai/ukernels/matmul/matmul_clamp_f32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.h index 251977e1..6599981c 100644 --- a/kai/ukernels/matmul/matmul_clamp_f32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.h +++ b/kai/ukernels/matmul/matmul_clamp_f32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.h @@ -1,15 +1,11 @@ // -// SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 // #pragma once -#if !defined(__aarch64__) || !defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) -#error This file must be compiled for AArch64, FEAT_BF16. -#else // Architectural features check. - #include #include @@ -124,5 +120,3 @@ void kai_run_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla( #ifdef __cplusplus } // extern "C" #endif // __cplusplus - -#endif // Architectural features check. -- GitLab From 060e5c19c7764aec49b2429179e199ec6c317b3f Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Wed, 2 Apr 2025 14:30:53 +0100 Subject: [PATCH 2/2] Update feature flags for assembly files and bazel build Signed-off-by: Viet-Hoa Do --- CMakeLists.txt | 6 ++++-- test/BUILD.bazel | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 511f9fe3..d57926a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,10 +308,12 @@ if(KLEIDIAI_BUILD_TESTS) set_source_files_properties(test/common/bfloat16_asm.S PROPERTIES LANGUAGE ASM_MARMASM) set_source_files_properties(test/common/float16_asm.S PROPERTIES LANGUAGE ASM_MARMASM) set_source_files_properties(test/common/round_asm.S PROPERTIES LANGUAGE ASM_MARMASM) + else() + set_source_files_properties(test/common/float16_asm.S PROPERTIES COMPILE_OPTIONS "-march=armv8.2-a+fp16${KLEIDIAI_INTERNAL_EXTRA_ARCH}") + set_source_files_properties(test/common/bfloat16_asm.S PROPERTIES COMPILE_OPTIONS "-march=armv8.2-a+fp16+bf16${KLEIDIAI_INTERNAL_EXTRA_ARCH}") + set_source_files_properties(test/common/sme.cpp PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-march=armv8.2-a+sve${KLEIDIAI_INTERNAL_EXTRA_ARCH}") endif() - set_source_files_properties(test/common/sme.cpp PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-march=armv8.2-a+sve${KLEIDIAI_INTERNAL_EXTRA_ARCH}") - target_link_libraries(kleidiai_test_framework PUBLIC kleidiai ) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 9019364a..652563b9 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -8,6 +8,7 @@ load( "//:kai_defs.bzl", "kai_cpu_bf16", "kai_cpu_fp16", + "kai_cpu_neon", "kai_cpu_sme", "kai_cxx_library", "kai_cxxopts", @@ -50,7 +51,7 @@ kai_cxx_library( name = "reference", srcs = glob(["reference/*.cpp"]), hdrs = glob(["reference/*.hpp"]), - cpu_uarch = kai_cpu_bf16() + kai_cpu_fp16(), + cpu_uarch = kai_cpu_neon(), deps = [ ":common", ], @@ -59,7 +60,7 @@ kai_cxx_library( cc_test( name = "kleidiai_test", srcs = glob(["tests/*.cpp"]), - copts = kai_cxxopts(kai_cpu_bf16() + kai_cpu_fp16()), + copts = kai_cxxopts(kai_cpu_neon()), includes = [], linkstatic = True, visibility = ["//visibility:public"], -- GitLab