1 #ifndef _SPLIT_MAT_DIST_H_ 2 #define _SPLIT_MAT_DIST_H_ 15 #ifndef __STDC_CONSTANT_MACROS 16 #define __STDC_CONSTANT_MACROS 18 #ifndef __STDC_LIMIT_MACROS 19 #define __STDC_LIMIT_MACROS 29 template <
typename NT,
typename IT>
32 double t01 = MPI_Wtime();
36 std::shared_ptr<CommGrid> layerGrid;
43 std::ostringstream tinfo;
45 tinfo <<
"Reader took " << t02-t01 <<
" seconds" << std::endl;
53 if(p.TotalLength()!=A->
getnrow())
61 std::ostringstream tinfo1;
62 tinfo1 <<
"Permutation took " << MPI_Wtime()-t02 <<
" seconds" << std::endl;
72 std::ostringstream outs;
73 outs <<
"Input load balance: " << balance << std::endl;
82 template<
typename IT,
typename NT>
85 double t01 = MPI_Wtime();
92 std::ostringstream minfo;
93 int nprocs = DEL->
commGrid->GetSize();
94 minfo <<
"Started Generation of scale "<< scale << std::endl;
95 minfo <<
"Using " << nprocs <<
" MPI processes" << std::endl;
101 std::ostringstream tinfo;
103 tinfo <<
"Generation took " << t02-t01 <<
" seconds" << std::endl;
115 std::shared_ptr<CommGrid> layerGrid;
118 p.
iota(A->getnrow(), 0);
121 std::ostringstream tinfo1;
122 tinfo1 <<
"Permutation took " << MPI_Wtime()-t02 <<
" seconds" << std::endl;
128 float balance = A->LoadImbalance();
129 std::ostringstream outs;
130 outs <<
"Load balance: " << balance << std::endl;
143 template <
typename IT,
typename NT>
146 double t01 = MPI_Wtime();
147 std::vector<IT> vecEss;
148 std::vector< SpDCCols<IT, NT> > partsmat;
152 double split_beg = MPI_Wtime();
153 if(rowsplit && nparts>1) localmat->
Transpose();
154 localmat->
ColSplit(nparts, partsmat);
156 for(
int i=0; i< nparts; ++i)
158 std::vector<IT> ess = partsmat[i].GetEssentials();
159 for(
auto itr = ess.begin(); itr != ess.end(); ++itr)
161 vecEss.push_back(*itr);
167 double scatter_beg = MPI_Wtime();
170 std::vector<IT> myess(esscnt);
171 MPI_Scatter(vecEss.data(), esscnt, MPIType<IT>(), myess.data(), esscnt, MPIType<IT>(), 0, CMG.
fiberWorld);
175 splitmat = partsmat[0];
176 for(
int recipient=1; recipient< nparts; ++recipient)
179 Arr<IT,NT> arrinfo = partsmat[recipient].GetArrays();
180 for(
unsigned int i=0; i< arrinfo.
indarrs.size(); ++i)
185 for(
unsigned int i=0; i< arrinfo.
numarrs.size(); ++i)
197 for(
unsigned int i=0; i< arrinfo.
indarrs.size(); ++i)
199 MPI_Recv(arrinfo.
indarrs[i].addr, arrinfo.
indarrs[i].count, MPIType<IT>(), 0, tag++, CMG.
fiberWorld, MPI_STATUS_IGNORE);
201 for(
unsigned int i=0; i< arrinfo.
numarrs.size(); ++i)
203 MPI_Recv(arrinfo.
numarrs[i].addr, arrinfo.
numarrs[i].count, MPIType<NT>(), 0, tag++, CMG.
fiberWorld, MPI_STATUS_IGNORE);
208 if(rowsplit && nparts>1) splitmat.
Transpose();
209 std::ostringstream tinfo;
210 tinfo <<
"Matrix split and distributed along layers: time " << MPI_Wtime()-t01 <<
" seconds" << std::endl;
Compute the maximum of two values.
SpDCCols< IT, NT > * ReadMat(std::string filename, CCGrid &CMG, bool permute, FullyDistVec< IT, IT > &p)
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
std::vector< LocArr< NT, IT > > numarrs
SpDCCols< IT, NT > * GenMat(CCGrid &CMG, unsigned scale, unsigned EDGEFACTOR, double initiator[4], bool permute)
std::vector< LocArr< IT, IT > > indarrs
float LoadImbalance() const
void ColSplit(int parts, std::vector< SpDCCols< IT, NT > > &matrices)
void Create(const std::vector< IT > &essentials)
void SplitMat(CCGrid &CMG, SpDCCols< IT, NT > *localmat, SpDCCols< IT, NT > &splitmat, bool rowsplit=false)
static void Print(const std::string &s)
void iota(IT globalsize, NT first)
Arr< IT, NT > GetArrays() const
std::shared_ptr< CommGrid > commGrid
void Transpose()
Mutator version, replaces the calling object.
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)