- Turn off auto-opening pools in the parallel preferences UI. Then you have essentially the same situation as existed in R2013a.
- Use the optional "number of workers" argument in your PARFOR loop - see the documentation for more.
Controlling new parallel feature "Automatically create a parallel pool when parallel keywords are executed"
18 views (last 30 days)
Show older comments
Hi all,
is there a possibility to control this feature (e.g. temporarily deactivate or read the settings value) from within a script?
Background is that I have a script that contains a parfor loop. For this parfor loop to work on workers there needs to be done some initializing though before entering the loop. This initialization is omitted when the matlabpool is automatically created when reaching the parfor loop.
This means I either need to start the matlabpool before reaching the loop so I can do the initialization (which I don't want to do by default) or (as an ugly workaround) I could add a dummy parfor loop to trigger the automatic startup of the matlabpool due to the new setting early.
Is there a proper way to control the preference (without user interaction)?
Regards Eduard
0 Comments
Accepted Answer
Edric Ellis
on 15 Jan 2014
Unfortunately, there's no API to modify the parallel preferences. I think you have essentially two options here, and these are:
As an example of the second approach, you could do something like this
if wantToGoParallel
M = Inf;
else
M = 0;
end
parfor (idx = 1:N, M)
doStuff(...);
end
2 Comments
Friedrich
on 15 Jan 2014
Actually one could change one entry in the parallel.settings file in the prefdir. There is one sections in that file which reads:
<settings name="pool">
<key name="AutoCreate">
<bool>
<value>1</value>
</bool>
</key>
Change the value 1 to 0 to disable it. So a bit fopen, fseek, fwrite does the job.
More Answers (0)
See Also
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!