gop
(Not recommended) Reduce arrays on spmd
workers
gop
is not recommended. Use spmdReduce
instead. For more information, see Version History.
Description
uses the function B
= gop(fcn
,A
)fcn
to reduce the array A
defined
on each worker running an spmd
block or communicating job.
For example, gop(@plus,A)
returns the sum of the arrays
A
defined on each worker.
MATLAB uses the fcn
function to reduce the array
A
defined on each worker by calling the function N-1
times.
N
is the value returned bynumlabs
in thatspmd
block or communicating job.Aj is the array
A
as defined onspmd
workerj
.
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
gop
on these workers, the result is the same as using
gop
on a client.
If numlabs
is equal to 1
,
B
is equal to A
.
reduces the array B
= gop(fcn
,A
,destination
)A
defined on each worker and stores the result on
only one worker.
Examples
Input Arguments
Algorithms
When you use gop(fcn,A)
, fcn
is used to combine
the value of A
from each worker.
To ensure that your spmd
block or communicating job always produces the
same results, specify fcn
as an associative function.