# Standard way(s) of launching MPI executable program?

**URL:** <https://ask.cyberinfrastructure.org/t/standard-way-s-of-launching-mpi-executable-program/3044>\
**Category:** Discussion Zone\
**Tags:** programming-for-hpc, slurm\
**Created:** [January 29, 2024, 8:33pm UTC](https://ask.cyberinfrastructure.org/t/standard-way-s-of-launching-mpi-executable-program/3044 "2024-01-29T20:33:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wirawan0](https://ask.cyberinfrastructure.org/user_avatar/ask.cyberinfrastructure.org/wirawan0/32/362_2.png) [@wirawan0](https://ask.cyberinfrastructure.org/u/wirawan0)\
**Post date:** [January 29, 2024, 8:33pm UTC](https://ask.cyberinfrastructure.org/t/standard-way-s-of-launching-mpi-executable-program/3044/1 "2024-01-29T20:33:37Z")

</div>

I want to poll the community to gather knowledge on one very basic thing: What is the standard way of launching an MPI executable program? Is this pretty universally acceptable across different clusters, different job schedulers, different hardware platform, etc.? The MPI standard since version 2.0 specifies `mpiexec` as the standardized name to launch MPI codes (see, e.g. standard version 4.1, [sec. 12.5 “Portable MPI Process Startup”](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report/node280.htm#Node280)).

_Background_: Evidently, at this present time, there are many different ways to launch MPI programs, and although `mpiexec` is supposed to be a standard, even implementors and site operators do not always support this standard command name.

Since I first learned MPI, at that time the command `mpirun` was the prevailing way among many clusters (read: the so-called “Linux Beowulf” clusters). Then I learned afterwards that there are many variations, e.g.

- On Cray HPC systems, they have a command-line launcher called `aprun` that users _have_ to use to get their programs (serial and parallel, I believe) running. (Apparently now it is not quite the case anymore, see e.g. [[https://support.hpe.com/hpesc/public/docDisplay?docId=a00115110en\_us&docLocale=en\_US&page=Parallel\_Application\_Launch\_Service\_PALS.html](https://support.hpe.com/hpesc/public/docDisplay?docId=a00115110en_us&docLocale=en_US&page=Parallel_Application_Launch_Service_PALS.html)]( HPE Cray Programming Environment User Guide CSM on HPE Cray EX (21.03) (S-8005))).)

- On some SLURM supercomputers such as NERSC, for OpenMPI, the documentation suggests using either `srun` or `mpirun` (see: [NERSC Wiki on Open MPI](https://docs.nersc.gov/development/programming-models/mpi/openmpi/) as of 2024-01-29).

- On PSC Bridges, I noted the use of `mpirun` (not explictly, but strongly implied in the [MPI Programming section](https://www.psc.edu/resources/bridges-2/user-guide/#programming-environment).

Anyone having insight of this varying ways launching MPI jobs? Do we even have a common way? I want to use this info to build a novice-level lesson for MPI that can apply to as many HPC cluster as possible, so that the best practice will become the first memory for the learners when they have to invoke their own MPI-parallel codes.

---

<div class="post-metadata">

**Author:** ![ktrn](https://ask.cyberinfrastructure.org/user_avatar/ask.cyberinfrastructure.org/ktrn/32/554_2.png) [@ktrn](https://ask.cyberinfrastructure.org/u/ktrn)\
**Post date:** [January 31, 2024, 1:21am UTC](https://ask.cyberinfrastructure.org/t/standard-way-s-of-launching-mpi-executable-program/3044/2 "2024-01-31T01:21:01Z")

</div>

This is indeed an interesting question.  
`mpiexec` is supposed to be a standardized way of running an MPI application and most if not MPI implementations provide this command.  
The [OpenMPI manual pages](https://docs.open-mpi.org/en/v5.0.x/man-openmpi/man1/mpirun.1.html) state that `mpiexec` and `mpirun` are synonyms for each other (a soft link to exactly the same executable) and will produce the exact same behavior. Since many clusters use `OpenMPI`, `mpirun` command is widely used there. However, for other MPI implementations, this might not be true.  
One would need to view the documentation for each implementation. For Intel MPI, you can see [this discussion](https://community.intel.com/t5/Intel-HPC-Toolkit/mpirun-vs-mpiexec/td-p/1121480).

srun is a `slurm` - specific command and is designed to deal with various MPI implementations using SLURM scheduler: not only OpenMPI but also IntelMPI, MPICH, etc. The idea is to make any MPI application run optimally on SLURM infrastructure. Details can be found on [SLURM’s MPI Documentation](https://slurm.schedmd.com/mpi_guide.html) website.

If you introduce users to an MPI programming, I would stick with `mpirun` and `mpiexec` commands. If, however, you teach them how to run MPI applications on a SLURM-based cluster, then you may want to consider `srun`.

---

<div class="post-metadata">

**Author:** ![nucci](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@nucci](https://ask.cyberinfrastructure.org/u/nucci)\
**Post date:** [March 11, 2024, 1:50pm UTC](https://ask.cyberinfrastructure.org/t/standard-way-s-of-launching-mpi-executable-program/3044/3 "2024-03-11T13:50:29Z")

</div>

I’ll “second” ktrn’s response. `mpirun` and `mpiexec` are about as standard as they come, and SLURM installations use `srun` for better integration with the job scheduling system. These are the start commands I used to use as part of the training I used to give for MPI.

For `mpirun` and `mpiexec` I’d also include all the necessary options for setting the number of hosts, the host file, etc. One of the advantages of `srun` is `SLURM` takes care of all these options.
