Skip main navigation

£199.99 £139.99 for one year of Unlimited learning. Offer ends on 28 February 2023 at 23:59 (UTC). T&Cs apply

Find out more

Hands-on: Message exchange

Message exchange using MPI
© CC-BY-NC-SA 4.0 by CSC - IT Center for Science

In this exercise we study sending and receiving data between two MPI process.

Source code for this exercise is located in mpi/message-exchange/

Communicating general Python objects

Write a simple program where two processes send and receive a message to/from
each other using send and recv. The message content is a dictionary {‘rank’ : myrank} where myrank is the rank of the sending process.
After receiving a message, each process should print out the rank of the
process and the value in the received dictionary.

Communicating NumPy arrays

In each process, construct a 100 000 element NumPy array which is initialized
to the rank of process. Send and receive the array using Send and Recv and after receiving print out the rank of process together with the first element of the received array. Investigate what happens when reordering the send and receive calls in one of the processes.

© CC-BY-NC-SA 4.0 by CSC - IT Center for Science
This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education