parfor loop stalls where a for loop does fine, no error

5 views (last 30 days)
Hi all,
I have a parfor loop that calls a function. Parameters are passed to the function. Two of the parameters are omega and delta, if either one of these is close to zero, the parfor loop stalls out and freezes. But, if it is for loop it works fine.
Doesn't make any sense to me. There is clearly more code to it....but is there any red flag that would make sense when parameters are close to zero, it works fine in a for, but stalls in a parfor?
Here is the code
parfor j = 1:numberOfICs
str = sprintf('trial: %d/%d',j,numberOfICs); disp(str)
IC = ICmatrix(j,:); % Choose initial position
% Pass to RK4
[all_Y_pos(:,:,j),all_aveLE(:,j),savedLETimeTemp] = ODE_approx_RK4(j,epsilon,eta,delta,omega,A,xi...
,IC(1),IC(2),t0,dt,tf,pert,threshold,exposh,orbitSaved,save_aveV...
,save_aveLE, orbitSaveStart);
if j == 1
savedLETime(j,:) = savedLETimeTemp;
end
end
Will

Answers (1)

Edric Ellis
Edric Ellis on 29 Mar 2012
The main difference when running PARFOR are that different iterations of the loop are executed by different processes. So, if your function has persistent state for example, that is not shared across all the workers. Other than that, there are no expected differences in the way functions are evaluated on the workers.

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!