41 template <
typename IT,
typename NT>
48 sel.
iota(k, v.TotalLength() - k);
56 return make_pair(topkind, topkele);
60 int main(
int argc,
char* argv[])
63 MPI_Init(&argc, &argv);
64 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
65 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
71 cout <<
"Usage: ./SpAsgnTest <BASEADDRESS> <Matrix> <PrunedMatrix> <RHSMatrix> <AssignedMatrix> <VectorRowIndices> <VectorColIndices>" << endl;
72 cout <<
"Example: ./SpAsgnTest ../mfiles A_100x100.txt A_with20x30hole.txt dense_20x30matrix.txt A_wdenseblocks.txt 20outta100.txt 30outta100.txt" << endl;
73 cout <<
"Input files should be under <BASEADDRESS> in tuples format" << endl;
79 string directory(argv[1]);
80 string normalname(argv[2]);
81 string prunedname(argv[3]);
82 string rhsmatname(argv[4]);
83 string assignname(argv[5]);
84 string vec1name(argv[6]);
85 string vec2name(argv[7]);
86 normalname = directory+
"/"+normalname;
87 prunedname = directory+
"/"+prunedname;
88 rhsmatname = directory+
"/"+rhsmatname;
89 assignname = directory+
"/"+assignname;
90 vec1name = directory+
"/"+vec1name;
91 vec2name = directory+
"/"+vec2name;
93 ifstream inputvec1(vec1name.c_str());
94 ifstream inputvec2(vec2name.c_str());
98 if(inputvec1.fail() || inputvec2.fail())
100 cout <<
"One of the input vector files do not exist, aborting" << endl;
101 MPI_Abort(MPI_COMM_WORLD,
NOFILE);
105 MPI_Barrier(MPI_COMM_WORLD);
107 shared_ptr<CommGrid> fullWorld;
108 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0) );
110 PARDBMAT
A(fullWorld);
111 PARDBMAT Apr(fullWorld);
112 PARDBMAT
B(fullWorld);
113 PARDBMAT
C(fullWorld);
117 A.ReadDistribute(normalname, 0);
118 Apr.ReadDistribute(prunedname, 0);
119 B.ReadDistribute(rhsmatname, 0);
120 C.ReadDistribute(assignname, 0);
124 vec1.
Apply(bind2nd(minus<int>(), 1));
125 vec2.
Apply(bind2nd(minus<int>(), 1));
128 Atemp.Prune(vec1, vec2);
133 SpParHelper::Print(
"Pruning is working\n");
137 SpParHelper::Print(
"Error in pruning, go fix it\n");
140 A.SpAsgn(vec1, vec2, B);
143 SpParHelper::Print(
"SpAsgn working correctly\n");
147 SpParHelper::Print(
"ERROR in SpAsgn, go fix it!\n");
148 A.SaveGathered(
"Erroneous_SpAsgnd.txt");
154 A.Find(crow, ccol, cval);
159 ptopk =
TopK(sval, 3);
std::shared_ptr< CommGrid > getcommgrid() const
pair< FullyDistVec< IT, IT >, FullyDistVec< IT, NT > > TopK(FullyDistSpVec< IT, NT > &v, IT k)
void iota(IT globalsize, NT first)
int main(int argc, char *argv[])
void Apply(_UnaryOperation __unary_op)
std::ifstream & ReadDistribute(std::ifstream &infile, int master, HANDLER handler)
FullyDistSpVec< IT, IT > sort()
sort the vector itself, return the permutation vector (0-based)