필터 지우기
필터 지우기

parfor and nested loop

조회 수: 4 (최근 30일)
huda nawaf
huda nawaf 2014년 1월 23일
댓글: huda nawaf 2014년 1월 24일
hi,
can I use parfor with nested loop?
for ex.
parfor i=1:5
for j=1:2
%%whatever
end
end
should I use par with each for or with one.
please, I need somebody can solve my problem.
Thanks in advance

답변 (2개)

Mischa Kim
Mischa Kim 2014년 1월 23일
Hello huda, there are no nested parfor loops. Parallelization with parfor only works on the outermost loop.
  댓글 수: 1
huda nawaf
huda nawaf 2014년 1월 24일
thanks,
ok, do u mean it is not problem if i use parfor for outermost loop and the inside loop stay as it.
I just wonder because when I used parfor for only outermost loop, I did not find any improvement in terms of running time.
Please, I badly need that.

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


Matt J
Matt J 2014년 1월 23일
편집: Matt J 2014년 1월 23일
To combine the loops into a single parfor loop,
parfor k=1:10
[i,j]=ind2sub([5,2],k);
%%whatever
end
  댓글 수: 3
Matt J
Matt J 2014년 1월 24일
The effectiveness of parfor depends a lot on what you're doing inside the loop.
huda nawaf
huda nawaf 2014년 1월 24일
yes, but I read if I have large array it is best to use spmd.
this function will distribute the array among workers.
but I have problem. Also I used pmode .
I did not find the efficiency of these functions. I hope to find simple example show me the difference between parallel and serial processing.
thanks

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

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by