2%> Return the MPI image count and the current image ID (e.g., MPI rank + 1)
3%>
if the application has been launched via a Hydra-based MPI ``mpiexec`` launcher.<br>
6%> This function attempts to
detect the invocation of the current MATLAB
7%> session via a Hydra-based MPI ``mpiexec`` binary MPI launcher instance.<br>
8%> The runtime detection is achieved by checking
for runtime environment
9%> variables that a Hydra-based ``mpiexec`` binary executable defines upon launch.<br>
11%> Specifically, a Hydra-basedMPI provides an informal
list of
12%> environment variables that are defined on every MPI process.<br>
13%> These variables may not be defined on all platforms.<br>
14%> Some are only defined at runtime,
while others are defined at compile-time.<br>
17%> <li> On **Unix systems**, the best approach to investigate the Hydra-MPI-specific runtime variables
18%> is to launch a Hydra-based ``mpiexec`` binary executable with the ``printenv`` Unix command.<br>
20%> mpiexec -np 1 printenv
22%> To see the compile-time variables and compare them with the runtime
list from the above,
try:<br>
26%> <li> On **Windows systems**, the best approach to investigate the Hydra-specific runtime variables
27%> is to launch a Hydra-based ``mpiexec`` binary executable with the ``set`` Windows batch command.<br>
29%> mpiexec -n 1 cmd /k set
31%> To see the compile-time variables and compare them with the runtime
list from the above,
try:<br>
35%> Note that as of 2024, the only ParaMonte-compatible Hydra-based
36%> MPI library on Windows is the Intel MPI library.<br>
39%> The most persistent environment variables
for Hydra-based ``mpiexec`` binary appear to be the following:<br>
42%> <li> ``PMI_RANK`` : The rank of the current process in the current MPI communication world.<br>
43%> <li> ``PMI_SIZE`` : The size (i.e., number of images/processes) of the current MPI communication world.<br>
44%> <li> ``MPI_LOCALRANKID`` : The **local** rank of the current process relative to the local host.<br>
45%> This environment variable may not be defined on all platforms (e.g., Windows) by all Hydra-based MPI libraries.<br>
46%> <li> ``MPI_LOCALNRANKS`` : The size (i.e., number of images/processes) of the current MPI communication on the local host.<br>
47%> This environment variable may not be defined on all platforms (e.g., Windows) by all Hydra-based MPI libraries.<br>
51%> ``
nproc`` : The output scalar MATLAB non-negative whole number containing
52%> the number of MPI images in the current invocation of a
53%> Hydra-based MPI ``mpiexec`` binary MPI launcher.<br>
54%> An output value of ``0`` implies the algorithm failed to
detect
55%> a ParaMonte-compatible Hydra-based MPI library or failed to infer the image count.<br>
56%> ``
rankp1`` : The output scalar MATLAB non-negative whole number containing
57%> the image ID (e.g., MPI rank + 1) of the current MPI image in
58%> the current invocation of a Hydra-based ``mpiexec`` binary MPI launcher.<br>
59%> An output value of ``0`` implies the algorithm failed to
detect
60%> a ParaMonte-compatible MPI library or failed to infer the image count.<br>
61%> Note that the image ID always starts at ``1``, unlike the MPI rank.<br>
62%> The argument ``
rankp1`` stands for ``rank + 1``.<br>
63%> An output value of ``0`` implies the algorithm failed to
detect
64%> a ParaMonte-compatible Hydra-based MPI library or failed to infer the image count.<br>
74%> [pm.lib.mpi.runtime.mmpi()](@ref
mmpi)<br>
75%> [pm.lib.mpi.runtime.impi()](@ref
impi)<br>
76%> [pm.lib.mpi.runtime.ompi()](@ref
ompi)<br>
77%> [pm.lib.mpi.runtime.hydra()](@ref
hydra)<br>
78%> [pm.lib.mpi.runtime.nproc()](@ref
nproc)<br>
79%> [pm.lib.mpi.runtime.rankp1()](@ref
rankp1)<br>
80%> [pm.lib.mpi.runtime.isimpi()](@ref
isimpi)<br>
81%> [pm.lib.mpi.runtime.detect()](@ref
detect)<br>
84%> \include{lineno} example/
lib/mpi/runtime/
hydra/main.m
86%> \include{lineno} example/
lib/mpi/runtime/
hydra/main.out.m
91%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
92%> \AmirShahmoradi, 12:10 AM Wednesday, November 13, 2024, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
95 for varname = ["PMI_SIZE", "MPI_LOCALNRANKS"]
96 nproc = getenv(varname);
108 for varname = ["PMI_RANK", "MPI_LOCALRANKID"]
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function detect(in vendor)
Return the MPI image count and current image ID (e.g., MPI rank + 1) and the MPI library name as it a...
function hydra()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function impi()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function isimpi()
Return true if and only if the application has been invoked via an Intel MPI mpiexec launcher,...
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function mmpi()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function nproc(in vendor)
Return the runtime number of MPI processes with which the mpiexec launcher may have been invoked.
function ompi()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function rankp1(in vendor)
Return the ID (MPI rank + 1) of the current MPI image (process), starting from the number one.