为什么很简单的Renderscript运行在GPU比CPU慢3倍 [英] Why very simple Renderscript runs 3 times slower in GPU than in CPU

查看:895
本文介绍了为什么很简单的Renderscript运行在GPU比CPU慢3倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试平台:

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

我写了一个很简单的Renderscript如下:

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;
}

我也用

adb shell setprop debug.rs.default-CPU-driver 1

迫使脚本在CP​​U的性能比较中运行。

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.

要确保我知道GPU或CPU的code运行是否我监视以下两件事情:

To make sure that I know whether the code run on GPU or CPU, I monitor the following two things:


  1. 我监视的logcat,看是否显示此日志成功加载运行时:libRSDriver_adreno.so

  2. 我监视CPU使用率

我运行此脚本与1600by1067和1920by1200分别解决两个大的图像。由于Nexus 5上使用的是Android 4.4有Renderscript GPU计算我认为这种简单的脚本的性能会在更高的GPU支持。但是,结果一致表明:(Nexus 5的多核心)CPU运行脚本​​的速度比的Adreno GPU 330跑得更快近3倍。

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.

推荐答案

您的脚本做任何有意义的工作,但你可能使该数据结构的其他副本(不能保证GPU驱动程序不会在这种情况下的) 。为什么不尝试真正做什么事情与输入一个例子,而不仅仅是直接复制它的输出?

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?

这篇关于为什么很简单的Renderscript运行在GPU比CPU慢3倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆