COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
ReduceTest.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
38using namespace std;
39using namespace combblas;
40
41// Simple helper class for declarations: Just the numerical type is templated
42// The index type and the sequential matrix type stays the same for the whole code
43// In this case, they are "int" and "SpDCCols"
44template <class NT>
45class PSpMat
46{
47public:
50};
51
52int main(int argc, char* argv[])
53{
54 int nprocs, myrank;
55 MPI_Init(&argc, &argv);
58
59 if(argc < 4)
60 {
61 if(myrank == 0)
62 {
63 cout << "Usage: ./ReduceTest <MatrixA> <SumColumns> <SumRows>" << endl;
64 cout << "<Matrix>,<SumColumns>,<SumRows> are absolute addresses, and files should be in triples format" << endl;
65 }
66 MPI_Finalize();
67 return -1;
68 }
69 {
70 string Aname(argv[1]);
71 string Bname(argv[2]);
72 string Cname(argv[3]);
73
74 ifstream inputB(Bname.c_str());
75 ifstream inputC(Cname.c_str());
77
79 fullWorld.reset( new CommGrid(MPI_COMM_WORLD, 0, 0) );
80
82 FullyDistVec<int,double> colsums(A.getcommgrid());
83 FullyDistVec<int,double> rowsums(A.getcommgrid());
84
85 A.ReadDistribute(Aname, 0);
86 colsums.ReadDistribute(inputB, 0);
87 rowsums.ReadDistribute(inputC, 0);
88
91 A.Reduce(rowsums_control, Row, std::plus<double>() , 0.0);
92 A.Reduce(colsums_control, Column, std::plus<double>() , 0.0);
93
95 {
96 SpParHelper::Print("Reduction via summation working correctly\n");
97 }
98 else
99 {
100 SpParHelper::Print("ERROR in Reduce via summation, go fix it!\n");
101 }
102
103 inputB.clear();
104 inputB.close();
105 inputC.clear();
106 inputC.close();
107 }
108 MPI_Finalize();
109 return 0;
110}
111
112
int main()
Definition Driver.cpp:12
SpParMat< int, NT, DCCols > MPI_DCCols
SpDCCols< int, NT > DCCols
static void Print(const std::string &s)
int nprocs
Definition comms.cpp:55
@ Column
Definition SpDefs.h:115
double A