简体   繁体   中英

ARMv8 NEON GCC intrinsics

Targeting Android-21 with 64-bit CPU with NDK r10c, to what extent are NEON intrinsics similar to 32-bit ARMv7a? What are the major caveats of porting ARM-specific C code to the new platform?

The NEON intrinsics in C should be mostly the same - Linaro are converting hand-written assembly to intrinsics (which obviously incurs some amount of performance loss, since compilers aren't perfect in this regard) to port the NEON support in some libraries (eg libvpx) to 64 bit. There's some new stuff (like support for 64 bit floats), but as far as I know most (practically all?) of the existing intrinsics should work the same.

Most of the actual changes to the instructions (like vzip -> zip1/zip2) and register set (changed how SIMD registers alias) are hidden on the intrinsics level.

The major caveat to keep in mind isn't so much about porting old code to AArch64, but about existing binaries and running 32 bit code.

You most probably need to update the NEON runtime detection (eg the cpufeatures library) to detect it properly on new ARMv8 devices even when running in 32 bit mode. If you use the cpufeatures library from the NDK, you need to rebuild your code with NDK r10 or newer to detect it properly on ARMv8 devices, even if you wouldn't plan to actually port it to AArch64 yet - otherwise you'll end up running the fallback C code only. (Long story short, the old cpufeatures library only parsed /proc/cpuinfo, and this has changed format on ARMv8 devices, so the old cpufeatures versions won't detect features properly.)

Edit: It turns out that the android kernels ended up having an extra compatibility option for /proc/cpuinfo, so the cpufeatures library from old NDK versions will keep detecting NEON just fine. See https://android.googlesource.com/kernel/common/+/cba0c6b2913c0d075a7434025f5dc29cd813707f%5E%21/ and https://android.googlesource.com/kernel/common/+/3868e7f8d47992922756d1aa6590f0d556c669b8%5E%21/ for details on this extra compatibility option (which doesn't seem to be in upstream linux kernels, at least not yet).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM