Skip main navigation

Bonus hands-on: Parallel heat equation solver

Implement a parallel heat equation solver using MPI
© CSC - IT Center for Science Ltd.

If you would like to further practice your parallel programming skills, we have as a final parallel programming hands-on exercise parallelization of the heat equation solver with MPI.

Source code for this exercise is located in mpi/heat-equation/

Parallelise the serial heat equation solver in numpy/heat-equation/ with MPI,
by dividing the grid into blocks of rows and assigning one row block to one
task. A domain decomposition, that is.

Note that the tasks are able to update the grid independently everywhere else
than on the boundary rows – there the communication of a single row with the
nearest neighbor is needed. This can be achieved by having additional ghost
layers that contain the boundary data of the neighboring tasks. As the system
is aperiodic, the outermost ranks communicate with a single neighbor, and the
inner ranks with two neighbors.

Insert suitable MPI routines into the skeleton code in
skeleton.py (search for “TODO”s). Remember to update all ghost layers at each iteration.

A schematic representation of the decomposition looks like: Domain decomposition

Once you have a functioning parallel pure Python version, try to Cythonize the main computational kernel by utilizing your solution (or model solution) in Step 3.11.

© CSC - IT Center for Science Ltd.
This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now