User`s guide

codistributor2dbc
11-47
codist = codistributor2dbc(lbgrid,blksize,orient,gsize) forms
a codistributor object that distributes arrays with the global size gsize. The
resulting codistributor object is complete and can therefore be used to build a
codistributed array from its local parts with codistributed.build. To use
the default values for lab grid, block size, and orientation, specify them using
codistributor2dbc.defaultLabGrid, codistributor2dbc.defaultBlockSize,
and codistributor2dbc.defaultOrientation, respectively.
Examples
Use a codistributor2dbc object to create an N-by-N matrix of ones.
N = 1000;
spmd
codistr = codistributor2dbc();
D = ones(N,codistr);
end
Use a fully specified codistributor2dbc 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 = codistributor2dbc(...
codistributor2dbc.defaultLabGrid, ...
codistributor2dbc.defaultBlockSize, ...
'row',[N,N]);
myLocalSize = [length(codistr.globalIndices(1)), ...
length(codistr.globalIndices(2))];
myLocalPart = labindex*ones(myLocalSize);
D = codistributed.build(myLocalPart,codistr);
end
spy(D==2);
See Also
codistributed | codistributor1d | getLocalPart | redistribute