Introduction to MPI - Exercise I
Write a parallel "Hello World Program" using MPI
1. Copy the file hello.c from /home/appl/mpiworkshop to a subdirectory called
"mpiworkshop" under your home directory, and name it hello_mpi.c
2. Edit hello_mpi.c into an MPI program in which each process outputs
whether it is the boss or a servant process.
- #include "mpi.h"
- Initialize MPI by calling MPI_Init
- Determine how many processes there are by calling MPI_Comm_size
- Determine the rank of the current process by calling MPI_Comm_rank
- Add a decision structure so that process #0 will print "Boss"
and all other processes will print "Servant" and their procss id
- Call MPI_Finalize
3. Compile/Debug the program using the MPI C compiler command "mpicc"
4. Copy the PBS file called "hello_mpi.pbs" from /home/appl/mpiworkshop
to your working directory.
5. Examine/edit the PBS file as needed to submit the job to 2 nodes and
add the path of mpicc and mpirun from /usr/local/apps/mpich-1.2.5 or
mpich-1.2.7p1/bin/mpicc and mpirun respectively.
6. Submit the job to PBS using:
7. Check the status of your job using:
qstat or qstat -u $USER
8. Examine the PBS error and output files, and repeat steps as necessary
until the output looks good.
9. Run checkprocs_me to make sure you have left no processes stranded on
10. Modify the pbs file to run the job on 4 nodes. Submit the job and
verify the output.