Skip to Main Content Skip to Search
Product Documentation

codistributor - Create codistributor object for codistributed arrays

Syntax

codist = codistributor()
codist = codistributor('1d')
codist = codistributor('1d', dim)
codist = codistributor('1d', dim, part)
codist = codistributor('2dbc')
codist = codistributor('2dbc', lbgrid)
codist = codistributor('2dbc', lbgrid, blksize)

Description

There are two schemes for distributing arrays. The scheme denoted by the string '1d' distributes an array along a single specified subscript, the distribution dimension, in a noncyclic, partitioned manner. The scheme denoted by '2dbc', employed by the parallel matrix computation software ScaLAPACK, applies only to two-dimensional arrays, and varies both subscripts over a rectangular computational grid of labs in a blocked, cyclic manner.

codist = codistributor(), with no arguments, returns a default codistributor object with zero-valued or empty parameters, which can then be used as an argument to other functions to indicate that the function is to create a codistributed array if possible with default distribution. For example,

Z = zeros(..., codistributor())
R = randn(..., codistributor())

codist = codistributor('1d') is the same as codist = codistributor().

codist = codistributor('1d', dim) also forms a codistributor object with codist.Dimension = dim and default partition.

codist = codistributor('1d', dim, part) also forms a codistributor object with codist.Dimension = dim and codist.Partition = part.

codist = codistributor('2dbc') forms a 2-D block-cyclic codistributor object. For more information about '2dbc' distribution, see 2-Dimensional Distribution.

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 labs, 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, lab 1 contains a 2-by-1-by-4 segment, lab 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 labs, 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
A

See Also

codistributed | codistributor1d | codistributor2dbc | getCodistributor | getLocalPart | redistribute

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS