COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
ParIOTest.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
15// Simple helper class for declarations: Just the numerical type is templated
16// The index type and the sequential matrix type stays the same for the whole code
17// In this case, they are "int" and "SpDCCols"
18template <class NT>
19class PSpMat
20{
21public:
24};
25
27{
28public:
30
31 template <typename c, typename t>
32 array<char,MAXVERTNAME> read(std::basic_istream<c,t>& is, int64_t index)
33 {
35 string str;
36 is >> str; // read into str
37 std::copy( str.begin(), str.end(), strarray.begin() );
38 if(str.length() < MAXVERTNAME) strarray[str.length()] = '\0'; // null terminating char
39
40 return strarray;
41 }
42
43 template <typename c, typename t>
44 void save(std::basic_ostream<c,t>& os, const array<char,MAXVERTNAME>& strarray, int64_t index)
45 {
46 auto locnull = find(strarray.begin(), strarray.end(), '\0');
47 string str(strarray.begin(), locnull);
48 os << str;
49 }
50};
51
52
53int main(int argc, char* argv[])
54{
55 int nprocs, myrank;
56 MPI_Init(&argc, &argv);
59
60 if(argc < 3)
61 {
62 if(myrank == 0)
63 {
64 cout << "Usage: ./ParIOTest <MatrixA> <MatrixB_general>" << endl;
65 cout << "<MatrixA> is an absolute address, and file should be in Matrix Market format" << endl;
66 cout << "<MatrixB_general> is an absolute address, file is in general triples format (MCL calls this label input)" << endl;
67
68 }
69 MPI_Finalize();
70 return -1;
71 }
72 {
73 string Aname(argv[1]);
74 string Bname(argv[2]);
75
77
78 A.ParallelReadMM(Aname, true, maximum<double>());
80
81
82 if (A == B)
83 {
84 SpParHelper::Print("Parallel Matrix Market I/O working correctly\n");
85 }
86 else
87 {
88 SpParHelper::Print("ERROR in Parallel Matrix Market I/O");
89 A.ParallelWriteMM("A_Error.mtx", true);
90 B.ParallelWriteMM("B_Error.mtx", true);
91 }
92
93 perm.ParallelWrite("PermutationVec.mtx", 1, StdArrayReadSaveHandler(), true);
94 }
96 return 0;
97}
98
int main()
Definition Driver.cpp:12
Definition test.cpp:53
SpParMat< int64_t, NT, DCCols > MPI_DCCols
Definition ParIOTest.cpp:23
SpDCCols< int64_t, NT > DCCols
Definition ParIOTest.cpp:22
array< char, MAXVERTNAME > getNoNum(int64_t index)
Definition ParIOTest.cpp:29
array< char, MAXVERTNAME > read(std::basic_istream< c, t > &is, int64_t index)
Definition ParIOTest.cpp:32
void save(std::basic_ostream< c, t > &os, const array< char, MAXVERTNAME > &strarray, int64_t index)
Definition ParIOTest.cpp:44
static void Print(const std::string &s)
int nprocs
Definition comms.cpp:55
#define MAXVERTNAME
Definition SpDefs.h:68
double A