|
1 | 1 |
|
| 2 | + |
| 3 | +# Mastering parallel programming |
| 4 | +The following parallel programming technologies are considered in practice: |
| 5 | +* `MPI` |
| 6 | +* `OpenMP` |
| 7 | +* `TBB` |
| 8 | + |
| 9 | +## Rules for submissions |
| 10 | +1. You are not supposed to trigger CI jobs by frequent updates of your pull request. First you should test you work locally with all the scripts (code style) |
| 11 | + * Respect others time and don't slow down the job queue |
| 12 | +2. Carefully check if the program can hang |
| 13 | + |
| 14 | +## 1. Set up your environment |
| 15 | +### Fetch submodules before building the project |
| 16 | +``` |
| 17 | +git submodule update --init --recursive |
| 18 | +``` |
| 19 | +### `MPI` |
| 20 | + * **Windows (MSVC)**: |
| 21 | + [Installers link.](https://www.microsoft.com/en-us/download/details.aspx?id=57467) You have to install `msmpisdk.msi` and `msmpisetup.exe`. |
| 22 | + * **Linux (`gcc` and `clang`)**: |
| 23 | + ``` |
| 24 | + sudo apt install mpich |
| 25 | + sudo apt install openmpi-bin |
| 26 | + sudo apt install libopenmpi-dev |
| 27 | + ``` |
| 28 | + * **MacOS (apple clang)**: |
| 29 | + ``` |
| 30 | + brew install open-mpi |
| 31 | + ``` |
| 32 | + |
| 33 | +### `OpenMP` |
| 34 | + `OpenMP` is included into `gcc` and `msvc`, but some components should be installed additionally: |
| 35 | + * **Linux (`gcc` and `clang`)**: |
| 36 | + ``` |
| 37 | + sudo apt install libomp-dev |
| 38 | + ``` |
| 39 | + * **MacOS (apple clang)**: The system is completely unstable thus you are not recommended to use it with `OpenMP`! |
| 40 | + ``` |
| 41 | + brew install libomp |
2 | 42 | ```
|
3 |
| - mkdir build |
4 |
| - cd build |
| 43 | + |
| 44 | +### `TBB` |
| 45 | + * **Windows (`MSVC`)**: `CMake` installs `TBB` while you run `cmake` for that project on Windows. |
| 46 | + * **Linux (`gcc` and `clang`)**: |
| 47 | + ``` |
| 48 | + sudo apt-get install libtbb-dev |
| 49 | + ``` |
| 50 | + * **MacOS (apple clang)**: |
| 51 | + ``` |
| 52 | + brew install tbb |
| 53 | + ``` |
| 54 | + |
| 55 | +## 2. Build the project with `CMake` |
| 56 | +Navigate to a source code folder. |
| 57 | + |
| 58 | +1) Configure the build: `Makefile`, `.sln`, etc. |
| 59 | + |
| 60 | + ``` |
| 61 | + mkdir build && cd build |
5 | 62 | cmake -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON ..
|
6 |
| - cd .. |
7 | 63 | ```
|
8 |
| -<i>Комментарий про ключи CMake:</i> |
9 |
| -- `-D USE_MPI=ON` отвечает за сборку зависимостей и проектов свзанных с MPI. |
10 |
| -- `-D USE_OMP=ON` отвечает за сборку зависимостей и проектов свзанных с OpenMP. |
11 |
| -- `-D USE_TBB=ON` отвечает за сборку зависимостей и проектов свзанных с TBB. |
| 64 | +*Help on CMake keys:* |
| 65 | +- `-D USE_MPI=ON` enbale `MPI` labs. |
| 66 | +- `-D USE_OMP=ON` enable `OpenMP` labs. |
| 67 | +- `-D USE_TBB=ON` enable `TBB` labs. |
12 | 68 |
|
13 |
| -<i>Соотвественно, если что-то не потребуется, то флаг можно не указывать.</i> |
| 69 | +*A corresponding flag can be omitted if it's not needed.* |
14 | 70 |
|
15 |
| -2) Собираем проект: |
| 71 | +2) Build the project: |
16 | 72 | ```
|
17 |
| - cmake --build build --config RELEASE |
| 73 | + cmake --build . --config RELEASE |
18 | 74 | ```
|
19 |
| -3) Находим и запускаем исполняемый файл в директории `<наш проект>/build/bin` |
| 75 | +3) Run `<project's folder>/build/bin` |
20 | 76 |
|
21 |
| -## 3. Инструкция по размещению своих исходных кодов в проекте |
22 |
| -* В директории `modules` есть папки с задачами: `task_1`, `task_2`, `task_3`. |
23 |
| -Находим директорию соотвествующую вашей задаче и переходим в нее. Создаем папку с названием `<фамилия>_<инициал имени>_<краткое название задачи>`. К примеру: `task1/nesterov_a_vector_sum`. |
24 |
| -* Теперь переходим в созданную нами директорию и начинаем работу над задачей. В данной директории должны быть всего 4 файла и все (кроме `CMakeLists.txt`) написанные вами: |
25 |
| - - `main.cpp` - google тесты для вашей задачи, количество тестов должно быть 5 или больше. |
26 |
| - - `vector_sum.h` - заголовочный файл с прототипами функций вашей задачи, название файла такое же, как и `<краткое название задачи>`. |
27 |
| - - `vector_sum.cpp` - исходные коды реализации функций вашей задачи, название файла такое же, как и `<краткое название задачи>`. |
28 |
| - - `CMakeLists.txt` - конфигурация вашего проекта. Пример для каждой конфигурации находятся в директории `test_tasks`. |
29 |
| -* Название pull-request'а выглядит следующим образом: |
| 77 | +## 3. How to submit you work |
| 78 | +* There are `task_1`, `task_2`, `task_3` folders in `modules` directory. There are 3 task for the semester. Move to a folder of your task. Make a directory named `<last name>_<first letter of name>_<short task name>`. Example: `task1/nesterov_a_vector_sum`. |
| 79 | +* Go into the newly created folder and begin you work on the task. There must be only 4 files and 3 of them must be written by you: |
| 80 | + - `main.cpp` - google tests for the task. The number of tests must be 4 or greater. |
| 81 | + - `vector_sum.h` - a header file with function prototypes, name it in the same way as `<short task name>`. |
| 82 | + - `vector_sum.cpp` - the task implementation, name it in the same way as `<short task name>`. |
| 83 | + - `CMakeLists.txt` - a file to configure your project. Examples for each configuration can be found in `test_tasks`. |
| 84 | +* Name your pull request in the following way: |
30 | 85 | ```
|
31 |
| - <Фамилия Имя>. Задача <Номер задачи (Их 3 в этом семестре)>. <Полное название задачи>. |
32 |
| - Нестеров Александр. Задач 1. Сумма элементов вектора. |
| 86 | + <Фамилия Имя>. Задача <Номер задачи>. <Полное название задачи>. |
| 87 | + Нестеров Александр. Задача 1. Сумма элементов вектора. |
33 | 88 | ```
|
34 |
| -* В описание pull-request'а пишем полную постановку задачи. |
| 89 | +* Provide the full task definition in pull request's description. |
35 | 90 |
|
36 |
| - Пример pull-request'а находится в pull-request'ах проекта. |
| 91 | + Example pull request is located in repo's pull requests. |
37 | 92 |
|
38 |
| -* Работаем со своим fork-репозитроием. Работаем в отдельной ветке и <b>НЕ в `master`!!!</b> Название ветки аналогично названию директории для вашей задачи. К примеру создание ветки: |
| 93 | +* Work on your fork-repository. Keep your work on a separate branch and **NOT on `master`!!!**. Name you branch in the same way as your task's folder. To create a branch run: |
39 | 94 | ```
|
40 | 95 | git checkout -b nesterov_a_vector_sum
|
41 | 96 | ```
|
42 | 97 |
|
43 |
| -## 4. Инстркция по размещению отчетов в проекте |
| 98 | +## 4. How to submit your report to the project |
44 | 99 |
|
45 |
| -* В директории `reports` размещаем <b>pdf-файл</b> с отчетом. |
46 |
| -Отчет должен называться следующим образом - `<фамилия>_<инициал имени>_<краткое название задачи>.pdf` |
| 100 | +* Place `<last name>_<first letter of name>_<short task name>.pdf` containing the report in [the `reports` folder](reports). |
47 | 101 |
|
48 | 102 | ```
|
49 | 103 | nesterov_a_vector_sum.pdf
|
50 | 104 | ```
|
51 |
| -* Название pull-request'а для отчета выглядит следующим образом: |
| 105 | +* Pull request's name for the report looks in the following way: |
52 | 106 | ```
|
53 | 107 | <Фамилия Имя>. Отчет. <Полное название задачи>.
|
54 | 108 | Нестеров Александр. Отчет. Сумма элементов вектора.
|
55 | 109 | ```
|
56 | 110 |
|
57 |
| -## Использование стиля кодирования |
58 |
| -Для проверки стиля кодирования используется Google C++ Style. |
59 |
| -* Описание стиля находится [здесь](https://google.github.io/styleguide/cppguide.html). |
60 |
| -* Проверить стиль можно с помощью скрипта (скрипт работает с 2-ой версией python): |
61 |
| - ``` |
62 |
| - cd <корень исходного проекта> |
63 |
| - python2 scripts/lint.py |
64 |
| - ``` |
65 |
| -<i>Невывполнение правил ведет к покраснению сборки проекта.</i> |
| 111 | +## Code style |
| 112 | +Please, follow [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). |
| 113 | +Code style can be verified with [the script](scripts/lint.py) (it runs with Python 2): |
| 114 | +``` |
| 115 | +cd <source project root> |
| 116 | +python2 scripts/lint.py |
| 117 | +``` |
| 118 | +*Failing to follow the rules makes the project build red.* |
0 commit comments