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: ./IndexingTest <BASEADDRESS> <Matrix> <IndexedMatrix> <VectorOne> <VectorTwo>" << endl;
72 cout <<
"Example: ./IndexingTest ../mfiles B_100x100.txt B_10x30_Indexed.txt rand10outta100.txt rand30outta100.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 indexdname(argv[3]);
82 string vec1name(argv[4]);
83 string vec2name(argv[5]);
84 normalname = directory+
"/"+normalname;
85 indexdname = directory+
"/"+indexdname;
86 vec1name = directory+
"/"+vec1name;
87 vec2name = directory+
"/"+vec2name;
89 ifstream inputvec1(vec1name.c_str());
90 ifstream inputvec2(vec2name.c_str());
94 if(inputvec1.fail() || inputvec2.fail())
96 cout <<
"One of the input vector files do not exist, aborting" << endl;
97 MPI_Abort(MPI_COMM_WORLD,
NOFILE);
101 MPI_Barrier(MPI_COMM_WORLD);
103 shared_ptr<CommGrid> fullWorld;
104 fullWorld.reset(
new CommGrid(MPI_COMM_WORLD, 0, 0) );
106 PARDBMAT
A(fullWorld);
107 PARDBMAT AID(fullWorld);
108 PARDBMAT ACID(fullWorld);
112 A.ReadDistribute(normalname, 0);
113 AID.ReadDistribute(indexdname, 0);
117 vec1.
Apply(bind2nd(minus<int>(), 1));
118 vec2.
Apply(bind2nd(minus<int>(), 1));
119 ACID =
A(vec1, vec2);
123 SpParHelper::Print(
"Indexing working correctly\n");
127 SpParHelper::Print(
"ERROR in indexing, go fix it!\n");
133 A.Find(crow, ccol, cval);
138 ptopk =
TopK(sval, 3);
145 p.
iota(A.getnrow(), 0);
146 q.
iota(A.getncol(), 0);
154 float oldbalance = A.LoadImbalance();
155 float newbalance = B.LoadImbalance();
157 outs <<
"Old balance: " << oldbalance << endl;
158 outs <<
"New balance: " << newbalance << endl;
159 SpParHelper::Print(outs.str());
160 SpParHelper::Print(outs.str());
166 SpParHelper::Print(
"Sorts are done\n");
167 PARDBMAT
C =
B(pinv,qinv);
170 SpParHelper::Print(
"Double permutation successfully restored the original\n");
174 SpParHelper::Print(
"Error in permutation\n");
int main(int argc, char *argv[])
pair< FullyDistVec< IT, IT >, FullyDistVec< IT, NT > > TopK(FullyDistSpVec< IT, NT > &v, IT k)
std::shared_ptr< CommGrid > getcommgrid() const
void iota(IT globalsize, NT first)
FullyDistVec< IT, IT > sort()
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)