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: 1 distributes along rows, 2 along columns, etc.
codist = codistributor1d(dim,part) forms a 1-D codistributor object for distribution according to the partition vector part. For example 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, etc.
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 dim, distribution partition part, and global size of its codistributed arrays 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 codistributor1d.unsetDimension for that argument; the distribution dimension is derived from gsize and is set to the last non-singleton dimension. Similarly, to use a default partition, specify codistributor1d.unsetPartition for that argument; the partition is then derived from the default for that global size and distribution dimension.
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 part(labidx). The 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 dim.
Use a codistributor1d object to create an N-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 trivial N-by-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);