Main Content


Create 2-D block-cyclic codistributor object for codistributed arrays


codist = codistributor2dbc()
codist = codistributor2dbc(lbgrid)
codist = codistributor2dbc(lbgrid,blksize)
codist = codistributor2dbc(lbgrid,blksize,orient)
codist = codistributor2dbc(lbgrid,blksize,orient,gsize)


The 2-D block-cyclic codistributor can be used only for two-dimensional arrays. It distributes arrays along two subscripts over a rectangular computational grid of labs (workers) in a block-cyclic manner. For a complete description of 2-D block-cyclic distribution, default parameters, and the relationship between block size and lab grid, see 2-Dimensional Distribution. The 2-D block-cyclic codistributor is used by the ScaLAPACK parallel matrix computation software library.

codist = codistributor2dbc() forms a 2-D block-cyclic codistributor2dbc codistributor object using default lab grid and block size.

codist = codistributor2dbc(lbgrid) forms a 2-D block-cyclic codistributor object using the specified lab grid and default block size. lbgrid must be a two-element vector defining the rows and columns of the lab grid, and the rows times columns must equal the number of workers for the codistributed array.

codist = codistributor2dbc(lbgrid,blksize) forms a 2-D block-cyclic codistributor object using the specified lab grid and block size.

codist = codistributor2dbc(lbgrid,blksize,orient) allows an orientation argument. Valid values for the orientation argument are 'row' for row orientation, and 'col' for column orientation of the lab grid. The default is row orientation.

The resulting codistributor of any of the above syntax is incomplete because its global size is not specified. A codistributor constructed this way can be used as an argument to other functions as a template codistributor when creating codistributed arrays.

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 To use the default values for lab grid, block size, and orientation, specify them using codistributor2dbc.defaultLabGrid, codistributor2dbc.defaultBlockSize, and codistributor2dbc.defaultOrientation, respectively.


Use a codistributor2dbc object to create an N-by-N matrix of ones.

N = 1000;
    codistr = codistributor2dbc();  
    D = ones(N,codistr);

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;
    codistr = codistributor2dbc(...
                 codistributor2dbc.defaultLabGrid, ...
                 codistributor2dbc.defaultBlockSize, ...
    myLocalSize = [length(codistr.globalIndices(1)), ...
    myLocalPart = spmdIndex*ones(myLocalSize);
    D =,codistr);