Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ indent_size = 2
[*.{yml,yaml}]
indent_size = 2

[*.{bat,cmd}]
end_of_line = crlf

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The repository has a tracked Windows batch script with CRLF line endings (scripts/generate_perf_results.bat), while the global EditorConfig rule sets end_of_line = lf for all files. This override resolves that conflict for .bat/.cmd files and keeps Windows scripts in their native line-ending format.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary for this patch? I'd even separate docs part at this point as well


[*.py]
indent_size = 4

Expand Down
51 changes: 51 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,54 @@ function(ppc_configure_subproject SUBDIR)
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
endforeach()
endfunction()

function(ppc_configure_meta_part PROJ_NAME BASE_DIR)
set(TEST_DIR "${BASE_DIR}/tests")
set(TEST_EXECUTABLES "")

add_tests(USE_FUNC_TESTS ${FUNC_TEST_EXEC} functional)
add_tests(USE_PERF_TESTS ${PERF_TEST_EXEC} performance)

message(STATUS " -- ${PROJ_NAME}")

foreach(IMPL IN LISTS PPC_IMPLEMENTATIONS)
setup_implementation(
NAME
${IMPL}
PROJ_NAME
${PROJ_NAME}
TESTS
"${TEST_EXECUTABLES}"
BASE_DIR
"${BASE_DIR}")
endforeach()
endfunction()

function(ppc_configure_meta_project SUBDIR)
add_compile_definitions(
PPC_SETTINGS_${SUBDIR}="${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/settings.json"
PPC_ID_${SUBDIR}="${SUBDIR}")

project(${SUBDIR})
message(STATUS "${SUBDIR}")

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/threads")
ppc_configure_meta_part(${SUBDIR}_threads
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/threads")
endif()

file(
GLOB process_task_dirs
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/processes"
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/processes/*")
list(SORT process_task_dirs)
foreach(PROCESS_TASK IN LISTS process_task_dirs)
if(NOT IS_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/processes/${PROCESS_TASK}")
continue()
endif()
ppc_configure_meta_part(
${SUBDIR}_processes_${PROCESS_TASK}
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/processes/${PROCESS_TASK}")
endforeach()
endfunction()
2 changes: 1 addition & 1 deletion docs/common_information/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Practice
- Task distribution is random for each student.
- Full automation of quality and performance checks; plagiarism checks are applied.
- Deadlines are set per task. See the penalties and grading rules in ``Points``.
- Examples are provided in ``tasks/example_threads`` and ``tasks/example_processes`` (and extended variations ``tasks/example_processes_2`` / ``tasks/example_processes_3``).
- Examples are provided in the unified ``tasks/example`` tree with ``threads`` and ``processes/t1``..``processes/t3`` sections.
Comment thread
allnes marked this conversation as resolved.
Outdated
- In each repository, the README.md contains a link to the course documentation.
- Each repository includes an example of a properly formatted PULL REQUEST.
- Submission of all tasks is mandatory to pass the course.
Expand Down
2 changes: 1 addition & 1 deletion docs/locale/en/LC_MESSAGES/user_guide/build.po

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make sure that all .po files are actually update

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the translation catalogs with sphinx-intl after regenerating gettext catalogs. docs_gettext, docs_update, and docs_html pass locally.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ msgstr ""
#: ../../../../docs/user_guide/build.rst:29
msgid ""
"``-D PPC_TASKS=all`` builds every task (default). Pass one task or a "
"semicolon list, for example ``-D PPC_TASKS=\"example_threads;example_processes\"``, "
"semicolon list, for example ``-D PPC_TASKS=\"example\"``, "
"to limit the build."
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions docs/locale/en/LC_MESSAGES/user_guide/submit_work.po
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ msgstr ""

#: ../../../../docs/user_guide/submit_work.rst:218
msgid ""
"Processes: ``tasks/example_processes``, ``tasks/example_processes_2``, "
"``tasks/example_processes_3``"
"Processes: ``tasks/example/processes/t1``, ``tasks/example/processes/t2``, "
"``tasks/example/processes/t3``"
msgstr ""

#: ../../../../docs/user_guide/submit_work.rst:219
msgid "Threads: ``tasks/example_threads``"
msgid "Threads: ``tasks/example/threads``"
msgstr ""

#: ../../../../docs/user_guide/submit_work.rst:221
Expand Down
8 changes: 4 additions & 4 deletions docs/locale/ru/LC_MESSAGES/common_information/introduction.po
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ msgstr "Дедлайны задаются на каждую задачу. Под

#: ../../../../docs/common_information/introduction.rst:23
msgid ""
"Examples are provided in ``tasks/example_threads`` and "
"``tasks/example_processes`` (and extended variations "
"``tasks/example_processes_2`` / ``tasks/example_processes_3``)."
msgstr "Примеры размещены в ``tasks/example_threads`` и ``tasks/example_processes`` (а также расширенные варианты: ``tasks/example_processes_2`` / ``tasks/example_processes_3``)."
"Examples are provided in ``tasks/example/threads`` and "
"``tasks/example/processes/t1`` (and extended variations "
"``tasks/example/processes/t2`` / ``tasks/example/processes/t3``)."
msgstr "Примеры размещены в ``tasks/example/threads`` и ``tasks/example/processes/t1`` (а также расширенные варианты: ``tasks/example/processes/t2`` / ``tasks/example/processes/t3``)."

#: ../../../../docs/common_information/introduction.rst:24
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions docs/locale/ru/LC_MESSAGES/user_guide/build.po
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ msgstr "``-D USE_PERF_TESTS=ON`` включает тесты на произво
#: ../../../../docs/user_guide/build.rst:29
msgid ""
"``-D PPC_TASKS=all`` builds every task (default). Pass one task or a "
"semicolon list, for example ``-D PPC_TASKS=\"example_threads;example_processes\"``, "
"semicolon list, for example ``-D PPC_TASKS=\"example\"``, "
"to limit the build."
msgstr ""
"``-D PPC_TASKS=all`` собирает все задачи (по умолчанию). Укажите одну "
"задачу или список через точку с запятой, например "
"``-D PPC_TASKS=\"example_threads;example_processes\"``, чтобы ограничить "
"``-D PPC_TASKS=\"example\"``, чтобы ограничить "
"сборку."

#: ../../../../docs/user_guide/build.rst:32
Expand Down
12 changes: 6 additions & 6 deletions docs/locale/ru/LC_MESSAGES/user_guide/submit_work.po
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ msgstr "Полезные примеры для ориентирования"

#: ../../../../docs/user_guide/submit_work.rst:218
msgid ""
"Processes: ``tasks/example_processes``, ``tasks/example_processes_2``, "
"``tasks/example_processes_3``"
"Processes: ``tasks/example/processes/t1``, ``tasks/example/processes/t2``, "
"``tasks/example/processes/t3``"
msgstr ""
"Процессы: ``tasks/example_processes``, ``tasks/example_processes_2``, "
"``tasks/example_processes_3``"
"Процессы: ``tasks/example/processes/t1``, ``tasks/example/processes/t2``, "
"``tasks/example/processes/t3``"

#: ../../../../docs/user_guide/submit_work.rst:219
msgid "Threads: ``tasks/example_threads``"
msgstr "Потоки: ``tasks/example_threads``"
msgid "Threads: ``tasks/example/threads``"
msgstr "Потоки: ``tasks/example/threads``"

#: ../../../../docs/user_guide/submit_work.rst:221
msgid ""
Expand Down
6 changes: 3 additions & 3 deletions docs/user_guide/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Navigate to the project root.

.. code-block:: bash

cmake -S . -B build -DPPC_TASKS="example_threads;example_processes" -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=Release
cmake -S . -B build -DPPC_TASKS=example -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=Release

Optional: enable sanitizers for local debugging

Expand All @@ -27,8 +27,8 @@ Navigate to the project root.
- ``-D USE_FUNC_TESTS=ON`` enable functional tests.
- ``-D USE_PERF_TESTS=ON`` enable performance tests.
- ``-D PPC_TASKS=all`` builds every task (default). Pass one task or a semicolon list,
for example ``-D PPC_TASKS="example_threads;example_processes"``, to limit
the build.
for example ``-D PPC_TASKS=example``, to limit the build. Meta-layout tasks
with ``threads`` and ``processes`` subtrees are built as one selected task.
- ``-D PPC_IMPLEMENTATIONS="seq;omp"`` select implementation folders to
configure.
- ``-D CMAKE_BUILD_TYPE=Release`` normal build (default).
Expand Down
12 changes: 8 additions & 4 deletions docs/user_guide/submit_work.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ Tips for tests

.. code-block:: json

{ "tasks_type": "processes", "tasks": { "mpi": "enabled", "seq": "enabled" } }
{ "tasks": { "mpi": "enabled", "seq": "enabled" } }

- ``info.json`` — student metadata used in automation (scoreboard, macros):

.. code-block:: json

{ "student": { "full_name": "Фамилия Имя Отчество", "group_number": "Группа", "task_number": "1" } }
{ "student": { "last_name": "Фамилия", "first_name": "Имя", "middle_name": "Отчество", "group_number": "Группа" } }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want to change it also right here right now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The metadata format is back to full_name + group_number


Build and local run
-------------------
Expand Down Expand Up @@ -188,8 +188,12 @@ Common pitfalls (read before pushing)

Useful examples to reference
----------------------------
- Processes: ``tasks/example_processes``, ``tasks/example_processes_2``, ``tasks/example_processes_3``
- Threads: ``tasks/example_threads``
- Unified example: ``tasks/example``
- Shared example files: ``tasks/example/settings.json``, ``tasks/example/info.json``, ``tasks/example/common``, ``tasks/example/data``
- Threads: ``tasks/example/threads/{seq,omp,tbb,stl,all}``
- Processes: ``tasks/example/processes/t1``, ``tasks/example/processes/t2``, ``tasks/example/processes/t3``
- Process tasks keep independent ``seq`` and ``mpi`` implementations under each ``tN`` directory.
- Example reports are tree-shaped: the root report links to section reports and each implementation directory has its own ``report.md``.

- Work from your fork in a dedicated branch (not ``master``). Branch name must match your task folder.

Expand Down
17 changes: 14 additions & 3 deletions modules/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
/// @param settings_file_path Path to the JSON file containing task type strings.
/// @return Formatted string combining the task type and its corresponding value from the file.
/// @throws std::runtime_error If the file cannot be opened.
inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string &settings_file_path) {
inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string &settings_file_path,
std::string_view settings_task_path = {}) {
std::ifstream file(settings_file_path);
if (!file.is_open()) {
throw std::runtime_error("Failed to open " + settings_file_path);
Expand All @@ -94,8 +95,18 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
return std::string(type_str);
}

const auto &tasks = list_settings->at("tasks");
return std::string(type_str) + "_" + std::string(tasks.at(std::string(type_str)));
const auto *settings_node = &list_settings->at("tasks");
for (size_t start = 0; start < settings_task_path.size();) {
const size_t separator = settings_task_path.find('.', start);
const size_t key_size = separator == std::string_view::npos ? settings_task_path.size() - start : separator - start;
settings_node = &settings_node->at(std::string(settings_task_path.substr(start, key_size)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make a proper error hanling here instead of using .at()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Replaced direct .at() access with explicit key validation and contextual runtime errors, and added a unit test for missing nested settings paths.

if (separator == std::string_view::npos) {
break;
}
start = separator + 1;
}

return std::string(type_str) + "_" + std::string(settings_node->at(std::string(type_str)));
}

enum class StateOfTesting : uint8_t {
Expand Down
11 changes: 11 additions & 0 deletions modules/task/tests/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ TEST(TaskTest, GetStringTaskTypeEachTypeWithValidFile) {
EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kSEQ, path));
}

TEST(TaskTest, GetStringTaskTypeReadsNestedTaskPath) {
std::string path = "settings_nested.json";
ScopedFile cleaner(path);
std::ofstream file(path);
file << R"({"tasks": {"processes": {"t2": {"mpi": "disabled", "seq": "enabled"}}}})";
file.close();

EXPECT_EQ(GetStringTaskType(TypeOfTask::kMPI, path, "processes.t2"), "mpi_disabled");
EXPECT_EQ(GetStringTaskType(TypeOfTask::kSEQ, path, "processes.t2"), "seq_enabled");
}

TEST(TaskTest, GetStringTaskTypeReturnsUnknownOnDefault) {
std::string path = "settings_valid_unknown.json";
ScopedFile cleaner(path);
Expand Down
23 changes: 13 additions & 10 deletions modules/util/include/func_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <tbb/tick_count.h>

#include <concepts>
#include <csignal>
#include <cstddef>
#include <functional>
#include <iostream>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -133,22 +133,25 @@ auto ExpandToValues(const Tuple &t) {

template <typename Task, typename InType, typename SizesContainer, std::size_t... Is>
auto GenTaskTuplesImpl(const SizesContainer &sizes, const std::string &settings_path,
std::index_sequence<Is...> /*unused*/) {
return std::make_tuple(std::make_tuple(ppc::task::TaskGetter<Task, InType>,
std::string(GetNamespace<Task>()) + "_" +
ppc::task::GetStringTaskType(Task::GetStaticTypeOfTask(), settings_path),
std::get<Is>(sizes))...);
std::string_view settings_task_path, std::index_sequence<Is...> /*unused*/) {
return std::make_tuple(
std::make_tuple(ppc::task::TaskGetter<Task, InType>,
std::string(GetNamespace<Task>()) + "_" +
ppc::task::GetStringTaskType(Task::GetStaticTypeOfTask(), settings_path, settings_task_path),
std::get<Is>(sizes))...);
}

template <typename Task, typename InType, typename SizesContainer>
auto TaskListGenerator(const SizesContainer &sizes, const std::string &settings_path) {
return GenTaskTuplesImpl<Task, InType>(sizes, settings_path,
auto TaskListGenerator(const SizesContainer &sizes, const std::string &settings_path,
std::string_view settings_task_path = {}) {
return GenTaskTuplesImpl<Task, InType>(sizes, settings_path, settings_task_path,
std::make_index_sequence<std::tuple_size_v<std::decay_t<SizesContainer>>>{});
}

template <typename Task, typename InType, typename SizesContainer>
constexpr auto AddFuncTask(const SizesContainer &sizes, const std::string &settings_path) {
return TaskListGenerator<Task, InType>(sizes, settings_path);
constexpr auto AddFuncTask(const SizesContainer &sizes, const std::string &settings_path,
std::string_view settings_task_path = {}) {
return TaskListGenerator<Task, InType>(sizes, settings_path, settings_task_path);
}

} // namespace ppc::util
12 changes: 6 additions & 6 deletions modules/util/include/perf_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include <tbb/tick_count.h>

#include <chrono>
#include <csignal>
#include <cstddef>
#include <functional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -77,7 +77,7 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O

ASSERT_FALSE(test_name.find("unknown") != std::string::npos);
if (test_name.find("disabled") != std::string::npos) {
GTEST_SKIP();
return;
Comment thread
aobolensk marked this conversation as resolved.
}

const auto test_env_scope = ppc::util::test::MakePerTestEnvForCurrentGTest(test_name);
Expand Down Expand Up @@ -111,9 +111,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
};

template <typename TaskType, typename InputType>
auto MakePerfTaskTuples(const std::string &settings_path) {
auto MakePerfTaskTuples(const std::string &settings_path, std::string_view settings_task_path = {}) {
const auto name = std::string(GetNamespace<TaskType>()) + "_" +
ppc::task::GetStringTaskType(TaskType::GetStaticTypeOfTask(), settings_path);
ppc::task::GetStringTaskType(TaskType::GetStaticTypeOfTask(), settings_path, settings_task_path);

return std::make_tuple(std::make_tuple(ppc::task::TaskGetter<TaskType, InputType>, name,
ppc::performance::PerfResults::TypeOfRunning::kPipeline),
Expand All @@ -133,8 +133,8 @@ auto TupleToGTestValues(Tuple &&tup) {
}

template <typename InputType, typename... TaskTypes>
auto MakeAllPerfTasks(const std::string &settings_path) {
return std::tuple_cat(MakePerfTaskTuples<TaskTypes, InputType>(settings_path)...);
auto MakeAllPerfTasks(const std::string &settings_path, std::string_view settings_task_path = {}) {
return std::tuple_cat(MakePerfTaskTuples<TaskTypes, InputType>(settings_path, settings_task_path)...);
}

} // namespace ppc::util
4 changes: 2 additions & 2 deletions scoreboard/data/copying.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ threads:
processes:
copying:
mpi:
- example_processes
- example_processes_t1
seq:
- example_processes
- example_processes_t1
Loading
Loading