Converting this big for-loop into a PARFOR-loop
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Yoav Livneh
2011-8-4
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
2011-8-4
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!