User`s guide
gather
11-101
gather
Transfer distributed array or gpuArray to local workspace
Syntax
X = gather(A)
X = gather(C,lab)
Description
X = gather(A) can operate inside an spmd statement, pmode, or communicating job to
gather together the elements of a codistributed array, or outside an spmd statement to
gather the elements of a distributed array. If you execute this inside an spmd statement,
pmode, or communicating job, X is a replicated array with all the elements of the array
on every worker. If you execute this outside an spmd statement, X is an array in the local
workspace, with the elements transferred from the multiple workers.
X = gather(distributed(X)) or X = gather(codistributed(X)) returns the
original array X.
X = gather(C,lab) converts a codistributed array C to a variant array X, such that all
of the elements are contained on worker lab, and X is a 0-by-0 empty double on all other
workers.
For a gpuArray input, X = gather(A) transfers the array elements from the GPU to
the local workspace.
If the input argument to gather is not a distributed, a codistributed, or a gpuArray, the
output is the same as the input.
Examples
Distribute a magic square across your workers, then gather the whole matrix onto every
worker and then onto the client. This code results in the equivalent of M = magic(n) on
all workers and the client.