Is there a way to run this loop in gpu and will it consume lesser time compared to parallel cpu computation time?
이전 댓글 표시
N=50;
for n=1:8
b=rand(300,103);
w=rand(300,1);
[Q,R]=qr(b,0);
A(:,:,n);=R
end
댓글 수: 8
Joss Knight
2018년 3월 20일
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
2018년 3월 21일
First place...is the code working ?
Naveen kumar Elumalai
2018년 3월 21일
Joss Knight
2018년 3월 22일
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
2018년 3월 22일
편집: Walter Roberson
2018년 3월 22일
Joss Knight
2018년 3월 22일
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
2018년 3월 29일
편집: Naveen kumar Elumalai
2018년 3월 29일
Joss Knight
2018년 4월 2일
No, you cannot. See answers to the equivalent questions from you and others e.g.
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!