HavoqGT
vertex_iterator.hpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright (c) 2013, Lawrence Livermore National Security, LLC.
4  * Produced at the Lawrence Livermore National Laboratory.
5  * Re-written by Steven Feldman <feldman12@llnl.gov>.
6  * LLNL-CODE-644630.
7  * All rights reserved.
8  *
9  * This file is part of HavoqGT, Version 0.1.
10  * For details, see https://computation.llnl.gov/casc/dcca-pub/dcca/Downloads.html
11  *
12  * Please also read this link – Our Notice and GNU Lesser General Public License.
13  * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
14  *
15  * This program is free software; you can redistribute it and/or modify it under
16  * the terms of the GNU Lesser General Public License (as published by the Free
17  * Software Foundation) version 2.1 dated February 1999.
18  *
19  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
20  * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A
21  * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public
22  * License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License along
25  * with this program; if not, write to the Free Software Foundation, Inc.,
26  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  * OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
29  *
30  * Our Preamble Notice
31  *
32  * A. This notice is required to be provided under our contract with the
33  * U.S. Department of Energy (DOE). This work was produced at the Lawrence
34  * Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
35  *
36  * B. Neither the United States Government nor Lawrence Livermore National
37  * Security, LLC nor any of their employees, makes any warranty, express or
38  * implied, or assumes any liability or responsibility for the accuracy,
39  * completeness, or usefulness of any information, apparatus, product, or process
40  * disclosed, or represents that its use would not infringe privately-owned rights.
41  *
42  * C. Also, reference herein to any specific commercial products, process, or
43  * services by trade name, trademark, manufacturer or otherwise does not
44  * necessarily constitute or imply its endorsement, recommendation, or favoring by
45  * the United States Government or Lawrence Livermore National Security, LLC. The
46  * views and opinions of authors expressed herein do not necessarily state or
47  * reflect those of the United States Government or Lawrence Livermore National
48  * Security, LLC, and shall not be used for advertising or product endorsement
49  * purposes.
50  *
51  */
52 
53 #ifndef HAVOQGT_MPI_IMPL_VERTEX_ITERATOR_HPP_
54 #define HAVOQGT_MPI_IMPL_VERTEX_ITERATOR_HPP_
55 
57 
58 namespace havoqgt {
59 namespace mpi {
60 
61 template <typename SegementManager>
63  : public std::iterator<std::input_iterator_tag, vertex_locator, ptrdiff_t,
64  const vertex_locator* const, const vertex_locator&> {
65  public:
67  : m_ptr_graph(NULL) {};
68  vertex_iterator& operator++();
69  vertex_iterator operator++(int);
70 
71  bool is_equal(const vertex_iterator& x) const;
72 
73  friend bool operator==(const vertex_iterator& x,
74  const vertex_iterator& y) { return x.is_equal(y); }
75 
76  friend bool operator!=(const vertex_iterator& x,
77  const vertex_iterator& y) { return !(x.is_equal(y)); }
78 
79 
80  const vertex_locator& operator*() const { return m_locator; }
81  const vertex_locator* const operator->() const { return &m_locator; }
82 
83  private:
85 
86  vertex_iterator(uint64_t index, const delegate_partitioned_graph* pgraph);
87  void update_locator();
88 
92 };
93 
94 
95 
97 // Vertex Iterator //
99 
100 template <typename SegmentManager>
101 inline
103 vertex_iterator(uint64_t index, const delegate_partitioned_graph<SegmentManager>* pgraph)
104  : m_ptr_graph(pgraph)
105  , m_owned_vert_index(index) {
106  update_locator();
107 }
108 
109 template <typename SegmentManager>
110 inline
113  ++m_owned_vert_index;
114  update_locator();
115  return *this;
116 }
117 
118 template <typename SegmentManager>
119 inline
122  vertex_iterator to_return = *this;
123  ++m_owned_vert_index;
124  update_locator();
125  return to_return;
126 }
127 
128 template <typename SegmentManager>
129 inline bool
132  assert(m_ptr_graph == x.m_ptr_graph);
133  return m_owned_vert_index == x.m_owned_vert_index;
134 }
135 
136 template <typename SegmentManager>
137 inline bool
140  return x.is_equal(y);
141 
142 }
143 
144 template <typename SegmentManager>
145 inline bool
148  return !(x.is_equal(y));
149 }
150 
151 template <typename SegmentManager>
152 inline void
155  for(; m_owned_vert_index < m_ptr_graph->m_owned_info.size()
156  && m_ptr_graph->m_owned_info[m_owned_vert_index].is_delegate == true;
157  ++ m_owned_vert_index);
158  if(m_owned_vert_index < m_ptr_graph->m_owned_info.size()) {
159  assert(m_ptr_graph->m_owned_info[m_owned_vert_index].is_delegate == false);
160  uint32_t owner = m_ptr_graph->m_mpi_rank;
161  m_locator = vertex_locator(false, m_owned_vert_index, owner);
162  }
163 }
164 
165 } // mpi
166 } // namespace havoqgt
167 #endif // HAVOQGT_MPI_IMPL_VERTEX_ITERATOR_HPP_
bool operator!=(delegate_partitioned_graph< SegementManager > &other)
friend bool operator!=(const vertex_iterator &x, const vertex_iterator &y)
friend bool operator==(const vertex_iterator &x, const vertex_iterator &y)
bip::vector< vert_info, SegmentAllocator< vert_info > > m_owned_info
bool operator==(delegate_partitioned_graph< SegementManager > &other)