| pyMPI tutorialThere are a lot of things left to explore in the base python programming language, but this tutorial was written with the intention of teaching people how to use MPI (Message Passing Interface) to program a cluster. For this reason, we will need a version of python that understands MPI. You can get that here. If getting pyMPI to work on your favorite machine is proving to be tricky, you can download MEMPI from here. To execute a parallel program you need to use the mpirun command, and specify the number of processes you want the program to run on. In essence, we are launching two nearly identical programs, the only thing that is different is the value of mpi.rank that each has. In the example below we will run in two processes. One process will have mpi.rank == 0, and the other will have mpi.rank == 1. Both will see mpi.size == 2 (the number of processes).
Notice how confusing the output looks. This is because there is no way to coordinate output generated by the two processors. For this reason, we will normally use an if statement before each print:
| |||||||||||||||||||||||||