Create 1-D codistributor object for codistributed arrays
codist = codistributor1d()
codist = codistributor1d(dim)
codist = codistributor1d(dim,part)
codist = codistributor1d(dim,part,gsize)
The 1-D codistributor distributes arrays along a single, specified distribution dimension, in a noncyclic, partitioned manner.
codist = codistributor1d() forms a
codistributor1d object using 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(dim) forms a 1-D codistributor
object for distribution along the specified dimension:
distributes along rows,
2 along columns, etc.
codist = codistributor1d(dim,part) forms a 1-D codistributor
object for distribution according to the partition vector
C1 = codistributor1d(1,[1,2,3,4]) describes the
distribution scheme for an array of ten rows to be codistributed by its first
dimension (rows), to four workers, with 1 row to the first, 2 rows to the second,
The resulting codistributor of any of the above syntax is incomplete because its global size is not specified. A codistributor constructed in this manner can be used as an argument to other functions as a template codistributor when creating codistributed arrays.
codist = codistributor1d(dim,part,gsize) forms a
codistributor object with distribution dimension
part, and global size of its codistributed
gsize. The resulting codistributor object is complete and
can be used to build a codistributed array from its local parts with
codistributed.build. To use a
default dimension, specify
that argument; the distribution dimension is derived from
and is set to the last non-singleton dimension. Similarly, to use a default
codistributor1d.unsetPartition for that
argument; the partition is then derived from the default for that global size and
The local part on worker
labidx of a codistributed array using
such a codistributor is of size
gsize in all dimensions except
dim, where the size is
local part has the same class and attributes as the overall codistributed array.
Conceptually, the overall global array could be reconstructed by concatenating the
various local parts along dimension
Use a codistributor1d object to create an
N matrix of ones, distributed by
N = 1000; spmd codistr = codistributor1d(1); % 1st dimension (rows) C = ones(N,codistr); end
Use a fully specified codistributor1d object to create a trivial
N codistributed matrix from its local
parts. Then visualize which elements are stored on worker 2.
N = 1000; spmd codistr = codistributor1d( ... codistributor1d.unsetDimension, ... codistributor1d.unsetPartition, ... [N,N]); myLocalSize = [N,N]; % start with full size on each lab % then set myLocalSize to default part of whole array: myLocalSize(codistr.Dimension) = codistr.Partition(labindex); myLocalPart = labindex*ones(myLocalSize); % arbitrary values D = codistributed.build(myLocalPart,codistr); end spy(D==2);