Create codistributed array from distributed data
D = codistributed.build(L,codist)
D = codistributed.build(L,codist,'noCommunication')
D = codistributed.build(L,codist)
forms a codistributed array withgetLocalPart(D) = L
. The codistributed arrayD
is created as if you had combined all copies of the local arrayL
. The distribution scheme is specified bycodist
. Global error checking ensures that the local parts conform with the specified distribution scheme. For information on constructing codistributor objects, see the reference pages forcodistributor1d
andcodistributor2dbc
.
D = codistributed.build(L,codist,'noCommunication')
builds a codistributed array, without performing any interworker communications for error checking.
codist
must be complete, which you can check by callingcodist.isComplete()
. The requirements on the size and structure of the local partL
depend on the class ofcodist
. For the 1-D and 2-D block-cyclic codistributors,L
must have the same class and sparsity on all workers. Furthermore, the local part L must represent the region described by theglobalIndices
method oncodist
.
Create a codistributed array of size 1001-by-1001 such that columnii
contains the valueii
.
spmdN = 1001; globalSize = [N,N];% Distribute the matrix over the second dimension (columns),% and let the codistributor derive the partition from the% global size.codistr = codistributor1d(2,...codistributor1d.unsetPartition,globalSize)% On 4 workers, codistr.Partition equals [251,250,250,250].% Allocate storage for the local part.localSize = [N, codistr.Partition(labindex)]; L = zeros(localSize);% Use globalIndices to map the indices of the columns% of the local part into the global column indices.globalInd = codistr.globalIndices(2);% On 4 workers, globalInd has the values:% 1:251对工人1% 252:501 on worker 2% 502:751 on worker 3% 752:1001 on worker 4% Initialize the columns of the local part to% the correct value.forlocalCol = 1:length(globalInd) globalCol = globalInd(localCol); L(:,localCol) = globalCol;endD = codistributed.build(L,codistr)end
codistributor1d
|codistributor2dbc
|gather
|globalIndices
|getLocalPart
|redistribute
|subsasgn
|subsref