CSCI 3366 (Parallel and Distributed Processing), Fall 2017:
Homework 1

Credit:
15 points.

Reading

Be sure you have read, or at least skimmed, the first few sections of the updated Appendix A (before writing your OpenMP program) and the first few sections of the updated Appendix B (before writing your MPI program).

Honor Code Statement

Please include with each part of the assignment the Honor Code pledge or just the word ``pledged'', plus one or more of the following about collaboration and help (as many as apply).1Text in italics is explanatory or something for you to fill in. For written assignments, it should go right after your name and the assignment number; for programming assignments, it should go in comments at the start of your program(s).

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!

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 two different programming environments (OpenMP and MPI), a parallel program that performs this calculation. (The next assignment will add additional programming environments.)

Details

Sequential starter programs

To get you started, I have written a sequential program in C that performs the desired calculation and prints 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 will need the flag -std=c99 or -std=c11 to compile the C code.)

Parallel programs

(10 points)

The programs you write (one each using OpenMP and MPI for this assignment, additional environments in the next assignment) 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.

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

Performance experiments

After you get each program working, you should try running it repeatedly, varying the number of threads or processes, to see whether more threads/processes really do help. Good machines to use for this purpose may be Dione for OpenMP (more processing elements than other machines) and the Pandora cluster (names Pandora01 through Pandora08) for MPI (Linux-only so shouldn't be rebooted out from under you).

Discussion of results

(5 points)

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 or name and the assignment (e.g., ``csci 3366 homework 1'' or ``parallel hw1'').



Footnotes

... apply).1
Credit where credit is due: I based the wording of this list on a posting to a SIGCSE mailing list. SIGCSE is the ACM's Special Interest Group on CS Education.


Berna Massingill
2017-09-29