19 template <
typename PARMAT>
35 static T_promote
id(){
return -1; };
37 static MPI_Op
mpi_op() {
return MPI_MIN; };
39 static T_promote
add(
const T_promote & arg1,
const T_promote & arg2)
41 return std::min(arg1, arg2);
44 static T_promote
multiply(
const bool & arg1,
const T_promote & arg2)
49 static void axpy(
bool a,
const T_promote & x, T_promote & y)
61 int main(
int argc,
char* argv[])
64 MPI_Init(&argc, &argv);
65 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
66 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
71 cout <<
"Usage: ./md <rmat|er|input> <scale|filename>" << endl;
72 cout <<
"Example: mpirun -np 4 ./md rmat 20" << endl;
73 cout <<
"Example: mpirun -np 4 ./md er 20" << endl;
74 cout <<
"Example: mpirun -np 4 ./md input a.mtx" << endl;
83 if(
string(argv[1]) ==
string(
"input"))
85 string filename(argv[2]);
87 inf.open(filename.c_str(), ios::in);
90 bool isSymmetric = header.find(
"symmetric");
91 bool isUnweighted = header.find(
"pattern");
100 else if(
string(argv[1]) ==
string(
"rmat"))
103 scale =
static_cast<unsigned>(atoi(argv[2]));
104 double initiator[4] = {.57, .19, .19, .05};
107 MPI_Barrier(MPI_COMM_WORLD);
113 else if(
string(argv[1]) ==
string(
"er"))
116 scale =
static_cast<unsigned>(atoi(argv[2]));
117 double initiator[4] = {.25, .25, .25, .25};
120 MPI_Barrier(MPI_COMM_WORLD);
154 x.SetElement(source, 1);
156 while(x.getnnz() > 0)
158 SpMV<SelectMinSR>(
A, x, nx,
false);
159 nx.Select(visited, [](
int64_t visit){
return visit==0;});
167 reach.DelElement(source);
211 while( fringe.
getnnz() > 0 )
214 fringe = PSpGEMM<SelectMinSR>(
A, fringe);
217 fringe =
EWiseMult(fringe, visited,
true);
222 fringe = PSpGEMM<PTDD>(E, fringe);
235 visited = PSpGEMM<PTDD>(NE, visited);
238 visited.
Reduce(degrees,
Column, plus<int64_t>(), static_cast<int64_t>(0));
239 degrees.Apply([](
int64_t val){
return (val-1);});
269 for(
int i=0; i<nprocs; )
274 s = locvals[j++] + sources.LengthUntil();
294 A.
Reduce(degrees,
Column, plus<int64_t>(), static_cast<int64_t>(0));
295 degrees.Apply([](
int64_t x){
return x-1;});
302 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
303 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
304 double time_beg = MPI_Wtime();
307 double time1=0, time2=0, time3=0;
311 int64_t s = degrees.MinElement().first;
317 time2 += MPI_Wtime()-time1;
326 time3 += MPI_Wtime()-time1;
328 degrees.Set(updatedDeg);
329 degrees.SetElement(s, A.
getnrow());
338 cout << i <<
" .................. " << nnz <<
" :: " << time2 <<
" + " << time3 << endl;
339 time2 = 0; time3 = 0;
347 double time_end = MPI_Wtime();
351 cout <<
" Total time: " << time_end - time_beg << endl;
void SetElement(IT indx, NT numx)
Indexing is performed 0-based.
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
std::shared_ptr< CommGrid > getcommgrid() const
void SetElement(IT indx, NT numx)
MPI_Datatype MPIType< int64_t >(void)
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
FullyDistSpVec< int64_t, int64_t > getReach(int64_t source, PSpMat_Int64 &A, FullyDistVec< int64_t, int64_t > &enodes)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
Dcsc< IU, typename promote_trait< NU1, NU2 >::T_promote > EWiseMult(const Dcsc< IU, NU1 > &A, const Dcsc< IU, NU2 > *B, bool exclude)
std::shared_ptr< CommGrid > getcommgrid() const
static T_promote add(const T_promote &arg1, const T_promote &arg2)
FullyDistSpVec< int64_t, int64_t > getReachesSPMM(FullyDistSpVec< int64_t, int64_t > &sources, PSpMat_Int64 &A, FullyDistVec< int64_t, int64_t > &enodes)
void Select(const FullyDistVec< IT, NT1 > &denseVec, _UnaryOperation unop)
SpParMat< int64_t, int64_t, SpDCCols< int64_t, int64_t > > PSpMat_Int64
void ReadDistribute(const std::string &filename, int master, bool nonum, HANDLER handler, bool transpose=false, bool pario=false)
static void axpy(bool a, const T_promote &x, T_promote &y)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
static T_promote multiply(const bool &arg1, const T_promote &arg2)
static void Print(const std::string &s)
void iota(IT globalsize, NT first)
int main(int argc, char *argv[])
void Symmetricize(PARMAT &A)
std::vector< IT > GetLocalInd()
FullyDistSpVec< int64_t, int64_t > getReachesSPMV(FullyDistSpVec< int64_t, int64_t > &sources, PSpMat_Int64 &A, FullyDistVec< int64_t, int64_t > &enodes)
SpParMat< int64_t, bool, SpDCCols< int64_t, bool > > PSpMat_Bool
static bool returnedSAID()