removing FOR loop to solve Ax=B on multidimensional arrays on GPU

2 views (last 30 days)
Hi,
my code looks this way now(Its an example code i wrote):
A=gpuArray(rand([1000 1000 1000]));
B=gpuArray(rand([1000 1 1000]));
for kk=1:1000
C(:,kk)=A(:,:,kk)\B(:,kk);
end
Assume that A,B,C matrices are GPU matrices. Is it possible to remove FOR loop and perform same operation as above lines on GPU using GPU matrices?.(Assume that i do not want to use 'while' or 'if' or any other loops )
The closest i could find was on fileexchange . However she/he does not talk about 'A\B' kind of operations. Also she/he does not talk about GPU computing.
Thank you.

Accepted Answer

Matt J
Matt J on 28 Nov 2018
C=pagefun(@mldivide,A,B)
  10 Comments
Matt J
Matt J on 30 Nov 2018
Edited: Matt J on 30 Nov 2018
Could you batch B's together as well? I.e., instead of applying pagefun to a 1000x1x1000 chunk of B data, apply to a chunk that is 1000 x BatchSizeB x 1000 or 1000 x BatchSizeB x BatchSizeA.
Joss Knight
Joss Knight on 1 Dec 2018
Yes, that. MLDIVIDE already works with multiple right-hand-sides, stacked along the columns of b. You only need PAGEFUN if A is changing.

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!