HavoqGT
edge_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_EDGE_ITERATOR_HPP_
54 #define HAVOQGT_MPI_IMPL_EDGE_ITERATOR_HPP_
55 
57 
58 namespace havoqgt {
59 namespace mpi {
60 
61 template <typename SegementManager>
62 class delegate_partitioned_graph<SegementManager>::edge_iterator {
63  public:
65  : m_ptr_graph(NULL) {};
66 
67  edge_iterator& operator++();
68  edge_iterator operator++(int);
69 
70  bool is_equal(const edge_iterator& x) const;
71 
72  friend bool operator==(const edge_iterator& x,
73  const edge_iterator& y) {return x.is_equal(y); }
74 
75  friend bool operator!=(const edge_iterator& x,
76  const edge_iterator& y) {return !(x.is_equal(y)); }
77 
78  vertex_locator source() const { return m_source; }
79  vertex_locator target() const;
80 
81  protected:
83  template <typename T1, typename T2> friend class edge_data;
84  edge_iterator(vertex_locator source, uint64_t edge_offset,
85  const delegate_partitioned_graph* const pgraph);
86 
88  uint64_t m_edge_offset;
90 };
91 
92 
94 // Edge Iterator //
96 
103 template <typename SegmentManager>
104 inline
107  uint64_t edge_offset,
108  const delegate_partitioned_graph* const pgraph)
109  : m_source(source)
110  , m_edge_offset(edge_offset)
111  , m_ptr_graph(pgraph) { }
112 
113 template <typename SegmentManager>
114 inline
117  ++m_edge_offset;
118  return *this;
119 }
120 
121 template <typename SegmentManager>
122 inline
125  edge_iterator to_return = *this;
126  ++m_edge_offset;
127  return to_return;
128 }
129 
130 template <typename SegmentManager>
131 inline bool
134  assert(m_source == x.m_source);
135  assert(m_ptr_graph == x.m_ptr_graph);
136  return m_edge_offset == x.m_edge_offset;
137 }
138 
139 template <typename SegmentManager>
140 inline bool
143  return x.is_equal(y);
144 
145 }
146 
147 template <typename SegmentManager>
148 inline bool
151  return !(x.is_equal(y));
152 }
153 
154 template <typename SegmentManager>
155 inline
156 typename delegate_partitioned_graph<SegmentManager>::vertex_locator
158  if(m_source.is_delegate()) {
159  assert(m_edge_offset < m_ptr_graph->m_delegate_targets_size);
160  assert(m_ptr_graph->m_delegate_targets[m_edge_offset].m_owner_dest <
161  m_ptr_graph->m_mpi_size);
162  return m_ptr_graph->m_delegate_targets[m_edge_offset];
163  }
164  assert(m_edge_offset < m_ptr_graph->m_owned_targets_size);
165  assert(m_ptr_graph->m_owned_targets[m_edge_offset].m_owner_dest <
166  m_ptr_graph->m_mpi_size);
167  return m_ptr_graph->m_owned_targets[m_edge_offset];
168 }
169 
170 
171 
172 } // mpi
173 } // namespace havoqgt
174 #endif // HAVOQGT_MPI_IMPL_EDGE_ITERATOR_HPP_
bool operator!=(delegate_partitioned_graph< SegementManager > &other)
const delegate_partitioned_graph *const m_ptr_graph
friend bool operator!=(const edge_iterator &x, const edge_iterator &y)
friend bool operator==(const edge_iterator &x, const edge_iterator &y)
bool operator==(delegate_partitioned_graph< SegementManager > &other)