Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

02 repo structure #23

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
295 changes: 290 additions & 5 deletions 02-repo-structure/02-repo-structure.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
\usepackage{hyperref} % For hyperlinks
\usepackage{listings}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage[T1]{fontenc}

\lstdefinestyle{CStyle}{
Expand Down Expand Up @@ -64,17 +65,301 @@
\tableofcontents
\end{frame}

\section{Introduction}
\section{The introduction to the repository}

\begin{frame}{Slide}
\begin{frame}[fragile]{Parallel programming technologies}
\begin{itemize}
\item \textbf{MPI}
\item OpenMP
\item TBB
\item std::thread
\end{itemize}
\end{frame}

\begin{frame}
\centering
\Huge{Thank You!}
\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}
4 changes: 3 additions & 1 deletion 02-repo-structure/02-repo-structure.toc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
\beamer@sectionintoc {1}{Introduction}{3}{0}{1}
\beamer@sectionintoc {1}{The introduction to the repository}{3}{0}{1}
\beamer@sectionintoc {2}{How to submit your work}{7}{0}{2}
\beamer@sectionintoc {3}{API of the course's repository}{9}{0}{3}
Loading