1 #include "../CombBLAS.h" 31 template <
typename PARMAT>
53 friend ostream&
operator<<(ostream& os,
const VertexType & vertex ){os <<
"(" << vertex.
parent <<
"," << vertex.root <<
")";
return os;};
73 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
74 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
83 A.
Reduce(*ColSums,
Column, plus<int64_t>(), static_cast<int64_t>(0));
84 A.
Reduce(*RowSums,
Row, plus<int64_t>(), static_cast<int64_t>(0));
95 nonisoColV = ColSums->
FindInds(bind2nd(greater<int64_t>(), 0));
96 nonisoRowV = RowSums->
FindInds(bind2nd(greater<int64_t>(), 0));
108 double avgDeg1 = (double) nnz1/(nrows1+ncols1);
111 A.operator()(nonisoRowV, nonisoColV,
true);
114 double avgDeg2 = (double) nnz2/(nrows2+ncols2);
119 cout <<
"ncol nrows nedges deg \n";
120 cout << nrows1 <<
" " << ncols1 <<
" " << nnz1 <<
" " << avgDeg1 <<
" \n";
121 cout << nrows2 <<
" " << ncols2 <<
" " << nnz2 <<
" " << avgDeg2 <<
" \n";
124 MPI_Barrier(MPI_COMM_WORLD);
138 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
141 cout <<
"\n-------------- usage --------------\n";
142 cout <<
"Usage (random matrix): ./maximal <er|g500|ssca> <Scale> <EDGEFACTOR> <algo><rand><moreSplit>\n";
143 cout <<
"Usage (input matrix): ./maximal <input> <matrix> <algo><rand><moreSplit>\n\n";
145 cout <<
" \n-------------- meaning of arguments ----------\n";
146 cout <<
"** er: Erdos-Renyi, g500: Graph500 benchmark, ssca: SSCA benchmark\n";
147 cout <<
"** scale: matrix dimention is 2^scale\n";
148 cout <<
"** edgefactor: average degree of vertices\n";
149 cout <<
"** algo : maximal matching algorithm used to initialize\n ";
150 cout <<
" greedy: greedy init , ks: Karp-Sipser, dmd: dynamic mindegree\n";
151 cout <<
" default: dynamic mindegree\n";
152 cout <<
"** (optional) rand: random parent selection in greedy/Karp-Sipser\n" ;
153 cout <<
"** (optional) moreSplit: more splitting of Matrix.\n" ;
154 cout <<
"(order of optional arguments does not matter)\n";
156 cout <<
" \n-------------- examples ----------\n";
157 cout <<
"Example: mpirun -np 4 ./maximal g500 18 16 ks rand" << endl;
158 cout <<
"Example: mpirun -np 4 ./maximal input cage12.mtx dmd\n" << endl;
165 for(
int i=0; i<argc; i++)
167 allArg += string(argv[i]);
170 if(allArg.find(
"moreSplit")!=string::npos)
172 if(allArg.find(
"randMaximal")!=string::npos)
174 if(allArg.find(
"greedy")!=string::npos)
176 else if(allArg.find(
"ks")!=string::npos)
178 else if(allArg.find(
"dmd")!=string::npos)
189 tinfo <<
"\n---------------------------------\n";
190 tinfo <<
" Maximal matching algorithm options: ";
192 if(
init ==
DMD) tinfo <<
" dynamic mindegree, ";
194 if(
randMaximal) tinfo <<
" random parent selection in greedy/Karp-Sipser, ";
196 tinfo <<
"\n---------------------------------\n\n";
197 SpParHelper::Print(tinfo.str());
249 int main(
int argc,
char* argv[])
254 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
255 if (provided < MPI_THREAD_SERIALIZED)
257 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
258 MPI_Abort(MPI_COMM_WORLD, 1);
261 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
262 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
280 if(
string(argv[1]) ==
string(
"input"))
284 string filename(argv[2]);
286 tinfo <<
"**** Reading input matrix: " << filename <<
" ******* " << endl;
287 SpParHelper::Print(tinfo.str());
293 tinfo <<
"Reader took " << t02-t01 <<
" seconds" << endl;
294 SpParHelper::Print(tinfo.str());
306 unsigned scale = (unsigned) atoi(argv[2]);
307 unsigned EDGEFACTOR = (unsigned) atoi(argv[3]);
309 if(
string(argv[1]) == string(
"er"))
316 else if(
string(argv[1]) == string(
"g500"))
323 else if(
string(argv[1]) == string(
"ssca"))
333 printf(
"The input type - %s - is not recognized.\n", argv[2]);
334 MPI_Abort(MPI_COMM_WORLD, 1);
337 SpParHelper::Print(
"Generating input matrix....\n");
346 tinfo <<
"Generator took " << t02-t01 <<
" seconds" << endl;
347 SpParHelper::Print(tinfo.str());
360 SpParHelper::Print(
"Performing random permuation of matrix.\n");
364 pcol.iota(ABool->
getncol(), 0);
367 (*ABool)(prow, pcol,
true);
368 SpParHelper::Print(
"Performed random permuation of matrix.\n");
381 A.
Reduce(degCol,
Column, plus<int64_t>(), static_cast<int64_t>(0));
387 int splitPerThread = 1;
389 nthreads = omp_get_num_threads();
393 tinfo <<
"Threading activated with " << nthreads <<
" threads, and matrix split into "<<
cblas_splits <<
" parts" << endl;
394 SpParHelper::Print(tinfo.str());
399 SpParHelper::Print(
" #####################################################\n");
400 SpParHelper::Print(
" ################## Run 1 ############################\n");
401 SpParHelper::Print(
" #####################################################\n");
404 SpParHelper::Print(
" #####################################################\n");
405 SpParHelper::Print(
" ################## Run 2 ############################\n");
406 SpParHelper::Print(
" #####################################################\n");
410 SpParHelper::Print(
" #####################################################\n");
411 SpParHelper::Print(
" ################## Run 3 ############################\n");
412 SpParHelper::Print(
" #####################################################\n");
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
void removeIsolated(PSpMat_Bool &A)
std::shared_ptr< CommGrid > getcommgrid() const
void ActivateThreading(int numsplits)
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)
Compute the maximum of two values.
void experiment(PSpMat_Bool &A, PSpMat_Bool &AT, FullyDistVec< int64_t, int64_t > degCol)
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.
friend bool operator==(const VertexType &vtx1, const VertexType &vtx2)
int main(int argc, char *argv[])
void iota(IT globalsize, NT first)
VertexType(int64_t p=-1, int64_t r=-1, int16_t pr=0)
SpParMat< int64_t, bool, SpDCCols< int64_t, bool > > PSpMat_Bool
friend bool operator<(const VertexType &vtx1, const VertexType &vtx2)
void Apply(_UnaryOperation __unary_op)
void GetOptions(char *argv[], int argc)
void Symmetricize(PARMAT &A)
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)