Exercise 1

Your first exercise is to simply make sure you can get one-sided calls to work. Each of the synchronization pages provides code fragments that implement simple examples of each of the methods. Provide the remaining code to set up the RMA sections and verify that you can compile and run the code. Add some output statements so you can verify that the correct data has been moved around.

Solutions: fence.c, pscw.c, lul.c

Note: pscw.c is intended to run with exactly 3 processes and will not work otherwise.

Exercise 2

In the Scalability topic, we provided some example code to calculate pi to an arbitrary number of digits. This was done by using MPI_Bcast and MPI_Reduce. But it also provides a nice example where you can use MPI_Accumulate. There are a couple of different ways to do this, but the simplest is probably to use post-start-complete-wait, where the manager process (or whatever process you determine) holds the initial data and just performs a post-wait. All worker processes use start-complete to retrieve the data from the manager process and call MPI_Accumulate when they are finished to sum the results on the manager process. The manager process can then return the answer.

Solution: piacc.c

Exercise 3

In Exercise 2, we suggested that you alter the pi calculation routine to use post-start-complete-wait. However, all communication is point-to-point from the manager (or whoever you decide will hold the data) to each of the workers. That means that it shouldn't be too hard for you to implement it using lock-unlock as well.

Solution: pilul.c

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement