Create codistributed array from replicated local data

`C = codistributed(X)`

C = codistributed(X,codist)

C = codistributed(X,lab,codist)

C = codistributed(C1,codist)

`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,lab,codist)`

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)`

accepts an
array `C1`

that is already codistributed, and redistributes
it into `C`

according to the distribution scheme
defined by the codistributor `codist`

. This is the
same as calling `C = redistribute(C1,codist)`

. If
the existing distribution scheme for `C1`

is the
same as that specified in `codist`

, then the result `C`

is
the same as the input `C1`

.

`gather`

essentially performs
the inverse of `codistributed`

.

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

`codistributor1d`

| `codistributor2dbc`

| `distributed`

| `gather`

| `getLocalPart`

| `globalIndices`

| `redistribute`

| `size`

| `subsasgn`

| `subsref`

Was this topic helpful?