Right Candidate for GPU Computing?

1 view (last 30 days)
Mehdi
Mehdi on 5 Aug 2014
Commented: Mehdi on 15 Aug 2014
There is a small code attached to this question. Basically I would like to see if you consider this as a candidate for GPU computing or not . It has multiple for loops which makes it a good candidate for parallel computing in general. However I have the following problems and questions regarding transforming it to a GPU code and I would appreciate your input:
1- The basic calculation inside the for loops is calculating orthogonal polynomials which are done in the symbolic form in MATLAB which does not accept gpuArray as input. Is there a workaround for this?
2- To perform the for loops on GPU do I need to use gpuArray.colon to specify range of the loop variables? Is it possible to write "for i=n1:n2" while n1 and n2 are of gpuArray type? If the loop is somehow performed on GPU will it be a parallel for, or it will be just a for with the inner calculations performed on GPU. If the for won't be parallel on GPU how can we make it parallel then?
3- Is it possible to use arrayfun to perform the for loops on GPU. In that case are the for loops parallel loops or only the calculation inside the for loops will be done on the GPU?
4- Considering we have indexing inside for loops (though the operations are element-wise) is it possible to use arrayfun for the for loop at all? Still we have the problem of the symbolic calculations as well.
Thanks very much in advance!

Accepted Answer

Matt J
Matt J on 5 Aug 2014
Edited: Matt J on 5 Aug 2014
The GPU is not meant for parallelizing general for-loops, although in some future release PAGEFUN might hopefully move us closer to that capability.
  3 Comments
Matt J
Matt J on 6 Aug 2014
Since there's no longer any clear reason you'd be using the GPU, it's not clear why the symbolic computations are a problem any longer. If you use PARFOR to accelerate your inner for-loop, you are of course free to do symbolic computation.
Although, I wonder why you wouldn't expand the polynomials into a form compatible with polyval. Moreover, I wonder why you would evaluate lots of polynomials and then sum the result over a loop. Since the sum of polynomials is again a polynomial, it seems to make more sense to sum the coefficients of the of polynomials and evaluate just the single final resulting polynomial.
Mehdi
Mehdi on 15 Aug 2014
Thanks Matt, I found what the problem was. The polynomials were repeatedly being calculated inside the loop. So I changed the code to calculate the polynomials at all the points I need only once before the loop, then I use them inside the loop...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!