From a68b9598731345cd22f1c968c3a9814b592e37f0 Mon Sep 17 00:00:00 2001 From: George Steed Date: Wed, 22 May 2024 10:05:29 +0100 Subject: [PATCH] [AArch64] Add initial build system support for SME Extend both the CMake and BUILD.gn configurations to support building a library with the Arm Scalable Matrix Extension (SME). Add an initial (empty) rotate_sme.cc source file to populate the library for now. Change-Id: Icd4bd6a8ce72ba132299b00c99478a18a85d869a Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5588664 Reviewed-by: Justin Green Reviewed-by: Frank Barchard --- BUILD.gn | 28 ++++++++++++++++++++++++++++ CMakeLists.txt | 6 ++++++ libyuv.gni | 1 + source/rotate_sme.cc | 30 ++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 source/rotate_sme.cc diff --git a/BUILD.gn b/BUILD.gn index 5bbf77ee0..2f1473a26 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -38,6 +38,9 @@ config("libyuv_config") { if (!libyuv_use_sve) { defines += [ "LIBYUV_DISABLE_SVE" ] } + if (!libyuv_use_sme) { + defines += [ "LIBYUV_DISABLE_SME" ] + } if (libyuv_disable_rvv) { defines += [ "LIBYUV_DISABLE_RVV" ] } @@ -273,6 +276,31 @@ if (libyuv_use_sve) { } } +if (libyuv_use_sme) { + static_library("libyuv_sme") { + sources = [ + "source/rotate_sme.cc", + ] + + deps = [ ":libyuv_internal" ] + + public_configs = [ ":libyuv_config" ] + + # Always enable optimization for Release and NaCl builds (to workaround + # crbug.com/538243). + if (!is_debug) { + configs -= [ "//build/config/compiler:default_optimization" ] + + # Enable optimize for speed (-O2) over size (-Os). + # TODO(fbarchard): Consider optimize_speed which is O3. + configs += [ "//build/config/compiler:optimize_max" ] + } + + # SME is an Armv9-A feature. + cflags = [ "-march=armv9-a+sme" ] + } +} + if (libyuv_use_msa) { static_library("libyuv_msa") { sources = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dfc93cec..3f521e351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,12 @@ if(NOT MSVC) ${ly_src_dir}/row_sve.cc) TARGET_COMPILE_OPTIONS(${ly_lib_name}_sve PRIVATE -march=armv9-a+sve2) LIST(APPEND ly_lib_parts $) + + # Enable AArch64 SME kernels. + ADD_LIBRARY(${ly_lib_name}_sme OBJECT + ${ly_src_dir}/rotate_sme.cc) + TARGET_COMPILE_OPTIONS(${ly_lib_name}_sme PRIVATE -march=armv9-a+sme) + LIST(APPEND ly_lib_parts $) endif() endif() diff --git a/libyuv.gni b/libyuv.gni index 6add96ad9..7a002c25f 100644 --- a/libyuv.gni +++ b/libyuv.gni @@ -19,6 +19,7 @@ declare_args() { current_cpu == "arm64" || (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon)) libyuv_use_sve = current_cpu == "arm64" + libyuv_use_sme = current_cpu == "arm64" libyuv_use_msa = (current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_msa libyuv_use_mmi = diff --git a/source/rotate_sme.cc b/source/rotate_sme.cc new file mode 100644 index 000000000..3130cee8f --- /dev/null +++ b/source/rotate_sme.cc @@ -0,0 +1,30 @@ +/* + * Copyright 2024 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "libyuv/rotate_row.h" +#include "libyuv/row.h" + +#include "libyuv/basic_types.h" + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +#if !defined(LIBYUV_DISABLE_SME) && defined(__aarch64__) + +// TODO: Port rotate kernels to SME. + +#endif // !defined(LIBYUV_DISABLE_SME) && defined(__aarch64__) + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif