Why is compiled parfor repeatedly trying to start a parallel pool?
10 views (last 30 days)
Show older comments
Situation: MATLAB 2015b, CentOS Linux 7, Compiler & Parallel toolboxes installed on machine, Parallel not licensed. Uncompiled: code works fine (parfor loops work like for loops in reverse since the Parallel Toolbox is not licensed). Compiled: at each parfor loop, code tries to start parallel pool (wasting >10 sec).
Example code:
function out = TestPar(s1,s2)
s1=str2num(s1);s2=str2num(s2);
out=zeros(1,s1);
for k = 1:3,
parfor p=1:numel(out),
out(p) = mean(mean(rand(s2,s2)));
end
end
Code Execution uncompiled: TestPar('10000','155') Code Execution compiled: system('TestPar 10000 155')
0 Comments
Answers (1)
OCDER
on 4 Oct 2017
Edited: OCDER
on 4 Oct 2017
Your compiled application (which is pre 2016a) has access to parallel processing and will use the default parallel setting, which is to autocreate a parpool when a parfor is encountered. Change the default setting for this autocreate feature before compiling, since the compiled application will use the default setting of your machine.
To fix:
ps = parallel.Settings;
ps.Pool.AutoCreate = false; %will prevent parpool from activating when encountering parfor
3 Comments
See Also
Categories
Find more on Licensing on Cloud Platforms 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!