User`s guide

5 Math with Codistributed Arrays
5-8
spmd, A = [11:18; 21:28; 31:38; 41:48], end
A =
11 12 13 14 15 16 17 18
21 22 23 24 25 26 27 28
31 32 33 34 35 36 37 38
41 42 43 44 45 46 47 48
The next line uses the codistributed function to construct a single 4-by-8 matrix D
that is distributed along the second dimension of the array:
spmd
D = codistributed(A);
getLocalPart(D)
end
1: Local Part | 2: Local Part | 3: Local Part | 4: Local Part
11 12 | 13 14 | 15 16 | 17 18
21 22 | 23 24 | 25 26 | 27 28
31 32 | 33 34 | 35 36 | 37 38
41 42 | 43 44 | 45 46 | 47 48
Arrays A and D are the same size (4-by-8). Array A exists in its full size on each worker,
while only a segment of array D exists on each worker.
spmd, size(A), size(D), end
Examining the variables in the client workspace, an array that is codistributed among
the workers inside an spmd statement, is a distributed array from the perspective of the
client outside the spmd statement. Variables that are not codistributed inside the spmd,
are Composites in the client outside the spmd.
whos
Name Size Bytes Class
A 1x4 613 Composite
D 4x8 649 distributed
See the codistributed function reference page for syntax and usage information.
Building from Smaller Arrays
The codistributed function is less useful for reducing the amount of memory required
to store data when you first construct the full array in one workspace and then partition
it into distributed segments. To save on memory, you can construct the smaller pieces