필터 지우기
필터 지우기

parfor is not really speeding up the function.

조회 수: 4 (최근 30일)
Filip
Filip 2023년 2월 8일
댓글: Filip 2023년 2월 8일
I am trying to speed up my code that is computing the max. coherence of each pair of rows insede of matrices A and B:
A = rand(1000, 100);
B = rand(4, 100);
fcmat = zeros(size(A,1), size(B,1));
for i = 1:size(A,1)
for j = 1:size(B,1)
c = mscohere(A(i,:),B(j,:));
fcmat(i,j) = max(c);
end
end
I have tried to use a simple parfor, but it runs in approximately same time as the non-parfor loop
B_n = size(B,1);
parfor (i = 1:size(A,1))
for j = 1:B_n
c = mscohere(A(i,:),B(j,:));
fcmat(i,j) = max(c);
end
end
Is there anything I have done (or probably have not done) that is causing this code to not run faster? Is there some other way/technique that could make this code run faster?
Thank you.

답변 (1개)

Ganesh Gudipati
Ganesh Gudipati 2023년 2월 8일
Hi Filip,
I could see some significant speed up in the code you provided after using parfor. Here are my observations
However you can check the following documentation to Improve parfor Performance. I hope this helps.
Thanks
Ganesh Gudipati
  댓글 수: 1
Filip
Filip 2023년 2월 8일
Thank you.
The problem was that Matlab allows the user to use parfor without having the Parallel Computing toolbox installed.

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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by