How to define 'local' matlabpool size at runtime for Parallel Computing Toolbox use in compiled MATLAB code?
Show older comments
Is it possible for a user of a standalone compiled MATLAB code, which uses the Parallel Computing Toolbox, to define the matlabpool size at run time?
My code queries the local configuration to get the number of workers:
schd = findResource('scheduler', 'configuration', 'local');
numWorkers = schd.ClusterSize;
I then allow the user to revise that number down via a GUI contol (so they don't max out their system if they have other stuff running). When processing begins I call:
matlabpool('local', numWorkers)
... % do stuff with parfor
matlabpool close
It works fine on my machine, however, when I compile this code on my machine (where the standard 'local' configuration has 8 workers) and then run it on a machine with only 2 cores, the number of workers gets set to 8, even though only 2 are available. Clearly the Compiler has compiled up and included my 'local' config.
If I don't know in advance how many cores a user will have, how can I access THEIR 'local' matlabpool configuration at runtime, instead of mine?
I'm using R2011a.
Many thanks, Nick
Accepted Answer
More Answers (2)
Marco Lavalle
on 23 Jan 2012
0 votes
Hi.
Last week I had a similar problem and I was glad to see this post.
However I have still an unsolved issue. I am trying to execute the program myExe.exe on a different machine than the one I used to compile the code.
1. I compile my code using mcc on the machine A, which has 8 cores.
2. On the machine A, I generate a parallel configuration file specifying 16 cores (=number of cores on the machine B). I tried several configuration options, like 'local' or jobmanager.
3. Then I connect to machine B.
4. I execute: myExe.exe -mcruserdata ParallelConfigurationFile:myConfig.mat
5. I get the following error: "Error when using the 'scheduler' section of the configuration myConfig.mat The ClusterSize for a local scheduler must be between 1 and 8".
How can I tell MCR to use all 16 cores on the machine B? And how should I prepare my configuration file? The documentation does not seem to provide an answer.
Many thanks, Marco.
Eduard
on 25 Dec 2012
0 votes
Hi, I compiled my code and setmcruserdata('ParallelConfigurationFile','local.mat')
And then I tried to execute the code like this:
MAAT_Master.exe -mcruserdata ParallelConfigurationFile:local.mat
It didn't work and led to the following error message:
??? MAAT_Master.exe -mcruserdata ParallelConfigurationFile:local.mat | Error: Unexpected MATLAB expression.
Can you help me, what is wrong with this code?
1 Comment
Walter Roberson
on 25 Dec 2012
Do not use that from the MATLAB command prompt. Or prefix it with '!' to run it from the MATLAB command prompt.
Categories
Find more on Job and Task Creation 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!