| Parallel Computing Toolbox™ | ![]() |
matlabpool
matlabpool open
matlabpool open poolsize
matlabpool open configname
matlabpool open configname poolsize
matlabpool poolsize
matlabpool
configname
matlabpool configname poolsize
matlabpool close
matlabpool close force
matlabpool close force configname
matlabpool size
matlabpool('open',
...)
matlabpool('close',
...)
matlabpool('open',...,
'FileDependencies', filecell)
matlabpool enables the parallel language features in the MATLAB language (e.g., parfor) by starting a parallel job that connects this MATLAB client with a number of labs.
matlabpool or matlabpool open starts a worker pool using the default parallel configuration, with the pool size specified by that configuration. (For information about setting up and selecting parallel configurations, see Programming with User Configurations.) You can also specify the pool size using matlabpool open poolsize, but most schedulers have a maximum number of processes that they can start (4 for a local scheduler). If the configuration specifies a job manager as the scheduler, matlabpool reserves its workers from among those already running and available under that job manager. If the configuration specifies a third-party scheduler, matlabpool instructs the scheduler to start the workers.
matlabpool open configname or matlabpool open configname poolsize starts a worker pool using the Parallel Computing Toolbox user configuration identified by configname rather than the default configuration to locate a scheduler. If the pool size is specified, it overrides the maximum and minimum number of workers specified in the configuration, and starts a pool of exactly that number of workers, even if it has to wait for them to be available.
Without specifying open or close, the command default is open. So, matlabpool poolsize, matlabpool configname, and matlabpool configname poolsize operate as matlabpool open ..., and are provided for convenience.
matlabpool close stops the worker pool, destroys the parallel job, and makes all parallel language features revert to using the MATLAB client for computing their results.
matlabpool close force destroys all parallel jobs created by matlabpool for the current user under the scheduler specified by the default configuration, including any jobs currently running.
matlabpool close force configname destroys all parallel jobs being run under the scheduler specified in the configuration configname.
matlabpool size returns the size of the worker pool if it is open, or 0 if the pool is closed.
matlabpool('open', ...) and matlabpool('close', ...) can be invoked as functions with optional arguments. The default is 'open'. For example, the following are equivalent:
matlabpool open MyConfig 4
matlabpool('open', 'MyConfig', 4)matlabpool('open',..., 'FileDependencies', filecell) starts a worker pool and allows you to specify file dependencies so that you can pass necessary files to the workers in the pool. The cell array filecell is appended to the FileDependencies specified in the configuration used for startup.
When a pool of workers is open, the following commands entered in the client's Command Window also execute on all the workers:
cd addpath rmpath
This enables you to set the working directory and the path on all the workers, so that a subsequent parfor-loop executes in the proper context.
If any of these commands does not work on the client, it is not executed on the workers either. For example, if addpath specifies a directory that the client cannot see or access, the addpath command is not executed on the workers. However, if the working directory or path can be set on the client, but cannot be set as specified on any of the workers, you do not get an error message returned to the client Command Window.
This slight difference in behavior is an issue especially in a mixed-platform environment where the client is not the same platform as the workers, where directories local to or mapped from the client are not available in the same way to the workers, or where directories are in a nonshared file system. For example, if you have a MATLAB client running on a Microsoft Windows operating system while the MATLAB workers are all running on Linux® operating systems, the same argument to addpath cannot work on both. In this situation, you can use the function pctRunOnAll to assure that a command runs on all the workers.
Start a pool using the default configuration to define the number of labs:
matlabpool
Start a pool of 16 labs using a configuration called myConf:
matlabpool open myConf 16
Start a pool of 2 labs using the local configuration:
matlabpool local 2
Run matlabpool as a function to check whether the worker pool is currently open:
isOpen = matlabpool('size') > 0Start a pool with the default configuration, and pass two M-files to the workers:
matlabpool('open', 'FileDependencies', {'mod1.m', 'mod2.m'})defaultParallelConfig, pctRunOnAll, parfor
![]() | localPart | methods | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |