MPIRUN(1)

πŸŽ€ MPIRUN(1) β€” mpirun, mpiexec: Execute serial and parallel jobs in Open MPI πŸŽ€

okay bestie, welcome to the Open MPI launch-page glow-up πŸ’… this is where mpirun and mpiexec live, and they are literally the same thing.

πŸ’– NOTE πŸ’–

mpirun and mpiexec are synonyms for each other. No cap: they are symbolic links to the same executable. Using either name will produce the exact same behavior. periodt ✨


🌈 SYNOPSIS 🌈

πŸ¦‹ Single Process Multiple Data (SPMD) Model:

mpirun [ options ] <program> [ <args> ]

πŸ¦‹ Multiple Instruction Multiple Data (MIMD) Model:

mpirun [ global_options ]
       [ local_options1 ] <program1> [ <args1> ] :
       [ local_options2 ] <program2> [ <args2> ] :
       ... :
       [ local_optionsN ] <programN> [ <argsN> ]

Note that in both models, invoking mpirun via an absolute path name is equivalent to specifying the --prefix option with a <dir> value equivalent to the directory where mpirun resides, minus its last subdirectory. For example:

shell$ /usr/local/bin/mpirun ...

is equivalent to

shell$ mpirun --prefix /usr/local

⭐ QUICK SUMMARY ⭐

If you are simply looking for how to run an MPI application, you probably want to use a command line of the following form:

shell$ mpirun [ -n X ] [ --hostfile <filename> ]  <program>

This will run X copies of <program> in your current run-time environment (if running under a supported resource manager, Open MPI’s mpirun will usually automatically use the corresponding resource manager process starter, as opposed to ssh (for example), which require the use of a hostfile, or will default to running all X copies on the localhost), scheduling (by default) in a round-robin fashion by CPU slot. See the rest of this documentation for more details. πŸ‘‘

Please note that mpirun automatically binds processes to hardware resources. Three binding patterns are used in the absence of any further directives (See map/rank/bind defaults for more details):

  • Bind to core: when the number of processes is <= 2
  • Bind to package: when the number of processes is > 2
  • Bind to none: when oversubscribed

If your application uses threads, then you probably want to ensure that you are either not bound at all (by specifying --bind-to none), or bound to multiple cores using an appropriate binding level or specific number of processing elements per application process. 🧡✨


🧚 OPEN MPI’S USE OF PRRTE 🧚

Open MPI uses the PMIx Reference Runtime Environment (PRRTE) as the main engine for launching, monitoring, and terminating MPI processes.

Much of the documentation below is directly imported from PRRTE. As such, it frequently refers to PRRTE concepts and command line options. Except where noted, these concepts and command line argument are all applicable to Open MPI as well. Open MPI extends the available PRRTE command line options, and also slightly modifies the PRRTE’s default behaviors in a few cases. These will be specifically described in the documentation below. 🫢


πŸ’œ COMMAND LINE OPTIONS πŸ’œ

The core of Open MPI’s mpirun processing is performed via the PRRTE. Specifically: mpirun is effectively a wrapper around prterun, but mpirun’s CLI options are slightly different than PRRTE’s CLI commands.

🫧 No content 🫧

There is no meaningful content in this file because Open MPI was either:

  • Built without PRRTE support.
  • Built with a PRRTE that was too old to include machine-readable documentation that could be incorporated into Open MPI’s documentation.

If you build Open MPI with a newer version of PRRTE (and have the Sphinx tool available when you run Open MPI’s configure command), you should get more meaningful documentation here.

Hence, there is no documentation for this section.

Sorry! 😭


🚧 OPTIONS (OLD / HARD-CODED CONTENT β€” TO BE AUDITED) 🚧

This is old content This is the old section of manually hard-coded content. It should probably be read / audited and see what we want to keep and what we want to discard. Feel free to refer to https://docs.prrte.org/ rather than replicating content here (e.g., for the definition of a slot and other things).

mpirun will send the name of the directory where it was invoked on the local node to each of the remote nodes, and attempt to change to that directory. See the β€œCurrent Working Directory” section below for further details. πŸ“

  • <program> β€” The program executable. This is identified as the first non-recognized argument to mpirun.
  • <args> β€” Pass these run-time arguments to every new process. These must always be the last arguments to mpirun. If an app context file is used, <args> will be ignored.
  • -h, --help β€” Display help for this command.
  • -q, --quiet β€” Suppress informative messages from orterun during application execution.
  • -v, --verbose β€” Be verbose.
  • -V, --version β€” Print version number. If no other arguments are given, this will also cause orterun to exit.
  • -N <num> β€” Launch num processes per node on all allocated nodes (synonym for --npernode).
  • --display-map β€” Display a table showing the mapped location of each process prior to launch.
  • --display-allocation β€” Display the detected resource allocation.
  • --output-proctable β€” Output the debugger proctable after launch.
  • --dvm β€” Create a persistent distributed virtual machine (DVM).
  • --max-vm-size <size> β€” Number of daemons to start.

Use one of the following options to specify which hosts (nodes) of the cluster to run on. Note that as of the start of the v1.8 release, mpirun will launch a daemon onto each host in the allocation (as modified by the following options) at the very beginning of execution, regardless of whether or not application processes will eventually be mapped to execute there. This is done to allow collection of hardware topology information from the remote nodes, thus allowing us to map processes against known topology. However, it is a change from the behavior in prior releases where daemons were only launched after mapping was complete, and thus only occurred on nodes where application processes would actually be executing. 🌐

  • -H, --host <host1,host2,...,hostN> β€” list of hosts on which to invoke processes.
  • --hostfile <hostfile> β€” Provide a hostfile to use.
  • --default-hostfile <hostfile> β€” Provide a default hostfile.
  • --machinefile <machinefile> β€” Synonym for --hostfile.
  • --cpu-set <list> β€” Restrict launched processes to the specified logical CPUs on each node (comma-separated list). Note that the binding options will still apply within the specified envelope β€” e.g., you can elect to bind each process to only one CPU within the specified CPU set.

The following options specify the number of processes to launch. Note that none of the options imply a particular binding policy β€” e.g., requesting N processes for each package does not imply that the processes will be bound to the package. πŸ”’

  • -n, --n, -c, -np <#> β€” Run this many copies of the program on the given nodes. This option indicates that the specified file is an executable program and not an application context. If no value is provided for the number of copies to execute (i.e., neither the -n nor its synonyms are provided on the command line), Open MPI will automatically execute a copy of the program on each process slot (see PRRTE’s definition of β€œslot” for description of a β€œprocess slot”). This feature, however, can only be used in the SPMD model and will return an error (without beginning execution of the application) otherwise.
NOTE: The -n option is the preferred option to be used to specify the number of copies of the program to be executed, but the alternate options are also accepted.
  • --map-by ppr:N:<object> β€” Launch N times the number of objects of the specified type on each node.
  • --npersocket <#persocket> β€” On each node, launch this many processes times the number of processor sockets on the node. The -npersocket option also turns on the --bind-to-socket option. (deprecated in favor of --map-by ppr:n:package)
  • --npernode <#pernode> β€” On each node, launch this many processes. (deprecated in favor of --map-by ppr:n:node).
  • --pernode β€” On each node, launch one process β€” equivalent to --npernode 1. (deprecated in favor of --map-by ppr:1:node)

To map processes: πŸ—ΊοΈ

  • --map-by <object> β€” Map to the specified object, defaults to package. Supported options include slot, hwthread, core, L1cache, L2cache, L3cache, package, numa, node, seq, rankfile, pe-list=#, and ppr. Any object can include modifiers by adding a : and any combination of the following:
    • pe=n β€” bind n processing elements to each proc
    • span β€” load balance the processes across the allocation
    • oversubscribe β€” allow more processes on a node than processing elements
    • nooversubscribe β€” do not allow more processes on a node than processing elements (default)
    • nolocal β€” do not place processes on the same host as the mpirun process
    • hwtcpus β€” use hardware threads as CPU slots for mapping
    • corecpus β€” use processor cores as CPU slots for mapping (default)
    • file=filename β€” used with rankfile; use filename to specify the file to use
    • ordered β€” used with pe-list to bind each process to one of the specified processing elements
NOTE: socket is also accepted as an alias for package.
  • --bycore β€” Map processes by core (deprecated in favor of --map-by core).
  • --byslot β€” Map and rank processes round-robin by slot (deprecated in favor of --map-by slot).
  • --nolocal β€” Do not run any copies of the launched application on the same node as orterun is running. This option will override listing the localhost with --host or any other host-specifying mechanism. Alias for --map-by :nolocal.
  • --nooversubscribe β€” Do not oversubscribe any nodes; error (without starting any processes) if the requested number of processes would cause oversubscription. This option implicitly sets β€œmax_slots” equal to the β€œslots” value for each node. (Enabled by default). Alias for --map-by :nooversubscribe.
  • --oversubscribe β€” Nodes are allowed to be oversubscribed, even on a managed system, and overloading of processing elements. Alias for --map-by :oversubscribe.
  • --bynode β€” Launch processes one per node, cycling by node in a round-robin fashion. This spreads processes evenly among nodes and assigns MPI_COMM_WORLD ranks in a round-robin, β€œby node” manner. (deprecated in favor of --map-by node)

πŸ’« To specify the processor IDs (continued)

  • --cpu-list <cpus> β€” a comma-delimited list of processor IDs that your processes get bound to [default=NULL]. Heads up: those processor IDs are interpreted as hwloc logical core IDs, bestie. 🧚
NOTE: run the hwloc lstopo(1) command to see a list of available cores and their logical IDs. Slay, now you know exactly which ones you're grabbing. πŸ’…

πŸ”’ To order processes' ranks in MPI_COMM_WORLD

  • --rank-by <mode> β€” rank in round-robin fashion according to the mode you pick, and it defaults to slot. Supported options include slot, node, fill, and span.

πŸ“Œ For process binding

  • --bind-to <object> β€” bind processes to the specified object, defaults to core. Supported options include slot, hwthread, core, l1cache, l2cache, l3cache, package, numa, and none.
  • --cpus-per-proc <#perproc> β€” bind each process to the specified number of cpus. (deprecated in favor of --map-by <obj>:PE=n) πŸ‘€ yes, deprecated, use the other one.
  • --cpus-per-rank <#perrank> β€” alias for --cpus-per-proc. (deprecated in favor of --map-by <obj>:PE=n)
  • --bind-to-core β€” bind processes to cores (deprecated in favor of --bind-to core)
  • --bind-to-socket β€” bind processes to processor sockets (deprecated in favor of --bind-to package)
  • --report-bindings β€” report any bindings for launched processes. Fr fr, great for vibe-checking where everything landed. πŸ”

πŸ—‚οΈ For rankfiles

  • --rankfile <rankfile> β€” provide a rankfile file. (deprecated in favor of --map-by rankfile:file=FILE)

πŸ–¨οΈ To manage standard I/O

  • --output-filename <filename> β€” redirect the stdout, stderr, and stddiag of all processes to a process-unique version of the specified filename. Any directories in the filename will automatically be created. Each output file will consist of filename.id, where the id will be the processes' rank in MPI_COMM_WORLD, left-filled with zero's for correct ordering in listings. A relative path value will be converted to an absolute path based on the cwd where mpirun is executed. Note that this will not work on environments where the file system on compute nodes differs from that where mpirun(1) is executed. 😭 (yes that last bit matters, don't skip it)
  • --stdin <rank> β€” the MPI_COMM_WORLD rank of the process that is to receive stdin. The default is to forward stdin to MPI_COMM_WORLD rank 0, but this option can be used to forward stdin to any process. It is also acceptable to specify none, indicating that no processes are to receive stdin. πŸ™ˆ
  • --merge-stderr-to-stdout β€” merge stderr to stdout for each process.
  • --tag-output β€” tag each line of output to stdout, stderr, and stddiag with [jobid, MCW_rank]<stdxxx> indicating the process jobid and MPI_COMM_WORLD rank of the process that generated the output, and the channel which generated it. Iconic little labels. 🏷️
  • --timestamp-output β€” timestamp each line of output to stdout, stderr, and stddiag.
  • --xml β€” provide all output to stdout, stderr, and stddiag in an XML format.
  • --xml-file <filename> β€” provide all output in XML format to the specified file.
  • --xterm <ranks> β€” display the output from the processes identified by their MPI_COMM_WORLD ranks in separate xterm windows. The ranks are specified as a comma-separated list of ranges, with a -1 indicating all. A separate window will be created for each specified process. πŸͺŸβœ¨
NOTE: xterm will normally terminate the window upon termination of the process running within it. However, by adding a ! to the end of the list of specified ranks, the proper options will be provided to ensure that xterm keeps the window open after the process terminates, thus allowing you to see the process' output. Each xterm window will subsequently need to be manually closed. Note: In some environments, xterm may require that the executable be in the user's path, or be specified in absolute or relative terms. Thus, it may be necessary to specify a local executable as ./my_mpi_app instead of just my_mpi_app. If xterm fails to find the executable, mpirun will hang, but still respond correctly to a ctrl-C. If this happens, please check that the executable is being specified correctly and try again. πŸ’€

πŸ“ To manage files and runtime environment

  • --path <path> β€” <path> that will be used when attempting to locate the requested executables. This is used prior to using the local PATH environment variable setting.
  • --prefix <dir> β€” prefix directory that will be used to set the PATH and LD_LIBRARY_PATH on the remote node before invoking Open MPI or the target process. See the Remote Execution section, below.
  • --noprefix β€” disable the automatic --prefix behavior.
  • --preload-binary β€” copy the specified executable(s) to remote machines prior to starting remote processes. The executables will be copied to the Open MPI session directory and will be deleted upon completion of the job. 🚚
  • --preload-files <files> β€” preload the comma-separated list of files to the current working directory of the remote machines where processes will be launched prior to starting those processes.
  • --set-cwd-to-session-dir β€” set the working directory of the started processes to their session directory.
  • --wd <dir> β€” synonym for -wdir.
  • --wdir <dir> β€” change to the directory <dir> before the user's program executes. See the Current Working Directory section for notes on relative paths. Note: if the --wdir option appears both on the command line and in an application context, the context will take precedence over the command line. Thus, if the path to the desired wdir is different on the backend nodes, then it must be specified as an absolute path that is correct for the backend node. 🫢
  • -x <env> β€” export the specified environment variables to the remote nodes before executing the program. Only one environment variable can be specified per -x option. Existing environment variables can be specified or new variable names specified with corresponding values. For example:
shell$ mpirun -x DISPLAY -x OFILE=/tmp/out ...

The parser for the -x option is not very sophisticated; it does not even understand quoted values. Users are advised to set variables in the environment, and then use -x to export (not define) them. πŸ₯² lowkey just export, don't try to be cute with it.

πŸŽ›οΈ Setting MCA parameters

  • --gmca <key> <value> β€” pass global MCA parameters that are applicable to all contexts. <key> is the parameter name; <value> is the parameter value.
  • --mca <key> <value> β€” send arguments to various MCA modules. See the Setting MCA Parameters section for more details.
NOTE: Open MPI will attempt to discern PMIx and PRRTE MCA parameters passed via --mca and handle them appropriately, but it may not always guess correctly. It is best to use --pmixmca and --prtemca when passing MCA parameters to PMIx and PRRTE, respectively. πŸ’… bestie, please just be specific.
  • --pmixmca <key> <value> β€” send arguments to MCA modules in the PMIx subsystem. See the Setting MCA Parameters section for more details.
  • --prtemca <key> <value> β€” send arguments to MCA modules in the PMIx Reference Runtime Environment (PRRTE) subsystem. See the Setting MCA Parameters section for more details.
  • --tune <tune_file> β€” specify a tune file to set arguments for various MCA modules and environment variables. See:
:ref:` Setting MCA parameters and environment variables from file
<man1-mpirun-setting-mca-params-from-file>`

Also, --am <arg> is an alias for --tune <arg>. πŸŽ€

πŸ› For debugging

  • --get-stack-traces β€” when paired with the --timeout option, mpirun will obtain and print out stack traces from all launched processes that are still alive when the timeout expires. Note that obtaining stack traces can take a little time and produce a lot of output, especially for large process-count jobs. 😭 it's giving "a lot" and it means it.
  • --timeout <seconds> β€” the maximum number of seconds that mpirun will run. After this many seconds, mpirun will abort the launched job and exit with a non-zero exit status. Using --timeout can be also useful when combined with the --get-stack-traces option. ⏰πŸ”₯

🌈 There are also other options

  • --allow-run-as-root β€” allow mpirun to run when executed by the root user (mpirun defaults to aborting when launched as the root user). Be sure to see the Running as root section for more detail.
  • --app <appfile> β€” provide an appfile, ignoring all other command line options.
  • --continuous β€” job is to run until explicitly terminated. main character energy, it does not stop. ♾️
  • --disable-recovery β€” disable recovery (resets all recovery options to off).
  • --do-not-launch β€” perform all necessary operations to prepare to launch the application, but do not actually launch it.
  • --enable-recovery β€” enable recovery from process failure (default: disabled)
  • --leave-session-attached β€” do not detach back-end daemons used by this application. This allows error messages from the daemons as well as the underlying environment (e.g., when failing to launch a daemon) to be output. πŸ‘€
  • --max-restarts <num> β€” max number of times to restart a failed process.
  • --personality <list> β€” comma-separated list of programming model, languages, and containers being used (default=ompi).
  • --ppr <list> β€” comma-separated list of number of processes on a given resource type (default: none). Alias for --map-by ppr:N:OBJ.
  • --report-child-jobs-separately β€” return the exit status of the primary job only.
  • --report-events <URI> β€” report events to a tool listening at the specified URI.
  • --report-pid <channel> β€” print out mpirun's PID during startup. The channel must be either a - to indicate that the PID is to be output to stdout, a + to indicate that the PID is to be output to stderr, or a filename to which the PID is to be written.
  • --report-uri <channel> β€” print out mpirun's URI during startup. The channel must be either a - to indicate that the URI is to be output to stdout, a + to indicate that the URI is to be output to stderr, or a filename to which the URI is to be written. πŸŽ€
  • --show-progress β€” output a brief periodic report on launch progress. πŸŒ€
  • --terminate β€” terminate the DVM.
  • --use-hwthread-cpus β€” use hardware threads as independent CPUs.

Note that if a number of slots is not provided to Open MPI (e.g., via the slots keyword in a hostfile or from a resource manager such as Slurm), the use of this option changes the default calculation of number of slots on a node. See the PRRTE's definition of "slot" for more details. 🧠

Also note that the use of this option changes the Open MPI's definition of a "processor element" from a processor core to a hardware thread. See PRRTE's definition of a "processor element" for more details.


The following options are useful for developers; they are not generally useful to most Open MPI users: πŸ‘©β€πŸ’» ✨

  • --debug-daemons β€” turns on debugging for the run-time daemons that this app is using πŸ›
  • --debug-daemons-file β€” same debugging energy for the run-time daemons this app uses, except the output gets stashed in files πŸ“
  • --display-devel-map β€” shows you a more detailed table of where every process got mapped before launch, so you can peek at the whole situation πŸ‘€
  • --display-topo β€” prints the topology as part of the process map right before launch πŸ—ΊοΈ
  • --launch-agent β€” tells it the name of the executable used to start processes on the remote nodes. Default is prted. This one's for testing new daemon concepts, or for passing options back to the daemons without mpirun itself ever seeing them. Like, for example: if you set the launch agent to prted --prtemca odls_base_verbose 5, the developer can ask prted for debugging output without any clutter from mpirun itself. slay ✨
  • --report-state-on-timeout β€” when you pair this with the --timeout command line option, it reports the run-time subsystem state of each process when the timeout expires ⏰

There may be other options listed with mpirun --help. (iykyk, go look πŸ‘‘)

🌸 Environment Variables 🌸

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?
  • MPIEXEC_TIMEOUT β€” synonym for the --timeout command line option. bestie behaviour fr fr πŸ’…

πŸ’– DESCRIPTION πŸ’–

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

One single invocation of mpirun starts an MPI application running under Open MPI. If your app is single process multiple data (SPMD), you can just specify it right there on the mpirun command line. easy.

If your app is multiple instruction multiple data (MIMD) β€” meaning it's made up of multiple programs β€” you can specify that whole set of programs and arguments in one of two ways: Extended Command Line Arguments, or Application Context. two paths, both iconic πŸ¦‹

An application context describes the MIMD program set, including all the arguments, in a separate file. That file is basically a bunch of mpirun command lines with the command name itself left out. And being able to give different options to different instantiations of a program? That's the other reason you'd reach for an application context.

Extended command line arguments let you describe the application layout right on the command line, using colons (:) to separate the specs for programs and arguments. Heads up: some options are set globally across all the specified programs (like --hostfile), while others belong to just a single program (like -n). lowkey important to know πŸ™ˆ

πŸŽ€ Specifying Host Nodes πŸŽ€

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

You can identify host nodes on the mpirun command line with the --host option, or inside a hostfile.

For example:

shell$ mpirun -H aa,aa,bb ./a.out

That launches two processes on node aa and one on bb. periodt.

Or, take a look at this hostfile:

shell$ cat myhostfile
aa slots=2
bb slots=2
cc slots=2

Here we're listing the host names (aa, bb, and cc) and how many slots each one has.

shell$ mpirun --hostfile myhostfile ./a.out

That'll launch two processes on each of the three nodes. ✨

shell$ mpirun --hostfile myhostfile --host aa ./a.out

That'll launch two processes, both of them on node aa.

shell$ mpirun --hostfile myhostfile --host dd ./a.out

And this one finds no hosts to run on, so it aborts with an error 😭 Like β€” the host dd that you specified just isn't in the hostfile you specified. that's the whole vibe check.

When you're running under resource managers (Slurm, Torque, etc.), Open MPI gets both the hostnames and the number of slots directly from the resource manager. no cap.

πŸ’œ Specifying Number of Processes πŸ’œ

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

So like we just saw, you can set the number of processes to run using the hostfile. But other mechanisms exist too πŸ‘€

You can specify the number of processes launched as a multiple of the number of nodes or processor packages available. For example:

shell$ mpirun -H aa,bb --map-by ppr:2:package ./a.out

That launches processes 0-3 on node aa and processes 4-7 on node bb (assuming aa and bb both contain 4 slots each).

shell$ mpirun -H aa,bb --map-by ppr:2:node ./a.out

That launches processes 0-1 on node aa and processes 2-3 on node bb.

shell$ mpirun -H aa,bb --map-by ppr:1:node ./a.out

One process per host node. clean 🌸

mpirun -H aa,bb --pernode ./a.out

This is the same as --map-by ppr:1:node and --npernode 1. twins fr.

Another alternative is specifying the number of processes with the -n option. Now consider this hostfile:

shell$ cat myhostfile
aa slots=4
bb slots=4
cc slots=4

Now run with myhostfile:

shell$ mpirun --hostfile myhostfile -n 6 ./a.out

That launches processes 0-3 on node aa and processes 4-5 on node bb. The remaining slots in the hostfile don't get used, because the -n option said only 6 processes should be launched. we respect the limit πŸ’…

πŸ¦‹ Mapping Processes to Nodes: Using Policies πŸ¦‹

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

The examples above show the default mapping of processes to nodes. But you can also control that mapping with various mpirun options that describe mapping policies.

Same hostfile as above, again with -n 6. Here's a few mpirun variations and which MPI_COMM_WORLD ranks end up on which node πŸ‘‘

  • mpirun β€” Node aa: 0 1 2 3, Node bb: 4 5, Node cc: (nothing)
  • mpirun --map-by node β€” Node aa: 0 3, Node bb: 1 4, Node cc: 2 5
  • mpirun --nolocal β€” Node aa: (nothing), Node bb: 0 1 2 3, Node cc: 4 5

The --map-by node option load balances the processes across the available nodes, numbering each process in a round-robin fashion. cute and fair πŸŽ€

The --nolocal option stops any processes from being mapped onto the local host (in this case node aa). And like β€” mpirun typically uses very few system resources, but --nolocal can genuinely help for launching very large jobs, where mpirun may actually need to use noticeable amounts of memory and/or processing time.

Just like -n can specify fewer processes than there are slots, it can also oversubscribe the slots. For example, with the same hostfile:

shell$ mpirun --hostfile myhostfile -n 14 ./a.out

That launches processes 0-3 on node aa, 4-7 on bb, and 8-11 on cc. Then it adds the remaining two processes to whichever nodes it chooses. it's giving chaos but make it balanced πŸ’€

You can also specify limits to oversubscription. For example, with the same hostfile:

shell$ mpirun --hostfile myhostfile -n 14 --nooversubscribe ./a.out

That produces an error, since --nooversubscribe prevents oversubscription. nope, not today πŸ™…

Limits to oversubscription can also be specified in the hostfile itself:

shell$ cat myhostfile
aa slots=4 max_slots=4
bb         max_slots=4
cc slots=4

The max_slots field specifies that limit. And when it's there, the slots value defaults to the limit. So now:

shell$ mpirun --hostfile myhostfile -n 14 ./a.out

...causes the first 12 processes to be launched as before, but the remaining two processes get forced onto node cc. The other two nodes are protected by the hostfile against oversubscription by this job. protective icon behaviour 🫢

Using the --nooversubscribe option can be helpful, since Open MPI currently does not get max_slots values from the resource manager. noted ✨

Of course, -n also works with the -H or -host option. For example:

shell$ mpirun -H aa,bb -n 8 ./a.out

That launches 8 processes. Since only two hosts are specified, after the first two processes get mapped β€” one to aa and one to bb β€” the remaining processes oversubscribe the specified hosts. it's giving packed house 😭

And here's a MIMD example:

shell$ mpirun -H aa -n 1 hostname : -H bb,cc -n 2 uptime

That launches process 0 running hostname on node aa, and processes 1 and 2 each running uptime on nodes bb and cc, respectively. multitalented fr fr 🌈

🌈 Mapping, Ranking, and Binding: Oh My! 🌈

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

Open MPI runs a three-phase procedure for assigning process locations and ranks:

  1. Mapping β€” assigns a default location to each process
  2. Ranking β€” assigns an MPI_COMM_WORLD rank value to each process
  3. Binding β€” constrains each process to run on specific processors

the holy trinity of process placement πŸ’…

The mapping step assigns a default location to each process based on whatever mapper is being employed. Mapping by slot, node, and sequentially results in assigning the processes at the node level. Mapping by object, on the other hand, lets the mapper assign the process to an actual object on each node.

Quick note though: the location assigned to the process is independent of where it'll actually be bound β€” the assignment is used solely as input to the binding algorithm. so don't get it twisted πŸ™ˆ

The mapping of processes to nodes can be defined not just with general policies, but β€” if you need it β€” with arbitrary mappings that a simple policy just can't describe. You can use the "sequential mapper," which reads the hostfile line by line, assigning processes to nodes in whatever order the hostfile specifies. Use the ---map-by seq option. For example, with the same hostfile as before:

shell$ mpirun -hostfile myhostfile --map-by seq ./a.out

That launches three processes β€” one on each of nodes aa, bb, and cc, respectively. The slot counts genuinely don't matter here; one process is launched per line, on whatever node is listed on that line. periodt. ✨

Another way to specify arbitrary mappings is with a rankfile, which gives you detailed control over process binding too. Rankfiles are discussed below πŸ‘‡

Okay so the second phase? It’s all about ranking the process within the job’s MPI_COMM_WORLD. Open MPI keeps this separate from the mapping procedure so you get more flexibility in the relative placement of MPI processes. The cutest way to see it is with this case, where we used the --np 8 --map-by ppr:2:package --host aa:4,bb:4 option:

  • --rank-by fill (i.e., dense packing) Default β€” Node aa: 0 1 | 2 3; Node bb: 4 5 | 6 7
  • --rank-by span (i.e., sparse or load balanced packing) β€” Node aa: 0 4 | 1 5; Node bb: 2 6 | 3 7
  • --rank-by node β€” Node aa: 0 2 | 4 6; Node bb: 1 3 | 5 7

Ranking by fill assigns MCW ranks in a simple progression across each node. Ranking by span and by slot provide the identical result β€” a round-robin progression of the packages across all nodes before returning to the first package on the first node. Ranking by node assigns MCW ranks iterating first across nodes then by package.

The binding phase actually binds each process to a given set of processors. This can improve performance if the operating system is placing processes suboptimally. For example, it might oversubscribe some multi-core processor packages, leaving other packages idle; this can lead processes to contend unnecessarily for common resources. Or, it might spread processes out too widely; this can be suboptimal if application performance is sensitive to interprocess communication costs. Binding can also keep the operating system from migrating processes excessively, regardless of how optimally those processes were placed to begin with.

The processors to be used for binding can be identified in terms of topological groupings β€” e.g., binding to an l3cache will bind each process to all processors within the scope of a single L3 cache within their assigned location. Thus, if a process is assigned by the mapper to a certain package, then a --bind-to l3cache directive will cause the process to be bound to the processors that share a single L3 cache within that package.

Alternatively, processes can be mapped and bound to specified cores using the --map-by pe-list= option. For example, --map-by pe-list=0,2,5 will map three processes all three of which will be bound to logical cores 0,2,5. If you intend to bind each of the three processes to different cores then the :ordered qualifier can be used like --map-by pe-list=0,2,5:ordered. In this example, the first process on a node will be bound to CPU 0, the second process on the node will be bound to CPU 2, and the third process on the node will be bound to CPU 5.

Finally, --report-bindings can be used to report bindings.

As an example, consider a node with two processor packages, each comprised of four cores, and each of those cores contains one hardware thread. The --report-bindings option shows the binding of each process in a descriptive manner. Below are some examples.

shell$ mpirun --np 4 --report-bindings --map-by core --bind-to core
[...] Rank 0 bound to package[0][core:0]
[...] Rank 1 bound to package[0][core:1]
[...] Rank 2 bound to package[0][core:2]
[...] Rank 3 bound to package[0][core:3]

In the above case, the processes bind to successive cores.

shell$ mpirun --np 4 --report-bindings --map-by package --bind-to package
[...] Rank 0 bound to package[0][core:0-3]
[...] Rank 1 bound to package[0][core:0-3]
[...] Rank 2 bound to package[1][core:4-7]
[...] Rank 3 bound to package[1][core:4-7]

In the above case, processes bind to all cores on successive packages. The processes cycle through the processor packages in a round-robin fashion as many times as are needed. By default, the processes are ranked in a fill manner.

shell$ mpirun --np 4 --report-bindings --map-by package --bind-to package --rank-by span
[...] Rank 0 bound to package[0][core:0-3]
[...] Rank 1 bound to package[1][core:4-7]
[...] Rank 2 bound to package[0][core:0-3]
[...] Rank 3 bound to package[1][core:4-7]

The above case demonstrates the difference in ranking when the span qualifier is used instead of the default.

shell$ mpirun --np 4 --report-bindings --map-by slot:PE=2 --bind-to core
[...] Rank 0 bound to package[0][core:0-1]
[...] Rank 1 bound to package[0][core:2-3]
[...] Rank 2 bound to package[0][core:4-5]
[...] Rank 3 bound to package[0][core:6-7]

In the above case, the output shows us that 2 cores have been bound per process. Specifically, the mapping by slot with the PE=2 qualifier indicated that each slot (i.e., process) should consume two processor elements. By default, Open MPI defines β€œprocessor element” as β€œcore”, and therefore the --bind-to core caused each process to be bound to both of the cores to which it was mapped.

shell$ mpirun --np 4 --report-bindings --map-by slot:PE=2 --use-hwthread-cpus
[...]] Rank 0 bound to package[0][hwt:0-1]
[...]] Rank 1 bound to package[0][hwt:2-3]
[...]] Rank 2 bound to package[0][hwt:4-5]
[...]] Rank 3 bound to package[0][hwt:6-7]

In the above case, we replace the --bind-to core with --use-hwthread-cpus. The --use-hwthread-cpus is converted into --bind-to hwthread and tells the --report-bindings output to show the hardware threads to which a process is bound. In this case, processes are bound to 2 hardware threads per process.

shell$ mpirun --np 4 --report-bindings --bind-to none
[...] Rank 0 is not bound (or bound to all available processors)
[...] Rank 1 is not bound (or bound to all available processors)
[...] Rank 2 is not bound (or bound to all available processors)
[...] Rank 3 is not bound (or bound to all available processors)

In the above case, binding is turned off and are reported as such.

Open MPI’s support for process binding depends on the underlying operating system. Therefore, certain process binding options may not be available on every system.

Process binding can also be set with MCA parameters. Their usage is less convenient than that of mpirun options. On the other hand, MCA parameters can be set not only on the mpirun command line, but alternatively in a system or user mca-params.conf file or as environment variables, as described in the Setting MCA Parameters. These are MCA parameters for the PRRTE runtime so the command line argument --prtemca (yes, prte with a single r, not two r’s) must be used to pass the MCA parameter key/value pair. Alternatively, the MCA parameter key/value pair may be specific on the command line by prefixing the key with PRTE_MCA_ (again, that is not a typo: PRTE not PRRTE). Some examples include:

  • --map-by core β€” PRRTE MCA parameter key rmaps_default_mapping_policy, value core
  • --map-by package β€” PRRTE MCA parameter key rmaps_default_mapping_policy, value package
  • --rank-by fill β€” PRRTE MCA parameter key rmaps_default_ranking_policy, value fill
  • --bind-to core β€” PRRTE MCA parameter key hwloc_default_binding_policy, value core
  • --bind-to package β€” PRRTE MCA parameter key hwloc_default_binding_policy, value package
  • --bind-to none β€” PRRTE MCA parameter key hwloc_default_binding_policy, value none

πŸŽ€ Defaults for Mapping, Ranking, and Binding πŸŽ€

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

If the user does not specify each of --map-by, --rank-by, and --bind-to option then the default values are as follows:

  • If no options are specified then
    • If the number of processes is less than or equal to 2, then:
      • --map-by is core
      • --bind-to is core
      • --rank-by is span
      • Result: --map-by core --bind-to core --rank-by span
    • Otherwise:
      • --map-by is package
      • --bind-to is package
      • --rank-by is fill
      • Result: --map-by package --bind-to package --rank-by fill
  • If only --map-by OBJ (where OBJ is something like core) is specified, then:
    • --map-by specified OBJ
    • --bind-to uses the same OBJ as --map-by
    • --rank-by defaults to fill
    • Result: --map-by OBJ --bind-to OBJ --rank-by fill
  • --map-by is either core or package depending on the number of processes
  • --bind-to uses that OBJ you gave it
  • --rank-by defaults to fill
  • Result: --map-by OBJ --bind-to OBJ --rank-by fill
  • If it's --map-by OBJ1 --bind-to OBJ2, then bestie, here's the tea:
    • --map-by uses the OBJ1 you specified
    • --bind-to uses the OBJ2 you specified
    • --rank-by defaults to fill
    • Result: --map-by OBJ2 --bind-to OBJ2 --rank-by fill

Okay so picture this (iykyk): 2 identical hosts (hostA and hostB), each with 2 packages (shown as []), each package with 8 cores (shown as /../), and 2 hardware threads per core (shown as a .). Slay, let's visualize πŸ’…

The default is --map-by core --bind-to core --rank-by span when the number of processes is less than or equal to 2:

shell$ mpirun --np 2 --host hostA:4,hostB:2 ./a.out
R0  hostA  [BB/../../../../../../..][../../../../../../../..]
R1  hostA  [../BB/../../../../../..][../../../../../../../..]

The default switches to --map-by package --bind-to package --rank-by fill when the number of processes is greater than 2:

shell$ mpirun --np 4 --host hostA:4,hostB:2 ./a.out
R0  hostA  [BB/BB/BB/BB/BB/BB/BB/BB][../../../../../../../..]
R1  hostA  [BB/BB/BB/BB/BB/BB/BB/BB][../../../../../../../..]
R2  hostA  [../../../../../../../..][BB/BB/BB/BB/BB/BB/BB/BB]
R3  hostA  [../../../../../../../..][BB/BB/BB/BB/BB/BB/BB/BB]

If only --map-by OBJ is specified, it implies --bind-to OBJ --rank-by fill. The example below results in --map-by hwthread --bind-to hwthread --rank-by fill:

shell$ mpirun --np 4 --map-by hwthread --host hostA:4,hostB:2 ./a.out
R0  hostA  [B./../../../../../../..][../../../../../../../..]
R1  hostA  [.B/../../../../../../..][../../../../../../../..]
R0  hostA  [../B./../../../../../..][../../../../../../../..]
R1  hostA  [../.B/../../../../../..][../../../../../../../..]

If only --bind-to OBJ is specified, then --map-by is determined by the number of processes and --rank-by goes to fill. The example below results in --map-by package --bind-to core --rank-by fill:

shell$ mpirun --np 4 --bind-to core --host hostA:4,hostB:2 ./a.out
R0  hostA  [BB/../../../../../../..][../../../../../../../..]
R1  hostA  [../BB/../../../../../..][../../../../../../../..]
R2  hostA  [../../../../../../../..][BB/../../../../../../..]
R3  hostA  [../../../../../../../..][../BB/../../../../../..]

Ngl the mapping pattern is way easier to see if you flip the default --rank-by from fill to span. So like: first, the processes are mapped by package iterating between the two, marking a core at a time. Next, the processes are ranked in a spanning manner that load balances them across the object they were mapped against. Finally, the processes are bound to the core that they were mapped against. Iconic three-step choreo ✨

shell$ mpirun --np 4 --bind-to core --rank-by span --host hostA:4,hostB:2 ./a.out
R0  hostA  [BB/../../../../../../..][../../../../../../../..]
R1  hostA  [../../../../../../../..][BB/../../../../../../..]
R2  hostA  [../BB/../../../../../..][../../../../../../../..]
R3  hostA  [../../../../../../../..][../BB/../../../../../..]

πŸŽ€ Rankfiles πŸŽ€

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

So a rankfile is literally just a text file that specifies detailed information about how individual processes should be mapped to nodes, and to which processor(s) they should be bound. Fr, that's the whole vibe. Each line of a rankfile specifies the location of one process (for MPI jobs, the process' "rank" refers to its rank in MPI_COMM_WORLD). The general form of each line in the rankfile is:

rank <N>=<hostname> slot=<slot list>

For example:

shell$ cat myrankfile
rank 0=aa slot=1:0-2
rank 1=bb slot=0:0,1
rank 2=cc slot=2-3
shell$ mpirun -H aa,bb,cc,dd --map-by rankfile:file=myrankfile ./a.out

Means that:

  • Rank 0 runs on node aa, bound to logical package 1, cores 0-2.
  • Rank 1 runs on node bb, bound to logical package 0, cores 0 and 1.
  • Rank 2 runs on node cc, bound to logical cores 2 and 3.

Note that only logical processor locations are supported. By default, the values specified are assumed to be cores. If you intend to specify specific hardware threads then you must add the :hwtcpus qualifier to the --map-by command line option (e.g., --map-by rankfile:file=myrankfile:hwtcpus).

If the binding specification overlaps between any two ranks then an error occurs. So no double-dipping 🚫. If you intend to allow processes to share the same logical processing unit then you must pass the --bind-to :overload-allowed command line option to tell the runtime to ignore this check.

The hostnames listed above are "absolute," meaning that actual resolvable hostnames are specified. However, hostnames can also be specified as "relative," meaning that they are specified in relation to an externally-specified list of hostnames (e.g., by mpirun's --host argument, a hostfile, or a job scheduler).

The "relative" specification is of the form +n<X>, where X is an integer specifying the Xth hostname in the set of all available hostnames, indexed from 0. For example:

shell$ cat myrankfile
rank 0=+n0 slot=1:0-2
rank 1=+n1 slot=0:0,1
rank 2=+n2 slot=2-3
shell$ mpirun -H aa,bb,cc,dd --map-by rankfile:file=myrankfile ./a.out

All package/core slot locations are specified as logical indexes.

NOTE: The Open MPI v1.6 series used physical indexes. Starting in Open MPI v5.0 only logical indexes are supported and the rmaps_rank_file_physical MCA parameter is no longer recognized.

You can use tools such as Hwloc's lstopo(1) to find the logical indexes of package and cores. Very handy, highly recommend 🫢


πŸ¦‹ Application Context or Executable Program? πŸ¦‹

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

To distinguish the two different forms, mpirun looks on the command line for --app option. If it is specified, then the file named on the command line is assumed to be an application context. If it is not specified, then the file is assumed to be an executable program. Simple as that, no cap πŸ’…

🌸 Locating Files 🌸

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

If no relative or absolute path is specified for a file, Open MPI will first look for files by searching the directories specified by the --path option. If there is no --path option set or if the file is not found at the --path location, then Open MPI will search the user's PATH environment variable as defined on the source node(s).

If a relative directory is specified, it must be relative to the initial working directory determined by the specific starter used. For example when using the ssh starter, the initial directory is $HOME by default. Other starters may set the initial directory to the current working directory from the invocation of mpirun.

🌈 Current Working Directory 🌈

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

The --wdir mpirun option (and its synonym, --wd) allows the user to change to an arbitrary directory before the program is invoked. It can also be used in application context files to specify working directories on specific nodes and/or for specific applications.

If the --wdir option appears both in a context file and on the command line, the context file directory will override the command line value. Context file said what it said πŸ’€

If the -wdir option is specified, Open MPI will attempt to change to the specified directory on all of the remote nodes. If this fails, mpirun will abort.

If the -wdir option is not specified, Open MPI will send the directory name where mpirun was invoked to each of the remote nodes. The remote nodes will try to change to that directory. If they are unable (e.g., if the directory does not exist on that node), then Open MPI will use the default directory determined by the starter.

All directory changing occurs before the user's program is invoked; it does not wait until MPI_INIT(3) is called. Punctual queen ⏰

⭐ Standard I/O ⭐

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

Open MPI directs UNIX standard input to /dev/null on all processes except the MPI_COMM_WORLD rank 0 process. The MPI_COMM_WORLD rank 0 process inherits standard input from mpirun.

NOTE: The node that invoked mpirun need not be the same as the node where the MPI_COMM_WORLD rank 0 process resides. Open MPI handles the redirection of mpirun's standard input to the rank 0 process.

Open MPI directs UNIX standard output and error from remote nodes to the node that invoked mpirun and prints it on the standard output/error of mpirun. Local processes inherit the standard output/error of mpirun and transfer to it directly.

Thus it is possible to redirect standard I/O for Open MPI applications by using the typical shell redirection procedure on mpirun. For example:

shell$ mpirun -n 2 my_app < my_input > my_output

Note that in this example only the MPI_COMM_WORLD rank 0 process will receive the stream from my_input on stdin. The stdin on all the other nodes will be tied to /dev/null. However, the stdout from all nodes will be collected into the my_output file. Rank 0 is the only one getting the aux, everyone else is on their own 🎧

πŸ’œ Signal Propagation πŸ’œ

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

When mpirun receives a SIGTERM and SIGINT, it will attempt to kill the entire job by sending all processes in the job a SIGTERM, waiting a small number of seconds, then sending all processes in the job a SIGKILL. It's giving "asked nicely, then did not ask nicely" 😭

SIGUSR1 and SIGUSR2 signals received by mpirun are propagated to all processes in the job.

A SIGTSTOP signal to mpirun will cause a SIGSTOP signal to be sent to all of the programs started by mpirun and likewise a SIGCONT signal to mpirun will cause a SIGCONT sent.

Other signals are not currently propagated by mpirun.

πŸ“ Process Termination / Signal Handling πŸ“

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

During the run of an MPI application, if any process dies abnormally (either exiting before invoking MPI_FINALIZE(3), or dying as the result of a signal), mpirun will print out an error message and kill the rest of the MPI application. One goes down, they all go down β€” dramatic but honestly fair πŸ’€

okay so, on the signal-handler thing: bestie, user signal handlers should probably avoid trying to clean up MPI state. like, <red>Open MPI is currently not async-signal-safe</red> β€” see MPI_INIT_THREAD(3) for the details about MPI_THREAD_MULTIPLE and thread safety. for example, if a segmentation fault occurs in MPI_SEND(3) (maybe because a bad buffer was passed in) and a user signal handler gets invoked, and that handler tries to invoke MPI_FINALIZE(3), <hotpink>Bad Things could happen</hotpink> since Open MPI was already β€œin” MPI when the error happened. and since mpirun will notice that the process died due to a signal, it’s probably not necessary (and safest) for the user to only clean up non-MPI state. periodt. πŸ’…

🌸 Process Environment 🌸

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

Processes in the MPI application inherit their environment from the <purple>PRRTE daemon</purple> on the node where they’re running. the environment is typically inherited from the user’s shell. on remote nodes, the exact environment is determined by the boot MCA module used. the rsh launch module, for example, uses either rsh/ssh to launch the PRRTE daemon on remote nodes, and typically executes one or more of the user’s shell-setup files before launching the PRRTE daemon. when running dynamically linked applications that need the LD_LIBRARY_PATH environment variable to be set, <yellow>care must be taken</yellow> to make sure it’s correctly set when booting Open MPI. fr fr.

See the Remote Execution section for more details. 🫢

πŸ¦‹ Remote Execution πŸ¦‹

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

Open MPI requires that the PATH environment variable be set to find executables on remote nodes (this is typically only necessary in rsh- or ssh-based environments β€” batch/scheduled environments typically copy the current environment to the execution of remote jobs, so if the current environment has PATH and/or LD_LIBRARY_PATH set properly, the remote nodes will also have it set properly). if Open MPI was compiled with shared library support, it may also be necessary to have the LD_LIBRARY_PATH environment variable set on remote nodes as well (especially to find the shared libraries required to run user MPI applications). no cap.

However, it’s not always desirable or possible to edit shell startup files to set PATH and/or LD_LIBRARY_PATH. the --prefix option is provided for some simple configurations where this is not possible. ✨

The --prefix option takes a single argument: the base directory on the remote node where Open MPI is installed. Open MPI will use this directory to set the remote PATH and LD_LIBRARY_PATH before executing any Open MPI or user applications. this allows running Open MPI jobs without having pre-configured the PATH and LD_LIBRARY_PATH on the remote nodes. iconic.

Open MPI adds the basename of the current node’s $bindir (the directory where Open MPI’s executables were installed) to the prefix and uses that to set the PATH on the remote node. similarly, Open MPI adds the basename of the current node’s $libdir (the directory where Open MPI’s libraries were installed) to the prefix and uses that to set the LD_LIBRARY_PATH on the remote node. for example:

  • Local bindir: /local/node/directory/bin
  • Local libdir: /local/node/directory/lib64

if the following command line is used:

shell$ mpirun --prefix /remote/node/directory

Open MPI will add /remote/node/directory/bin to the PATH and /remote/node/directory/lib64 to the LD_LIBRARY_PATH on the remote node before attempting to execute anything. slay.

The --prefix option is not sufficient if the installation paths on the remote node are different than the local node (e.g., if /lib is used on the local node, but /lib64 is used on the remote node), or if the installation paths are something other than a subdirectory under a common prefix. 🫠

Note that executing mpirun via an absolute pathname is equivalent to specifying --prefix without the last subdirectory in the absolute pathname to mpirun. for example:

shell$ /usr/local/bin/mpirun ...

is equivalent to

shell$ mpirun --prefix /usr/local

πŸŽ€ Exported Environment Variables πŸŽ€

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

All environment variables that are named in the form OMPI_* will automatically be exported to new processes on the local and remote nodes. environmental parameters can also be set/forwarded to the new processes using the MCA parameter mca_base_env_list. the -x option to mpirun has been deprecated, but the syntax of the MCA param follows that prior example. while the syntax of the -x option and MCA param allows the definition of new variables, note that the parser for these options are currently not very sophisticated β€” it does not even understand quoted values. users are advised to set variables in the environment and use the option to export them; not to define them. πŸ’–

✨ Setting MCA Parameters ✨

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

The --mca switch allows the passing of parameters to various MCA (Modular Component Architecture) modules. MCA modules have direct impact on MPI programs because they allow tunable parameters to be set at run time (such as which BTL communication device driver to use, what parameters to pass to that BTL, etc.). the way that works is lowkey powerful.

The --mca switch takes two arguments: <key> and <value>. the <key> argument generally specifies which MCA module will receive the value. for example, the <key> btl is used to select which BTL to be used for transporting MPI messages. the <value> argument is the value that is passed. for example:

shell$ mpirun --mca btl tcp,self -n 1 my_mpi_app

This tells Open MPI to use the tcp and self BTLs, and to run a single copy of my_mpi_app an allocated node. 🌈

shell$ mpirun --mca btl self -n 1 my_mpi_app

Tells Open MPI to use the self BTL, and to run a single copy of my_mpi_app an allocated node.

The --mca switch can be used multiple times to specify different <key> and/or <value> arguments. if the same <key> is specified more than once, the <value>s are concatenated with a comma (,) separating them.

Note that the --mca switch is simply a shortcut for setting environment variables. the same effect may be accomplished by setting corresponding environment variables before running mpirun. the form of the environment variables that Open MPI sets is:

OMPI_MCA_<key>=<value>

Thus, the --mca switch overrides any previously set environment variables. the --mca settings similarly override MCA parameters set in the $OPAL_PREFIX/etc/openmpi-mca-params.conf or $HOME/.openmpi/mca-params.conf file. πŸ‘‘

Unknown <key> arguments are still set as environment variable β€” they are not checked (by mpirun) for correctness. illegal or incorrect <value> arguments may or may not be reported β€” it depends on the specific MCA module. to find the available component types under the MCA architecture, or to find the available parameters for a specific component, use the ompi_info command. see the ompi_info(1) man page for detailed information on this command. πŸ’œ

🧚 Setting MCA parameters and environment variables from file 🧚

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

The --tune command line option and its synonym --mca mca_base_envar_file_prefix allows a user to set MCA parameters and environment variables with the syntax described below. this option requires a single file or list of files separated by β€œ,” to follow. πŸ“

A valid line in the file may contain zero or more -x or --mca. the following patterns are supported:

  • --mca var val
  • --mca var "val"
  • -x var=val
  • -x var

If any argument is duplicated in the file, the last value read will be used.

MCA parameters and environment specified on the command line have higher precedence than variables specified in the file. no cap.

πŸ”₯ Running as root πŸ”₯

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?
WARNING: The Open MPI team strongly advises against executing mpirun as the root user. MPI applications should be run as regular (non-root) users.

mpirun will refuse to run as root by default.

To override this default, you can add the --allow-run-as-root option to the mpirun command line, or you can set the environmental parameters OMPI_ALLOW_RUN_AS_ROOT=1 and OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1. note that it takes setting two environment variables to effect the same behavior as --allow-run-as-root in order to stress the Open MPI team’s strong advice against running as the root user. 😭

After extended discussions with communities who use containers (where running as the root user is the default), there was a persistent desire to be able to enable root execution of mpirun via an environmental control (vs. the existing --allow-run-as-root command line parameter). the compromise of using two environment variables was reached: it allows root execution via an environmental control, but it conveys the Open MPI team’s strong recommendation against this behavior. πŸ’€

⭐ Exit status ⭐

This is old, hard-coded content. Is this content still current / accurate? Should it be updated and retained, or removed?

There is no standard definition for what mpirun should return as an exit status. after considerable discussion, we settled on the following method for assigning the mpirun exit status (note: in the following description, the β€œprimary” job is the initial application started by mpirun β€” all jobs that are spawned by that job are designated β€œsecondary” jobs):

  • If all processes in the primary job normally terminate with exit status 0, mpirun returns 0.
  • If one or more processes in the primary job normally terminate with non-zero exit status, mpirun returns the exit status of the process with the lowest MPI_COMM_WORLD rank to have a non-zero status.
  • If all processes in the primary job normally terminate with exit status 0, and one or more processes in a secondary job normally terminate with non-zero exit status, mpirun:
    1. Returns the exit status of the process with the lowest MPI_COMM_WORLD rank in the lowest jobid to have a non-zero status, and
    2. Outputs a message summarizing the exit status of the primary and all secondary jobs.
  • --report-child-jobs-separately β€” if this command line option is set, we only hand back the exit status of the primary job, bestie. Any non-zero exit status in secondary jobs gets reported solely in a summary print statement. That's it. That's the whole vibe.

By default, the job will abort when any process terminates with non-zero status. 😭 But β€” and this is the slay part β€” the MCA parameter --prtemca state_base_error_non_zero_exit can be set to β€œfalse” (or β€œ0”) to cause Open MPI to not abort a job if one or more processes return a non-zero status. In that situation, Open MPI records and notes that processes exited with non-zero termination status so it can report the appropriate exit status of mpirun (per the bullet points above, iykyk).


🌈 EXAMPLES 🌈

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

Be sure also to see the examples throughout the sections above, okay? Like, they're sprinkled everywhere, don't miss 'em. πŸ’…

shell$ mpirun -n 4 --mca btl tcp,sm,self prog1

Run 4 copies of prog1 using the tcp, sm (shared memory), and self (process loopback) BTL's for the transport of MPI messages. Four prog1s. Living their best lives. 🫢


✨ RETURN VALUE ✨

This is old, hard-coded content Is this content still current / accurate? Should it be updated and retained, or removed?

mpirun returns 0 if all processes started by mpirun exit after calling MPI_FINALIZE(3). πŸŽ€

A non-zero value is returned if:

  • an internal error occurred in mpirun, or
  • one or more processes exited before calling MPI_FINALIZE(3).

If an internal error occurred in mpirun, the corresponding error code is returned. If one or more processes exit before calling MPI_FINALIZE(3), the return value of the MPI_COMM_WORLD rank of the process that mpirun first notices died before calling MPI_FINALIZE(3) will be returned. Note that, in general, this will be the first process that died β€” but it is not guaranteed to be so. πŸ™ˆ Like, usually, but not a promise, bestie.

If the --timeout command line option is used and the timeout expires before the job completes (thereby forcing mpirun to kill the job), mpirun will return an exit status equivalent to the value of ETIMEDOUT (which is typically 110 on Linux and OS X systems). πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

MPI_INIT(3), MPI_INIT_THREAD(3), MPI_FINALIZE(3), ompi_info(1)


2003-2026, The Open MPI Community


And that's the whole page, bestie β€” you made it to the end πŸ¦‹ This lil' masterclass is from the MPIRUN(1) manual, dated Sep 11, 2026, brought to you by the Open MPI girlies. Go forth and mpirun responsibly. Periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from