Vous êtes sur la page 1sur 1

Parallel Programming 2016

Exercise 1. Communication in a ring of processes

Write a MPI program that sends a message around a number of processes


connected in a ring, and measures the time it takes for the message to travel around
the ring. The program should work for any number of processes greater than or
equal to two.

Process zero first reads in the size of the message and sends the message size to all
other processes in the ring. After that, it creates a message of the specified size and
sends it to the next process in the ring, and then waits for the message to complete
its trip around the ring and receives it from the last process. Process zero measures
how long time it takes before the message has completed a round through the ring
of processes, using MPI_Wtime.

The other processes in the ring receive the message from their predecessor and
send it further to the next process.

After a message has been sent one round through the ring, process zero reads a new
message size from the user, and repeats the operation. The program terminates
when the user enters a message size of zero. Make sure that all processes terminate
correctly.

The program should print out how long time the communication around the ring
took, the message size and the number of processes that participated. Test the
program and make sure that it works correctly both with small messages (a few
bytes) and with large messages (up to a gigabyte) and on process counts from two
up to 48.

Implement this program with C or C++ and MPI on Asterope. Make sure that the
program follows the given specification and implements all described behaviour.
Test the program carefully and verify that it works for varying message sizes and
numbers of processes.

1/1

Vous aimerez peut-être aussi