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

Go to the source code of this file.

Functions

function nproc (in vendor)
 Return the runtime number of MPI processes with which the mpiexec launcher may have been invoked.
More...
 

Function Documentation

◆ nproc()

function nproc ( in  vendor)

Return the runtime number of MPI processes with which the mpiexec launcher may have been invoked.

Otherwise, return 1 if no use of mpiexec launcher is detected or it is invoked with only 1 MPI process.

An output value of >1 can be used as an indication of the use of the mpiexec launcher in launching the ParaMonte library.

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 number of MPI processes launched by the mpiexec command or 1 if no mpiexec invocation has occurred or mpiexec has been launched with only one process or the rank inference fails.


Possible calling interfaces

value = pm.lib.mpi.runtime.nproc()
value = pm.lib.mpi.runtime.nproc([])
value = pm.lib.mpi.runtime.nproc(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.nproc()')
5disp( pm.lib.mpi.runtime.nproc() )
6
7disp("")
8disp('pm.lib.mpi.runtime.nproc([])')
9disp( pm.lib.mpi.runtime.nproc([]) )
10
11disp("")
12disp('pm.lib.mpi.runtime.nproc("impi")')
13disp( pm.lib.mpi.runtime.nproc("impi") )
14
15disp("")
16disp('pm.lib.mpi.runtime.nproc("INTEL")')
17disp( pm.lib.mpi.runtime.nproc("INTEL") )
18
19disp("")
20disp('pm.lib.mpi.runtime.nproc("intel")')
21disp( pm.lib.mpi.runtime.nproc("intel") )
22
23disp("")
24disp('pm.lib.mpi.runtime.nproc("ompi")')
25disp( pm.lib.mpi.runtime.nproc("ompi") )
26
27disp("")
28disp('pm.lib.mpi.runtime.nproc("openmpi")')
29disp( pm.lib.mpi.runtime.nproc("openmpi") )
30
31disp("")
32disp('pm.lib.mpi.runtime.nproc("open-mpi")')
33disp( pm.lib.mpi.runtime.nproc("open-mpi") )
34
35disp("")
36disp('pm.lib.mpi.runtime.nproc("mpich")')
37disp( pm.lib.mpi.runtime.nproc("mpich") )
38
39disp("")
40disp('pm.lib.mpi.runtime.nproc("unknown")')
41disp( pm.lib.mpi.runtime.nproc("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 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 root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.

Example output
1pm.lib.mpi.runtime.nproc()
2 1
3pm.lib.mpi.runtime.nproc([])
4 1
5pm.lib.mpi.runtime.nproc("impi")
6 1
7pm.lib.mpi.runtime.nproc("INTEL")
8 1
9pm.lib.mpi.runtime.nproc("intel")
10 1
11pm.lib.mpi.runtime.nproc("ompi")
12 1
13pm.lib.mpi.runtime.nproc("openmpi")
14 1
15pm.lib.mpi.runtime.nproc("open-mpi")
16 1
17pm.lib.mpi.runtime.nproc("mpich")
18 1
19pm.lib.mpi.runtime.nproc("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