spmdReduce
Description
uses the function B = spmdReduce(fcn,A)fcn to reduce the array A defined
on each worker running an spmd block or communicating job. The
function stores the result B of reduction on every worker.
For example, spmdReduce(@plus,A) returns the sum of the arrays
A defined on each worker.
MATLAB® uses the fcn function to reduce
AJ by calling the function N - 1 times.
N is the number of workers running the
spmdblock or communicating job. To get the number of workers running the current spmd block, use thespmdSizefunctionAj is the array
Adefined onspmdworker whose index is j.
To ensure that your spmd block or communicating job always produces
the same results, specify fcn as an associative function.
When you use parfor, parfeval, or
parfevalOnAll to run code on a parallel
pool, the workers are independent and do not communicate with each other. If you use
spmdReduce on these workers, the result is the same as using
spmdReduce on a client.
If one worker is running the current spmd block,
B is equal to A.
reduces B = spmdReduce(fcn,A,destination)A and stores the result on only one worker.
Examples
Input Arguments
Algorithms
This figure shows how the spmdReduce function uses
fcn when you call spmdReduce(fcn,A).

Extended Capabilities
Version History
Introduced in R2022b