|
mpirun, mpiexec — Execute serial and parallel jobs in Open MPI. NOTE: mpirun and mpiexec are synonyms for each
other. Indeed, they are symbolic links to the same executable. Using either of
the names will produce the exact same behavior.
SYNOPSISSingle Process Multiple Data (SPMD) Model: mpirun [ options ] <program> [ <args> ] Multiple Instruction Multiple Data (MIMD) Model: mpirun [ global_options ] 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 SUMMARYIf 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):
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 PRRTEOpen 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 docuemtnation below. COMMAND LINE OPTIONSThe 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. General command line optionsThe following general command line options are available.
Launch options
Mapping, ranking, and binding options
Output options
Input options
Specific options
MPI Options
Debugger / tool options
Debug options
Fault Tolerance OptionsThese options are only available is Open MPI / PRRTE were compiled with Fault Tolerance functionality enabled.
Details of individual command line optionsThe sections below offer more detail than the abbreviated lists, above. The --allow-run-as-root optionAllow execution as root (STRONGLY DISCOURAGED). Running as root exposes the user to potentially catastrophic file system corruption and damage — e.g., if the user accidentally points the root of the session directory to a system required point, this directory and all underlying elements will be deleted upon job completion, thereby rendering the system inoperable. It is recognized that some environments (e.g., containers) may require operation as root, and that the user accepts the risks in those scenarios. Accordingly, one can override PRRTE’s run-as-root protection by providing one of the following:
Again, we recommend this only be done if absolutely necessary. The --bind-to optionBy default, processes are bound to individual CPUs (either COREs or HWTHREADs, as defined by default or by user specification for the job). On nodes that are OVERSUBSCRIBEd (i.e., where the number of procs exceeds the number of assigned slots), the default is to not bind the processes. NOTE: Processes from prior jobs that are already executing on a
node are not “unbound” when a new job mapping results in the
node becoming oversubscribed.
Binding is performed to the first available specified object type within the object where the process was mapped. In other words, binding can only be done to the mapped object or to a resource located beneath that object. An object is considered completely consumed when the number of processes bound to it equals the number of CPUs within it. Unbound processes are not considered in this computation. Additional processes cannot be mapped to consumed objects unless the OVERLOAD qualifier is provided via the --bind-to command line option. Note that directives and qualifiers are case-insensitive and can be shortened to the minimum number of characters to uniquely identify them. Thus, L1CACHE can be given as l1cache or simply as L1. Supported binding directives include:
Any directive can include qualifiers by adding a colon (:) and any combination of one or more of the following to the --bind-to option:
NOTE: Directives and qualifiers are case-insensitive.
OVERLOAD is the same as overload.
The --debug-daemons optionDebug daemon output enabled. This is a somewhat limited stream of information normally used to simply confirm that the daemons started. Includes leaving the output streams open. The --debug-daemons-file optionDebug daemon output is enabled and all output from the daemons is redirected into files with names of the form: output-prted-<daemon-nspace>-<nodename>.log These names avoid conflict on shared file systems. The files are located in the top-level session directory assigned to the DVM. The --display optionThe display command line directive must be accompanied by a comma-delimited list of case-insensitive options indicating what information about the job and/or allocation is to be displayed. The full directive need not be provided — only enough characters are required to uniquely identify the directive. For example, ALL is sufficient to represent the ALLOCATION directive — while MAP can not be used to represent MAP-DEVEL (though MAP-D would suffice). Supported values include:
The display command line directive can include qualifiers by adding a colon (:) and any combination of one or more of the following (delimited by colons):
Provided qualifiers will apply to all of the display directives. The --forward-signals optionComma-delimited list of additional signals (names or integers) to forward to application processes (none = forward nothing). Signals provided by default include SIGTSTP, SIGUSR1, SIGUSR2, SIGABRT, SIGALRM, and SIGCONT. The --host optionHost syntax consists of a comma-delimited list of node names, each entry optionally containing a :N extension indicating the number of slots to assign to that entry: --host node01:5,node02 In the absence of the slot extension, one slot will be assigned to the node. Duplicate entries are aggregated and the number of slots assigned to that node are summed together. NOTE: A “slot” is the PRRTE term for an
allocatable unit where we can launch a process. Thus, the number of slots
equates to the maximum number of processes PRRTE may start on that node
without oversubscribing it.
The --hostfile optionPRRTE supports several levels of user-specified host lists based on an established precedence order. Users can specify a default hostfile that contains a list of nodes to be used by the DVM. Only one default hostfile can be provided for a given DVM. In addition, users can specify a hostfile that contains a list of nodes to be used for a DVM, or can provide a comma-delimited list of nodes to be used for that DVM via the --host command line option. The precedence order applied to these various options depends to some extent on the local environment. The following table illustrates how host and hostfile directives work together to define the set of hosts upon which a DVM will execute in the absence of a resource manager (RM):
This changes somewhat in the presence of an RM as that entity specifies the initial allocation of nodes. In this case, the default hostfile, hostfile and host directives are all used to filter the RM’s specification so that a user can utilize different portions of the allocation for different DVMs. This is done according to the same precedence order as in the prior table, with the RM providing the initial pool of nodes. Hostfiles (sometimes called “machine files”) are a combination of two things:
Hostfile syntax consists of one node name on each line, optionally including a designated number of “slots”: # This is a comment line, and will be ignored node01 slots=10 node13 slots=5 node15 node16 node17 slots=3 ... Blank lines and lines beginning with a # are ignored. A “slot” is the PRRTE term for an allocatable unit where we can launch a process. See the section on definition of the term slot for a longer description of slots. In the absence of the slot parameter, PRRTE will assign either the number of slots to be the number of CPUs detected on the node or the resource manager-assigned value if operating in the presence of an RM. IMPORTANT: If using a resource manager, the user-specified number of
slots is capped by the RM-assigned value.
The --leave-session-attached optionDo not discard stdout/stderr of remote PRRTE daemons. The primary use for this option is to ensure that the daemon output streams (i.e., stdout and stderr) remain open after launch, thus allowing the user to see any daemon-generated error messages. Otherwise, the daemon will “daemonize” itself upon launch, thereby closing its output streams. The --map-by optionProcesses are mapped based on one of the following directives as applied at the job level:
Any directive can include qualifiers by adding a colon (:) and any combination of one or more of the following (delimited by colons) to the --map-by option (except where noted):
NOTE: Directives and qualifiers are case-insensitive and can be
shortened to the minimum number of characters to uniquely identify them. Thus,
L1CACHE can be given as l1cache or simply as L1.
The type of CPU (core vs hwthread) used in the mapping algorithm is determined as follows:
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 via the PE=# qualifier to the --map-by command line directive. A more detailed description of the mapping, ranking, and binding procedure can be obtained via the --help placement option. The --output optionThe output command line directive must be accompanied by a comma-delimited list of case-insensitive options that control how output is generated. The full directive need not be provided — only enough characters are required to uniquely identify the directive. For example, MERGE is sufficient to represent the MERGE-STDERR-TO-STDOUT directive — while TAG can not be used to represent TAG-DETAILED (though TAG-D would suffice). Supported values include:
Supported qualifiers include NOCOPY (do not copy the output to the stdout/err streams), and RAW (do not buffer the output into complete lines, but instead output it as it is received). The --pmixmca optionPass a PMIx MCA parameter Syntax: --pmixmca <key> <value>, where key is the parameter name and value is the parameter value. The --prefix optionPrefix to be used to look for PRRTE executables. PRRTE automatically sets the prefix for remote daemons if it was either configured with the --enable-prte-prefix-by-default option OR prte itself was executed with an absolute path to the prte command. This option overrides those settings, if present, and forces use of the provided path. The --pmix-prefix optionPrefix to be used by a PRRTE executable to look for its PMIx installation on remote nodes. This is the location of the top-level directory for the installation. If the installation has not been moved, it would be the value given to “–prefix” when the installation was configured. Note that PRRTE cannot determine the exact name of the library subdirectory under this location. For example, some systems will call it “lib” while others call it “lib64”. Accordingly, PRRTE will use the library subdirectory name of the PMIx installation used to build PRRTE. The --app-prefix optionPrefix to be used by an app to look for its PMIx installation on remote nodes. This is the location of the top-level directory for the installation. If the installation has not been moved, it would be the value given to “–prefix” when the installation was configured. Note that PRRTE cannot determine the exact name of the library subdirectory under this location. For example, some systems will call it “lib” while others call it “lib64”. Accordingly, PRRTE will use the library subdirectory name of the PMIx installation used to build PRRTE. In the absence of providing an application-specific prefix, the PMIx prefix (if given) used by PRRTE’s own executables will be applied unless the “–no-app-prefix” directive is given. The --no-app-prefix optionDo not apply any prefix to this application. This is needed when a default PMIx prefix has been given to PRRTE, but the application has been built against a PMIx library that (a) is different from the one used by PRRTE, and (b) was not moved. Otherwise, PRRTE will apply its default prefix to the application. The --prtemca optionPass a PRRTE MCA parameter. Syntax: --prtemca <key> <value>, where key is the parameter name and value is the parameter value. The --noprefix optionDisable automatic --prefix behavior. PRRTE automatically sets the prefix for remote daemons if it was either configured with the --enable-prte-prefix-by-default option OR prte itself was executed with an absolute path to the prte command. This option disables that behavior. The --rank-by optionPRRTE automatically ranks processes for each job starting from zero. Regardless of the algorithm used, rank assignments span applications in the same job — i.e., a command line of -n 3 app1 : -n 2 app2 will result in app1 having three processes ranked 0-2 and app2 having two processes ranked 3-4. By default, process ranks are assigned in accordance with the mapping directive — e.g., jobs that are mapped by-node will have the process ranks assigned round-robin on a per-node basis. However, users can override the default by specifying any of the following directives using the --rank-by command line option:
The rank-by command line option has no qualifiers. NOTE: Directives are case-insensitive. SPAN is the same
as span.
A more detailed description of the mapping, ranking, and binding procedure can be obtained via the --help placement option. The --runtime-options optionThe --runtime-options command line directive must be accompanied by a comma-delimited list of case-insensitive options that control the runtime behavior of the job. The full directive need not be provided — only enough characters are required to uniquely identify the directive. Runtime options are typically true or false, though this is not a requirement on developers. Since the value of each option may need to be set (e.g., to override a default set by MCA parameter), the syntax of the command line directive includes the use of an = character to allow inclusion of a value for the option. For example, one can set the ABORT-NONZERO-STATUS option to true by specifying it as ABORT-NONZERO-STATUS=1. Note that boolean options can be set to true using a non-zero integer or a case-insensitive string of the word true. For the latter representation, the user need only provide at least the T character. The same policy applies to setting a boolean option to false. Note that a boolean option will default to true if provided without a value. Thus, --runtime-options abort-nonzero is sufficient to set the ABORT-NONZERO-STATUS option to true. Supported values include:
The --runtime-options command line option has no qualifiers. NOTE: Directives are case-insensitive. FWD-ENVIRONMENT
is the same as fwd-environment.
The --stream-buffering optionAdjust buffering for stdout/stderr. Allowable values:
The --tune optionComma-delimited list of one or more files containing PRRTE and PMIx MCA params for tuning DVM and/or application operations. Parameters in the file will be treated as generic parameters and subject to the translation rules/uncertainties. See --help mca for more information. Syntax in the file is: param = value with one parameter and its associated value per line. Empty lines and lines beginning with the # character are ignored. The -x optionExport an environment variable, optionally specifying a value. For example:
The --unset-env optionUnset the named environmental variable. Note --unset-env foo* unsets all current environmental variables starting with “foo” The --prepend-env optionPrepend the named environment variable with the given value. The “[c]” must be appended to the name to specify the separator to be used when appending the value. Example: --prepend-envar LD_LIBRARY_PATH[:] foo/lib will result in: LD_LIBRARY_PATH=foo/lib:$LD_LIBRARY_PATH The --append-env optionAppend the named environment variable with the given value. The “[c]” must be appended to the name to specify the separator to be used when appending the value. Example: --append-envar LD_LIBRARY_PATH[:] foo/lib will result in: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:foo/lib Deprecated command line optionsThe following command line options are deprecated, and should generally not be used. They may be removed in a future release of Open MPI. The --bind-to-core optionBind each process to its own core.
The --display-allocation optionDisplay the allocation being used by this job.
The --display-devel-allocation optionDisplay a detailed list (mostly intended for developers) of the allocation being used by this job.
The --display-devel-map optionDisplay a detailed process map (mostly intended for developers) just before launch.
The --display-map optionDisplay the process map just before launch.
The --display-topo optionDisplay the topology as part of the process map (mostly intended for developers) just before launch.
The --gmca optionSyntax: --gmca <key> <value>, where key is the parameter name and value is the parameter value. The g prefix indicates that this parameter is “global”, and to be applied to all application contexts — not just the one in which the directive appears. Pass generic MCA parameters — i.e., parameters whose project affiliation must be determined by PRRTE based on matching the name of the parameter with defined values from various projects that PRRTE knows about.
The --mca optionSyntax: --mca <key> <value>, where key is the parameter name and value is the parameter value. Pass generic MCA parameters — i.e., parameters whose project affiliation must be determined by PRRTE based on matching the name of the parameter with defined values from various projects that PRRTE knows about.
The --merge-stderr-to-stdout optionMerge stderr to stdout for each process.
The --output-directory optionRedirect output from application processes into filename/job/rank/std[out,err,diag]. A relative path value will be converted to an absolute path. The directory name may include a colon followed by a comma-delimited list of optional case-insensitive directives. Supported directives currently include NOJOBID (do not include a job-id directory level) and NOCOPY (do not copy the output to the stdout/err streams).
The --output-filename optionRedirect output from application processes into filename.rank. A relative path value will be converted to an absolute path. The directory name may include a colon followed by a comma-delimited list of optional case-insensitive directives. Supported directives currently include NOCOPY (do not copy the output to the stdout/err streams).
The --report-bindings optionDisplay process bindings to stderr.
The --tag-output optionTag all output with [job,rank].
The --timestamp-output optionTimestamp all application process output.
The --xml optionProvide all output in XML format.
OPTIONS (OLD / HARD-CODED CONTENT — TO BE AUDITED
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.
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.
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.
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.
To map processes:
NOTE: socket is also accepted as an alias for
package.
You can run Run the hwloc lstopo(1) command to see
a list of available cores and their logical IDs.
To order processes’ ranks in MPI_COMM_WORLD:
For process binding:
For rankfiles:
To manage standard I/O:
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:
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. Setting MCA parameters:
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 parammeters to PMIx and PRRTE,
respectively.
For debugging:
There are also other options:
The following options are useful for developers; they are not generally useful to most Open MPI users:
There may be other options listed with mpirun --help. Environment Variables
DESCRIPTION
One invocation of mpirun starts an MPI application running under Open MPI. If the application is single process multiple data (SPMD), the application can be specified on the mpirun command line. If the application is multiple instruction multiple data (MIMD), comprising of multiple programs, the set of programs and argument can be specified in one of two ways: Extended Command Line Arguments, and Application Context. An application context describes the MIMD program set including all arguments in a separate file. This file essentially contains multiple mpirun command lines, less the command name itself. The ability to specify different options for different instantiations of a program is another reason to use an application context. Extended command line arguments allow for the description of the application layout on the command line using colons (:) to separate the specification of programs and arguments. Some options are globally set across all specified programs (e.g., --hostfile), while others are specific to a single program (e.g., -n). Specifying Host Nodes
Host nodes can be identified on the mpirun command line with the --host option or in a hostfile. For example: shell$ mpirun -H aa,aa,bb ./a.out Launches two processes on node aa and one on bb. Or, consider the hostfile: shell$ cat myhostfile aa slots=2 bb slots=2 cc slots=2 Here, we list both the host names (aa, bb, and cc) but also how many slots there are for each. shell$ mpirun --hostfile myhostfile ./a.out will launch two processes on each of the three nodes. shell$ mpirun --hostfile myhostfile --host aa ./a.out will launch two processes, both on node aa. shell$ mpirun --hostfile myhostfile --host dd ./a.out will find no hosts to run on and will abort with an error. That is, the specified host dd is not in the specified hostfile. When running under resource managers (e.g., Slurm, Torque, etc.), Open MPI will obtain both the hostnames and the number of slots directly from the resource manager. Specifying Number of Processes
As we have just seen, the number of processes to run can be set using the hostfile. Other mechanisms exist. The number of processes launched can be specified 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 launches processes 0-3 on node aa and process 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 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 launches one process per host node. mpirun -H aa,bb --pernode ./a.out is the same as --map-by ppr:1:node and --npernode 1. Another alternative is to specify the number of processes with the -n option. Consider now the 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 will launch processes 0-3 on node aa and processes 4-5 on node bb. The remaining slots in the hostfile will not be used since the -n option indicated that only 6 processes should be launched. Mapping Processes to Nodes: Using Policies
The examples above illustrate the default mapping of process processes to nodes. This mapping can also be controlled with various mpirun options that describe mapping policies. Consider the same hostfile as above, again with -n 6. The table below lists a few mpirun variations, and shows which MPI_COMM_WORLD ranks end up on which node:
The --map-by node option will load balance the processes across the available nodes, numbering each process in a round-robin fashion. The --nolocal option prevents any processes from being mapped onto the local host (in this case node aa). While mpirun typically consumes few system resources, --nolocal can be helpful for launching very large jobs where mpirun may actually need to use noticeable amounts of memory and/or processing time. Just as -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 will launch processes 0-3 on node aa, 4-7 on bb, and 8-11 on cc. It will then add the remaining two processes to whichever nodes it chooses. One can also specify limits to oversubscription. For example, with the same hostfile: shell$ mpirun --hostfile myhostfile -n 14 --nooversubscribe ./a.out will produce an error since --nooversubscribe prevents oversubscription. 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 such a limit. When it does, the slots value defaults to the limit. Now: shell$ mpirun --hostfile myhostfile -n 14 ./a.out causes the first 12 processes to be launched as before, but the remaining two processes will be forced onto node cc. The other two nodes are protected by the hostfile against oversubscription by this job. Using the --nooversubscribe option can be helpful since Open MPI currently does not get max_slots values from the resource manager. Of course, -n can also be used with the -H or -host option. For example: shell$ mpirun -H aa,bb -n 8 ./a.out launches 8 processes. Since only two hosts are specified, after the first two processes are mapped, one to aa and one to bb, the remaining processes oversubscribe the specified hosts. And here is a MIMD example: shell$ mpirun -H aa -n 1 hostname : -H bb,cc -n 2 uptime will launch process 0 running hostname on node aa and processes 1 and 2 each running uptime on nodes bb and cc, respectively. Mapping, Ranking, and Binding: Oh My!
Open MPI employs a three-phase procedure for assigning process locations and ranks:
The mapping step is used to assign a default location to each process based on the mapper being employed. Mapping by slot, node, and sequentially results in the assignment of the processes to the node level. In contrast, mapping by object, allows the mapper to assign the process to an actual object on each node. Note that the location assigned to the process is independent of where it will be bound — the assignment is used solely as input to the binding algorithm. The mapping of process processes to nodes can be defined not just with general policies but also, if necessary, using arbitrary mappings that cannot be described by a simple policy. One 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, using the same hostfile as before: shell$ mpirun -hostfile myhostfile --map-by seq ./a.out will launch three processes, one on each of nodes aa, bb, and cc, respectively. The slot counts don’t matter; one process is launched per line on whatever node is listed on the line. Another way to specify arbitrary mappings is with a rankfile, which gives you detailed control over process binding as well. Rankfiles are discussed below. The second phase focuses on the ranking of the process within the job’s MPI_COMM_WORLD. Open MPI separates this from the mapping procedure to allow more flexibility in the relative placement of MPI processes. This is best illustrated by considering the following cases where we used the --np 8 --map-by ppr:2:package --host aa:4,bb:4 option:
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:
Defaults for Mapping, Ranking, and Binding
If the user does not specify each of --map-by, --rank-by, and --bind-to option then the default values are as follows:
Consider 2 identical hosts (hostA and hostB) with 2 packages (denoted by []) each with 8 cores (denoted by /../) and 2 hardware threads per core (denoted by a .). Default of --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/../../../../../..][../../../../../../../..] Default of --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, then 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 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/../../../../../..] The mapping pattern might be better seen if we change the default --rank-by from fill to span. 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 againast. 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
Rankfiles are text files that specify detailed information about how individual processes should be mapped to nodes, and to which processor(s) they should be bound. 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:
Note that only logicical processor locations are supported. By default, the values specifed 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. 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 resolveable 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 logicial 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. Application Context or Executable Program?
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. Locating Files
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
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. 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. Standard I/O
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. Signal Propagation
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. 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
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. User signal handlers should probably avoid trying to cleanup MPI state (Open MPI is currently not async-signal-safe; see MPI_INIT_THREAD(3) for details about MPI_THREAD_MULTIPLE and thread safety). For example, if a segmentation fault occurs in MPI_SEND(3) (perhaps because a bad buffer was passed in) and a user signal handler is invoked, if this user handler attempts to invoke MPI_FINALIZE(3), Bad Things could happen since Open MPI was already “in” MPI when the error occurred. Since mpirun will notice that the process died due to a signal, it is probably not necessary (and safest) for the user to only clean up non-MPI state. Process Environment
Processes in the MPI application inherit their environment from the PRRTE daemon upon the node on which they are 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 which require the LD_LIBRARY_PATH environment variable to be set, care must be taken to ensure that it is correctly set when booting Open MPI. See the Remote Execution section for more details. Remote Execution
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). However, it is 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. 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:
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. 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
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
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 --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
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:
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. Running as root
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
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):
By default, the job will abort when any process terminates with non-zero status. 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 the Open MPI records and notes that processes exited with non-zero termination status to report the appropriate exit status of mpirun (per bullet points above). EXAMPLES
Be sure also to see the examples throughout the sections above. 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. RETURN VALUE
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. In the event that 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 is not guaranteed to be so. 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)
COPYRIGHT2003-2026, The Open MPI Community
|