Complete OpenMPI (mpirun) keyboard shortcuts and commands reference — 12 shortcuts across 2 categories. Quick reference cheat sheet for Windows & Mac.
mpirun is Open MPI's launcher, and its flags decide where processes land and how they are pinned, which for a GPU or HPC job matters as much as the code. The table lists the launch and environment options an operator actually types; the notes explain mapping versus binding, which is the distinction most tutorials blur.
| Shortcut | Action | Description |
|---|---|---|
| mpirun -n 4 ./prog | Run N processes | Launch 4 copies of the program across the allocated resources. |
| --hostfile hosts.txt | Host file | Specify a file listing hosts and slot counts to run on. |
| -H host1,host2 | Host list | Comma-delimited list of hosts to launch processes on directly. |
| -N 4 | Processes per node | Launch 4 processes on each allocated node (synonym: --npernode). |
| --map-by node | Mapping policy | Distribute processes round-robin across nodes instead of filling one node first. |
| --bind-to core | CPU binding | Bind each process to a specific CPU core for consistent performance. |
| Shortcut | Action | Description |
|---|---|---|
| -x VAR | Export env variable | Export an environment variable from the launching shell to every process. |
| --mca key value | Set MCA parameter | Pass a Modular Component Architecture parameter to tune Open MPI's behavior. |
| --allow-run-as-root | Allow root | Permit mpirun to launch as the root user; discouraged outside containers. |
| --display-map | Show process map | Print the mapped location of every process before launch, useful for debugging placement. |
| --oversubscribe | Oversubscribe | Allow launching more processes than available CPU slots. |
| -V | Version | Print the Open MPI version and exit. |
The most essential OpenMPI (mpirun) shortcuts are: mpirun -n 4 ./prog (Run N processes), --hostfile hosts.txt (Host file), -H host1,host2 (Host list).
These are command-line commands — type them in your terminal or console. Combine them with shell history search (Ctrl + R) and aliases to work even faster.
The OpenMPI (mpirun) shortcut for run n processes is mpirun -n 4 ./prog. Launch 4 copies of the program across the allocated resources.
Yes — use My Stack to combine OpenMPI (mpirun) shortcuts with any other platform on this site into one printable reference, which is useful if your daily workflow spans several tools.
mpirun -n 4 ./prog starts four ranks on the local host or the hosts Open MPI knows about. --hostfile hosts.txt names the hosts (with a slots= count per line) and -H host1,host2 lists them inline; -N 4 puts exactly four ranks on each node. Under Slurm none of this is needed — mpirun reads the allocation from the environment, and srun can launch directly.
Mapping decides the order ranks are assigned to resources and binding decides what each rank is pinned to. --map-by node distributes ranks round-robin across nodes (rank 0 on node A, rank 1 on node B…) rather than filling one node first, which balances memory bandwidth; --map-by ppr:1:numa is the usual form for one GPU per NUMA domain. --bind-to core locks every rank onto its own core, preventing the OS from migrating it, and is the single flag most likely to raise a benchmark score. --display-map prints the resulting layout before the program starts, and should be checked once per new cluster. --oversubscribe allows more ranks than slots, for testing on a laptop.
-x VAR exports an environment variable to every rank (-x LD_LIBRARY_PATH -x NCCL_DEBUG=INFO), which is how library paths and debugging flags reach remote hosts. --mca key value sets an Open MPI internal parameter — btl_tcp_if_include eth0 to choose a network, pml ucx to select the transport — and ompi_info --param all all lists them. --allow-run-as-root is required inside containers running as root; -V prints the version.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"