MCSR_logo.jpg (56K)
Home My MCSR Supercomputers Software Research Education
Login
Quick Links:

FAQs
Minicamp
Chemistry
insideHPC Blog
Current Jobs
Job History
Mathematica
Training
News
Contact Us

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: qsub hello_mpi.pbs
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. ls cat hello_mpi.pbs.eXXXX cat hello_mpi.pbs.oXXXX
9. Run checkprocs_me to make sure you have left no processes stranded on the nodes.
10. Modify the pbs file to run the job on 4 nodes. Submit the job and verify the output.

Last Modified:June 08, 2007 10:31:43.   Copyright © 1997-2012 The Mississippi Center for Supercomputing Research. All Rights Reserved.   The University of Mississippi
Valid RSS