16 bool from_string(T & t,
const string& s, std::ios_base& (*f)(std::ios_base&))
19 return !(iss >> f >> t).fail();
22 int main(
int argc,
char* argv[])
25 MPI_Init(&argc, &argv);
26 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
27 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
33 cout <<
"Usage: ./IndexingTiming Input/Force/Binary <Inputfile>/<Scale>/<BinaryFile>" << endl;
41 if(
string(argv[1]) ==
string(
"Input"))
43 A->ReadDistribute(argv[2], 0);
45 else if(
string(argv[1]) ==
string(
"Binary"))
52 outs <<
"Reading " << argv[2] <<
" with " << n <<
" vertices and " << m <<
" edges" << endl;
53 SpParHelper::Print(outs.str());
55 SpParHelper::Print(
"Read binary input to distributed edge list\n");
58 SpParHelper::Print(
"Permuted Edges\n");
61 SpParHelper::Print(
"Renamed Vertices\n");
63 A =
new PARDBMAT(*DEL,
false);
65 SpParHelper::Print(
"Created double Sparse Matrix\n");
67 else if(
string(argv[1]) ==
string(
"Force"))
69 double initiator[4] = {.6, .4/3, .4/3, .4/3};
72 int scale =
static_cast<unsigned>(atoi(argv[2]));
74 outs <<
"Forcing scale to : " << scale << endl;
75 SpParHelper::Print(outs.str());
77 SpParHelper::Print(
"Generated local RMAT matrices\n");
80 SpParHelper::Print(
"Permuted Edges\n");
83 SpParHelper::Print(
"Renamed Vertices\n");
86 A =
new PARDBMAT(*DEL,
false);
88 SpParHelper::Print(
"Created double Sparse Matrix\n");
94 p.
iota(A->getnrow(), 0);
96 SpParHelper::Print(
"Permutation Generated\n");
97 PARDBMAT
B = (*A)(p,p);
100 float oldbalance = A->LoadImbalance();
101 float newbalance = B.LoadImbalance();
103 outs <<
"Running on " << nprocs <<
" cores" << endl;
104 outs <<
"Old balance: " << oldbalance << endl;
105 outs <<
"New balance: " << newbalance << endl;
106 SpParHelper::Print(outs.str());
108 MPI_Barrier(MPI_COMM_WORLD);
109 double t1 = MPI_Wtime();
116 MPI_Barrier(MPI_COMM_WORLD);
117 double t2 = MPI_Wtime();
121 cout<<
"Indexing Iterations finished"<<endl;
122 printf(
"%.6lf seconds elapsed per iteration\n", (t2-t1)/(
double)ITERATIONS);
127 vector< FullyDistVec<int,int> > clusters(nclust);
128 int nperclus = A->getnrow() / nclust;
130 for(
int i = 0; i< nclust; i++)
132 int k = std::min(nperclus, A->getnrow() - nperclus * i);
133 clusters[i].iota(k, nperclus * i);
134 clusters[i] = p(clusters[i]);
137 for(
int i=0; i< nclust; i++)
139 B = (*A)(clusters[i], clusters[i]);
143 MPI_Barrier(MPI_COMM_WORLD);
145 for(
int i=0; i< nclust; i++)
148 B = (*A)(clusters[i], clusters[i]);
151 MPI_Barrier(MPI_COMM_WORLD);
156 cout<<
"Indexing Iterations finished"<<endl;
157 printf(
"%.6lf seconds elapsed per iteration\n", (t2-t1)/(
double)ITERATIONS);
161 for(
int i=0; i< nclust; i++)
164 C.Prune(clusters[i], clusters[i]);
167 B = (*A)(clusters[i], clusters[i]);
168 C.SpAsgn(clusters[i], clusters[i], B);
173 SpParHelper::Print(
"Pruning and SpAsgn seem to be working\n");
177 SpParHelper::Print(
"A and C don't match, below is C's info followed by B's info\n");
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
void PermEdges(DistEdgeList< IT > &DEL)
void RenameVertices(DistEdgeList< IU > &DEL)
void iota(IT globalsize, NT first)
int main(int argc, char *argv[])
bool from_string(T &t, const string &s, std::ios_base &(*f)(std::ios_base &))