Computer Science 400
Parallel Processing and High Performance Computing

Fall 2017, Siena College

Lab 9: More Collective Communication
Due: 11:59 PM, Monday, October 16, 2017

You will work with more collective communication routines in this lab. You may work alone or with a partner.

Getting Set Up

You will receive an email with the link to follow to set up your GitHub repository coll2-yourgitname for this Lab. One member of the group should follow the link to set up the repository on GitHub, then that person should email the instructor with the other group members' GitHub usernames so they can be granted access. This will allow all members of the group to clone the repository and commit and push changes to the origin on GitHub. At least one group member should make a clone of the repository to begin work.

Scatter and Gather

Question 1: Answer Pacheco Exercise 3.8 on p. 141. You may submit pictures of hand drawings or use a drawing program. (10 points)

A Monte Carlo Method to Compute pi

Not only games make use of random numbers. There is a class of algorithms knows as Monte Carlo methods that use random numbers to help compute some result.

We will write a parallel program that uses a Monte Carlo method to estimate the value of pi.

The algorithm is fairly straightforward. We repeatedly choose (x,y) coordinate pairs, where the x and y values are in the range 0-1 (i.e.the square with corners at (0,0) and (1,1). For each pair, we determine if its distance from (0,0) is less than or equal to 1. If it is, it means that point lies within the first quardant of a unit circle. Otherwise, it lies outside. If we have a truly random sample of points, there should be an equal probability that they have been chosen at any location in our square domain. The space within the circle occupies (pi)/(4) of the square of area 1.

So we can approximate pi by taking the number of random points found to be within the unit circle, dividing that by the total number of points and multiplying it by 4!

A sequential Java program to do this is included for your reference in the starter repository.

Practice Program: Write a C program, mpi_pi.c, parallelized with MPI, to approximate pi using the Monte Carlo method described. See below for some additional requirements and suggestions. (25 points)

Here is a sample run of my program, on 4 processes with 100,000,000 points per process. Your program should produce the same output in a similar format.

Will use 100000000 points per process
[0] 78540219 in circle, pi approx = 3.141609
[1] 78538052 in circle, pi approx = 3.141522
[2] 78541818 in circle, pi approx = 3.141673
[3] 78543977 in circle, pi approx = 3.141759
in circle values range from 78538052 to 78543977
Final approximation of pi: 3.141641

Question 2: Run your program for 1 billion points per process on 32, 128, and 512 processes on Stampede2. Rename your output files to stampede32.output, stampede128.output, and stampede512.output, and include them in your repository. (6 points)

Prefix Computations

Complete Pacheco Exercise 3.11 on p. 142. You need not write code for parts a, b, and c. The program you are asked to write in part d will be graded as a practice program. Name it prefix_sum.c. (Points breakdown: a. 2 points, b. 4 points, c. 8 points, d. 10 points)

Submitting

Your submission requires that all required deliverables are committed and pushed to the master for your repository on GitHub.

Grading

This assignment is worth 65 points, which are distributed as follows:

> FeatureValueScore
Ex. 3.8 a 5
Ex. 3.8 b 5
mpi_pi.c command-line parameter handling/checking/broadcast 5
mpi_pi.c random numbers 3
mpi_pi.c each rank computes its count 6
mpi_pi.c gather counts to rank 0 6
mpi_pi.c print counts/pi approximations 5
Lab Question 2: output captures 6
Ex. 3.11 a 2
Ex. 3.11 b 4
Ex. 3.11 c 8
Ex. 3.11 d 10
Total 65