From c403ada4ab9569cbd9c8a8b067529c9bed40a5d4 Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Tue, 21 Jan 2025 13:38:44 +0000 Subject: [PATCH 1/3] Add missing prototypes - Enable "-Wmissing-prototypes" compiler warning flag in the CMake and Bazel build scripts to catch missing prototypes. Additionally, enable "-Wstrict-prototypes" option. - Expose missing prototypes in the public API. - Resolve conflicting prototypes by aligning the definition to the declaration. Signed-off-by: Jakub Sujak --- CMakeLists.txt | 2 ++ ..._f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.c | 2 ++ ...32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.c | 2 ++ .../pack/kai_lhs_pack_bf16p2vlx2_f32_sme.c | 2 ++ .../pack/kai_lhs_pack_bf16p8x4_f16_neon.c | 2 ++ .../pack/kai_lhs_pack_f32p2vlx1_f32_sme.c | 2 ++ .../pack/kai_lhs_pack_x16p2vlx2_x16_sme.c | 2 ++ .../pack/kai_lhs_quant_pack_bf16p1x4_f32_neon.c | 2 ++ .../pack/kai_lhs_quant_pack_bf16p8x4_f32_neon.c | 6 ++++-- ...kai_rhs_pack_kxn_bf16p12x4biasf16_f16_neon.h | 17 ++++++++++++----- ...kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.c | 2 ++ ..._rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.c | 4 +++- ..._rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.c | 4 +++- ...i_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.c | 4 +++- ..._rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.c | 2 ++ ..._rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h | 9 ++++++++- ...rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0.h | 13 ++++++++++++- .../kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.c | 2 ++ ...s_quant_pack_kxn_bf16p12x4biasf32_f32_neon.c | 7 ++++--- kai_defs.bzl | 2 ++ test/common/printer.cpp | 4 +++- test/reference/cast.cpp | 4 +++- .../matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp | 10 +++++----- 23 files changed, 84 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fdf43ec..63e5961c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,8 @@ else() "-Wstrict-overflow=2" "-Wswitch-default" "-Wcast-qual" + "-Wmissing-prototypes" + "-Wstrict-prototypes" ) set(KLEIDIAI_WARNING_FLAGS_CXX diff --git a/kai/ukernels/matmul/matmul_clamp_f16_f16p_f16p/kai_matmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.c b/kai/ukernels/matmul/matmul_clamp_f16_f16p_f16p/kai_matmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.c index 6a130319..a30936cf 100644 --- a/kai/ukernels/matmul/matmul_clamp_f16_f16p_f16p/kai_matmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.c +++ b/kai/ukernels/matmul/matmul_clamp_f16_f16p_f16p/kai_matmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_matmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa.h" + #include #include #include diff --git a/kai/ukernels/matmul/matmul_clamp_fp32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.c b/kai/ukernels/matmul/matmul_clamp_fp32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.c index da28c6f0..f677276f 100644 --- a/kai/ukernels/matmul/matmul_clamp_fp32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.c +++ b/kai/ukernels/matmul/matmul_clamp_fp32_bf16p_bf16p/kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p2vlx2_f32_sme.c b/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p2vlx2_f32_sme.c index 351a4e3a..e6992357 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p2vlx2_f32_sme.c +++ b/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p2vlx2_f32_sme.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_lhs_pack_bf16p2vlx2_f32_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p8x4_f16_neon.c b/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p8x4_f16_neon.c index 1cc0c071..ce92ba1f 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p8x4_f16_neon.c +++ b/kai/ukernels/matmul/pack/kai_lhs_pack_bf16p8x4_f16_neon.c @@ -12,6 +12,8 @@ #error This file must be compiled for AArch64, FEAT_BF16, FEAT_FP16. #else // Architectural features check. +#include "kai_lhs_pack_bf16p8x4_f16_neon.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.c b/kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.c index d8b4708d..e2636770 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.c +++ b/kai/ukernels/matmul/pack/kai_lhs_pack_f32p2vlx1_f32_sme.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_lhs_pack_f32p2vlx1_f32_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_pack_x16p2vlx2_x16_sme.c b/kai/ukernels/matmul/pack/kai_lhs_pack_x16p2vlx2_x16_sme.c index f16d52b2..d865117f 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_pack_x16p2vlx2_x16_sme.c +++ b/kai/ukernels/matmul/pack/kai_lhs_pack_x16p2vlx2_x16_sme.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_lhs_pack_x16p2vlx2_x16_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p1x4_f32_neon.c b/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p1x4_f32_neon.c index 5d6f1587..fb0c4bd5 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p1x4_f32_neon.c +++ b/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p1x4_f32_neon.c @@ -8,6 +8,8 @@ #error This file must be compiled for AArch64, FEAT_BF16. #else // Architectural features check. +#include "kai_lhs_quant_pack_bf16p1x4_f32_neon.h" + #include #include #include diff --git a/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p8x4_f32_neon.c b/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p8x4_f32_neon.c index 9e59bdd0..60862dc4 100644 --- a/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p8x4_f32_neon.c +++ b/kai/ukernels/matmul/pack/kai_lhs_quant_pack_bf16p8x4_f32_neon.c @@ -10,6 +10,8 @@ #define MAX_MR 8 +#include "kai_lhs_quant_pack_bf16p8x4_f32_neon.h" + #include #include #include @@ -50,8 +52,8 @@ size_t kai_get_lhs_packed_size_lhs_quant_pack_bf16p8x4_f32_neon(size_t m, size_t } void kai_run_lhs_quant_pack_bf16p8x4_f32_neon( - size_t m, size_t k, size_t mr, size_t kr, size_t sr, size_t m_idx_start, const float* lhs, size_t lhs_stride, - uint16_t* lhs_packed) { + size_t m, size_t k, size_t mr, size_t kr, size_t sr, size_t m_idx_start, const void* lhs, size_t lhs_stride, + void* lhs_packed) { KAI_ASSUME(mr == kai_mr); KAI_ASSUME(sr == kai_sr); KAI_ASSUME(kr == kai_kr); diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf16_f16_neon.h b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf16_f16_neon.h index cd386302..11a6601f 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf16_f16_neon.h +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf16_f16_neon.h @@ -1,5 +1,5 @@ // -// 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 // @@ -33,18 +33,25 @@ size_t kai_get_rhs_offset_rhs_pack_kxn_bf16p12x4biasf16_f16_neon(size_t n_idx); /// @return The offset in bytes to the data element. size_t kai_get_bias_offset_rhs_pack_kxn_bf16p12x4biasf16_f16_neon(size_t n_idx); +/// Gets the row stride in bytes to the packed RHS matrix. +/// +/// @param[in] k Number of rows. +/// +/// @return Row stride in bytes to the packed RHS matrix. +size_t kai_get_rhs_packed_stride_rhs_pack_kxn_bf16p12x4biasf16_f16_neon(size_t k); + /// Gets the offset in bytes to the data element in the packed RHS buffer. /// -/// @param[in] n_idx Row index. -/// @param[in] k Number of columns. +/// @param[in] n_idx Column index. +/// @param[in] k Number of rows. /// /// @return The offset in bytes to the data element. size_t kai_get_rhs_packed_offset_rhs_pack_kxn_bf16p12x4biasf16_f16_neon(size_t n_idx, size_t k); /// Gets the size in bytes of the packed RHS buffer. /// -/// @param[in] n Number of rows. -/// @param[in] k Number of columns. +/// @param[in] n Number of columns. +/// @param[in] k Number of rows. /// /// @return The size in bytes of the packed RHS buffer. size_t kai_get_rhs_packed_size_rhs_pack_kxn_bf16p12x4biasf16_f16_neon(size_t n, size_t k); diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.c b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.c index 1138a679..5a431216 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.c @@ -12,6 +12,8 @@ #error This file must be compiled for AArch64, FEAT_BF16, FEAT_FP16. #else // Architectural features check. +#include "kai_rhs_pack_kxn_bf16p12x4biasf32_f16_neon.h" + #include #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.c b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.c index 61b8ba48..d85533d9 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.c @@ -1,5 +1,5 @@ // -// 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 // @@ -8,6 +8,8 @@ #error This file must be compiled for AArch64. #else // Architectural features check. +#include "kai_rhs_pack_kxn_f16p16x1biasf16_f16_f16_neon.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.c b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.c index 5ce709fa..55e49474 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.c @@ -1,5 +1,5 @@ // -// 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 // @@ -8,6 +8,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_rhs_pack_kxn_f32p2vlx1biasf32_f32_f32_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.c b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.c index 0c6b0074..afa3d8b5 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.c @@ -1,5 +1,5 @@ // -// 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 // @@ -8,6 +8,8 @@ #error This file must be compiled for AArch64. #else // Architectural features check. +#include "kai_rhs_pack_kxn_f32p8x1biasf32_f32_f32_neon.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.c b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.c index 426bfc6c..b5fe9904 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h index 8bd3f6ee..6e677d89 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h @@ -1,5 +1,5 @@ // -// 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 // @@ -34,6 +34,13 @@ size_t kai_get_rhs_offset_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(size_t n_idx /// @return The offset in bytes to the data element. size_t kai_get_bias_offset_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(size_t n_idx); +/// Gets the row stride in bytes to the packed RHS matrix. +/// +/// @param[in] k Number of columns. +/// +/// @return Row stride in bytes to the packed RHS matrix. +size_t kai_get_rhs_packed_stride_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(size_t k); + /// Gets the offset in bytes to the data element in the packed RHS buffer. /// /// @param[in] n_idx Row index. diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0.h b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0.h index f06e736c..a350c0af 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0.h +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0.h @@ -1,5 +1,5 @@ // -// 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 // @@ -14,6 +14,17 @@ extern "C" { #endif +/// Gets the row stride in bytes to the packed RHS matrix. +/// +/// @param[in] k The number of columns in the RHS matrix (not packed). +/// @param[in] nr The number of columns written by the matmul micro-kernel. +/// @param[in] kr The number of columns loaded in the single innermost loop of the matmul micro-kernel. +/// @param[in] bl The block length, which defines the number of K values stored in a single block. It must be equivalent +/// to 32. +/// +/// @return Row stride in bytes to the packed RHS matrix. +size_t kai_get_rhs_packed_stride_rhs_pack_nxk_qsi4c32pscalef16_qsu4c32s16s0(size_t k, size_t nr, size_t kr, size_t bl); + /// Gets the offset in bytes for the RHS matrix (not packed), which holds /// the int4 values in a N x K matrix, where N is number of rows and K is the number of columns. /// diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.c b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.c index 8ca803bd..d2921858 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.c +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.c @@ -11,6 +11,8 @@ #error This file must be compiled for AArch64, FEAT_SVE2. #else // Architectural features check. +#include "kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h" + #include #include diff --git a/kai/ukernels/matmul/pack/kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon.c b/kai/ukernels/matmul/pack/kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon.c index 78b7f9cd..e08021d0 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon.c +++ b/kai/ukernels/matmul/pack/kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon.c @@ -13,6 +13,8 @@ #define MAX_NR 12 +#include "kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon.h" + #include #include #include @@ -24,9 +26,8 @@ static const size_t kai_nr = 12; static const size_t kai_kr = 4; static const size_t kai_sr = 1; -size_t kai_get_n_step_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon(size_t nr) { - KAI_ASSUME(kai_nr == nr); - return nr; +size_t kai_get_n_step_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon(void) { + return kai_nr; } size_t kai_get_rhs_offset_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon(size_t n_idx) { diff --git a/kai_defs.bzl b/kai_defs.bzl index 66ec4414..94fc48e2 100644 --- a/kai_defs.bzl +++ b/kai_defs.bzl @@ -26,6 +26,8 @@ def kai_gcc_warn_copts(): "-Wswitch-default", "-Wno-vla", "-Wcast-qual", + "-Wmissing-prototypes", + "-Wstrict-prototypes", ] def kai_gcc_warn_cxxopts(): diff --git a/test/common/printer.cpp b/test/common/printer.cpp index 9fc3e0d8..eaad08a4 100644 --- a/test/common/printer.cpp +++ b/test/common/printer.cpp @@ -1,9 +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 // +#include "test/common/printer.hpp" + #include #include #include diff --git a/test/reference/cast.cpp b/test/reference/cast.cpp index 487c2f1e..67ad0e77 100644 --- a/test/reference/cast.cpp +++ b/test/reference/cast.cpp @@ -1,9 +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 // +#include "test/reference/cast.hpp" + #include #include #include diff --git a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp index 638b1dc3..81ffaf4d 100644 --- a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp @@ -1,5 +1,5 @@ // -// 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 // @@ -182,7 +182,7 @@ struct TestReference { }; /// Generate test reference data -TestReference get_test_reference(const MatMulShape& shape, const MatMulVariant& variant) { +static TestReference get_test_reference(const MatMulShape& shape, const MatMulVariant& variant) { // ============================================================ // Generates input and reference output data // ============================================================ @@ -282,7 +282,7 @@ TestReference get_test_reference(const MatMulShape& shape, const MatMulVariant& } /// Test LHS packing -void test_lhs_pack( +static void test_lhs_pack( const MatMulShape& shape, const MatMulVariant& variant, const Rect& output_area, const TestReference& reference) { KAI_ASSUME(variant.lhs_pack.has_value()); @@ -313,7 +313,7 @@ void test_lhs_pack( } /// Test RHS packing -void test_rhs_pack( +static void test_rhs_pack( const MatMulShape& shape, const MatMulVariant& variant, const Rect& output_area, const TestReference& reference) { const auto imp_packed_rhs_size = variant.rhs_pack.get_packed_rhs_size(shape.n, shape.k); ASSERT_EQ(imp_packed_rhs_size, reference.packed_rhs.size()); @@ -349,7 +349,7 @@ void test_rhs_pack( } /// Test MatMul of GEMM like kernel -void test_matmul( +static void test_matmul( const MatMulShape& shape, const MatMulVariant& variant, const Rect& output_area, const TestReference& reference) { const auto imp_dst_size = variant.matmul.get_dst_size(shape.m, shape.n); ASSERT_EQ(imp_dst_size, reference.dst_qsi8_clamped.size()); -- GitLab From 0679061db377a5d44d8f1c458fae3500bcddb734 Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Tue, 21 Jan 2025 16:19:28 +0000 Subject: [PATCH 2/3] Separate C only flags Signed-off-by: Jakub Sujak --- CMakeLists.txt | 12 +++++++++--- kai_defs.bzl | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63e5961c..fe4f7fae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,11 +36,11 @@ if(KLEIDIAI_ENABLE_CLANG_TIDY) endif() if(MSVC) - set(KLEIDIAI_WARNING_FLAGS_C + set(KLEIDIAI_WARNING_FLAGS_BASE # "/Wall" - This flag is disabled until the kernel library is cleaned up. ) else() - set(KLEIDIAI_WARNING_FLAGS_C + set(KLEIDIAI_WARNING_FLAGS_BASE "-Wall" "-Wdisabled-optimization" "-Werror" @@ -51,6 +51,10 @@ else() "-Wstrict-overflow=2" "-Wswitch-default" "-Wcast-qual" + ) + + # C only flags not present in C++ + set(KLEIDIAI_WARNING_FLAGS_C "-Wmissing-prototypes" "-Wstrict-prototypes" ) @@ -60,11 +64,13 @@ else() "-Weffc++" "-Woverloaded-virtual" "-Wsign-promo" + "-Wmissing-declarations" ) endif() set(KLEIDIAI_WARNING_FLAGS - ${KLEIDIAI_WARNING_FLAGS_C} + ${KLEIDIAI_WARNING_FLAGS_BASE} + $<$:${KLEIDIAI_WARNING_FLAGS_C}> $<$:${KLEIDIAI_WARNING_FLAGS_CXX}> ) diff --git a/kai_defs.bzl b/kai_defs.bzl index 94fc48e2..3848ba2b 100644 --- a/kai_defs.bzl +++ b/kai_defs.bzl @@ -26,6 +26,11 @@ def kai_gcc_warn_copts(): "-Wswitch-default", "-Wno-vla", "-Wcast-qual", + ] + +# GCC/CLANG C only warning options +def kai_gcc_warn_conlyopts(): + return [ "-Wmissing-prototypes", "-Wstrict-prototypes", ] @@ -36,6 +41,7 @@ def kai_gcc_warn_cxxopts(): "-Weffc++", "-Woverloaded-virtual", "-Wsign-promo", + "-Wmissing-declarations", ] # GCC/CLANG compiler options @@ -144,6 +150,7 @@ def _kai_c_cxx_common(name, copts_def_func, **kwargs): extra_copts.append("-fno-tree-vectorize") kwargs["copts"] = kwargs.get("copts", []) + copts_def_func(cpu_uarch) + extra_copts + kwargs["conlyopts"] = kai_gcc_warn_conlyopts() kwargs["deps"] = ["//:common"] + kwargs.get("deps", []) kwargs["linkstatic"] = kwargs.get("linkstatic", True) -- GitLab From 6e9ab41d514073e5bca8de33acff22125e562184 Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Tue, 21 Jan 2025 16:41:20 +0000 Subject: [PATCH 3/3] Align mismatched parameter names Signed-off-by: Jakub Sujak --- .../pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h | 4 ++-- .../matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h index 6e677d89..77e68f69 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme.h @@ -22,10 +22,10 @@ size_t kai_get_n_step_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(void); /// Gets the offset in bytes to the data element in the RHS matrix buffer. /// /// @param[in] n_idx Column index. -/// @param[in] rhs_offset Row stride in bytes of the RHS matrix. +/// @param[in] rhs_stride Row stride in bytes of the RHS matrix. /// /// @return The offset in bytes to the data element. -size_t kai_get_rhs_offset_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(size_t n_idx, size_t rhs_offset); +size_t kai_get_rhs_offset_rhs_pack_nxk_f32p2vlx1biasf32_f32_f32_sme(size_t n_idx, size_t rhs_stride); /// Gets the offset in bytes to the data element in the bias buffer. /// diff --git a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h index e5cbc791..f9ad4b7f 100644 --- a/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h +++ b/kai/ukernels/matmul/pack/kai_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme.h @@ -1,5 +1,5 @@ // -// 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 // @@ -22,10 +22,10 @@ size_t kai_get_n_step_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme(void); /// Gets the offset in bytes to the data element in the RHS matrix buffer. /// /// @param[in] n_idx Column index. -/// @param[in] rhs_offset Row stride in bytes of the RHS matrix. +/// @param[in] rhs_stride Row stride in bytes of the RHS matrix. /// /// @return The offset in bytes to the data element. -size_t kai_get_rhs_offset_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme(size_t n_idx, size_t rhs_offset); +size_t kai_get_rhs_offset_rhs_pack_nxk_x16p2vlx2b_x16_x16_sme(size_t n_idx, size_t rhs_stride); /// Gets the offset in bytes to the data element in the bias buffer. /// -- GitLab