codistributed

Create codistributed array from replicated local data

Syntax

C = codistributed(X)
C = codistributed(X,codist)
C = codistributed(X,codist,lab)
C = codistributed(C1,codist)

Description

C = codistributed(X) distributes a replicated array X using the default codistributor, creating a codistributed array C as a result. X must be a replicated array, that is, it must have the same value on all workers. size(C) is the same as size(X).

C = codistributed(X,codist) distributes a replicated array X using the distribution scheme defined by codistributor codist. X must be a replicated array, namely it must have the same value on all workers. size(C) is the same as size(X). For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc.

C = codistributed(X,codist,lab) distributes a local array X that resides on the worker identified by lab, using the codistributor codist. Local array X must be defined on all workers, but only the value from lab is used to construct C. size(C) is the same as size(X).

C = codistributed(C1,codist) where the input array C1 is already a codistributed array, redistributes the array C1 according to the distribution scheme defined by codistributor codist. This is the same as calling C = redistribute(C1,codist). If the specified distribution scheme is that same as that already in effect, then the result is the same as the input.

Tips

gather essentially performs the inverse of codistributed.

Examples

Create a 1000-by-1000 codistributed array C1 using the default distribution scheme.

spmd
    N = 1000;
    X = magic(N);          % Replicated on every worker
    C1 = codistributed(X); % Partitioned among the workers
end

Create a 1000-by-1000 codistributed array C2, distributed by rows (over its first dimension).

spmd
    N = 1000;
    X = magic(N);
    C2 = codistributed(X,codistributor1d(1));
end
Was this topic helpful?