1#include "CombBLAS/CombBLAS.h"
31template <
typename PARMAT>
53 friend ostream&
operator<<(ostream& os,
const VertexType & vertex ){os <<
"(" << vertex.
parent <<
"," << vertex.root <<
")";
return os;};
73 MPI_Comm comm =
A.getcommgrid()->GetWorld();
74 MPI_Comm_size(comm,&
nprocs);
75 MPI_Comm_rank(comm,&myrank);
84 A.Reduce(*ColSums,
Column, plus<int64_t>(),
static_cast<int64_t>(0));
85 A.Reduce(*RowSums,
Row, plus<int64_t>(),
static_cast<int64_t>(0));
96 nonisoColV = ColSums->
FindInds(bind2nd(greater<int64_t>(), 0));
97 nonisoRowV = RowSums->
FindInds(bind2nd(greater<int64_t>(), 0));
108 int64_t nrows1=
A.getnrow(), ncols1=
A.getncol(), nnz1 =
A.getnnz();
109 double avgDeg1 = (double) nnz1/(nrows1+ncols1);
112 A.operator()(nonisoRowV, nonisoColV,
true);
114 int64_t nrows2=
A.getnrow(), ncols2=
A.getncol(), nnz2 =
A.getnnz();
115 double avgDeg2 = (double) nnz2/(nrows2+ncols2);
120 cout <<
"ncol nrows nedges deg \n";
121 cout << nrows1 <<
" " << ncols1 <<
" " << nnz1 <<
" " << avgDeg1 <<
" \n";
122 cout << nrows2 <<
" " << ncols2 <<
" " << nnz2 <<
" " << avgDeg2 <<
" \n";
139 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
142 cout <<
"\n-------------- usage --------------\n";
143 cout <<
"Usage (random matrix): ./maximal <er|g500|ssca> <Scale> <EDGEFACTOR> <algo><rand><moreSplit>\n";
144 cout <<
"Usage (input matrix): ./maximal <input> <matrix> <algo><rand><moreSplit>\n\n";
146 cout <<
" \n-------------- meaning of arguments ----------\n";
147 cout <<
"** er: Erdos-Renyi, g500: Graph500 benchmark, ssca: SSCA benchmark\n";
148 cout <<
"** scale: matrix dimention is 2^scale\n";
149 cout <<
"** edgefactor: average degree of vertices\n";
150 cout <<
"** algo : maximal matching algorithm used to initialize\n ";
151 cout <<
" greedy: greedy init , ks: Karp-Sipser, dmd: dynamic mindegree\n";
152 cout <<
" default: dynamic mindegree\n";
153 cout <<
"** (optional) rand: random parent selection in greedy/Karp-Sipser\n" ;
154 cout <<
"** (optional) moreSplit: more splitting of Matrix.\n" ;
155 cout <<
"(order of optional arguments does not matter)\n";
157 cout <<
" \n-------------- examples ----------\n";
158 cout <<
"Example: mpirun -np 4 ./maximal g500 18 16 ks rand" << endl;
159 cout <<
"Example: mpirun -np 4 ./maximal input cage12.mtx dmd\n" << endl;
166 for(
int i=0; i<argc; i++)
168 allArg += string(argv[i]);
171 if(allArg.find(
"moreSplit")!=string::npos)
173 if(allArg.find(
"randMaximal")!=string::npos)
175 if(allArg.find(
"greedy")!=string::npos)
177 else if(allArg.find(
"ks")!=string::npos)
179 else if(allArg.find(
"dmd")!=string::npos)
190 tinfo <<
"\n---------------------------------\n";
191 tinfo <<
" Maximal matching algorithm options: ";
193 if(
init ==
DMD) tinfo <<
" dynamic mindegree, ";
195 if(
randMaximal) tinfo <<
" random parent selection in greedy/Karp-Sipser, ";
197 tinfo <<
"\n---------------------------------\n\n";
198 SpParHelper::Print(tinfo.str());
250int main(
int argc,
char* argv[])
255 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
256 if (provided < MPI_THREAD_SERIALIZED)
258 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
259 MPI_Abort(MPI_COMM_WORLD, 1);
262 MPI_Comm_size(MPI_COMM_WORLD,&
nprocs);
263 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
281 if(
string(argv[1]) ==
string(
"input"))
285 string filename(argv[2]);
287 tinfo <<
"**** Reading input matrix: " << filename <<
" ******* " << endl;
288 SpParHelper::Print(tinfo.str());
294 tinfo <<
"Reader took " << t02-t01 <<
" seconds" << endl;
295 SpParHelper::Print(tinfo.str());
307 unsigned scale = (unsigned) atoi(argv[2]);
308 unsigned EDGEFACTOR = (unsigned) atoi(argv[3]);
310 if(
string(argv[1]) == string(
"er"))
317 else if(
string(argv[1]) == string(
"g500"))
324 else if(
string(argv[1]) == string(
"ssca"))
334 printf(
"The input type - %s - is not recognized.\n", argv[2]);
335 MPI_Abort(MPI_COMM_WORLD, 1);
338 SpParHelper::Print(
"Generating input matrix....\n");
347 tinfo <<
"Generator took " << t02-t01 <<
" seconds" << endl;
348 SpParHelper::Print(tinfo.str());
361 SpParHelper::Print(
"Performing random permuation of matrix.\n");
368 (*ABool)(prow, pcol,
true);
369 SpParHelper::Print(
"Performed random permuation of matrix.\n");
382 A.Reduce(degCol,
Column, plus<int64_t>(),
static_cast<int64_t>(0));
388 int splitPerThread = 1;
390 nthreads = omp_get_num_threads();
394 tinfo <<
"Threading activated with " << nthreads <<
" threads, and matrix split into "<<
cblas_splits <<
" parts" << endl;
395 SpParHelper::Print(tinfo.str());
400 SpParHelper::Print(
" #####################################################\n");
401 SpParHelper::Print(
" ################## Run 1 ############################\n");
402 SpParHelper::Print(
" #####################################################\n");
405 SpParHelper::Print(
" #####################################################\n");
406 SpParHelper::Print(
" ################## Run 2 ############################\n");
407 SpParHelper::Print(
" #####################################################\n");
411 SpParHelper::Print(
" #####################################################\n");
412 SpParHelper::Print(
" ################## Run 3 ############################\n");
413 SpParHelper::Print(
" #####################################################\n");
int main(int argc, char *argv[])
SpParMat< int64_t, bool, SpDCCols< int64_t, bool > > PSpMat_Bool
void GetOptions(char *argv[], int argc)
void Symmetricize(PARMAT &A)
void experiment(PSpMat_Bool &A, PSpMat_Bool &AT, FullyDistVec< int64_t, int64_t > degCol)
void removeIsolated(PSpMat_Bool &A)
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
void iota(IT globalsize, NT first)
void Apply(_UnaryOperation __unary_op)
void ActivateThreading(int numsplits)
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)
std::shared_ptr< CommGrid > getcommgrid() const
void MaximalMatching(Par_DCSC_Bool &A, Par_DCSC_Bool &AT, FullyDistVec< IT, IT > &mateRow2Col, FullyDistVec< IT, IT > &mateCol2Row, FullyDistVec< IT, IT > °ColRecv, int type, bool rand=true)
friend bool operator<(const VertexType &vtx1, const VertexType &vtx2)
friend bool operator==(const VertexType &vtx1, const VertexType &vtx2)
VertexType(int64_t p=-1, int64_t r=-1, int16_t pr=0)
friend ostream & operator<<(ostream &os, const VertexType &vertex)
Compute the maximum of two values.