HavoqGT
run_triangle_count.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Lawrence Livermore National Security, LLC.
3  * Produced at the Lawrence Livermore National Laboratory.
4  * Written by Roger Pearce <rpearce@llnl.gov>.
5  * LLNL-CODE-644630.
6  * All rights reserved.
7  *
8  * This file is part of HavoqGT, Version 0.1.
9  * For details, see https://computation.llnl.gov/casc/dcca-pub/dcca/Downloads.html
10  *
11  * Please also read this link – Our Notice and GNU Lesser General Public License.
12  * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License (as published by the Free
16  * Software Foundation) version 2.1 dated February 1999.
17  *
18  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A
20  * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License along
24  * with this program; if not, write to the Free Software Foundation, Inc.,
25  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  * OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
28  *
29  * Our Preamble Notice
30  *
31  * A. This notice is required to be provided under our contract with the
32  * U.S. Department of Energy (DOE). This work was produced at the Lawrence
33  * Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
34  *
35  * B. Neither the United States Government nor Lawrence Livermore National
36  * Security, LLC nor any of their employees, makes any warranty, express or
37  * implied, or assumes any liability or responsibility for the accuracy,
38  * completeness, or usefulness of any information, apparatus, product, or process
39  * disclosed, or represents that its use would not infringe privately-owned rights.
40  *
41  * C. Also, reference herein to any specific commercial products, process, or
42  * services by trade name, trademark, manufacturer or otherwise does not
43  * necessarily constitute or imply its endorsement, recommendation, or favoring by
44  * the United States Government or Lawrence Livermore National Security, LLC. The
45  * views and opinions of authors expressed herein do not necessarily state or
46  * reflect those of the United States Government or Lawrence Livermore National
47  * Security, LLC, and shall not be used for advertising or product endorsement
48  * purposes.
49  *
50  */
51 
52 #include <havoqgt/page_rank.hpp>
53 #include <havoqgt/environment.hpp>
60 
61 #include <boost/bind.hpp>
62 #include <boost/function.hpp>
63 
65 #include <assert.h>
66 
67 #include <deque>
68 #include <string>
69 #include <utility>
70 #include <algorithm>
71 #include <functional>
72 
73 #include <boost/interprocess/managed_heap_memory.hpp>
74 
75 namespace hmpi = havoqgt::mpi;
76 using namespace havoqgt::mpi;
77 
78 int main(int argc, char** argv) {
81 
82  int mpi_rank(0), mpi_size(0);
83 
84  havoqgt::havoqgt_init(&argc, &argv);
85  {
86  CHK_MPI(MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank));
87  CHK_MPI(MPI_Comm_size(MPI_COMM_WORLD, &mpi_size));
89 
90  if (mpi_rank == 0) {
91  std::cout << "MPI initialized with " << mpi_size << " ranks." << std::endl;
92  std::cout << "CMD line:";
93  for (int i = 0; i < argc; ++i) {
94  std::cout << " " << argv[i];
95  }
96  std::cout << std::endl;
98  //print_system_info(false);
99  }
100  MPI_Barrier(MPI_COMM_WORLD);
101 
102 
103  std::string graph_input;
104 
105  if (argc < 2) {
106  std::cerr << "usage: <graph input file name>"
107  << " (argc:" << argc << " )." << std::endl;
108  exit(-1);
109  } else {
110  int pos = 1;
111  graph_input = argv[pos++];
112  }
113 
114 
115  MPI_Barrier(MPI_COMM_WORLD);
116 
117  havoqgt::distributed_db ddb(havoqgt::db_open(), graph_input.c_str());
118 
119  graph_type *graph = ddb.get_segment_manager()->
120  find<graph_type>("graph_obj").first;
121  assert(graph != nullptr);
122 
123  MPI_Barrier(MPI_COMM_WORLD);
124  if (mpi_rank == 0) {
125  std::cout << "Graph Loaded Ready." << std::endl;
126  }
127  //graph->print_graph_statistics();
128  MPI_Barrier(MPI_COMM_WORLD);
129 
130  for(int i=0; i<100; ++i) {
131  uint64_t count = triangle_count(*graph, graph->label_to_locator(i));
132  if(mpi_rank == 0) {
133  std::cout << "Vertex " << i << " has " << count << " triangles." << std::endl;
134  }
135  }
136 
137  } // END Main MPI
139 
140  return 0;
141 }
hmpi::delegate_partitioned_graph< segment_manager_t > graph_type
void havoqgt_finalize()
mapped_type::segment_manager segment_manager_type
segment_manager_type * get_segment_manager()
old_environment & get_environment()
uint64_t triangle_count(TGraph &g, typename TGraph::vertex_locator s)
#define CHK_MPI(a)
Definition: mpi.hpp:68
int main(int argc, char **argv)
havoqgt::distributed_db::segment_manager_type segment_manager_t
void havoqgt_init(int *argc, char ***argv)