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
|
<a name="Module:Scientific.MPI"><h1>Module Scientific.MPI</h1></a>
<p>This module contains a Python interface to the Message Passing
Interface (MPI), and standardized library for message-passing parallel
computing. Please read an introduction to MPI before using this
module; some terms in the documentation do not make much sense unless
you understand the principles of MPI.</p>
<p>This module contains only one object, <tt>world</tt>, which represents the
default communicator in MPI. This communicator can be used directly
for sending and receiving data, or other communicators can be
derived from it.
</p>
<h1>Submodules:</h1>
<ul><li><a href="Scientific_24.html">Module Scientific.MPI.IO</a></ul>
<hr width=70%>
<a name="Class:Scientific.MPI.MPICommunicator"><h2>Class MPICommunicator: MPI Communicator</h2></a>
<p>There is no constructor for MPI Communicator objects. The
default communicator is given by Scientific.MPI.world, and
other communicators can only be created by methods on an
existing communicator object.</p>
<p>A communicator object has two read-only attributes: <tt>rank</tt> is
an integer which indicates the rank of the current process in
the communicator, and <tt>size</tt> is an integer equal to the number
of processes that participate in the communicator.
</p>
<b>Methods:</b><br>
<ul>
<li> <b><i>duplicate</i></b>()
<p>Returns a new communicator object with the same properties
as the original one.</p>
<li> <b><i>send</i></b>(<i>data</i>, <i>destination</i>, <i>tag</i>)
<p>Sends the contents of <i>data</i> (a string or any contiguous NumPy
array except for general object arrays) to the processor
whose rank is <i>destination</i>, using <i>tag</i> as an identifier.
</p>
<li> <b><i>receive</i></b>(<i>data</i>, <i>source</i>=<tt>None</tt>, <i>tag</i>=<tt>None</tt>)
<p>Receives an array from the process with rank <i>source</i>
with identifier <i>tag</i>. The default <i>source</i>=None means
that messages from any process are accepted. The value
of <i>data</i> can either be an array object, in which case it
must be contiguous and large enough to store the
incoming data; it must also have the correct shape.
Alternatively, <i>data</i> can be a string specifying
the data type (in practice, one would use Numeric.Int,
Numeric.Float, etc.). In the latter case, a new array
object is created to receive the data.</p>
<p>The return value is a tuple containing four elements:
the array containing the data, the source process rank
(an integer), the message tag (an integer), and the
number of elements that were received (an integer).
</p>
<li> <b><i>receiveString</i></b>(<i>source</i>=<tt>None</tt>, <i>tag</i>=<tt>None</tt>)
<p>Receives a string from the process with rank <i>source</i>
with identifier <i>tag</i>. The default <i>source</i>=None means
that messages from any process are accepted.</p>
<p>The return value is a tuple containing three elements:
the string containing the data, the source process rank
(an integer), and the message tag (an integer).
</p>
<li> <b><i>broadcast</i></b>(<i>array</i>, <i>root</i>)
<p>Sends data from the process with rank <i>root</i> to all
processes (including <i>root</i>). The parameter <i>array</i> can be
any contiguous NumPy array except for general object arrays.
On the process <i>root</i>, it holds the data to be sent. After
the call, the data in <i>array</i> is the same for all processors.
The shape and data type of <i>array</i> must be the same in
all processes.
</p>
<li> <b><i>share</i></b>(<i>send</i>, <i>receive</i>)
<p>Distributes data from each process to all other processes
in the communicator. The array <i>send</i> (any contiguous NumPy
array except for general object arrays) contains the data
to be sent by each process, the shape and data type must be
identical in all processes. The array <i>receive</i> must have
the same data type as <i>send</i> and one additional dimension
(the first one), whose length must be the number of processes
in the communicator. After the call, the value
of |receive|[i] is equal to the contents of the array <i>send</i>
in process i.
</p>
<li> <b><i>barrier</i></b>()
<p>Waits until all processes in the communicator have
called the same method, then all processes continue.</p>
</ul>
<hr width=70%>
<a name="Class:Scientific.MPI.MPIError"><h2>Class MPIError: MPI call failed</h2></a>
|