【问题标题】:Why is this statement in a CUDA kernel slow?为什么 CUDA 内核中的这个语句很慢?
【发布时间】:2013-09-27 02:42:19
【问题描述】:

我正在使用 CUDA 做一些计算机视觉方面的工作。以下代码大约需要 20 秒才能完成。

__global__ void nlmcuda_kernel(float* fpOMul,/*other input args*/){

float fpODenoised[75];

/*Do awesome stuff to compute fpODenoised*/

//inside nested loops:(This is the statement that is the bottleneck in the code.)
      fpOMul[ii * iwl * iwxh + iindex * iwxh + il] = fpODenoised[ii * iwl +iindex];

}

如果我将该语句替换为

fpOMul[ii * iwl * iwxh + iindex * iwxh + il] = 2.0f;

代码几乎不需要几秒钟即可完成。

为什么指定的语句很慢,我怎样才能让它运行得快?

【问题讨论】:

    标签: c cuda


    【解决方案1】:

    当您更改代码时,编译器可以看到不再需要所有出色的 fpdenoised 代码,并且可以对其进行优化。您修改的实际语句不是性能差异的直接原因。您可以通过查看每种情况下的 ptx 或 sass 代码来验证这一点。

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 2010-10-19
      相关资源
      最近更新 更多