CSCI 3366 (Introduction to Parallel and Distributed Processing), Spring 2011:
Homework 1

Credit:
30 points.

Overview

First a reminder about something said in class: In doing this assignment, please do not discuss the problem or possible solutions with people who took this course in a previous year. I want you to discover the potential pitfalls yourselves!

In class we briefly discussed approximating the value of $ \pi$ by ``throwing darts'' at a square of side 2 enclosing a circle of radius 1, counting how many darts fall within the circle, and then dividing that by the total number of darts to get the ratio between the area of the circle ($ \pi$ ) and the area of the square (4). For this assignment, your mission is to write, for each of the programming environments we've talked about (OpenMP, MPI, and Java), a parallel program that performs this calculation.

Details

Sequential starter programs

To get you started, I have written sequential programs in C and Java that perform the desired calculation and print appropriate results:

Start by downloading these two programs, compiling them, and running them a few times to get a sense of what inputs you need to get a good approximation of $ \pi$ . Feel free to also tinker with the parts of the code that generate the sequence of random numbers; you may find some method you think will work better. (For the C program, review the man pages for rand and drand48. For the Java program, review the API (``Java docs'') for the Random class.)

Parallel programs

The three programs you write (one each using OpenMP, MPI, and Java) should accept the same command-line input and produce the same output as my sequential programs, except that:

You can also make any changes you like to how the programs work internally.

It's up to you how you choose to parallelize the sequential code, but notice that in many respects the calculation here strongly resembles the one in the numerical integration example, so the approaches we used for that example might work well here too. The only thing that's tricky is deciding what to do about the random numbers (should all the processes/threads generate the same sequence of random numbers? should they generate different ones? if so, how?). For this assignment, I want you to make your best guess about what would be reasonable, implement that, and see how it works. After everyone has turned something in, we'll discuss in class your results and possible improvements.

You can make my grading job a bit easier by using the following names for your programs:

Discussion of results

In addition to turning in your source code, briefly answer the following questions about each of your programs:

Keep in mind that this assignment is a first pass at producing good programs for this problem. Your programs should compile and produce output that's more or less reasonable, but you will have another chance (in Homework 2) to produce something that really works well, so it's okay this time if the output seems slightly off, or the performance is disappointing.

Hints and tips

What to turn in and how

Submit your program source code and discussion of results by sending mail to bmassing@cs.trinity.edu. Send program source as attachments. You can put your discussion of results in the body of the message or attach a file in any format readable on our Linux lab machines (plain text, PDF, something openable with OpenOffice, etc.). Please use a subject line that mentions the course number and the assignment (e.g., ``csci 3366 homework 1'').



Berna Massingill
2011-01-27