Detecting FPU presence on Android

前端 未结 2 2026
孤独总比滥情好
孤独总比滥情好 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:14

    It's a Linux kernel underneath, and at least the default Android configuration will mount procfs. That means you can look into /proc/cpuinfo, which on an ARM system looks something like:

    # cat /proc/cpuinfo 
    Processor       : ARMv7 Processor rev 3 (v7l)
    BogoMIPS        : 249.96
    Features        : swp half thumb fastmult vfp edsp neon vfpv3 
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x1
    CPU part        : 0xc08
    CPU revision    : 3
    [ ... ]
    

    If the "Features" line lists at least vfp, then the ARM SoC has an FPU.

    You should be able to read /proc/cpuinfo via Dalvik/Java interfaces, just like a normal file, no privileged access or anything required. I'm not a Java programmer, so leaving that as an exercise to the reader.

提交回复
热议问题