Environment
Launching MPI programs
MPI.mpiexec
— Function.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 JuliaCmd
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
Enums
MPI.ThreadLevel
— Type.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. SeeIs_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
Functions
MPI.Abort
— Function.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
MPI.Init
— Function.Init()
Initialize MPI in the current process.
All MPI programs must contain exactly one call to MPI.Init
or MPI.Init_thread
. In particular, note that it is not valid to call MPI.Init
or MPI.Init_thread
again after calling MPI.Finalize
.
The only MPI functions that may be called before MPI.Init
/MPI.Init_thread
are MPI.Initialized
and MPI.Finalized
.
External links
MPI.Init_thread
— Function.Init_thread(required::ThreadLevel)
Initialize MPI and the MPI thread environment in the current process. The argument specifies the required level of threading support, see ThreadLevel
.
The function will return the provided ThreadLevel
, and values may be compared via inequalities, i.e.
provided = Init_thread(required)
@assert provided >= required
All MPI programs must contain exactly one call to MPI.Init
or MPI.Init_thread
. In particular, note that it is not valid to call MPI.Init
or MPI.Init_thread
again after calling MPI.Finalize
.
The only MPI functions that may be called before MPI.Init
/MPI.Init_thread
are MPI.Initialized
and MPI.Finalized
.
External links
MPI.Query_thread
— Function.Query_thread()
Query the level of threading support in the current process. Returns a ThreadLevel
value denoting
External links
MPI.Is_thread_main
— Function.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
MPI.Initialized
— Function.Initialized()
Returns true
if MPI.Init
has been called, false
otherwise.
It is unaffected by MPI.Finalize
, and is one of the few functions that may be called before MPI.Init
.
External links
MPI.Finalize
— Function.Finalize()
Marks MPI state for cleanup. This should be called after Init
, at most once, and no further MPI calls (other than Initialized
or Finalized
) should be made after it is called.
Note that this does not correspond exactly to MPI_FINALIZE
in the MPI specification. In particular:
It may not finalize MPI immediately. Julia will wait until all MPI-related objects are garbage collected before finalizing MPI. As a result,
Finalized()
may returnfalse
afterFinalize()
has been called. See Finalizers for more details.It is optional:
Init
will automatically insert a hook to finalize MPI when Julia exits.
External links
MPI.Finalized
— Function.Finalized()
Returns true
if MPI.Finalize
has completed, false
otherwise.
It is safe to call before MPI.Init
and after MPI.Finalize
.
External links
MPI.universe_size
— Function.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.