HavoqGT
edge_data.hpp
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  * Re-written by Steven Feldman <feldman12@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 #ifndef HAVOQGT_MPI_IMPL_EDGE_DATA_HPP_
53 #define HAVOQGT_MPI_IMPL_EDGE_DATA_HPP_
54 
56 
57 namespace havoqgt {
58 namespace mpi {
59 
60 template <typename SegementManager>
61 template <typename T, typename SegManagerOther>
62 class delegate_partitioned_graph<SegementManager>::edge_data {
63  public:
64  typedef typename bip::vector< T, bip::allocator<T, SegManagerOther> >
66  typedef T value_type;
67 
68  edge_data() {}
69 
70  T& operator[] (const edge_iterator& itr);
71  const T& operator[] (const edge_iterator& itr) const;
72 
73  void reset(const T& r) {
74  for(size_t i=0; i<m_owned_edge_data.size(); ++i) {
75  m_owned_edge_data[i] = r;
76  }
77  for(size_t i=0; i<m_delegate_edge_data.size(); ++i) {
78  m_delegate_edge_data[i] = r;
79  }
80  }
81 
82  iterator delegate_begin() { return m_delegate_edge_data.begin(); }
83  iterator delegate_end() { return m_delegate_edge_data.end(); }
84  iterator owned_begin() { return m_owned_edge_data.begin(); }
85  iterator owned_end() { return m_owned_edge_data.end(); }
86 
87 //private:
88 // friend class delegate_partitioned_graph;
89  edge_data(uint64_t owned_size, uint64_t delegate_size,
90  SegManagerOther* sm);
91  edge_data(uint64_t owned_size, uint64_t delegate_size, const T& init,
92  SegManagerOther* sm);
93 
94  private:
95  bip::vector< T, bip::allocator<T, SegManagerOther> >
97  bip::vector< T, bip::allocator<T, SegManagerOther> >
99 };
100 
101 
103 // edge_data //
105 template <typename SegmentManager>
106 template<typename T, typename SegManagerOther>
108 edge_data(uint64_t owned_size, uint64_t delegate_size, SegManagerOther* sm)
109  : m_owned_edge_data(sm->template get_allocator<T>())
110  , m_delegate_edge_data(sm->template get_allocator<T>()) {
111  m_owned_edge_data.resize(owned_size);
112  m_delegate_edge_data.resize(delegate_size);
113  }
114 
115 template <typename SegmentManager>
116 template<typename T, typename SegManagerOther>
118 edge_data(uint64_t owned_size, uint64_t delegate_size, const T& init, SegManagerOther* sm)
119  : m_owned_edge_data(owned_size, init, sm->template get_allocator<T>())
120  , m_delegate_edge_data(delegate_size, init, sm->template get_allocator<T>()) { }
121 
122 template <typename SegmentManager>
123 template<typename T, typename SegManagerOther>
124 T&
127  if(itr.m_source.is_delegate()) {
128  assert(itr.m_edge_offset < m_delegate_edge_data.size());
129  return m_delegate_edge_data[itr.m_edge_offset];
130  }
131  assert(itr.m_edge_offset < m_owned_edge_data.size());
132  return m_owned_edge_data[itr.m_edge_offset];
133 }
134 
135 template <typename SegmentManager>
136 template<typename T, typename SegManagerOther>
137 const T&
139  if(itr.m_source.is_delegate()) {
140  assert(itr.m_edge_offset < m_delegate_edge_data.size());
141  return m_delegate_edge_data[itr.m_edge_offset];
142  }
143  assert(itr.m_edge_offset < m_owned_edge_data.size());
144  return m_owned_edge_data[itr.m_edge_offset];
145 }
146 
147 } // mpi
148 } // namespace havoqgt
149 #endif // HAVOQGT_MPI_IMPL_EDGE_DATA_HPP_
bip::vector< T, bip::allocator< T, SegManagerOther > > m_owned_edge_data
Definition: edge_data.hpp:96
bip::vector< T, bip::allocator< T, SegManagerOther > > m_delegate_edge_data
Definition: edge_data.hpp:98
bip::vector< T, bip::allocator< T, SegManagerOther > >::iterator iterator
Definition: edge_data.hpp:65