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
433 views
in Technique[技术] by (71.8m points)

android - Why very simple Renderscript runs 3 times slower in GPU than in CPU

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:

  1. I monitor the logcat to see if this log is displayed "Successfully loaded runtime: libRSDriver_adreno.so"
  2. 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

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

1 Reply

0 votes
by (71.8m points)

Your script is doing no meaningful work, but you are potentially making additional copies of the data structure (can't guarantee what the GPU driver does in this case). Why not try an example that actually does something with the input, rather than just copying it directly to the output?


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

1.4m articles

1.4m replys

5 comments

57.0k users

...