summaryrefslogtreecommitdiff
path: root/doc/html/boost/mpi/cartesian_communicator.html
blob: 8f5c6f2daba72069222ecd4c242d750359a2ca5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class cartesian_communicator</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp" title="Header &lt;boost/mpi/cartesian_communicator.hpp&gt;">
<link rel="prev" href="operator__1_3_27_7_2_2_1_4.html" title="Function template operator!=">
<link rel="next" href="cartesian_dimension.html" title="Struct cartesian_dimension">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="operator__1_3_27_7_2_2_1_4.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cartesian_dimension.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.mpi.cartesian_communicator"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class cartesian_communicator</span></h2>
<p>boost::mpi::cartesian_communicator &#8212; An MPI communicator with a cartesian topology. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp" title="Header &lt;boost/mpi/cartesian_communicator.hpp&gt;">boost/mpi/cartesian_communicator.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpi</span><span class="special">::</span><span class="identifier">communicator</span> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="cartesian_communicator.html#boost.mpi.cartesian_communicatorconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_5-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MPI_Comm</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">comm_create_kind</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_6-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="communicator.html" title="Class communicator">communicator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span><span class="special">,</span> 
                         <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_7-bb"><span class="identifier">cartesian_communicator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">&amp;</span><span class="special">,</span> 
                         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4-bb">public member functions</a></span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_1-bb"><span class="identifier">ndims</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_2-bb"><span class="identifier">rank</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_3-bb"><span class="identifier">shifted_ranks</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_4-bb"><span class="identifier">coordinates</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_5-bb"><span class="identifier">topology</span></a><span class="special">(</span><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_6-bb"><span class="identifier">topology</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">int</span> <a class="link" href="cartesian_communicator.html#id-1_3_27_7_3_2_1_1_4_7-bb"><span class="identifier">rank</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.27.7.4.4.4"></a><h2>Description</h2>
<p>A <code class="computeroutput"><a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a></code> is a communicator whose topology is expressed as a grid. Cartesian communicators have the same functionality as (intra)communicators, but also allow one to query the relationships among processes and the properties of the grid. </p>
<div class="refsect2">
<a name="id-1.3.27.7.4.4.4.3"></a><h3>
<a name="boost.mpi.cartesian_communicatorconstruct-copy-destruct"></a><code class="computeroutput">cartesian_communicator</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_27_7_3_2_1_1_5-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MPI_Comm</span> <span class="special">&amp;</span> comm<span class="special">,</span> <span class="identifier">comm_create_kind</span> kind<span class="special">)</span><span class="special">;</span></pre>
<p>Build a new Boost.MPI cartesian communicator based on the MPI communicator <code class="computeroutput">comm</code> with cartesian topology.</p>
<p><code class="computeroutput">comm</code> may be any valid MPI communicator. If <code class="computeroutput">comm</code> is MPI_COMM_NULL, an empty communicator (that cannot be used for communication) is created and the <code class="computeroutput">kind</code> parameter is ignored. Otherwise, the <code class="computeroutput">kind</code> parameter determines how the Boost.MPI communicator will be related to <code class="computeroutput">comm:</code> </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_duplicate</code>, duplicate <code class="computeroutput">comm</code> to create a new communicator. This new communicator will be freed when the Boost.MPI communicator (and all copies of it) is destroyed. This option is only permitted if the underlying MPI implementation supports MPI 2.0; duplication of intercommunicators is not available in MPI 1.x.</p></li>
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_take_ownership</code>, take ownership of <code class="computeroutput">comm</code>. It will be freed automatically when all of the Boost.MPI communicators go out of scope.</p></li>
<li class="listitem"><p>If <code class="computeroutput">kind</code> is <code class="computeroutput">comm_attach</code>, this Boost.MPI communicator will reference the existing MPI communicator <code class="computeroutput">comm</code> but will not free <code class="computeroutput">comm</code> when the Boost.MPI communicator goes out of scope. This option should only be used when the communicator is managed by the user. </p></li>
</ul></div>
<p>
</p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_27_7_3_2_1_1_6-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="communicator.html" title="Class communicator">communicator</a> <span class="special">&amp;</span> comm<span class="special">,</span> 
                       <span class="keyword">const</span> <a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span> dims<span class="special">,</span> <span class="keyword">bool</span> reorder <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span><span class="special">;</span></pre>
<p>Create a new communicator whose topology is described by the given cartesian. The indices of the vertices in the cartesian will be assumed to be the ranks of the processes within the communicator. There may be fewer vertices in the cartesian than there are processes in the communicator; in this case, the resulting communicator will be a NULL communicator.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">comm</code></span></p></td>
<td><p>The communicator that the new, cartesian communicator will be based on.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">dims</code></span></p></td>
<td><p>the cartesian dimension of the new communicator. The size indicate the number of dimension. Some dimensions be set to zero, in which case the corresponding dimension value is left to the system.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">reorder</code></span></p></td>
<td><p>Whether MPI is permitted to re-order the process ranks within the returned communicator, to better optimize communication. If false, the ranks of each process in the returned process will match precisely the rank of that process within the original communicator. </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_27_7_3_2_1_1_7-bb"></a><span class="identifier">cartesian_communicator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="cartesian_communicator.html" title="Class cartesian_communicator">cartesian_communicator</a> <span class="special">&amp;</span> comm<span class="special">,</span> 
                       <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> keep<span class="special">)</span><span class="special">;</span></pre>
<p>Create a new cartesian communicator whose topology is a subset of an existing cartesian cimmunicator. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">comm</code></span></p></td>
<td><p>the original communicator. </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">keep</code></span></p></td>
<td><p>and array containiing the dimension to keep from the existing communicator. </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.27.7.4.4.4.4"></a><h3>
<a name="id-1_3_27_7_3_2_1_1_4-bb"></a><code class="computeroutput">cartesian_communicator</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_27_7_3_2_1_1_4_1-bb"></a><span class="identifier">ndims</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrive the number of dimension of the underlying toppology. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_27_7_3_2_1_1_4_2-bb"></a><span class="identifier">rank</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> coords<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Return the rank of the process at the given coordinates. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">coords</code></span></p></td>
<td><p>the coordinates. the size must match the communicator's topology. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a name="id-1_3_27_7_3_2_1_1_4_3-bb"></a><span class="identifier">shifted_ranks</span><span class="special">(</span><span class="keyword">int</span> dim<span class="special">,</span> <span class="keyword">int</span> disp<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Return the rank of the source and target destination process through a shift. 
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">dim</code></span></p></td>
<td><p>the dimension in which the shift takes place. 0 &lt;= dim &lt;= ndim(). </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">disp</code></span></p></td>
<td><p>the shift displacement, can be positive (upward) or negative (downward). </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <a name="id-1_3_27_7_3_2_1_1_4_4-bb"></a><span class="identifier">coordinates</span><span class="special">(</span><span class="keyword">int</span> rk<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Provides the coordinates of the process with the given rank. 

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">rk</code></span></p></td>
<td><p>the ranks in this communicator. </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>the coordinates. </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_27_7_3_2_1_1_4_5-bb"></a><span class="identifier">topology</span><span class="special">(</span><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <span class="special">&amp;</span> dims<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&amp;</span> coords<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrieve the topology and coordinates of this process in the grid. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="cartesian_topology.html" title="Class cartesian_topology">cartesian_topology</a> <a name="id-1_3_27_7_3_2_1_1_4_6-bb"></a><span class="identifier">topology</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Retrieve the topology of the grid. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">int</span> <a name="id-1_3_27_7_3_2_1_1_4_7-bb"></a><span class="identifier">rank</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Determine the rank of the executing process in a communicator. <p>This routine is equivalent to <code class="computeroutput">MPI_Comm_rank</code>.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The rank of the process in the communicator, which will be a value in [0, size()) </p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2005-2007 Douglas Gregor,
      Matthias Troyer, Trustees of Indiana University<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at &lt;ulink url="http://www.boost.org/LICENSE_1_0.txt"&gt;
        http://www.boost.org/LICENSE_1_0.txt &lt;/ulink&gt;)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="operator__1_3_27_7_2_2_1_4.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../mpi/reference.html#header.boost.mpi.cartesian_communicator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cartesian_dimension.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>