[vlc-devel] [PATCH 2/2] contrib: soxr: fix SIMD32 detection on aarch64

Alexandre Janniaux ajanni at videolabs.io
Tue Nov 26 18:07:00 CET 2019


Hi,

Thank you for feedback,

On Tue, Nov 26, 2019 at 06:26:52PM +0200, Rémi Denis-Courmont wrote:
> Hi,
>
> AArch64 NEON is not compatible with ARM NEON. You can't just treat them as equal.

I don't know for the assembly itself, but the intrinsics are
still generated correctly according to each architecture,
which means that armv7a is able to run SIMD32 tests and
AArch64 should be able to run both SIMD32 and SIMD64 tests
if I understand this correctly. Then, the places when soxr
use simd32 or simd64 is determined by whether WITH_CR32S
and WITH_CR64S are defined, and whether should_use_simd32
and should_use_simd64 are defined. It means that this
patch brings incomplete support for SIMD32 intrinsics on
aarch64 through AArch64 NEON but not SIMD64. I didn't
succeed in building with SIMD64 enabled but it starts to
be out of my scope of knowledge.

See for instance the following file:

https://github.com/urho3d/android-ndk/blob/master/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/include/arm_neon.h

I didn't look for a more stable source but you can get it
from the toolchain.

Also the android NDK guide on NEON doesn't seem to make
hard distinction between armv7a and AArch64 except for the
availability on NEON.

https://developer.android.com/ndk/guides/cpu-arm-neon

Does it seem reasonable to you ? It makes AArch64 soxr
build from zero SIMD to SIMD32.

> And it makes zero sense to use A7 CPU tuning in that case also.

Actually I didn't added this part, and it's just used for
testing in this file but maybe they are used afterwards.
However the snippet is different from the current contrib
state so I'll try to find the correct version so as to
reoutput it in a correct fashion. To be honest, I don't
want to change this part even if it's not correct because
I don't master what it does exactly and I have no reason
to change it.

The current code for this is instead:

```
  set (TRIAL_C_FLAGS
    # Gcc
    "-mfpu=neon       -mfloat-abi=hard"
    "-mfpu=neon       -mfloat-abi=softfp"
    "-mfpu=neon       -mfloat-abi=soft"
  )
```

Regards,
--
Alexandre Janniaux
Videolabs

> Le 26 novembre 2019 15:50:38 GMT+02:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
> >SIMD32 CMake script only matches CMAKE_SYSTEM_PROCESSOR against "^arm",
> >while it is "aarch64" when building for arm64.
> >
> >Fix the detection by adding the match against "^aarch64" too to
> >generate NEON code on arm64.
> >---
> > ...ake-SIMD32-fix-detection-for-aarch64.patch | 35 +++++++++++++++++++
> > contrib/src/soxr/rules.mak                    |  1 +
> > 2 files changed, 36 insertions(+)
> >create mode 100644
> >contrib/src/soxr/0005-cmake-SIMD32-fix-detection-for-aarch64.patch
> >
> >diff --git
> >a/contrib/src/soxr/0005-cmake-SIMD32-fix-detection-for-aarch64.patch
> >b/contrib/src/soxr/0005-cmake-SIMD32-fix-detection-for-aarch64.patch
> >new file mode 100644
> >index 0000000000..1cfd85b394
> >--- /dev/null
> >+++
> >b/contrib/src/soxr/0005-cmake-SIMD32-fix-detection-for-aarch64.patch
> >@@ -0,0 +1,35 @@
> >+From d68eedd3cfe632c50e3859219f3868bedc3a4a34 Mon Sep 17 00:00:00 2001
> >+From: Alexandre Janniaux <ajanni at videolabs.io>
> >+Date: Tue, 26 Nov 2019 11:38:25 +0100
> >+Subject: [PATCH] cmake: SIMD32: fix ARM detection for aarch64
> >+
> >+When compiling for android for arm64, the settings exposed to cmake
> >will
> >+be the following:
> >+
> >++ Android: API '21'
> >++ Architecture: 'arm64'
> >++ ABI: 'arm64-v8a'
> >++ Processor: 'aarch64'
> >+
> >+So CMAKE_SYSTEM_PROCESSOR must also be checked for aarch64 so as to
> >+generate NEON code.
> >+---
> >+ cmake/Modules/FindSIMD32.cmake | 3 ++-
> >+ 1 file changed, 2 insertions(+), 1 deletion(-)
> >+
> >+diff --git a/cmake/Modules/FindSIMD32.cmake
> >b/cmake/Modules/FindSIMD32.cmake
> >+index 9e42373..eaf5864 100644
> >+--- a/cmake/Modules/FindSIMD32.cmake
> >++++ b/cmake/Modules/FindSIMD32.cmake
> >+@@ -9,7 +9,8 @@
> >+
> >+ if (DEFINED SIMD32_C_FLAGS)
> >+   set (TRIAL_C_FLAGS)
> >+-elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
> >++elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm"
> >++        OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
> >+   set (TRIAL_C_FLAGS
> >+     # Gcc
> >+     "-mfpu=neon-vfpv4 -mcpu=cortex-a7"
> >+--
> >+2.24.0
> >diff --git a/contrib/src/soxr/rules.mak b/contrib/src/soxr/rules.mak
> >index a26557b6fb..d861790c6d 100644
> >--- a/contrib/src/soxr/rules.mak
> >+++ b/contrib/src/soxr/rules.mak
> >@@ -21,6 +21,7 @@ soxr: soxr-$(SOXR_VERSION)-Source.tar.xz .sum-soxr
> > 	$(APPLY) $(SRC)/soxr/0003-add-aarch64-support.patch
> >	$(APPLY)
> >$(SRC)/soxr/0004-arm-fix-SIGILL-when-doing-divisions-on-some-old-arch.patch
> > 	$(APPLY) $(SRC)/soxr/find_ff_pkgconfig.patch
> >+	$(APPLY)
> >$(SRC)/soxr/0005-cmake-SIMD32-fix-detection-for-aarch64.patch
> > 	$(call pkg_static,"src/soxr.pc.in")
> > 	$(MOVE)
> >
> >--
> >2.24.0
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list