distributed_property_map.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
  7. <title>Parallel BGL Distributed Property Map</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-distributed-property-map">
  12. <h1 class="title"><a class="reference external" href="http://www.osl.iu.edu/research/pbgl"><img align="middle" alt="Parallel BGL" class="align-middle" src="pbgl-logo.png" /></a> Distributed Property Map</h1>
  13. <!-- Copyright (C) 2004-2008 The Trustees of Indiana University.
  14. Use, modification and distribution is subject to the Boost Software
  15. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  16. http://www.boost.org/LICENSE_1_0.txt) -->
  17. <p>A distributed property map adaptor is a property map whose stored
  18. values are distributed across multiple non-overlapping memory spaces
  19. on different processes. Values local to the current process are stored
  20. within a local property map and may be immediately accessed via
  21. <tt class="docutils literal"><span class="pre">get</span></tt> and <tt class="docutils literal"><span class="pre">put</span></tt>. Values stored on remote processes may also be
  22. accessed via <tt class="docutils literal"><span class="pre">get</span></tt> and <tt class="docutils literal"><span class="pre">put</span></tt>, but the behavior differs slightly:</p>
  23. <blockquote>
  24. <ul class="simple">
  25. <li><tt class="docutils literal"><span class="pre">put</span></tt> operations update a local ghost cell and send a &quot;put&quot;
  26. message to the process that owns the value. The owner is free to
  27. update its own &quot;official&quot; value or may ignore the put request.</li>
  28. <li><tt class="docutils literal"><span class="pre">get</span></tt> operations returns the contents of the local ghost
  29. cell. If no ghost cell is available, one is created using a
  30. (customizable) default value.</li>
  31. </ul>
  32. </blockquote>
  33. <p>Using distributed property maps requires a bit more care than using
  34. local, sequential property maps. While the syntax and semantics are
  35. similar, distributed property maps may contain out-of-date
  36. information that can only be guaranteed to be synchronized by
  37. calling the <tt class="docutils literal"><span class="pre">synchronize</span></tt> function in all processes.</p>
  38. <p>To address the issue of out-of-date values, distributed property
  39. maps support multiple <a class="reference internal" href="#consistency-models">consistency models</a> and may be supplied with a
  40. <a class="reference internal" href="#reduction-operation">reduction operation</a>.</p>
  41. <p>Distributed property maps meet the requirements of the <a class="reference external" href="http://www.boost.org/libs/property_map/ReadablePropertyMap.html">Readable
  42. Property Map</a> and, potentially, the <a class="reference external" href="http://www.boost.org/libs/property_map/WritablePropertyMap.html">Writable Property Map</a> and
  43. <a class="reference external" href="http://www.boost.org/libs/property_map/ReadWritePropertyMap.html">Read/Write Property Map</a> concepts. Distributed property maps do
  44. <em>not</em>, however, meet the requirements of the <a class="reference external" href="http://www.boost.org/libs/property_map/LvaluePropertyMap.html">Lvalue Property Map</a>
  45. concept, because elements residing in another process are not
  46. directly addressible. There are several forms of distributed property
  47. maps:</p>
  48. <blockquote>
  49. <ul class="simple">
  50. <li><a class="reference internal" href="#distributed-property-map-adaptor">Distributed property map adaptor</a></li>
  51. <li><a class="reference internal" href="#distributed-iterator-property-map">Distributed iterator property map</a></li>
  52. <li><a class="reference internal" href="#distributed-safe-iterator-property-map">Distributed safe iterator property map</a></li>
  53. <li><a class="reference internal" href="#local-property-map">Local property map</a></li>
  54. </ul>
  55. </blockquote>
  56. <div class="section" id="consistency-models">
  57. <h1>Consistency models</h1>
  58. <p>Distributed property maps offer many consistency models, which affect
  59. how the values read from and written to remote keys relate to the
  60. &quot;official&quot; value for that key stored in the owning process. The
  61. consistency model of a distributed property map can be set with the
  62. member function <tt class="docutils literal"><span class="pre">set_consistency_model</span></tt> to a bitwise-OR of the
  63. flags in the <tt class="docutils literal"><span class="pre">boost::parallel::consistency_model</span></tt> enumeration. The
  64. individual flags are:</p>
  65. <blockquote>
  66. <ul class="simple">
  67. <li><tt class="docutils literal"><span class="pre">cm_forward</span></tt>: The default consistency model, which propagates
  68. values forward from <tt class="docutils literal"><span class="pre">put</span></tt> operations on remote processors to
  69. the owner of the value being changed.</li>
  70. <li><tt class="docutils literal"><span class="pre">cm_backward</span></tt>: After all values have been forwarded or flushed
  71. to the owning processes, each process receives updates values for
  72. each of its ghost cells. After synchronization, the values in
  73. ghost cells are guaranteed to match the values stored on the
  74. owning processor.</li>
  75. <li><tt class="docutils literal"><span class="pre">cm_bidirectional</span></tt>: A combination of both <tt class="docutils literal"><span class="pre">cm_forward</span></tt> and
  76. <tt class="docutils literal"><span class="pre">cm_backward</span></tt>.</li>
  77. <li><tt class="docutils literal"><span class="pre">cm_flush</span></tt>: At the beginning of synchronization, all of the
  78. values stored locally in ghost cells are sent to their owning
  79. processors.</li>
  80. <li><tt class="docutils literal"><span class="pre">cm_reset</span></tt>: Executes a <tt class="docutils literal"><span class="pre">reset()</span></tt> operation after
  81. synchronization, setting the values in each ghost cell to their
  82. default value.</li>
  83. <li><tt class="docutils literal"><span class="pre">cm_clear</span></tt>: Executes a <tt class="docutils literal"><span class="pre">clear()</span></tt> operation after
  84. synchronizing, eliminating all ghost cells.</li>
  85. </ul>
  86. </blockquote>
  87. <p>There are several common combinations of flags that result in
  88. interesting consistency models. Some of these combinations are:</p>
  89. <blockquote>
  90. <ul class="simple">
  91. <li><tt class="docutils literal"><span class="pre">cm_forward</span></tt>: By itself, the forward consistency model enables
  92. algorithms such as <a class="reference external" href="dijkstra_shortest_paths.html">Dijkstra's shortest paths</a> and
  93. <a class="reference external" href="breadth_first_search.html">Breadth-First Search</a> to operate correctly.</li>
  94. <li><tt class="docutils literal"><span class="pre">cm_flush</span> <span class="pre">&amp;</span> <span class="pre">cm_reset</span></tt>: All updates values are queued locally,
  95. then flushed during the synchronization step. Once the flush has
  96. occurred, the ghost cells are restored to their default
  97. values. This consistency model is used by the <a class="reference external" href="page_rank.html">PageRank</a>
  98. implementation to locally accumulate rank for each node.</li>
  99. </ul>
  100. </blockquote>
  101. </div>
  102. <div class="section" id="reduction-operation">
  103. <h1>Reduction operation</h1>
  104. <p>The reduction operation maintains consistency by determining how
  105. multiple writes to a property map are resolved and what the property
  106. map should do if unknown values are requested. More specifically, a
  107. reduction operation is used in two cases:</p>
  108. <blockquote>
  109. <ol class="arabic simple">
  110. <li>When a value is needed for a remote key but no value is
  111. immediately available, the reduction operation provides a
  112. suitable default. For instance, a distributed property map
  113. storing distances may have a reduction operation that returns
  114. an infinite value as the default, whereas a distributed
  115. property map for vertex colors may return white as the
  116. default.</li>
  117. <li>When a value is received from a remote process, the process
  118. owning the key associated with that value must determine which
  119. value---the locally stored value, the value received from a
  120. remote process, or some combination of the two---will be
  121. stored as the &quot;official&quot; value in the property map. The
  122. reduction operation transforms the local and remote values
  123. into the &quot;official&quot; value to be stored.</li>
  124. </ol>
  125. </blockquote>
  126. <p>The reduction operation of a distributed property map can be set with
  127. the <tt class="docutils literal"><span class="pre">set_reduce</span></tt> method of <tt class="docutils literal"><span class="pre">distributed_property_map</span></tt>. The reduce
  128. operation is a function object with two signatures. The first
  129. signature takes a (remote) key and returns a default value for it,
  130. whereas the second signatures takes a key and two values (local first,
  131. then remote) and will return the combined value that will be stored in
  132. the local property map. Reduction operations must also contain a
  133. static constant <tt class="docutils literal"><span class="pre">non_default_resolver&quot;,</span> <span class="pre">which</span> <span class="pre">states</span> <span class="pre">whether</span> <span class="pre">the</span>
  134. <span class="pre">reduction</span> <span class="pre">operation's</span> <span class="pre">default</span> <span class="pre">value</span> <span class="pre">actually</span> <span class="pre">acts</span> <span class="pre">like</span> <span class="pre">a</span> <span class="pre">default</span>
  135. <span class="pre">value.</span> <span class="pre">It</span> <span class="pre">should</span> <span class="pre">be</span> <span class="pre">``true</span></tt> when the default is meaningful (e.g.,
  136. infinity for a distance) and <tt class="docutils literal"><span class="pre">false</span></tt> when the default should not be
  137. used.</p>
  138. <p>The following reduction operation is used by the distributed PageRank
  139. algorithm. The default rank for a remote node is 0. Rank is
  140. accumulated locally, and then the reduction operation combines local
  141. and remote values by adding them. Combined with a consistency model
  142. that flushes all values to the owner and then resets the values
  143. locally in each step, the resulting property map will compute partial
  144. sums on each processor and then accumulate the results on the owning
  145. processor. The PageRank reduction operation is defined as follows.</p>
  146. <pre class="literal-block">
  147. template&lt;typename T&gt;
  148. struct rank_accumulate_reducer {
  149. static const bool non_default_resolver = true;
  150. // The default rank of an unknown node
  151. template&lt;typename K&gt;
  152. T operator()(const K&amp;) const { return T(0); }
  153. template&lt;typename K&gt;
  154. T operator()(const K&amp;, const T&amp; x, const T&amp; y) const { return x + y; }
  155. };
  156. </pre>
  157. </div>
  158. <div class="section" id="distributed-property-map-adaptor">
  159. <h1>Distributed property map adaptor</h1>
  160. <p>The distributed property map adaptor creates a distributed property
  161. map from a local property map, a <a class="reference external" href="process_group.html">process group</a> over which
  162. distribution should occur, and a <a class="reference external" href="GlobalDescriptor.html">global descriptor</a> type that
  163. indexes the distributed property map.</p>
  164. <div class="section" id="synopsis">
  165. <h2>Synopsis</h2>
  166. <pre class="literal-block">
  167. template&lt;typename ProcessGroup, typename LocalPropertyMap, typename Key,
  168. typename GhostCellS = gc_mapS&gt;
  169. class distributed_property_map
  170. {
  171. public:
  172. typedef ... ghost_regions_type;
  173. distributed_property_map();
  174. distributed_property_map(const ProcessGroup&amp; pg,
  175. const LocalPropertyMap&amp; pm);
  176. template&lt;typename Reduce&gt;
  177. distributed_property_map(const ProcessGroup&amp; pg,
  178. const LocalPropertyMap&amp; pm,
  179. const Reduce&amp; reduce);
  180. template&lt;typename Reduce&gt; void set_reduce(const Reduce&amp; reduce);
  181. void set_consistency_model(int model);
  182. void flush();
  183. void reset();
  184. void clear();
  185. };
  186. reference get(distributed_property_map pm, const key_type&amp; key);
  187. void
  188. put(distributed_property_map pm, const key_type&amp; key, const value_type&amp; value);
  189. local_put(distributed_property_map pm, const key_type&amp; key, const value_type&amp; value);
  190. void request(distributed_property_map pm, const key_type&amp; key);
  191. void synchronize(distributed_property_map&amp; pm);
  192. template&lt;typename Key, typename ProcessGroup, typename LocalPropertyMap&gt;
  193. distributed_property_map&lt;ProcessGroup, LocalPropertyMap, Key&gt;
  194. make_distributed_property_map(const ProcessGroup&amp; pg, LocalPropertyMap pmap);
  195. template&lt;typename Key, typename ProcessGroup, typename LocalPropertyMap,
  196. typename Reduce&gt;
  197. distributed_property_map&lt;ProcessGroup, LocalPropertyMap, Key&gt;
  198. make_distributed_property_map(const ProcessGroup&amp; pg, LocalPropertyMap pmap,
  199. Reduce reduce);
  200. </pre>
  201. </div>
  202. <div class="section" id="template-parameters">
  203. <h2>Template parameters</h2>
  204. <dl class="docutils">
  205. <dt><strong>ProcessGroup</strong>:</dt>
  206. <dd>The type of the process group over which the
  207. property map is distributed and is also the medium for
  208. communication.</dd>
  209. <dt><strong>LocalPropertyMap</strong>:</dt>
  210. <dd>The type of the property map that will store values
  211. for keys local to this processor. The <tt class="docutils literal"><span class="pre">value_type</span></tt> of this
  212. property map will become the <tt class="docutils literal"><span class="pre">value_type</span></tt> of the distributed
  213. property map. The distributed property map models the same property
  214. map concepts as the <tt class="docutils literal"><span class="pre">LocalPropertyMap</span></tt>, with one exception: a
  215. distributed property map cannot be an <a class="reference external" href="http://www.boost.org/libs/property_map/LvaluePropertyMap.html">Lvalue Property Map</a>
  216. (because remote values are not addressable), and is therefore
  217. limited to <a class="reference external" href="http://www.boost.org/libs/property_map/ReadWritePropertyMap.html">Read/Write Property Map</a>.</dd>
  218. <dt><strong>Key</strong>:</dt>
  219. <dd>The <tt class="docutils literal"><span class="pre">key_type</span></tt> of the distributed property map, which
  220. must model the <a class="reference external" href="GlobalDescriptor.html">Global Descriptor</a> concept. The process ID type of
  221. the <tt class="docutils literal"><span class="pre">Key</span></tt> parameter must match the process ID type of the
  222. <tt class="docutils literal"><span class="pre">ProcessGroup</span></tt>, and the local descriptor type of the <tt class="docutils literal"><span class="pre">Key</span></tt> must
  223. be convertible to the <tt class="docutils literal"><span class="pre">key_type</span></tt> of the <tt class="docutils literal"><span class="pre">LocalPropertyMap</span></tt>.</dd>
  224. <dt><strong>GhostCellS</strong>:</dt>
  225. <dd><p class="first">A selector type that indicates how ghost cells should be stored in
  226. the distributed property map. There are either two or three
  227. options, depending on your compiler:</p>
  228. <blockquote class="last">
  229. <ul class="simple">
  230. <li><tt class="docutils literal"><span class="pre">boost::parallel::gc_mapS</span></tt> (default): Uses an STL <tt class="docutils literal"><span class="pre">map</span></tt> to
  231. store the ghost cells for each process.</li>
  232. <li><tt class="docutils literal"><span class="pre">boost::parallel::gc_vector_mapS</span></tt>: Uses a sorted STL
  233. <tt class="docutils literal"><span class="pre">vector</span></tt> to store the ghost cells for each process. This
  234. option works well when there are likely to be few insertions
  235. into the ghost cells; for instance, if the only ghost cells used
  236. are for neighboring vertices, the property map can be
  237. initialized with cells for each neighboring vertex, providing
  238. faster lookups than a <tt class="docutils literal"><span class="pre">map</span></tt> and using less space.</li>
  239. <li><tt class="docutils literal"><span class="pre">boost::parallel::gc_hash_mapS</span></tt>: Uses the GCC <tt class="docutils literal"><span class="pre">hash_map</span></tt> to
  240. store ghost cells. This option may improve performance over
  241. <tt class="docutils literal"><span class="pre">map</span></tt> for large problems sizes, where the set of ghost cells
  242. cannot be predetermined.</li>
  243. </ul>
  244. </blockquote>
  245. </dd>
  246. </dl>
  247. </div>
  248. <div class="section" id="member-functions">
  249. <h2>Member functions</h2>
  250. <pre class="literal-block">
  251. distributed_property_map();
  252. </pre>
  253. <p>Default-construct a distributed property map. The property map is in
  254. an invalid state, and may only be used if it is reassigned to a valid
  255. property map.</p>
  256. <hr class="docutils" />
  257. <pre class="literal-block">
  258. distributed_property_map(const ProcessGroup&amp; pg,
  259. const LocalPropertyMap&amp; pm);
  260. template&lt;typename Reduce&gt;
  261. distributed_property_map(const ProcessGroup&amp; pg,
  262. const LocalPropertyMap&amp; pm,
  263. const Reduce&amp; reduce);
  264. </pre>
  265. <p>Construct a property map from a process group and a local property
  266. map. If a <tt class="docutils literal"><span class="pre">reduce</span></tt> operation is not supplied, a default of
  267. <tt class="docutils literal"><span class="pre">basic_reduce&lt;value_type&gt;</span></tt> will be used.</p>
  268. <hr class="docutils" />
  269. <pre class="literal-block">
  270. template&lt;typename Reduce&gt; void set_reduce(const Reduce&amp; reduce);
  271. </pre>
  272. <p>Replace the current reduction operation with the new operation
  273. <tt class="docutils literal"><span class="pre">reduce</span></tt>.</p>
  274. <hr class="docutils" />
  275. <pre class="literal-block">
  276. void set_consistency_model(int model);
  277. </pre>
  278. <p>Sets the consistency model of the distributed property map, which will
  279. take effect on the next synchronization step. See the section
  280. <a class="reference internal" href="#consistency-models">Consistency models</a> for a description of the effect of various
  281. consistency model flags.</p>
  282. <hr class="docutils" />
  283. <pre class="literal-block">
  284. void flush();
  285. </pre>
  286. <p>Emits a message sending the contents of all local ghost cells to the
  287. owners of those cells.</p>
  288. <hr class="docutils" />
  289. <pre class="literal-block">
  290. void reset();
  291. </pre>
  292. <p>Replaces the values stored in each of the ghost cells with the default
  293. value generated by the reduction operation.</p>
  294. <hr class="docutils" />
  295. <pre class="literal-block">
  296. void clear();
  297. </pre>
  298. <p>Removes all ghost cells from the property map.</p>
  299. </div>
  300. <div class="section" id="free-functions">
  301. <h2>Free functions</h2>
  302. <pre class="literal-block">
  303. reference get(distributed_property_map pm, const key_type&amp; key);
  304. </pre>
  305. <p>Retrieves the element in <tt class="docutils literal"><span class="pre">pm</span></tt> associated with the given <tt class="docutils literal"><span class="pre">key</span></tt>. If
  306. the key refers to data stored locally, returns the actual value
  307. associated with the key. If the key refers to nonlocal data, returns
  308. the value of the ghost cell. If no ghost cell exists, the behavior
  309. depends on the current reduction operation: if a reduction operation
  310. has been set and has <tt class="docutils literal"><span class="pre">non_default_resolver</span></tt> set <tt class="docutils literal"><span class="pre">true</span></tt>, then a
  311. ghost cell will be created according to the default value provided by
  312. the reduction operation. Otherwise, the call to <tt class="docutils literal"><span class="pre">get</span></tt> will abort
  313. because no value exists for this remote cell. To avoid this problem,
  314. either set a reduction operation that generates default values,
  315. <tt class="docutils literal"><span class="pre">request()</span></tt> the value and then perform a synchronization step, or
  316. <tt class="docutils literal"><span class="pre">put</span></tt> a value into the cell before reading it.</p>
  317. <hr class="docutils" />
  318. <pre class="literal-block">
  319. void
  320. put(distributed_property_map pm, const key_type&amp; key, const value_type&amp; value);
  321. </pre>
  322. <p>Places the given <tt class="docutils literal"><span class="pre">value</span></tt> associated with <tt class="docutils literal"><span class="pre">key</span></tt> into property map
  323. <tt class="docutils literal"><span class="pre">pm</span></tt>. If the key refers to data stored locally, the value is
  324. immediately updates. If the key refers to data stored in a remote
  325. process, updates (or creates) a local ghost cell containing this
  326. value for the key and sends the new value to the owning process. Note
  327. that the owning process may reject this value based on the reduction
  328. operation, but this will not be detected until the next
  329. synchronization step.</p>
  330. <hr class="docutils" />
  331. <pre class="literal-block">
  332. void
  333. local_put(distributed_property_map pm, const key_type&amp; key, const value_type&amp; value);
  334. </pre>
  335. <p>Equivalent to <tt class="docutils literal"><span class="pre">put(pm,</span> <span class="pre">key,</span> <span class="pre">value)</span></tt>, except that no message is sent
  336. to the owning process when the value is changed for a nonlocal key.</p>
  337. <hr class="docutils" />
  338. <pre class="literal-block">
  339. void synchronize(distributed_property_map&amp; pm);
  340. </pre>
  341. <p>Synchronize the values stored in the distributed property maps. Each
  342. process much execute <tt class="docutils literal"><span class="pre">synchronize</span></tt> at the same time, after which
  343. the ghost cells in every process will reflect the actual value stored
  344. in the owning process.</p>
  345. <hr class="docutils" />
  346. <pre class="literal-block">
  347. void request(distributed_property_map pm, const key_type&amp; key);
  348. </pre>
  349. <p>Request that the element &quot;key&quot; be available after the next
  350. synchronization step. For a non-local key, this means establishing a
  351. ghost cell and requesting.</p>
  352. <hr class="docutils" />
  353. <pre class="literal-block">
  354. template&lt;typename Key, typename ProcessGroup, typename LocalPropertyMap&gt;
  355. distributed_property_map&lt;ProcessGroup, LocalPropertyMap, Key&gt;
  356. make_distributed_property_map(const ProcessGroup&amp; pg, LocalPropertyMap pmap);
  357. template&lt;typename Key, typename ProcessGroup, typename LocalPropertyMap,
  358. typename Reduce&gt;
  359. distributed_property_map&lt;ProcessGroup, LocalPropertyMap, Key&gt;
  360. make_distributed_property_map(const ProcessGroup&amp; pg, LocalPropertyMap pmap,
  361. Reduce reduce);
  362. </pre>
  363. <p>Create a distributed property map over process group <tt class="docutils literal"><span class="pre">pg</span></tt> and local
  364. property map <tt class="docutils literal"><span class="pre">pmap</span></tt>. A default reduction operation will be generated
  365. if it is not provided.</p>
  366. </div>
  367. </div>
  368. <div class="section" id="distributed-iterator-property-map">
  369. <h1>Distributed iterator property map</h1>
  370. <p>The distributed iterator property map adaptor permits the creation of
  371. distributed property maps from random access iterators using the same
  372. syntax as non-distributed iterator property maps. The specialization
  373. is based on a <a class="reference internal" href="#local-property-map">local property map</a>, which contains the
  374. indices for local descriptors and is typically returned to describe
  375. the vertex indices of a distributed graph.</p>
  376. <div class="section" id="id1">
  377. <h2>Synopsis</h2>
  378. <pre class="literal-block">
  379. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  380. typename GlobalKey, typename LocalMap, typename ValueType,
  381. typename Reference&gt;
  382. class iterator_property_map&lt;RandomAccessIterator,
  383. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  384. ValueType, Reference&gt;
  385. {
  386. public:
  387. typedef local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt; index_map_type;
  388. iterator_property_map();
  389. iterator_property_map(RandomAccessIterator iter, const index_map_type&amp; id);
  390. };
  391. reference get(iterator_property_map pm, const key_type&amp; key);
  392. void put(iterator_property_map pm, const key_type&amp; key, const value_type&amp; value);
  393. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  394. typename GlobalKey, typename LocalMap&gt;
  395. iterator_property_map&lt;RandomAccessIterator,
  396. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt; &gt;
  397. make_iterator_property_map(RandomAccessIterator iter,
  398. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt; id);
  399. </pre>
  400. </div>
  401. <div class="section" id="id2">
  402. <h2>Member functions</h2>
  403. <pre class="literal-block">
  404. iterator_property_map();
  405. </pre>
  406. <p>Default-constructs a distributed iterator property map. The property
  407. map is in an invalid state, and must be reassigned before it may be
  408. used.</p>
  409. <hr class="docutils" />
  410. <pre class="literal-block">
  411. iterator_property_map(RandomAccessIterator iter, const index_map_type&amp; id);
  412. </pre>
  413. <p>Constructs a distributed iterator property map using the property map
  414. <tt class="docutils literal"><span class="pre">id</span></tt> to map global descriptors to local indices. The random access
  415. iterator sequence <tt class="docutils literal"><span class="pre">[iter,</span> <span class="pre">iter</span> <span class="pre">+</span> <span class="pre">n)</span></tt> must be a valid range, where
  416. <tt class="docutils literal"><span class="pre">[0,</span> <span class="pre">n)</span></tt> is the range of local indices.</p>
  417. </div>
  418. <div class="section" id="id3">
  419. <h2>Free functions</h2>
  420. <pre class="literal-block">
  421. reference get(iterator_property_map pm, const key_type&amp; key);
  422. </pre>
  423. <p>Returns the value associated with the given <tt class="docutils literal"><span class="pre">key</span></tt> from the
  424. distributed property map.</p>
  425. <hr class="docutils" />
  426. <pre class="literal-block">
  427. void put(iterator_property_map pm, const key_type&amp; key, const value_type&amp; value);
  428. </pre>
  429. <p>Associates the value with the given key in the distributed property map.</p>
  430. <hr class="docutils" />
  431. <pre class="literal-block">
  432. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  433. typename GlobalKey, typename LocalMap, typename ValueType,
  434. typename Reference&gt;
  435. iterator_property_map&lt;RandomAccessIterator,
  436. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  437. ValueType, Reference&gt;
  438. make_iterator_property_map(RandomAccessIterator iter,
  439. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  440. ValueType, Reference&gt; id);
  441. </pre>
  442. <p>Creates a distributed iterator property map using the given iterator
  443. <tt class="docutils literal"><span class="pre">iter</span></tt> and local index property map <tt class="docutils literal"><span class="pre">id</span></tt>.</p>
  444. </div>
  445. </div>
  446. <div class="section" id="distributed-safe-iterator-property-map">
  447. <h1>Distributed safe iterator property map</h1>
  448. <p>The distributed safe iterator property map adaptor permits the
  449. creation of distributed property maps from random access iterators
  450. using the same syntax as non-distributed safe iterator property
  451. maps. The specialization is based on a <a class="reference internal" href="#local-property-map">local property map</a>, which
  452. contains the indices for local descriptors and is typically returned
  453. to describe the vertex indices of a distributed graph. Safe iterator
  454. property maps check the indices of accesses to ensure that they are
  455. not out-of-bounds before attempting to access an value.</p>
  456. <div class="section" id="id4">
  457. <h2>Synopsis</h2>
  458. <pre class="literal-block">
  459. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  460. typename GlobalKey, typename LocalMap, typename ValueType,
  461. typename Reference&gt;
  462. class safe_iterator_property_map&lt;RandomAccessIterator,
  463. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  464. ValueType, Reference&gt;
  465. {
  466. public:
  467. typedef local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt; index_map_type;
  468. safe_iterator_property_map();
  469. safe_iterator_property_map(RandomAccessIterator iter, std::size_t n,
  470. const index_map_type&amp; id);
  471. };
  472. reference get(safe_iterator_property_map pm, const key_type&amp; key);
  473. void put(safe_iterator_property_map pm, const key_type&amp; key, const value_type&amp; value);
  474. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  475. typename GlobalKey, typename LocalMap, typename ValueType,
  476. typename Reference&gt;
  477. safe_iterator_property_map&lt;RandomAccessIterator,
  478. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  479. ValueType, Reference&gt;
  480. make_safe_iterator_property_map(RandomAccessIterator iter,
  481. std::size_t n,
  482. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  483. ValueType, Reference&gt; id);
  484. </pre>
  485. </div>
  486. <div class="section" id="id5">
  487. <h2>Member functions</h2>
  488. <pre class="literal-block">
  489. safe_iterator_property_map();
  490. </pre>
  491. <p>Default-constructs a distributed safe iterator property map. The property
  492. map is in an invalid state, and must be reassigned before it may be
  493. used.</p>
  494. <hr class="docutils" />
  495. <pre class="literal-block">
  496. safe_iterator_property_map(RandomAccessIterator iter, std::size_t n,
  497. const index_map_type&amp; id);
  498. </pre>
  499. <p>Constructs a distributed safe iterator property map using the property map
  500. <tt class="docutils literal"><span class="pre">id</span></tt> to map global descriptors to local indices. The random access
  501. iterator sequence <tt class="docutils literal"><span class="pre">[iter,</span> <span class="pre">iter</span> <span class="pre">+</span> <span class="pre">n)</span></tt>.</p>
  502. </div>
  503. <div class="section" id="id6">
  504. <h2>Free functions</h2>
  505. <pre class="literal-block">
  506. reference get(safe_iterator_property_map pm, const key_type&amp; key);
  507. </pre>
  508. <p>Returns the value associated with the given <tt class="docutils literal"><span class="pre">key</span></tt> from the
  509. distributed property map.</p>
  510. <hr class="docutils" />
  511. <pre class="literal-block">
  512. void put(safe_iterator_property_map pm, const key_type&amp; key, const value_type&amp; value);
  513. </pre>
  514. <p>Associates the value with the given key in the distributed property map.</p>
  515. <hr class="docutils" />
  516. <pre class="literal-block">
  517. template&lt;typename RandomAccessIterator, typename ProcessGroup,
  518. typename GlobalKey, typename LocalMap, typename ValueType,
  519. typename Reference&gt;
  520. safe_iterator_property_map&lt;RandomAccessIterator,
  521. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  522. ValueType, Reference&gt;
  523. make_safe_iterator_property_map(RandomAccessIterator iter,
  524. std::size_t n,
  525. local_property_map&lt;ProcessGroup, GlobalKey, LocalMap&gt;,
  526. ValueType, Reference&gt; id);
  527. </pre>
  528. <p>Creates a distributed safe iterator property map using the given iterator
  529. <tt class="docutils literal"><span class="pre">iter</span></tt> and local index property map <tt class="docutils literal"><span class="pre">id</span></tt>. The indices in <tt class="docutils literal"><span class="pre">id</span></tt> must</p>
  530. </div>
  531. </div>
  532. <div class="section" id="local-property-map">
  533. <h1>Local property map</h1>
  534. <p>A property map adaptor that accesses an underlying property map whose
  535. key type is the local part of the <tt class="docutils literal"><span class="pre">Key</span></tt> type for the local subset
  536. of keys. Local property maps are typically used by distributed graph
  537. types for vertex index properties.</p>
  538. <div class="section" id="id7">
  539. <h2>Synopsis</h2>
  540. <pre class="literal-block">
  541. template&lt;typename ProcessGroup, typename GlobalKey, typename LocalMap&gt;
  542. class local_property_map
  543. {
  544. public:
  545. typedef typename property_traits&lt;LocalMap&gt;::value_type value_type;
  546. typedef GlobalKey key_type;
  547. typedef typename property_traits&lt;LocalMap&gt;::reference reference;
  548. typedef typename property_traits&lt;LocalMap&gt;::category category;
  549. explicit
  550. local_property_map(const ProcessGroup&amp; process_group = ProcessGroup(),
  551. const LocalMap&amp; local_map = LocalMap());
  552. reference operator[](const key_type&amp; key);
  553. };
  554. reference get(const local_property_map&amp; pm, key_type key);
  555. void put(local_property_map pm, const key_type&amp; key, const value_type&amp; value);
  556. </pre>
  557. </div>
  558. <div class="section" id="id8">
  559. <h2>Template parameters</h2>
  560. <table class="docutils field-list" frame="void" rules="none">
  561. <col class="field-name" />
  562. <col class="field-body" />
  563. <tbody valign="top">
  564. <tr class="field"><th class="field-name">ProcessGroup:</th><td class="field-body">the type of the process group over which the global
  565. keys are distributed.</td>
  566. </tr>
  567. <tr class="field"><th class="field-name">GlobalKey:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">key_type</span></tt> of the local property map, which
  568. must model the <a class="reference external" href="GlobalDescriptor.html">Global Descriptor</a> concept. The process ID type of
  569. the <tt class="docutils literal"><span class="pre">GlobalKey</span></tt> parameter must match the process ID type of the
  570. <tt class="docutils literal"><span class="pre">ProcessGroup</span></tt>, and the local descriptor type of the <tt class="docutils literal"><span class="pre">GlobalKey</span></tt>
  571. must be convertible to the <tt class="docutils literal"><span class="pre">key_type</span></tt> of the <tt class="docutils literal"><span class="pre">LocalMap</span></tt>.</td>
  572. </tr>
  573. <tr class="field"><th class="field-name">LocalMap:</th><td class="field-body">the type of the property map that will store values
  574. for keys local to this processor. The <tt class="docutils literal"><span class="pre">value_type</span></tt> of this
  575. property map will become the <tt class="docutils literal"><span class="pre">value_type</span></tt> of the local
  576. property map. The local property map models the same property
  577. map concepts as the <tt class="docutils literal"><span class="pre">LocalMap</span></tt>.</td>
  578. </tr>
  579. </tbody>
  580. </table>
  581. </div>
  582. <div class="section" id="id9">
  583. <h2>Member functions</h2>
  584. <pre class="literal-block">
  585. explicit
  586. local_property_map(const ProcessGroup&amp; process_group = ProcessGroup(),
  587. const LocalMap&amp; local_map = LocalMap());
  588. </pre>
  589. <p>Constructs a local property map whose keys are distributed across the
  590. given process group and which accesses the given local map.</p>
  591. <hr class="docutils" />
  592. <pre class="literal-block">
  593. reference operator[](const key_type&amp; key);
  594. </pre>
  595. <p>Access the value associated with the given key, which must be local
  596. to this process.</p>
  597. </div>
  598. <div class="section" id="id10">
  599. <h2>Free functions</h2>
  600. <pre class="literal-block">
  601. reference get(const local_property_map&amp; pm, key_type key);
  602. </pre>
  603. <p>Return the value associated with the given key, which must be local
  604. to this process.</p>
  605. <hr class="docutils" />
  606. <pre class="literal-block">
  607. void put(local_property_map pm, const key_type&amp; key, const value_type&amp; value);
  608. </pre>
  609. <p>Set the value associated with the given key, which must be local to
  610. this process.</p>
  611. <hr class="docutils" />
  612. <p>Copyright (C) 2004, 2005 The Trustees of Indiana University.</p>
  613. <p>Authors: Douglas Gregor and Andrew Lumsdaine</p>
  614. </div>
  615. </div>
  616. </div>
  617. <div class="footer">
  618. <hr class="footer" />
  619. Generated on: 2009-05-31 00:22 UTC.
  620. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  621. </div>
  622. </body>
  623. </html>