COMBINATORIAL_BLAS  1.6
SplitMergeTest.cpp
Go to the documentation of this file.
1 /****************************************************************/
2 /* Parallel Combinatorial BLAS Library (for Graph Computations) */
3 /* version 1.6 -------------------------------------------------*/
4 /* date: 11/15/2016 --------------------------------------------*/
5 /* authors: Ariful Azad, Aydin Buluc, Adam Lugowski ------------*/
6 /****************************************************************/
7 /*
8  Copyright (c) 2010-2016, 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 <mpi.h>
30 #include <sys/time.h>
31 #include <iostream>
32 #include <functional>
33 #include <algorithm>
34 #include <vector>
35 #include <sstream>
36 #include "CombBLAS/CombBLAS.h"
37 
38 using namespace std;
39 using namespace combblas;
40 #define NSPLITS 5
41 
42 int main(int argc, char* argv[])
43 {
44  int nprocs, myrank;
45  MPI_Init(&argc, &argv);
46  MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
47  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
48 
49  {
51 
52  double initiator[4] = {.57, .19, .19, .05};
54  DEL->GenGraph500Data(initiator, 12, 8, true, true ); // generate packed edges
55  SpParHelper::Print("Generated renamed edge lists\n");
56 
57  // conversion from distributed edge list, keeps self-loops, sums duplicates
58  PSpMat_s32p64_Int G(*DEL, false);
59  delete DEL; // free memory before symmetricizing
60  SpParHelper::Print("Created Sparse Matrix (with int32 local indices and values)\n");
61 
62  SpDCCols<int32_t,int> G_perproc = G.seq();
63  G_perproc.PrintInfo();
64 
65  SpDCCols<int32_t,int> G_perproc_copy = G_perproc;
66  vector< SpDCCols<int32_t,int> > splits(NSPLITS);
67  G_perproc.ColSplit(NSPLITS, splits);
68 
69  SpDCCols<int32_t,int> G_perproc_reconstructed;
70  G_perproc_reconstructed.ColConcatenate(splits);
71 
72  G_perproc_reconstructed.PrintInfo();
73 
74  if(G_perproc_copy == G_perproc_reconstructed)
75  {
76  cout << "ColSplit/ColConcatenate works" << endl;
77  }
78  else
79  {
80  cout << "ERROR" << endl;
81  }
82  }
83  MPI_Finalize();
84  return 0;
85 }
int main(int argc, char *argv[])
#define NSPLITS
void GenGraph500Data(double initiator[4], int log_numverts, int edgefactor, bool scramble=false, bool packed=false)
SpParMat< int64_t, int, SpDCCols< int32_t, int > > PSpMat_s32p64_Int
Definition: SpMSpVBench.cpp:62
void ColConcatenate(std::vector< SpDCCols< IT, NT > > &matrices)
Definition: SpDCCols.cpp:939
void ColSplit(int parts, std::vector< SpDCCols< IT, NT > > &matrices)
Definition: SpDCCols.cpp:897
Definition: CCGrid.h:4
void PrintInfo() const
Definition: SpDCCols.cpp:1235