codistributor1d - 1-D distribution scheme for codistributed array - MATLAB (original) (raw)
1-D distribution scheme for codistributed array
Description
Use a codistributor1d
object to define the one-dimensional distribution scheme for a codistributed array. The one-dimensional codistributor distributes arrays along a single specified dimension, the distribution dimension, in a noncyclic, partitioned manner.
Creation
Syntax
Description
`codist` = codistributor1d
returns acodistributor1d
object using the default dimension and partition. The default dimension is the last nonsingleton dimension of the codistributed array. The default partition distributes the array along the default dimension as evenly as possible.
`codist` = codistributor1d(`Dimension`)
returns a 1-D codistributor object for distribution along the dimension specified by theDimension property. For example, if Dimension
is 1, the function distributes the object along rows.
`codist` = codistributor1d(`Dimension`,`Partition`)
also returns a 1-D codistributor object for distribution according to the partition vector specified by the Partition property. For example, C1 = codistributor1d(1,[1,2,3,4])
distributes an array of 10 rows to four workers, with one row to the first worker, two rows to the second worker, three rows to the third worker, and four rows to the fourth worker.
The resulting codistributor of any of the above syntaxes is incomplete because its global size is not specified. Use a codistributor constructed this way as an argument to other functions as a template codistributor when creating codistributed arrays.
`codist` = codistributor1d(`Dimension`,`Partition`,[gsize](#mw%5F747056de-57d8-4101-9b2f-18d15bafa543))
returns a codistributor object with the global size gsize
.
You can use the resulting codistributor object to build a codistributed array from its local parts with codistributed.build. To use a default dimension, specify codistributor1d.unsetDimension
for the Dimension property; the function derives the distribution dimension from gsize
and selects the last nonsingleton dimension as the default dimension. Similarly, to use a default partition, specify codistributor1d.unsetPartition
for thePartition property; the function derives the default partition from the global size and distribution dimension.
The local part on worker workerIndex
of a codistributed array using such a codistributor is of size gsize
in all dimensions except dimension
, where the size ispart(workerIndex)
. The local part has the same class and attributes as the overall codistributed array. The overall global array can be reconstructed by concatenating the various local parts along dimensiondimension
.
Input Arguments
Global size of the codistributed array, specified as an integer.
Properties
Distribution dimension, specified as a scalar integer. The distribution dimension specifies the dimension over which you distribute the codistributed
array.
Partitioning vector, specified as an integer row vector. The partitioning vector specifies the distribution of the codistributed
array to the workers.
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) |
globalIndices | Global indices for local part of codistributed array |
Inf | Create codistributed array of all Inf values |
isComplete | True if codistributor object is complete |
NaN | Create codistributed array of all NaN values |
ones | Create codistributed array of all ones |
rand | Create codistributed array of uniformly distributed random numbers |
randn | Create codistributed array of normally distributed random numbers |
sparse | Create codistributed sparse matrix |
true | Create codistributed array of logical 1 (true) |
zeros | Create codistributed array of all zeros |
Examples
Use a codistributor1d
object to create anN
-by-N
matrix of ones, distributed by rows.
N = 1000; spmd codistr = codistributor1d(1); % 1st dimension (rows) C = ones(N,codistr); end
Use a fully specified codistributor1d
object to create a N
-by-N
codistributed matrix from its local parts. Then visualize which elements are stored on worker 2.
Start with full sized array on each worker then set myLocalSize
to default part of whole array.
N = 1000; spmd codistr = codistributor1d( ... codistributor1d.unsetDimension, ... codistributor1d.unsetPartition, ... [N N]); myLocalSize = [N N]; % myLocalSize(codistr.Dimension) = codistr.Partition(spmdIndex); myLocalPart = spmdIndex*ones(myLocalSize); D = codistributed.build(myLocalPart,codistr); end spy(D==2);
Version History
Introduced in R2009b