for-loop GPU Parallelization

조회 수: 1 (최근 30일)
John
John 2011년 12월 27일
I was wondering whether there is a way to parallelize a for-loop such that each GPU core runs one in parallel. I have access to the Parallel Computing Toolbox v2011a, and of course any freely available files, if all I have to do is download them into a folder (e.g. GPUmat).
More specifically, I want to drive multiple systems to equilibrium independently, with each system consisting mainly of an array.
As far as I know, there is no way to do such a thing explicitly with the Toolbox? I tried circumventing this by defining a gpu-array "index" [1 2 3 ... N ] and using arrayfun on the array. The problem I ran into was arrayfun won't let me run loops on the GPU. Furthermore, I'm not sure what this exactly does to each GPU core.
I also tried GPUmat's compiler, which won't let me call indices of arrays. It's also not completely clear whether the GPUfor loop is a parallel for-loop.

답변 (1개)

Jill Reese
Jill Reese 2011년 12월 27일
R2011a does support loops with arrayfun executing on the GPU. Without knowing more details about the code you'd like to execute on the GPU it's hard to provide suggestions on how to proceed. Could you add a code snippet to your post?
  댓글 수: 2
John
John 2011년 12월 28일
I haven't implemented it to my program yet, but I've been playing around with it.
What I tried was
function y = testfunction(x)
for i=1:x
y=x+i;
end
This works fine for normal arrays but doesn't for gpu arrays.
Jill Reese
Jill Reese 2012년 7월 2일
Are you passing in x as a scalar?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by