Large broadcast variable in parfor loop

조회 수: 3 (최근 30일)
dominik
dominik 2013년 11월 5일
답변: dominik 2013년 11월 25일
Hi
Im having a for loop that i want to parallelize. In the loop th essential part is an interpolation. The problem is that the interpolant is huge, (V has 2 to 4 GB). Once I parallelize the loop, this read-only broadcast variable is multiplied in the memory and i run out of memory.
Is there a way to avoid this? i.e. to have the speedup benefits of parallalizing without the need to duplicate the huge interpolant in the memory?
IP=scatteredinterpolant(w,x,y,z,V)
parfor i=1:N
user_function( parameters, IP(ww(i),xx(i),yy(i),zz(i)) )
end
Thanks Dominik

채택된 답변

Edric Ellis
Edric Ellis 2013년 11월 6일
Unfortunately, because PARFOR supports operation across multiple machines and uses multiple MATLAB processes, I'm afraid there's no way to avoid having broadcast data replicated across the workers.
If you're using only local workers, you might be able to use this File Exchange submission: http://www.mathworks.com/matlabcentral/fileexchange/28572-sharedmatrix
  댓글 수: 1
dominik
dominik 2013년 11월 7일
Thanks Eric, this seems to be what i need (if this allows me to send multiple interpolants to the shared memory). Never having used mex files I have problems getting it running so far, but I guess once working it will do the trick for me. It's a pity this functionality isnt included in matlab as an option for local parallelisation...Thanks!

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

추가 답변 (1개)

dominik
dominik 2013년 11월 25일
I got it running.... but it seems this submission does only work for cells and matrixes. When I try to share a griddedInterpolant I get an error.

카테고리

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