0
我正在使用CUDA做一些計算機視覺工作。以下代碼需要大約20秒才能完成。爲什麼CUDA內核中的這條語句很慢?
__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;
該語句的代碼幾乎需要幾秒鐘就可以完成。
爲什麼指定的語句很慢,我該如何讓它運行得很快?