codistributed
Access elements of arrays distributed among workers in parallel pool
Description
Arrays partitioned among the workers in a parallel pool are accessible from the
workers as codistributed
array objects. Codistributed array objects on
workers that you create inside spmd
statements or from within task functions
of communicating jobs are accessed as distributed arrays on the client.
Creation
Use either the codistributed
function, or the codistributed.build
function to create a codistributed
object.
Syntax
Description
distributes a local array C
= codistributed(X
,workerIndex
)X
that resides on the worker identified by
workerIndex
, using the default codistributor. The local array
X
must be defined on all workers, but the function uses only the
WorkerIndex
to construct C
.
size(C)
is the same as the size of X
.
distributes a replicated array C
= codistributed(X
,codist
)X
using the distribution scheme
defined by codistributor codist
. X
must be a
replicated array, that is, it must have the same value on all workers. The size of
C
is the same as the size of X
. For information
on constructing codistributor objects, see codistributor1d
and codistributor2dbc
.
distributes a local array C
= codistributed(X
,workerIndex
,codist
)X
that resides on the worker identified by
workerIndex
, using the codistributor codist
. The
local array X
must be defined on all workers, but the function uses
only the WorkerIndex
to construct C
.
size(C)
is the same as the size of X
.
accepts an array C
= codistributed(C1
,codist
)C1
that is already codistributed, and redistributes
it into C
according to the distribution scheme defined by the
codistributor codist
. This syntax is equivalent to C =
redistribute(C1,codist)
. If the existing distribution scheme for
C1
is the same as that specified in codist
, then
the result C
is the same as the input C1
.
Input Arguments
Output Arguments
Object Functions
gather | Transfer distributed array, Composite object, or
gpuArray object to local workspace |
getCodistributor | Codistributor object for existing codistributed array |
getLocalPart | Local portion of codistributed array |
globalIndices | Global indices for local part of codistributed array |
Inf | Create codistributed array of all Inf values |
iscodistributed | True for codistributed array |
redistribute | Redistribute codistributed array with another distribution scheme |
The object functions for codistributed arrays are too numerous to list here. Most resemble and behave the same as built-in MATLAB® functions. For a complete list of object functions, see Run MATLAB Functions with Distributed Arrays.
Among the object functions there are several for examining the characteristics of the array itself. Most behave like the MATLAB functions of the same name.
iscodistributed | True for codistributed array |
isreal | Determine whether array uses complex storage |
isUnderlyingType | Determine whether input has specified underlying data type |
length | Length of largest array dimension |
ndims | Number of array dimensions |
size | Array size |
underlyingType | Type of underlying data determining array behavior |
Examples
Tips
The gather
function performs the inverse of
codistributed
. Use the gather
function to retrieve
codistributed arrays into the client work space.
Alternative Functionality
You can also create a codistributed array explicitly from spmd
code or
a communicating job task with any of these MATLAB functions.
Version History
Introduced in R2008b
See Also
distributed
| gather
| getLocalPart
| spmd
| parpool
| codistributor1d
| codistributor2dbc
| subsref
| subsasgn
| globalIndices
| redistribute