Skip main navigation

Hands-on: Message exchange

Message exchange using MPI
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

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