The easiest way is to simply use mpiexec (or mpirun) to run the program, specifying the number of MPI tasks required:
$ cat foo.py from mpi4py import MPI comm = MPI.COMM_WORLD nprocs = comm.Get_size() rank = comm.Get_rank() if rank == 0: data = 'Hello!' comm.send(data, dest=nprocs-1, tag=1) elif rank == nprocs-1: data = comm.recv(source=0, tag=1) print 'Rank ', rank, ' received ', data $ mpiexec -np 4 python foo.py Rank 3 received Hello!
Note, however, that working with 96 tasks on your laptop will probably not be particularly useful.
source share