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