[vlc-commits] linux/cpu: run-time detect AdvSIMD on AArch64

Rémi Denis-Courmont git at videolan.org
Mon Dec 17 19:06:08 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 17 19:53:46 2018 +0200| [813f70062c923bb8fae0336a610a8f922cc72d64] | committer: Rémi Denis-Courmont

linux/cpu: run-time detect AdvSIMD on AArch64

This only assumes NEON is available on AArch64 if it is actually
enabled in the compiler settings (or rather, not explicitly disabled).
Otherwise, perform regular run-time detection.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=813f70062c923bb8fae0336a610a8f922cc72d64
---

 include/vlc_cpu.h                              | 10 +++++++---
 modules/video_filter/deinterlace/deinterlace.c |  2 +-
 src/linux/cpu.c                                |  6 +++---
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index b95f851fff..7d731e09fd 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -170,10 +170,14 @@ VLC_API unsigned vlc_CPU(void);
 
 # elif defined (__aarch64__)
 #  define HAVE_FPU 1
-#  define VLC_CPU_ARM_SVE 0x1
+#  define VLC_CPU_ARM_NEON 0x1
+#  define VLC_CPU_ARM_SVE  0x2
 
-// NEON is mandatory for general purpose ARMv8-a CPUs
-#  define vlc_CPU_ARM64_NEON() (1)
+#  ifdef __ARM_NEON
+#   define vlc_CPU_ARM_NEON() (1)
+#  else
+#   define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
+#  endif
 
 #  ifdef __ARM_FEATURE_SVE
 #   define vlc_CPU_ARM_SVE()   (1)
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 458bd638d0..6bcba0f3bb 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -576,7 +576,7 @@ notsupp:
     else
 #endif
 #if defined(CAN_COMPILE_ARM64)
-    if( vlc_CPU_ARM64_NEON() )
+    if( vlc_CPU_ARM_NEON() )
         p_sys->pf_merge = pixel_size == 1 ? merge8_arm64_neon : merge16_arm64_neon;
     else
 #endif
diff --git a/src/linux/cpu.c b/src/linux/cpu.c
index e5b5abea5e..1b240a7082 100644
--- a/src/linux/cpu.c
+++ b/src/linux/cpu.c
@@ -67,13 +67,13 @@ static void vlc_CPU_init (void)
 
         while ((cap = strsep (&p, " ")) != NULL)
         {
-#if defined (__arm__)
+#if defined (__arm__) || defined (__aarch64__)
             if (!strcmp (cap, "neon"))
                 core_caps |= VLC_CPU_ARM_NEON;
-
-#elif defined (__aarch64__)
+# if defined (__aarch64__)
             if (!strcmp (cap, "sve"))
                 core_caps |= VLC_CPU_ARM_SVE;
+# endif
 
 #elif defined (__i386__) || defined (__x86_64__)
             if (!strcmp (cap, "mmx"))



More information about the vlc-commits mailing list