COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
PermuteVector.cpp
Go to the documentation of this file.
1#include <mpi.h>
2#include <sys/time.h>
3#include <iostream>
4#include <functional>
5#include <algorithm>
6#include <vector>
7#include <sstream>
8#include "../CombBLAS.h"
9
10using namespace std;
11
12
13int main(int argc, char* argv[])
14{
15 int nprocs, myrank;
16 MPI_Init(&argc, &argv);
17 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
18 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
19
20 if(argc < 2)
21 {
22 if(myrank == 0)
23 {
24 cout << "Usage: ./PermuteVectors <VectorOne> <VectorTwo> ... (as many vectors as needed)\n" << endl;
25 cout << "Permutes all the vector inputs with the same random order\n" << endl;
26 }
27 MPI_Finalize();
28 return -1;
29 }
30 {
31 bool randpermed = false;
32 FullyDistVec<int,int> randperm;
33 for(int i=1; i < argc; ++i)
34 {
35 string vecname(argv[i]);
36 ifstream inputvec(vecname.c_str());
37
38 if(myrank == 0)
39 {
40 if(inputvec.fail())
41 {
42 cout << "One of the input vector files do not exist, aborting" << endl;
43 MPI_Abort(MPI_COMM_WORLD, NOFILE);
44 return -1;
45 }
46 }
47 FullyDistVec<int,int> vec;
48 vec.ReadDistribute(inputvec, 0);
49
50 if(!randpermed)
51 {
52 randperm.iota(vec.TotalLength(), 0);
53 randperm.RandPerm(); // can't we seed this (to avoid indexing and iota generation?)
54 randpermed = true;
55 }
56
57 inputvec.clear();
58 inputvec.close();
59 }
60 }
61 MPI_Finalize();
62 return 0;
63}
int main()
Definition Driver.cpp:12
int nprocs
Definition comms.cpp:55
#define NOFILE
Definition SpDefs.h:75