Speed up a program

조회 수: 3 (최근 30일)
Vlad
Vlad 2014년 12월 4일
댓글: Vlad 2014년 12월 5일
It is required to speed up a very simple program:
for i=1:1000
for j=1:1000
A=fun(i, j) % matrix 3x3
D=eig(A);
end
end
Execution time for fun(i, j) is much less then time for eig(A). A mean execution time of whole program is about 40 minutes. I wrote a mex-file for calculating eigenvalues and improved the speed by 4 times. So now the mean time is about 10 minutes. I tried parfor-loop, it did not work. CUDA did not help as well =(
I will be very appreciated for any idea.

답변 (2개)

Zoltán Csáti
Zoltán Csáti 2014년 12월 4일
Why didn't parfor and CUDA work? Do you meet the requirements?
  댓글 수: 1
Vlad
Vlad 2014년 12월 5일
I suppose, that matrix 3x3 is very small for gpu-calculations, that's why there is no advantage of using it.

댓글을 달려면 로그인하십시오.


Edric Ellis
Edric Ellis 2014년 12월 5일
Here's what I tried with PARFOR, and this worked:
function D = pfeg
N = 100;
D = zeros(N, N, 3);
parfor i = 1:N
for j = 1:N
A = fun(i, j);
D(i, j, :) = eig(A);
end
end
end
function A = fun(i, j)
A = rand(3) .* i + j;
end
I'm not surprised that the GPU didn't help much - 3x3 matrices are simply too small to take good advantage of the GPU capabilities (unless you can use pagefun - which unfortunately you cannot in this case).
  댓글 수: 1
Vlad
Vlad 2014년 12월 5일
OK. I will try and write about results later.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by