Converting this big for-loop into a PARFOR-loop

I am struggling converting this loop into a PARFOR loop:
NARRtroughid=nan(277,349,93,30,3,'single');
for yr=1:30 fprintf('**********NOW ON yr %d**********\n',yr);
for dy=1:92 fprintf('NOW ON day %d\n',dy);
for la=100+2:135-2
for lo=80+7:170-7
NARRtroughid(la,lo,dy,yr,:)=trofid(lat(la,1),lon(1,lo),lat,lon,squeeze(h(:,:,dy,yr)));
end
end
end
end
I am getting slicing errors and I dont really understand how to slice this up. Here is the error:
variable indexed but not sliced,in a PARFOR loop. this might result in unnecessary communication overhead.
I read online but no help for large nested-forloops like this one. Any help you be great!

댓글 수: 1

Can you show how you implemented the PARFOR loop? It will be easier to help you slice your variables.
BTW not slicing your variables doesn't cause an error. The warning means that it might take longer to run the loop because in each iteration MATLAB sends the entire array to the worker, instead of just the relevant slice, which takes more time.

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

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 8월 4일

0 개 추천

Hi,
first of all you got a warning, not an error. The warning indicates that it might be, that the parfor loop does not perform as one expects. Nevertheless it should run, does it?
Titus

카테고리

도움말 센터File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

질문:

2011년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by