create parallel pool on cluster -凯发k8网页登录
create parallel pool on cluster
syntax
description
parpool
starts a parallel pool of workers using the default profile. with default preferences, matlab® starts a pool on the local machine with one worker per physical cpu core up to the limit set in the default profile. for more information on parallel preferences, see specify your parallel preferences.
in general, the pool size is specified by the preferredpoolnumworkers
property of the default profile. for all factors that can affect your pool size, see
.
parpool
enables the full functionality of the parallel language features in matlab by creating a special job on a pool of workers, and connecting the matlab client to the parallel pool. parallel language features include parfor
, parfeval
, parfevalonall
, spmd
, and distributed
. if possible, the working folder on the workers is set to match that of the matlab client session.
parpool(
creates and returns a pool with the specified number of workers. poolsize
)poolsize
can be a positive integer or a range specified as a 2-element vector of integers. if poolsize
is a range, the resulting pool has size as large as possible in the range requested.
specifying the poolsize
overrides any value specified in the preferredpoolnumworkers
property, and starts a pool of exactly that number of workers, even if it has to wait for them to be available. most clusters have a maximum number of workers they can start. if the profile specifies a matlab job scheduler cluster, parpool
reserves its workers from among those already running and available under that matlab job scheduler. if the profile specifies a local or third-party scheduler, parpool
instructs the scheduler to start the workers for the pool.
parpool(___,
applies the specified values for certain properties when starting the pool.name,value
)
examples
input arguments
output arguments
tips
the pool status indicator in the lower-left corner of the desktop shows the client session connection to the pool and the pool status. click the icon for a menu of supported pool actions.
with a pool running: with no pool running:
if you set your parallel preferences to automatically create a parallel pool when necessary, you do not need to explicitly call the
parpool
command. you might explicitly create a pool to control when you incur the overhead time of setting it up, so the pool is ready for subsequent parallel language constructs.delete(poolobj)
shuts down the parallel pool. without a parallel pool,spmd
andparfor
run as a single thread in the client, unless your parallel preferences are set to automatically start a parallel pool for them.when you use the matlab editor to update files on the client that are attached to a parallel pool, those updates automatically propagate to the workers in the pool. (this automatic updating does not apply to simulink® model files. to propagate updated model files to the workers, use the function.)
if possible, the working folder on the workers is initially set to match that of the matlab client session. subsequently, the following commands entered in the client command window also execute on all the workers in the pool:
this behavior allows you to set the working folder and the command search path on all the workers, so that subsequent pool activities such as
parfor
-loops execute in the proper context.when changing folders or adding a path with
cd
oraddpath
on clients with windows® operating systems, the value sent to the workers is the unc path for the folder if possible. for clients with linux® operating systems, it is the absolute folder location.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 folder that the client cannot access, theaddpath
command is not executed on the workers. however, if the working folder 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.be careful of this slight difference in behavior in a mixed-platform environment where the client is not the same platform as the workers, where folders local to or mapped from the client are not available in the same way to the workers, or where folders 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 to assure that a command runs on all the workers.another difference between client and workers is that any
addpath
arguments that are part of the folder are not set on the workers. the assumption is that the matlab install base is already included in the workers’ paths. the rules foraddpath
regarding workers in the pool are:subfolders of the
matlabroot
folder are not sent to the workers.any folders that appear before the first occurrence of a
matlabroot
folder are added to the top of the path on the workers.any folders that appear after the first occurrence of a
matlabroot
folder are added after thematlabroot
group of folders on the workers’ paths.
for example, suppose that
matlabroot
on the client isc:\applications\matlab\
. with an open parallel pool, execute the following to set the path on the client and all workers:addpath('p1', 'p2', 'c:\applications\matlab\t3', 'c:\applications\matlab\t4', 'p5', 'c:\applications\matlab\t6', 'p7', 'p8');
because
t3
,t4
, andt6
are subfolders ofmatlabroot
, they are not set on the workers’ paths. so on the workers, the pertinent part of the path resulting from this command is:p1 p2
p5 p7 p8 if you are using macintosh or linux, and see problems during large parallel pool creation, see .
version history
introduced in r2013bsee also
| | | | | | parfor
| | | | |