Some workers go idle in parfor creating a waste of computation time
Show older comments
Hi all,
I have a for loop of 90 iterations (array xx has 90 rows and say 20 colums - each row is an iteration). Each iteration evaluate a costly function. the evaluation time for some functions is around ~ 24 hours while for some others is around 10 hours.
I am using parfor with a pool of 20 workers. However, I observe that some of the workers go idel after finishing the iteration faster. this can create a large waster of time. How can I request parfor worker to immediately run a new iteration after it finishes its current evlauation?
myCluster = parcluster('local');
myCluster.NumWorkers = 20;
saveProfile(myCluster);
p=parpool(20, 'IdleTimeout', Inf);
opts = parforOptions(p, 'RangePartitionMethod', 'fixed', 'SubrangeSize', 1);
parfor (k=1:size(xx,1),opts)
out(k,:)=f(xx(k,:), k);
end
Accepted Answer
More Answers (0)
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!