ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
nproc.m
Go to the documentation of this file.
1%> \brief
2%> Return the runtime number of MPI processes
3%> with which the `mpiexec` launcher may have been invoked.<br>
4%>
5%> \details
6%> Otherwise, return `1` if no use of `mpiexec` launcher is
7%> detected or it is invoked with only ``1`` MPI process.<br>
8%>
9%> An output value of ``>1`` can be used as an indication of the use
10%> of the ``mpiexec`` launcher in launching the ParaMonte library.<br>
11%>
12%> \param[in] vendor : See the corresponding argument of [pm.lib.mpi.runtime.detect](@ref detect).<br>
13%> (**optional**. The default is set by [pm.lib.mpi.runtime.detect](@ref detect).)
14%>
15%> \return
16%> ``value`` : The output MATLAB scalar positive whole number, containing the number
17%> of MPI processes launched by the ``mpiexec`` command or ``1``
18%> if no ``mpiexec`` invocation has occurred or ``mpiexec``
19%> has been launched with only one process or the rank
20%> inference fails.<br>
21%>
22%> \interface{nproc}
23%> \code{.m}
24%>
25%> value = pm.lib.mpi.runtime.nproc()
26%> value = pm.lib.mpi.runtime.nproc([])
27%> value = pm.lib.mpi.runtime.nproc(vendor)
28%>
29%> \endcode
30%>
31%> \example{nproc}
32%> \include{lineno} example/lib/mpi/runtime/nproc/main.m
33%> \output{nproc}
34%> \include{lineno} example/lib/mpi/runtime/nproc/main.out.m
35%>
36%> \final{nproc}
37%>
38%> \author
39%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
40%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
41function value = nproc(vendor)
42 if nargin < 1
43 vendor = [];
44 end
45 [~, value, ~] = pm.lib.mpi.runtime.detect(vendor);
46 value = max(1, value);
47 %if nargin < 1
48 % vendorList = [];
49 %else
50 % vendorList = string(vendor);
51 %end
52 %if pm.array.len(vendorList) == 0
53 % vendorList = pm.lib.mpi.choices();
54 %end
55 %value = 1;
56 %mexname = "pm_parallelism";
57 %for iname = 1 : length(vendorList)
58 % mexdirs = pm.lib.path.mexdir(mexname, vendorList(iname));
59 % for ipath = 1 : length(mexdirs)
60 % %mexdirs{ipath}
61 % matpath = path;
62 % pm.lib.path.clean();
63 % path(matpath, mexdirs{ipath});
64 % %persistent mh;
65 % %if ~isa(mh, 'matlab.mex.MexHost') || ~isvalid(mh)
66 % % mh = mexhost;
67 % %end
68 % %temp = feval(mh, mexname, 'getImageCountMPI');
69 % %value = max(value, temp);
70 % mexcall = string(mexname + "('getImageCountMPI');");
71 % try
72 % temp = eval(mexcall);
73 % value = max(value, temp);
74 % catch
75 % continue;
76 % end
77 % path(matpath);
78 % end
79 %end
80end
function vendor(in name)
Return the MPI library vendor name from the input MPI name based on the internal ParaMonte shared lib...
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 nproc(in vendor)
Return the runtime number of MPI processes with which the mpiexec launcher may have been invoked.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...