distributed
Create and access elements of distributed arrays from client
Description
A distributed array on the client represents an array that is partitioned out
among the workers in a parallel pool. You operate on the entire array as a single entity;
however, workers operate only on their part of the array and automatically transfer data
between themselves when necessary. A distributed array resembles a normal MATLAB® array in the way you index and manipulate its elements, but none of its elements
exist on the client. Codistributed arrays that you create inside spmd
statements are accessible as distributed arrays from the
client.
Creation
Use the distributed
function or use the
"distributed"
option of array creation functions such as ones
or zeros
. For a list of array creation functions
that create distributed arrays directly on workers, see Alternative Functionality.
Description
creates a distributed array from an array D
= distributed(X
)X
.
Use this syntax to create a distributed array from local data only if the MATLAB client can store all of X
in memory. To create large
distributed arrays, use the previous syntax to create a distributed array from a
datastore, or the "distributed"
option of array creation functions such
as ones
, zeros
, or any other creation functions listed in Alternative Functionality.
If the input argument is already a distributed array, the result is the same as the input.
creates a distributed array from the D
= distributed(C
,dim
)Composite
object
C
, with the entries of C
concatenated and
distributed along the dimension dim
. If you omit
dim
, then the first dimension is the distribution dimension.
All entries of the Composite
object must have the same class.
Dimensions other than the distribution dimension must be the same.
Input Arguments
Output Arguments
Object Functions
Several MATLAB toolboxes include functions with distributed array support. For a list of functions in all MathWorks® products that support distributed arrays, see All Functions List (Distributed Arrays).
Several object functions enable you to examine the characteristics of a distributed array. Most behave like the MATLAB functions of the same name.
isdistributed | True for distributed 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
A distributed array is created on the workers of the existing parallel pool. If no pool exists,
distributed
starts a new parallel pool unless the automatic starting of pools is disabled in your parallel preferences. If there is no parallel pool anddistributed
cannot start one, MATLAB returns the result as a nondistributed array in the client workspace.
Alternative Functionality
This table lists the available MATLAB functions that create distributed
arrays directly on the
workers. For more information, see the Extended Capabilities section of the function reference
page.
eye | distributed.cell |
false | distributed. colon |
Inf | distributed. linspace |
NaN | distributed. logspace |
ones | distributed.spalloc |
true | distributed.speye |
zeros | distributed.sprand |
rand | distributed.sprandn |
randi | |
randn |