Homework Three

The goal of this assignment is learn basic message programming and to develop a program using simple partitioning. You will start with the examples given in Pacheco, Chapter 4. For this assignment you are to write two programs in either C or C++ using the MPI message passing library. Your programs must compile without warnings and execute correctly on eagle.csce.uark.edu for full credit. You must turn in both programs for full credit. Also, for full credit use good programming style, including the use of an appropriate amount of comments. In addition to the source code, your submission must also include the answers, in a plain text file, to the questions found at the end of the page. Submit the source code and answers to the questions to Hai Nguyen, hqn01@uark.edu.

For this assignment, I would like you to implement the adaptive version of the trapezoidal rule as described in class. I would like you to implement both a serial version and a parallel version. The interval should be input from the command line. The serial program should execute with the command line interface:

      trapezoid < left > < right >

The parallel version should execute under MPI with the command line interface:

      mpirun -np <number of processors> trapezoid < left > < right >

You may assume that in the serial version that you start with 2 trapezoids and double it each time until the result is "close enough". For the parallel version, you may assume that each process starts with 2 trapezoids and iterates independently until its portion is "close enough". You may hardcode the function.

Watch this space. I may give you another, more interesting function and interval to test.

For now, you may use

y=x^3 - 9x^2 + 26x - 24

Also, for convenience, you may use the following sample command line tests. You may also want to develop some test calls of your own:

The program should output the interval of integration, the value of the integral, the number of trapezoids used in the final calculation. For the parallel version you should print this information for each process as well as for the total.

For both programs answer the following summary questions in a plain text file:

  1. Were there any features of the assignment that did you not successfully implement?
  2. How did the input you used test your program thoroughly for its correct operation?
  3. How did you analyze the output of your program to prove to yourself that the output of your program shows your program is working correctly?
  4. How many hours did you spend designing, coding, and debugging this assignment?
Enjoy!