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!