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:
|module load impi python/3.9.7
To run a mpi4py python program (e.g. helloworld.py):
|mpirun -np $NP python -m mpi4py helloworld.py
|mpirun -np $NP python3 -m mpi4py helloworld.py
where $NP is the number of MPI processes.
User may read the demo files and SLURM scripts provided under directory /share1/python/sample/mpi4py/.