问题
I have an Android application which uses the NDK to execute a large amount of floating point math.
I just acquired a new Galaxy Nexus. To my surprise, my app runs MUCH slower than it should. I suspect this is because most devices are using hardware acceleration and the Galaxy Nexus is not. If I perform an operation which does not require floating point math, the Galaxy Nexus performs how I would expect.
Here are the CPU/GPU specs and sample timings for several devices. I've normalized the stats to take into account display resolution:
Droid
CPU: TI OMAP 3430 (ARM Cortex-A8 600 MHz underclocked to 550 MHz)
GPU: PowerVR SGX530
Instruction Set: ARMv7
Test Run: 1,980 pixels per second
Galaxy Nexus
CPU: TI OMAP 4460 (ARM Cortex-A9 dual-core 1.2 GHz)
GPU: PowerVR SGX540
Instruction Set: ARMv7
Test Run: 2,253 pixels per second
Droid Incredible
CPU: QSD8650 (Qualcomm Snapdragon 1 GHz)
GPU: Adreno 200
Instruction Set: ARMv7
Test Run: 4,571 pixels per second
I have this configuration in my Application.mk file:
APP_ABI := armeabi armeabi-v7a
I have not re-compiled my code with NDK-r7, but I don't understand why this would make such a dramatic difference. Any idea what is wrong?
回答1:
You could try to use
APP_ABI := armeabi-v7a
to force use of the v7a instructions only.
I could imagine that the new CPU is not detected as supporting v7a instructions and that thus the no-FPU code is used at runtime as a fallback.
回答2:
This StackOverflow question may be the cause of the poor performance on your Galaxy Nexus: Galaxy Nexus - wrong CPU ABI being selected during install time.
That seems to be a bug. I've tested it also by creating a small project using native code and indeed Galaxy Nexus chooses the wrong library (armeabi instead of armeabi-v7a).
I've reported this bug at http://code.google.com/p/android/issues/detail?id=25321 , with the sample project attached on the bug. Please star it to bring attention to Android engineers.
回答3:
I think the problem is that there are 2 cores in the processor. Thus, you have 600 Mhz for one core. So if your math method uses only one thread this can be an answer. Although, I do not understand why it is 2 times slower (comparable time can be explained).
来源:https://stackoverflow.com/questions/8617789/android-floating-point-math-performance