本文整理汇总了C++中mpi::Intracomm::Allgather方法的典型用法代码示例。如果您正苦于以下问题:C++ Intracomm::Allgather方法的具体用法?C++ Intracomm::Allgather怎么用?C++ Intracomm::Allgather使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpi::Intracomm
的用法示例。
在下文中一共展示了Intracomm::Allgather方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: temp
FullyDistSpVec<IT, IT> FullyDistSpVec<IT, NT>::sort()
{
MPI::Intracomm World = commGrid->GetWorld();
FullyDistSpVec<IT,IT> temp(commGrid);
IT nnz = getlocnnz();
pair<NT,IT> * vecpair = new pair<NT,IT>[nnz];
int nprocs = World.Get_size();
int rank = World.Get_rank();
IT * dist = new IT[nprocs];
dist[rank] = nnz;
World.Allgather(MPI::IN_PLACE, 1, MPIType<IT>(), dist, 1, MPIType<IT>());
IT sizeuntil = accumulate(dist, dist+rank, 0);
for(IT i=0; i< nnz; ++i)
{
vecpair[i].first = num[i]; // we'll sort wrt numerical values
vecpair[i].second = ind[i] + sizeuntil;
}
SpParHelper::MemoryEfficientPSort(vecpair, nnz, dist, World);
vector< IT > nind(nnz);
vector< IT > nnum(nnz);
for(IT i=0; i< nnz; ++i)
{
num[i] = vecpair[i].first; // sorted range (change the object itself)
nind[i] = ind[i]; // make sure the sparsity distribution is the same
nnum[i] = vecpair[i].second; // inverse permutation stored as numerical values
}
delete [] vecpair;
delete [] dist;
temp.NOT_FOUND = NOT_FOUND;
temp.glen = glen;
temp.ind = nind;
temp.num = nnum;
return temp;
}