CS475 Fall 2008 - HW 1
Parallel MPI Program to Compute the Value of Pi
Objectives
The objective of this lab is to write your
first MPI program, to debug and test it, and to experimentally determine
the gains you get in running it in parallel on up to 16 processors (two
nodes on bassi).
Problem Statement
This lab is to be performed on
bassi.nersc.gov. The Lab Schedule
has instructions that
explain how to start working with the NERSC environment in general and
bassi in particular.
Exercise 4.11 in the text describes how the value of Pi can be computed by
evaluating a definite integral. Your main assignment is to solve Problem
4.11. That is, turn in a correct working program that computes Pi using
the rectangle rule. You should also address 4.11 (b) relaing to the
performance of your parallel program on a varying number of processors and
report that in your lab report.
Your code should conform to the following:
- Your code should be parameterized with the number of strips to
evaluate, i.e., it should run for any value from 1000,000 to
10,000,000. Your program should take this value (the number of strips)
as a command line argument.
- You should use a cyclic distribution of the computations to
processors, as in the circuit satisfiability example in the text.
- Each process, after completing its share of computations should
print, to the stdout, its processor id, followed by its partial sum
(that it is going to return to the master process). Just print the
"raw" partial result, do not multiply it by 4. Use the following
format:
printf("%d %lf\n", rank, partial_result); where,
rank is the rank of the process, and partial_result
is the result it has computed and is going to return to the
master process.
- The master process (after adding up the partial results) should
print the final Pi Value. Use the following format:
printf("FINAL PI VALUE IS %lf\n", final_result); where,
final_result is the final value of Pi computed by the master
process.
Extra Credit: Implement a block distribution of computations
to processors.
What/When/How to Submit:
- 5:00 pm Tuesday, Sept 16. Program to be submitted via checkin. Instructions for
turning in your tar file.
- 2:00 pm, Thursday, Sept 18. Lab report to be turned in (hardcopy) in
class (distance students turn in their reports electronically using
checkin). If your program has been modified between submission of program
and lab report, please turn in the new version also by checkin, and
describe clearly in a README file included in the checkin, what has
changed (also briefly discuss these changes in your lab report).
Good luck and have fun!
Last Modified: 9/10/2008