Main Content

codistributed.build

Create codistributed array from distributed data

Syntax

D = codistributed.build(L,codist)
D = codistributed.build(L,codist,'noCommunication')

Description

D = codistributed.build(L,codist)forms a codistributed array withgetLocalPart(D) = L. The codistributed arrayDis 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 forcodistributor1dandcodistributor2dbc.

D = codistributed.build(L,codist,'noCommunication')builds a codistributed array, without performing any interworker communications for error checking.

codistmust be complete, which you can check by callingcodist.isComplete(). The requirements on the size and structure of the local partLdepend on the class ofcodist. For the 1-D and 2-D block-cyclic codistributors,Lmust have the same class and sparsity on all workers. Furthermore, the local part L must represent the region described by theglobalIndicesmethod oncodist.

Examples

Create a codistributed array of size 1001-by-1001 such that columniicontains 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
Introduced in R2009b