33 #ifndef __STDC_CONSTANT_MACROS 34 #define __STDC_CONSTANT_MACROS 36 #ifndef __STDC_LIMIT_MACROS 37 #define __STDC_LIMIT_MACROS 68 int main(
int argc,
char* argv[])
71 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
72 if (provided < MPI_THREAD_SERIALIZED)
74 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
75 MPI_Abort(MPI_COMM_WORLD, 1);
82 nthreads = omp_get_num_threads();
87 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
88 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
91 cout <<
"Process Grid (p x p x t): " << sqrt(nprocs) <<
" x " << sqrt(nprocs) <<
" x " << nthreads << endl;
98 cout <<
"Usage: ./cc -I <mm|triples> -M <FILENAME_MATRIX_MARKET> (required)\n";
99 cout <<
"-I <INPUT FILE TYPE> (mm: matrix market, triples: (vtx1, vtx2, edge_weight) triples. default:mm)\n";
100 cout <<
"-base <BASE OF MATRIX MARKET> (default:1)\n";
101 cout <<
"-rand <RANDOMLY PERMUTE VERTICES> (default:0)\n";
102 cout <<
"Example (0-indexed mtx with random permutation): ./cc -M input.mtx -base 0 -rand 1" << endl;
103 cout <<
"Example (triples format): ./cc -I triples -M input.txt" << endl;
109 string ifilename =
"";
112 bool isMatrixMarket =
true;
114 for (
int i = 1; i < argc; i++)
116 if (strcmp(argv[i],
"-I")==0)
118 string ifiletype = string(argv[i+1]);
119 if(ifiletype ==
"triples") isMatrixMarket =
false;
121 if (strcmp(argv[i],
"-M")==0)
123 ifilename = string(argv[i+1]);
124 if(myrank == 0) printf(
"filename: %s",ifilename.c_str());
126 else if (strcmp(argv[i],
"-base")==0)
128 base = atoi(argv[i + 1]);
129 if(myrank == 0) printf(
"\nBase of MM (1 or 0):%d",base);
131 else if (strcmp(argv[i],
"-rand")==0)
133 randpermute = atoi(argv[i + 1]);
134 if(myrank == 0) printf(
"\nRandomly permute the matrix? (1 or 0):%d",randpermute);
138 double tIO = MPI_Wtime();
151 SpParHelper::Print(
"Symmatricizing an unsymmetric input matrix.\n");
158 outs <<
"File Read time: " << MPI_Wtime() - tIO << endl;
159 SpParHelper::Print(outs.str());
161 if(randpermute && isMatrixMarket)
170 SpParHelper::Print(
"Applied symmetric permutation.\n");
174 SpParHelper::Print(
"Rectangular matrix: Can not apply symmetric permutation.\n");
182 outs <<
"isolated vertice: " << isov.TotalLength() << endl;
183 SpParHelper::Print(outs.str());
189 outs <<
"Load balance: " << balance << endl;
190 outs <<
"Nonzeros: " << nnz << endl;
191 SpParHelper::Print(outs.str());
192 double t1 = MPI_Wtime();
197 double t2 = MPI_Wtime();
207 double tend = MPI_Wtime();
209 s2 <<
"Number of clusters: " << nclusters << endl;
210 s2 <<
"Total time: " << (t2-t1) << endl;
211 s2 <<
"=================================================\n" << endl ;
212 SpParHelper::Print(s2.str());
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
std::shared_ptr< CommGrid > getcommgrid() const
FullyDistVec< IT, std::array< char, MAXVERTNAME > > ReadGeneralizedTuples(const std::string &, _BinaryOperation)
Compute the maximum of two values.
SpDCCols< int64_t, double > DCCols
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
float LoadImbalance() const
FullyDistVec< IT, IT > CC(SpParMat< IT, NT, DER > &A, IT &nCC)
void iota(IT globalsize, NT first)
SpParMat< int64_t, double, DCCols > MPI_DCCols
int main(int argc, char *argv[])
NT Reduce(_BinaryOperation __binary_op, NT identity) const
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)