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 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
codistributed.cell | Create codistributed cell array |
codistributed.colon | Distributed colon operation |
codistributed.spalloc | Allocate space for sparse codistributed matrix |
codistributed.speye | Create codistributed sparse identity matrix |
codistributed.sprand | Create codistributed sparse array of uniformly distributed pseudo-random values |
codistributed.sprandn | Create codistributed sparse array of normally distributed pseudo-random values |
eye | Create codistributed identity matrix |
false | Create codistributed array of logical 0 (false) |
gather | Transfer distributed array, Composite array or gpuArray 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 |
NaN | Create codistributed array of all NaN values |
ones | Create codistributed array of all ones |
rand | Create codistributed array of uniformly distributed random numbers |
randi | Create codistributed array of uniformly distributed random integers |
randn | Create codistributed array of normally distributed random numbers |
redistribute | Redistribute codistributed array with another distribution scheme |
sparse | Create codistributed sparse matrix |
true | Create codistributed array of logical 1 (true) |
zeros | Create codistributed array of all zeros |
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