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 failed = failed ~= 0;
70 if ~failed
71 path = string(strip(stdout, newline));
72 % On Windows, ``where()`` returns a list of all identified paths.
73 % Note that MATLAB has also its own ``mpiexec`` which can show up in ``path``.
74 if ispc()
75 pathList = split(path, newline);
76 for i = 1 : length(pathList)
77 item = pathList(i);
78 if ~contains(item, "MATLAB" + filesep + "R")
79 path = pathList(i);
80 end
81 end
82 end
83 vendorNameLower = lower(pm.sys.path.mpiexec.vendor(path));
84 if vendorNameLower ~= ""
85 if ~(contains(appName, vendorLower) || contains(vendorNameLower, vendorLower))
86 path = "";
87 end
88 else
89 path = "";
90 end
91 end
92 if path ~= ""
93 path = string(strip(path, newline));
94 break;
95 end
96 end
97end
function vendor(in name)
Return the MPI library vendor name from the input MPI name based on the internal ParaMonte shared lib...
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 which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...