mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
[AArch64] Add SME implementation of ScaleRowDown2
Including associated changes for adding a new scale_sme.cc file. There is no benefit from an SVE version of this kernel for devices with an SVE vector length of 128-bits, so skip directly to SME instead. We do not use the ZA tile here, so this is a purely streaming-SVE (SSVE) implementation. Change-Id: I47d149613fbabd8c203605a809811f1a668e8fb7 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5913883 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Justin Green <greenjustin@google.com>
This commit is contained in:
parent
237f39cb8c
commit
593965cea2
1
BUILD.gn
1
BUILD.gn
@ -263,6 +263,7 @@ if (libyuv_use_sme) {
|
|||||||
sources = [
|
sources = [
|
||||||
"source/rotate_sme.cc",
|
"source/rotate_sme.cc",
|
||||||
"source/row_sme.cc",
|
"source/row_sme.cc",
|
||||||
|
"source/scale_sme.cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
deps = [ ":libyuv_internal" ]
|
deps = [ ":libyuv_internal" ]
|
||||||
|
|||||||
@ -130,7 +130,8 @@ int main(void) { return 0; }
|
|||||||
# Enable AArch64 SME kernels.
|
# Enable AArch64 SME kernels.
|
||||||
add_library(${ly_lib_name}_sme OBJECT
|
add_library(${ly_lib_name}_sme OBJECT
|
||||||
${ly_src_dir}/rotate_sme.cc
|
${ly_src_dir}/rotate_sme.cc
|
||||||
${ly_src_dir}/row_sme.cc)
|
${ly_src_dir}/row_sme.cc
|
||||||
|
${ly_src_dir}/scale_sme.cc)
|
||||||
target_compile_options(${ly_lib_name}_sme PRIVATE -march=armv9-a+sme)
|
target_compile_options(${ly_lib_name}_sme PRIVATE -march=armv9-a+sme)
|
||||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sme>)
|
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sme>)
|
||||||
else()
|
else()
|
||||||
|
|||||||
@ -116,6 +116,12 @@ extern "C" {
|
|||||||
#define HAS_SCALEUVROWUP2_BILINEAR_16_NEON
|
#define HAS_SCALEUVROWUP2_BILINEAR_16_NEON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// The following are available on AArch64 SME platforms:
|
||||||
|
#if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
|
||||||
|
defined(__aarch64__)
|
||||||
|
#define HAS_SCALEROWDOWN2_SME
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||||
#define HAS_SCALEADDROW_MSA
|
#define HAS_SCALEADDROW_MSA
|
||||||
#define HAS_SCALEARGBCOLS_MSA
|
#define HAS_SCALEARGBCOLS_MSA
|
||||||
@ -1397,13 +1403,15 @@ void ScaleUVRowUp2_Bilinear_16_Any_NEON(const uint16_t* src_ptr,
|
|||||||
int dst_width);
|
int dst_width);
|
||||||
|
|
||||||
// ScaleRowDown2Box also used by planar functions
|
// ScaleRowDown2Box also used by planar functions
|
||||||
// NEON downscalers with interpolation.
|
// NEON/SME downscalers with interpolation.
|
||||||
|
|
||||||
// Note - not static due to reuse in convert for 444 to 420.
|
|
||||||
void ScaleRowDown2_NEON(const uint8_t* src_ptr,
|
void ScaleRowDown2_NEON(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
int dst_width);
|
int dst_width);
|
||||||
|
void ScaleRowDown2_SME(const uint8_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width);
|
||||||
void ScaleRowDown2Linear_NEON(const uint8_t* src_ptr,
|
void ScaleRowDown2Linear_NEON(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
|
|||||||
@ -74,6 +74,13 @@ static void ScalePlaneDown2(int src_width,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(HAS_SCALEROWDOWN2_SME)
|
||||||
|
if (TestCpuFlag(kCpuHasSME)) {
|
||||||
|
if (filtering == kFilterNone) {
|
||||||
|
ScaleRowDown2 = ScaleRowDown2_SME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(HAS_SCALEROWDOWN2_SSSE3)
|
#if defined(HAS_SCALEROWDOWN2_SSSE3)
|
||||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||||
ScaleRowDown2 =
|
ScaleRowDown2 =
|
||||||
|
|||||||
65
source/scale_sme.cc
Normal file
65
source/scale_sme.cc
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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/scale_row.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace libyuv {
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
|
||||||
|
defined(__aarch64__)
|
||||||
|
|
||||||
|
__arm_locally_streaming void ScaleRowDown2_SME(const uint8_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width) {
|
||||||
|
// Streaming-SVE only, no use of ZA tile.
|
||||||
|
(void)src_stride;
|
||||||
|
int vl;
|
||||||
|
asm volatile(
|
||||||
|
"cntb %x[vl] \n"
|
||||||
|
"subs %w[dst_width], %w[dst_width], %w[vl] \n"
|
||||||
|
"b.lt 2f \n"
|
||||||
|
|
||||||
|
"1: \n"
|
||||||
|
"ptrue p0.b \n"
|
||||||
|
"ld2b {z0.b, z1.b}, p0/z, [%[src_ptr]] \n"
|
||||||
|
"incb %[src_ptr], all, mul #2 \n"
|
||||||
|
"subs %w[dst_width], %w[dst_width], %w[vl] \n"
|
||||||
|
"st1b {z1.b}, p0, [%[dst_ptr]] \n"
|
||||||
|
"incb %[dst_ptr] \n"
|
||||||
|
"b.ge 1b \n"
|
||||||
|
|
||||||
|
"2: \n"
|
||||||
|
"adds %w[dst_width], %w[dst_width], %w[vl] \n"
|
||||||
|
"b.eq 99f \n"
|
||||||
|
|
||||||
|
"whilelt p0.b, wzr, %w[dst_width] \n"
|
||||||
|
"ld2b {z0.b, z1.b}, p0/z, [%[src_ptr]] \n"
|
||||||
|
"st1b {z1.b}, p0, [%[dst_ptr]] \n"
|
||||||
|
|
||||||
|
"99: \n"
|
||||||
|
: [src_ptr] "+r"(src_ptr), // %[src_ptr]
|
||||||
|
[dst_ptr] "+r"(dst), // %[dst_ptr]
|
||||||
|
[dst_width] "+r"(dst_width), // %[dst_width]
|
||||||
|
[vl] "=r"(vl) // %[vl]
|
||||||
|
:
|
||||||
|
: "memory", "cc", "z0", "z1", "p0");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) &&
|
||||||
|
// defined(__aarch64__)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
} // namespace libyuv
|
||||||
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user