diff --git a/02-repo-structure/02-repo-structure.tex b/02-repo-structure/02-repo-structure.tex index a4b0b36..bff4511 100644 --- a/02-repo-structure/02-repo-structure.tex +++ b/02-repo-structure/02-repo-structure.tex @@ -83,289 +83,56 @@ \section{The introduction to the repository} \end{itemize} \end{frame} -\begin{frame}[fragile]{Step-by-step guide to build the project} +\begin{frame}{Documentation} + Follow the documentation for detailed instructions and examples: \begin{itemize} - \item Download all submodules - \item Set up your environment - \item Build the project with CMake + \item EN: \href{https://learning-process.github.io/parallel\_programming\_course/en/}{https://learning-process.github.io/parallel\_programming\_course/en/} + \item RU: \href{https://learning-process.github.io/parallel\_programming\_course/ru/}{https://learning-process.github.io/parallel\_programming\_course/ru/} \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 \ - -B \ - -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 \ - --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 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(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(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 in(1, count); - std::vector out(1, 0); - - // Create TaskData - std::shared_ptr taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(in.data())); - taskDataSeq->inputs_count.emplace_back(in.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(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 inputs; - std::vector inputs_count; - std::vector outputs; - std::vector outputs_count; - enum StateOfTesting { FUNC, PERF } state_of_testing; - }; - \end{lstlisting} - \lstset{style=CStyle, caption=Functions order} - \begin{lstlisting} - std::vector 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 in(1, count); - std::vector out(1, 0); - - // Create TaskData - std::shared_ptr taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(in.data())); - taskDataSeq->inputs_count.emplace_back(in.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(out.data())); - taskDataSeq->outputs_count.emplace_back(out.size()); - - // Create Task - auto testTaskSequential = std::make_shared(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(); - 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(current_time_point - t0).count(); - return static_cast(duration) * 1e-9; - }; - - // Create and init perf results - auto perfResults = std::make_shared(); - - // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskSequential); - perfAnalyzer->pipeline_run(perfAttr, perfResults); - ppc::core::Perf::print_perf_statistic(perfResults); - ASSERT_EQ(count, out[0]); - } - \end{lstlisting} +\begin{frame}[fragile]{Local Setup and Build} + \begin{itemize} + \item Dev Container (recommended): VS Code + Docker + Dev Containers extension + \item Manual prerequisites: Install CMake; install MPI/OpenMP per OS (see docs) + \item Download submodules: \\ + \verb|git submodule update --init --recursive --depth=1| + \item Configure build: \\ + \verb|mkdir build && cd build| \\[-2pt] + \verb|cmake -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=Release ..| + \item Build: \\ + \verb|cmake --build . --config Release --parallel| + \end{itemize} \end{frame} -\begin{frame}[fragile]{Practice} - Practice +\begin{frame}[fragile]{Docker and Dev Container} + You may use Docker container for the convenience of development. + \begin{itemize} + \item VS Code flow (recommended): + \begin{itemize} + \item Open the repo in VS Code, install Dev Containers extension + \item Use: \verb|Dev Containers: Reopen in Container| + \item VS Code builds a container with GCC, CMake, MPI, OpenMP, tools + \end{itemize} + \item Prebuilt image (in case you do not use dev container or VS Code): + \begin{itemize} + \item Pull: \verb|docker pull ghcr.io/learning-process/ppc-ubuntu:1.1| + \item Run: \verb|docker run -it ghcr.io/learning-process/ppc-ubuntu:1.1| + \end{itemize} + \item Build locally (Dockerfile: \texttt{docker/ubuntu.Dockerfile}): + \begin{itemize} + \item Build: \verb|docker build -f docker/ubuntu.Dockerfile -t ppc-dev .| + \item Run: \verb|docker run -it ppc-dev| + \item Mount repo (optional): \verb|-v "$(pwd)":/work -w /work| + \end{itemize} + \end{itemize} \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} + \item PPC Docker image \href{https://github.com/orgs/learning-process/packages/container/package/ppc-ubuntu}{https://github.com/orgs/learning-process/packages/container/package/ppc-ubuntu} + \item VS Code Dev Containers Extension \href{https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers}{https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers} \end{itemize} \end{frame} diff --git a/02-repo-structure/02-repo-structure.toc b/02-repo-structure/02-repo-structure.toc index c99d34b..6ef466e 100644 --- a/02-repo-structure/02-repo-structure.toc +++ b/02-repo-structure/02-repo-structure.toc @@ -1,3 +1 @@ \beamer@sectionintoc {1}{The introduction to the repository}{3}{0}{1} -\beamer@sectionintoc {2}{How to submit your work}{8}{0}{2} -\beamer@sectionintoc {3}{API of the course's repository}{11}{0}{3}