matlabpool - Start parallel language worker pool

Syntax

matlabpool
matlabpool open
matlabpool open poolsize
matlabpool open conf
matlabpool open conf poolsize
matlabpool conf poolsize
matlabpool close
matlabpool close force
matlabpool close force conf

Description

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 conf or matlabpool open conf poolsize starts a worker pool using the Parallel Computing Toolbox™ user configuration conf 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.

matlabpool conf poolsize is the same as matlabpool open conf poolsize and is 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 conf destroys all parallel jobs being run under the scheduler specified in the configuration conf.

matlabpool can be invoked as either a command or a function. For example, the following are equivalent:

matlabpool open conf 4
matlabpool('open', 'conf', 4)

Remarks

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.

Examples

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

See Also

defaultParallelConfig, pctRunOnAll, parfor

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS