-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlecture19.tex
382 lines (283 loc) · 9.02 KB
/
lecture19.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
%Template
%Copyright (C) 2019 Patrick Diehl
%
%This program is free software: you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation, either version 3 of the License, or
%(at your option) any later version.
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%You should have received a copy of the GNU General Public License
%along with this program. If not, see <http://www.gnu.org/licenses/>.
\providecommand\classoption{12pt}
\documentclass[\classoption]{beamer}
\input{./template/packages}
\input{template/variables.tex}
% frame slide
\title{\coursename}
\subtitle{Lecture 19: Distributed implementation of the heat equation II}
\author{\tiny Patrick Diehl \orcid{0000-0003-3922-8419}}
%\institute {
% \href{}{\tt \scriptsize \today}
%}
\date {
\tiny \url{\courseurl}
\vspace{2cm}
\doclicenseThis
}
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\setmainfont{Raleway}
\fi
\ifluatex
\usepackage{fontspec}
\setmainfont{Raleway}
\fi
\usepackage{pgfplots}
\begin{document} {
\setbeamertemplate{footline}{}
\frame {
\titlepage
}
}
\frame{
\tableofcontents
}
\AtBeginSection[]{
\begin{frame}
\vfill
\centering
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
\usebeamerfont{title}\insertsectionhead\par%
\end{beamercolorbox}
\vfill
\end{frame}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Reminder}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Lecture 18}
\begin{block}{What you should know from last lecture}
\begin{itemize}
\item How to compile HPX using networking
\item Receiving topology information
\end{itemize}
\end{block}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Improving sending data}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Exchanging boundary data}
\begin{center}
\begin{tikzpicture}
\foreach \i in {1,...,9}{
\node at (\i,0) {\pgfuseplotmark{square*}};
}
\foreach \i in {1,...,9}{
\node[below] at (\i,-0.1) {$x_\i$};
}
\foreach \i in {4,...,6}{
\node at (\i,1.75) {\pgfuseplotmark{square*}};
}
\draw (3.8,1.) rectangle ++(2.4,1.5) node {};
\draw (0.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (3.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (6.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (4,1.75) -- (3,0);
\draw (4,1.75) -- (4,0);
\draw (4,1.75) -- (5,0);
\draw (6,1.75) -- (5,0);
\draw (6,1.75) -- (6,0);
\draw (6,1.75) -- (7,0);
\node[below] at (0,0) {\small $t=0$};
\node[below] at (0,1.75) {\small $t=1$};
\end{tikzpicture}
\end{center}
In the previous example we exchanged the whole left and right partition to update the temperatures of the partition in the middle. However, we only need one value of the neighboring partitions to update the temperature for $x_4$ and $x_6$.
\end{frame}
\begin{frame}[fragile]{Updating the partition I }
\begin{lstlisting}
// Create a partition only having the left or
// right boundary element
partition_data(partition_data const& base,
std::size_t min_index)
: data_(base.data_.data()+min_index, 1,
buffer_type::reference),
size_(base.size()),
min_index_(min_index)
{
HPX_ASSERT(min_index < base.size());
}
double& operator[](std::size_t idx) {
return data_[index(idx)]; }
double operator[](std::size_t idx) const {
return data_[index(idx)]; }
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Updating the partition II }
\begin{lstlisting}
private:
std::size_t index(std::size_t idx) const
{
HPX_ASSERT(idx >= min_index_ && idx < size_);
return idx - min_index_;
}
\end{lstlisting}
\vspace{1cm}
Now, we have to make use of sending smaller partitions to the node containing the middle partitions. We will use the previously introduced partition type.
\end{frame}
\begin{frame}[fragile]{Updating the partition server}
\begin{lstlisting}
partition_data get_data(partition_type t) const
{
switch (t)
{
case left_partition: // Last element
return partition_data(data_, data_.size()-1);
case middle_partition:
break;
case right_partition: // First element
return partition_data(data_, 0);
default:
HPX_ASSERT(false);
break;
}
return data_;
}
\end{lstlisting}
\end{frame}
\begin{frame}{Improve the computation of the middle partition}
\begin{center}
\begin{tikzpicture}
\foreach \i in {1,...,9}{
\node at (\i,0) {\pgfuseplotmark{square*}};
}
\foreach \i in {1,...,9}{
\node[below] at (\i,-0.1) {$x_\i$};
}
\foreach \i in {4,...,6}{
\node at (\i,1.75) {\pgfuseplotmark{square*}};
}
\draw (3.8,1.) rectangle ++(2.4,1.5) node {};
\draw (0.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (3.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (6.8,-0.75) rectangle ++(2.4,1.5) node {};
\draw (5,1.75) -- (4,0);
\draw (5,1.75) -- (5,0);
\draw (5,1.75) -- (6,0);
\node[below] at (0,0) {\small $t=0$};
\node[below] at (0,1.75) {\small $t=1$};
\end{tikzpicture}
\end{center}
We only need the left and right partition to compute the updated temperature $x_4$ and $x_6$, but we can compute the temperature for $x_5$ without having the partitions Thus, we could update the values in the mid of the partition, while waiting to receive the partitions.
\end{frame}
\begin{frame}[fragile]{Update the stepper: Compute local}
\begin{lstlisting}
hpx::shared_future<partition_data> middle_data =
middle.get_data(partition_server::middle_partition);
hpx::future<partition_data> next_middle =
middle_data.then(
unwrapping(
[middle](partition_data const& m) -> partition_data
{
HPX_UNUSED(middle);
// All local operations are performed once the
// middle data of the previous time step becomes
// available.
std::size_t size = m.size();
partition_data next(size);
for (std::size_t i = 1; i != size-1; ++i)
next[i] = heat(m[i-1], m[i], m[i+1]);
return next;
}));
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Update the stepper: Compute the boundary values}
\begin{lstlisting}
return dataflow(
hpx::launch::async,
unwrapping(
[left, middle, right](partition_data next,
partition_data const& l,
partition_data const& m,
partition_data const& r) -> partition
{
HPX_UNUSED(left);
HPX_UNUSED(right);
// Calculate the missing boundary elements once the
// corresponding data has become available.
std::size_t size = m.size();
next[0] = heat(l[size-1], m[0], m[1]);
next[size-1] = heat(m[size-2],
m[size-1], r[0]);
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Update the stepper: Compute the boundary values}
\begin{lstlisting}
// The new partition_data will be allocated on the
// same locality as 'middle'.
return partition(middle.get_id(), next);
}),
std::move(next_middle),
left.get_data(
partition_server::left_partition),
middle_data,
right.get_data(
partition_server::right_partition)
);
}
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Scaling results}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Configuration file}
\begin{lstlisting}[language=bash]
#!/usr/bin/env bash
#SBATCH -o hostname_%j.out
#SBATCH -t 00:25:00
#SBATCH -p medusa
#SBATCH -D /home/pdiehl/Compile/hpx-1.3.0/build/bin/
export LD_LIBRARY_PATH
=$LD_LIBRARY_PATH:
/home/pdiehl/Compile/hpx-1.3.0/build/lib
module load gcc/8.2.0 boost/1.69.0-gcc8.2.0-release
mpi/openmpi-x86_64
srun 1d_stencil_7 --nx=1000000 --np=10
\end{lstlisting}
\begin{block}{Running}
\lstinline| sbatch -N 1,2,3,4,5 stencil.sbatch|
\end{block}
\end{frame}
\begin{frame}{Distributed scaling}
\begin{center}
\begin{tikzpicture}
\mode<beamer>{
\begin{axis}[xlabel=Localities,ylabel=Execution time, grid=both,title= Stencil 2,legend pos=north west,legend style = {text=white,fill=background,draw=background}]
\addplot[azure] table [x=Localities, y=Execution_Time_sec, col sep=comma] {./data/stencil_7.dat};
\end{axis}
}
\mode<handout>{
\selectcolormodel{gray}
\begin{axis}[xlabel=Localities,ylabel=Execution time, grid=both,title=Stencil 7,legend style={at={(0.5,0.5)},anchor=west}]
\addplot table [x=Localities, y=Execution_Time_sec, col sep=comma] {./data/stencil_7.dat};
\end{axis}
}
\end{tikzpicture}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Summary}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Summary}
\begin{block}{After this lecture, you should know}
\begin{itemize}
\item Running distributed HPX applications
\item Using the slurm environment and modules on clusters
\end{itemize}
\end{block}
\end{frame}
\end{document}