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
|
This release of ScientificPython contains support for parallelization
via the Bulk Synchronous Parallel library (BSPlib). If you want to
write parallelized programs in Python using the BSP module in
Scientific Python, you need either the BSPlib interface or the MPI
interface (see README.MPI for that one). If you don't want to write
parallel code, or don't know what that is, don't read the following,
and go on with installation. In the following I will assume that you
know what BSPlib is, and that you have it installed on your system
BSPlib support in ScientificPython is limited to the message passing
functionality, direct remote memory access is not implemented. The
Python data types that are supported are strings and Numerical Python
arrays. The BSPlib module exists mainly as a low-level support for the
module Scientific.BSP, which offers a more convenient high-level
interface and allows the transmission of almost arbitrart Python
objects. The BSPlib module also provides a C API for use by other
extension modules.
Here is what you have to do to get BSPlib 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/BSPlib.
3) Type "python compile.py".
4) Move the resulting executable "bsppython" to a directory on your
shell's execution path.
This recipe should work on any system with a working installation
of BSPlib. It has been tested with version 1.4 under Linux.
To execute a BSP program, use bsppython instead of the normal Python
interpreter. Programs that use only the high-level module
Scientific.BSP will also work with a standard Python interpreter, but
only use one processor. Scientific.BSP can also use MPI for low-level
communication, if you prefer that option, install MPI support (see
README.MPI for details) and run the programs with the mpipython
executable.
There is also an interactive parallel console, which is highly
recommended for program development. It is used much like the standard
Python interpreter, and is in fact sufficiently similar that it can be
used instead of standard Python with the Emacs mode for Python. That
combination is at the moment the best development environment for
parallel Python code. The interactive parallel console is a small
executable script called "ibsppython", to be found in the Src/BSPlib
directory. Copy it anywhere to any directory on the search path of
your Unix system.
Special thanks to Joe VanAndel for the new compile.py script that
works with Python 2.2 as well!
In case you wonder why a special Python executable is required, here is
some background information:
First of all, the BSPlib interface does not work with a standard
Python interpreter. The reason is that the BSPlib interface requires
that the call to bsp_begin() be the first executed statement in the
Python interpreter. Moreover, a modified interpreter is the only way
to guarantee that bsp_end() is always called at the end, even if the
Python program crashes. The file Src/BSPlib/bsppython.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. Depending on your
operating system, it might be impossible to use the BSPlib interface
module as a dynamic library, because the interpreter and the module
might use different copies of the BSPlib code. The safest bet is to
link the interface module, Scientific_bsplib, together with the
bsppython executable. Other C extension modules can then call BSPlib
functions via Python's CObject indirection method.
Konrad Hinsen
Centre de Biophysique Moleculaire (CNRS)
Rue Charles Sadron
45071 Orleans Cedex 2
France
E-Mail: hinsen@cnrs-orleans.fr
|