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

查看:120
本文介绍了如何检查臂上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已要求从OS上获取它,因此您必须使用OS 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位具有不同的标志,但是想法是相同的.请参见源/文档
  • 在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天全站免登陆