1 | ------------------------------------------------ |
---|
2 | PyPAR - Parallel Python, efficient and scalable |
---|
3 | parallelism using the message passing interface (MPI). |
---|
4 | |
---|
5 | Author: Ole Nielsen (2001 -) |
---|
6 | Email: Ole.Nielsen@anu.edu.au |
---|
7 | Version: See pypar.__version__ |
---|
8 | Date: See pypar.__date__ |
---|
9 | |
---|
10 | Major contributions by |
---|
11 | Gian Paolo Ciceri (gp.ciceri@acm.org) |
---|
12 | Prabhu Ramachandran (prabhu@aero.iitm.ernet.in) |
---|
13 | |
---|
14 | Minor but important contributions by |
---|
15 | Doug Orr (doug@arbor.net) |
---|
16 | Michal Kaukic (mike@frcatel.fri.utc.sk) |
---|
17 | |
---|
18 | ------------------------------------------------ |
---|
19 | |
---|
20 | The python module pypar.py and the C-extension mpi.c |
---|
21 | implements scalable parallelism on distributed and shared |
---|
22 | memory architectures using the essential subset of |
---|
23 | the Message Passing Interface (MPI) standard. |
---|
24 | |
---|
25 | FEATURES |
---|
26 | |
---|
27 | - Python interpreter is not modified: |
---|
28 | Parallel python programs need only import the pypar module. |
---|
29 | |
---|
30 | - Easy installation: This is essentially about compiling and linking |
---|
31 | the C-extension with the local MPI installation. A distutils setup file |
---|
32 | is included. |
---|
33 | |
---|
34 | - Flexibility: Pypar allows communication of general Python objects |
---|
35 | of any type. |
---|
36 | |
---|
37 | - Intuitive API: |
---|
38 | The user need only specify what to send and to which processor. |
---|
39 | Pypar takes care of details about |
---|
40 | data types and MPI specifics such as tags, communicators and buffers. |
---|
41 | Receiving is analogous. |
---|
42 | |
---|
43 | - Efficiency: |
---|
44 | Full bandwidth of C-MPI programs is achieved for consecutive Numerical |
---|
45 | arrays. Latency is less than twice that of pure C-MPI programs. |
---|
46 | Test programs to verify this are included (pytiming, ctiming.c) |
---|
47 | |
---|
48 | - Lightweight: |
---|
49 | Pypar consists of just two files: mpiext.c and pypar.py |
---|
50 | |
---|
51 | See the DOC file for instructions on how to program with pypar. |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | PRE-REQUISITES (on all nodes) |
---|
56 | |
---|
57 | Python 2.0 or later |
---|
58 | Numeric Python (incl RandomArray) matching the Python installation |
---|
59 | Native MPI C library |
---|
60 | Native C compiler |
---|
61 | |
---|
62 | Pypar has been tested on the following platforms |
---|
63 | OPENMPI with Linux on Opteron 64 bit |
---|
64 | OPENMPI with Ubuntu Linux (32 bit) |
---|
65 | MPI on DEC Alpha |
---|
66 | LAM/MPI (6.5.6, 7.0) on Linux (Debian Woody/Cid and Red Hat 7.1) |
---|
67 | MPICH and LAM 7.0 on Solaris (Sun Enterprise) |
---|
68 | MPICH on Linux |
---|
69 | MPICH on Windows (NT/2000) |
---|
70 | MPICH for Darwin (Mac OS) |
---|
71 | LAM/MPI with Linux on Opteron 64 bit |
---|
72 | |
---|
73 | There are currently issues with MPICH2, so we recommend using OPENMPI |
---|
74 | On Ubuntu systems you need to install the following 2 packages: |
---|
75 | apt-get install openmpi-bin |
---|
76 | apt-get install libopenmpi-dev |
---|
77 | |
---|
78 | |
---|
79 | INSTALL |
---|
80 | |
---|
81 | UNIX PLATFORMS |
---|
82 | Type |
---|
83 | python setup.py install |
---|
84 | |
---|
85 | This should install pypar and its extension in the default |
---|
86 | site-packages directory on your system. |
---|
87 | |
---|
88 | If you wish to install it in your home directory use |
---|
89 | |
---|
90 | python setup.py install --prefix=~ |
---|
91 | |
---|
92 | WINDOWS (NT/2000, MPICH) |
---|
93 | To build, you need: |
---|
94 | 1) MPICH (http://www-unix.mcs.anl.gov/mpi/mpich/) |
---|
95 | 2) MinGW (http://www.mingw.org). Tested with GCC v 2.95-3.6. |
---|
96 | 3) Set MPICH_DIR to the appropriate directory |
---|
97 | 4) Build using 'python setup.py build --compiler=mingw32' |
---|
98 | 5) Install using 'python setup.py install'. |
---|
99 | |
---|
100 | --- |
---|
101 | If you encountered any installation problems, read on. |
---|
102 | Do not worry about messages about unresolved symbols. This is normal |
---|
103 | for shared libraries on some machines. |
---|
104 | |
---|
105 | To compile C-extension mpi.c requires either a mpi-aware c compiler |
---|
106 | such as mpicc or a standard c compiler with mpi libraries linked in. |
---|
107 | See local MPI installation for details, possibly edit Makefile and |
---|
108 | type make. |
---|
109 | See installation notes below about compiling under mpi. |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | COMPILE PYPAR LOCALLY |
---|
114 | |
---|
115 | If you don't want to install pypar using distutils or if you encounter |
---|
116 | problems doing so, you can compile it locally using the the script |
---|
117 | compile_pypar_locally.py (located in the pypar source directory) |
---|
118 | is a non-distutils way of compiling the extension and will put the |
---|
119 | mpiext.so file in the current working dir. |
---|
120 | With a PATH to that dir, you can run your pypar programs using the |
---|
121 | local installation. |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | TESTING |
---|
126 | Pypar comes with a number of tests and demos available in the |
---|
127 | examples directory - please try these to verify the installation. |
---|
128 | |
---|
129 | See also mandelbrot examples (in demos/mandelbrot_example) using different parallel |
---|
130 | approaches to compute the well-known fractal in parallel. |
---|
131 | Before running any of these you must compile their C extensions. This is done as follows: |
---|
132 | |
---|
133 | python compile_mandelbrot_c_extensions.py |
---|
134 | |
---|
135 | |
---|
136 | In particular the script mandel_parallel_cyclic.py should produce almost perfect speedup. |
---|
137 | To run it on 2 processors, write |
---|
138 | |
---|
139 | mpirun -np 2 python mandel_parallel_dynamic.py |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | RUNNING PYTHON MPI JOBS |
---|
145 | |
---|
146 | Pypar runs in exactly the same way as MPI programs written in |
---|
147 | C or Fortran. |
---|
148 | |
---|
149 | E.g. to run the enclosed demo script (demo.py) on 4 processors, |
---|
150 | enter a command similar to |
---|
151 | |
---|
152 | mpirun -np 4 python demo.py |
---|
153 | |
---|
154 | Consult your MPI distribution for exact syntax of mpirun. |
---|
155 | Sometimes it is called prun and often parallel jobs will be |
---|
156 | submitted in batch mode. |
---|
157 | |
---|
158 | You can also execute demo.py as a stand-alone executable python script |
---|
159 | |
---|
160 | mpirun -np 4 demo.py |
---|
161 | |
---|
162 | |
---|
163 | Enclosed is a script to estimate the communication speed of your system. |
---|
164 | Execute |
---|
165 | |
---|
166 | mpirun -np 4 pytiming |
---|
167 | |
---|
168 | Care has been taken in pypar to achieve the same bandwidth and almost as |
---|
169 | good communication latency as corresponding C/MPI programs. |
---|
170 | Please compile and run ctiming.c to see the reference values: |
---|
171 | |
---|
172 | make ctiming |
---|
173 | mpirun -np 4 ctiming |
---|
174 | |
---|
175 | Note that timings might fluctuate from run to run due to variable |
---|
176 | system load. |
---|
177 | |
---|
178 | An example of a master-slave program using pypar is available in demo2.py. |
---|
179 | |
---|
180 | |
---|
181 | INSTALLATION NOTES (If all else fails) |
---|
182 | |
---|
183 | Most MPI implementations provide a script or an executable called |
---|
184 | "mpicc" which compiles C programs using MPI and does |
---|
185 | not require any explicitly mentioned libraries. |
---|
186 | If such a script exists, but with a different name, change |
---|
187 | the name in the beginning of compile.py. If no such script exists, put |
---|
188 | the name of your C compiler in that place and add all required linking |
---|
189 | options yourself. |
---|
190 | |
---|
191 | For example, on an Alpha server it would look something like |
---|
192 | |
---|
193 | cc -c mpi.c -I/opt/Python-2.1/include/python2.1/ |
---|
194 | cc -shared mpi.o -o mpi.so -lmpi -lelan |
---|
195 | |
---|
196 | or using the wrapper |
---|
197 | |
---|
198 | mpicc -c mpi.c -I/opt/Python-2.1/include/python2.1/ |
---|
199 | mpicc -shared mpi.o -o mpi.so |
---|
200 | |
---|
201 | On Linux (using LAM-MPI) it is |
---|
202 | |
---|
203 | mpicc -c mpi.c -I/opt/Python-2.1/include/python2.1/ |
---|
204 | mpicc -shared mpi.o -o mpi.so |
---|
205 | |
---|
206 | Start processors using |
---|
207 | lamboot -v lamhosts |
---|
208 | |
---|
209 | On Linux (using OPENMPI) the compilation and executions steps are as with LAM-MPI, but |
---|
210 | there is no need for lamboot anymore. With OPENMPI you may need to uncomment the line |
---|
211 | |
---|
212 | btl = ^openib |
---|
213 | |
---|
214 | in /etc/openmpi/openmpi-mca-params.conf to get rid of the warning "OpenIB on host ... was unable to find any HCAs." Another warning, "unable to open osc pt2pt: file not found (ignored)", is a known openmpi problem with an unknown solution. |
---|
215 | See http://code.google.com/p/petsc4py/wiki/InstallationNotes for more details. |
---|
216 | |
---|
217 | |
---|
218 | |
---|
219 | HOW DOES PYPAR WORK? |
---|
220 | |
---|
221 | Pypar works as follows |
---|
222 | 1 mpirun starts P python processes as specified by mpirun -np P |
---|
223 | 2 each python process imports pypar which in turn imports a shared |
---|
224 | library (python extension mpiext.so) that has been statically linked |
---|
225 | to the C MPI libraries using e.g. mpicc (or cc -lmpi) |
---|
226 | 3 The Python extension proceeds to call MPI_init with any commandline |
---|
227 | parameters passed in by mpirun (As far as I remember MPICH uses this |
---|
228 | to identify rank and size, whereas LAM doesn't) |
---|
229 | 4 The supported MPI calls are made available to Python through the |
---|
230 | pypar interface |
---|
231 | |
---|
232 | If pypar is invoked sequentially it supports a rudimentary interface |
---|
233 | with e.g. rank() == 0 and size() == 1 |
---|
234 | |
---|
235 | |
---|
236 | |
---|
237 | DOCUMENTATION |
---|
238 | |
---|
239 | See the file DOC for an introduction to pypar. |
---|
240 | See also examples demo.py and pytiming |
---|
241 | as well as documentation in pypar.py. |
---|
242 | |
---|
243 | |
---|
244 | HISTORY |
---|
245 | |
---|
246 | See release_notes.txt for newer releases! |
---|
247 | |
---|
248 | version 2.0.1_alpha (11/7/7) Setup patch by jk Nilsen and removal |
---|
249 | of obsolete code |
---|
250 | version 2.0alpha (3/7/7) Migration to numpy and patches to setup |
---|
251 | Also started Subversion repository on Sourceforge. |
---|
252 | |
---|
253 | version 1.9.3 (24 April 2007) |
---|
254 | added bypass form for reduce |
---|
255 | version 1.9.2 |
---|
256 | First version under Subversion |
---|
257 | version 1.9.1 (15 Dec 2003) |
---|
258 | Consistent naming (all lower case, no abbreviations) |
---|
259 | version 1.9 (3 Dec 2003) |
---|
260 | Obsoleted raw forms of communication as they were confusing. |
---|
261 | The semantics of send, receive, scatter, gather etc is now that |
---|
262 | one can optionally specify a buffer to use if desired. |
---|
263 | Bypass forms added. |
---|
264 | |
---|
265 | version 1.8.2 (16 November 2003) |
---|
266 | Fixed scatter, gather and reduce calls to automatically |
---|
267 | figure out buffer lengths. Also tested scatter and gather for |
---|
268 | complex and multidimensional data. |
---|
269 | version 1.8.1 (13 November 2003) |
---|
270 | Added direct support (i.e. not using the vanilla protocol) |
---|
271 | for multidimensional Numeric arrays of type Complex. |
---|
272 | version 1.8 (11 November 2003) |
---|
273 | Changed status object to be (optionally) returned from receive and |
---|
274 | raw_receive rather maintaining a global state where one instance of |
---|
275 | the status object is modified. |
---|
276 | This was suggested by the audience at presentation at Department of |
---|
277 | Computer Science, Australian National University, 18 June 2003. |
---|
278 | |
---|
279 | version 1.7 (7 November 2003) |
---|
280 | Added support for Numerical arrays of arbitrary dimension |
---|
281 | in send, receive and bcast. |
---|
282 | The need for this obvious functionality was pointed by Michal Kaukic. |
---|
283 | |
---|
284 | version 1.6.5 (30 August 2003) |
---|
285 | Added NULL commandline argument as required by LAM 7.0 and |
---|
286 | identified by Doug Orr and Dave Reed. |
---|
287 | version 1.6.4 (10 Jan 2003) |
---|
288 | Comments and review of installation |
---|
289 | version 1.6.3 (10 Jan 2003) |
---|
290 | Minor issues and clean-up |
---|
291 | version 1.6.2 (29 Oct 2002) |
---|
292 | Added Windows platform to installation as contributed by |
---|
293 | Simon Frost |
---|
294 | version 1.6.0 (18 Oct 2002) |
---|
295 | Changed installation to distutils as contributed by |
---|
296 | Prabhu Ramachandran |
---|
297 | |
---|
298 | version 1.5 (30 April 2002) |
---|
299 | Got pypar to work with MPICH/Linux and cleaned up initialisation |
---|
300 | version 1.4 (4 March 2002) |
---|
301 | Fixed-up and ran testpypar on 22 processors on Sun |
---|
302 | version 1.3 (21 February 2002) |
---|
303 | Added gather and reduce fixed up testpypar.py |
---|
304 | |
---|
305 | version 1.2.2, 1.2.3 (17 February 2002) |
---|
306 | Minor fixes in distribution |
---|
307 | version 1.2.1 (16 February 2002) |
---|
308 | Status block, MPI_ANY_TAG, MPI_ANY_SOURCE exported |
---|
309 | Version 1.2 (15 February 2002) |
---|
310 | Scatter added by Gian Paolo Ciceri |
---|
311 | Version 1.1 (14 February 2002) |
---|
312 | Bcast added by Gian Paolo Ciceri |
---|
313 | Version 1.0.2 (10 February 2002) |
---|
314 | Modified by Gian Paulo Ciceri to allow pypar run under Python 2.2 |
---|
315 | Version 1.0.1 (8 February 2002) |
---|
316 | Modified to install on SUN enterprise systems under Mpich |
---|
317 | Version 1.0 (7 February 2002) |
---|
318 | First public release for Python 2.1 (OMN) |
---|
319 | |
---|
320 | |
---|
321 | KNOWN BUGS |
---|
322 | Scatter for the moment works only properly when the amount of data is a |
---|
323 | multiple of the number of processors (as does the underlying MPI_Scatter). |
---|
324 | I am working on a more general scatter (and gather) which will |
---|
325 | distribute data as evenly as possible for all amounts of data. |
---|
326 | |
---|
327 | |
---|
328 | LICENSE |
---|
329 | This program is free software; you can redistribute it and/or modify |
---|
330 | it under the terms of the GNU General Public License as published by |
---|
331 | the Free Software Foundation; either version 2 of the License, or |
---|
332 | (at your option) any later version. |
---|
333 | |
---|
334 | This program is distributed in the hope that it will be useful, |
---|
335 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
336 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
337 | GNU General Public License (http://www.gnu.org/copyleft/gpl.html) |
---|
338 | for more details. |
---|
339 | |
---|
340 | You should have received a copy of the GNU General Public License |
---|
341 | along with this program; if not, write to the Free Software |
---|
342 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
343 | |
---|
344 | |
---|
345 | Contact address: Ole.Nielsen@anu.edu.au |
---|
346 | |
---|
347 | ============================================================================= |
---|
348 | |
---|
349 | ACKNOWLEDGEMENTS |
---|
350 | This work was supported by School of Mathematical Sciences at |
---|
351 | the Australian National University and funded by Australian |
---|
352 | Partnership for Advanced Computing (APAC). |
---|
353 | Many thanks go to |
---|
354 | |
---|
355 | Gian Paolo Ciceri (gp.ciceri@acm.org) |
---|
356 | for fixing pypar to run under Python 2.2 and for adding all the |
---|
357 | collective communication stuff from version 1.1 and onwards. |
---|
358 | Prabhu Ramachandran (prabhu@aero.iitm.ernet.in) |
---|
359 | for making a proper distutils installation procedure |
---|
360 | Simon D. W. Frost (sdfrost@ucsd.edu) and Vladimir Lazunin (lazunin@gmail.com) |
---|
361 | for testing pypar under Windows and creating the installation procedure |
---|
362 | Jakob Schiotz (schiotz@fysik.dtu.dk) and Steven Farcy (steven@artabel.net) |
---|
363 | for pointing out initial problems with pypar and MPICH. |
---|
364 | Markus Hegland (Markus.Hegland@anu.edu.au) |
---|
365 | for supporting the work. |
---|
366 | Doug Orr (doug@arbor.net) |
---|
367 | for identifying and fixing problem with LAM 7.0 requiring |
---|
368 | last commandline argumnet to be NULL. |
---|
369 | Dave Reed (dreed@capital.edu) |
---|
370 | for pointing out problem with LAM 7.0 and for testing the fix. |
---|
371 | Matthew Wakefield (matthew.wakefield@anu.edu.au) |
---|
372 | for pointing out and fixing support for Mac OS X (darwin) |
---|
373 | David Brown (David.L.Brown@kla-tencor.com) |
---|
374 | for contributing to the Windows/Cygwin installation procedure |
---|
375 | Michal Kaukic (mike@frcatel.fri.utc.sk) |
---|
376 | for pointing out the need for multi dimensional arrays and |
---|
377 | for suggesting an implementation in the 2D case. |
---|
378 | J K Nilsen for support and compiler patches |
---|
379 | Ross Wilson for designed the pypar logo in January 2009 |
---|
380 | Andrew Rowe (mr_andrew_d_rowe@hotmail.com) for fixing windows installation |
---|
381 | in March 2011. |
---|
382 | |
---|
383 | |
---|
384 | |
---|
385 | |
---|
386 | |
---|
387 | |
---|
388 | |
---|
389 | |
---|
390 | |
---|
391 | |
---|
392 | |
---|
393 | |
---|
394 | |
---|
395 | |
---|
396 | |
---|
397 | |
---|
398 | |
---|
399 | |
---|
400 | |
---|