Sending in a ring (broadcast by ring)


Sending data in a ring



1. Write a program that takes data from process zero and sends it to all of the other processes by sending it in a ring. That is, process i should receive the data and send it to process i+1, until the last process is reached.
Assume that the data consists of a single integer. Process zero reads the data from the user. The input value is read from the terminal by process zero and sent to all others until a negative integer is given as input.

You may want to use these MPI routines in your solution:

2. Read your data from a file (say ring.dat). How is your output compare to the previous output?