【问题标题】:Why very simple Renderscript runs 3 times slower in GPU than in CPU为什么非常简单的 Renderscript 在 GPU 中运行速度比在 CPU 中慢 3 倍
【发布时间】:2013-12-04 17:14:48
【问题描述】:

我的测试平台:

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如下:

#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

强制脚本在 CPU 上运行以进行性能比较。

在我计算运行时间之前,我还使用了让脚本运行一小段时间来预热。

为了确保我知道代码是在 GPU 上运行还是在 CPU 上运行,我监控以下两件事:

  1. 我监控logcat看这个日志是否显示“成功加载运行时:libRSDriver_adreno.so”
  2. 我监控 CPU 使用率

我用两个分辨率分别为 1600×1067 和 1920×1200 的大图像运行这个脚本。由于使用 Android 4.4 的 Nexus 5 支持 Renderscript GPU 计算,我假设这个简单脚本的性能在 GPU 中会更高。然而,结果一致表明,在(Nexus 5 的多核)CPU 上运行脚本的速度几乎是在 Adreno 330 GPU 上运行的 3 倍。

我想问一下为什么会发生这种情况,以及我是否遗漏了一些东西以使这个简单的脚本更快。

【问题讨论】:

    标签: android gpgpu renderscript


    【解决方案1】:

    您的脚本没有做任何有意义的工作,但您可能会制作数据结构的额外副本(无法保证 GPU 驱动程序在这种情况下会做什么)。为什么不尝试一个实际处理输入的示例,而不是直接将其复制到输出?

    【讨论】:

    猜你喜欢
    • 2019-07-10
    • 2016-10-23
    • 2022-01-19
    • 2015-12-27
    • 2016-08-08
    • 1970-01-01
    • 2019-04-18
    • 2021-02-01
    相关资源
    最近更新 更多