about parfor and spmd speedup

조회 수: 1 (최근 30일)
Xiaochun
Xiaochun 2011년 12월 30일
hi,
I have tested the speedup of parfor and spmd as
1)for
tic
for n=1:1000
A=B*C;
end
toc;
2)parfor spmd in one worker in the same pc:
// I have stored B C in the worker before computing
tic
parfor n=1:1000
A=B*C;
end
toc;
I find that the speed of parfor and spmd is only 2/3 of single matlab. is it possible to make it faster?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 30일
how big are B and C ?

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 30일
If your matrices are not very big, then the time required to set up workers and communicate data in to them can overwhelm any saving of using multiple workers.
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 12월 30일
With a matrix that big, your "for" matrix multiplication would be farmed out to the highly optimized and multithreaded BLAS or LAPACK, using multiple cores or hyperthreading.
I gather that each "parfor" or "smpd" worker requires a new process, and my understanding is that those would only have access to the core or hyperthread they are allocated to.
Xiaochun
Xiaochun 2012년 1월 2일
I see. Thank you very much.

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

추가 답변 (1개)

Knut
Knut 2012년 1월 3일
So the spot where parfor can really shine is loops that are : a)Simple enough that parfor can do them in parallell b)complex/non-general enough that MATLAB does not have a low-level library that does it in paralell anyways
?
  댓글 수: 1
Titus Edelhofer
Titus Edelhofer 2012년 1월 3일
As a rule of thumb: yes. Another way to formulate b): when you have e.g. a quad core (with hyperthreading), i.e., your task manager shows you 8 CPU usages, and your (loop) code runs at exactly 12.5% average CPU usage ...

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

카테고리

Help CenterFile Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by