ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
vendor.m
Go to the documentation of this file.
1%> \brief
2%> Return the a MATLAB string containing the MPI library vendor
3%> name corresponding to the input ``mpiexec`` system path.<br>
4%>
5%> \param[in] path : The input scalar MATLAB string,
6%> containing the path to the ``mpiexec``
7%> binary whose vendor is to be determined.<br>
8%> (**optional**, default = [pm.sys.path.mpiexec.which()](@ref which))
9%>
10%> \return
11%> ``name`` : The output MATLAB string containing the MPI library vendor name ALL in lower-case.<br>
12%> Possible values are:<br>
13%> <ol>
14%> <li> ``"Intel"`` : representing the Intel MPI library.
15%> <li> ``"MPICH"`` : representing the MPICH MPI library.
16%> <li> ``"OpenMPI"`` : representing the OpenMPI library.
17%> </ol>
18%> If the vendor name cannot be identified, the output will be empty ``""``.<br>
19%>
20%> \interface{vendor}
21%> \code{.m}
22%>
23%> name = pm.sys.path.mpiexec.vendor()
24%> name = pm.sys.path.mpiexec.vendor(path)
25%>
26%> \endcode
27%>
28%> \example{vendor}
29%> \include{lineno} example/sys/path/mpiexec/vendor/main.m
30%> \output{vendor}
31%> \include{lineno} example/sys/path/mpiexec/vendor/main.out.m
32%>
33%> \final{vendor}
34%>
35%> \author
36%> \JoshuaOsborne, May 21 2024, 5:04 AM, University of Texas at Arlington<br>
37%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
38%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
39function name = vendor(path)
40 name = "";
41 if 0 == nargin
42 path = pm.sys.path.mpiexec.which();
43 if path == ""
44 return;
45 end
46 else
47 path = string(path);
48 end
49 if contains(path, ".openmpi")
50 name = "OpenMPI";
51 elseif contains(path, ".mpich")
52 name = "MPICH";
53 else
54 % Retrieve mpiexec version.
55 if isunix()
56 path = strrep(path, """", "\""");
57 end
58 failed = pm.os.is.lin() && startsWith(path, "/mnt/"); % A Windows-path application in WSL freezes MATLAB.
59 if ~failed
60 [failed, version] = system("""" + path + """" + " --version");
61 end
62 if ~failed
63 versionLower = lower(version);
64 if contains(version, "Intel")
65 name = "Intel";
66 elseif contains(versionLower, "openmpi") || contains(versionLower, "open-mpi") || contains(versionLower, "openrte")
67 name = "OpenMPI";
68 elseif contains(versionLower, "mpich") || contains(versionLower, "hydra")
69 % MPICH is the most elusive, so we check it as the last possibility.
70 name = "MPICH";
71 end
72 else
73 % On Windows (and perhaps other OS), calling ``system("mpiexec --version")``
74 % can fail because ``mpiexec`` can refer to the MATLAB copy of mpiexec binary.
75 % Unknown option: -version
76 % Error: no executable specified
77 % Unable to parse the mpiexec command arguments.
78 % To bypass this failure, we check if ``cpuinfo`` exists in the same path as ``mpiexec``.
79 % If so, then the mpiexec binary belongs to Intel MPI library.
80 [dirname, filename, extname] = fileparts(path);
81 if filename == "mpiexec"
82 cipath = fullfile(dirname, "cpuinfo" + extname);
83 if isfile(cipath)
84 name = "Intel";
85 elseif ispc() && extname ~= ".exe"
86 cipath = fullfile(dirname, "cpuinfo.exe");
87 if isfile(cipath)
88 name = "Intel";
89 end
90 end
91 end
92 end
93 end
94end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
function copy(in from, in to, in fields)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...
function lin()
Return true if the current OS is Linux.
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...