parallel_property_maps.hpp 8.7 KB

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