COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
GenWriteMatrix.cpp
Go to the documentation of this file.
1/****************************************************************/
2/* Parallel Combinatorial BLAS Library (for Graph Computations) */
3/* version 1.6 -------------------------------------------------*/
4/* date: 6/15/2017 ---------------------------------------------*/
5/* authors: Ariful Azad, Aydin Buluc --------------------------*/
6/****************************************************************/
7/*
8 Copyright (c) 2010-2017, The Regents of the University of California
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 */
28
29#include "CombBLAS/CombBLAS.h"
30#include <mpi.h>
31#include <sys/time.h>
32#include <iostream>
33#include <functional>
34#include <algorithm>
35#include <vector>
36#include <string>
37#include <sstream>
38
39using namespace std;
40using namespace combblas;
41
42
43template <class T>
44bool from_string(T & t, const string& s, std::ios_base& (*f)(std::ios_base&))
45{
47 return !(iss >> f >> t).fail();
48}
49
50
51template <typename PARMAT>
53{
54 // boolean addition is practically a "logical or"
55 // therefore this doesn't destruct any links
56 PARMAT AT = A;
57 AT.Transpose();
58 A += AT;
59}
60
61
62int main(int argc, char* argv[])
63{
64 int nprocs, myrank;
65#ifdef _OPENMP
66 int provided, flag, claimed;
69 if (!flag)
70 SpParHelper::Print("This thread called init_thread but Is_thread_main gave false\n");
72 if (claimed != provided)
73 SpParHelper::Print("Query thread gave different thread level than requested\n");
74#else
75 MPI_Init(&argc, &argv);
76#endif
77
80 if(argc < 4)
81 {
82 if(myrank == 0)
83 {
84 cout << "Usage: ./genwritemat <Scale> <Edgefactor> <Symmetricize> <outputname>" << endl;
85 cout << "Example: ./genwritemat 25 16 1 scale25_ef16_symmetric.mtx" << endl;
86 }
88 return -1;
89 }
90 {
91 unsigned scale = static_cast<unsigned>(atoi(argv[1]));
92 unsigned edgefactor = static_cast<unsigned>(atoi(argv[2]));
93 int symmetric = static_cast<unsigned>(atoi(argv[3]));
94
95
96 double initiator[4] = {.57, .19, .19, .05};
97
98 double t01 = MPI_Wtime();
99 double t02;
101 DEL->GenGraph500Data(initiator, scale, edgefactor, true, true ); // generate packed edges
102 SpParHelper::Print("Generated renamed edge lists\n");
103 t02 = MPI_Wtime();
105 tinfo << "Generation took " << t02-t01 << " seconds" << endl;
107
108
109 typedef SpParMat < int64_t, int, SpDCCols<int32_t,int> > PSpMat_s32p64_Int; // use 32-bits for local matrices, but parallel semantics are 64-bits
110 PSpMat_s32p64_Int G(*DEL, false); // conversion from distributed edge list, keeps self-loops, sums duplicates
111 delete DEL; // free memory before symmetricizing
112 SpParHelper::Print("Created Sparse Matrix (with int32 local indices and values)\n");
113
114 int64_t removed = G.RemoveLoops();
116 loopinfo << "Removed " << removed << " loops" << endl;
118 G.PrintInfo();
119
120 if(symmetric)
121 {
123 SpParHelper::Print("Symmetricized\n");
124 }
125
126 float balance = G.LoadImbalance();
128 outs << "Load balance: " << balance << endl;
130
131 G.ParallelWriteMM(string(argv[4]), true); // write one-based
132 }
133 MPI_Finalize();
134 return 0;
135}
136
int main()
Definition Driver.cpp:12
bool from_string(T &t, const string &s, std::ios_base &(*f)(std::ios_base &))
SpParMat< int64_t, int, SpDCCols< int32_t, int > > PSpMat_s32p64_Int
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
static void Print(const std::string &s)
int nprocs
Definition comms.cpp:55
void Symmetricize(PARMAT &A)
Definition ReadMatDist.h:29
double A
int64_t edgefactor