distributed_property_map.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. // Copyright (C) 2004-2008 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Douglas Gregor
  6. // Nick Edmonds
  7. // Andrew Lumsdaine
  8. // The placement of this #include probably looks very odd relative to
  9. // the #ifndef/#define pair below. However, this placement is
  10. // extremely important to allow the various property map headers to be
  11. // included in any order.
  12. #include <boost/property_map/property_map.hpp>
  13. #ifndef BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP
  14. #define BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP
  15. #include <boost/assert.hpp>
  16. #include <boost/type_traits/is_base_and_derived.hpp>
  17. #include <boost/shared_ptr.hpp>
  18. #include <boost/weak_ptr.hpp>
  19. #include <boost/optional.hpp>
  20. #include <boost/property_map/parallel/process_group.hpp>
  21. #include <boost/function/function1.hpp>
  22. #include <vector>
  23. #include <set>
  24. #include <boost/property_map/parallel/basic_reduce.hpp>
  25. #include <boost/property_map/parallel/detail/untracked_pair.hpp>
  26. #include <boost/type_traits/is_same.hpp>
  27. #include <boost/property_map/parallel/local_property_map.hpp>
  28. #include <map>
  29. #include <boost/version.hpp>
  30. #include <boost/property_map/parallel/unsafe_serialize.hpp>
  31. #include <boost/multi_index_container.hpp>
  32. #include <boost/multi_index/hashed_index.hpp>
  33. #include <boost/multi_index/member.hpp>
  34. #include <boost/multi_index/sequenced_index.hpp>
  35. // Serialization functions for constructs we use
  36. #include <boost/serialization/utility.hpp>
  37. namespace boost { namespace parallel {
  38. namespace detail {
  39. /**************************************************************************
  40. * Metafunction that degrades an Lvalue Property Map category tag to
  41. * a Read Write Property Map category tag.
  42. **************************************************************************/
  43. template<bool IsLvaluePropertyMap>
  44. struct make_nonlvalue_property_map
  45. {
  46. template<typename T> struct apply { typedef T type; };
  47. };
  48. template<>
  49. struct make_nonlvalue_property_map<true>
  50. {
  51. template<typename>
  52. struct apply
  53. {
  54. typedef read_write_property_map_tag type;
  55. };
  56. };
  57. /**************************************************************************
  58. * Performs a "put" on a property map so long as the property map is
  59. * a Writable Property Map or a mutable Lvalue Property Map. This
  60. * is required because the distributed property map's message
  61. * handler handles "put" messages even for a const property map,
  62. * although receipt of a "put" message is ill-formed.
  63. **************************************************************************/
  64. template<bool IsLvaluePropertyMap>
  65. struct maybe_put_in_lvalue_pm
  66. {
  67. template<typename PropertyMap, typename Key, typename Value>
  68. static inline void
  69. do_put(PropertyMap, const Key&, const Value&)
  70. { BOOST_ASSERT(false); }
  71. };
  72. template<>
  73. struct maybe_put_in_lvalue_pm<true>
  74. {
  75. template<typename PropertyMap, typename Key, typename Value>
  76. static inline void
  77. do_put(PropertyMap pm, const Key& key, const Value& value)
  78. {
  79. using boost::put;
  80. put(pm, key, value);
  81. }
  82. };
  83. template<typename PropertyMap, typename Key, typename Value>
  84. inline void
  85. maybe_put_impl(PropertyMap pm, const Key& key, const Value& value,
  86. writable_property_map_tag)
  87. {
  88. using boost::put;
  89. put(pm, key, value);
  90. }
  91. template<typename PropertyMap, typename Key, typename Value>
  92. inline void
  93. maybe_put_impl(PropertyMap pm, const Key& key, const Value& value,
  94. lvalue_property_map_tag)
  95. {
  96. typedef typename property_traits<PropertyMap>::value_type value_type;
  97. typedef typename property_traits<PropertyMap>::reference reference;
  98. // DPG TBD: Some property maps are improperly characterized as
  99. // lvalue_property_maps, when in fact they do not provide true
  100. // references. The most typical example is those property maps
  101. // built from vector<bool> and its iterators, which deal with
  102. // proxies. We don't want to mischaracterize these as not having a
  103. // "put" operation, so we only consider an lvalue_property_map as
  104. // constant if its reference is const value_type&. In fact, this
  105. // isn't even quite correct (think of a
  106. // vector<bool>::const_iterator), but at present C++ doesn't
  107. // provide us with any alternatives.
  108. typedef is_same<const value_type&, reference> is_constant;
  109. maybe_put_in_lvalue_pm<(!is_constant::value)>::do_put(pm, key, value);
  110. }
  111. template<typename PropertyMap, typename Key, typename Value>
  112. inline void
  113. maybe_put_impl(PropertyMap, const Key&, const Value&, ...)
  114. { BOOST_ASSERT(false); }
  115. template<typename PropertyMap, typename Key, typename Value>
  116. inline void
  117. maybe_put(PropertyMap pm, const Key& key, const Value& value)
  118. {
  119. maybe_put_impl(pm, key, value,
  120. typename property_traits<PropertyMap>::category());
  121. }
  122. } // end namespace detail
  123. /** The consistency model used by the distributed property map. */
  124. enum consistency_model {
  125. cm_forward = 1 << 0,
  126. cm_backward = 1 << 1,
  127. cm_bidirectional = cm_forward | cm_backward,
  128. cm_flush = 1 << 2,
  129. cm_reset = 1 << 3,
  130. cm_clear = 1 << 4
  131. };
  132. /** Distributed property map adaptor.
  133. *
  134. * The distributed property map adaptor is a property map whose
  135. * stored values are distributed across multiple non-overlapping
  136. * memory spaces on different processes. Values local to the current
  137. * process are stored within a local property map and may be
  138. * immediately accessed via @c get and @c put. Values stored on
  139. * remote processes may also be access via @c get and @c put, but the
  140. * behavior differs slightly:
  141. *
  142. * - @c put operations update a local ghost cell and send a "put"
  143. * message to the process that owns the value. The owner is free to
  144. * update its own "official" value or may ignore the put request.
  145. *
  146. * - @c get operations returns the contents of the local ghost
  147. * cell. If no ghost cell is available, one is created using the
  148. * default value provided by the "reduce" operation. See, e.g.,
  149. * @ref basic_reduce and @ref property_reduce.
  150. *
  151. * Using distributed property maps requires a bit more care than using
  152. * local, sequential property maps. While the syntax and semantics are
  153. * similar, distributed property maps may contain out-of-date
  154. * information that can only be guaranteed to be synchronized by
  155. * calling the @ref synchronize function in all processes.
  156. *
  157. * To address the issue of out-of-date values, distributed property
  158. * maps are supplied with a reduction operation. The reduction
  159. * operation has two roles:
  160. *
  161. * -# When a value is needed for a remote key but no value is
  162. * immediately available, the reduction operation provides a
  163. * suitable default. For instance, a distributed property map
  164. * storing distances may have a reduction operation that returns
  165. * an infinite value as the default, whereas a distributed
  166. * property map for vertex colors may return white as the
  167. * default.
  168. *
  169. * -# When a value is received from a remote process, the process
  170. * owning the key associated with that value must determine which
  171. * value---the locally stored value, the value received from a
  172. * remote process, or some combination of the two---will be
  173. * stored as the "official" value in the property map. The
  174. * reduction operation transforms the local and remote values
  175. * into the "official" value to be stored.
  176. *
  177. * @tparam ProcessGroup the type of the process group over which the
  178. * property map is distributed and is also the medium for
  179. * communication.
  180. *
  181. * @tparam StorageMap the type of the property map that will
  182. * store values for keys local to this processor. The @c value_type of
  183. * this property map will become the @c value_type of the distributed
  184. * property map. The distributed property map models the same property
  185. * map concepts as the @c LocalPropertyMap, with one exception: a
  186. * distributed property map cannot be an LvaluePropertyMap (because
  187. * remote values are not addressable), and is therefore limited to
  188. * ReadWritePropertyMap.
  189. */
  190. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  191. class distributed_property_map
  192. {
  193. public:
  194. /// The key type of the property map.
  195. typedef typename property_traits<GlobalMap>::key_type key_type;
  196. /// The value type of the property map.
  197. typedef typename property_traits<StorageMap>::value_type value_type;
  198. typedef typename property_traits<StorageMap>::reference reference;
  199. typedef ProcessGroup process_group_type;
  200. private:
  201. typedef distributed_property_map self_type;
  202. typedef typename property_traits<StorageMap>::category local_category;
  203. typedef typename property_traits<StorageMap>::key_type local_key_type;
  204. typedef typename property_traits<GlobalMap>::value_type owner_local_pair;
  205. typedef typename ProcessGroup::process_id_type process_id_type;
  206. enum property_map_messages {
  207. /** A request to store a value in a property map. The message
  208. * contains a std::pair<key, data>.
  209. */
  210. property_map_put,
  211. /** A request to retrieve a particular value in a property
  212. * map. The message contains a key. The owner of that key will
  213. * reply with a value.
  214. */
  215. property_map_get,
  216. /** A request to update values stored on a remote processor. The
  217. * message contains a vector of keys for which the source
  218. * requests updated values. This message will only be transmitted
  219. * during synchronization.
  220. */
  221. property_map_multiget,
  222. /** A request to store values in a ghost cell. This message
  223. * contains a vector of key/value pairs corresponding to the
  224. * sequence of keys sent to the source processor.
  225. */
  226. property_map_multiget_reply,
  227. /** The payload containing a vector of local key-value pairs to be
  228. * put into the remote property map. A key-value std::pair will be
  229. * used to store each local key-value pair.
  230. */
  231. property_map_multiput
  232. };
  233. // Code from Joaquín M López Muñoz to work around unusual implementation of
  234. // std::pair in VC++ 10:
  235. template<typename First,typename Second>
  236. class pair_first_extractor {
  237. typedef std::pair<First,Second> value_type;
  238. public:
  239. typedef First result_type;
  240. const result_type& operator()(const value_type& x) const {
  241. return x.first;
  242. }
  243. result_type& operator()(value_type& x) const {
  244. return x.first;
  245. }
  246. };
  247. public:
  248. /// The type of the ghost cells
  249. typedef multi_index::multi_index_container<
  250. std::pair<key_type, value_type>,
  251. multi_index::indexed_by<
  252. multi_index::sequenced<>,
  253. multi_index::hashed_unique<
  254. pair_first_extractor<key_type, value_type>
  255. >
  256. >
  257. > ghost_cells_type;
  258. /// Iterator into the ghost cells
  259. typedef typename ghost_cells_type::iterator iterator;
  260. /// Key-based index into the ghost cells
  261. typedef typename ghost_cells_type::template nth_index<1>::type
  262. ghost_cells_key_index_type;
  263. /// Iterator into the ghost cells (by key)
  264. typedef typename ghost_cells_key_index_type::iterator key_iterator;
  265. /** The property map category. A distributed property map cannot be
  266. * an Lvalue Property Map, because values on remote processes cannot
  267. * be addresses.
  268. */
  269. typedef typename detail::make_nonlvalue_property_map<
  270. (is_base_and_derived<lvalue_property_map_tag, local_category>::value
  271. || is_same<lvalue_property_map_tag, local_category>::value)>
  272. ::template apply<local_category>::type category;
  273. /** Default-construct a distributed property map. This function
  274. * creates an initialized property map that must be assigned to a
  275. * valid value before being used. It is only provided here because
  276. * property maps must be Default Constructible.
  277. */
  278. distributed_property_map() {}
  279. /** Construct a distributed property map. Builds a distributed
  280. * property map communicating over the given process group and using
  281. * the given local property map for storage. Since no reduction
  282. * operation is provided, the default reduction operation @c
  283. * basic_reduce<value_type> is used.
  284. */
  285. distributed_property_map(const ProcessGroup& pg, const GlobalMap& global,
  286. const StorageMap& pm)
  287. : data(new data_t(pg, global, pm, basic_reduce<value_type>(), false))
  288. {
  289. typedef handle_message<basic_reduce<value_type> > Handler;
  290. data->ghost_cells.reset(new ghost_cells_type());
  291. Handler handler(data);
  292. data->process_group.replace_handler(handler, true);
  293. data->process_group.template get_receiver<Handler>()
  294. ->setup_triggers(data->process_group);
  295. }
  296. /** Construct a distributed property map. Builds a distributed
  297. * property map communicating over the given process group and using
  298. * the given local property map for storage. The given @p reduce
  299. * parameter is used as the reduction operation.
  300. */
  301. template<typename Reduce>
  302. distributed_property_map(const ProcessGroup& pg, const GlobalMap& global,
  303. const StorageMap& pm,
  304. const Reduce& reduce);
  305. ~distributed_property_map();
  306. /// Set the reduce operation of the distributed property map.
  307. template<typename Reduce>
  308. void set_reduce(const Reduce& reduce);
  309. // Set the consistency model for the distributed property map
  310. void set_consistency_model(int model);
  311. // Get the consistency model
  312. int get_consistency_model() const { return data->model; }
  313. // Set the maximum number of ghost cells that we are allowed to
  314. // maintain. If 0, all ghost cells will be retained.
  315. void set_max_ghost_cells(std::size_t max_ghost_cells);
  316. // Clear out all ghost cells
  317. void clear();
  318. // Reset the values in all ghost cells to the default value
  319. void reset();
  320. // Flush all values destined for remote processors
  321. void flush();
  322. reference operator[](const key_type& key) const
  323. {
  324. owner_local_pair p = get(data->global, key);
  325. if (p.first == process_id(data->process_group)) {
  326. return data->storage[p.second];
  327. } else {
  328. return cell(key);
  329. }
  330. }
  331. process_group_type process_group() const
  332. {
  333. return data->process_group.base();
  334. }
  335. StorageMap& base() { return data->storage; }
  336. const StorageMap& base() const { return data->storage; }
  337. /** Sends a "put" request.
  338. * \internal
  339. *
  340. */
  341. void
  342. request_put(process_id_type p, const key_type& k, const value_type& v) const
  343. {
  344. send(data->process_group, p, property_map_put,
  345. boost::parallel::detail::make_untracked_pair(k, v));
  346. }
  347. /** Access the ghost cell for the given key.
  348. * \internal
  349. */
  350. value_type& cell(const key_type& k, bool request_if_missing = true) const;
  351. /** Perform synchronization
  352. * \internal
  353. */
  354. void do_synchronize();
  355. const GlobalMap& global() const { return data->global; }
  356. GlobalMap& global() { return data->global; }
  357. struct data_t
  358. {
  359. data_t(const ProcessGroup& pg, const GlobalMap& global,
  360. const StorageMap& pm, const function1<value_type, key_type>& dv,
  361. bool has_default_resolver)
  362. : process_group(pg), global(global), storage(pm),
  363. ghost_cells(), max_ghost_cells(1000000), get_default_value(dv),
  364. has_default_resolver(has_default_resolver), model(cm_forward) { }
  365. /// The process group
  366. ProcessGroup process_group;
  367. /// A mapping from the keys of this property map to the global
  368. /// descriptor.
  369. GlobalMap global;
  370. /// Local property map
  371. StorageMap storage;
  372. /// The ghost cells
  373. shared_ptr<ghost_cells_type> ghost_cells;
  374. /// The maximum number of ghost cells we are permitted to hold. If
  375. /// zero, we are permitted to have an infinite number of ghost
  376. /// cells.
  377. std::size_t max_ghost_cells;
  378. /// Default value for remote ghost cells, as defined by the
  379. /// reduction operation.
  380. function1<value_type, key_type> get_default_value;
  381. /// True if this resolver is the "default" resolver, meaning that
  382. /// we should not be able to get() a default value; it needs to be
  383. /// request()ed first.
  384. bool has_default_resolver;
  385. // Current consistency model
  386. int model;
  387. // Function that resets all of the ghost cells to their default
  388. // values. It knows the type of the resolver, so we can eliminate
  389. // a large number of calls through function pointers.
  390. void (data_t::*reset)();
  391. // Clear out all ghost cells
  392. void clear();
  393. // Flush all values destined for remote processors
  394. void flush();
  395. // Send out requests to "refresh" the values of ghost cells that
  396. // we're holding.
  397. void refresh_ghost_cells();
  398. private:
  399. template<typename Resolver> void do_reset();
  400. friend class distributed_property_map;
  401. };
  402. friend struct data_t;
  403. shared_ptr<data_t> data;
  404. private:
  405. // Prunes the least recently used ghost cells until we have @c
  406. // max_ghost_cells or fewer ghost cells.
  407. void prune_ghost_cells() const;
  408. /** Handles incoming messages.
  409. *
  410. * This function object is responsible for handling all incoming
  411. * messages for the distributed property map.
  412. */
  413. template<typename Reduce>
  414. struct handle_message
  415. {
  416. explicit handle_message(const shared_ptr<data_t>& data,
  417. const Reduce& reduce = Reduce())
  418. : data_ptr(data), reduce(reduce) { }
  419. void operator()(process_id_type source, int tag);
  420. /// Individual message handlers
  421. void
  422. handle_put(int source, int tag,
  423. const boost::parallel::detail::untracked_pair<key_type, value_type>& data,
  424. trigger_receive_context);
  425. value_type
  426. handle_get(int source, int tag, const key_type& data,
  427. trigger_receive_context);
  428. void
  429. handle_multiget(int source, int tag,
  430. const std::vector<key_type>& data,
  431. trigger_receive_context);
  432. void
  433. handle_multiget_reply
  434. (int source, int tag,
  435. const std::vector<boost::parallel::detail::untracked_pair<key_type, value_type> >& msg,
  436. trigger_receive_context);
  437. void
  438. handle_multiput
  439. (int source, int tag,
  440. const std::vector<unsafe_pair<local_key_type, value_type> >& data,
  441. trigger_receive_context);
  442. void setup_triggers(process_group_type& pg);
  443. private:
  444. weak_ptr<data_t> data_ptr;
  445. Reduce reduce;
  446. };
  447. /* Sets up the next stage in a multi-stage synchronization, for
  448. bidirectional consistency. */
  449. struct on_synchronize
  450. {
  451. explicit on_synchronize(const shared_ptr<data_t>& data) : data_ptr(data) { }
  452. void operator()();
  453. private:
  454. weak_ptr<data_t> data_ptr;
  455. };
  456. };
  457. /* An implementation helper macro for the common case of naming
  458. distributed property maps with all of the normal template
  459. parameters. */
  460. #define PBGL_DISTRIB_PMAP \
  461. distributed_property_map<ProcessGroup, GlobalMap, StorageMap>
  462. /* Request that the value for the given remote key be retrieved in
  463. the next synchronization round. */
  464. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  465. inline void
  466. request(const PBGL_DISTRIB_PMAP& pm,
  467. typename PBGL_DISTRIB_PMAP::key_type const& key)
  468. {
  469. if (get(pm.data->global, key).first != process_id(pm.data->process_group))
  470. pm.cell(key, false);
  471. }
  472. /** Get the value associated with a particular key. Retrieves the
  473. * value associated with the given key. If the key denotes a
  474. * locally-owned object, it returns the value from the local property
  475. * map; if the key denotes a remotely-owned object, retrieves the
  476. * value of the ghost cell for that key, which may be the default
  477. * value provided by the reduce operation.
  478. *
  479. * Complexity: For a local key, O(1) get operations on the underlying
  480. * property map. For a non-local key, O(1) accesses to the ghost cells.
  481. */
  482. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  483. inline
  484. typename PBGL_DISTRIB_PMAP::value_type
  485. get(const PBGL_DISTRIB_PMAP& pm,
  486. typename PBGL_DISTRIB_PMAP::key_type const& key)
  487. {
  488. using boost::get;
  489. typename property_traits<GlobalMap>::value_type p =
  490. get(pm.data->global, key);
  491. if (p.first == process_id(pm.data->process_group)) {
  492. return get(pm.data->storage, p.second);
  493. } else {
  494. return pm.cell(key);
  495. }
  496. }
  497. /** Put a value associated with the given key into the property map.
  498. * When the key denotes a locally-owned object, this operation updates
  499. * the underlying local property map. Otherwise, the local ghost cell
  500. * is updated and a "put" message is sent to the processor owning this
  501. * key.
  502. *
  503. * Complexity: For a local key, O(1) put operations on the underlying
  504. * property map. For a nonlocal key, O(1) accesses to the ghost cells
  505. * and will send O(1) messages of size O(sizeof(key) + sizeof(value)).
  506. */
  507. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  508. void
  509. put(const PBGL_DISTRIB_PMAP& pm,
  510. typename PBGL_DISTRIB_PMAP::key_type const & key,
  511. typename PBGL_DISTRIB_PMAP::value_type const & value)
  512. {
  513. using boost::put;
  514. typename property_traits<GlobalMap>::value_type p =
  515. get(pm.data->global, key);
  516. if (p.first == process_id(pm.data->process_group)) {
  517. put(pm.data->storage, p.second, value);
  518. } else {
  519. if (pm.data->model & cm_forward)
  520. pm.request_put(p.first, key, value);
  521. pm.cell(key, false) = value;
  522. }
  523. }
  524. /** Put a value associated with a given key into the local view of the
  525. * property map. This operation is equivalent to @c put, but with one
  526. * exception: no message will be sent to the owning processor in the
  527. * case of a remote update. The effect is that any value written via
  528. * @c local_put for a remote key may be overwritten in the next
  529. * synchronization round.
  530. */
  531. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  532. void
  533. local_put(const PBGL_DISTRIB_PMAP& pm,
  534. typename PBGL_DISTRIB_PMAP::key_type const & key,
  535. typename PBGL_DISTRIB_PMAP::value_type const & value)
  536. {
  537. using boost::put;
  538. typename property_traits<GlobalMap>::value_type p =
  539. get(pm.data->global, key);
  540. if (p.first == process_id(pm.data->process_group))
  541. put(pm.data->storage, p.second, value);
  542. else pm.cell(key, false) = value;
  543. }
  544. /** Cache the value associated with the given remote key. If the key
  545. * is local, ignore the operation. */
  546. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  547. inline void
  548. cache(const PBGL_DISTRIB_PMAP& pm,
  549. typename PBGL_DISTRIB_PMAP::key_type const & key,
  550. typename PBGL_DISTRIB_PMAP::value_type const & value)
  551. {
  552. typename ProcessGroup::process_id_type id = get(pm.data->global, key).first;
  553. if (id != process_id(pm.data->process_group)) pm.cell(key, false) = value;
  554. }
  555. /// Synchronize the property map.
  556. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  557. void
  558. synchronize(PBGL_DISTRIB_PMAP& pm)
  559. {
  560. pm.do_synchronize();
  561. }
  562. /// Create a distributed property map.
  563. template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
  564. inline distributed_property_map<ProcessGroup, GlobalMap, StorageMap>
  565. make_distributed_property_map(const ProcessGroup& pg, GlobalMap global,
  566. StorageMap storage)
  567. {
  568. typedef distributed_property_map<ProcessGroup, GlobalMap, StorageMap>
  569. result_type;
  570. return result_type(pg, global, storage);
  571. }
  572. /**
  573. * \overload
  574. */
  575. template<typename ProcessGroup, typename GlobalMap, typename StorageMap,
  576. typename Reduce>
  577. inline distributed_property_map<ProcessGroup, GlobalMap, StorageMap>
  578. make_distributed_property_map(const ProcessGroup& pg, GlobalMap global,
  579. StorageMap storage, Reduce reduce)
  580. {
  581. typedef distributed_property_map<ProcessGroup, GlobalMap, StorageMap>
  582. result_type;
  583. return result_type(pg, global, storage, reduce);
  584. }
  585. } } // end namespace boost::parallel
  586. #include <boost/property_map/parallel/impl/distributed_property_map.ipp>
  587. #undef PBGL_DISTRIB_PMAP
  588. #endif // BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP