33#ifndef __STDC_CONSTANT_MACROS
34#define __STDC_CONSTANT_MACROS
36#ifndef __STDC_LIMIT_MACROS
37#define __STDC_LIMIT_MACROS
49#include "CombBLAS/CombBLAS.h"
70int main(
int argc,
char* argv[])
73 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
74 if (provided < MPI_THREAD_SERIALIZED)
76 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
77 MPI_Abort(MPI_COMM_WORLD, 1);
84 nthreads = omp_get_num_threads();
89 MPI_Comm_size(MPI_COMM_WORLD,&
nprocs);
90 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
93 cout <<
"Process Grid (p x p x t): " << sqrt(
nprocs) <<
" x " << sqrt(
nprocs) <<
" x " << nthreads << endl;
100 cout <<
"Usage: ./fastsv -I <mm|triples> -M <FILENAME> (required)\n";
101 cout <<
"-I <INPUT FILE TYPE> (mm: matrix market, triples: (vtx1, vtx2, edge_weight) triples. default:mm)\n";
102 cout <<
"-base <BASE OF MATRIX MARKET> (default:1)\n";
103 cout <<
"-rand <RANDOMLY PERMUTE VERTICES> (default:0)\n";
104 cout <<
"Example (0-indexed mtx with random permutation): ./fastsv -M input.mtx -base 0 -rand 1" << endl;
105 cout <<
"Example (triples format): ./fastsv -I triples -M input.txt" << endl;
111 string ifilename =
"";
115 bool isMatrixMarket =
true;
117 for (
int i = 1; i < argc; i++)
119 if (strcmp(argv[i],
"-I")==0)
121 string ifiletype = string(argv[i+1]);
122 if(ifiletype ==
"triples") isMatrixMarket =
false;
124 if (strcmp(argv[i],
"-M")==0)
126 ifilename = string(argv[i+1]);
127 if(myrank == 0) printf(
"filename: %s\n",ifilename.c_str());
129 else if (strcmp(argv[i],
"-base")==0)
131 base = atoi(argv[i + 1]);
132 if(myrank == 0) printf(
"\nBase of MM (1 or 0):%d\n",base);
134 else if (strcmp(argv[i],
"-rand")==0)
136 randpermute = atoi(argv[i + 1]);
137 if(myrank == 0) printf(
"\nRandomly permute the matrix? (1 or 0):%d\n",randpermute);
139 else if (strcmp(argv[i],
"-step")==0)
141 step = atoi(argv[i + 1]);
142 if(myrank == 0) printf(
"\nGraph size:%.2f%%\n", 100.0 / step);
146 double tIO = MPI_Wtime();
159 SpParHelper::Print(
"Symmatricizing an unsymmetric input matrix.\n");
165 outs <<
"File Read time: " << MPI_Wtime() -
tIO << endl;
166 SpParHelper::Print(outs.str());
168 if(randpermute && isMatrixMarket)
170 double tPerm = MPI_Wtime();
172 if(
A.getnrow() ==
A.getncol())
175 p.
iota(
A.getnrow(), 0);
178 SpParHelper::Print(
"Applied symmetric permutation.\n");
182 SpParHelper::Print(
"Rectangular matrix: Can not apply symmetric permutation.\n");
184 double dur = MPI_Wtime() - tPerm;
187 outs <<
"Random permutation time: " << dur << endl;
188 SpParHelper::Print(outs.str());
195 outs <<
"isolated vertice: " << isov.TotalLength() << endl;
196 SpParHelper::Print(outs.str());
198 float balance =
A.LoadImbalance();
199 Int nnz =
A.getnnz();
202 outs <<
"Load balance: " << balance << endl;
203 outs <<
"Nonzeros: " << nnz << endl;
204 SpParHelper::Print(outs.str());
205 double t1 = MPI_Wtime();
210 double t2 = MPI_Wtime();
220 double tend = MPI_Wtime();
222 s2 <<
"Number of components: " << nclusters << endl;
223 s2 <<
"Total time: " << (t2-t1) << endl;
224 s2 <<
"=================================================\n" << endl ;
225 SpParHelper::Print(s2.str());
int main(int argc, char *argv[])
SpParMat< Int, Int, DCCols > MPI_DCCols
SpDCCols< Int, Int > DCCols
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
NT Reduce(_BinaryOperation __binary_op, NT identity) const
void iota(IT globalsize, NT first)
FullyDistVec< IT, IT > SV(SpParMat< IT, NT, DER > &A, IT &nCC)
Compute the maximum of two values.