Main Content

codistributed.build

分散データから対話型分散配列を作成する

構文

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

説明

D = codistributed.build(L,codist)getLocalPart(D) = L を使用して対話型分散配列を形成します。対話型分散配列 D は、ローカル配列 L のコピーをすべて結合した場合と等価なものとして作成されます。分散スキームは codist により指定されます。グローバルなエラー チェックにより、ローカル部分が指定された分散スキームに準拠することが確認されます。対話型分散オブジェクトの作成の詳細については、codistributor1d および codistributor2dbc のリファレンス ページを参照してください。

D = codistributed.build(L,codist,'noCommunication') は、エラー チェック用のワーカー間の通信を実行せずに対話型分散配列を作成します。

codist は完全でなければなりません。それをチェックするには、codist.isComplete() を呼び出します。ローカル部分 L のサイズおよび構造に関する要件は codist のクラスによって異なります。1 次元および 2 次元ブロックサイクリック対話型分散の場合、L のクラスとスパース性はすべてのワーカーで同じでなければなりません。また、ローカル部分 L は codistglobalIndices メソッドで記述されている領域を表さなければなりません。

ii に値 ii が含まれるように、サイズが 1001 行 1001 列の対話型分散配列を作成します。

spmd
    N = 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(spmdIndex)];
    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    on worker 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.
    for localCol = 1:length(globalInd)
        globalCol = globalInd(localCol);
        L(:,localCol) = globalCol;
    end
    D = codistributed.build(L,codistr)
end

バージョン履歴

R2009b で導入