COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
SpGEMM3D.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 <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#include "CombBLAS/CommGrid3D.h"
38#include "CombBLAS/SpParMat3D.h"
39#include "CombBLAS/ParFriends.h"
40
41using namespace std;
42using namespace combblas;
43
44#define EPS 0.0001
45
46#ifdef _OPENMP
48#else
50#endif
51
52
53// Simple helper class for declarations: Just the numerical type is templated
54// The index type and the sequential matrix type stays the same for the whole code
55// In this case, they are "int" and "SpDCCols"
56template <class NT>
57class PSpMat
58{
59public:
62};
63
64int main(int argc, char* argv[])
65{
66 int nprocs, myrank;
67 MPI_Init(&argc, &argv);
70
71 if(argc < 2){
72 if(myrank == 0)
73 {
74 cout << "Usage: ./<Binary> <MatrixA> " << endl;
75 }
77 return -1;
78 }
79 else {
80 double vm_usage, resident_set;
81 string Aname(argv[1]);
82 if(myrank == 0){
83 fprintf(stderr, "Data: %s\n", argv[1]);
84 }
86 fullWorld.reset( new CommGrid(MPI_COMM_WORLD, 0, 0) );
87
88 double t0, t1;
89
91
93 //t0 = MPI_Wtime();
94 //M.ParallelReadMM(Aname, true, maximum<double>());
95 //t1 = MPI_Wtime();
96 //if(myrank == 0) fprintf(stderr, "Time taken to read file: %lf\n", t1-t0);
97 //t0 = MPI_Wtime();
98 //FullyDistVec<int64_t, int64_t> p( M.getcommgrid() );
99 //FullyDistVec<int64_t, int64_t> q( M.getcommgrid() );
100 //p.iota(M.getnrow(), 0);
101 //q.iota(M.getncol(), 0);
102 //p.RandPerm();
103 //q.RandPerm();
104 //(M)(p,q,true);// in-place permute to save memory
105 //t1 = MPI_Wtime();
106 //if(myrank == 0) fprintf(stderr, "Time taken to permuatate input: %lf\n", t1-t0);
107
108 // Read labelled triple files
109 t0 = MPI_Wtime();
110 M.ReadGeneralizedTuples(Aname, maximum<double>());
111 t1 = MPI_Wtime();
112 if(myrank == 0) fprintf(stderr, "Time taken to read file: %lf\n", t1-t0);
113
115
116 // Run 2D multiplication to compare against
121 (A2D, B2D);
122
123 if(myrank == 0) fprintf(stderr, "2D Multiplication done \n");
124
125 // Increase number of layers 1 -> 4 -> 16
126 for(int layers = 1; layers <= 16; layers = layers * 4){
127 // Create two copies of input matrix which would be used in multiplication
130
131 // Convert 2D matrices to 3D
134 if(myrank == 0) fprintf(stderr, "Running 3D with %d layers\n", layers);
135
138 (A3D, B3D);
139
141 if(C2D == C3D2D){
142 if(myrank == 0) fprintf(stderr, "Correct!\n");
143 }
144 else{
145 if(myrank == 0) fprintf(stderr, "Not correct!\n");
146 }
147 }
148
149 }
150 MPI_Finalize();
151 return 0;
152}
int main()
Definition Driver.cpp:12
int cblas_splits
Definition SpGEMM3D.cpp:49
SpParMat< int64_t, NT, DCCols > MPI_DCCols
Definition SpGEMM3D.cpp:61
SpDCCols< int64_t, NT > DCCols
Definition SpGEMM3D.cpp:60
int nprocs
Definition comms.cpp:55
long int64_t
Definition compat.h:21