-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path02-repo-structure.tex
365 lines (316 loc) · 11.5 KB
/
02-repo-structure.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
\documentclass{beamer}
% Theme choice
\usetheme{Madrid}
% Optional packages
\usepackage{graphicx} % For including images
\usepackage{amsmath} % For math symbols and formulas
\usepackage{hyperref} % For hyperlinks
\usepackage{listings}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage[T1]{fontenc}
\lstdefinestyle{CStyle}{
language=C, % Set the language to C
basicstyle=\ttfamily\footnotesize\linespread{0.9}\tiny, % Set font style and size
keywordstyle=\color{blue}, % Color of keywords
commentstyle=\color{gray}, % Color of comments
stringstyle=\color{red}, % Color of strings
showstringspaces=false, % Do not mark spaces in strings
breaklines=true, % Enable line breaks at appropriate places
breakatwhitespace=false, % Break lines at any character, not just whitespace
numbers=left, % Show line numbers on the left
numberstyle=\tiny\color{gray}, % Style for line numbers
tabsize=4, % Set tab width
keepspaces=true, % Keep indentation spaces
frame=single, % Add a border around the code
aboveskip=0pt, % Reduce space above the code block
belowskip=0pt, % Reduce space below the code block
xleftmargin=7.5pt, % Add left padding (approx. 2.8mm or 10px)
xrightmargin=15pt, % Add left padding (approx. 2.8mm or 10px)
}
% Title, author, date, and institute (optional)
\title[Parallel Programming. Repository structure]{Parallel Programming course. Repository structure}
\author{Obolenskiy Arseniy, Nesterov Alexander}
\institute{Nizhny Novgorod State University}
\date{\today} % or \date{Month Day, Year}
% Redefine the footline to display both the short title and the university name
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.45\paperwidth,ht=2.5ex,dp=1ex,leftskip=1em,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortinstitute % Displays the university name
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.45\paperwidth,ht=2.5ex,dp=1ex,leftskip=1em,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshorttitle % Displays the short title
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.1\paperwidth,ht=2.5ex,dp=1ex,rightskip=1em,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertframenumber{} / \inserttotalframenumber
\end{beamercolorbox}}%
\vskip0pt%
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{Contents}
\tableofcontents
\end{frame}
\section{The introduction to the repository}
\begin{frame}[fragile]{Parallel programming technologies}
\begin{itemize}
\item \textbf{MPI}
\item OpenMP
\item TBB
\item std::thread
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Step-by-step guide to build the project}
\begin{itemize}
\item Download all submodules
\item Set up your environment
\item Build the project with CMake
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Download all submodules \& Set up your environment}
\lstset{style=CStyle, caption=Git submodules}
\begin{lstlisting}
git submodule update --init --recursive
\end{lstlisting}
\lstset{style=CStyle, caption=Download MPI}
\begin{lstlisting}
// Windows
msmpisdk.msi & msmpisetup.exe
// Linux (gcc and clang)
sudo apt install -y mpich openmpi-bin libopenmpi-dev
// MacOS (apple clang)
brew install open-mpi
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Build the project with help CMake}
\lstset{style=CStyle, caption=Configure the build}
\begin{lstlisting}
cmake -S <source code/path to CMakeLists.txt> \
-B <build directory> \
-D USE_SEQ=ON \
-D USE_MPI=ON \
-D USE_FUNC_TESTS=ON \
-D USE_PERF_TESTS=ON \
-D CMAKE_BUILD_TYPE=Release ..
\end{lstlisting}
\lstset{style=CStyle, caption=Build the project}
\begin{lstlisting}
cmake --build <build directory> \
--config Release \
--parallel
\end{lstlisting}
\end{frame}
\section{How to submit your work}
\begin{frame}[fragile]{Directories}
\begin{table}[h!]
\resizebox{8cm}{!} {
\begin{tabular}{| p{4.2 cm} | p{4.2 cm} |}
\hline
\textbf{Directory} & \textbf{What is it?} \\
\hline
\textbf{.github/workflows} & CI \\
\hline
\textbf{1stsamples} & Simple examples \\
\hline
\textbf{3rdparty} & Auxiliary libraries \\
\hline
\textbf{cmake} & CMake scripts \\
\hline
\textbf{modules} & API source code \\
\hline
\textbf{scripts} & Auxiliary scripts \\
\hline
\textbf{tasks} & Students tasks \\
\hline
\end{tabular}
}
\caption{Root directories}
\end{table}
\begin{table}[h!]
\resizebox{8cm}{!} {
\begin{tabular}{| p{4.2 cm} | p{4.2 cm} |}
\hline
\textbf{Directory} & \textbf{What is it?} \\
\hline
\textbf{mpi} & MPI \\
\hline
\textbf{omp} & OpenMP \\
\hline
\textbf{seq} & Sequential \\
\hline
\textbf{stl} & std:thread \\
\hline
\textbf{tbb} & Threading Building Blocks \\
\hline
\end{tabular}
}
\caption{Tasks directories}
\end{table}
\end{frame}
\begin{frame}[fragile]{Directories}
\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\node (n1) at (1,10) {PPC};
\node (n2) at (3,8) {tasks};
\node (n3) at (5,6) {mpi};
\node (n4) at (9,11) {src};
\node (n5) at (9,9.5) {include};
\node (n6) at (9,7) {func\_tests};
\node (n7) at (9,4) {perf\_tests};
\foreach \from/\to in {n1/n2,n2/n3,n3/n4,n3/n5,n3/n6,n3/n7}
\draw (\from) -- (\to);
\end{tikzpicture}
\end{frame}
\section{API of the course's repository}
\begin{frame}[fragile]{Task's prototype}
\lstset{style=CStyle, caption=include/ops\_seq.hpp}
\begin{lstlisting}
class TestTaskSequential : public ppc::core::Task {
public:
explicit TestTaskSequential(std::shared_ptr<ppc::core::TaskData> taskData_) : Task(std::move(taskData_)) {}
bool pre_processing() override;
bool validation() override;
bool run() override;
bool post_processing() override;
private:
int input_{}, res{};
};
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Task's source code}
\lstset{style=CStyle, caption=src/ops\_seq.cpp | pre\_processing}
\begin{lstlisting}
bool nesterov_a_test_task_seq::TestTaskSequential::pre_processing() {
internal_order_test();
// Init value for input and output
input_ = reinterpret_cast<int*>(taskData->inputs[0])[0];
res = 0;
return true;
}
\end{lstlisting}
\lstset{style=CStyle, caption=src/ops\_seq.cpp | validation}
\begin{lstlisting}
bool nesterov_a_test_task_seq::TestTaskSequential::validation() {
internal_order_test();
// Check count elements of output
return taskData->inputs_count[0] == 1 && taskData->outputs_count[0] == 1;
}
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Task's source code}
\lstset{style=CStyle, caption=src/ops\_seq.cpp | run}
\begin{lstlisting}
bool nesterov_a_test_task_seq::TestTaskSequential::run() {
internal_order_test();
for (int i = 0; i < input_; i++) {
res++;
}
return true;
}
\end{lstlisting}
\lstset{style=CStyle, caption=src/ops\_seq.cpp | post\_processing}
\begin{lstlisting}
bool nesterov_a_test_task_seq::TestTaskSequential::post_processing() {
internal_order_test();
reinterpret_cast<int*>(taskData->outputs[0])[0] = res;
return true;
}
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Task's functional tests}
\lstset{style=CStyle, caption=func\_tests/main.cpp}
\begin{lstlisting}
TEST(Sequential, Test_Sum_10) {
const int count = 10;
// Create data
std::vector<int> in(1, count);
std::vector<int> out(1, 0);
// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
taskDataSeq->inputs_count.emplace_back(in.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
taskDataSeq->outputs_count.emplace_back(out.size());
// Create Task
nesterov_a_test_task_seq::TestTaskSequential testTaskSequential(taskDataSeq);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();
ASSERT_EQ(count, out[0]);
}
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{TaskData structure}
\lstset{style=CStyle, caption=TaskData}
\begin{lstlisting}
struct TaskData {
std::vector<uint8_t *> inputs;
std::vector<std::uint32_t> inputs_count;
std::vector<uint8_t *> outputs;
std::vector<std::uint32_t> outputs_count;
enum StateOfTesting { FUNC, PERF } state_of_testing;
};
\end{lstlisting}
\lstset{style=CStyle, caption=Functions order}
\begin{lstlisting}
std::vector<std::string> right_functions_order =
{"validation",
"pre_processing",
"run",
"post_processing"};
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Task's performance tests - part 1}
\lstset{style=CStyle, caption=perf\_tests/main.cpp}
\begin{lstlisting}
TEST(sequential_example_perf_test, test_pipeline_run) {
const int count = 100;
// Create data
std::vector<int> in(1, count);
std::vector<int> out(1, 0);
// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
taskDataSeq->inputs_count.emplace_back(in.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
taskDataSeq->outputs_count.emplace_back(out.size());
// Create Task
auto testTaskSequential = std::make_shared<nesterov_a_test_task_seq::TestTaskSequential>(taskDataSeq);
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Task's performance tests - part 2}
\lstset{style=CStyle, caption=perf\_tests/main.cpp}
\begin{lstlisting}
// Create Perf attributes
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
perfAttr->num_running = 10;
const auto t0 = std::chrono::high_resolution_clock::now();
perfAttr->current_timer = [&] {
auto current_time_point = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(current_time_point - t0).count();
return static_cast<double>(duration) * 1e-9;
};
// Create and init perf results
auto perfResults = std::make_shared<ppc::core::PerfResults>();
// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(testTaskSequential);
perfAnalyzer->pipeline_run(perfAttr, perfResults);
ppc::core::Perf::print_perf_statistic(perfResults);
ASSERT_EQ(count, out[0]);
}
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]{Practice}
Practice
\end{frame}
\begin{frame}{References}
\begin{itemize}
\item PPC Repository \href{https://github.com/learning-process/parallel\_programming\_course}{https://github.com/learning-process/parallel\_programming\_course}
\end{itemize}
\end{frame}
\end{document}