ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
which.m
Go to the documentation of this file.
1%> \brief
2%> Return the a MATLAB string containing the path to
3%> the first ``mpiexec`` executable binary found in system path.
4%>
5%> \details
6%> The output of this function is what is typically returned
7%> by the Unix command ``command -v mpiexec`` or the Windows CMD
8%> command ``where mpiexec``.<br>
9%>
10%> \warning
11%> Note that this function intentionally skips any ``mpiexec``
12%> path that is installed by and within the MATLAB binary directory.<br>
13%>
14%> \param[in] vendor : The input scalar MATLAB string, containing the MPI
15%> library vendor that should match the ``mpiexec`` binary.<br>
16%> Possible values are:<br>
17%> <ol>
18%> <li> ``"Intel"`` : representing the Intel MPI library.
19%> <li> ``"MPICH"`` : representing the MPICH MPI library.
20%> <li> ``"OpenMPI"`` : representing the OpenMPI library.
21%> </ol>
22%> (**optional**, default = ``""`` representing all possible vendors.)
23%>
24%> \return
25%> ``path`` : The output MATLAB string containing the paths to
26%> the first ``mpiexec`` executable binary found in system path.<br>
27%> If the ``mpiexec`` does not exist or match the specified ``vendor``,
28%> the output will be an empty string ``""``.<br>
29%>
30%>
31%> \interface{which}
32%> \code{.m}
33%>
34%> path = pm.sys.path.mpiexec.which()
35%> path = pm.sys.path.mpiexec.which(vendor)
36%>
37%> \endcode
38%>
39%> \example{which}
40%> \include{lineno} example/sys/path/mpiexec/which/main.m
41%> \output{which}
42%> \include{lineno} example/sys/path/mpiexec/which/main.out.m
43%>
44%> \final{which}
45%>
46%> \author
47%> \JoshuaOsborne, May 21 2024, 5:06 AM, University of Texas at Arlington<br>
48%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
49%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
50function path = which(vendor)
51 if 0 < nargin
52 vendorLower = lower(vendor);
53 if vendorLower == "impi"
54 vendorLower = "intel";
55 elseif vendorLower == "open-mpi" || vendorLower == "openrte"
56 vendorLower = "openmpi";
57 end
58 else
59 vendorLower = "";
60 end
61 path = "";
62 appNameList = ["mpiexec", "mpiexec.openmpi", "mpiexec.mpich"];
63 for appName = appNameList
64 if ispc()
65 [failed, stdout] = system("where " + appName);
66 else
67 [failed, stdout] = system("command -v " + appName);
68 end
69 if ~failed
70 path = string(strip(stdout, newline));
71 % On Windows, ``where()`` returns a list of all identified paths.
72 % Note that MATLAB has also its own ``mpiexec`` which can show up in ``path``.
73 if ispc()
74 pathList = split(path, newline);
75 for i = 1 : length(pathList)
76 item = pathList(i);
77 if ~contains(item, "MATLAB" + filesep + "R")
78 path = pathList(i);
79 end
80 end
81 end
82 vendorNameLower = lower(pm.sys.path.mpiexec.vendor(path));
83 if vendorNameLower ~= ""
84 if ~(contains(appName, vendorLower) || contains(vendorNameLower, vendorLower))
85 path = "";
86 end
87 else
88 path = "";
89 end
90 end
91 if path ~= ""
92 path = string(strip(path, newline));
93 break;
94 end
95 end
96end
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function show(in obj, in name, in hidden)
Display the components of an input MATLAB variable on MATLAB Console recursively.
function vendor(in path)
Return the a MATLAB string containing the MPI library vendor name corresponding to the input mpiexec ...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...