[AArch64] Add SME implementation of ScaleUVRowDown2

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: Ic4ba5f97dc57afc558c08a57e9b5009d6e487e0f
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5979725
Reviewed-by: Justin Green <greenjustin@google.com>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
George Steed 2024-08-27 15:32:01 +01:00 committed by Frank Barchard
parent de6b47370f
commit 551cee7845
3 changed files with 48 additions and 0 deletions

View File

@ -120,6 +120,7 @@ extern "C" {
#if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
defined(__aarch64__)
#define HAS_SCALEROWDOWN2_SME
#define HAS_SCALEUVROWDOWN2_SME
#endif
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
@ -1154,6 +1155,10 @@ void ScaleUVRowDown2_NEON(const uint8_t* src_ptr,
ptrdiff_t src_stride,
uint8_t* dst,
int dst_width);
void ScaleUVRowDown2_SME(const uint8_t* src_ptr,
ptrdiff_t src_stride,
uint8_t* dst,
int dst_width);
void ScaleUVRowDown2Linear_NEON(const uint8_t* src_ptr,
ptrdiff_t src_stride,
uint8_t* dst_uv,

View File

@ -149,6 +149,44 @@ __arm_locally_streaming void ScaleRowDown2Box_SME(const uint8_t* src_ptr,
#undef SCALEROWDOWN2BOX_SVE
__arm_locally_streaming void ScaleUVRowDown2_SME(const uint8_t* src_uv,
ptrdiff_t src_stride,
uint8_t* dst_uv,
int dst_width) {
// Streaming-SVE only, no use of ZA tile.
(void)src_stride;
int vl;
asm volatile(
"cnth %x[vl] \n"
"subs %w[dst_width], %w[dst_width], %w[vl] \n"
"b.lt 2f \n"
"1: \n"
"ptrue p0.b \n"
"ld2h {z0.h, z1.h}, p0/z, [%[src_uv]] \n"
"incb %[src_uv], all, mul #2 \n"
"subs %w[dst_width], %w[dst_width], %w[vl] \n"
"st1h {z1.h}, p0, [%[dst_uv]] \n"
"incb %[dst_uv] \n"
"b.ge 1b \n"
"2: \n"
"adds %w[dst_width], %w[dst_width], %w[vl] \n"
"b.eq 99f \n"
"whilelt p0.h, wzr, %w[dst_width] \n"
"ld2h {z0.h, z1.h}, p0/z, [%[src_uv]] \n"
"st1h {z1.h}, p0, [%[dst_uv]] \n"
"99: \n"
: [src_uv] "+r"(src_uv), // %[src_uv]
[dst_uv] "+r"(dst_uv), // %[dst_uv]
[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__)

View File

@ -120,6 +120,11 @@ static void ScaleUVDown2(int src_width,
}
}
#endif
#if defined(HAS_SCALEUVROWDOWN2_SME)
if (TestCpuFlag(kCpuHasSME) && filtering == kFilterNone) {
ScaleUVRowDown2 = ScaleUVRowDown2_SME;
}
#endif
#if defined(HAS_SCALEUVROWDOWN2_RVV)
if (TestCpuFlag(kCpuHasRVV)) {
ScaleUVRowDown2 =