ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
install.m
Go to the documentation of this file.
1%> \brief
2%> Install or provide instructions to install the MPI
3%> library from the requested input MPI ``vendor``.<br>
4%>
5%> \details
6%> Currently, this function can only install the
7%> Intel MPI runtime libraries on Linux or Windows.<br>
8%> For other MPI vendors, it can only provide installation instructions.<br>
9%>
10%> \param[in] vendor : The input scalar or vector MATLAB string, containing the
11%> MPI library vendor supported by the ParaMonte library.<br>
12%> Possible values are:<br>
13%> <ol>
14%> <li> ``OpenMPI``, representing the OpenMPI library.<br>
15%> <li> ``MPICH``, representing the MPICH MPI library.<br>
16%> <li> ``Intel``, representing the Intel MPI library.<br>
17%> <li> ``all``, representing all available MPI library.<br>
18%> Specifying this value can lead to a comprehensive
19%> search for all available ParaMonte-compatible
20%> MPI installations on the system, which may
21%> time-consuming on some platforms.<br>
22%> This comprehensive system-level search
23%> only if the initial shallow search for
24%> the ParaMonte-compatible MPI library
25%> installations fails.<br>
26%> </ol>
27%> Note that **all values are case-insensitive**.<br>
28%> (**optional, default = ``"Intel"`` on platforms supported by the Intel MPI library, otherwise ``"all"``.)
29%> \param[in] isyes : The input scalar MATLAB ``logical`.<br>
30%> If provided, it will serve as the answer to the question displayed on the prompt by
31%> the function to confirm whether the user wants to install the MPI libraries or not.<br>
32%> This functionality becomes important when interaction with users through the prompt is impossible.<br>
33%> (**optional. If missing, the download question will be shown on the user prompt.)
34%>
35%> \return
36%> ``failed`` : The output scalar MATLAB ``logical`` that is ``true`` if and only if
37%> the MPI library installation or its instruction display fails.<br>
38%>
39%> \interface{install}
40%> \code{.m}
41%>
42%> failed = pm.lib.mpi.install();
43%> failed = pm.lib.mpi.install(vendor);
44%> failed = pm.lib.mpi.install(vendor, []);
45%> failed = pm.lib.mpi.install(vendor, isyes);
46%> failed = pm.lib.mpi.install([], isyes);
47%>
48%> \endcode
49%>
50%> \warning
51%> This function has side-effects by printing messages on screen.<br>
52%>
53%> \example{install}
54%> \include{lineno} example/lib/mpi/install/main.m
55%> \output{install}
56%> \include{lineno} example/lib/mpi/install/main.out.m
57%>
58%> \final{install}
59%>
60%> \author
61%> \AmirShahmoradi, 11:51 PM Monday, November 11, 2024, Dallas, TX<br>
62function failed = install(vendor, isyes)
63
64 failed = false;
65
66 if nargin < 2
67 isyes = [];
68 end
69
70 if nargin < 1
71 vendor = [];
72 end
73
74 if isempty(vendor)
75 vendor = "";
76 end
77
78 if pm.array.len(vendor) == 0 || strcmpi(vendor, "any") || strcmpi(vendor, "all")
79 mpiVendorList = ["Intel", "MPICH", "OpenMPI"];
80 else
81 mpiVendorList = [string(vendor)];
82 end
83
84 weblinks = pm.lib.weblinks();
85
86 %%%%
87 %%%% Read the MPI installation instructions.
88 %%%%
89
90 msgfile = fullfile(pm.lib.path.auxil(), ".mpi.install.msg");
91 try
92 fprintf('%s\n\n', strrep(fileread(msgfile), char(13), ''));
93 catch me
94 failed = true;
95 warning ( newline ...
96 + string(me.identifier) + " : " + string(me.message) + newline ...
97 + "Failed to read the contents of the following file:" + newline ...
98 + newline ...
99 + pm.io.tab + """" + msgfile + """" + newline ...
100 + newline ...
101 + "The ParaMonte MATLAB library integrty appears compromised." + newline ...
102 + "You can download the latest version of the library from: " + newline ...
103 + newline ...
104 + pm.io.tab + pm.web.href(weblinks.github.releases.url) + newline ...
105 + newline ...
106 );
107 end
108
109 %%%%
110 %%%% Install the Intel runtime library if requested.
111 %%%%
112
113 if any(contains(pm.lib.mpi.vendor(mpiVendorList), "Intel")) && ~ismac
114
115 promptmsg = "Would you like to install the Intel MPI runtime libraries on this system now (requires internet access)? (y/n)";
116 if ~isempty(isyes)
117 disp(promptmsg);
118 itis = isyes;
119 else
120 itis = pm.io.isyes(promptmsg);
121 end
122 if itis
123 try
124
125 auxpath = pm.lib.path.auxil()
126 auxfile = fullfile(auxpath, ".deps." + pm.os.namel() + ".mpi.intel");
127 mpifile = strrep(strrep(fileread(auxfile), char(13), ''), char(10), '');
128 binlink = weblinks.github.releases.download.auxil.url + "/" + mpifile;
129 binpath = websave(fullfile(auxpath, mpifile), binlink);
130
131 disp("The binary file is stored at: """ + binpath + """");
132
133 disp("Executing binary file...");
134 disp("Please use the default recommended installation settings if and when prompted.");
135
136 if ispc
137 [failed, cmdout] = system(binpath, "-echo");
138 else
139 [failed, cmdout] = system("chmod +x " + binpath + " && " + binpath, "-echo");
140 end
141 failed = failed ~= 0;
142
143 if failed
144 warning ( newline ...
145 + "Failed to execute the Intel MPI installation binary file." + newline ...
146 + "Here is the terminal output:" + newline ...
147 + newline ...
148 + strjoin(string(cmdout), newline) + newline ...
149 + newline ...
150 + "You can install the MPI library by manually executing the binary located at:" + newline ...
151 + newline ...
152 + pm.io.tab + binpath + newline ...
153 + newline ...
154 + "Skipping the Intel MPI installation..." + newline ...
155 + newline ...
156 );
157 end
158
159 catch me
160
161 failed = true;
162 warning ( newline ...
163 + string(me.identifier) + " : " + string(me.message) + newline ...
164 + "Failed to read the contents of the following file:" + newline ...
165 + newline ...
166 + pm.io.tab + """" + auxfile + """" + newline ...
167 + newline ...
168 + "The ParaMonte MATLAB library integrty appears compromised." + newline ...
169 + "You can download the latest version of the library from: " + newline ...
170 + newline ...
171 + pm.io.tab + pm.web.href(weblinks.github.releases.url) + newline ...
172 + newline ...
173 );
174
175 end
176 end
177
178 end
179
180end
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 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 isyes(in question)
Return a scalar MATLAB logical that is true if the user response to a question on the MATLAB command ...
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function namel()
Return a MATLAB string containing the lower-case name of the current OS.
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...