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
23 #include "CombBLAS/CombBLAS.h"
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;
51 if(
A->getnrow() ==
A->getncol())
53 if(p.TotalLength()!=
A->getnrow())
56 p.
iota(
A->getnrow(), 0);
61 std::ostringstream tinfo1;
62 tinfo1 <<
"Permutation took " << MPI_Wtime()-t02 <<
" seconds" << std::endl;
71 float balance =
A->LoadImbalance();
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)
193 splitmat.Create(myess);
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;