File: README.MPI

package info (click to toggle)
python-scientific 2.2-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,368 kB
  • ctags: 2,396
  • sloc: python: 6,468; ansic: 3,643; xml: 3,596; makefile: 79; sh: 27
file content (94 lines) | stat: -rw-r--r-- 4,298 bytes parent folder | download
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
This release of ScientificPython contains support for parallelization
via the Message Passing Interface (MPI). If you don't know what that
is, you probably don't need it, so don't read the following, and go on
with installation. In the following I will assume that you do know
what MPI is, and how to compile and link MPI programs on your
platform.

MPI support in ScientificPython is still very basic; there are
probably more complete MPI interfaces out there. The strong point of
ScientificPython's interface is the integration into Python:
communicators are Python objects, all communication happens via
methods defined on communicator objects, support is provided for
sending and receiving both string and NumPy array objects. Moreover,
Python scripts can rather easily be written in such a way that they
work both with and without MPI support, of course using only a single
processor when no MPI is available. Finally, there is a full C API as
well, which means that other C modules can make use of MPI without
having to link to the MPI library, which is particularly useful for
dynamic library modules. It also facilitates packaging of MPI-based
code, which doesn't need to know anything at all about the MPI
library.

The module Scientific.MPI is documented in the ScientificPython
manual. The main purpose of this file is to explain how to install
ScientificPython with MPI support. It works on a couple of platforms
without modifications, but that's no guarantee that it will work
immediately on yours as well.


Here is what you have to do to get MPI support in Scientific Python:

1) Build and install Scientific Python as usual (i.e.
   "python setup.py install" in most cases).

2) Go to the directory Src/MPI.

3) Type "python compile.py".

4) Move the resulting executable "mpipython" to a directory on your
   shell's execution path.

This should work under the condition that your MPI implementation
provides a script or executable called "mpicc" which compiles C
programs using MPI and does not require any explicitly mentioned
libraries. If such a script exists, but with a different name, change
the name in the beginning of compile.py. If no such script exists, put
the name of your C compiler in that place and add all required linking
options in the file Setup.in.


For running Python code that uses MPI, you must use mpipython, not the
standard Python executable. If you use the standard python version,
the variable Scientific.MPI.world has the value None instead of
an MPI Communicator object. To write code that works with or without
MPI, check if Scientific.MPI.world is None before making MPI calls.

To test your installation, execute the program Examples/mpi.py
using more than one processor.



In case you wonder why a special Python executable is required, here is
some background information:

First of all, the MPI interface does not work with a standard Python
interpreter. The reason is that MPI (at least some implementations,
including MPICH) requires access to the command line parameters
*before* Python takes over and puts them into sys.argv. Therefore
MPI_Init() must be called before the Python main loop is entered, and
it is also advisable to put MPI_Finalize() into a place where it is
guaranteed to be executed even if the program crashes. The file
Src/mpipython.c takes care of these two calls; it is in fact nothing
but a slightly modified version of the python interpreter program,
python.c. (In case you wonder why it's so small: all the real work is
done in the Python library functions that are called.)

The second problem is dynamic library support. If your MPI
implementation comes as a dynamic library, then you shouldn't have any
problems. If it doesn't, then it might be impossible to use the MPI
interface module as a dynamic library, because the interpreter and the
module would use different copies of the MPI code, which will probably
create problems if MPI uses global variables. The safest bet is to
link the interface module, Scientific_mpi, together with the mpipython
executable. However, on my system (Linux/MPICH), it works fine as a
dynamic library as well, so you might want to try it.


Konrad Hinsen
Centre de Biophysique Moleculaire (CNRS)
Rue Charles Sadron
45071 Orleans Cedex 2
France

E-Mail: hinsen@cnrs-orleans.fr