Go to USC home page USC Logo USC HPCG
UNIVERSITY OF SOUTH CAROLINA
GET ACCESS | NICK STATUS | DOCUMENTATION | NICK SPECIFICATIONS

HPCG HOME

ABOUT HPCG

SYSTEMS & ACCESS

PROJECTS & PUBLICATIONS

TUTORIALS & DOCS

COLLEGE HOME PAGE

USEFUL COMMANDS

COMPILING CODE

USING THE QUEUE

DOCUMENTATION
USC  THIS SITE

Simple MPI Program Execution

ZIA:

1.      Create Directory
-     $ mkdir test
-     $ cd test

(useful commands: ls, ls –ltra, pwd, cd .., cp)

2.      Creating C MPI Test Code
hello.c

-          Use vi text editor

-          $ vi <filename.c>

-          i.e. $ vi hello.c 

-          Enter code and properly format

3.      Compiling (NOTICE the library option -lmpi)

-          $ icc –o <executablename> -lmpi <sourcefilename>

-          $ icc –o hello -lmpi hello.c

-          You can ignore feupdate warning

4.      Submit to Queue to Run Job

-          Copy your skeleton submission script (or download here)

-          cp /work/submitZia.sh ~/

-          Edit your script to fit your job:

-          $ vi submitZia.sh

-          Edit number of appropriate nodes

-          Edit working directory

-          i.e. “cd /home/<username>/test/”

-          Edit command for PBS to run

-          i.e. “mpirun -np 4 /home/<username>/test/hello.exe”

-          Once submit script is created, submit to queue to:

-          $ qsub <scriptname>

-          i.e. $ qsub submitZia.sh

5.      Check standard Error and standard Output files

As specified in script:

### Output files
#PBS -o hello.out
#PBS -e hello.err

-          $ cat <errorfile or outputfile> (you can also use ‘more’)

-          i.e. $ cat hello.err

-          i.e. $ cat hello.out

 

hello.c Source code

Example of an MPI Program mpitest.c

/* program hello */
/* Adapted from mpihello.f by drs */

#include <mpi.h>
#include <stdio.h>

int main(int argc, char **argv)
{

     int *buf, i, rank, nints, len;
     char hostname[256];

     MPI_Init(&argc,&argv);

          MPI_Comm_rank(MPI_COMM_WORLD, &rank);
          gethostname(hostname,255);
          printf("Hello world! I am process number: %d on host %s\n", rank, hostname);

     MPI_Finalize();

     return 0;
}
 

PBS Script Example

#!/bin/sh
### Job name
#PBS -N helloMPI
### Output files
#PBS -o hello.out
#PBS -e hello.err
### Specify Resrouces
#PBS -l select=1:ncpus=4
#PBS -l place=free:shared


cd /home/<username>/test

mpirun -np 4 /home/<username>/test/hello

 
RETURN TO TOP
USC LINKS: DIRECTORY MAP EVENTS VIP
SITE INFORMATION