Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > be0974b2b8ed02af93714b256a53dd30 > files > 212

mpi4py-docs-1.2.2-6.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Design and Interface Overview &mdash; MPI for Python v1.2.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.2.2',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="MPI for Python v1.2.2 documentation" href="index.html" />
    <link rel="next" title="Installation" href="install.html" />
    <link rel="prev" title="Introduction" href="intro.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="install.html" title="Installation"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="intro.html" title="Introduction"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">MPI for Python v1.2.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="design-and-interface-overview">
<h1>Design and Interface Overview<a class="headerlink" href="#design-and-interface-overview" title="Permalink to this headline">¶</a></h1>
<p>MPI for Python provides an object oriented approach to message passing
which grounds on the standard MPI-2 C++ bindings. The interface was
designed with focus in translating MPI syntax and semantics of
standard MPI-2 bindings for C++ to Python. Any user of the standard
C/C++ MPI bindings should be able to use this module without need of
learning a new interface.</p>
<div class="section" id="communicating-python-objects-and-array-data">
<h2>Communicating Python Objects and Array Data<a class="headerlink" href="#communicating-python-objects-and-array-data" title="Permalink to this headline">¶</a></h2>
<p>The Python standard library supports different mechanisms for data
persistence. Many of them rely on disk storage, but <em>pickling</em> and
<em>marshaling</em> can also work with memory buffers.</p>
<p>The <tt class="xref docutils literal"><span class="pre">pickle</span></tt> (slower, written in pure Python) and <tt class="xref docutils literal"><span class="pre">cPickle</span></tt>
(faster, written in C) modules provide user-extensible facilities to
serialize general Python objects using ASCII or binary formats. The
<tt class="xref docutils literal"><span class="pre">marshal</span></tt> module provides facilities to serialize built-in Python
objects using a binary format specific to Python, but independent of
machine architecture issues.</p>
<p><em>MPI for Python</em> can communicate any built-in or used-defined Python
object taking advantage of the features provided by the
mod:<cite>pickle</cite>/<tt class="xref docutils literal"><span class="pre">cPickle</span></tt> modules. These facilities will be
routinely used to build binary representations of objects to
communicate (at sending processes), and restoring them back (at
receiving processes).</p>
<p>Although simple and general, the serialization approach (i.e.,
<em>pickling</em> and <em>unpickling</em>) previously discussed imposes important
overheads in memory as well as processor usage, especially in the
scenario of objects with large memory footprints being
communicated. Pickling general Python objects, ranging from primitive
or container built-in types to user-defined classes, necessarily
requires computer resources.  Processing is also needed for
dispatching the appropriate serialization method (that depends on the
type of the object) and doing the actual packing. Additional memory is
always needed, and if its total amount in not known <em>a priori</em>, many
reallocations can occur.  Indeed, in the case of large numeric arrays,
this is certainly unacceptable and precludes communication of objects
occupying half or more of the available memory resources.</p>
<p><em>MPI for Python</em> supports direct communication of any object exporting
the single-segment buffer interface. This interface is a standard
Python mechanism provided by some types (e.g., strings and numeric
arrays), allowing access in the C side to a contiguous memory buffer
(i.e., address and length) containing the relevant data. This feature,
in conjunction with the capability of constructing user-defined MPI
datatypes describing complicated memory layouts, enables the
implementation of many algorithms involving multidimensional numeric
arrays (e.g., image processing, fast Fourier transforms, finite
difference schemes on structured Cartesian grids) directly in Python,
with negligible overhead, and almost as fast as compiled Fortran, C,
or C++ codes.</p>
</div>
<div class="section" id="communicators">
<h2>Communicators<a class="headerlink" href="#communicators" title="Permalink to this headline">¶</a></h2>
<p>In <em>MPI for Python</em>, <tt class="xref docutils literal"><span class="pre">Comm</span></tt> is the base class of
communicators.  Communicator size and calling process rank can be
respectively obtained with methods <tt class="xref docutils literal"><span class="pre">Get_size()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Get_rank()</span></tt>.</p>
<p>The <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> and <tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> classes are sublcasses
of the <tt class="xref docutils literal"><span class="pre">Comm</span></tt> class.  The <tt class="xref docutils literal"><span class="pre">Is_inter()</span></tt> method (and
<tt class="xref docutils literal"><span class="pre">Is_intra()</span></tt>, provided for convenience, it is not part of the MPI
specification) is defined for communicator objects and can be used to
determine the particular communicator class.</p>
<p>The two predefined intracommunicator instances are available:
<tt class="xref docutils literal"><span class="pre">COMM_WORLD</span></tt> and <tt class="xref docutils literal"><span class="pre">COMM_SELF</span></tt>.  From them, new
communicators can be created as needed.</p>
<p>New communicator instances can be obtained with the <tt class="xref docutils literal"><span class="pre">Clone()</span></tt>
method of <tt class="xref docutils literal"><span class="pre">Comm</span></tt> objects, the <tt class="xref docutils literal"><span class="pre">Dup()</span></tt> and <tt class="xref docutils literal"><span class="pre">Split()</span></tt>
methods of <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> and <tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> objects, and
methods <tt class="xref docutils literal"><span class="pre">Create_intercomm()</span></tt> and <tt class="xref docutils literal"><span class="pre">Merge()</span></tt> of
<tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> and <tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> objects respectively.</p>
<p>Virtual topologies (<tt class="xref docutils literal"><span class="pre">Cartcomm</span></tt> and <tt class="xref docutils literal"><span class="pre">Graphcomm</span></tt> classes,
both being a specialization of <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> class) are fully
supported. New instances can be obtained from intracommunicator
instances with factory methods <tt class="xref docutils literal"><span class="pre">Create_cart()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Create_graph()</span></tt> of <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> class.</p>
<p>The associated process group can be retrieved from a communicator by
calling the <tt class="xref docutils literal"><span class="pre">Get_group()</span></tt> method, which returns an instance of the
<tt class="xref docutils literal"><span class="pre">Group</span></tt> class. Set operations with <tt class="xref docutils literal"><span class="pre">Group</span></tt> objects like
like <tt class="xref docutils literal"><span class="pre">Union()</span></tt>, <tt class="xref docutils literal"><span class="pre">Intersect()</span></tt> and <tt class="xref docutils literal"><span class="pre">Difference()</span></tt> are fully
supported, as well as the creation of new communicators from these
groups.</p>
</div>
<div class="section" id="point-to-point-communications">
<h2>Point-to-Point Communications<a class="headerlink" href="#point-to-point-communications" title="Permalink to this headline">¶</a></h2>
<p>Point to point communication is a fundamental capability of massage
passing systems. This mechanism enables the transmittal of data
between a pair of processes, one side sending, the other, receiving.</p>
<p>MPI provides a set of <em>send</em> and <em>receive</em> functions allowing the
communication of <em>typed</em> data with an associated <em>tag</em>.  The type
information enables the conversion of data representation from one
architecture to another in the case of heterogeneous computing
environments; additionally, it allows the representation of
non-contiguous data layouts and user-defined datatypes, thus avoiding
the overhead of (otherwise unavoidable) packing/unpacking
operations. The tag information allows selectivity of messages at the
receiving end.</p>
<div class="section" id="blocking-communications">
<h3>Blocking Communications<a class="headerlink" href="#blocking-communications" title="Permalink to this headline">¶</a></h3>
<p>MPI provides basic send and receive functions that are <em>blocking</em>.
These functions block the caller until the data buffers involved in
the communication can be safely reused by the application program.</p>
<p>In <em>MPI for Python</em>, the <tt class="xref docutils literal"><span class="pre">Send()</span></tt>, <tt class="xref docutils literal"><span class="pre">Recv()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Sendrecv()</span></tt> methods of communicator objects provide support for
blocking point-to-point communications within <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> and
<tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> instances. These methods can communicate memory
buffers. The variants <tt class="xref docutils literal"><span class="pre">send()</span></tt>, <tt class="xref docutils literal"><span class="pre">recv()</span></tt> and <tt class="xref docutils literal"><span class="pre">sendrecv()</span></tt>
can communicate general Python objects.</p>
</div>
<div class="section" id="nonblocking-communications">
<h3>Nonblocking Communications<a class="headerlink" href="#nonblocking-communications" title="Permalink to this headline">¶</a></h3>
<p>On many systems, performance can be significantly increased by
overlapping communication and computation. This is particularly true
on systems where communication can be executed autonomously by an
intelligent, dedicated communication controller.</p>
<p>MPI provides <em>nonblocking</em> send and receive functions. They allow the
possible overlap of communication and computation.  Non-blocking
communication always come in two parts: posting functions, which begin
the requested operation; and test-for-completion functions, which
allow to discover whether the requested operation has completed.</p>
<p>In <em>MPI for Python</em>, the <tt class="xref docutils literal"><span class="pre">Isend()</span></tt> and <tt class="xref docutils literal"><span class="pre">Irecv()</span></tt> methods of
the <tt class="xref docutils literal"><span class="pre">Comm</span></tt> class initiate a send and receive operation
respectively. These methods return a <tt class="xref docutils literal"><span class="pre">Request</span></tt> instance,
uniquely identifying the started operation.  Its completion can be
managed using the <tt class="xref docutils literal"><span class="pre">Test()</span></tt>, <tt class="xref docutils literal"><span class="pre">Wait()</span></tt>, and <tt class="xref docutils literal"><span class="pre">Cancel()</span></tt>
methods of the <tt class="xref docutils literal"><span class="pre">Request</span></tt> class. The management of
<tt class="xref docutils literal"><span class="pre">Request</span></tt> objects and associated memory buffers involved in
communication requires a careful, rather low-level coordination. Users
must ensure that objects exposing their memory buffers are not
accessed at the Python level while they are involved in nonblocking
message-passing operations.</p>
<p>Often a communication with the same argument list is repeatedly
executed within an inner loop. In such cases, communication can be
further optimized by using persistent communication, a particular case
of nonblocking communication allowing the reduction of the overhead
between processes and communication controllers. Furthermore , this
kind of optimization can also alleviate the extra call overheads
associated to interpreted, dynamic languages like Python.</p>
<p>In <em>MPI for Python</em>, the <tt class="xref docutils literal"><span class="pre">Send_init()</span></tt> and <tt class="xref docutils literal"><span class="pre">Recv_init()</span></tt>
methods of the <tt class="xref docutils literal"><span class="pre">Comm</span></tt> class create a persistent request for a
send and receive operation respectively.  These methods return an
instance of the <tt class="xref docutils literal"><span class="pre">Prequest</span></tt> class, a subclass of the
<tt class="xref docutils literal"><span class="pre">Request</span></tt> class. The actual communication can be effectively
started using the <tt class="xref docutils literal"><span class="pre">Start()</span></tt> method, and its completion can be
managed as previously described.</p>
</div>
</div>
<div class="section" id="collective-communications">
<h2>Collective Communications<a class="headerlink" href="#collective-communications" title="Permalink to this headline">¶</a></h2>
<p>Collective communications allow the transmittal of data between
multiple processes of a group simultaneously. The syntax and semantics
of collective functions is consistent with point-to-point
communication. Collective functions communicate <em>typed</em> data, but
messages are not paired with an associated <em>tag</em>; selectivity of
messages is implied in the calling order. Additionally, collective
functions come in blocking versions only.</p>
<p>The more commonly used collective communication operations are the
following.</p>
<ul class="simple">
<li>Barrier synchronization across all group members.</li>
<li>Global communication functions<ul>
<li>Broadcast data from one member to all members of a group.</li>
<li>Gather data from all members to one member of a group.</li>
<li>Scatter data from one member to all members of a group.</li>
</ul>
</li>
<li>Global reduction operations such as sum, maximum, minimum, etc.</li>
</ul>
<p><em>MPI for Python</em> provides support for almost all collective
calls. Unfortunately, the <tt class="xref docutils literal"><span class="pre">Alltoallw()</span></tt> and <tt class="xref docutils literal"><span class="pre">Reduce_scatter()</span></tt>
methods are curently unimplemented.</p>
<p>In <em>MPI for Python</em>, the <tt class="xref docutils literal"><span class="pre">Bcast()</span></tt>, <tt class="xref docutils literal"><span class="pre">Scatter()</span></tt>,
<tt class="xref docutils literal"><span class="pre">Gather()</span></tt>, <tt class="xref docutils literal"><span class="pre">Allgather()</span></tt> and <tt class="xref docutils literal"><span class="pre">Alltoall()</span></tt> methods of
<tt class="xref docutils literal"><span class="pre">Comm</span></tt> instances provide support for collective communications
of memory buffers. The variants <tt class="xref docutils literal"><span class="pre">bcast()</span></tt>, <tt class="xref docutils literal"><span class="pre">scatter()</span></tt>,
<tt class="xref docutils literal"><span class="pre">gather()</span></tt>, <tt class="xref docutils literal"><span class="pre">allgather()</span></tt> and <tt class="xref docutils literal"><span class="pre">alltoall()</span></tt> can communicate
general Python objects.  The vector variants (which can communicate
different amounts of data at each process) <tt class="xref docutils literal"><span class="pre">Scatterv()</span></tt>,
<tt class="xref docutils literal"><span class="pre">Gatherv()</span></tt>, <tt class="xref docutils literal"><span class="pre">Allgatherv()</span></tt> and <tt class="xref docutils literal"><span class="pre">Alltoallv()</span></tt> are also
supported, they can only communicate objects exposing memory buffers.</p>
<p>Global reduction operations on memory buffers are accessible through
the <tt class="xref docutils literal"><span class="pre">Reduce()</span></tt>, <tt class="xref docutils literal"><span class="pre">Allreduce()</span></tt>, <tt class="xref docutils literal"><span class="pre">Scan()</span></tt> and <tt class="xref docutils literal"><span class="pre">Exscan()</span></tt>
methods. The variants <tt class="xref docutils literal"><span class="pre">reduce()</span></tt>, <tt class="xref docutils literal"><span class="pre">allreduce()</span></tt>, <tt class="xref docutils literal"><span class="pre">scan()</span></tt>
and <tt class="xref docutils literal"><span class="pre">exscan()</span></tt> can communicate general Python objects; however,
the actual required reduction computations are performed sequentially
at some process. All the predefined (i.e., <tt class="xref docutils literal"><span class="pre">SUM</span></tt>,
<tt class="xref docutils literal"><span class="pre">PROD</span></tt>, <tt class="xref docutils literal"><span class="pre">MAX</span></tt>, etc.)  reduction operations can be
applied.</p>
</div>
<div class="section" id="dynamic-process-management">
<h2>Dynamic Process Management<a class="headerlink" href="#dynamic-process-management" title="Permalink to this headline">¶</a></h2>
<p>In the context of the MPI-1 specification, a parallel application is
static; that is, no processes can be added to or deleted from a
running application after it has been started. Fortunately, this
limitation was addressed in MPI-2. The new specification added a
process management model providing a basic interface between an
application and external resources and process managers.</p>
<p>This MPI-2 extension can be really useful, especially for sequential
applications built on top of parallel modules, or parallel
applications with a client/server model. The MPI-2 process model
provides a mechanism to create new processes and establish
communication between them and the existing MPI application. It also
provides mechanisms to establish communication between two existing
MPI applications, even when one did not <em>start</em> the other.</p>
<p>In <em>MPI for Python</em>, new independent processes groups can be created
by calling the <tt class="xref docutils literal"><span class="pre">Spawn()</span></tt> method within an intracommunicator (i.e.,
an <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> instance).  This call returns a new
intercommunicator (i.e., an <tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> instance) at the parent
process group. The child process group can retrieve the matching
intercommunicator by calling the <tt class="xref docutils literal"><span class="pre">Get_parent()</span></tt> (class) method
defined in the <tt class="xref docutils literal"><span class="pre">Comm</span></tt> class. At each side, the new
intercommunicator can be used to perform point to point and collective
communications between the parent and child groups of processes.</p>
<p>Alternatively, disjoint groups of processes can establish
communication using a client/server approach. Any server application
must first call the <tt class="xref docutils literal"><span class="pre">Open_port()</span></tt> function to open a <em>port</em> and
the <tt class="xref docutils literal"><span class="pre">Publish_name()</span></tt> function to publish a provided <em>service</em>, and
next call the <tt class="xref docutils literal"><span class="pre">Accept()</span></tt> method within an <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt>
instance.  Any client applications can first find a published
<em>service</em> by calling the <tt class="xref docutils literal"><span class="pre">Lookup_name()</span></tt> function, which returns
the <em>port</em> where a server can be contacted; and next call the
<tt class="xref docutils literal"><span class="pre">Connect()</span></tt> method within an <tt class="xref docutils literal"><span class="pre">Intracomm</span></tt> instance. Both
<tt class="xref docutils literal"><span class="pre">Accept()</span></tt> and <tt class="xref docutils literal"><span class="pre">Connect()</span></tt> methods return an
<tt class="xref docutils literal"><span class="pre">Intercomm</span></tt> instance. When connection between client/server
processes is no longer needed, all of them must cooperatively call the
<tt class="xref docutils literal"><span class="pre">Disconnect()</span></tt> method of the <tt class="xref docutils literal"><span class="pre">Comm</span></tt> class. Additionally,
server applications should release resources by calling the
<tt class="xref docutils literal"><span class="pre">Unpublish_name()</span></tt> and <tt class="xref docutils literal"><span class="pre">Close_port()</span></tt> functions.</p>
</div>
<div class="section" id="one-sided-communications">
<h2>One-Sided Communications<a class="headerlink" href="#one-sided-communications" title="Permalink to this headline">¶</a></h2>
<p>One-sided communications (also called <em>Remote Memory Access</em>, <em>RMA</em>)
supplements the traditional two-sided, send/receive based MPI
communication model with a one-sided, put/get based
interface. One-sided communication that can take advantage of the
capabilities of highly specialized network hardware. Additionally,
this extension lowers latency and software overhead in applications
written using a shared-memory-like paradigm.</p>
<p>The MPI specification revolves around the use of objects called
<em>windows</em>; they intuitively specify regions of a process&#8217;s memory that
have been made available for remote read and write operations.  The
published memory blocks can be accessed through three functions for
put (remote send), get (remote write), and accumulate (remote update
or reduction) data items. A much larger number of functions support
different synchronization styles; the semantics of these
synchronization operations are fairly complex.</p>
<p>In <em>MPI for Python</em>, one-sided operations are available by using
instances of the <tt class="xref docutils literal"><span class="pre">Win</span></tt> class. New window objects are
created by calling the <tt class="xref docutils literal"><span class="pre">Create()</span></tt> method at all processes within a
communicator and specifying a memory buffer . When a window instance
is no longer needed, the <tt class="xref docutils literal"><span class="pre">Free()</span></tt> method should be called.</p>
<p>The three one-sided MPI operations for remote write, read and
reduction are available through calling the methods <tt class="xref docutils literal"><span class="pre">Put()</span></tt>,
<tt class="xref docutils literal"><span class="pre">Get()</span></tt>, and <tt class="xref docutils literal"><span class="pre">Accumulate()</span></tt> respectively within a
<tt class="xref docutils literal"><span class="pre">Win</span></tt> instance.  These methods need an integer rank identifying
the target process and an integer offset relative the base address of
the remote memory block being accessed.</p>
<p>The one-sided operations read, write, and reduction are implicitly
nonblocking, and must be synchronized by using two primary modes.
Active target synchronization requires the origin process to call the
<tt class="xref docutils literal"><span class="pre">Start()</span></tt> and <tt class="xref docutils literal"><span class="pre">Complete()</span></tt> methods at the origin process, and
target process cooperates by calling the <tt class="xref docutils literal"><span class="pre">Post()</span></tt> and <tt class="xref docutils literal"><span class="pre">Wait()</span></tt>
methods. There is also a collective variant provided by the
<tt class="xref docutils literal"><span class="pre">Fence()</span></tt> method. Passive target synchronization is more lenient,
only the origin process calls the <tt class="xref docutils literal"><span class="pre">Lock()</span></tt> and <tt class="xref docutils literal"><span class="pre">Unlock()</span></tt>
methods. Locks are used to protect remote accesses to the locked
remote window and to protect local load/store accesses to a locked
local window.</p>
</div>
<div class="section" id="parallel-input-output">
<h2>Parallel Input/Output<a class="headerlink" href="#parallel-input-output" title="Permalink to this headline">¶</a></h2>
<p>The POSIX standard provides a model of a widely portable file
system. However, the optimization needed for parallel input/output
cannot be achieved with this generic interface. In order to ensure
efficiency and scalability, the underlying parallel input/output
system must provide a high-level interface supporting partitioning of
file data among processes and a collective interface supporting
complete transfers of global data structures between process memories
and files. Additionally, further efficiencies can be gained via
support for asynchronous input/output, strided accesses to data, and
control over physical file layout on storage devices. This scenario
motivated the inclusion in the MPI-2 standard of a custom interface in
order to support more elaborated parallel input/output operations.</p>
<p>The MPI specification for parallel input/output revolves around the
use objects called <em>files</em>. As defined by MPI, files are not just
contiguous byte streams. Instead, they are regarded as ordered
collections of <em>typed</em> data items. MPI supports sequential or random
access to any integral set of these items. Furthermore, files are
opened collectively by a group of processes.</p>
<p>The common patterns for accessing a shared file (broadcast, scatter,
gather, reduction) is expressed by using user-defined datatypes.
Compared to the communication patterns of point-to-point and
collective communications, this approach has the advantage of added
flexibility and expressiveness. Data access operations (read and
write) are defined for different kinds of positioning (using explicit
offsets, individual file pointers, and shared file pointers),
coordination (non-collective and collective), and synchronism
(blocking, nonblocking, and split collective with begin/end phases).</p>
<p>In <em>MPI forPython</em>, all MPI input/output operations are performed
through instances of the <tt class="xref docutils literal"><span class="pre">File</span></tt> class. File handles are
obtained by calling the <tt class="xref docutils literal"><span class="pre">Open()</span></tt> method at all processes within a
communicator and providing a file name and the intended access mode.
After use, they must be closed by calling the <tt class="xref docutils literal"><span class="pre">Close()</span></tt> method.
Files even can be deleted by calling method <tt class="xref docutils literal"><span class="pre">Delete()</span></tt>.</p>
<p>After creation, files are typically associated with a per-process
<em>view</em>. The view defines the current set of data visible and
accessible from an open file as an ordered set of elementary
datatypes. This data layout can be set and queried with the
<tt class="xref docutils literal"><span class="pre">Set_view()</span></tt> and <tt class="xref docutils literal"><span class="pre">Get_view()</span></tt> methods respectively.</p>
<p>Actual input/output operations are achieved by many methods combining
read and write calls with different behavior regarding positioning,
coordination, and synchronism. Summing up, <em>MPI for Python</em> provides
the thirty (30) methods defined in MPI-2 for reading from or writing
to files using explicit offsets or file pointers (individual or
shared), in blocking or nonblocking and collective or noncollective
versions.</p>
</div>
<div class="section" id="environmental-management">
<h2>Environmental Management<a class="headerlink" href="#environmental-management" title="Permalink to this headline">¶</a></h2>
<div class="section" id="initialization-and-exit">
<h3>Initialization and Exit<a class="headerlink" href="#initialization-and-exit" title="Permalink to this headline">¶</a></h3>
<p>Module functions <tt class="xref docutils literal"><span class="pre">Init()</span></tt> or <tt class="xref docutils literal"><span class="pre">Init_thread()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Finalize()</span></tt> provide MPI initialization and finalization
respectively. Module functions <tt class="xref docutils literal"><span class="pre">Is_initialized()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Is_finalized()</span></tt> provide the respective tests for initialization
and finalization.</p>
<div class="admonition caution">
<p class="first admonition-title">Caution</p>
<p class="last"><tt class="xref docutils literal"><span class="pre">MPI_Init()</span></tt> or <tt class="xref docutils literal"><span class="pre">MPI_Init_thread()</span></tt> is
actually called when you import the <tt class="xref docutils literal"><span class="pre">MPI</span></tt> module from the
<tt class="xref docutils literal"><span class="pre">mpi4py</span></tt> package, but only if MPI is not already
initialized. In such case, calling <tt class="xref docutils literal"><span class="pre">Init()</span></tt>/<tt class="xref docutils literal"><span class="pre">Init_thread()</span></tt>
from Python is expected to generate an MPI error, and in turn an
exception will be raised.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><tt class="xref docutils literal"><span class="pre">MPI_Finalize()</span></tt> is registered (by using Python C/API
function <tt class="xref docutils literal"><span class="pre">Py_AtExit()</span></tt>) for being automatically called when
Python processes exit, but only if <tt class="xref docutils literal"><span class="pre">mpi4py</span></tt> actually
initialized Therefore, there is no need to call <tt class="xref docutils literal"><span class="pre">Finalize()</span></tt>
from Python to ensure MPI finalization.</p>
</div>
</div>
<div class="section" id="implementation-information">
<h3>Implementation Information<a class="headerlink" href="#implementation-information" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The MPI version number can be retrieved from module function
<tt class="xref docutils literal"><span class="pre">Get_version()</span></tt>. It returns a two-integer tuple
<tt class="docutils literal"><span class="pre">(version,subversion)</span></tt>.</li>
</ul>
<ul class="simple">
<li>The <tt class="xref docutils literal"><span class="pre">Get_processor_name()</span></tt> function can be used to access the
processor name.</li>
<li>The values of predefined attributes attached to the world
communicator can be obtained by calling the <tt class="xref docutils literal"><span class="pre">Get_attr()</span></tt> method
within the <tt class="xref docutils literal"><span class="pre">COMM_WORLD</span></tt> instance.</li>
</ul>
</div>
<div class="section" id="timers">
<h3>Timers<a class="headerlink" href="#timers" title="Permalink to this headline">¶</a></h3>
<p>MPI timer functionalities are available through the <tt class="xref docutils literal"><span class="pre">Wtime()</span></tt> and
<tt class="xref docutils literal"><span class="pre">Wtick()</span></tt> functions.</p>
</div>
<div class="section" id="error-handling">
<h3>Error Handling<a class="headerlink" href="#error-handling" title="Permalink to this headline">¶</a></h3>
<p>Error handling functionality is almost completely supported.  Errors
originated in native MPI calls will raise an instance of the module
exception class <tt class="xref docutils literal"><span class="pre">Exception</span></tt>, which is a subclass of the standard
Python exception <tt class="xref docutils literal"><span class="pre">RuntimeError</span></tt>.</p>
<div class="admonition caution">
<p class="first admonition-title">Caution</p>
<p class="last">Importing with <tt class="docutils literal"><span class="pre">from</span> <span class="pre">mpi4py.MPI</span> <span class="pre">import</span> <span class="pre">*</span></tt> will cause
a name clashing with standard Python <tt class="xref docutils literal"><span class="pre">Exception</span></tt> base class.</p>
</div>
<p>In order facilitate communicator sharing with other Python modules
interfacing MPI-based parallel libraries, default MPI error handlers
<tt class="xref docutils literal"><span class="pre">ERRORS_RETURN</span></tt>, <tt class="xref docutils literal"><span class="pre">ERRORS_ARE_FATAL</span></tt> can be assigned to
and retrieved from communicators, windows and files with methods
<tt class="xref docutils literal"><span class="pre">{Class}.Set_errhandler()</span></tt> and <tt class="xref docutils literal"><span class="pre">{Class}.Get_errhandler()</span></tt>.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="#">Design and Interface Overview</a><ul>
<li><a class="reference external" href="#communicating-python-objects-and-array-data">Communicating Python Objects and Array Data</a></li>
<li><a class="reference external" href="#communicators">Communicators</a></li>
<li><a class="reference external" href="#point-to-point-communications">Point-to-Point Communications</a><ul>
<li><a class="reference external" href="#blocking-communications">Blocking Communications</a></li>
<li><a class="reference external" href="#nonblocking-communications">Nonblocking Communications</a></li>
</ul>
</li>
<li><a class="reference external" href="#collective-communications">Collective Communications</a></li>
<li><a class="reference external" href="#dynamic-process-management">Dynamic Process Management</a></li>
<li><a class="reference external" href="#one-sided-communications">One-Sided Communications</a></li>
<li><a class="reference external" href="#parallel-input-output">Parallel Input/Output</a></li>
<li><a class="reference external" href="#environmental-management">Environmental Management</a><ul>
<li><a class="reference external" href="#initialization-and-exit">Initialization and Exit</a></li>
<li><a class="reference external" href="#implementation-information">Implementation Information</a></li>
<li><a class="reference external" href="#timers">Timers</a></li>
<li><a class="reference external" href="#error-handling">Error Handling</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="intro.html"
                                  title="previous chapter">Introduction</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="install.html"
                                  title="next chapter">Installation</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/mpi4py.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="install.html" title="Installation"
             >next</a></li>
        <li class="right" >
          <a href="intro.html" title="Introduction"
             >previous</a> |</li>
        <li><a href="index.html">MPI for Python v1.2.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Lisandro Dalcin.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.6.
    </div>
  </body>
</html>