7#include "CombBLAS/CombBLAS.h"
14 static IT id() {
return static_cast<IT>(0); }
16 static MPI_Op
mpi_op() {
return MPI_LOR; }
17 static IT add(
const IT& arg1,
const IT& arg2) {
return (arg1 || arg2); }
18 static IT multiply(
const IT& arg1,
const IT& arg2) {
return (arg1 && arg2); }
22template <
class IT,
class NT,
class DER>
25 std::shared_ptr<CommGrid> grid =
A.getcommgrid();
26 int myrank = grid->GetRank();
27 int myproccol = grid->GetRankInProcRow();
28 int myprocrow = grid->GetRankInProcCol();
30 MPI_Comm ColWorld = grid->GetColWorld();
32 IT total_rows =
A.getnrow();
33 IT total_cols =
A.getncol();
35 int procrows = grid->GetGridRows();
36 int proccols = grid->GetGridCols();
38 IT rows_perproc = total_rows / procrows;
39 IT cols_perproc = total_cols / proccols;
41 IT row_offset = myprocrow * rows_perproc;
42 IT col_offset = myproccol * cols_perproc;
44 DER *spSeq =
A.seqptr();
46 IT localcols = spSeq->getncol();
47 std::vector<IT> local_colidx(localcols,
static_cast<IT>(-1));
49 for (
auto colit = spSeq->begcol(); colit != spSeq->endcol(); ++colit)
51 auto nzit = spSeq->begnz(colit);
52 if (nzit != spSeq->endnz(colit))
53 local_colidx[colit.colid()] = nzit.rowid() + row_offset;
56 MPI_Allreduce(MPI_IN_PLACE, local_colidx.data(),
static_cast<int>(localcols), MPIType<IT>(), MPI_MAX, ColWorld);
58 std::vector<IT> fillarr;
61 for (
auto itr = local_colidx.begin(); itr != local_colidx.end(); ++itr)
62 fillarr.push_back(*itr);
67template <
class IT,
class NT,
class DER>
76int main(
int argc,
char *argv[])
79 MPI_Init(&argc, &argv);
80 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
81 MPI_Comm_size(MPI_COMM_WORLD, &
nprocs);
86 std::cerr <<
"Usage: ./KTipsTest <Matrix> <l>" << std::endl;
92 int l = atoi(argv[2]);
94 std::shared_ptr<CommGrid> fullWorld;
95 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0));
99 A.ParallelReadMM(std::string(argv[1]),
false,
maximum<int>());
113 for (
int k = 1; k <= l; ++k)
130 TipSources.
Set(kSources);
131 TipDests.
Set(kDests);
int main(int argc, char *argv[])
FullyDistVec< IT, IT > LastNzRowIdxPerCol(const SpParMat< IT, NT, DER > &A)
SpParMat< IT, NT, DER > FrontierMat(const SpParMat< IT, NT, DER > &A, const FullyDistSpVec< IT, IT > &sources, const NT &initval)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
FullyDistSpVec< IT, NT > Find(_Predicate pred) const
Return the elements for which pred is true.
void iota(IT globalsize, NT first)
void Set(const FullyDistSpVec< IT, NT > &rhs)
FullyDistSpVec< IT, NT > GGet(const FullyDistSpVec< IT, NT1 > &spVec, _BinaryOperationIdx __binopIdx, NT nullValue)
FullyDistVec< IT, NT > Reduce(Dim dim, _BinaryOperation __binary_op, NT id, _UnaryOperation __unary_op) const
void SetDifference(const SpParMat< IT, NT, DER > &rhs)
void PruneColumnByIndex(const FullyDistSpVec< IT, IRRELEVANT_NT > &ci)
static void axpy(IT a, const IT &x, IT &y)
static bool returnedSAID()
static IT add(const IT &arg1, const IT &arg2)
static IT multiply(const IT &arg1, const IT &arg2)
Compute the maximum of two values.