COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
Mtx2Bin.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/CombBLAS.h"
9
10using namespace std;
11using namespace combblas;
12
13
14
15int main(int argc, char* argv[])
16{
17 int nprocs, myrank;
18 MPI_Init(&argc, &argv);
21
22 if(argc < 4)
23 {
24 if(myrank == 0)
25 {
26 cout << "Usage: ./ReadWriteMtx <InputMTX> <OutputBinary> <0|1> <permute>" << endl;
27 cout << "<InputMTX> can have reverse edges missing or with different values, but the reader will choose the edge with maximum value when that happens (common in dna/protein sequence search)" << endl;
28 cout << "<OutputBinary> is just the name of the output after such incompatibilities in MTX file are removed and all bidirectional edges now have the same value" << endl;
29 cout << "<0|1>: zero or one indexed (for inputs)" << endl;
30 cout << "<permute> randomly permute the matrix (default: 0 - meaning false)" << endl;
31
32 }
34 return -1;
35 }
36 {
37 string Aname(argv[1]);
38 string Bname(argv[2]);
39 bool permute = 0;
40 bool index = static_cast<bool>(atoi(argv[3]));
41
42 if(myrank ==0)
43 {
44 cout << "Reading file " << Aname << " that is " << index << " indexed" << endl;
45 }
46 if(argc == 5)
47 {
48 permute = static_cast<bool>(atoi(argv[4]));
49 if(myrank == 0)
50 {
51 if(permute)
52 cout << "Randomly permuting" << endl;
53 }
54 }
55
56
58
59 A.ParallelReadMM(Aname, index, maximum<double>());
60 if(permute)
61 {
62 FullyDistVec<int64_t,int64_t> perm; // get a different permutation
63 perm.iota(A.getnrow(), 0);
64 perm.RandPerm();
65 A(perm, perm, true); // in-place permute to save memory
66 }
67 A.PrintInfo();
68
69 A.ParallelBinaryWrite(Bname);
70
71 if(myrank == 0)
72 {
73 cout << "Now, reading the file back again in binary format..." << endl;
74 }
76 B.ReadDistribute (Bname, 0, false, true);
77 B.PrintInfo();
78 }
80 return 0;
81}
82
int main()
Definition Driver.cpp:12
Definition test.cpp:53
int nprocs
Definition comms.cpp:55
double A