Objective
Write a MPI program to find sum of n values using p processors of
message passing cluster. Assume that p processors are arranged in ring topology.
Description
In linear array interconnection network with a wraparound connection is called
as a ring. A wraparound connection is often provided between the processors at the
end.A simple way of communicating a message between processors is, by repeatedly passing message
to the processor immediately to either right or left; depending on which direction yield a shorter
path, until it reaches its destination, i.e., first processor in the ring.
All the processes are involved in communication. The process with rank k
(k is greater than 0) receives the accumulated or partial sum
from the previous process with rank k-1. Process with rank p-1
sends the final sum to process with rank 0. Finally, process with rank 0
prints the final sum.
Input
For input data, let each process use its identifying number, i.e. the value of
its rank. For example, process with rank 0 uses the number 0, process
with rank 1 uses the number 1, etc.
Output
Process with rank 0 prints the final sum.