ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
verify.m
Go to the documentation of this file.
1%> \brief
2%> Verify the existence of ParaMonte-compatible
3%> MPI library installations on the current system
4%> using a brute-force system path search.<br>
5%>
6%> \details
7%> Because of the intensive nature of the search,
8%> this algorithm may take some time to accomplish
9%> the task on some platforms with large file systems.<br>
10%>
11%> The installation detection is performed by searching for
12%> available `mpiexec` MPI-launcher binaries for different
13%> MPI library installations.<br>
14%>
15%> \param[in] vendor : The input scalar or vector MATLAB string, containing the
16%> MPI library vendor supported by the ParaMonte library.<br>
17%> Possible values are:<br>
18%> <ol>
19%> <li> ``OpenMPI``, representing the OpenMPI library.<br>
20%> <li> ``MPICH``, representing the MPICH MPI library.<br>
21%> <li> ``Intel``, representing the Intel MPI library.<br>
22%> <li> ``all``, representing all available MPI library.<br>
23%> Specifying this value can lead to a comprehensive
24%> search for all available ParaMonte-compatible
25%> MPI installations on the system, which may
26%> time-consuming on some platforms.<br>
27%> This comprehensive system-level search
28%> only if the initial shallow search for
29%> the ParaMonte-compatible MPI library
30%> installations fails.<br>
31%> </ol>
32%> Note that **all values are case-insensitive**.<br>
33%> (**optional, default = ``"all"``.)
34%>
35%> \return
36%> ``failed`` : The output scalar MATLAB ``logical`` that is ``true``
37%> if and only if the ``mpiexec`` verification fails.<br>
38%>
39%> \interface{verify}
40%> \code{.m}
41%>
42%> failed = pm.sys.path.mpiexec.verify()
43%> failed = pm.sys.path.mpiexec.verify(vendor)
44%>
45%> \endcode
46%>
47%> \warning
48%> This function has side-effects by printing messages on screen.<br>
49%>
50%> \example{verify}
51%> \include{lineno} example/sys/path/mpiexec/verify/main.m
52%> \output{verify}
53%> \include{lineno} example/sys/path/mpiexec/verify/main.out.m
54%>
55%> \final{verify}
56%>
57%> \author
58%> \AmirShahmoradi, 11:51 PM Monday, November 11, 2024, Dallas, TX<br>
59function failed = verify(vendor)
60
61 failed = false;
62
63 if nargin < 1
64 vendor = [];
65 end
66
67 if isempty(vendor)
68 vendor = "";
69 end
70
71 if pm.array.len(vendor) == 0 || strcmpi(vendor, "any") || strcmpi(vendor, "all")
72 mpiVendorList = ["Intel", "MPICH", "OpenMPI"];
73 else
74 mpiVendorList = [string(vendor)];
75 end
76
77 %%%%
78 %%%% Perform a brute-force search for MPI installations.
79 %%%%
80
81 mpiexecFound = false;
82 mpiVendorList = ["Intel", "MPICH", "OpenMPI"];
83 for mpiVendor = mpiVendorList
84 mpiVendorLower = lower(mpiVendor);
85 disp("Checking for the " + mpiVendor + " MPI library installations. This may take a bit...")
86 mpiPathList = pm.sys.path.mpiexec.find(mpiVendorLower);
87 if isempty(mpiPathList)
88 disp(pm.io.tab + "None detected.")
89 else
90 mpiexecFound = true;
91 disp(pm.io.tab + "The following " + mpiVendor + " ``mpiexec`` binaries were detected:")
92 for ipath = 1 : length(mpiPathList)
93 disp(pm.io.tab + pm.io.tab + mpiPathList(ipath))
94 end
95 end
96 end
97
98 if mpiexecFound
99 disp( newline ...
100 + "At least one MPI runtime library installation from vendors " + newline ...
101 + "compatible with the ParaMonte library exists on your system." + newline ...
102 );
103 else
104 disp( newline ...
105 + "No MPI runtime libraries were detected on your system." + newline ...
106 + "Even if you believe there is any, it is invisible to runtime shell." + newline ...
107 );
108 failed = pm.lib.mpi.install();
109 end
110
111 if ~failed
112 msgfile = fullfile(pm.lib.path.auxil(), ".mpi.run.msg");
113 try
114 fprintf('%s\n\n', strrep(fileread(msgfile), char(13), ''));
115 catch me
116 failed = true;
117 weblinks = pm.lib.weblinks();
118 warning ( newline ...
119 + string(me.identifier) + " : " + string(me.message) + newline ...
120 + "Failed to read the contents of the following file:" + newline ...
121 + newline ...
122 + pm.io.tab + """" + msgfile + """" + newline ...
123 + newline ...
124 + "The ParaMonte MATLAB library integrity appears compromised." + newline ...
125 + "You can download the latest version of the library from: " + newline ...
126 + newline ...
127 + pm.io.tab + pm.web.href(weblinks.github.releases.url) + newline ...
128 + newline ...
129 );
130 end
131 end
132
133end
function verify(in varval, in vartype, in varsize, in varname)
Verify the type and number of elements of the input varval match the specified input vartype and vars...
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 auxil()
Return a scalar MATLAB string containing the path to the auxil directory of the ParaMonte library pac...
function find(in vendor)
Return a list of scalar MATLAB strings containing the paths to all detected mpiexec binaries installe...
function href(in url)
Return an HTML-style decoration of the input URL if the ParaMonte MATLAB library is used in GUI,...
function install(in vendor, in isyes)
Install or provide instructions to install the MPI library from the requested input MPI vendor.
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function tab()
Return a scalar MATLAB string containing 4 blank characters equivalent to a tab character.
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...