for loop and data in GPU memory
3 次查看(过去 30 天)
显示 更早的评论
If the for loop is parallelizable, does the Parallel Computing Toolbox execute for loop in a parallel fashion when it is acting on data stored in GPU memory?
2 个评论
Jill Reese
2012-11-8
It would be a bit easier to answer your question if you provided some sample code.
Thanks, Jill
采纳的回答
Jill Reese
2012-11-9
The for loop is not performed in parallel when you write code like this:
A = gpuArray(X);
for i = 1:length(A)
B(i) = f(A(i));
end
However, if your function f contains only elementwise operations, then you could achieve more parallelism by using arrayfun like so:
B = arrayfun(@f, A);
0 个评论
更多回答(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!