CS 320/CSE 302/ECE 392

Introduction to Parallel Programming for Scientists and Engineers

MP5 - Due Friday, April 24

 

 

The objective of this MP is to write two MPI versions of the odd-even transposition sort.

 

First, you are requested to implement the algorithm presented in class where it is assumed that there is a single value per processor. Notice that the compare-exchange phase can be implemented using MPI_SENDRECV (see below how to find a description of this command) and letting each processor decide whether or not to replace its value with the one received from its partner.

 

For the second part, implement the same algorithm, but now assume each processor has M items (M>1).The compare-exchange phase can be implemented by having processor I and I+1 exchange the whole M-element array (I=1,3,.... for the odd phase, and I=2,4,.. for the even phase). Then both processors sort the combined arrays and then select the upper (processor I+1) or the lower half (processor I) of the array before moving to the next phase of the algorithm.

 

The value M should be read by processor 0 and then broadcast to all processors. Each processor should generate its list of M INTEGER items using a random number generator. Each processor should print its rank (myid) and the sorted M item list at the end of the algorithm.

 

For the extra 50 points, it is necessary to extend the algorithm so that, instead of exchanging all M items at once, several exchanges of N items (N<M) are carried out. This can be done using the algorithm described in the attached Chapter 18 of Solving Problems on Concurrent Processors by G. Fox et. al.

 

To run MPI programs, you should compile using

mpif77 <fortran source file (*.f)>

(mpif77 is in /usr/local/bin) and then run the program using

mpirun -np <number of processors> <executable file (a.out)>.

 

To get information about MPI commands, you can go to http://www.mcs.anl.gov/mpi and there click MPI Standard 1.1 on the left bar. Then go to the end of the frame on the right and click Index.

 

Finally, if you registered for 1 full unit: you will need 150 extra points.

If you have 100 extra points now you can do the extra work from MP5 (this one) or MP6 for 50 extra points.

If you have 50 extra points you need to do both the extra work from MP5 and MP6.

If you have 0 points you should do a special project. This is to implement in MPI the extra problem (the third version of the loop) from MP4.