Code optimization with GPU
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone, I have the following line of codes which I would like to parallelize on the GPU :
U = zeros(q, M, q, 'gpuArray');
for j=1:q
U(j,:,j) = my_line_vector;
end
Is there any way to suppress the loop?
Thes are the lines of code that run the slowest in my program.
Thank you in advance
Michel
0 个评论
采纳的回答
Joss Knight
2021-1-16
编辑:Joss Knight
2021-1-16
I = reshape(gpuArray.eye(q),q,1,q);
U = I.*my_line_vector;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!