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%> \see
29%> [pm.lib.mpi.name()](@ref name)<br>
30%> [pm.lib.mpi.vendor()](@ref vendor)<br>
31%> [pm.sys.path.mpiexec.vendor()](@ref vendor)<br>
32%>
33%> \example{vendor}
34%> \include{lineno} example/sys/path/mpiexec/vendor/main.m
35%> \output{vendor}
36%> \include{lineno} example/sys/path/mpiexec/vendor/main.out.m
37%>
38%> \final{vendor}
39%>
40%> \author
41%> \JoshuaOsborne, May 21 2024, 5:04 AM, University of Texas at Arlington<br>
42%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
43%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
44function name = vendor(path)
45 name = "";
46 if 0 == nargin
47 path = pm.sys.path.mpiexec.which();
48 if path == ""
49 return;
50 end
51 else
52 path = string(path);
53 end
54 if contains(path, ".openmpi")
55 name = "OpenMPI";
56 elseif contains(path, ".mpich")
57 name = "MPICH";
58 else
59 % Retrieve mpiexec version.
60 if isunix()
61 path = strrep(path, """", "\""");
62 end
63 failed = pm.os.is.lin() && startsWith(path, "/mnt/"); % A Windows-path application in WSL freezes MATLAB.
64 if ~failed
65 [failed, version] = system("""" + path + """" + " --version");
66 failed = failed ~= 0;
67 end
68 if ~failed
69 versionLower = lower(version);
70 if contains(version, "Intel")
71 name = "Intel";
72 elseif contains(versionLower, "openmpi") || contains(versionLower, "open-mpi") || contains(versionLower, "openrte")
73 name = "OpenMPI";
74 elseif contains(versionLower, "mpich") || contains(versionLower, "hydra")
75 % MPICH is the most elusive, so we check it as the last possibility.
76 name = "MPICH";
77 end
78 else
79 % On Windows (and perhaps other OS), calling ``system("mpiexec --version")``
80 % can fail because ``mpiexec`` can refer to the MATLAB copy of mpiexec binary.
81 % Unknown option: -version
82 % Error: no executable specified
83 % Unable to parse the mpiexec command arguments.
84 % To bypass this failure, we check if ``cpuinfo`` exists in the same path as ``mpiexec``.
85 % If so, then the mpiexec binary belongs to Intel MPI library.
86 [dirname, filename, extname] = fileparts(path);
87 if filename == "mpiexec"
88 cipath = fullfile(dirname, "cpuinfo" + extname);
89 if isfile(cipath)
90 name = "Intel";
91 elseif ispc() && extname ~= ".exe"
92 cipath = fullfile(dirname, "cpuinfo.exe");
93 if isfile(cipath)
94 name = "Intel";
95 end
96 end
97 end
98 end
99 end
100end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function vendor(in name)
Return the MPI library vendor name from the input MPI name based on the internal ParaMonte shared lib...
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 field, in exclude)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...
function hydra()
Return the MPI image count and the current image ID (e.g., MPI rank + 1) if the application has been ...
function lin()
Return true if the current OS is Linux.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...