MPI Lab07: Send and Receive

Objective
To run an MPI program. Topics include MPI_Send and MPI_Receive.

Background
For random numbers include stdlib.h. To seed the numbers, use the command srand(getpid());. Also include sys/types.h for this call to getpid(). To generate a random value, use the command rand() % 1000 + 1;, which gives you an integer in the range [1, 1000]--change appropriately.

randoms.c: Sample file for generating random numbers for each process in MPI.

Imagine you are at a dinner party and you want to know the average salary in the room, but you don't want to embarass anyone by having each person state his or her salary publicly. You write a large random number on a slip of paper and pass it to the person sitting next to you. That person adds his or her salary to the number, writes this sum on a new piece of paper, and passes it on to the next person. The process continues until the sum makes its way back to you. You simply subtract the large random number you had written initially and divide by the number of people at the table. Don't forget to add in your own salary!

Assignment
Create a file named salary.c that solves the problem stated above assuming that each node in your topology is a different "person" sitting at the table (use appropriate random numbers for each person's salary). You will have to use send and receive functions defined by MPI.

Sample Output
The average salary in the room is 85674.