36#include "CombBLAS/CombBLAS.h"
41template <
typename IT,
typename NT>
48 sel.
iota(k, v.TotalLength() - k);
56 return make_pair(topkind, topkele);
63 val = make_pair(rhs, -rhs);
67 val = make_pair(1,-1);
69 pair<double, double>
val;
73int main(
int argc,
char* argv[])
76 MPI_Init(&argc, &argv);
77 MPI_Comm_size(MPI_COMM_WORLD,&
nprocs);
78 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
84 cout <<
"Usage: ./SpAsgnTest <BASEADDRESS> <Matrix> <PrunedMatrix> <RHSMatrix> <AssignedMatrix> <VectorRowIndices> <VectorColIndices>" << endl;
85 cout <<
"Example: ./SpAsgnTest TESTDATA/ A_100x100.txt A_with20x30hole.txt dense_20x30matrix.txt A_wdenseblocks.txt 20outta100.txt 30outta100.txt" << endl;
86 cout <<
"Input files should be under <BASEADDRESS> in triples format" << endl;
92 string directory(argv[1]);
93 string normalname(argv[2]);
94 string prunedname(argv[3]);
95 string rhsmatname(argv[4]);
96 string assignname(argv[5]);
97 string vec1name(argv[6]);
98 string vec2name(argv[7]);
99 normalname = directory+
"/"+normalname;
100 prunedname = directory+
"/"+prunedname;
101 rhsmatname = directory+
"/"+rhsmatname;
102 assignname = directory+
"/"+assignname;
103 vec1name = directory+
"/"+vec1name;
104 vec2name = directory+
"/"+vec2name;
106 ifstream inputvec1(vec1name.c_str());
107 ifstream inputvec2(vec2name.c_str());
111 if(inputvec1.fail() || inputvec2.fail())
113 cout <<
"One of the input vector files do not exist, aborting" << endl;
114 MPI_Abort(MPI_COMM_WORLD,
NOFILE);
118 MPI_Barrier(MPI_COMM_WORLD);
121 shared_ptr<CommGrid> fullWorld;
122 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0) );
124 PARDBMAT
A(fullWorld);
125 PARDBMAT Apr(fullWorld);
126 PARDBMAT
B(fullWorld);
127 PARDBMAT
C(fullWorld);
131 A.ReadDistribute(normalname, 0);
132 Apr.ReadDistribute(prunedname, 0);
133 B.ReadDistribute(rhsmatname, 0);
134 C.ReadDistribute(assignname, 0);
138 vec1.
Apply(bind2nd(minus<int64_t>(), 1));
139 vec2.
Apply(bind2nd(minus<int64_t>(), 1));
142 Atemp.Prune(vec1, vec2);
144 PARPAIRMAT Apair =
A;
145 Apair.Prune(vec1, vec2);
147 PARDBMAT Apruned =
A;
148 Apruned.PruneFull(vec1, vec2);
149 Apruned.ParallelWriteMM(
"ArowscolsPruned.mtx",
true);
154 SpParHelper::Print(
"Pruning is working\n");
158 SpParHelper::Print(
"Error in pruning, go fix it\n");
161 A.SpAsgn(vec1, vec2,
B);
164 SpParHelper::Print(
"SpAsgn working correctly\n");
168 SpParHelper::Print(
"ERROR in SpAsgn, go fix it!\n");
169 A.SaveGathered(
"Erroneous_SpAsgnd.txt");
175 A.Find(crow, ccol, cval);
pair< FullyDistVec< IT, IT >, FullyDistVec< IT, NT > > TopK(FullyDistSpVec< IT, NT > &v, IT k)
int main(int argc, char *argv[])
FullyDistSpVec< IT, IT > sort()
sort the vector itself, return the permutation vector (0-based)
std::shared_ptr< CommGrid > getcommgrid() const
std::ifstream & ReadDistribute(std::ifstream &infile, int master, HANDLER handler)
void iota(IT globalsize, NT first)
void Apply(_UnaryOperation __unary_op)
pair< double, double > val