mpirun
Run parallel applications using MPI
TLDR
Execute an Open MPI program
Execute an Open MPI program with n parallel processes
Allow more processes than available physical cores
SYNOPSIS
mpirun [options] <program> [<program_args>]
Or, for more detailed control over host specifications:
mpirun [options] -np <num_procs> -host <host1,host2,...> <program> [<program_args>]
Commonly aliased or superseded by mpiexec, which is part of the MPI standard:
mpiexec [options] <program> [<program_args>]
PARAMETERS
-np <N>
Specifies the number of processes to launch for the application.
-host <host1,host2,...>
Explicitly lists the hosts (nodes) on which to run the processes, typically in a comma-separated list.
-hostfile <filepath>
Specifies a file containing a list of hosts and their available slots (cores/processors) for process allocation.
--mca <key> <value>
(Open MPI specific) Used to set various internal parameters for Open MPI's Modular Component Architecture.
-wd <directory>
Sets the working directory for all launched processes on their respective nodes.
-x <ENV_VAR>
Exports a specified environment variable from the launching shell to the launched MPI processes.
-gdb / -tv
(Implementation specific) Launches the MPI application under a debugger (e.g., GDB) or a TotalView debugger wrapper.
--oversubscribe
(Open MPI specific) Allows the launching of more processes than available physical cores or slots on a node.
--bind-to <type>
(Open MPI specific) Specifies how processes should be bound to CPU resources (e.g., core, socket, none).
--map-by <type>
(Open MPI specific) Specifies how processes should be mapped to computing resources (e.g., node, socket, core).
DESCRIPTION
mpirun is a crucial command-line utility used to launch parallel applications written using the Message Passing Interface (MPI). It is typically provided as part of an MPI implementation (e.g., Open MPI, MPICH, Intel MPI). Its primary function is to orchestrate the execution of an MPI program across multiple processes, which can be distributed across different nodes in a computing cluster. mpirun handles the initialization of the MPI environment, process allocation, communication setup, and standard I/O redirection for the parallel application. It allows users to specify the number of processes, their placement on specific hosts or cores, and various runtime options crucial for performance tuning and debugging of distributed applications. While mpirun is widely used, the MPI standard itself defines mpiexec as the preferred launcher, which mpirun often serves as a wrapper or alias for.
CAVEATS
The exact behavior and available options of mpirun can vary significantly between different MPI implementations (e.g., Open MPI, MPICH, Intel MPI). Users must ensure that the mpirun command being used matches the MPI library against which their application was compiled. Proper environment setup, including PATH and LD_LIBRARY_PATH, is crucial for mpirun to locate the correct executables and libraries.
When used in a cluster environment, mpirun often integrates with resource managers like SLURM, PBS/Torque, or LSF, which handle initial resource allocation and job scheduling, passing the allocated resources to mpirun. Security considerations, such as passwordless SSH access between nodes, are often required for mpirun to launch processes remotely.
MPI STANDARD COMPLIANCE
While mpirun is widely recognized, the MPI standard specifies mpiexec as the portable command for launching MPI applications. mpirun in many MPI implementations (like Open MPI and MPICH) often behaves identically to mpiexec or is a symbolic link to it, ensuring compliance and portability across different MPI environments. This distinction is important for writing portable scripts.
RESOURCE MANAGER INTEGRATION
In large-scale High-Performance Computing (HPC) environments, mpirun is frequently used within the context of a job scheduler (e.g., SLURM, PBS, LSF). The scheduler first allocates computing resources (nodes, cores). Then, mpirun leverages this allocation to distribute and launch MPI processes across the assigned resources, often utilizing specific process managers or daemons provided by the MPI implementation (like OpenRTE for Open MPI or Hydra for MPICH).
HISTORY
The concept of a unified command for launching parallel MPI applications emerged with the development of the Message Passing Interface standard itself in the early 1990s. While various early parallel computing systems had their own job launchers, mpirun became a de-facto standard adopted by many MPI implementations to provide a consistent user experience for launching distributed programs.
The MPI Forum, recognizing the need for a standardized launcher, defined mpiexec as part of the MPI-2 standard (1997). Many MPI implementations, including Open MPI and MPICH, continue to provide mpirun as a user-friendly alias or a wrapper around their mpiexec-compliant launcher, ensuring backward compatibility and familiarity for users. Its development has closely tracked the evolution of MPI, adapting to new network technologies, processor architectures, and resource management systems in high-performance computing.
SEE ALSO
mpiexec(1): The standard MPI launcher defined by the MPI Forum, often aliased by mpirun., orterun(1): (Open MPI specific) The actual executable that mpirun often points to in Open MPI., srun(1): SLURM job step launcher, used in conjunction with resource manager environments., qsub(1): PBS/Torque command for submitting jobs to a batch system., ssh(1): Often used by mpirun for remote process spawning.