Program Execution

Simple MPI Program Execution

NICK/OPTIMUS/MAXWELL:

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

  •         $ mpicc —o <executablename> <sourcefilename>
  •         $ mpicc —o hello hello.c
  •         You can ignore feupdate warning

4.      Submit to Queue to Run Job

  •         Copy your skeleton submission script from belo
  •         Edit your script to fit your job:
  •         $ vi submit.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 -hostfile $PBS_NODEFILE /home/<username>/test/hello.exe’
  •         Once submit script is created, submit to queue to:
  •         $ qsub <scriptname>
  •         i.e. $ qsub submit.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’)
  •      $ cat hello.err
  •      $ 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 nodes=2:ppn=4

cd /home/<username>/test

mpirun -np 8 -hostfile $PBS_NODEFILE /home/<username>/test/hello

Simple Program Execution on 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=4:ncpus=1
#PBS -l place=free:shared

cd /home/<username>/test

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


PLEASE NOTICE the lines:

#PBS -l select=P:ncpus=T
#PBS -l place=free:shared

Where P is the number of MPI processes, and T is the number of OpenMP threads per process. If the job is purely MPI, T should be set to 1.

You must use these directives in order to run properly on ZIA.

Upcoming Events

There are no upcoming events at this time.