如何检查手臂上NEON的存在? [英] How to check the existence of NEON on arm?

查看:20
本文介绍了如何检查手臂上NEON的存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何判断给定ARM处理器上是否存在NEON引擎?可以为此目的查询任何状态/标志寄存器吗?

How to determine whether NEON engine exists on given ARM processor? Any status/flag register can be queried for such purpose?

推荐答案

我相信unixsmurf 的答案 与使用具有特权内核的操作系统一样好.对于通用功能检测,似乎 ARM 要求从操作系统中获取它,因此您必须使用操作系统 API 来获取它.

I believe unixsmurf's answer is about as good as you'll get if using an OS with privileged kernel. For general purpose feature detection, it seems ARM has made it a requirement to get this from the OS, and so you must use an OS API to get it.

  • 在 Android NDK 上,将 #include <cpu-features.h>(android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) &&(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON).请注意,这是针对 32 位 ARM 的.ARM 64 位有不同的标志,但想法是一样的.请参阅 sources/docs.
  • 在 Linux 上,如果可用,请使用 #include <sys/auxv.h>#include <asm/hwcap.h>getauxval(AT_HWCAP) &HWCAP_NEON.
  • 在 iOS 上,我不确定是否存在动态调用,方法似乎是您构建针对 NEON 的应用,然后确保您的应用被标记为需要 NEON,因此它只会安装在支持它的设备上.当然,您应该使用预定义的预处理器标志 __ARM_NEON__ 来确保在编译时一切正常.
  • 无论 Microsoft 做什么,或者您是否使用其他一些 RTOS...我不知道...
  • On Android NDK use #include <cpu-features.h> with (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON). Note this is for 32 bit ARM. ARM 64 bit has different flags but the idea is the same. See the sources/docs.
  • On Linux, if available use #include <sys/auxv.h> and #include <asm/hwcap.h> with getauxval(AT_HWCAP) & HWCAP_NEON.
  • On iOS, I'm not sure there is a dynamic call, the methodology seems to be that you build your app targeting NEON, then make sure your app is flagged to require NEON so it will only install on devices which support it. Of course you should use the pre-defined preprocessor flag __ARM_NEON__ to make sure everything is in order at compile time.
  • On whatever Microsoft does or if you are using some other RTOS... I don't know...

实际上你会看到很多 Android 实现,它们只是解析/proc/cpuinfo 以实现 android_getCpuFeatures()....呵呵.但它似乎仍在改进,最新版本使用 getauxval 方法.

Actually you'll see a lot of Android implementations which just parse /proc/cpuinfo in order to implement android_getCpuFeatures().... Heh. But still it seems to be getting improved and newest versions use the getauxval method.

这篇关于如何检查手臂上NEON的存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆