CS475 Fall 2009 - 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). Additionally, you will have two versions of your code: one
using a block distribution and one using a cyclic distribution. The
timings for both versions should be compared and discussed in your report.
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) relating 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 1,000,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.
- You should submit the C source code in a file named pi_cycle.c by Sept. 15, midnight.
Block Distribution: Modify pi_cycle.c to use a block distribution
of computations to processors. The code for this program should be named
pi_block.c and is due by 2:00pm on Thursday. Block distribution will be
discussed in class on Tuesday.
What/When/How to Submit:
- Midnight, Tuesday, Sept 15. pi_cycle.c to be submitted via checkin as HW1. Instructions for
turning in your tar file.
- 2:00 pm, Thursday, Sept 17. pi_block.c to be submitted via checkin as
HW1_PART2. Lab report to be turned in (hardcopy) in class (distance
students turn in their reports electronically using checkin as HW1_REPORT).
If pi_cycle.c has been modified between submission of HW1 and the lab
report, please turn in the new version also by checkin as HW1_PART2, 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/2009