Environment

Launching MPI programs

MPI.mpiexecFunction
mpiexec(fn)

A wrapper function for the MPI launcher executable. Calls fn(cmd), where cmd is a Cmd object of the MPI launcher.

Environment Variables

The behaviour of mpiexec can be controlled by the following environment variables:

  • JULIA_MPIEXEC: the name or path of the launcher executable (set at compile time).
  • JULIA_MPIEXEC_ARGS: additional arguments that are passed to the launcher. These are space seperated, supporting the same quoting rules as Julia Cmd objects. These can be modified at run time.

Usage

julia> mpiexec(cmd -> run(`$cmd -n 3 echo hello world`));
hello world
hello world
hello world
source
MPI.install_mpiexecjlFunction
MPI.install_mpiexecjl(; command::String = "mpiexecjl",
                      destdir::String = joinpath(DEPOT_PATH[1], "bin"),
                      force::Bool = false, verbose::Bool = true)

Install the mpiexec wrapper to destdir directory, with filename command. Set force to true to overwrite an existing destination file with the same path. If verbose is true, the installation prints information about the progress of the process.

source

Enums

MPI.ThreadLevelType
ThreadLevel

An Enum denoting the level of threading support in the current process:

  • MPI.THREAD_SINGLE: Only one thread will execute.

  • MPI.THREAD_FUNNELED: The process may be multi-threaded, but the application must ensure that only the main thread makes MPI calls. See Is_thread_main.

  • MPI.THREAD_SERIALIZED: The process may be multi-threaded, and multiple threads may make MPI calls, but only one at a time (i.e. all MPI calls are serialized).

  • MPI.THREAD_MULTIPLE: Multiple threads may call MPI, with no restrictions.

See also

source

Functions

MPI.AbortFunction
Abort(comm::Comm, errcode::Integer)

Make a “best attempt” to abort all tasks in the group of comm. This function does not require that the invoking environment take any action with the error code. However, a Unix or POSIX environment should handle this as a return errorcode from the main program.

External links

source
MPI.InitFunction
Init(;threadlevel=:serialized, finalize_atexit=true, errors_return=true)

Initialize MPI in the current process. The keyword options:

  • threadlevel: either :single, :funneled, :serialized (default), :multiple, or an instance of ThreadLevel.
  • finalize_atexit: if true (default), adds an atexit hook to call MPI.Finalize if it hasn't already been called.
  • errors_return: if true (default), will set the default error handlers for MPI.COMM_SELF and MPI.COMM_WORLD to be MPI.ERRORS_RETURN. MPI errors will then appear as Julia exceptions.

It will return the ThreadLevel value which MPI is initialized at.

All MPI programs must call this function at least once before calling any other MPI operations: the only MPI functions that may be called before MPI.Init are MPI.Initialized and MPI.Finalized.

It is safe to call MPI.Init multiple times, however it is not valid to call it after calling MPI.Finalize.

External links

source
MPI.Is_thread_mainFunction
Is_thread_main()

Queries whether the current thread is the main thread according to MPI. This can be called by any thread, and is useful for the THREAD_FUNNELED ThreadLevel.

External links

source
MPI.FinalizeFunction
Finalize()

Marks MPI state for cleanup. This should be called after MPI.Init, and can be called at most once. No further MPI calls (other than Initialized or Finalized) should be made after it is called.

MPI.Init will automatically insert a hook to call this function when Julia exits, if it hasn't already been called.

External links

source
MPI.universe_sizeFunction
universe_size()

The total number of available slots, or nothing if it is not defined. This is determined by the MPI_UNIVERSE_SIZE attribute of COMM_WORLD.

This is typically dependent on the MPI implementation: for MPICH-based implementations, this is specified by the -usize argument. OpenMPI defines a default value based on the number of processes available.

source