Links: [Course Home] [Schedule] [Moodle]
Due Tuesday, Feb. 19 at 10:45 AM. No late submissions accepted.
Complete the following problems. In order to receive credit, you must show enough work to make it clear how you arrived at your answer.
For written solutions, you may submit your assignment via hard copy (in class or office hours) or as a PDF or .doc/.docx/.txt via Moodle. If you do submit via Moodle, it is your responsibility to verify that your submitted file is correctly formatted. Corrupted or unreadable files will not receive any credit.
For code submissions, please submit your source file(s) via Moodle. If you have more than once source file, please include a makefile.
You may work in groups of up to three students and turn in one solution for the group. Make sure that all group members' names are on all submitted documents.
Turn in an MPI program that implements Programming Assignment 3.2 (pp. 147-148) in the textbook, with the following additional specifications:
These directions assume that you will be using cwolf. You are welcome to use some other system, but you're on your own with the MPI installation.
Add the following lines to the .bash_profile (notice the dot) file in your home directory on cwolf:
alias mpicc=/usr/lib64/openmpi/bin/mpicc alias mpiexec=/usr/lib64/openmpi/bin/mpiexec
Then type
source ~/.bash_profile
followed by
which mpiexec
You should see something like
alias mpiexec='/usr/lib64/openmpi/bin/mpiexec' /usr/lib64/openmpi/bin/mpiexec
Copy an MPI "Hello World" program (from your textbook or elsewhere) and compile it:
mpicc -o hello.out hello_world.c
Run it with 4 processes:
mpiexec -n 4 ./hello.out
Process 0 should ask the user for the number of throws to simulate and then broadcast that answer to the other processes.
Define a function
long long int get_input(int my_rank, int size)that gets and returns the user's input. This will be similar to Program 3.5 in the textbook, but you should use MPI_Bcast instead of individual sends and receives.
Next, implement the simulation code. Some cautionary notes on obtaining a random double:
(double)rand() / (double)RAND_MAXThis has some flaws, but I'm OK with you using it.
srand()to seed the random number generator. It should be something that's not the same for every process -- otherwise, what's the point?
Use MPI_Reduce to send all of the results back to Process 0, and print the result.
Insert timing code that uses the MPI_Wtime library. The timing should start just after get_input returns, and it should end after the call to MPI_Reduce. Use MPI_Reduce again to print the maximum time across all of the processes.
Document your code. In your initial comment, include a discussion of how you seeded the random number generator and any other pertinent issues.
This section is based on your MPI program from the previous section.
To start, find a number of throws that takes a few minutes (2-10) for 1 process to complete. Let's call the runtime T and the number of throws N.
Submit a writeup that includes the following information: