What is MPI for Python?

MPI for Python (mpi4py) provides bindings of the Message Passing Interface (MPI) standard for Python programming language, allowing Python program to exploit multiple processors.

What is MPI?

MPI, the message Passing Interface, is a standarized and portable message-passing system designed to function on a wide variety of parallel computers. The standard defines the syntax and semantics of library routines and allows users to write portable programs in the main scientific programming languages (Fortran, C, C++, etc).

What is Python?

Python is a modern, easy ro learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming with dynamic typing and dynamic binding. It supports modules and packages, which encourages program modularity and code reuse. Python is ideal for writing higher-level parts of large-scale scientific applications and driving simulations in parallel architecture like clusters of PC’s or SMP’s.

Using MPI for Python

To use mpi4py, user should use the following commands:

System Python version Command
HPC2015 2.7.11 module load impi python/2.7.11
3.4.3 module load impi python/3.4.3
3.6.3 module load impi python/3.6.3

To run a mpi4py python program (e.g. helloworld.py):

Python 2.x mpirun -np $NP python -m mpi4py helloworld.py
Python 3.x mpirun -np $NP python3 -m mpi4py helloworld.py

where $NP is the number of MPI processes.

User may read the demo files and pbs scripts provided under directory /share1/python/sample/mpi4py/.

Additional Information

Official documentation can be obtained from MPI for Python Website or User Manual

Related pages: MPICH, OpenMPI, Intel MPI, MPI Programming Self-learn tutorial