Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
439 views
in Technique[技术] by (71.8m points)

optimization - Detecting FPU presence on Android

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.

After some research it seems that using FloatMath class is slower on a unit that possesses an FPU, so I would like to have best of both worlds.

Most newer phones have an FPU, but I would like to get the most performance the device can offer.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...