37int main(
int argc,
char* argv[])
39 MPI::Init(argc, argv);
40 int nprocs = MPI::COMM_WORLD.Get_size();
41 int myrank = MPI::COMM_WORLD.Get_rank();
46 MPI::Datatype types[3] = {MPI::INT, MPI::DOUBLE, MPI::INT};
47 int lengths[3] = {1, 1, 1};
50 disp[0] = MPI::Get_address(&n.
id) - MPI::Get_address(&n);
51 disp[1] = MPI::Get_address(&n.
dist) - MPI::Get_address(&n);
52 disp[2] = MPI::Get_address(&n.
parent) - MPI::Get_address(&n);
61 cout << endl <<
"Require 3 args..." << endl <<
62 "fileName startV testV" << endl;
67 char* fileName = argv[1];
68 stringstream sstr(argv[2]);
71 stringstream sstr2(argv[3]);
76 cout <<
"startV: " << startVert << endl;
78 MPI::COMM_WORLD.Barrier();
81 SpParMat<int, double, SpDCCols <int, double> > G;
82 G.ReadDistribute(fileName, 0);
83 int numVerts = G.getncol();
85 cout <<
"numVerts: " << numVerts << endl;
87 if (startVert > numVerts || startVert <= 0) {
88 cout <<
"Invalid start vertex id." << endl;
93 Node zero(
double(0), -1);
95 time_t startTime, endTime;
98 startTime = time(NULL);
99 cout <<
"start computing" << endl;
103 bool finished =
false;
105 FullyDistVec<int, Node> result(G.getcommgrid(), G.getncol(),
Node());
106 FullyDistSpVec<int, Node> frontier(G.getcommgrid(), G.getncol());
108 frontier.SetElement(startVert - 1, zero);
109 frontier.setNumToInd();
114 frontier = EWiseApply<Node>(frontier, result, binaryOp, doOp,
false,
Node());
115 result.EWiseApply(frontier, binaryOp,
false,
Node());
117 for(iteration = 1; iteration < numVerts; iteration++) {
118 frontier = SpMV<SPSRing>(G, frontier);
119 frontier.setNumToInd();
120 frontier = EWiseApply<Node>(frontier, result, binaryOp, doOp,
false,
Node());
121 if (frontier.getnnz() == 0) {
125 result.EWiseApply(frontier, binaryOp,
false,
Node());
128 Node res = result[testVert - 1];
130 endTime = time(NULL);
131 elapsedTime = difftime(endTime, startTime);
133 cout <<
"finished" << endl;
136 cout <<
"negative loop" << endl;
138 cout <<
"number of iterations: " << iteration << endl;
139 cout <<
"running time: " << elapsedTime <<
"s" << endl;