• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright Jeremy Siek 1999-2001.
2 //  Copyright (C) 2006 Trustees of Indiana University
3 //  Authors: Douglas Gregor and Jeremy Siek
4 
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 //  See http://www.boost.org/libs/property_map for documentation.
10 
11 #ifndef BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP
12 #define BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP
13 
14 // Parallel property maps moved over from <boost/property_map/property_map.hpp>
15 // as part of refactoring out all parallel code from sequential property map
16 // library.
17 
18 #include <boost/assert.hpp>
19 #include <boost/config.hpp>
20 #include <boost/static_assert.hpp>
21 #include <cstddef>
22 #include <boost/concept_archetype.hpp>
23 #include <boost/mpl/assert.hpp>
24 #include <boost/mpl/or.hpp>
25 #include <boost/mpl/and.hpp>
26 #include <boost/mpl/has_xxx.hpp>
27 #include <boost/type_traits/is_same.hpp>
28 #include <boost/property_map/property_map.hpp>
29 
30 #include <boost/property_map/parallel/distributed_property_map.hpp>
31 #include <boost/property_map/parallel/local_property_map.hpp>
32 
33 namespace boost {
34 /** Distributed iterator property map.
35  *
36  * This specialization of @ref iterator_property_map builds a
37  * distributed iterator property map given the local index maps
38  * generated by distributed graph types that automatically have index
39  * properties.
40  *
41  * This specialization is useful when creating external distributed
42  * property maps via the same syntax used to create external
43  * sequential property maps.
44  */
45 template<typename RandomAccessIterator, typename ProcessGroup,
46          typename GlobalMap, typename StorageMap,
47          typename ValueType, typename Reference>
48 class iterator_property_map
49         <RandomAccessIterator,
50          local_property_map<ProcessGroup, GlobalMap, StorageMap>,
51          ValueType, Reference>
52   : public parallel::distributed_property_map
53              <ProcessGroup,
54               GlobalMap,
55               iterator_property_map<RandomAccessIterator, StorageMap,
56                                     ValueType, Reference> >
57 {
58   typedef iterator_property_map<RandomAccessIterator, StorageMap,
59                                 ValueType, Reference> local_iterator_map;
60 
61   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
62                                              local_iterator_map> inherited;
63 
64   typedef local_property_map<ProcessGroup, GlobalMap, StorageMap>
65     index_map_type;
66   typedef iterator_property_map self_type;
67 
68 public:
iterator_property_map()69   iterator_property_map() { }
70 
iterator_property_map(RandomAccessIterator cc,const index_map_type & id)71   iterator_property_map(RandomAccessIterator cc, const index_map_type& id)
72     : inherited(id.process_group(), id.global(),
73                 local_iterator_map(cc, id.base())) { }
74 };
75 
76 /** Distributed iterator property map.
77  *
78  * This specialization of @ref iterator_property_map builds a
79  * distributed iterator property map given a distributed index
80  * map. Only the local portion of the distributed index property map
81  * is utilized.
82  *
83  * This specialization is useful when creating external distributed
84  * property maps via the same syntax used to create external
85  * sequential property maps.
86  */
87 template<typename RandomAccessIterator, typename ProcessGroup,
88          typename GlobalMap, typename StorageMap,
89          typename ValueType, typename Reference>
90 class iterator_property_map<
91         RandomAccessIterator,
92         parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>,
93         ValueType, Reference
94       >
95   : public parallel::distributed_property_map
96              <ProcessGroup,
97               GlobalMap,
98               iterator_property_map<RandomAccessIterator, StorageMap,
99                                     ValueType, Reference> >
100 {
101   typedef iterator_property_map<RandomAccessIterator, StorageMap,
102                                 ValueType, Reference> local_iterator_map;
103 
104   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
105                                              local_iterator_map> inherited;
106 
107   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
108                                              StorageMap>
109     index_map_type;
110 
111 public:
iterator_property_map()112   iterator_property_map() { }
113 
iterator_property_map(RandomAccessIterator cc,const index_map_type & id)114   iterator_property_map(RandomAccessIterator cc, const index_map_type& id)
115     : inherited(id.process_group(), id.global(),
116                 local_iterator_map(cc, id.base())) { }
117 };
118 
119 namespace parallel {
120 // Generate an iterator property map with a specific kind of ghost
121 // cells
122 template<typename RandomAccessIterator, typename ProcessGroup,
123          typename GlobalMap, typename StorageMap>
124 distributed_property_map<ProcessGroup,
125                          GlobalMap,
126                          iterator_property_map<RandomAccessIterator,
127                                                StorageMap> >
make_iterator_property_map(RandomAccessIterator cc,local_property_map<ProcessGroup,GlobalMap,StorageMap> index_map)128 make_iterator_property_map(RandomAccessIterator cc,
129                            local_property_map<ProcessGroup, GlobalMap,
130                                               StorageMap> index_map)
131 {
132   typedef distributed_property_map<
133             ProcessGroup, GlobalMap,
134             iterator_property_map<RandomAccessIterator, StorageMap> >
135     result_type;
136   return result_type(index_map.process_group(), index_map.global(),
137                      make_iterator_property_map(cc, index_map.base()));
138 }
139 
140 } // end namespace parallel
141 
142 /** Distributed safe iterator property map.
143  *
144  * This specialization of @ref safe_iterator_property_map builds a
145  * distributed iterator property map given the local index maps
146  * generated by distributed graph types that automatically have index
147  * properties.
148  *
149  * This specialization is useful when creating external distributed
150  * property maps via the same syntax used to create external
151  * sequential property maps.
152  */
153 template<typename RandomAccessIterator, typename ProcessGroup,
154          typename GlobalMap, typename StorageMap, typename ValueType,
155          typename Reference>
156 class safe_iterator_property_map
157         <RandomAccessIterator,
158          local_property_map<ProcessGroup, GlobalMap, StorageMap>,
159          ValueType, Reference>
160   : public parallel::distributed_property_map
161              <ProcessGroup,
162               GlobalMap,
163               safe_iterator_property_map<RandomAccessIterator, StorageMap,
164                                          ValueType, Reference> >
165 {
166   typedef safe_iterator_property_map<RandomAccessIterator, StorageMap,
167                                      ValueType, Reference> local_iterator_map;
168 
169   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
170                                              local_iterator_map> inherited;
171 
172   typedef local_property_map<ProcessGroup, GlobalMap, StorageMap> index_map_type;
173 
174 public:
safe_iterator_property_map()175   safe_iterator_property_map() { }
176 
safe_iterator_property_map(RandomAccessIterator cc,std::size_t n,const index_map_type & id)177   safe_iterator_property_map(RandomAccessIterator cc, std::size_t n,
178                              const index_map_type& id)
179     : inherited(id.process_group(), id.global(),
180                 local_iterator_map(cc, n, id.base())) { }
181 };
182 
183 /** Distributed safe iterator property map.
184  *
185  * This specialization of @ref safe_iterator_property_map builds a
186  * distributed iterator property map given a distributed index
187  * map. Only the local portion of the distributed index property map
188  * is utilized.
189  *
190  * This specialization is useful when creating external distributed
191  * property maps via the same syntax used to create external
192  * sequential property maps.
193  */
194 template<typename RandomAccessIterator, typename ProcessGroup,
195          typename GlobalMap, typename StorageMap,
196          typename ValueType, typename Reference>
197 class safe_iterator_property_map<
198         RandomAccessIterator,
199         parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>,
200         ValueType, Reference>
201   : public parallel::distributed_property_map
202              <ProcessGroup,
203               GlobalMap,
204               safe_iterator_property_map<RandomAccessIterator, StorageMap,
205                                          ValueType, Reference> >
206 {
207   typedef safe_iterator_property_map<RandomAccessIterator, StorageMap,
208                                      ValueType, Reference> local_iterator_map;
209 
210   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
211                                              local_iterator_map> inherited;
212 
213   typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
214                                              StorageMap>
215     index_map_type;
216 
217 public:
safe_iterator_property_map()218   safe_iterator_property_map() { }
219 
safe_iterator_property_map(RandomAccessIterator cc,std::size_t n,const index_map_type & id)220   safe_iterator_property_map(RandomAccessIterator cc, std::size_t n,
221                              const index_map_type& id)
222     : inherited(id.process_group(), id.global(),
223                 local_iterator_map(cc, n, id.base())) { }
224 };
225 
226 }
227 
228 #include <boost/property_map/vector_property_map.hpp>
229 
230 #endif /* BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP */
231 
232