diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c0ba92605..493dc482b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -379,10 +379,10 @@ jobs: --exclude '.*tasks/.*/tests/.*' \ --exclude '.*modules/.*/tests/.*' \ --exclude '.*tasks/common/runners/.*' \ - --exclude '.*modules/core/runners/.*' \ - --exclude '.*modules/core/util/include/perf_test_util.hpp' \ - --exclude '.*modules/core/util/include/func_test_util.hpp' \ - --exclude '.*modules/core/util/src/func_test_util.cpp' \ + --exclude '.*modules/runners/.*' \ + --exclude '.*modules/util/include/perf_test_util.hpp' \ + --exclude '.*modules/util/include/func_test_util.hpp' \ + --exclude '.*modules/util/src/func_test_util.cpp' \ --xml --output ../coverage.xml \ --html=../cov-report/index.html --html-details - name: Upload coverage reports to Codecov diff --git a/codecov.yml b/codecov.yml index ed03862a6..9f0e9ba67 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,10 +2,10 @@ ignore: - "tasks/**/tests/**" - "modules/**/tests/**" - "tasks/common/runners/**" - - "modules/core/runners/**" - - "modules/core/util/include/perf_test_util.hpp" - - "modules/core/util/include/func_test_util.hpp" - - "modules/core/util/src/func_test_util.cpp" + - "modules/runners/**" + - "modules/util/include/perf_test_util.hpp" + - "modules/util/include/func_test_util.hpp" + - "modules/util/src/func_test_util.cpp" coverage: status: project: diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 34e8d7f4e..a867e59fd 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,7 +1,53 @@ -message(STATUS "Modules") +message(STATUS "Core components") +set(exec_func_tests "core_func_tests") +set(exec_func_lib "core_module_lib") subdirlist(subdirs ${CMAKE_CURRENT_SOURCE_DIR}) foreach(subd ${subdirs}) - add_subdirectory(${subd}) + get_filename_component(PROJECT_ID ${subd} NAME) + set(PATH_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${subd}") + set(PROJECT_ID "${PROJECT_ID}") + message(STATUS "-- " ${PROJECT_ID}) + + file(GLOB_RECURSE TMP_LIB_SOURCE_FILES ${PATH_PREFIX}/include/* + ${PATH_PREFIX}/src/*) + list(APPEND LIB_SOURCE_FILES ${TMP_LIB_SOURCE_FILES}) + + file(GLOB_RECURSE TMP_FUNC_TESTS_SOURCE_FILES ${PATH_PREFIX}/tests/*) + list(APPEND FUNC_TESTS_SOURCE_FILES ${TMP_FUNC_TESTS_SOURCE_FILES}) endforeach() + +project(${exec_func_lib}) +add_library(${exec_func_lib} STATIC ${LIB_SOURCE_FILES}) +set_target_properties(${exec_func_lib} PROPERTIES LINKER_LANGUAGE CXX) + +# Add include directories to target +target_include_directories( + ${exec_func_lib} PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty + ${CMAKE_SOURCE_DIR}/modules ${CMAKE_SOURCE_DIR}/tasks) + +ppc_link_envpp(${exec_func_lib}) +ppc_link_json(${exec_func_lib}) +ppc_link_gtest(${exec_func_lib}) +ppc_link_threads(${exec_func_lib}) +ppc_link_openmp(${exec_func_lib}) +ppc_link_tbb(${exec_func_lib}) +ppc_link_mpi(${exec_func_lib}) +ppc_link_stb(${exec_func_lib}) + +add_executable(${exec_func_tests} ${FUNC_TESTS_SOURCE_FILES}) + +target_link_libraries(${exec_func_tests} PUBLIC ${exec_func_lib}) + +enable_testing() +add_test(NAME ${exec_func_tests} COMMAND ${exec_func_tests}) + +# Installation rules +install( + TARGETS ${exec_func_lib} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) + +install(TARGETS ${exec_func_tests} RUNTIME DESTINATION bin) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt deleted file mode 100644 index 487b2c9f5..000000000 --- a/modules/core/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) -message(STATUS "${MODULE_NAME} tasks") -set(exec_func_tests "${MODULE_NAME}_func_tests") -set(exec_func_lib "${MODULE_NAME}_module_lib") -set(project_suffix "_${MODULE_NAME}") - -subdirlist(subdirs ${CMAKE_CURRENT_SOURCE_DIR}) - -foreach(subd ${subdirs}) - get_filename_component(PROJECT_ID ${subd} NAME) - set(PATH_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${subd}") - set(PROJECT_ID "${PROJECT_ID}${project_suffix}") - message(STATUS "-- " ${PROJECT_ID}) - - file(GLOB_RECURSE TMP_LIB_SOURCE_FILES ${PATH_PREFIX}/include/* - ${PATH_PREFIX}/src/*) - list(APPEND LIB_SOURCE_FILES ${TMP_LIB_SOURCE_FILES}) - - file(GLOB_RECURSE TMP_FUNC_TESTS_SOURCE_FILES ${PATH_PREFIX}/tests/*) - list(APPEND FUNC_TESTS_SOURCE_FILES ${TMP_FUNC_TESTS_SOURCE_FILES}) -endforeach() - -project(${exec_func_lib}) -add_library(${exec_func_lib} STATIC ${LIB_SOURCE_FILES}) -set_target_properties(${exec_func_lib} PROPERTIES LINKER_LANGUAGE CXX) - -# Add include directories to target -target_include_directories( - ${exec_func_lib} PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty - ${CMAKE_SOURCE_DIR}/modules ${CMAKE_SOURCE_DIR}/tasks) - -ppc_link_envpp(${exec_func_lib}) -ppc_link_json(${exec_func_lib}) -ppc_link_gtest(${exec_func_lib}) -ppc_link_threads(${exec_func_lib}) -ppc_link_openmp(${exec_func_lib}) -ppc_link_tbb(${exec_func_lib}) -ppc_link_mpi(${exec_func_lib}) -ppc_link_stb(${exec_func_lib}) - -add_executable(${exec_func_tests} ${FUNC_TESTS_SOURCE_FILES}) - -target_link_libraries(${exec_func_tests} PUBLIC ${exec_func_lib}) - -enable_testing() -add_test(NAME ${exec_func_tests} COMMAND ${exec_func_tests}) - -# Installation rules -install( - TARGETS ${exec_func_lib} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) - -install(TARGETS ${exec_func_tests} RUNTIME DESTINATION bin) diff --git a/modules/core/performance/tests/test_task.hpp b/modules/core/performance/tests/test_task.hpp deleted file mode 100644 index 98b6993eb..000000000 --- a/modules/core/performance/tests/test_task.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include -#include - -#include "core/task/include/task.hpp" - -namespace ppc::test::perf { - -template -class TestTask : public ppc::core::Task { - public: - explicit TestTask(const InType& in) { this->GetInput() = in; } - - bool ValidationImpl() override { return !this->GetInput().empty(); } - - bool PreProcessingImpl() override { - this->GetOutput() = 0; - return true; - } - - bool RunImpl() override { - for (unsigned i = 0; i < this->GetInput().size(); i++) { - this->GetOutput() += this->GetInput()[i]; - } - return true; - } - - bool PostProcessingImpl() override { return true; } -}; - -template -class FakePerfTask : public TestTask { - public: - explicit FakePerfTask(const InType& in) : TestTask(in) {} - - bool RunImpl() override { - std::this_thread::sleep_for(std::chrono::seconds(11)); - return TestTask::RunImpl(); - } -}; - -} // namespace ppc::test::perf diff --git a/modules/core/task/tests/test_task.hpp b/modules/core/task/tests/test_task.hpp deleted file mode 100644 index 042298a29..000000000 --- a/modules/core/task/tests/test_task.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include -#include - -#include "core/task/include/task.hpp" - -namespace ppc::test::task { - -template -class TestTask : public ppc::core::Task { - public: - explicit TestTask(const InType& in) { this->GetInput() = in; } - - bool ValidationImpl() override { return !this->GetInput().empty(); } - - bool PreProcessingImpl() override { - this->GetOutput() = 0; - return true; - } - - bool RunImpl() override { - for (unsigned i = 0; i < this->GetInput().size(); i++) { - this->GetOutput() += this->GetInput()[i]; - } - return true; - } - - bool PostProcessingImpl() override { return true; } -}; - -template -class FakeSlowTask : public TestTask { - public: - explicit FakeSlowTask(const InType& in) : TestTask(in) {} - - bool RunImpl() override { - std::this_thread::sleep_for(std::chrono::seconds(2)); - return TestTask::RunImpl(); - } -}; - -} // namespace ppc::test::task diff --git a/modules/core/performance/include/performance.hpp b/modules/performance/include/performance.hpp similarity index 81% rename from modules/core/performance/include/performance.hpp rename to modules/performance/include/performance.hpp index 72f1a403c..eaafc5378 100644 --- a/modules/core/performance/include/performance.hpp +++ b/modules/performance/include/performance.hpp @@ -9,16 +9,18 @@ #include #include -#include "core/task/include/task.hpp" +#include "task/include/task.hpp" -namespace ppc::core { +namespace ppc::performance { + +inline double DefaultTimer() { return -1.0; } struct PerfAttr { /// @brief Number of times the task is run for performance evaluation. uint64_t num_running = 5; /// @brief Timer function returning current time in seconds. /// @cond - std::function current_timer = [&] { return -1.0; }; + std::function current_timer = DefaultTimer; /// @endcond }; @@ -33,15 +35,15 @@ template class Perf { public: // Init performance analysis with an initialized task and initialized data - explicit Perf(const TaskPtr& task_ptr) : task_(task_ptr) { - task_ptr->GetStateOfTesting() = StateOfTesting::kPerf; + explicit Perf(const ppc::task::TaskPtr& task_ptr) : task_(task_ptr) { + task_ptr->GetStateOfTesting() = ppc::task::StateOfTesting::kPerf; } // Check performance of full task's pipeline: PreProcessing() -> // Validation() -> Run() -> PostProcessing() void PipelineRun(const PerfAttr& perf_attr) { perf_results_.type_of_running = PerfResults::TypeOfRunning::kPipeline; - CommonRun(perf_attr, [&]() { + CommonRun(perf_attr, [&] { task_->Validation(); task_->PreProcessing(); task_->Run(); @@ -54,7 +56,7 @@ class Perf { task_->Validation(); task_->PreProcessing(); - CommonRun(perf_attr, [&]() { task_->Run(); }, perf_results_); + CommonRun(perf_attr, [&] { task_->Run(); }, perf_results_); task_->PostProcessing(); task_->Validation(); @@ -92,11 +94,11 @@ class Perf { } /// @brief Retrieves the performance test results. /// @return The latest PerfResults structure. - PerfResults GetPerfResults() { return perf_results_; } + [[nodiscard]] PerfResults GetPerfResults() const { return perf_results_; } private: PerfResults perf_results_; - std::shared_ptr> task_; + std::shared_ptr> task_; static void CommonRun(const PerfAttr& perf_attr, const std::function& pipeline, PerfResults& perf_results) { auto begin = perf_attr.current_timer(); for (uint64_t i = 0; i < perf_attr.num_running; i++) { @@ -107,14 +109,14 @@ class Perf { } }; -inline std::string GetStringParamName(ppc::core::PerfResults::TypeOfRunning type_of_running) { - if (type_of_running == core::PerfResults::kTaskRun) { +inline std::string GetStringParamName(PerfResults::TypeOfRunning type_of_running) { + if (type_of_running == PerfResults::kTaskRun) { return "task_run"; } - if (type_of_running == core::PerfResults::kPipeline) { + if (type_of_running == PerfResults::kPipeline) { return "pipeline"; } return "none"; } -} // namespace ppc::core +} // namespace ppc::performance diff --git a/modules/core/performance/tests/.clang-tidy b/modules/performance/tests/.clang-tidy similarity index 100% rename from modules/core/performance/tests/.clang-tidy rename to modules/performance/tests/.clang-tidy diff --git a/modules/core/performance/tests/perf_tests.cpp b/modules/performance/tests/perf_tests.cpp similarity index 60% rename from modules/core/performance/tests/perf_tests.cpp rename to modules/performance/tests/perf_tests.cpp index b90d6537c..1888e39a3 100644 --- a/modules/core/performance/tests/perf_tests.cpp +++ b/modules/performance/tests/perf_tests.cpp @@ -8,51 +8,92 @@ #include #include #include +#include #include -#include "core/performance/include/performance.hpp" -#include "core/performance/tests/test_task.hpp" -#include "core/task/include/task.hpp" -#include "core/util/include/util.hpp" +#include "performance/include/performance.hpp" +#include "task/include/task.hpp" +#include "util/include/util.hpp" + +using namespace ppc::task; + +namespace ppc::test { + +template +class TestPerfTask : public ppc::task::Task { + public: + explicit TestPerfTask(const InType& in) { this->GetInput() = in; } + + bool ValidationImpl() override { return !this->GetInput().empty(); } + + bool PreProcessingImpl() override { + this->GetOutput() = 0; + return true; + } + + bool RunImpl() override { + for (unsigned i = 0; i < this->GetInput().size(); i++) { + this->GetOutput() += this->GetInput()[i]; + } + return true; + } + + bool PostProcessingImpl() override { return true; } +}; + +template +class FakePerfTask : public TestPerfTask { + public: + explicit FakePerfTask(const InType& in) : TestPerfTask(in) {} + + bool RunImpl() override { + std::this_thread::sleep_for(std::chrono::seconds(11)); + return TestPerfTask::RunImpl(); + } +}; + +} // namespace ppc::test + +namespace ppc::performance { TEST(perf_tests, check_perf_pipeline) { std::vector in(2000, 1); - auto test_task = std::make_shared, uint32_t>>(in); + auto test_task = std::make_shared, uint32_t>>(in); - ppc::core::Perf, uint32_t> perf_analyzer(test_task); + Perf, uint32_t> perf_analyzer(test_task); - ppc::core::PerfAttr perf_attr; + PerfAttr perf_attr; perf_analyzer.PipelineRun(perf_attr); perf_analyzer.PrintPerfStatistic("check_perf_pipeline"); - ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, ppc::core::PerfResults::kMaxTime); + ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, PerfResults::kMaxTime); EXPECT_EQ(test_task->GetOutput(), in.size()); } TEST(perf_tests, check_perf_pipeline_float) { std::vector in(2000, 1); - auto test_task = std::make_shared, float>>(in); + auto test_task = std::make_shared, float>>(in); - ppc::core::Perf, float> perf_analyzer(test_task); + Perf, float> perf_analyzer(test_task); - ppc::core::PerfAttr perf_attr; + PerfAttr perf_attr; perf_analyzer.PipelineRun(perf_attr); perf_analyzer.PrintPerfStatistic("check_perf_pipeline_float"); - ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, ppc::core::PerfResults::kMaxTime); + ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, PerfResults::kMaxTime); EXPECT_EQ(test_task->GetOutput(), in.size()); } TEST(perf_tests, check_perf_pipeline_uint8_t_slow_test) { std::vector in(128, 1); - auto test_task = std::make_shared, uint8_t>>(in); + auto test_task = std::make_shared, uint8_t>>(in); - ppc::core::Perf, uint8_t> perf_analyzer(test_task); + Perf, uint8_t> perf_analyzer(test_task); - ppc::core::PerfAttr perf_attr; + PerfAttr perf_attr; perf_attr.num_running = 1; const auto t0 = std::chrono::high_resolution_clock::now(); @@ -69,33 +110,33 @@ TEST(perf_tests, check_perf_pipeline_uint8_t_slow_test) { TEST(perf_tests, check_perf_task_exception) { std::vector in(2000, 1); - auto test_task = std::make_shared, uint32_t>>(in); + auto test_task = std::make_shared, uint32_t>>(in); - ppc::core::Perf, uint32_t> perf_analyzer(test_task); + Perf, uint32_t> perf_analyzer(test_task); ASSERT_ANY_THROW(perf_analyzer.PrintPerfStatistic("check_perf_task_exception")); - ppc::core::PerfAttr perf_attr; + PerfAttr perf_attr; perf_analyzer.TaskRun(perf_attr); } TEST(perf_tests, check_perf_task_float) { std::vector in(2000, 1); - auto test_task = std::make_shared, float>>(in); + auto test_task = std::make_shared, float>>(in); - ppc::core::Perf, float> perf_analyzer(test_task); + Perf, float> perf_analyzer(test_task); - ppc::core::PerfAttr perf_attr; + PerfAttr perf_attr; perf_analyzer.TaskRun(perf_attr); perf_analyzer.PrintPerfStatistic("check_perf_task_float"); - ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, ppc::core::PerfResults::kMaxTime); + ASSERT_LE(perf_analyzer.GetPerfResults().time_sec, PerfResults::kMaxTime); EXPECT_EQ(test_task->GetOutput(), in.size()); } struct ParamTestCase { - ppc::core::PerfResults::TypeOfRunning input; + PerfResults::TypeOfRunning input; std::string expected_output; friend void PrintTo(const ParamTestCase& param, std::ostream* os) { *os << "{ input = " << static_cast(param.input) << ", expected = " << param.expected_output << " }"; @@ -106,19 +147,19 @@ class GetStringParamNameParamTest : public ::testing::TestWithParam& info) { return info.param.expected_output; }); struct TaskTypeTestCase { - ppc::core::TypeOfTask type; + TypeOfTask type; std::string expected; std::string label; friend void PrintTo(const TaskTypeTestCase& param, std::ostream* os) { @@ -153,46 +194,45 @@ TEST_P(GetStringTaskTypeTest, ReturnsExpectedString) { } INSTANTIATE_TEST_SUITE_P(AllTypeCases, GetStringTaskTypeTest, - ::testing::Values(TaskTypeTestCase{ppc::core::TypeOfTask::kALL, "all_ALL", "kALL"}, - TaskTypeTestCase{ppc::core::TypeOfTask::kSTL, "stl_STL", "kSTL"}, - TaskTypeTestCase{ppc::core::TypeOfTask::kOMP, "omp_OMP", "kOMP"}, - TaskTypeTestCase{ppc::core::TypeOfTask::kMPI, "mpi_MPI", "kMPI"}, - TaskTypeTestCase{ppc::core::TypeOfTask::kTBB, "tbb_TBB", "kTBB"}, - TaskTypeTestCase{ppc::core::TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"})); + ::testing::Values(TaskTypeTestCase{TypeOfTask::kALL, "all_ALL", "kALL"}, + TaskTypeTestCase{TypeOfTask::kSTL, "stl_STL", "kSTL"}, + TaskTypeTestCase{TypeOfTask::kOMP, "omp_OMP", "kOMP"}, + TaskTypeTestCase{TypeOfTask::kMPI, "mpi_MPI", "kMPI"}, + TaskTypeTestCase{TypeOfTask::kTBB, "tbb_TBB", "kTBB"}, + TaskTypeTestCase{TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"})); TEST(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) { std::string missing_path = "non_existent_settings.json"; - EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error); + EXPECT_THROW(GetStringTaskType(TypeOfTask::kSEQ, missing_path), std::runtime_error); } TEST(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) { const std::string missing_path = "non_existent_settings.json"; - EXPECT_THROW( - try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { - EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); - throw; - }, - std::runtime_error); + EXPECT_THROW(try { GetStringTaskType(TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { + EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); + throw; + }, + std::runtime_error); } TEST(GetStringTaskTypeStandaloneTest, ReturnsUnknownForInvalidEnum) { std::string path = (std::filesystem::temp_directory_path() / "tmp_settings.json").string(); std::ofstream(path) << R"({"tasks":{"seq":"SEQ"}})"; - auto result = GetStringTaskType(ppc::core::TypeOfTask::kUnknown, path); + auto result = GetStringTaskType(TypeOfTask::kUnknown, path); EXPECT_EQ(result, "unknown"); std::filesystem::remove(path); } TEST(GetStringTaskTypeEdgeCases, ThrowsIfFileCannotBeOpened) { - EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, "definitely_missing_file.json"), std::runtime_error); + EXPECT_THROW(GetStringTaskType(TypeOfTask::kSEQ, "definitely_missing_file.json"), std::runtime_error); } TEST(GetStringTaskTypeEdgeCases, ThrowsIfJsonIsMalformed) { std::string path = (std::filesystem::temp_directory_path() / "bad_json.json").string(); std::ofstream(path) << "{ this is not valid json "; - EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonParseError); + EXPECT_THROW(GetStringTaskType(TypeOfTask::kSEQ, path), NlohmannJsonParseError); std::filesystem::remove(path); } @@ -200,7 +240,7 @@ TEST(GetStringTaskTypeEdgeCases, ThrowsIfJsonValueIsNull) { std::string path = (std::filesystem::temp_directory_path() / "null_value.json").string(); std::ofstream(path) << R"({"tasks": { "seq": null }})"; - EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonTypeError); + EXPECT_THROW(GetStringTaskType(TypeOfTask::kSEQ, path), NlohmannJsonTypeError); std::filesystem::remove(path); } @@ -208,17 +248,17 @@ TEST(GetStringTaskTypeEdgeCases, ThrowsIfJsonValueIsNull) { TEST(GetStringTaskTypeEdgeCases, ReturnsUnknownIfEnumOutOfRange) { std::string path = (std::filesystem::temp_directory_path() / "ok.json").string(); std::ofstream(path) << R"({"tasks":{"seq":"SEQ"}})"; - auto result = GetStringTaskType(ppc::core::TypeOfTask::kUnknown, path); + auto result = GetStringTaskType(TypeOfTask::kUnknown, path); EXPECT_EQ(result, "unknown"); std::filesystem::remove(path); } TEST(GetStringTaskStatusTest, HandlesEnabledAndDisabled) { - EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kEnabled), "enabled"); - EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kDisabled), "disabled"); + EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kEnabled), "enabled"); + EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kDisabled), "disabled"); } -class DummyTask : public ppc::core::Task { +class DummyTask : public Task { public: using Task::Task; bool ValidationImpl() override { return true; } @@ -229,12 +269,12 @@ class DummyTask : public ppc::core::Task { TEST(TaskTest, GetDynamicTypeReturnsCorrectEnum) { DummyTask task; - task.SetTypeOfTask(ppc::core::TypeOfTask::kOMP); + task.SetTypeOfTask(TypeOfTask::kOMP); task.Validation(); task.PreProcessing(); task.Run(); task.PostProcessing(); - EXPECT_EQ(task.GetDynamicTypeOfTask(), ppc::core::TypeOfTask::kOMP); + EXPECT_EQ(task.GetDynamicTypeOfTask(), TypeOfTask::kOMP); } TEST(TaskTest, DestructorTerminatesIfWrongOrder) { @@ -261,9 +301,9 @@ TYPED_TEST(GetNamespaceTest, ExtractsNamespaceCorrectly) { std::string k_ns = ppc::util::GetNamespace(); if constexpr (std::is_same_v) { - EXPECT_EQ(k_ns, "my::nested"); + EXPECT_EQ(k_ns, "ppc::performance::my::nested"); } else if constexpr (std::is_same_v) { - EXPECT_EQ(k_ns, "my"); + EXPECT_EQ(k_ns, "ppc::performance::my"); } else if constexpr (std::is_same_v) { EXPECT_EQ(k_ns, ""); } else { @@ -273,9 +313,9 @@ TYPED_TEST(GetNamespaceTest, ExtractsNamespaceCorrectly) { TEST(PerfTest, PipelineRunAndTaskRun) { auto task_ptr = std::make_shared(); - ppc::core::Perf perf(task_ptr); + Perf perf(task_ptr); - ppc::core::PerfAttr attr; + PerfAttr attr; double time = 0.0; attr.num_running = 2; attr.current_timer = [&time]() { @@ -286,19 +326,19 @@ TEST(PerfTest, PipelineRunAndTaskRun) { EXPECT_NO_THROW(perf.PipelineRun(attr)); auto res_pipeline = perf.GetPerfResults(); - EXPECT_EQ(res_pipeline.type_of_running, ppc::core::PerfResults::kPipeline); + EXPECT_EQ(res_pipeline.type_of_running, PerfResults::kPipeline); EXPECT_GT(res_pipeline.time_sec, 0.0); EXPECT_NO_THROW(perf.TaskRun(attr)); auto res_taskrun = perf.GetPerfResults(); - EXPECT_EQ(res_taskrun.type_of_running, ppc::core::PerfResults::kTaskRun); + EXPECT_EQ(res_taskrun.type_of_running, PerfResults::kTaskRun); EXPECT_GT(res_taskrun.time_sec, 0.0); } TEST(PerfTest, PrintPerfStatisticThrowsOnNone) { { auto task_ptr = std::make_shared(); - ppc::core::Perf perf(task_ptr); + Perf perf(task_ptr); EXPECT_THROW(perf.PrintPerfStatistic("test"), std::runtime_error); } EXPECT_TRUE(ppc::util::DestructorFailureFlag::Get()); @@ -306,14 +346,14 @@ TEST(PerfTest, PrintPerfStatisticThrowsOnNone) { } TEST(PerfTest, GetStringParamNameTest) { - EXPECT_EQ(GetStringParamName(ppc::core::PerfResults::kTaskRun), "task_run"); - EXPECT_EQ(GetStringParamName(ppc::core::PerfResults::kPipeline), "pipeline"); - EXPECT_EQ(GetStringParamName(ppc::core::PerfResults::kNone), "none"); + EXPECT_EQ(GetStringParamName(PerfResults::kTaskRun), "task_run"); + EXPECT_EQ(GetStringParamName(PerfResults::kPipeline), "pipeline"); + EXPECT_EQ(GetStringParamName(PerfResults::kNone), "none"); } TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) { { - struct BadTask : ppc::core::Task { + struct BadTask : Task { bool ValidationImpl() override { return true; } bool PreProcessingImpl() override { return true; } bool RunImpl() override { return true; } @@ -324,3 +364,5 @@ TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) { EXPECT_TRUE(ppc::util::DestructorFailureFlag::Get()); ppc::util::DestructorFailureFlag::Unset(); } + +} // namespace ppc::performance diff --git a/modules/core/runners/include/runners.hpp b/modules/runners/include/runners.hpp similarity index 92% rename from modules/core/runners/include/runners.hpp rename to modules/runners/include/runners.hpp index 15d50941d..56a46f1e0 100644 --- a/modules/core/runners/include/runners.hpp +++ b/modules/runners/include/runners.hpp @@ -5,7 +5,7 @@ #include #include -namespace ppc::core { +namespace ppc::runners { /// @brief GTest event listener that checks for unread MPI messages after each test. /// @note Used to detect unexpected inter-process communication leftovers. @@ -25,7 +25,7 @@ class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener { /// @brief Constructs the listener with a base listener for delegation. /// @param base A shared pointer to another GTest event listener. explicit WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base) : base_(std::move(base)) {} - /// @brief Called after a test ends. Passes call to base listener and prints failures with rank. + /// @brief Called after a test ends. Passes call base listener and print failures with rank. void OnTestEnd(const ::testing::TestInfo& test_info) override; /// @brief Called when a test part fails. Prints MPI rank info along with the failure. void OnTestPartResult(const ::testing::TestPartResult& test_part_result) override; @@ -49,4 +49,4 @@ int Init(int argc, char** argv); /// @return Exit code from RUN_ALL_TESTS. int SimpleInit(int argc, char** argv); -} // namespace ppc::core +} // namespace ppc::runners diff --git a/modules/core/runners/src/runners.cpp b/modules/runners/src/runners.cpp similarity index 90% rename from modules/core/runners/src/runners.cpp rename to modules/runners/src/runners.cpp index 15d4eee43..524ceb8ea 100644 --- a/modules/core/runners/src/runners.cpp +++ b/modules/runners/src/runners.cpp @@ -1,4 +1,4 @@ -#include "core/runners/include/runners.hpp" +#include "runners/include/runners.hpp" #include #include @@ -10,10 +10,10 @@ #include #include -#include "core/util/include/util.hpp" #include "oneapi/tbb/global_control.h" +#include "util/include/util.hpp" -namespace ppc::core { +namespace ppc::runners { void UnreadMessagesDetector::OnTestEnd(const ::testing::TestInfo& /*test_info*/) { int rank = -1; @@ -89,9 +89,9 @@ int Init(int argc, char** argv) { MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank != 0 && (argc < 2 || argv[1] != std::string("--print-workers"))) { auto* listener = listeners.Release(listeners.default_result_printer()); - listeners.Append(new ppc::core::WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener>(listener))); + listeners.Append(new WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener>(listener))); } - listeners.Append(new ppc::core::UnreadMessagesDetector()); + listeners.Append(new UnreadMessagesDetector()); auto status = RunAllTests(); @@ -112,4 +112,4 @@ int SimpleInit(int argc, char** argv) { return RunAllTests(); } -} // namespace ppc::core +} // namespace ppc::runners diff --git a/modules/core/task/include/task.hpp b/modules/task/include/task.hpp similarity index 98% rename from modules/core/task/include/task.hpp rename to modules/task/include/task.hpp index 05fcd0b26..f54b73b4c 100644 --- a/modules/core/task/include/task.hpp +++ b/modules/task/include/task.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -17,10 +16,11 @@ #include #include #include +#include #include #include -namespace ppc::core { +namespace ppc::task { /// @brief Represents the type of task (parallelization technology). /// @details Used to select the implementation type in tests and execution logic. @@ -236,7 +236,7 @@ class Task { virtual bool PreProcessingImpl() = 0; /// @brief User-defined task execution logic. - /// @return True if run is successful. + /// @return True if a run is successful. virtual bool RunImpl() = 0; /// @brief User-defined postprocessing logic. @@ -277,4 +277,4 @@ std::shared_ptr TaskGetter(InType in) { return std::make_shared(in); } -} // namespace ppc::core +} // namespace ppc::task diff --git a/modules/core/task/tests/.clang-tidy b/modules/task/tests/.clang-tidy similarity index 100% rename from modules/core/task/tests/.clang-tidy rename to modules/task/tests/.clang-tidy diff --git a/modules/core/task/tests/task_tests.cpp b/modules/task/tests/task_tests.cpp similarity index 66% rename from modules/core/task/tests/task_tests.cpp rename to modules/task/tests/task_tests.cpp index 17f5485d7..daedf15a0 100644 --- a/modules/core/task/tests/task_tests.cpp +++ b/modules/task/tests/task_tests.cpp @@ -10,14 +10,52 @@ #include #include -#include "core/runners/include/runners.hpp" -#include "core/task/include/task.hpp" -#include "core/task/tests/test_task.hpp" -#include "core/util/include/util.hpp" +#include "runners/include/runners.hpp" +#include "task/include/task.hpp" +#include "util/include/util.hpp" + +using namespace ppc::task; + +namespace ppc::test { + +template +class TestTask : public ppc::task::Task { + public: + explicit TestTask(const InType& in) { this->GetInput() = in; } + + bool ValidationImpl() override { return !this->GetInput().empty(); } + + bool PreProcessingImpl() override { + this->GetOutput() = 0; + return true; + } + + bool RunImpl() override { + for (unsigned i = 0; i < this->GetInput().size(); i++) { + this->GetOutput() += this->GetInput()[i]; + } + return true; + } + + bool PostProcessingImpl() override { return true; } +}; + +template +class FakeSlowTask : public TestTask { + public: + explicit FakeSlowTask(const InType& in) : TestTask(in) {} + + bool RunImpl() override { + std::this_thread::sleep_for(std::chrono::seconds(2)); + return TestTask::RunImpl(); + } +}; + +} // namespace ppc::test TEST(task_tests, check_int32_t) { std::vector in(20, 1); - ppc::test::task::TestTask, int32_t> test_task(in); + ppc::test::TestTask, int32_t> test_task(in); ASSERT_EQ(test_task.Validation(), true); test_task.PreProcessing(); test_task.Run(); @@ -27,7 +65,7 @@ TEST(task_tests, check_int32_t) { TEST(task_tests, check_int32_t_slow) { std::vector in(20, 1); - ppc::test::task::FakeSlowTask, int32_t> test_task(in); + ppc::test::FakeSlowTask, int32_t> test_task(in); ASSERT_EQ(test_task.Validation(), true); test_task.PreProcessing(); test_task.Run(); @@ -36,7 +74,7 @@ TEST(task_tests, check_int32_t_slow) { TEST(task_tests, check_validate_func) { std::vector in; - ppc::test::task::TestTask, int32_t> test_task(in); + ppc::test::TestTask, int32_t> test_task(in); ASSERT_EQ(test_task.Validation(), false); test_task.PreProcessing(); test_task.Run(); @@ -45,7 +83,7 @@ TEST(task_tests, check_validate_func) { TEST(task_tests, check_double) { std::vector in(20, 1); - ppc::test::task::TestTask, double> test_task(in); + ppc::test::TestTask, double> test_task(in); ASSERT_EQ(test_task.Validation(), true); test_task.PreProcessing(); test_task.Run(); @@ -55,7 +93,7 @@ TEST(task_tests, check_double) { TEST(task_tests, check_float) { std::vector in(20, 1); - ppc::test::task::TestTask, float> test_task(in); + ppc::test::TestTask, float> test_task(in); ASSERT_EQ(test_task.Validation(), true); test_task.PreProcessing(); test_task.Run(); @@ -65,7 +103,7 @@ TEST(task_tests, check_float) { TEST(task_tests, check_wrong_order_disabled_valgrind) { std::vector in(20, 1); - ppc::test::task::TestTask, float> test_task(in); + ppc::test::TestTask, float> test_task(in); ASSERT_EQ(test_task.Validation(), true); test_task.PreProcessing(); EXPECT_THROW(test_task.PostProcessing(), std::runtime_error); @@ -73,27 +111,23 @@ TEST(task_tests, check_wrong_order_disabled_valgrind) { TEST(task_tests, premature_postprocessing_no_steps) { std::vector in(20, 1); - ppc::test::task::TestTask, float> test_task(in); + ppc::test::TestTask, float> test_task(in); EXPECT_THROW(test_task.PostProcessing(), std::runtime_error); } TEST(task_tests, premature_postprocessing_after_preprocessing) { std::vector in(20, 1); - ppc::test::task::TestTask, float> test_task(in); + ppc::test::TestTask, float> test_task(in); EXPECT_THROW(test_task.PreProcessing(), std::runtime_error); EXPECT_THROW(test_task.PostProcessing(), std::runtime_error); } -TEST(TaskTest, GetStringTaskStatus_Disabled) { - EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kDisabled), "disabled"); -} +TEST(TaskTest, GetStringTaskStatus_Disabled) { EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kDisabled), "disabled"); } -TEST(TaskTest, GetStringTaskStatus_Enabled) { - EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kEnabled), "enabled"); -} +TEST(TaskTest, GetStringTaskStatus_Enabled) { EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kEnabled), "enabled"); } TEST(TaskTest, GetStringTaskType_InvalidFileThrows) { - EXPECT_THROW({ GetStringTaskType(ppc::core::TypeOfTask::kALL, "non_existing_file.json"); }, std::runtime_error); + EXPECT_THROW({ GetStringTaskType(TypeOfTask::kALL, "non_existing_file.json"); }, std::runtime_error); } TEST(TaskTest, GetStringTaskType_UnknownType_WithValidFile) { @@ -102,7 +136,7 @@ TEST(TaskTest, GetStringTaskType_UnknownType_WithValidFile) { file << R"({"tasks": {"all": "enabled", "stl": "enabled", "omp": "enabled", "mpi": "enabled", "tbb": "enabled", "seq": "enabled"}})"; file.close(); - EXPECT_NO_THROW({ GetStringTaskType(ppc::core::TypeOfTask::kUnknown, path); }); + EXPECT_NO_THROW({ GetStringTaskType(TypeOfTask::kUnknown, path); }); } TEST(TaskTest, GetStringTaskType_ThrowsOnBadJSON) { @@ -110,7 +144,7 @@ TEST(TaskTest, GetStringTaskType_ThrowsOnBadJSON) { std::ofstream file(path); file << "{"; file.close(); - EXPECT_THROW({ GetStringTaskType(ppc::core::TypeOfTask::kALL, path); }, std::exception); + EXPECT_THROW({ GetStringTaskType(TypeOfTask::kALL, path); }, std::exception); } TEST(TaskTest, GetStringTaskType_EachType_WithValidFile) { @@ -120,12 +154,12 @@ TEST(TaskTest, GetStringTaskType_EachType_WithValidFile) { << R"({"tasks": {"all": "enabled", "stl": "enabled", "omp": "enabled", "mpi": "enabled", "tbb": "enabled", "seq": "enabled"}})"; file.close(); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kALL, path)); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kSTL, path)); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kOMP, path)); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kMPI, path)); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kTBB, path)); - EXPECT_NO_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kALL, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kSTL, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kOMP, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kMPI, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kTBB, path)); + EXPECT_NO_THROW(GetStringTaskType(TypeOfTask::kSEQ, path)); } TEST(TaskTest, GetStringTaskType_ReturnsUnknown_OnDefault) { @@ -134,7 +168,7 @@ TEST(TaskTest, GetStringTaskType_ReturnsUnknown_OnDefault) { file << R"({"tasks": {"all": "enabled"}})"; file.close(); - auto result = ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kUnknown, path); + auto result = GetStringTaskType(TypeOfTask::kUnknown, path); EXPECT_EQ(result, "unknown"); } @@ -144,13 +178,13 @@ TEST(TaskTest, GetStringTaskType_ThrowsIfKeyMissing) { file << R"({"tasks": {"all": "enabled"}})"; file.close(); - EXPECT_ANY_THROW(ppc::core::GetStringTaskType(ppc::core::TypeOfTask::kSTL, path)); + EXPECT_ANY_THROW(GetStringTaskType(TypeOfTask::kSTL, path)); } TEST(TaskTest, TaskDestructor_ThrowsIfStageIncomplete) { { std::vector in(20, 1); - struct LocalTask : ppc::core::Task, int32_t> { + struct LocalTask : Task, int32_t> { explicit LocalTask(const std::vector& in) { this->GetInput() = in; } bool ValidationImpl() override { return true; } bool PreProcessingImpl() override { return true; } @@ -166,7 +200,7 @@ TEST(TaskTest, TaskDestructor_ThrowsIfStageIncomplete) { TEST(TaskTest, TaskDestructor_ThrowsIfEmpty) { { std::vector in(20, 1); - struct LocalTask : ppc::core::Task, int32_t> { + struct LocalTask : Task, int32_t> { explicit LocalTask(const std::vector& in) { this->GetInput() = in; } bool ValidationImpl() override { return true; } bool PreProcessingImpl() override { return true; } @@ -179,7 +213,7 @@ TEST(TaskTest, TaskDestructor_ThrowsIfEmpty) { } TEST(TaskTest, InternalTimeTest_ThrowsIfTimeoutExceeded) { - struct SlowTask : ppc::core::Task, int32_t> { + struct SlowTask : Task, int32_t> { explicit SlowTask(const std::vector& in) { this->GetInput() = in; } bool ValidationImpl() override { return true; } bool PreProcessingImpl() override { @@ -192,14 +226,14 @@ TEST(TaskTest, InternalTimeTest_ThrowsIfTimeoutExceeded) { std::vector in(20, 1); SlowTask task(in); - task.GetStateOfTesting() = ppc::core::StateOfTesting::kFunc; + task.GetStateOfTesting() = StateOfTesting::kFunc; task.Validation(); EXPECT_NO_THROW(task.PreProcessing()); task.Run(); EXPECT_THROW(task.PostProcessing(), std::runtime_error); } -class DummyTask : public ppc::core::Task { +class DummyTask : public Task { public: using Task::Task; bool ValidationImpl() override { return true; } @@ -231,4 +265,4 @@ TEST(TaskTest, PostProcessingThrowsIfCalledBeforeRun) { EXPECT_THROW(task->PostProcessing(), std::runtime_error); } -int main(int argc, char** argv) { return ppc::core::SimpleInit(argc, argv); } +int main(int argc, char** argv) { return ppc::runners::SimpleInit(argc, argv); } diff --git a/modules/core/util/include/func_test_util.hpp b/modules/util/include/func_test_util.hpp similarity index 88% rename from modules/core/util/include/func_test_util.hpp rename to modules/util/include/func_test_util.hpp index 22aac7ac6..e43b59e75 100644 --- a/modules/core/util/include/func_test_util.hpp +++ b/modules/util/include/func_test_util.hpp @@ -13,13 +13,15 @@ #include #include -#include "core/task/include/task.hpp" -#include "core/util/include/util.hpp" +#include "task/include/task.hpp" +#include "util/include/util.hpp" + +using namespace ppc::task; namespace ppc::util { template -using FuncTestParam = std::tuple(InType)>, std::string, TestType>; +using FuncTestParam = std::tuple(InType)>, std::string, TestType>; template using GTestFuncParam = ::testing::TestParamInfo>; @@ -96,7 +98,7 @@ class BaseRunFuncTests : public ::testing::TestWithParam task_; + TaskPtr task_; }; template @@ -113,10 +115,10 @@ auto ExpandToValues(const Tuple& t) { template auto GenTaskTuplesImpl(const SizesContainer& sizes, const std::string& settings_path, std::index_sequence /*unused*/) { - return std::make_tuple(std::make_tuple(ppc::core::TaskGetter, - std::string(GetNamespace()) + "_" + - ppc::core::GetStringTaskType(Task::GetStaticTypeOfTask(), settings_path), - sizes[Is])...); + return std::make_tuple(std::make_tuple( + TaskGetter, + std::string(GetNamespace()) + "_" + GetStringTaskType(Task::GetStaticTypeOfTask(), settings_path), + sizes[Is])...); } template diff --git a/modules/core/util/include/perf_test_util.hpp b/modules/util/include/perf_test_util.hpp similarity index 68% rename from modules/core/util/include/perf_test_util.hpp rename to modules/util/include/perf_test_util.hpp index 10b63f15e..66afefd11 100644 --- a/modules/core/util/include/perf_test_util.hpp +++ b/modules/util/include/perf_test_util.hpp @@ -14,9 +14,12 @@ #include #include -#include "core/performance/include/performance.hpp" -#include "core/task/include/task.hpp" -#include "core/util/include/util.hpp" +#include "performance/include/performance.hpp" +#include "task/include/task.hpp" +#include "util/include/util.hpp" + +using namespace ppc::task; +using namespace ppc::performance; namespace ppc::util { @@ -24,8 +27,8 @@ double GetTimeMPI(); int GetMPIRank(); template -using PerfTestParam = std::tuple(InType)>, std::string, - ppc::core::PerfResults::TypeOfRunning>; +using PerfTestParam = + std::tuple(InType)>, std::string, PerfResults::TypeOfRunning>; template /// @brief Base class for performance testing of parallel tasks. @@ -35,7 +38,7 @@ class BaseRunPerfTests : public ::testing::TestWithParam>& info) { - return ppc::core::GetStringParamName(std::get(info.param)) + "_" + + return GetStringParamName(std::get(info.param)) + "_" + std::get(info.param); } @@ -44,17 +47,17 @@ class BaseRunPerfTests : public ::testing::TestWithParamGetDynamicTypeOfTask() == ppc::core::TypeOfTask::kMPI || - task_->GetDynamicTypeOfTask() == ppc::core::TypeOfTask::kALL) { + virtual void SetPerfAttributes(PerfAttr& perf_attrs) { + if (task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kMPI || + task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kALL) { const double t0 = GetTimeMPI(); perf_attrs.current_timer = [t0] { return GetTimeMPI() - t0; }; - } else if (task_->GetDynamicTypeOfTask() == ppc::core::TypeOfTask::kOMP) { + } else if (task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kOMP) { const double t0 = omp_get_wtime(); perf_attrs.current_timer = [t0] { return omp_get_wtime() - t0; }; - } else if (task_->GetDynamicTypeOfTask() == ppc::core::TypeOfTask::kSEQ || - task_->GetDynamicTypeOfTask() == ppc::core::TypeOfTask::kSTL || - task_->GetDynamicTypeOfTask() == ppc::core::TypeOfTask::kTBB) { + } else if (task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kSEQ || + task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kSTL || + task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kTBB) { const auto t0 = std::chrono::high_resolution_clock::now(); perf_attrs.current_timer = [&] { auto now = std::chrono::high_resolution_clock::now(); @@ -77,13 +80,13 @@ class BaseRunPerfTests : public ::testing::TestWithParam task_; + TaskPtr task_; }; template auto MakePerfTaskTuples(const std::string& settings_path) { - const auto name = std::string(GetNamespace()) + "_" + - ppc::core::GetStringTaskType(TaskType::GetStaticTypeOfTask(), settings_path); + const auto name = + std::string(GetNamespace()) + "_" + GetStringTaskType(TaskType::GetStaticTypeOfTask(), settings_path); - return std::make_tuple(std::make_tuple(ppc::core::TaskGetter, name, - ppc::core::PerfResults::TypeOfRunning::kPipeline), - std::make_tuple(ppc::core::TaskGetter, name, - ppc::core::PerfResults::TypeOfRunning::kTaskRun)); + return std::make_tuple(std::make_tuple(TaskGetter, name, PerfResults::TypeOfRunning::kPipeline), + std::make_tuple(TaskGetter, name, PerfResults::TypeOfRunning::kTaskRun)); } template diff --git a/modules/core/util/include/util.hpp b/modules/util/include/util.hpp similarity index 100% rename from modules/core/util/include/util.hpp rename to modules/util/include/util.hpp diff --git a/modules/core/util/src/func_test_util.cpp b/modules/util/src/func_test_util.cpp similarity index 78% rename from modules/core/util/src/func_test_util.cpp rename to modules/util/src/func_test_util.cpp index 6f6b19af7..47899659f 100644 --- a/modules/core/util/src/func_test_util.cpp +++ b/modules/util/src/func_test_util.cpp @@ -1,6 +1,6 @@ #include -#include "core/util/include/perf_test_util.hpp" +#include "util/include/perf_test_util.hpp" double ppc::util::GetTimeMPI() { return MPI_Wtime(); } diff --git a/modules/core/util/src/util.cpp b/modules/util/src/util.cpp similarity index 97% rename from modules/core/util/src/util.cpp rename to modules/util/src/util.cpp index 9d4c01a3d..8f776bbe0 100644 --- a/modules/core/util/src/util.cpp +++ b/modules/util/src/util.cpp @@ -1,4 +1,4 @@ -#include "core/util/include/util.hpp" +#include "util/include/util.hpp" #include #include diff --git a/modules/core/util/tests/util.cpp b/modules/util/tests/util.cpp similarity index 98% rename from modules/core/util/tests/util.cpp rename to modules/util/tests/util.cpp index 913773b0d..53450443f 100644 --- a/modules/core/util/tests/util.cpp +++ b/modules/util/tests/util.cpp @@ -1,4 +1,4 @@ -#include "core/util/include/util.hpp" +#include "util/include/util.hpp" #include diff --git a/tasks/common/runners/functional.cpp b/tasks/common/runners/functional.cpp index 443721579..7eb563375 100644 --- a/tasks/common/runners/functional.cpp +++ b/tasks/common/runners/functional.cpp @@ -1,12 +1,12 @@ #include -#include "core/runners/include/runners.hpp" -#include "core/util/include/util.hpp" #include "oneapi/tbb/global_control.h" +#include "runners/include/runners.hpp" +#include "util/include/util.hpp" int main(int argc, char** argv) { if (ppc::util::IsUnderMpirun()) { - return ppc::core::Init(argc, argv); + return ppc::runners::Init(argc, argv); } - return ppc::core::SimpleInit(argc, argv); + return ppc::runners::SimpleInit(argc, argv); } diff --git a/tasks/common/runners/performance.cpp b/tasks/common/runners/performance.cpp index 83b9bd261..10ee455c6 100644 --- a/tasks/common/runners/performance.cpp +++ b/tasks/common/runners/performance.cpp @@ -1,3 +1,3 @@ -#include "core/runners/include/runners.hpp" +#include "runners/include/runners.hpp" -int main(int argc, char** argv) { return ppc::core::Init(argc, argv); } +int main(int argc, char** argv) { return ppc::runners::Init(argc, argv); } diff --git a/tasks/example_processes/common/include/common.hpp b/tasks/example_processes/common/include/common.hpp index 1e953987b..127d96c4c 100644 --- a/tasks/example_processes/common/include/common.hpp +++ b/tasks/example_processes/common/include/common.hpp @@ -3,13 +3,13 @@ #include #include -#include "core/task/include/task.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_processes { using InType = int; using OutType = int; using TestType = std::tuple; -using BaseTask = ppc::core::Task; +using BaseTask = ppc::task::Task; } // namespace nesterov_a_test_task_processes diff --git a/tasks/example_processes/mpi/include/ops_mpi.hpp b/tasks/example_processes/mpi/include/ops_mpi.hpp index 7fc57c29f..dc128dc16 100644 --- a/tasks/example_processes/mpi/include/ops_mpi.hpp +++ b/tasks/example_processes/mpi/include/ops_mpi.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_processes/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_processes { class NesterovATestTaskMPI : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kMPI; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kMPI; } explicit NesterovATestTaskMPI(const InType &in); private: diff --git a/tasks/example_processes/mpi/src/ops_mpi.cpp b/tasks/example_processes/mpi/src/ops_mpi.cpp index b426c3325..d57719e7f 100644 --- a/tasks/example_processes/mpi/src/ops_mpi.cpp +++ b/tasks/example_processes/mpi/src/ops_mpi.cpp @@ -5,8 +5,8 @@ #include #include -#include "core/util/include/util.hpp" #include "example_processes/common/include/common.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_processes { diff --git a/tasks/example_processes/seq/include/ops_seq.hpp b/tasks/example_processes/seq/include/ops_seq.hpp index 3b8f03baf..0a893aa2d 100644 --- a/tasks/example_processes/seq/include/ops_seq.hpp +++ b/tasks/example_processes/seq/include/ops_seq.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_processes/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_processes { class NesterovATestTaskSEQ : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kSEQ; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kSEQ; } explicit NesterovATestTaskSEQ(const InType& in); private: diff --git a/tasks/example_processes/seq/src/ops_seq.cpp b/tasks/example_processes/seq/src/ops_seq.cpp index 7795d7424..f45af8e76 100644 --- a/tasks/example_processes/seq/src/ops_seq.cpp +++ b/tasks/example_processes/seq/src/ops_seq.cpp @@ -3,8 +3,8 @@ #include #include -#include "core/util/include/util.hpp" #include "example_processes/common/include/common.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_processes { diff --git a/tasks/example_processes/tests/functional/main.cpp b/tasks/example_processes/tests/functional/main.cpp index 113c611f4..f7b1a4171 100644 --- a/tasks/example_processes/tests/functional/main.cpp +++ b/tasks/example_processes/tests/functional/main.cpp @@ -12,11 +12,11 @@ #include #include -#include "core/util/include/func_test_util.hpp" -#include "core/util/include/util.hpp" #include "example_processes/common/include/common.hpp" #include "example_processes/mpi/include/ops_mpi.hpp" #include "example_processes/seq/include/ops_seq.hpp" +#include "util/include/func_test_util.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_processes { diff --git a/tasks/example_processes/tests/performance/main.cpp b/tasks/example_processes/tests/performance/main.cpp index 1526a7877..88042ab83 100644 --- a/tasks/example_processes/tests/performance/main.cpp +++ b/tasks/example_processes/tests/performance/main.cpp @@ -1,9 +1,9 @@ #include -#include "core/util/include/perf_test_util.hpp" #include "example_processes/common/include/common.hpp" #include "example_processes/mpi/include/ops_mpi.hpp" #include "example_processes/seq/include/ops_seq.hpp" +#include "util/include/perf_test_util.hpp" namespace nesterov_a_test_task_processes { diff --git a/tasks/example_threads/all/include/ops_all.hpp b/tasks/example_threads/all/include/ops_all.hpp index 9a2deade2..cea5c9704 100644 --- a/tasks/example_threads/all/include/ops_all.hpp +++ b/tasks/example_threads/all/include/ops_all.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_threads/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { class NesterovATestTaskALL : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kALL; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kALL; } explicit NesterovATestTaskALL(const InType &in); private: diff --git a/tasks/example_threads/all/src/ops_all.cpp b/tasks/example_threads/all/src/ops_all.cpp index 960ad344c..21e6024b8 100644 --- a/tasks/example_threads/all/src/ops_all.cpp +++ b/tasks/example_threads/all/src/ops_all.cpp @@ -7,9 +7,9 @@ #include #include -#include "core/util/include/util.hpp" #include "example_threads/common/include/common.hpp" #include "oneapi/tbb/parallel_for.h" +#include "util/include/util.hpp" namespace nesterov_a_test_task_threads { diff --git a/tasks/example_threads/common/include/common.hpp b/tasks/example_threads/common/include/common.hpp index 21a29015a..f75fe1779 100644 --- a/tasks/example_threads/common/include/common.hpp +++ b/tasks/example_threads/common/include/common.hpp @@ -3,13 +3,13 @@ #include #include -#include "core/task/include/task.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { using InType = int; using OutType = int; using TestType = std::tuple; -using BaseTask = ppc::core::Task; +using BaseTask = ppc::task::Task; } // namespace nesterov_a_test_task_threads diff --git a/tasks/example_threads/omp/include/ops_omp.hpp b/tasks/example_threads/omp/include/ops_omp.hpp index 1fc5cd4c8..1a0dfcca0 100644 --- a/tasks/example_threads/omp/include/ops_omp.hpp +++ b/tasks/example_threads/omp/include/ops_omp.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_threads/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { class NesterovATestTaskOMP : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kOMP; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kOMP; } explicit NesterovATestTaskOMP(const InType& in); private: diff --git a/tasks/example_threads/omp/src/ops_omp.cpp b/tasks/example_threads/omp/src/ops_omp.cpp index ee3f42df7..5666df9be 100644 --- a/tasks/example_threads/omp/src/ops_omp.cpp +++ b/tasks/example_threads/omp/src/ops_omp.cpp @@ -4,8 +4,8 @@ #include #include -#include "core/util/include/util.hpp" #include "example_threads/common/include/common.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_threads { diff --git a/tasks/example_threads/seq/include/ops_seq.hpp b/tasks/example_threads/seq/include/ops_seq.hpp index dccae8530..8519b85fe 100644 --- a/tasks/example_threads/seq/include/ops_seq.hpp +++ b/tasks/example_threads/seq/include/ops_seq.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_threads/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { class NesterovATestTaskSEQ : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kSEQ; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kSEQ; } explicit NesterovATestTaskSEQ(const InType& in); private: diff --git a/tasks/example_threads/seq/src/ops_seq.cpp b/tasks/example_threads/seq/src/ops_seq.cpp index f645d2d52..ce3cea398 100644 --- a/tasks/example_threads/seq/src/ops_seq.cpp +++ b/tasks/example_threads/seq/src/ops_seq.cpp @@ -3,8 +3,8 @@ #include #include -#include "core/util/include/util.hpp" #include "example_threads/common/include/common.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_threads { diff --git a/tasks/example_threads/stl/include/ops_stl.hpp b/tasks/example_threads/stl/include/ops_stl.hpp index 554ac1e37..b51034298 100644 --- a/tasks/example_threads/stl/include/ops_stl.hpp +++ b/tasks/example_threads/stl/include/ops_stl.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_threads/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { class NesterovATestTaskSTL : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kSTL; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kSTL; } explicit NesterovATestTaskSTL(const InType& in); private: diff --git a/tasks/example_threads/stl/src/ops_stl.cpp b/tasks/example_threads/stl/src/ops_stl.cpp index 2e84e479e..45397fd6c 100644 --- a/tasks/example_threads/stl/src/ops_stl.cpp +++ b/tasks/example_threads/stl/src/ops_stl.cpp @@ -5,8 +5,8 @@ #include #include -#include "core/util/include/util.hpp" #include "example_threads/common/include/common.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_threads { diff --git a/tasks/example_threads/tbb/include/ops_tbb.hpp b/tasks/example_threads/tbb/include/ops_tbb.hpp index d88ffafb5..0635d5935 100644 --- a/tasks/example_threads/tbb/include/ops_tbb.hpp +++ b/tasks/example_threads/tbb/include/ops_tbb.hpp @@ -1,13 +1,13 @@ #pragma once -#include "core/task/include/task.hpp" #include "example_threads/common/include/common.hpp" +#include "task/include/task.hpp" namespace nesterov_a_test_task_threads { class NesterovATestTaskTBB : public BaseTask { public: - static constexpr ppc::core::TypeOfTask GetStaticTypeOfTask() { return ppc::core::TypeOfTask::kTBB; } + static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { return ppc::task::TypeOfTask::kTBB; } explicit NesterovATestTaskTBB(const InType& in); private: diff --git a/tasks/example_threads/tbb/src/ops_tbb.cpp b/tasks/example_threads/tbb/src/ops_tbb.cpp index 9e3b37dbf..a392c99a9 100644 --- a/tasks/example_threads/tbb/src/ops_tbb.cpp +++ b/tasks/example_threads/tbb/src/ops_tbb.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #include "example_threads/common/include/common.hpp" diff --git a/tasks/example_threads/tests/functional/main.cpp b/tasks/example_threads/tests/functional/main.cpp index b3131329e..e34f21702 100644 --- a/tasks/example_threads/tests/functional/main.cpp +++ b/tasks/example_threads/tests/functional/main.cpp @@ -12,14 +12,14 @@ #include #include -#include "core/util/include/func_test_util.hpp" -#include "core/util/include/util.hpp" #include "example_threads/all/include/ops_all.hpp" #include "example_threads/common/include/common.hpp" #include "example_threads/omp/include/ops_omp.hpp" #include "example_threads/seq/include/ops_seq.hpp" #include "example_threads/stl/include/ops_stl.hpp" #include "example_threads/tbb/include/ops_tbb.hpp" +#include "util/include/func_test_util.hpp" +#include "util/include/util.hpp" namespace nesterov_a_test_task_threads { diff --git a/tasks/example_threads/tests/performance/main.cpp b/tasks/example_threads/tests/performance/main.cpp index a49731afa..970759c25 100644 --- a/tasks/example_threads/tests/performance/main.cpp +++ b/tasks/example_threads/tests/performance/main.cpp @@ -1,12 +1,12 @@ #include -#include "core/util/include/perf_test_util.hpp" #include "example_threads/all/include/ops_all.hpp" #include "example_threads/common/include/common.hpp" #include "example_threads/omp/include/ops_omp.hpp" #include "example_threads/seq/include/ops_seq.hpp" #include "example_threads/stl/include/ops_stl.hpp" #include "example_threads/tbb/include/ops_tbb.hpp" +#include "util/include/perf_test_util.hpp" namespace nesterov_a_test_task_threads {