|
|
Introduction to MPI - Exercise II
Write a parallel program using MPI to add sum the elements of an
array of integers, using Broadcast and Gather
1. Copy the file add.c from /home/appl/mpiworkshop to a directory called
"mpiworkshop" under your home directory.
2. Examine, compile, and execute the add.c program on one node.
cat add.c
mpicc add.c
OR
/usr/local/apps/mpich-1.2.5/bin/mpicc add.c
3. Copy the partially developed parallel program add_mpi.c from
/home/appl/mpiworkshop to a directory called "mpiworkshop"
under your home directory.
4. Edit add_mpi.c by following the instructions in CAPITAL LETTERS
in the comments of the program.
5. Copy add_mpi.pbs from /home/appl/mpiworkshop to your working directory
and examine/edit the lines containing mpich-1.2.4 and change them to
mpich-1.2.5 or mpich-1.2.7p1 to compile and run add_mpi.c on 2 nodes.
6. Use qsub to submit the PBS job to PBS; qstat to monitor the job
in the queue; and examine the PBS error/output files.
7. Run checkprocs_me to ensure you have stranded no processes on any nodes.
8. Modify the PBS job to run it on 4 nodes, and resubmit.
9. What happens when you run it on 3 nodes?
OPTIONAL
10. Modify add_mpi.c so that it will still work correctly even if
the number of processes/nodes does not evenly divide into the
size of the array.
|