本文整理匯總了C++中DistMatrix::ColOwner方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::ColOwner方法的具體用法?C++ DistMatrix::ColOwner怎麽用?C++ DistMatrix::ColOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::ColOwner方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: if
void TransformColumns
( const Matrix<F>& Z,
DistMatrix<F,MC,MR,BLOCK>& H )
{
DEBUG_CSE
const Int width = H.Width();
const Grid& grid = H.Grid();
const Int blockWidth = H.BlockWidth();
const Int firstBlockWidth = blockWidth - H.RowCut();
if( width <= firstBlockWidth || grid.Width() == 1 )
{
if( grid.Col() == H.ColOwner(0) )
{
// This process row can locally update its portion of H
Matrix<F> HLocCopy( H.Matrix() );
Gemm( NORMAL, NORMAL, F(1), HLocCopy, Z, H.Matrix() );
}
}
else if( width <= firstBlockWidth + blockWidth )
{
const bool firstCol = H.ColOwner( 0 );
const bool secondCol = H.ColOwner( firstBlockWidth );
if( grid.Col() == firstCol )
{
//
// Replace H with
//
// | HLeft, HRight | | ZLeft, ZRight |,
//
// where HLeft is owned by this process column and HRight by the
// next.
//
auto ZLeft = Z( ALL, IR(0,firstBlockWidth) );
// Partition space for the combined matrix
Matrix<F> HCombine( H.LocalHeight(), width );
auto HLeft = HCombine( ALL, IR(0,firstBlockWidth) );
auto HRight = HCombine( ALL, IR(firstBlockWidth,END) );
// Copy our portion into the combined matrix
HLeft = H.LockedMatrix();
// Exchange the data
El::SendRecv( HLeft, HRight, H.RowComm(), secondCol, secondCol );
// Form our portion of the result
Gemm( NORMAL, NORMAL, F(1), HCombine, ZLeft, H.Matrix() );
}
else if( grid.Col() == secondCol )
{
//
// Replace H with
//
// | HLeft, HRight | | ZLeft, ZRight |,
//
// where HLeft is owned by the previous process column and HRight
// by this one.
//
auto ZRight = Z( ALL, IR(firstBlockWidth,END) );
// Partition space for the combined matrix
Matrix<F> HCombine( H.LocalHeight(), width );
auto HLeft = HCombine( ALL, IR(0,firstBlockWidth) );
auto HRight = HCombine( ALL, IR(firstBlockWidth,END) );
// Copy our portion into the combined matrix
HRight = H.LockedMatrix();
// Exchange the data
El::SendRecv( HRight, HLeft, H.RowComm(), firstCol, firstCol );
// Form our portion of the result
Gemm( NORMAL, NORMAL, F(1), HCombine, ZRight, H.Matrix() );
}
}
else
{
// Fall back to the entire process column interacting.
// TODO(poulson): Only form the subset of the result that we need.
DistMatrix<F,MC,STAR,BLOCK> H_MC_STAR( H );
Matrix<F> HLocCopy( H_MC_STAR.Matrix() );
Gemm( NORMAL, NORMAL, F(1), HLocCopy, Z, H_MC_STAR.Matrix() );
H = H_MC_STAR;
}
}
示例2: if
void TransformColumns
( const Matrix<F>& V,
DistMatrix<F,MC,MR,BLOCK>& A )
{
DEBUG_CSE
const Int width = A.Width();
const Grid& grid = A.Grid();
const Int blockWidth = A.BlockWidth();
const Int firstBlockWidth = blockWidth - A.RowCut();
if( width <= firstBlockWidth || grid.Width() == 1 )
{
if( grid.Col() == A.ColOwner(0) )
{
// This process row can locally update its portion of A
TransformColumns( V, A.Matrix() );
}
}
else if( width <= firstBlockWidth + blockWidth )
{
const int firstCol = A.ColOwner( 0 );
const int secondCol = A.ColOwner( firstBlockWidth );
if( grid.Col() == firstCol )
{
//
// Replace A with
//
// | ALeft, ARight | | VLeft, VRight |,
//
// where ALeft is owned by this process column and ARight by the
// next.
//
// Partition space for the combined matrix
Matrix<F> ACombine( A.LocalHeight(), width );
auto ALeft = ACombine( ALL, IR(0,firstBlockWidth) );
auto ARight = ACombine( ALL, IR(firstBlockWidth,END) );
// Copy our portion into the combined matrix
ALeft = A.LockedMatrix();
// Exchange the data
El::SendRecv( ALeft, ARight, A.RowComm(), secondCol, secondCol );
// Form our portion of the result
auto VLeft = V( ALL, IR(0,firstBlockWidth) );
Gemm( NORMAL, NORMAL, F(1), ACombine, VLeft, A.Matrix() );
}
else if( grid.Col() == secondCol )
{
//
// Replace A with
//
// | ALeft, ARight | | VLeft, VRight |,
//
// where ALeft is owned by the previous process column and ARight
// by this one.
//
// Partition space for the combined matrix
Matrix<F> ACombine( A.LocalHeight(), width );
auto ALeft = ACombine( ALL, IR(0,firstBlockWidth) );
auto ARight = ACombine( ALL, IR(firstBlockWidth,END) );
// Copy our portion into the combined matrix
ARight = A.LockedMatrix();
// Exchange the data
El::SendRecv( ARight, ALeft, A.RowComm(), firstCol, firstCol );
// Form our portion of the result
auto VRight = V( ALL, IR(firstBlockWidth,END) );
Gemm( NORMAL, NORMAL, F(1), ACombine, VRight, A.Matrix() );
}
}
else
{
// Fall back to the entire process column interacting.
// TODO(poulson): Only form the subset of the result that we need.
DistMatrix<F,MC,STAR,BLOCK> A_MC_STAR( A );
Matrix<F> ALocCopy( A_MC_STAR.Matrix() );
Gemm( NORMAL, NORMAL, F(1), ALocCopy, V, A_MC_STAR.Matrix() );
A = A_MC_STAR;
}
}