Homework Five - MPI programming

Due : 11:59pm, Tuesday Decemeber 15, 2015

This is a hard deadline. Homeworks submitted after this time will not be considered.

Assignment:

Parallelize the program using MPI. To do this follow the instructions in

  • Using OpenMPI on Gollum and use the
  • hostfile for all nodes and cores using gigabit ethernet for spawning
  • When compiling and running you must NOT use gollum itself but one of the nodes node1 to node12.

    For this assignment you are to write programs in either C or C++ using the MPI message passing library. Your programs must compile without warnings and execute correctly for full credit. Also, for full credit use good programming style, including the use of an appropriate amount of comments.
    Place the code in a subdirectory called hw5 and submit using the svn.

    1. Write a program work.c for three processors in the boss-worker programming style. Specifically, P0 will be the boss. It will first create a 40000-element double precision 1-D array. The value for each array element will be the its index squared. Processors 1 and 2 will act as workers.
      P0 will transfer ONLY the odd-indexed elements of the array to P1. Similarly PO will transfer only the even-indexed elements to P2. Your program should do these transfers by making a new derived vector data type that consists of every other element in the 1-D array. The boss and each worker should use only one send/receive pair, using the new data type.
      P1 will then calculate the average of all the array elements which have an odd index. P2 will calculate the average of all the array elements which have an even index. When the workers are done they will output their results.
      Place the results in a file work.txt and submit to svn with the program.
    2. Write a program search.c in which four processors search an array in parallel (each gets a fourth of the elements to search). All the processors are searching the integer array for the element whose value is 11. There is only one 11 in the entire array of 40,000 integers.

      Use as input file called data which contains the integer array (ASCII, one element per line). Before the searching begins have ONLY P0 read in the array elements from the data file and distribute one fourth to each of the other three processors and keep one fourth for its own search.
      When one processor has found the element 11, it should notify all the other processors using a non-blocking MPI command, then print the index that the 11 was found at and stop. On receiving the notification the other processors should print out the index they are at at that time and stop searching. Place the results in a file search.txt and submit to svn with the program.


    This assignment is an individual assignment, to be done on your own without help from other persons including other students in the class. If you use materials from any sources other than the class notes, you must reference them explicitly in a comment in the program.

    Instructions for submitting the homework using svn are contained in this file.