Is there a way to run this loop in gpu and will it consume lesser time compared to parallel cpu computation time?
Show older comments
N=50;
for n=1:8
b=rand(300,103);
w=rand(300,1);
[Q,R]=qr(b,0);
A(:,:,n);=R
end
8 Comments
Joss Knight
on 20 Mar 2018
I don't want to put this as an answer to your question because it might seem like an obvious point: have you tried using gpuArray data to see if things go faster? Something as simple as b=rand(300,103,'gpuArray') would get you started.
KSSV
on 21 Mar 2018
First place...is the code working ?
Naveen kumar Elumalai
on 21 Mar 2018
Joss Knight
on 22 Mar 2018
But you're not doing a multiplication, you're doing a QR decomposition. Decomposing a 300-by-103 matrix should be sufficient computation that you get an advantage using the GPU, even when you're doing it 8 times.
Naveen kumar Elumalai
on 22 Mar 2018
Edited: Walter Roberson
on 22 Mar 2018
Joss Knight
on 22 Mar 2018
Okay, well this
for m=1:52
A(1:300,m)=B(1:300,n).*D(1:300,m);
end
is equivalent to this
A = B(1:300,n).*D;
If you have enough memory you could even vectorize the outer loop since this
for n=1:36
for m=1:52
A(1:300,m)=B(1:300,n).*D(1:300,m);
end
end
is equivalent to this
A = reshape(B,size(B,1),1,size(B,2)) .* D;
and then you'd access A page-by-page, like
[Q,R] = qr(A(:,:,n),0);
Naveen kumar Elumalai
on 29 Mar 2018
Edited: Naveen kumar Elumalai
on 29 Mar 2018
Joss Knight
on 2 Apr 2018
No, you cannot. See answers to the equivalent questions from you and others e.g.
Answers (1)
Naveen kumar Elumalai
on 22 Mar 2018
0 votes
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!