1 #include "../CombBLAS.h" 21 template <
typename PARMAT>
43 secondMaxProfit = smp;
48 friend ostream&
operator<<(ostream& os,
const VertexType & vertex ){os <<
"(" << vertex.objID <<
", " << vertex.price <<
", " << vertex.secondMaxProfit <<
")";
return os;};
60 struct max2 :
public std::binary_function<VertexType, VertexType, VertexType>
68 if(x.secondMaxProfit < y.price) ret.secondMaxProfit = y.price;
73 if(y.secondMaxProfit < x.price) ret.secondMaxProfit = x.price;
93 return max2()(arg1, arg2);
101 return VertexType(arg2.objID, arg1 - arg2.price, arg2.secondMaxProfit);
120 template <
class IT,
class NT>
134 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
135 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
144 A.
Reduce(*ColSums,
Column, plus<int64_t>(), static_cast<int64_t>(0));
145 A.
Reduce(*RowSums,
Row, plus<int64_t>(), static_cast<int64_t>(0));
156 nonisoColV = ColSums->
FindInds(bind2nd(greater<int64_t>(), 0));
157 nonisoRowV = RowSums->
FindInds(bind2nd(greater<int64_t>(), 0));
169 double avgDeg1 = (double) nnz1/(nrows1+ncols1);
172 A.operator()(nonisoRowV, nonisoColV,
true);
175 double avgDeg2 = (double) nnz2/(nrows2+ncols2);
180 cout <<
"ncol nrows nedges deg \n";
181 cout << nrows1 <<
" " << ncols1 <<
" " << nnz1 <<
" " << avgDeg1 <<
" \n";
182 cout << nrows2 <<
" " << ncols2 <<
" " << nnz2 <<
" " << avgDeg2 <<
" \n";
185 MPI_Barrier(MPI_COMM_WORLD);
194 int main(
int argc,
char* argv[])
199 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
200 if (provided < MPI_THREAD_SERIALIZED)
202 printf(
"ERROR: The MPI library does not have MPI_THREAD_SERIALIZED support\n");
203 MPI_Abort(MPI_COMM_WORLD, 1);
206 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
207 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
223 if(
string(argv[1]) ==
string(
"input"))
227 string filename(argv[2]);
229 tinfo <<
"**** Reading input matrix: " << filename <<
" ******* " << endl;
230 SpParHelper::Print(tinfo.str());
236 tinfo <<
"Reader took " << t02-t01 <<
" seconds" << endl;
237 SpParHelper::Print(tinfo.str());
249 unsigned scale = (unsigned) atoi(argv[2]);
250 unsigned EDGEFACTOR = (unsigned) atoi(argv[3]);
252 if(
string(argv[1]) == string(
"er"))
258 cout <<
"ER ******** \n";
260 else if(
string(argv[1]) == string(
"g500"))
266 cout <<
"g500 ******** \n";
268 else if(
string(argv[1]) == string(
"ssca"))
274 cout <<
"ER ******** \n";
279 printf(
"The input type - %s - is not recognized.\n", argv[2]);
280 MPI_Abort(MPI_COMM_WORLD, 1);
283 SpParHelper::Print(
"Generating input matrix....\n");
292 tinfo <<
"Generator took " << t02-t01 <<
" seconds" << endl;
293 SpParHelper::Print(tinfo.str());
297 SpParHelper::Print(
"Generated matrix symmetricized....\n");
306 SpParHelper::Print(
"Performing random permutation of matrix.\n");
310 pcol.iota(ABool->
getncol(), 0);
313 (*ABool)(prow, pcol,
true);
314 SpParHelper::Print(
"Performed random permutation of matrix.\n");
323 auction(A, mateRow2Col, mateCol2Row);
343 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
344 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
352 vector<vector<double> > timing;
354 vector<int64_t> phaseMatched;
355 double t1, time_search, time_augment, time_phase;
370 bidders = SpMV<SubMaxSR>(
A, objects);
381 activeBidders = EWiseApply<VertexType>(activeBidders, mateRow2Col,
393 activeBidders.DebugPrint();
395 activeBidders.
Invert(ncol,
418 mateCol2Row.Set(successfullBids);
433 mateRow2Col.Set(successfullBidders);
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
std::shared_ptr< CommGrid > getcommgrid() const
static VertexType multiply(const double &arg1, const VertexType &arg2)
Compute the maximum of two values.
void auction(PSpMat_s32p64 &A, FullyDistVec< int64_t, int64_t > &mateRow2Col, FullyDistVec< int64_t, int64_t > &mateCol2Row)
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
SpParMat< int64_t, int64_t, SpDCCols< int64_t, int64_t > > PSpMat_Int64
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
void removeIsolated(PSpMat_Bool &A)
FullyDistSpVec< IT, NT > Invert(IT globallen)
bool isMaximalmatching(PSpMat_Int64 &A, FullyDistVec< IT, NT > &mateRow2Col, FullyDistVec< IT, NT > &mateCol2Row, FullyDistSpVec< int64_t, int64_t > unmatchedRow, FullyDistSpVec< int64_t, int64_t > unmatchedCol)
SpParMat< int64_t, bool, SpDCCols< int64_t, bool > > PSpMat_Bool
friend ostream & operator<<(ostream &os, const VertexType &vertex)
void iota(IT globalsize, NT first)
void maximumMatching(PSpMat_s32p64 &Aeff, FullyDistVec< int64_t, int64_t > &mateRow2Col, FullyDistVec< int64_t, int64_t > &mateCol2Row)
int main(int argc, char *argv[])
VertexType(int64_t oi=-1, double p=0, double smp=-9999999)
const VertexType operator()(const VertexType &x, const VertexType &y) const
friend bool operator<(const VertexType &vtx1, const VertexType &vtx2)
static void axpy(const double a, const VertexType &x, VertexType &y)
void ApplyInd(_BinaryOperation __binary_op)
static VertexType add(const VertexType &arg1, const VertexType &arg2)
SpParMat< int64_t, bool, SpDCCols< int32_t, bool > > PSpMat_s32p64
void Symmetricize(PARMAT &A)
SpDCCols< IT, NT > * multiply(SpDCCols< IT, NT > &splitA, SpDCCols< IT, NT > &splitB, CCGrid &CMG, bool isBT, bool threaded)
static bool returnedSAID()
void Apply(_UnaryOperation __unary_op)
void ParallelReadMM(const std::string &filename, bool onebased, _BinaryOperation BinOp)
SpParMat< int64_t, float, SpDCCols< int64_t, float > > PSpMat_float