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

谁说胖子不能爱 提交于 2020-01-07 04:07:26

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/20381691/why-very-simple-renderscript-runs-3-times-slower-in-gpu-than-in-cpu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!