ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
rankp1.m
Go to the documentation of this file.
1%> \brief
2%> Return the ID (MPI rank + 1) of the current MPI image (process),
3%> **starting from the number one**.<br>
4%>
5%> \details
6%> Beware that this routine returns ``1``
7%> for the MPI rank of the first process which is ``0``.<br>
8%> This is the reason for the naming used for this function ``rankp1``
9%> standing for ``rank + 1``, consistent with the parallel ParaMonte
10%> library conventions across all supported programming languages.<br>
11%>
12%> This function can be used to automate the inclusion or exclusion of
13%> single-process activities within the ParaMonte library by creating a fence
14%> around the activities (e.g., visualization, or postprocessing tasks) to
15%> be done only by a specific (normally the first) parallel process.<br>
16%> See the documentation of [pm.sampling.Paradram](@ref Paradram) for example usage.<br>
17%>
18%> \param[in] vendor : See the corresponding argument of [pm.lib.mpi.runtime.detect](@ref detect).<br>
19%> (**optional**. The default is set by [pm.lib.mpi.runtime.detect](@ref detect).)
20%>
21%> \return
22%> ``value`` : The output MATLAB scalar positive whole-number containing the
23%> image (process) ID of the MPI processes launched by the ``mpiexec``.<br>
24%> If no MPI parallelism is involved with current application session,
25%> of if an error occurs while inferring the MPI image ID,
26%> the returned value is always ``1``.<br>
27%>
28%> \interface{rankp1}
29%> \code{.m}
30%>
31%> value = pm.lib.mpi.runtime.rankp1()
32%> value = pm.lib.mpi.runtime.rankp1([])
33%> value = pm.lib.mpi.runtime.rankp1(vendor)
34%>
35%> \endcode
36%>
37%> \example{rankp1}
38%> \include{lineno} example/lib/mpi/runtime/rankp1/main.m
39%> \output{rankp1}
40%> \include{lineno} example/lib/mpi/runtime/rankp1/main.out.m
41%>
42%> \final{rankp1}
43%>
44%> \author
45%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
46%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
47function value = rankp1(vendor)
48 if nargin < 1
49 vendor = [];
50 end
51 [~, ~, value] = pm.lib.mpi.runtime.detect(vendor);
52 value = max(1, value);
53end
function vendor(in name)
Return the MPI library vendor name from the input MPI name based on the internal ParaMonte shared lib...
This is the ParaDRAM class for generating instances of serial and parallel Delayed-Rejection Adaptive...
Definition: Paradram.m:18
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 lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function parallel()
Return a scalar MATLAB logical that is true if and only if the current installation of MATLAB contain...
function rankp1(in vendor)
Return the ID (MPI rank + 1) of the current MPI image (process), starting from the number one.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...