A parallel pool is a set of MATLAB® workers in a compute cluster or desktop, bound together by a special type of job so that they can be used interactively and can communicate with each other during the lifetime of the job. In one sense, a parallel pool describes this collection of workers, such as when referring to the pool size. In another sense, a parallel pool describes the special job running on these workers, such as when viewing your jobs in the Job Monitor. While these pool workers are reserved for your interactive use, they are not available to other users.
You can have only one parallel pool accessible at a time from a MATLAB client session. In MATLAB, the current parallel pool is represented by a parallel.Pool object.
By default, a parallel pool starts automatically when needed by certain parallel language features. The following statements and functions can cause a pool to start:
Your parallel preferences specify which cluster the pool runs on, and the preferred number of workers in the pool. To access your preferences, on the Home tab, in the Environment section, click Parallel > Parallel Preferences.
In your parallel preferences, you can turn off the option for the pool to open or close automatically. If you choose not to have the pool open automatically, you can control the pool with the following techniques.
You can use the pool indicator in the lower-left corner of the desktop to manually start a parallel pool. Click the indicator icon, and select Start parallel pool. The pool size and cluster are specified by your parallel preferences and default cluster. Your default cluster is indicated by a check mark on the Parallel > Default Cluster menu.
The menu options are different when a pool is running; in this case you can select Shut down parallel pool.
Start a Parallel Pool. You can start and stop a parallel pool programmatically, using default settings or specifying alternatives.
To open a parallel pool based on your preference settings:
parpool
To open a pool of a specific size:
parpool(4)
To use a cluster other than your default, to specify where the pool runs:
parpool('MyCluster',4)
Shut Down a Parallel Pool. You can get the current parallel pool, and use that object when you want to shut down the pool:
p = gcp; delete(p)
There are several places to specify your pool size. Several factors might limit the size of your pool. The actual size of your parallel pool is determined by the combination of the following:
Licensing or cluster size
The ultimate limit on the number of workers in a pool is restricted to the number of workers in your cluster. This might be determined by the number of MATLAB Distributed Computing Server™ licenses available, or in the case of MJS by the number of workers running in the cluster. A local cluster running on the client machine requires no licensing beyond the one for Parallel Computing Toolbox™, and the limit on the number or workers is high enough to support the range of known desktop hardware.
Cluster profile number of workers (NumWorkers
)
A cluster object can set a hard limit on the number of workers, which you can set in the cluster profile. Even if you request more workers at the command line or in your preferences, you cannot exceed the limit set in the applicable profile. Attempting to exceed this number generates an error.
Command-line argument
If you specify a pool size at the command line, this overrides the setting of your preferences. But this value must fall within the limits of the applicable cluster profile.
Parallel preferences
If you do not specify a pool size at the command line, MATLAB attempts to start a parallel pool with a size determined by your parallel preferences, provided that this value falls within the limits of the applicable cluster profile. Note that this is a preference, not a requirement or request for a specific number of workers. So if a pool cannot start with as many workers as called for in your preferences, you get a smaller pool, without any errors. If you need an exact number of workers, specify the number at the command line.
For selection of the cluster on which the pool runs, precedence is determined by:
The command-line cluster object argument. For example,
this overrides the default profile setting, and uses the cluster identified
by the profile 'MyProfile'
:
c = parcluster('MyProfile'); p = parpool(c);
The cluster specified in the default profile:
p = parpool;
delete
| distributed
| gcp
| parcluster
| parfeval
| parfor
| parpool
| spmd