User`s guide
codistributor
11-41
codist = codistributor('2dbc') forms a 2-D block-cyclic codistributor object. For
more information about '2dbc' distribution, see “2-Dimensional Distribution” on page
5-16.
codist = codistributor('2dbc', lbgrid) forms a 2-D block-cyclic codistributor
object with the lab grid defined by lbgrid and with default block size.
codist = codistributor('2dbc', lbgrid, blksize) forms a 2-D block-cyclic
codistributor object with the lab grid defined by lbgrid and with a block size defined by
blksize.
codist = getCodistributor(D) returns the codistributor object of codistributed
array D.
Examples
On four workers, create a 3-dimensional, 2-by-6-by-4 array with distribution along the
second dimension, and partition scheme [1 2 1 2]. In other words, worker 1 contains a
2-by-1-by-4 segment, worker 2 a 2-by-2-by-4 segment, etc.
spmd
dim = 2; % distribution dimension
codist = codistributor('1d', dim, [1 2 1 2], [2 6 4]);
if mod(labindex, 2)
L = rand(2,1,4);
else
L = rand(2,2,4);
end
A = codistributed.build(L, codist)
end
A
On four workers, create a 20-by-5 codistributed array A, distributed by rows (over its first
dimension) with a uniform partition scheme.
spmd
dim = 1; % distribution dimension
partn = codistributor1d.defaultPartition(20);
codist = codistributor('1d', dim, partn, [20 5]);
L = magic(5) + labindex;
A = codistributed.build(L, codist)
end