简体   繁体   English

ARMv8 NEON GCC内在函数

[英]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? 针对带有NDK r10c和64位CPU的Android-21,NEON内在函数在何种程度上类似于32位ARMv7a? What are the major caveats of porting ARM-specific C code to the new platform? 将特定于ARM的C代码移植到新平台的主要注意事项是什么?

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. C中的NEON内在函数应该基本相同-Linaro将手写汇编转换为内在函数(显然会导致一定程度的性能损失,因为编译器在这方面并不完美),以便将NEON支持移植到某些库中(例如libvpx)到64位。 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. 有一些新的东西(例如对64位浮点数的支持),但是据我所知(实际上是全部?),现有的内在函数应该工作相同。

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. 指令的大多数实际更改(例如vzip-> zip1 / zip2)和寄存器集(已更改SIMD寄存器别名的方式)都隐藏在内在函数级别上。

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. 要记住的主要警告不是将旧代码移植到AArch64,而是关于现有二进制文件和运行32位代码。

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. 您很可能需要更新NEON运行时检测(例如cpufeatures库)以在新的ARMv8设备上正确检测它,即使在32位模式下运行时也是如此。 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. 如果您使用NDK中的cpufeatures库,则即使您不打算将其实际移植到AArch64上,也需要使用NDK r10或更高版本重建代码以在ARMv8设备上正确地检测到它-否则最终仅运行后备C代码。 (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.) (长话短说,旧的cpufeatures库仅解析/ proc / cpuinfo,并且这已更改了ARMv8设备上的格式,因此旧的cpufeatures版本将无法正确检测功能。)

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. 编辑:事实证明,Android内核最终为/ proc / cpuinfo提供了额外的兼容性选项,因此旧NDK版本的cpufeatures库将继续检测NEON正常。 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). 有关详细信息,请参见https://android.googlesource.com/kernel/common/+/cba0c6b2913c0d075a7434025f5dc29cd813707f%5E%21/https://android.googlesource.com/kernel/common/+/3868e7f8d47992922756d1aa6590f0d556c669b8%5E%21/额外的兼容性选项(至少在上游linux内核中似乎没有)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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