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
|
<!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="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Appendix — MPI for Python 3.0.3 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Installation" href="install.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="install.html" title="Installation"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">MPI for Python 3.0.3 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="appendix">
<h1>Appendix<a class="headerlink" href="#appendix" title="Permalink to this headline">¶</a></h1>
<div class="section" id="mpi-enabled-python-interpreter">
<span id="python-mpi"></span><h2>MPI-enabled Python interpreter<a class="headerlink" href="#mpi-enabled-python-interpreter" title="Permalink to this headline">¶</a></h2>
<blockquote>
<div><div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">These days it is no longer required to use the MPI-enabled Python
interpreter in most cases, and, therefore, is not built by
default anymore because it is too difficult to reliably build a
Python interpreter across different distributions. If you know
that you still <strong>really</strong> need it, see below on how to use the
<cite>build_exe</cite> and <cite>install_exe</cite> commands.</p>
</div>
</div></blockquote>
<p>Some MPI-1 implementations (notably, MPICH 1) <strong>do require</strong> the
actual command line arguments to be passed at the time
<code class="xref c c-func docutils literal notranslate"><span class="pre">MPI_Init()</span></code> is called. In this case, you will need to use a
re-built, MPI-enabled, Python interpreter binary executable. A basic
implementation (targeting Python 2.X) of what is required is shown
below:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><Python.h></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><mpi.h></span><span class="cp"></span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="n">status</span><span class="p">,</span> <span class="n">flag</span><span class="p">;</span>
<span class="n">MPI_Init</span><span class="p">(</span><span class="o">&</span><span class="n">argc</span><span class="p">,</span> <span class="o">&</span><span class="n">argv</span><span class="p">);</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">Py_Main</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">);</span>
<span class="n">MPI_Finalized</span><span class="p">(</span><span class="o">&</span><span class="n">flag</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">flag</span><span class="p">)</span> <span class="n">MPI_Finalize</span><span class="p">();</span>
<span class="k">return</span> <span class="n">status</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The source code above is straightforward; compiling it should also
be. However, the linking step is more tricky: special flags have to be
passed to the linker depending on your platform. In order to alleviate
you for such low-level details, <em>MPI for Python</em> provides some
pure-distutils based support to build and install an MPI-enabled
Python interpreter executable:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd mpi4py-X.X.X
$ python setup.py build_exe [--mpi=<name>|--mpicc=/path/to/mpicc]
$ [sudo] python setup.py install_exe [--install-dir=$HOME/bin]
</pre></div>
</div>
<p>After the above steps you should have the MPI-enabled interpreter
installed as <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/bin/python</span><em><span class="pre">X</span></em><span class="pre">.</span><em><span class="pre">X</span></em><span class="pre">-mpi</span></code> (or
<code class="file docutils literal notranslate"><span class="pre">$HOME/bin/python</span><em><span class="pre">X</span></em><span class="pre">.</span><em><span class="pre">X</span></em><span class="pre">-mpi</span></code>). Assuming that
<code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/bin</span></code> (or <code class="file docutils literal notranslate"><span class="pre">$HOME/bin</span></code>) is listed on your
<span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>, you should be able to enter your MPI-enabled Python
interactively, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python2.7-mpi
Python 2.7.8 (default, Nov 10 2014, 08:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python2.7-mpi'
>>>
</pre></div>
</div>
</div>
<div class="section" id="building-mpi-from-sources">
<span id="building-mpi"></span><h2>Building MPI from sources<a class="headerlink" href="#building-mpi-from-sources" title="Permalink to this headline">¶</a></h2>
<p>In the list below you have some executive instructions for building
some of the open-source MPI implementations out there with support for
shared/dynamic libraries on POSIX environments.</p>
<ul>
<li><p class="first"><em>MPICH</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ tar -zxf mpich-X.X.X.tar.gz
$ cd mpich-X.X.X
$ ./configure --enable-shared --prefix=/usr/local/mpich
$ make
$ make install
</pre></div>
</div>
</li>
<li><p class="first"><em>Open MPI</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ tar -zxf openmpi-X.X.X tar.gz
$ cd openmpi-X.X.X
$ ./configure --prefix=/usr/local/openmpi
$ make all
$ make install
</pre></div>
</div>
</li>
<li><p class="first"><em>MPICH 1</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ tar -zxf mpich-X.X.X.tar.gz
$ cd mpich-X.X.X
$ ./configure --enable-sharedlib --prefix=/usr/local/mpich1
$ make
$ make install
</pre></div>
</div>
</li>
</ul>
<p>Perhaps you will need to set the <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">LD_LIBRARY_PATH</span></code>
environment variable (using <strong class="command">export</strong>, <strong class="command">setenv</strong> or
what applies to your system) pointing to the directory containing the
MPI libraries . In case of getting runtime linking errors when running
MPI programs, the following lines can be added to the user login shell
script (<code class="file docutils literal notranslate"><span class="pre">.profile</span></code>, <code class="file docutils literal notranslate"><span class="pre">.bashrc</span></code>, etc.).</p>
<ul>
<li><p class="first"><em>MPICH</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>MPI_DIR=/usr/local/mpich
export LD_LIBRARY_PATH=$MPI_DIR/lib:$LD_LIBRARY_PATH
</pre></div>
</div>
</li>
<li><p class="first"><em>Open MPI</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>MPI_DIR=/usr/local/openmpi
export LD_LIBRARY_PATH=$MPI_DIR/lib:$LD_LIBRARY_PATH
</pre></div>
</div>
</li>
<li><p class="first"><em>MPICH 1</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>MPI_DIR=/usr/local/mpich1
export LD_LIBRARY_PATH=$MPI_DIR/lib/shared:$LD_LIBRARY_PATH:
export MPICH_USE_SHLIB=yes
</pre></div>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">MPICH 1 support for dynamic libraries is not completely
transparent. Users should set the environment variable
<span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">MPICH_USE_SHLIB</span></code> to <code class="docutils literal notranslate"><span class="pre">yes</span></code> in order to avoid link
problems when using the <strong class="program">mpicc</strong> compiler wrapper.</p>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Appendix</a><ul>
<li><a class="reference internal" href="#mpi-enabled-python-interpreter">MPI-enabled Python interpreter</a></li>
<li><a class="reference internal" href="#building-mpi-from-sources">Building MPI from sources</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="install.html"
title="previous chapter">Installation</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/appendix.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="install.html" title="Installation"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">MPI for Python 3.0.3 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2019, Lisandro Dalcin.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.4.
</div>
</body>
</html>
|