diff mbox series

[FFmpeg-devel,4/5] aarch64: Print the SVE vector length in libavutil/tests/cpu.c

Message ID 20240917121419.610349-4-martin@martin.st
State Accepted
Headers show
Series [FFmpeg-devel,1/5] aarch64: Detect I8MM on Windows via SVE-I8MM | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Martin Storsjö Sept. 17, 2024, 12:14 p.m. UTC
This makes this aspect more visible in test logs.
---
 libavutil/aarch64/Makefile  |  2 ++
 libavutil/aarch64/cpu.h     |  4 ++++
 libavutil/aarch64/cpu_sve.S | 29 +++++++++++++++++++++++++++++
 libavutil/tests/cpu.c       |  8 ++++++++
 4 files changed, 43 insertions(+)
 create mode 100644 libavutil/aarch64/cpu_sve.S
diff mbox series

Patch

diff --git a/libavutil/aarch64/Makefile b/libavutil/aarch64/Makefile
index eba0151337..992e95e4df 100644
--- a/libavutil/aarch64/Makefile
+++ b/libavutil/aarch64/Makefile
@@ -4,3 +4,5 @@  OBJS += aarch64/cpu.o                                                 \
 
 NEON-OBJS += aarch64/float_dsp_neon.o                                 \
              aarch64/tx_float_neon.o                                  \
+
+SVE-OBJS += aarch64/cpu_sve.o                                         \
diff --git a/libavutil/aarch64/cpu.h b/libavutil/aarch64/cpu.h
index df7becca30..a41b729659 100644
--- a/libavutil/aarch64/cpu.h
+++ b/libavutil/aarch64/cpu.h
@@ -30,4 +30,8 @@ 
 #define have_sve(flags)     CPUEXT(flags, SVE)
 #define have_sve2(flags)    CPUEXT(flags, SVE2)
 
+#if HAVE_SVE
+int ff_aarch64_sve_length(void);
+#endif
+
 #endif /* AVUTIL_AARCH64_CPU_H */
diff --git a/libavutil/aarch64/cpu_sve.S b/libavutil/aarch64/cpu_sve.S
new file mode 100644
index 0000000000..d216ed2c49
--- /dev/null
+++ b/libavutil/aarch64/cpu_sve.S
@@ -0,0 +1,29 @@ 
+/*
+ * Copyright (c) 2023 Martin Storsjo
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "asm.S"
+
+ENABLE_SVE
+
+function ff_aarch64_sve_length, export=1
+        cntb            x0
+        ret
+endfunc
diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c
index 679b538f0f..abe2b057d7 100644
--- a/libavutil/tests/cpu.c
+++ b/libavutil/tests/cpu.c
@@ -23,6 +23,10 @@ 
 #include "libavutil/cpu.h"
 #include "libavutil/avstring.h"
 
+#if ARCH_AARCH64
+#include "libavutil/aarch64/cpu.h"
+#endif
+
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -161,6 +165,10 @@  int main(int argc, char **argv)
     print_cpu_flags(cpu_flags_raw, "raw");
     print_cpu_flags(cpu_flags_eff, "effective");
     printf("threads = %s (cpu_count = %d)\n", threads, cpu_count);
+#if ARCH_AARCH64
+    if (cpu_flags_raw & AV_CPU_FLAG_SVE)
+        printf("sve_vector_length = %d\n", 8 * ff_aarch64_sve_length());
+#endif
 
     return 0;
 }