parallel_property_maps.hpp 8.7 KB

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