本文整理匯總了C++中DistMatrix::Empty方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::Empty方法的具體用法?C++ DistMatrix::Empty怎麽用?C++ DistMatrix::Empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::Empty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: logic_error
/*
* Distributes A in such a way that
* Layer 0 <- A(:, 0:(n/h - 1))
* Layer 1 <- A(:, (n/h):(2n/h - 1))
* .
* .
* .
* Layer h-1 <- A(:, ((h-1)n/h):n)
*/
void DistributeCols
( const mpi::Comm& depthComm,
const DistMatrix<double,MC,MR>& A,
DistMatrix<double,MC,MR>& B )
{
const Grid& meshGrid = A.Grid();
const int meshSize = meshGrid.Size();
const int depthSize = mpi::CommSize( depthComm );
const int depthRank = mpi::CommRank( depthComm );
const int sendCount = A.LocalHeight()*A.LocalWidth();
const int recvCount = sendCount / depthSize;
// For now, we will make B as large as A...
// TODO: NOT DO THIS
if( A.LocalHeight() != A.LocalLDim() )
throw std::logic_error("Local height did not match local ldim");
B.Empty();
B.AlignWith( A );
Zeros( A.Height(), A.Width(), B );
// Scatter
const int localColOffset = (A.LocalWidth()/depthSize)*depthRank;
mpi::Scatter
( A.LockedLocalBuffer(), recvCount,
B.LocalBuffer(0,localColOffset), recvCount, 0, depthComm );
}
示例2: AccumulateRHS
void AccumulateRHS( const DistMatrix<F,VC,STAR>& X, DistMatrix<F,STAR,STAR>& Z )
{
const Int height = X.Height();
const Int width = X.Width();
Z.Empty();
Zeros( Z, height, width );
const Int localHeight = X.LocalHeight();
const Int colShift = X.ColShift();
const int commSize = X.Grid().Size();
const F* XBuffer = X.LockedBuffer();
F* ZBuffer = Z.Buffer();
const Int XLDim = X.LDim();
const Int ZLDim = Z.LDim();
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = colShift + iLoc*commSize;
for( Int j=0; j<width; ++j )
ZBuffer[i+j*ZLDim] = XBuffer[iLoc+j*XLDim];
}
mpi::AllReduce( ZBuffer, ZLDim*width, mpi::SUM, X.Grid().VCComm() );
}