HavoqGT
vertex_locator.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_LOCATOR_HPP_
54 #define HAVOQGT_MPI_IMPL_VERTEX_LOCATOR_HPP_
55 
57 
58 namespace havoqgt {
59 namespace mpi {
60 
61 template <typename SegementManager>
62 class delegate_partitioned_graph<SegementManager>::vertex_locator {
63  public:
65  m_is_delegate = 0;
66  m_is_bcast = 0;
67  m_is_intercept = 0;
68  m_owner_dest = std::numeric_limits<uint32_t>::max();
69  m_local_id = std::numeric_limits<uint64_t>::max();
70  }
71 
72  bool is_valid() const {
74  conv.m_local_id = std::numeric_limits<uint64_t>::max();
75  conv.m_owner_dest = std::numeric_limits<uint64_t>::max();
76 
77 
78  return (m_local_id != conv.m_local_id || m_owner_dest != conv.m_owner_dest);
79  }
80 
81  bool is_delegate() const { return m_is_delegate == 1;}
82  uint32_t owner() const { return m_owner_dest; }
83  void set_dest(uint32_t dest) { m_owner_dest = dest; assert(m_owner_dest == dest);}
84  uint64_t local_id() const { return m_local_id;}
85  bool is_equal(const vertex_locator x) const;
86  uint32_t get_bcast() const { return m_is_bcast ; }
87  void set_bcast(uint32_t bcast) { m_is_bcast = bcast; }
88  bool is_intercept() const { return m_is_intercept == 1;}
89  void set_intercept(bool intercept) { m_is_intercept = intercept; }
90 
91  friend bool operator==(const vertex_locator& x,
92  const vertex_locator& y) {return x.is_equal(y); }
93  friend bool operator<(const vertex_locator& x,
94  const vertex_locator& y) {
95  if (x.m_is_delegate == y.m_is_delegate) {
96  if (x.m_owner_dest == y.m_owner_dest) {
97  return x.m_local_id < y.m_local_id;
98  }
99  else {
100  return x.m_owner_dest < y.m_owner_dest;
101  }
102 
103  } else {
104  return x.m_is_delegate < y.m_is_delegate;
105  }
106  }
107 
108 
109  friend bool operator!=(const vertex_locator& x,
110  const vertex_locator& y) {return !(x.is_equal(y)); }
111 
112  private:
114  unsigned int m_is_delegate : 1;
115 
116  unsigned int m_is_bcast : 1;
117  unsigned int m_is_intercept : 1;
118  unsigned int m_owner_dest : 20;
119  uint64_t m_local_id : 39;
120 
121  vertex_locator(bool is_delegate, uint64_t local_id, uint32_t owner_dest);
122 } __attribute__ ((packed)) ;
123 
124 
126 // Vertex Locator //
128 
135 template <typename SegmentManager>
136 inline
138 vertex_locator(bool is_delegate, uint64_t local_id, uint32_t owner_dest) {
139  m_is_bcast = 0;
140  m_is_intercept = 0;
141 
142  if (is_delegate) {
143  m_is_delegate = true;
144  m_owner_dest = owner_dest;
146  if(!(m_is_delegate == true
147  && m_local_id == local_id
148  && m_owner_dest == owner_dest)) { std::cerr << "ERROR: vertex_locator()" << std::endl; exit(-1);}
149  } else {
150  m_is_delegate = false;
151  m_owner_dest = owner_dest;
153  if(!(m_is_delegate == false
154  && m_owner_dest == owner_dest
155  && m_local_id == local_id)) { std::cerr << "ERROR: vertex_locator()" << std::endl; exit(-1);}
156 
157  }
158 }
159 
160 template <typename SegmentManager>
161 inline bool
164  return m_is_delegate == x.m_is_delegate
165  && m_is_bcast == x.m_is_bcast
166  && m_is_intercept == x.m_is_intercept
167  && m_owner_dest == x.m_owner_dest
168  && m_local_id == x.m_local_id;
169 }
170 
171 
172 } // mpi
173 } // namespace havoqgt
174 #endif // HAVOQGT_MPI_IMPL_VERTEX_LOCATOR_HPP_
friend bool operator<(const vertex_locator &x, const vertex_locator &y)
friend bool operator!=(const vertex_locator &x, const vertex_locator &y)
friend bool operator==(const vertex_locator &x, const vertex_locator &y)