Detecting FPU presence on Android

前端 未结 2 2025
孤独总比滥情好
孤独总比滥情好 2020-12-10 16:46

I want to get the most performance of my mobile application on Android. I would like to know if someone is aware of a trick to check if the phone possesses an FPU.

A

2条回答
  •  佛祖请我去吃肉
    2020-12-10 17:31

    Even though it is a very old thread, for anyone like me landed here by google may find this useful. Here I am showing how we can do it using NDK (C++) as the Java-way is already given.

    Using NDK, by including cpu-features.h, we can utilize a number of API and predefined macros to detect the availability of FPU.

    For 32 bit processor, you should check one of ANDROID_CPU_ARM_FEATURE_VFPv3, ANDROID_CPU_ARM_FEATURE_VFPv2, ANDROID_CPU_ARM_FEATURE_VFP_D32, ANDROID_CPU_ARM_FEATURE_VFP_FP16 or ANDROID_CPU_ARM_FEATURE_VFP_FMA on the return value of android_getCpuFeatures() which will ensure that your processor is armed with an FPU.

    For 64 bit, please check ANDROID_CPU_ARM64_FEATURE_FP flag.

    Additionally, call android_getCpuFamily() to get CPU family/architecture (ARM/MIPS, 32/64 bit etc).

    The cpufeatures library manual has everything to include and use it in your project.

提交回复
热议问题