Basics of MPI Programming

5.2 mpirun mpiexec

mpirun (Windows) and mpiexec (Linux) are used to initiate MPI jobs.

mpirun (Windows)

mpirun is a .NET Assembly.   It is used to launch MPI and non-MPI processes on local and remote computers.

How do you specify the machines on which your program will be run? 
 


  • The simplest way is to call vsched -m to produce a file called machines, which consists of a list of the machines your batch job has allocated. If a machines file is produced, do not use the -mach_file and -pg_file parameters for mpirun.
  • If you do not have a SPMD program, you will probably need to use the -pg_file parameter for mpirun.  In this case you would need to create a file called myfile.pg, which consists of the machines that have been allocated, along with the executables to be run on each.  Here is an example of a .pg file:
ctc001.tc.cornell.edu 4 demo.exe
ctc002.tc.cornell.edu 3 demoSub.exe
ctc003.tc.cornell.edu 2 demoSub2.exe

    The following items are commonly-used parameters for the mpirun command.

    -np specifies the number of tasks to run

    -wd specifies the working directory to be used by the MPI processes. It is only necessary if your current directory and desired working directory are not the same.

    -h | -help displays the command line arguments for mpirun

    -verbose prints verbose output for debugging purposes

    -mpi_debug invokes extra checks on the input parameters and extra output if errors occur at runtime.

    -mpi_verbose switch to verbose output mode for the MPI/Pro application.  This information is different from that produced by the -verbose flag. 

    Example: mpirun -np 4 myexecutable.exe

    In this example, the machines file and executable must  be in the directory in which you issue the mpirun command.

    mpiexec (Linux)

    How do you specify the machines on which your program will be run? 

    • The simplest way is to call vsched -m to produce a file called machines, which consists of a list of the machines your batch job has allocated.

    /usr/bin/vsched -machines

    • Next start up the mpds on each machine. Following -f, specify the complete path to the machines file.

    mpdboot -n 2 -f $HOME/machines

    Use mpiexec to run the parallel job.

    run executable: mpiexec -n 2 myexe
                or
    run script: mpiexec -n 2 myscript

    Options

    -n (or -np) specifies the number of tasks to run

    -wdir specifies the working directory to be used by the MPI processes. It is only necessary if your current directory and desired working directory are not the same

    -l   labels standard out and standard error (stdout and  stderr) with the rank of the process

    For more options: type man mpiexec or mpiexec at a prompt.