Introduction to MPI

This page gathers together resources for the Introduction to MPI course by MJ Rutter for the 2020 MPhil / CDT in the Centre for Scientific Computing. The copyright of the contents is held by its author, unless otherwise stated.

Handout

Example Materials

The Beginning (lecture 2)

More Quadrature (lecture 3)

Mandelbrot Set (lecture 4)

Some prefer to see examples in Fortran, and, for them, mandel_mpi.f90 is provided. This uses mpi_gather to collect the whole array onto the root process before writing it out. It uses stream I/O (introduced in Fortran 2003). It could be modified to use the inquire statement and pos option to the write statement in order to let each MPI process write its own line, in a similar fashion to the C codes above.

As an extra example, combining MPI with GTK (with no proof that they are compatible), mgtk.c. This is a master-slave Mandelbrot set which displays its output via GTK. It is intended as an MPI example, not an example of good MPI+GTK programming. One can readily see idle slaves consuming CPU time in this example.

(One might well argue that modern computers are so fast that there is little reason to use the power of MPI for this problem, and even serial python codes such as this GTK3 python Mandelbrot set are quite fast enough. On the other hand, the MPI code presented here was used to produce a 31,500x10,500 pixel image of part of the Mandelbrot set with maxiter set to 2048. This was then printed at 300dpi to produce a poster for a school. An attempt to produce an image of this size using Mathematica's MandelbrotSetPlot function failed, whereas the MPI code succeeded on a much more modest computer.)

Laplace's Equation (lecture 5)

Miscellaneous (lecture 6)

Communicators (lecture 7)

MPI-IO (lecture 7)

Hardware (lecture 8)

Useful Links