CSCI 3366 (Introduction to Parallel and Distributed Processing), Fall 2015:
Homework 1

Credit:
40 points.

Overview

First a general comment: For this assignment, please do not discuss the problem or possible solutions with each other or anyone else. I want you to discover any potential pitfalls yourselves! Also, don't worry too much at this point if your code doesn't perform very well. The objective is to get something working; there will be a follow-up assignment that focuses on addressing problems with performance and/or accuracy.

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 different programming environments (OpenMP, MPI, and Java) a parallel program that performs this calculation. (Notice that you will not be writing an OpenCL program for this assignment, but in the next assignment you'll be revising the programs you write for this assignment and adding one for OpenCL.)

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 this code, compiling it, and running it a few times to get a sense of what inputs you need to get a good approximation of $ \pi$ . (Notice that you may need the flag -std=c99 or -std=c11 to compile the C code.)

Parallel programs

The programs you write should accept the same command-line input and produce the same output as my sequential program, 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.

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 source code and other files by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course number and the assignment (e.g., ``csci 3366 homework 1''). If there's any question of which file(s) correspond to which problems, explain in the body of the mail message.



Berna Massingill
2015-12-17