ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
rankp1.m File Reference

Go to the source code of this file.

Functions

function rankp1 (in vendor)
 Return the ID (MPI rank + 1) of the current MPI image (process), starting from the number one.
More...
 

Function Documentation

◆ rankp1()

function rankp1 ( in  vendor)

Return the ID (MPI rank + 1) of the current MPI image (process), starting from the number one.

Beware that this routine returns 1 for the MPI rank of the first process which is 0.
This is the reason for the naming used for this function rankp1 standing for rank + 1, consistent with the parallel ParaMonte library conventions across all supported programming languages.

This function can be used to automate the inclusion or exclusion of single-process activities within the ParaMonte library by creating a fence around the activities (e.g., visualization, or postprocessing tasks) to be done only by a specific (normally the first) parallel process.
See the documentation of pm.sampling.Paradram for example usage.

Parameters
[in]vendor: See the corresponding argument of pm.lib.mpi.runtime.detect.
(optional. The default is set by pm.lib.mpi.runtime.detect.)
Returns
value : The output MATLAB scalar positive whole-number containing the image (process) ID of the MPI processes launched by the mpiexec.
If no MPI parallelism is involved with current application session, of if an error occurs while inferring the MPI image ID, the returned value is always 1.


Possible calling interfaces

value = pm.lib.mpi.runtime.rankp1()
value = pm.lib.mpi.runtime.rankp1([])
value = pm.lib.mpi.runtime.rankp1(vendor)
function vendor(in name)
Return the MPI library vendor name from the input MPI name based on the internal ParaMonte shared lib...


Example usage

1cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
2addpath('../../../../../'); % Add the ParaMonte library root directory to the search path.
3
4disp('pm.lib.mpi.runtime.rankp1()')
5disp( pm.lib.mpi.runtime.rankp1() )
6
7disp("")
8disp('pm.lib.mpi.runtime.rankp1([])')
9disp( pm.lib.mpi.runtime.rankp1([]) )
10
11disp("")
12disp('pm.lib.mpi.runtime.rankp1("impi")')
13disp( pm.lib.mpi.runtime.rankp1("impi") )
14
15disp("")
16disp('pm.lib.mpi.runtime.rankp1("INTEL")')
17disp( pm.lib.mpi.runtime.rankp1("INTEL") )
18
19disp("")
20disp('pm.lib.mpi.runtime.rankp1("intel")')
21disp( pm.lib.mpi.runtime.rankp1("intel") )
22
23disp("")
24disp('pm.lib.mpi.runtime.rankp1("ompi")')
25disp( pm.lib.mpi.runtime.rankp1("ompi") )
26
27disp("")
28disp('pm.lib.mpi.runtime.rankp1("openmpi")')
29disp( pm.lib.mpi.runtime.rankp1("openmpi") )
30
31disp("")
32disp('pm.lib.mpi.runtime.rankp1("open-mpi")')
33disp( pm.lib.mpi.runtime.rankp1("open-mpi") )
34
35disp("")
36disp('pm.lib.mpi.runtime.rankp1("mpich")')
37disp( pm.lib.mpi.runtime.rankp1("mpich") )
38
39disp("")
40disp('pm.lib.mpi.runtime.rankp1("unknown")')
41disp( pm.lib.mpi.runtime.rankp1("unknown") )
function impi()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
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.
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.

Example output
1pm.lib.mpi.runtime.rankp1()
2 1
3pm.lib.mpi.runtime.rankp1([])
4 1
5pm.lib.mpi.runtime.rankp1("impi")
6 1
7pm.lib.mpi.runtime.rankp1("INTEL")
8 1
9pm.lib.mpi.runtime.rankp1("intel")
10 1
11pm.lib.mpi.runtime.rankp1("ompi")
12 1
13pm.lib.mpi.runtime.rankp1("openmpi")
14 1
15pm.lib.mpi.runtime.rankp1("open-mpi")
16 1
17pm.lib.mpi.runtime.rankp1("mpich")
18 1
19pm.lib.mpi.runtime.rankp1("unknown")
20 1


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin