My test platform:
Development OS: Windows 7 32-bit
Phone: Nexus 5
Phone OS version: Android 4.4
SDK bundle: adt-bundle-windows-x86-20131030
Build-tool version: 19
SDK tool version: 22.3
Platform tool version: 19
I wrote a very simple Renderscript as follows:
#pragma rs_fp_relaxed
uchar4 __attribute__((kernel)) someKernel(uchar4 in, uint32_t x, uint32_t y){
return in;
}
I also used
adb shell setprop debug.rs.default-CPU-driver 1
to force the script to run on CPU for performance comparison.
I also used let the script to run for a short period for warm up before I count the running time.
To make sure that I know whether the code run on GPU or CPU, I monitor the following two things:
- I monitor the logcat to see if this log is displayed "Successfully loaded runtime: libRSDriver_adreno.so"
- I monitor the CPU usage
I run this script with two big images with resolution 1600by1067 and 1920by1200 respectively. Since Nexus 5 using Android 4.4 has support for Renderscript GPU compute I assumed that the performance of this simple script will be higher in GPU. However, the result consistently showed that the speed of the script running on (Nexus 5's multi-core) CPU is almost 3 times faster than running on Adreno 330 GPU.
I'd like to ask why this happened and if I missed something to make this simple script faster.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…