Is there a way to run this loop in gpu and will it consume lesser time compared to parallel cpu computation time?

34 views (last 30 days)
Naveen kumar Elumalai on 20 Mar 2018
Commented: Joss Knight on 2 Apr 2018
N=50;
for n=1:8
b=rand(300,103);
w=rand(300,1);
[Q,R]=qr(b,0);
A(:,:,n);=R
end

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
Could I be able to access it at once, instead of using page by page
%code
for n=1:36
[Q(:,:,n),R(:,:,n)]=qr(A2(:,:,n),0);
end
I wanted this to happen without for loop. Here A2, is 600*103*36,
R needs to be of the size 103*103*36 and
Q of the size 600*103*36

Naveen kumar Elumalai on 22 Mar 2018
This is taking so much time than the normal cpu execution