partition
Syntax
Description
partition
divides an existing parallel pool into pool
partitions, allowing you to use specific resources from the existing pool. Use the
partition
function to create pools that target specific resources or
to create multiple pools to execute more than one parallel workflow at a time.
creates a pool object, newPool
= partition(pool
,"MaxNumWorkersPerHost",MaxNumWorkersPerHost
)newPool
, with up to
MaxNumWorkersPerHost
workers from each host contributing workers to
the input pool, pool
.
A host is a machine that runs MATLAB® workers. On a local pool, the host is your computer. On a cluster pool, the hosts are the machines within the cluster. A cluster pool can have workers running on multiple hosts.
If a host runs fewer pool workers than the number of workers you request, the
partition
function allocates all available workers from that host
to newPool
.
creates a pool object, newPool
= partition(pool
,"MaxNumWorkersPerGPU",MaxNumWorkersPerGPU
)newpool
, with up to
MaxNumWorkersPerGPU
workers for each unique GPU in the input pool,
pool
.
A GPU must be attached to the same host as a MATLAB worker to be assigned to the worker. If the partition
function is unable to assign the requested number of workers to a GPU, the function
allocates all workers that it can assign to the GPU to newpool
. On
hosts with multiple GPUs, the number of MATLAB workers and GPUs on the host determines the maximum number of workers that the
partition
function can assign to each GPU. On hosts that do not
have a GPU, the partition
function returns an empty pool unless other
hosts in the pool have GPUs.
This partitioning method uses the result of the gpuDevice
function on each parallel pool worker to determine which worker is
associated with which GPU. The partition
function considers only
workers with an allocated GPU and does not modify the property values of any GPU. The
partition
function executes code on all workers in
pool
to gather gpuDevice
information. If any
worker is busy executing a parfeval
computation, the
partition
function waits until the parfeval
computation completes.
partitions the input pool object, newPool
= partition(pool
,"Workers",Workers
)pool
, to create a new pool object,
newPool
, containing only workers specified by the
parallel.Worker
object or array of parallel.Worker
objects, Workers
. Every worker in Workers
must be
a member of the Workers
property of the input pool.
[
also returns newPool
,remainingPool
] = partition(pool
,___)remainingPool
, a pool object that contains the set of
workers in pool
but not in newpool
.
Examples
Input Arguments
Output Arguments
Tips
The pool partition contains some workers from the input pool therefore both the input pool and its partitions can schedule work on the same workers. Consequently, using one pool can delay the execution of work on other pools. Deleting any pool instance deletes the underlying collection of workers and any parallel job running on the pool. All pools using the same collection of resources become invalid. If you no longer need a pool partition, allow the instance to go out of scope rather than explicitly deleting it.
The
NumWorkers
property value of the pool partition reflects the number of workers the pool can use.The new pool shares some properties with the input pool. Changes to these properties affect all pools. These shared properties are:
AttachedFiles
FileStore
ValueStore
IdleTimeout
Version History
Introduced in R2025a