User`s guide

Working with Codistributed Arrays
5-13
Construct an 8-by-16 codistributed array D of random values distributed by columns on
four workers:
spmd
D = rand(8,16,codistributor());
size(getLocalPart(D))
end
returns on each worker:
8 4
Create a new codistributed array distributed by rows from an existing one already
distributed by columns:
spmd
X = redistribute(D, codistributor1d(1));
size(getLocalPart(X))
end
returns on each worker:
2 16
Restoring the Full Array
You can restore a codistributed array to its undistributed form using the gather
function. gather takes the segments of an array that reside on different workers and
combines them into a replicated array on all workers, or into a single array on one
worker.
Distribute a 4-by-10 array to four workers along the second dimension:
spmd, A = [11:20; 21:30; 31:40; 41:50], end
A =
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
spmd, D = codistributed(A), end
WORKER 1 WORKER 2 WORKER 3 WORKER 4