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).
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 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 () 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.)
To get you started, I have written a sequential program in C that performs the desired calculation and prints appropriate results:
(5 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 note 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:
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).
(5 points)
In addition to turning in your source code, briefly answer the following questions about each of your programs:
Submit your program source code and discussion of results by putting them in the “turn-in” folder I set up for each of you on Google Drive (it should be in your “shared with me” with a name that starts with CSCI3366), specifically in the HW01 subfolder.
(Yes, this is different from how I asked students to submit work in previous semesters. I figure try it out, and if it goes badly we can go back to e-mail, though that's not without problems either.)
Include with your assignment the following information.
For programming assignments, please put it a separate file. (I strongly prefer plain text, but if you insist you can put it in a PDF -- just no word-processor documents or Google Drive links please). For written assignments, please put it in your main document.
This should include the Honor Code pledge, or just the word “pledged”, plus at least one of the following about collaboration and help (as many as apply). Text in italics is explanatory or something for you to fill in; you don't need to repeat it!
This should be a brief essay (a sentence or two is fine, though you can write as much as you like) telling me what if anything you think you learned from the assignment, and what if anything you found interesting, difficult, or otherwise noteworthy.