User`s guide
Working with Codistributed Arrays
5-17
Now you can use this codistributor object to distribute the original matrix:
P>> AA = codistributed(A, DIST)
This distributes the array among the workers according to this scheme:
1 9 17 25 33 41 49 57
2 10 18 26 34 42 50 58
3 11 19 27 35 43 51 59
4 12 20 28 36 44 52 60
5 13 21 29 37 45 53 61
6 14 22 30 38 46 54 62
7 15 23 31 39 47 55 63
8 16 24 32 40 48 56 64
LAB 1
LAB 3
LAB 2
LAB 4
If the lab grid does not perfectly overlay the dimensions of the codistributed array, you
can still use '2dbc' distribution, which is block cyclic. In this case, you can imagine
the lab grid being repeatedly overlaid in both dimensions until all the original matrix
elements are included.
Using the same original 8-by-8 matrix and 2-by-2 lab grid, consider a block size of 3
instead of 4, so that 3-by-3 square blocks are distributed among the workers. The code
looks like this:
P>> DIST = codistributor2dbc([2 2], 3)
P>> AA = codistributed(A, DIST)
The first “row” of the lab grid is distributed to worker 1 and worker 2, but that contains
only six of the eight columns of the original matrix. Therefore, the next two columns are
distributed to worker 1. This process continues until all columns in the first rows are
distributed. Then a similar process applies to the rows as you proceed down the matrix,
as shown in the following distribution scheme: