From b6f7c09ac2bde567a60157ae1c7d90345cf9fb1e Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Sun, 12 Jan 2025 23:33:29 +0100 Subject: [PATCH 01/16] add all dir --- .github/labeler.yml | 2 + docs/user_guide/submit_work.rst | 5 +- tasks/CMakeLists.txt | 29 +++ tasks/all/example_mpi/data/test.txt | 1 + tasks/all/example_mpi/func_tests/main.cpp | 292 ++++++++++++++++++++++ tasks/all/example_mpi/include/ops_mpi.hpp | 48 ++++ tasks/all/example_mpi/perf_tests/main.cpp | 87 +++++++ tasks/all/example_mpi/src/ops_mpi.cpp | 103 ++++++++ tasks/all/example_omp/data/test.txt | 1 + tasks/all/example_omp/func_tests/main.cpp | 255 +++++++++++++++++++ tasks/all/example_omp/include/ops_omp.hpp | 40 +++ tasks/all/example_omp/perf_tests/main.cpp | 71 ++++++ tasks/all/example_omp/src/ops_omp.cpp | 89 +++++++ tasks/all/example_seq/data/test.txt | 1 + tasks/all/example_seq/func_tests/main.cpp | 151 +++++++++++ tasks/all/example_seq/include/ops_seq.hpp | 22 ++ tasks/all/example_seq/perf_tests/main.cpp | 80 ++++++ tasks/all/example_seq/src/ops_seq.cpp | 27 ++ tasks/all/example_stl/data/test.txt | 1 + tasks/all/example_stl/func_tests/main.cpp | 261 +++++++++++++++++++ tasks/all/example_stl/include/ops_stl.hpp | 43 ++++ tasks/all/example_stl/perf_tests/main.cpp | 80 ++++++ tasks/all/example_stl/src/ops_stl.cpp | 105 ++++++++ tasks/all/example_tbb/data/test.txt | 1 + tasks/all/example_tbb/func_tests/main.cpp | 254 +++++++++++++++++++ tasks/all/example_tbb/include/ops_tbb.hpp | 43 ++++ tasks/all/example_tbb/perf_tests/main.cpp | 73 ++++++ tasks/all/example_tbb/src/ops_tbb.cpp | 94 +++++++ tasks/all/runner.cpp | 69 +++++ 29 files changed, 2326 insertions(+), 2 deletions(-) create mode 100644 tasks/all/example_mpi/data/test.txt create mode 100644 tasks/all/example_mpi/func_tests/main.cpp create mode 100644 tasks/all/example_mpi/include/ops_mpi.hpp create mode 100644 tasks/all/example_mpi/perf_tests/main.cpp create mode 100644 tasks/all/example_mpi/src/ops_mpi.cpp create mode 100644 tasks/all/example_omp/data/test.txt create mode 100644 tasks/all/example_omp/func_tests/main.cpp create mode 100644 tasks/all/example_omp/include/ops_omp.hpp create mode 100644 tasks/all/example_omp/perf_tests/main.cpp create mode 100644 tasks/all/example_omp/src/ops_omp.cpp create mode 100644 tasks/all/example_seq/data/test.txt create mode 100644 tasks/all/example_seq/func_tests/main.cpp create mode 100644 tasks/all/example_seq/include/ops_seq.hpp create mode 100644 tasks/all/example_seq/perf_tests/main.cpp create mode 100644 tasks/all/example_seq/src/ops_seq.cpp create mode 100644 tasks/all/example_stl/data/test.txt create mode 100644 tasks/all/example_stl/func_tests/main.cpp create mode 100644 tasks/all/example_stl/include/ops_stl.hpp create mode 100644 tasks/all/example_stl/perf_tests/main.cpp create mode 100644 tasks/all/example_stl/src/ops_stl.cpp create mode 100644 tasks/all/example_tbb/data/test.txt create mode 100644 tasks/all/example_tbb/func_tests/main.cpp create mode 100644 tasks/all/example_tbb/include/ops_tbb.hpp create mode 100644 tasks/all/example_tbb/perf_tests/main.cpp create mode 100644 tasks/all/example_tbb/src/ops_tbb.cpp create mode 100644 tasks/all/runner.cpp diff --git a/.github/labeler.yml b/.github/labeler.yml index de42b5aa6..1fb12bf6b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,3 +1,5 @@ +'task:all': + - "tasks/all/**" 'task:mpi': - "tasks/mpi/**" 'task:omp': diff --git a/docs/user_guide/submit_work.rst b/docs/user_guide/submit_work.rst index 155a162fc..51362a28e 100644 --- a/docs/user_guide/submit_work.rst +++ b/docs/user_guide/submit_work.rst @@ -1,12 +1,13 @@ How to submit your work ======================== -- There are ``mpi``, ``omp``, ``seq``, ``stl``, ``tbb`` folders in the ``tasks`` directory. Move to a folder of your task. Create a directory named ``__``. +- There are ``all``, ``mpi``, ``omp``, ``seq``, ``stl``, ``tbb`` folders in the ``tasks`` directory. Move to a folder of your task. Create a directory named ``__``. Example: ``seq/nesterov_a_vector_sum``. Please name all tasks **with the same** name directory. If the ``seq`` task is named ``seq/nesterov_a_vector_sum``, then the ``omp`` task must be named ``omp/nesterov_a_vector_sum``. - Navigate into the newly created folder and begin your work on the task. The folder must contain only 4 directories with files: + - ``data`` - Directory with own data files for functional testing of the task. - ``func_tests`` - Directory with Google tests for functional testing of the task. - ``include`` - Directory for header files with function prototypes. - ``perf_tests`` - Directory with Google tests for performance testing. The number of tests must be 2: ``run_task`` and ``run_pipeline``. @@ -14,7 +15,7 @@ How to submit your work - There must be 10 executable files for running: - - ``__tests``. For example, ``omp_perf_tests`` - an executable file for performance tests of OpenMP practice tasks. + - ``__tests``. For example, ``omp_perf_tests`` - an executable file for performance tests of OpenMP practice tasks. - All prototypes and classes in the ``include`` directory must be namespace-escaped. Name your namespace as follows: diff --git a/tasks/CMakeLists.txt b/tasks/CMakeLists.txt index f8344ac07..0253dbfb2 100644 --- a/tasks/CMakeLists.txt +++ b/tasks/CMakeLists.txt @@ -30,6 +30,12 @@ else () message(WARNING "TBB tasks not build!") endif () +if (USE_MPI AND USE_OMP AND USE_SEQ AND USE_STL AND USE_TBB) + list(APPEND LIST_OF_TASKS "all") +else () + message(WARNING "ALL tasks not build!") +endif () + add_compile_definitions(PATH_TO_PPC_PROJECT="${CMAKE_SOURCE_DIR}") foreach(TASK_TYPE ${LIST_OF_TASKS}) @@ -101,6 +107,29 @@ foreach(TASK_TYPE ${LIST_OF_TASKS}) target_link_libraries(${EXEC_FUNC} PUBLIC boost_mpi boost_serialization) endif () elseif ("${MODULE_NAME}" STREQUAL "tbb") + add_dependencies(${EXEC_FUNC} ppc_onetbb) + target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_onetbb/install/lib) + if(NOT MSVC) + target_link_libraries(${EXEC_FUNC} PUBLIC tbb) + endif() + elseif ("${MODULE_NAME}" STREQUAL "all") + target_link_libraries(${EXEC_FUNC} PUBLIC Threads::Threads) + target_link_libraries(${EXEC_FUNC} PUBLIC ${OpenMP_libomp_LIBRARY}) + if( MPI_COMPILE_FLAGS ) + set_target_properties(${EXEC_FUNC} PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") + endif( MPI_COMPILE_FLAGS ) + + if( MPI_LINK_FLAGS ) + set_target_properties(${EXEC_FUNC} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}") + endif( MPI_LINK_FLAGS ) + target_link_libraries(${EXEC_FUNC} PUBLIC ${MPI_LIBRARIES}) + + add_dependencies(${EXEC_FUNC} ppc_boost) + target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_boost/install/lib) + if (NOT MSVC) + target_link_libraries(${EXEC_FUNC} PUBLIC boost_mpi boost_serialization) + endif () + add_dependencies(${EXEC_FUNC} ppc_onetbb) target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_onetbb/install/lib) if(NOT MSVC) diff --git a/tasks/all/example_mpi/data/test.txt b/tasks/all/example_mpi/data/test.txt new file mode 100644 index 000000000..8bc658371 --- /dev/null +++ b/tasks/all/example_mpi/data/test.txt @@ -0,0 +1 @@ +120 \ No newline at end of file diff --git a/tasks/all/example_mpi/func_tests/main.cpp b/tasks/all/example_mpi/func_tests/main.cpp new file mode 100644 index 000000000..c22598e57 --- /dev/null +++ b/tasks/all/example_mpi/func_tests/main.cpp @@ -0,0 +1,292 @@ +#include + +#include +#include +#include +#include +#include + +#include "mpi/example/include/ops_mpi.hpp" + +namespace { +std::vector GetRandomVector(int sz) { + std::random_device dev; + std::mt19937 gen(dev()); + std::vector vec(sz); + for (int i = 0; i < sz; i++) { + vec[i] = gen() % 100 - 50; + } + return vec; +} +} // namespace + +TEST(Parallel_Operations_MPI, Test_Sum) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_sum(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + const int count_size_vector = 120; + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_sum.data())); + task_data_par->outputs_count.emplace_back(global_sum.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_sum(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); + task_data_seq->outputs_count.emplace_back(reference_sum.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_sum[0], global_sum[0]); + } +} + +TEST(Parallel_Operations_MPI, Test_Diff) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_diff(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + const int count_size_vector = 240; + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_diff.data())); + task_data_par->outputs_count.emplace_back(global_diff.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_diff(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_diff.data())); + task_data_seq->outputs_count.emplace_back(reference_diff.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_diff[0], global_diff[0]); + } +} + +TEST(Parallel_Operations_MPI, Test_Diff_2) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_diff(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + const int count_size_vector = 120; + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_diff.data())); + task_data_par->outputs_count.emplace_back(global_diff.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_diff(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_diff.data())); + task_data_seq->outputs_count.emplace_back(reference_diff.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_diff[0], global_diff[0]); + } +} + +TEST(Parallel_Operations_MPI, Test_Max) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_max(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + const int count_size_vector = 240; + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_max.data())); + task_data_par->outputs_count.emplace_back(global_max.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_max(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_max.data())); + task_data_seq->outputs_count.emplace_back(reference_max.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_max[0], global_max[0]); + } +} + +TEST(Parallel_Operations_MPI, Test_Max_2) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_max(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + const int count_size_vector = 120; + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_max.data())); + task_data_par->outputs_count.emplace_back(global_max.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_max(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_max.data())); + task_data_seq->outputs_count.emplace_back(reference_max.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_max[0], global_max[0]); + } +} + +TEST(Parallel_Operations_MPI, Test_Max_2_File) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_max(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + + if (world.rank() == 0) { + std::string line; + std::ifstream test_file(ppc::core::GetAbsolutePath("mpi/example/data/test.txt")); + if (test_file.is_open()) { + getline(test_file, line); + } + test_file.close(); + + const int count_size_vector = std::stoi(line); + global_vec = GetRandomVector(count_size_vector); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_max.data())); + task_data_par->outputs_count.emplace_back(global_max.size()); + } + + nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); + ASSERT_EQ(test_mpi_task_parallel.validation(), true); + test_mpi_task_parallel.pre_processing(); + test_mpi_task_parallel.run(); + test_mpi_task_parallel.post_processing(); + + if (world.rank() == 0) { + // Create data + std::vector reference_max(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_seq->inputs_count.emplace_back(global_vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(reference_max.data())); + task_data_seq->outputs_count.emplace_back(reference_max.size()); + + // Create Task + nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); + ASSERT_EQ(test_mpi_task_sequential.validation(), true); + test_mpi_task_sequential.pre_processing(); + test_mpi_task_sequential.run(); + test_mpi_task_sequential.post_processing(); + + ASSERT_EQ(reference_max[0], global_max[0]); + } +} diff --git a/tasks/all/example_mpi/include/ops_mpi.hpp b/tasks/all/example_mpi/include/ops_mpi.hpp new file mode 100644 index 000000000..9b04fcc54 --- /dev/null +++ b/tasks/all/example_mpi/include/ops_mpi.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "core/task/include/task.hpp" + +namespace nesterov_a_test_task_mpi { + +class TestMPITaskSequential : public ppc::core::Task { + public: + explicit TestMPITaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +class TestMPITaskParallel : public ppc::core::Task { + public: + explicit TestMPITaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_, local_input_; + int res{}; + std::string ops; + boost::mpi::communicator world; +}; + +} // namespace nesterov_a_test_task_mpi \ No newline at end of file diff --git a/tasks/all/example_mpi/perf_tests/main.cpp b/tasks/all/example_mpi/perf_tests/main.cpp new file mode 100644 index 000000000..a18d819a3 --- /dev/null +++ b/tasks/all/example_mpi/perf_tests/main.cpp @@ -0,0 +1,87 @@ +#include + +#include +#include + +#include "core/perf/include/perf.hpp" +#include "mpi/example/include/ops_mpi.hpp" + +TEST(mpi_example_perf_test, test_pipeline_run) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_sum(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + int count_size_vector; + if (world.rank() == 0) { + count_size_vector = 120; + global_vec = std::vector(count_size_vector, 1); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_sum.data())); + task_data_par->outputs_count.emplace_back(global_sum.size()); + } + + auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); + ASSERT_EQ(test_mpi_task_parallel->validation(), true); + test_mpi_task_parallel->pre_processing(); + test_mpi_task_parallel->run(); + test_mpi_task_parallel->post_processing(); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const boost::mpi::timer current_timer; + perf_attr->current_timer = [&] { return current_timer.elapsed(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_mpi_task_parallel); + perf_analyzer->PipelineRun(perf_attr, perf_results); + if (world.rank() == 0) { + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count_size_vector, global_sum[0]); + } +} + +TEST(mpi_example_perf_test, test_task_run) { + boost::mpi::communicator world; + std::vector global_vec; + std::vector global_sum(1, 0); + // Create TaskData + auto task_data_par = std::make_shared(); + int count_size_vector; + if (world.rank() == 0) { + count_size_vector = 120; + global_vec = std::vector(count_size_vector, 1); + task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); + task_data_par->inputs_count.emplace_back(global_vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(global_sum.data())); + task_data_par->outputs_count.emplace_back(global_sum.size()); + } + + auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); + ASSERT_EQ(test_mpi_task_parallel->validation(), true); + test_mpi_task_parallel->pre_processing(); + test_mpi_task_parallel->run(); + test_mpi_task_parallel->post_processing(); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const boost::mpi::timer current_timer; + perf_attr->current_timer = [&] { return current_timer.elapsed(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_mpi_task_parallel); + perf_analyzer->TaskRun(perf_attr, perf_results); + if (world.rank() == 0) { + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count_size_vector, global_sum[0]); + } +} diff --git a/tasks/all/example_mpi/src/ops_mpi.cpp b/tasks/all/example_mpi/src/ops_mpi.cpp new file mode 100644 index 000000000..6a824f8c7 --- /dev/null +++ b/tasks/all/example_mpi/src/ops_mpi.cpp @@ -0,0 +1,103 @@ +#include "mpi/example/include/ops_mpi.hpp" + +#include +#include +#include +#include +#include +#include + +bool nesterov_a_test_task_mpi::TestMPITaskSequential::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 0; + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskSequential::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_mpi::TestMPITaskSequential::run_impl() { + if (ops == "+") { + res = std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops == "-") { + res = -std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops == "max") { + res = *std::ranges::max_element(input_); + } + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskSequential::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskParallel::pre_processing_impl() { + unsigned int delta = 0; + if (world.rank() == 0) { + delta = taskData->inputs_count[0] / world.size(); + } + broadcast(world, delta, 0); + + if (world.rank() == 0) { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + for (int proc = 1; proc < world.size(); proc++) { + world.send(proc, 0, input_.data() + (proc * delta), delta); + } + } + local_input_ = std::vector(delta); + if (world.rank() == 0) { + local_input_ = std::vector(input_.begin(), input_.begin() + delta); + } else { + world.recv(0, 0, local_input_.data(), delta); + } + // Init value for output + res = 0; + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskParallel::validation_impl() { + if (world.rank() == 0) { + // Check count elements of output + return taskData->outputs_count[0] == 1; + } + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskParallel::run_impl() { + int local_res; + if (ops == "+") { + local_res = std::accumulate(local_input_.begin(), local_input_.end(), 0); + } else if (ops == "-") { + local_res = -std::accumulate(local_input_.begin(), local_input_.end(), 0); + } else if (ops == "max") { + local_res = *std::ranges::max_element(local_input_); + } + + if (ops == "+" || ops == "-") { + reduce(world, local_res, res, std::plus(), 0); + } else if (ops == "max") { + reduce(world, local_res, res, boost::mpi::maximum(), 0); + } + return true; +} + +bool nesterov_a_test_task_mpi::TestMPITaskParallel::post_processing_impl() { + if (world.rank() == 0) { + reinterpret_cast(taskData->outputs[0])[0] = res; + } + return true; +} diff --git a/tasks/all/example_omp/data/test.txt b/tasks/all/example_omp/data/test.txt new file mode 100644 index 000000000..7813681f5 --- /dev/null +++ b/tasks/all/example_omp/data/test.txt @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/tasks/all/example_omp/func_tests/main.cpp b/tasks/all/example_omp/func_tests/main.cpp new file mode 100644 index 000000000..73f357b9a --- /dev/null +++ b/tasks/all/example_omp/func_tests/main.cpp @@ -0,0 +1,255 @@ +#include + +#include +#include +#include + +#include "omp/example/include/ops_omp.hpp" + +namespace { +std::vector GetRandomVector(int sz) { + std::random_device dev; + std::mt19937 gen(dev()); + std::vector vec(sz); + for (int i = 0; i < sz; i++) { + vec[i] = gen() % 100 - 50; + } + return vec; +} +} // namespace + +TEST(Parallel_Operations_OpenMP, Test_Sum) { + std::vector vec = GetRandomVector(100); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_OpenMP, Test_Diff) { + std::vector vec = GetRandomVector(100); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_OpenMP, Test_Diff_2) { + std::vector vec = GetRandomVector(10); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_OpenMP, Test_Mult) { + std::vector vec = GetRandomVector(10); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_OpenMP, Test_Mult_2) { + std::vector vec = GetRandomVector(5); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { + std::string line; + std::ifstream test_file(ppc::core::GetAbsolutePath("omp/example/data/test.txt")); + if (test_file.is_open()) { + getline(test_file, line); + } + test_file.close(); + + std::vector vec = GetRandomVector(std::stoi(line)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_omp_task_sequential.validation(), true); + test_omp_task_sequential.pre_processing(); + test_omp_task_sequential.run(); + test_omp_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_omp_task_parallel.validation(), true); + test_omp_task_parallel.pre_processing(); + test_omp_task_parallel.run(); + test_omp_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} diff --git a/tasks/all/example_omp/include/ops_omp.hpp b/tasks/all/example_omp/include/ops_omp.hpp new file mode 100644 index 000000000..6cf742b80 --- /dev/null +++ b/tasks/all/example_omp/include/ops_omp.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include +#include + +#include "core/task/include/task.hpp" + +namespace nesterov_a_test_task_omp { + +class TestOMPTaskSequential : public ppc::core::Task { + public: + explicit TestOMPTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +class TestOMPTaskParallel : public ppc::core::Task { + public: + explicit TestOMPTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +} // namespace nesterov_a_test_task_omp \ No newline at end of file diff --git a/tasks/all/example_omp/perf_tests/main.cpp b/tasks/all/example_omp/perf_tests/main.cpp new file mode 100644 index 000000000..38b3daaa0 --- /dev/null +++ b/tasks/all/example_omp/perf_tests/main.cpp @@ -0,0 +1,71 @@ +#include +#include + +#include + +#include "core/perf/include/perf.hpp" +#include "omp/example/include/ops_omp.hpp" + +TEST(openmp_example_perf_test, test_pipeline_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_omp = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + perf_attr->current_timer = [&] { return omp_get_wtime(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_omp); + perf_analyzer->PipelineRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); +} + +TEST(openmp_example_perf_test, test_task_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_omp = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + perf_attr->current_timer = [&] { return omp_get_wtime(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_omp); + perf_analyzer->TaskRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); +} diff --git a/tasks/all/example_omp/src/ops_omp.cpp b/tasks/all/example_omp/src/ops_omp.cpp new file mode 100644 index 000000000..0666e6bbe --- /dev/null +++ b/tasks/all/example_omp/src/ops_omp.cpp @@ -0,0 +1,89 @@ +#include "omp/example/include/ops_omp.hpp" + +#include + +#include +#include +#include +#include +#include + +bool nesterov_a_test_task_omp::TestOMPTaskSequential::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 1; + return true; +} + +bool nesterov_a_test_task_omp::TestOMPTaskSequential::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_omp::TestOMPTaskSequential::run_impl() { + if (ops == "+") { + res = std::accumulate(input_.begin(), input_.end(), 1); + } else if (ops == "-") { + res -= std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops == "*") { + res = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); + } + return true; +} + +bool nesterov_a_test_task_omp::TestOMPTaskSequential::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} + +bool nesterov_a_test_task_omp::TestOMPTaskParallel::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 1; + return true; +} + +bool nesterov_a_test_task_omp::TestOMPTaskParallel::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_omp::TestOMPTaskParallel::run_impl() { + double start = omp_get_wtime(); + auto temp_res = res; + if (ops == "+") { +#pragma omp parallel for reduction(+ : temp_res) + for (int i = 0; i < static_cast(input_.size()); i++) { + temp_res += input_[i]; + } + } else if (ops == "-") { +#pragma omp parallel for reduction(- : temp_res) + for (int i = 0; i < static_cast(input_.size()); i++) { + temp_res -= input_[i]; + } + } else if (ops == "*") { +#pragma omp parallel for reduction(* : temp_res) + for (int i = 0; i < static_cast(input_.size()); i++) { + temp_res *= input_[i]; + } + } + res = temp_res; + double finish = omp_get_wtime(); + std::cout << "How measure time in OpenMP: " << finish - start << '\n'; + return true; +} + +bool nesterov_a_test_task_omp::TestOMPTaskParallel::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} diff --git a/tasks/all/example_seq/data/test.txt b/tasks/all/example_seq/data/test.txt new file mode 100644 index 000000000..105d7d9ad --- /dev/null +++ b/tasks/all/example_seq/data/test.txt @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/tasks/all/example_seq/func_tests/main.cpp b/tasks/all/example_seq/func_tests/main.cpp new file mode 100644 index 000000000..c00a899a9 --- /dev/null +++ b/tasks/all/example_seq/func_tests/main.cpp @@ -0,0 +1,151 @@ +#include + +#include +#include + +#include "seq/example/include/ops_seq.hpp" + +TEST(Sequential, Test_Sum_10) { + const int count = 10; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} + +TEST(Sequential, Test_Sum_20) { + const int count = 20; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} + +TEST(Sequential, Test_Sum_50) { + const int count = 50; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} + +TEST(Sequential, Test_Sum_70) { + const int count = 70; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} + +TEST(Sequential, Test_Sum_100) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} + +TEST(Sequential, Test_Sum_100_From_File) { + std::string line; + std::ifstream test_file(ppc::core::GetAbsolutePath("seq/example/data/test.txt")); + if (test_file.is_open()) { + getline(test_file, line); + } + test_file.close(); + + const int count = std::stoi(line); + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); + ASSERT_EQ(test_task_sequential.validation(), true); + test_task_sequential.pre_processing(); + test_task_sequential.run(); + test_task_sequential.post_processing(); + ASSERT_EQ(count, out[0]); +} diff --git a/tasks/all/example_seq/include/ops_seq.hpp b/tasks/all/example_seq/include/ops_seq.hpp new file mode 100644 index 000000000..5f68f5ecb --- /dev/null +++ b/tasks/all/example_seq/include/ops_seq.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#include "core/task/include/task.hpp" + +namespace nesterov_a_test_task_seq { + +class TestTaskSequential : public ppc::core::Task { + public: + explicit TestTaskSequential(ppc::core::TaskDataPtr taskData_) : Task(std::move(taskData_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + int input_{}, res{}; +}; + +} // namespace nesterov_a_test_task_seq \ No newline at end of file diff --git a/tasks/all/example_seq/perf_tests/main.cpp b/tasks/all/example_seq/perf_tests/main.cpp new file mode 100644 index 000000000..a308a51ed --- /dev/null +++ b/tasks/all/example_seq/perf_tests/main.cpp @@ -0,0 +1,80 @@ +#include + +#include + +#include "core/perf/include/perf.hpp" +#include "seq/example/include/ops_seq.hpp" + +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 + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_sequential = std::make_shared(task_data_seq); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = std::chrono::high_resolution_clock::now(); + perf_attr->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 perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_sequential); + perf_analyzer->PipelineRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count, out[0]); +} + +TEST(sequential_example_perf_test, test_task_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_sequential = std::make_shared(task_data_seq); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = std::chrono::high_resolution_clock::now(); + perf_attr->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 perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_sequential); + perf_analyzer->TaskRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count, out[0]); +} diff --git a/tasks/all/example_seq/src/ops_seq.cpp b/tasks/all/example_seq/src/ops_seq.cpp new file mode 100644 index 000000000..1051f75f7 --- /dev/null +++ b/tasks/all/example_seq/src/ops_seq.cpp @@ -0,0 +1,27 @@ +#include "seq/example/include/ops_seq.hpp" + +#include + +bool nesterov_a_test_task_seq::TestTaskSequential::pre_processing_impl() { + // Init value for input and output + input_ = reinterpret_cast(taskData->inputs[0])[0]; + res = 0; + return true; +} + +bool nesterov_a_test_task_seq::TestTaskSequential::validation_impl() { + // Check count elements of output + return taskData->inputs_count[0] == 1 && taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_seq::TestTaskSequential::run_impl() { + for (int i = 0; i < input_; i++) { + res++; + } + return true; +} + +bool nesterov_a_test_task_seq::TestTaskSequential::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} diff --git a/tasks/all/example_stl/data/test.txt b/tasks/all/example_stl/data/test.txt new file mode 100644 index 000000000..3f10ffe7a --- /dev/null +++ b/tasks/all/example_stl/data/test.txt @@ -0,0 +1 @@ +15 \ No newline at end of file diff --git a/tasks/all/example_stl/func_tests/main.cpp b/tasks/all/example_stl/func_tests/main.cpp new file mode 100644 index 000000000..ad4701309 --- /dev/null +++ b/tasks/all/example_stl/func_tests/main.cpp @@ -0,0 +1,261 @@ +#include + +#include +#include +#include +#include + +#include "stl/example/include/ops_stl.hpp" + +namespace { +std::vector GetRandomVector(int sz) { + std::random_device dev; + std::mt19937 gen(dev()); + std::vector vec(sz); + for (int i = 0; i < sz; i++) { + vec[i] = gen() % 100 - 50; + } + return vec; +} +} // namespace + +TEST(Parallel_Operations_STL_Threads, Test_Sum) { + auto nthreads = std::thread::hardware_concurrency() * 10; + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_STL_Threads, Test_Sum_2) { + auto nthreads = std::thread::hardware_concurrency() * 11; + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_STL_Threads, Test_Sum_3) { + auto nthreads = std::thread::hardware_concurrency() * 13; + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_STL_Threads, Test_Diff) { + auto nthreads = std::thread::hardware_concurrency() * 14; + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { + auto nthreads = std::thread::hardware_concurrency() * 15; + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { + std::string line; + std::ifstream test_file(ppc::core::GetAbsolutePath("stl/example/data/test.txt")); + if (test_file.is_open()) { + getline(test_file, line); + } + test_file.close(); + + auto nthreads = std::thread::hardware_concurrency() * std::stoi(line); + std::vector vec = GetRandomVector(static_cast(nthreads)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_stl_task_sequential.validation(), true); + test_stl_task_sequential.pre_processing(); + test_stl_task_sequential.run(); + test_stl_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_stl_task_parallel.validation(), true); + test_stl_task_parallel.pre_processing(); + test_stl_task_parallel.run(); + test_stl_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} diff --git a/tasks/all/example_stl/include/ops_stl.hpp b/tasks/all/example_stl/include/ops_stl.hpp new file mode 100644 index 000000000..66a611161 --- /dev/null +++ b/tasks/all/example_stl/include/ops_stl.hpp @@ -0,0 +1,43 @@ +#ifndef TASKS_EXAMPLES_TEST_STD_OPS_STD_H_ +#define TASKS_EXAMPLES_TEST_STD_OPS_STD_H_ + +#include +#include + +#include "core/task/include/task.hpp" + +namespace nesterov_a_test_task_stl { + +class TestSTLTaskSequential : public ppc::core::Task { + public: + explicit TestSTLTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +class TestSTLTaskParallel : public ppc::core::Task { + public: + explicit TestSTLTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +} // namespace nesterov_a_test_task_stl + +#endif // TASKS_EXAMPLES_TEST_STD_OPS_STD_H_ diff --git a/tasks/all/example_stl/perf_tests/main.cpp b/tasks/all/example_stl/perf_tests/main.cpp new file mode 100644 index 000000000..66bdc42f3 --- /dev/null +++ b/tasks/all/example_stl/perf_tests/main.cpp @@ -0,0 +1,80 @@ +#include + +#include + +#include "core/perf/include/perf.hpp" +#include "stl/example/include/ops_stl.hpp" + +TEST(stl_example_perf_test, test_pipeline_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_stl = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = std::chrono::high_resolution_clock::now(); + perf_attr->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 perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_stl); + perf_analyzer->PipelineRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count, out[0]); +} + +TEST(stl_example_perf_test, test_task_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_stl = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = std::chrono::high_resolution_clock::now(); + perf_attr->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 perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_stl); + perf_analyzer->TaskRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count, out[0]); +} diff --git a/tasks/all/example_stl/src/ops_stl.cpp b/tasks/all/example_stl/src/ops_stl.cpp new file mode 100644 index 000000000..46cf82ddf --- /dev/null +++ b/tasks/all/example_stl/src/ops_stl.cpp @@ -0,0 +1,105 @@ +#include "stl/example/include/ops_stl.hpp" + +#include +#include +#include +#include +#include +#include +#include + +bool nesterov_a_test_task_stl::TestSTLTaskSequential::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto *tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 0; + return true; +} + +bool nesterov_a_test_task_stl::TestSTLTaskSequential::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_stl::TestSTLTaskSequential::run_impl() { + if (ops == "+") { + res = std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops == "-") { + res -= std::accumulate(input_.begin(), input_.end(), 0); + } + return true; +} + +bool nesterov_a_test_task_stl::TestSTLTaskSequential::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} + +namespace { +std::mutex my_mutex; + +void AtomOps(std::vector vec, const std::string &ops, std::promise &&pr) { + auto sz = vec.size(); + int reduction_elem = 0; + if (ops == "+") { + for (size_t i = 0; i < sz; i++) { + std::lock_guard my_lock(my_mutex); + reduction_elem += vec[i]; + } + } else if (ops == "-") { + for (size_t i = 0; i < sz; i++) { + std::lock_guard my_lock(my_mutex); + reduction_elem -= vec[i]; + } + } + pr.set_value(reduction_elem); +} +} // namespace + +bool nesterov_a_test_task_stl::TestSTLTaskParallel::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto *tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 0; + return true; +} + +bool nesterov_a_test_task_stl::TestSTLTaskParallel::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_stl::TestSTLTaskParallel::run_impl() { + const auto nthreads = std::thread::hardware_concurrency(); + const auto delta = (input_.end() - input_.begin()) / nthreads; + + auto *promises = new std::promise[nthreads]; + auto *futures = new std::future[nthreads]; + auto *threads = new std::thread[nthreads]; + + for (unsigned i = 0; i < nthreads; i++) { + futures[i] = promises[i].get_future(); + std::vector tmp_vec(input_.begin() + i * delta, input_.begin() + (i + 1) * delta); + threads[i] = std::thread(AtomOps, tmp_vec, ops, std::move(promises[i])); + threads[i].join(); + res += futures[i].get(); + } + + delete[] promises; + delete[] futures; + delete[] threads; + return true; +} + +bool nesterov_a_test_task_stl::TestSTLTaskParallel::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} diff --git a/tasks/all/example_tbb/data/test.txt b/tasks/all/example_tbb/data/test.txt new file mode 100644 index 000000000..7813681f5 --- /dev/null +++ b/tasks/all/example_tbb/data/test.txt @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/tasks/all/example_tbb/func_tests/main.cpp b/tasks/all/example_tbb/func_tests/main.cpp new file mode 100644 index 000000000..93bde0295 --- /dev/null +++ b/tasks/all/example_tbb/func_tests/main.cpp @@ -0,0 +1,254 @@ +#include + +#include +#include +#include + +#include "tbb/example/include/ops_tbb.hpp" + +namespace { +std::vector GetRandomVector(int sz) { + std::random_device dev; + std::mt19937 gen(dev()); + std::vector vec(sz); + for (int i = 0; i < sz; i++) { + vec[i] = gen() % 100 - 50; + } + return vec; +} +} // namespace + +TEST(Parallel_Operations_TBB, Test_Sum) { + std::vector vec = GetRandomVector(100); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "+"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "+"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_TBB, Test_Diff) { + std::vector vec = GetRandomVector(100); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_TBB, Test_Diff_2) { + std::vector vec = GetRandomVector(50); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "-"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "-"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_TBB, Test_Mult) { + std::vector vec = GetRandomVector(10); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_TBB, Test_Mult_2) { + std::vector vec = GetRandomVector(5); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} + +TEST(Parallel_Operations_TBB, Test_Mult_2_File) { + std::string line; + std::ifstream test_file(ppc::core::GetAbsolutePath("tbb/example/data/test.txt")); + if (test_file.is_open()) { + getline(test_file, line); + } + test_file.close(); + + std::vector vec = GetRandomVector(std::stoi(line)); + // Create data + std::vector ref_res(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_seq->inputs_count.emplace_back(vec.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(ref_res.data())); + task_data_seq->outputs_count.emplace_back(ref_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); + ASSERT_EQ(test_tbb_task_sequential.validation(), true); + test_tbb_task_sequential.pre_processing(); + test_tbb_task_sequential.run(); + test_tbb_task_sequential.post_processing(); + + // Create data + std::vector par_res(1, 0); + + // Create TaskData + auto task_data_par = std::make_shared(); + task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); + task_data_par->inputs_count.emplace_back(vec.size()); + task_data_par->outputs.emplace_back(reinterpret_cast(par_res.data())); + task_data_par->outputs_count.emplace_back(par_res.size()); + + // Create Task + nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); + ASSERT_EQ(test_tbb_task_parallel.validation(), true); + test_tbb_task_parallel.pre_processing(); + test_tbb_task_parallel.run(); + test_tbb_task_parallel.post_processing(); + ASSERT_EQ(ref_res[0], par_res[0]); +} diff --git a/tasks/all/example_tbb/include/ops_tbb.hpp b/tasks/all/example_tbb/include/ops_tbb.hpp new file mode 100644 index 000000000..0d212c986 --- /dev/null +++ b/tasks/all/example_tbb/include/ops_tbb.hpp @@ -0,0 +1,43 @@ +#ifndef TASKS_EXAMPLES_TEST_TBB_OPS_TBB_H_ +#define TASKS_EXAMPLES_TEST_TBB_OPS_TBB_H_ + +#include +#include + +#include "core/task/include/task.hpp" + +namespace nesterov_a_test_task_tbb { + +class TestTBBTaskSequential : public ppc::core::Task { + public: + explicit TestTBBTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +class TestTBBTaskParallel : public ppc::core::Task { + public: + explicit TestTBBTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) + : Task(std::move(taskData_)), ops(std::move(ops_)) {} + bool pre_processing_impl() override; + bool validation_impl() override; + bool run_impl() override; + bool post_processing_impl() override; + + private: + std::vector input_; + int res{}; + std::string ops; +}; + +} // namespace nesterov_a_test_task_tbb + +#endif // TASKS_EXAMPLES_TEST_TBB_OPS_TBB_H_ diff --git a/tasks/all/example_tbb/perf_tests/main.cpp b/tasks/all/example_tbb/perf_tests/main.cpp new file mode 100644 index 000000000..db04bc1e2 --- /dev/null +++ b/tasks/all/example_tbb/perf_tests/main.cpp @@ -0,0 +1,73 @@ +#include +#include + +#include + +#include "core/perf/include/perf.hpp" +#include "tbb/example/include/ops_tbb.hpp" + +TEST(tbb_example_perf_test, test_pipeline_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_tbb = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = oneapi::tbb::tick_count::now(); + perf_attr->current_timer = [&] { return (oneapi::tbb::tick_count::now() - t0).seconds(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_tbb); + perf_analyzer->PipelineRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); +} + +TEST(tbb_example_perf_test, test_task_run) { + const int count = 100; + + // Create data + std::vector in(1, count); + std::vector out(1, 0); + + // Create TaskData + auto task_data_seq = std::make_shared(); + task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); + task_data_seq->inputs_count.emplace_back(in.size()); + task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); + task_data_seq->outputs_count.emplace_back(out.size()); + + // Create Task + auto test_task_tbb = std::make_shared(task_data_seq, "+"); + + // Create Perf attributes + auto perf_attr = std::make_shared(); + perf_attr->num_running = 10; + const auto t0 = oneapi::tbb::tick_count::now(); + perf_attr->current_timer = [&] { return (oneapi::tbb::tick_count::now() - t0).seconds(); }; + + // Create and init perf results + auto perf_results = std::make_shared(); + + // Create Perf analyzer + auto perf_analyzer = std::make_shared(test_task_tbb); + perf_analyzer->TaskRun(perf_attr, perf_results); + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); +} diff --git a/tasks/all/example_tbb/src/ops_tbb.cpp b/tasks/all/example_tbb/src/ops_tbb.cpp new file mode 100644 index 000000000..e18f2217c --- /dev/null +++ b/tasks/all/example_tbb/src/ops_tbb.cpp @@ -0,0 +1,94 @@ +#include "tbb/example/include/ops_tbb.hpp" + +#include + +#include +#include +#include +#include +#include +#include + +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 1; + return true; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::run_impl() { + if (ops == "+") { + res = std::accumulate(input_.begin(), input_.end(), 1); + } else if (ops == "-") { + res -= std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops == "*") { + res = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); + } + return true; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::pre_processing_impl() { + // Init vectors + input_ = std::vector(taskData->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); + for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_[i] = tmp_ptr[i]; + } + // Init value for output + res = 1; + return true; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::validation_impl() { + // Check count elements of output + return taskData->outputs_count[0] == 1; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::run_impl() { + if (ops == "+") { + res += oneapi::tbb::parallel_reduce( + oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 0, + [](tbb::blocked_range::iterator> r, int running_total) { + running_total += std::accumulate(r.begin(), r.end(), 0); + return running_total; + }, + std::plus<>()); + } else if (ops == "-") { + res -= oneapi::tbb::parallel_reduce( + oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 0, + [](tbb::blocked_range::iterator> r, int running_total) { + running_total += std::accumulate(r.begin(), r.end(), 0); + return running_total; + }, + std::plus<>()); + } else if (ops == "*") { + res *= oneapi::tbb::parallel_reduce( + oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 1, + [](tbb::blocked_range::iterator> r, int running_total) { + running_total *= std::accumulate(r.begin(), r.end(), 1, std::multiplies<>()); + return running_total; + }, + std::multiplies<>()); + } + return true; +} + +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::post_processing_impl() { + reinterpret_cast(taskData->outputs[0])[0] = res; + return true; +} diff --git a/tasks/all/runner.cpp b/tasks/all/runner.cpp new file mode 100644 index 000000000..dc5256667 --- /dev/null +++ b/tasks/all/runner.cpp @@ -0,0 +1,69 @@ +#include + +#include +#include +#include + +class UnreadMessagesDetector : public ::testing::EmptyTestEventListener { + public: + UnreadMessagesDetector(boost::mpi::communicator com) : com_(std::move(com)) {} + + void OnTestEnd(const ::testing::TestInfo& test_info) override { + com_.barrier(); + if (const auto msg = com_.iprobe(boost::mpi::any_source, boost::mpi::any_tag)) { + fprintf( + stderr, + "[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n", + com_.rank(), test_info.test_suite_name(), test_info.name(), msg->source(), msg->tag()); + exit(2); + } + com_.barrier(); + } + + private: + boost::mpi::communicator com_; +}; + +class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener { + public: + WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base, boost::mpi::communicator com) + : base_(std::move(base)), com_(std::move(com)) {} + + void OnTestEnd(const ::testing::TestInfo& test_info) override { + if (test_info.result()->Passed()) { + return; + } + PrintProcessRank(); + base_->OnTestEnd(test_info); + } + + void OnTestPartResult(const ::testing::TestPartResult& test_part_result) override { + if (test_part_result.passed() || test_part_result.skipped()) { + return; + } + PrintProcessRank(); + base_->OnTestPartResult(test_part_result); + } + + private: + void PrintProcessRank() const { printf(" [ PROCESS %d ] ", com_.rank()); } + + std::shared_ptr<::testing::TestEventListener> base_; + boost::mpi::communicator com_; +}; + +int main(int argc, char** argv) { + boost::mpi::environment env(argc, argv); + boost::mpi::communicator world; + + ::testing::InitGoogleTest(&argc, argv); + + auto& listeners = ::testing::UnitTest::GetInstance()->listeners(); + if (world.rank() != 0 && (argc < 2 || argv[1] != std::string("--print-workers"))) { + auto* listener = listeners.Release(listeners.default_result_printer()); + listeners.Append(new WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener>(listener), world)); + } + listeners.Append(new UnreadMessagesDetector(world)); + + return RUN_ALL_TESTS(); +} From e3c00df9dc93a89d81a49e8b11c65876315c76a7 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Sun, 12 Jan 2025 23:49:09 +0100 Subject: [PATCH 02/16] fix scripts --- scripts/create_perf_table.py | 2 +- scripts/run.bat | 2 ++ scripts/run_mpi.sh | 3 +++ scripts/run_perf_collector.bat | 1 + scripts/run_perf_collector.sh | 2 ++ scripts/run_perf_count_checker.sh | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/create_perf_table.py b/scripts/create_perf_table.py index bd9b84283..d33b26aff 100644 --- a/scripts/create_perf_table.py +++ b/scripts/create_perf_table.py @@ -11,7 +11,7 @@ logs_path = os.path.abspath(args.input) xlsx_path = os.path.abspath(args.output) -list_of_type_of_tasks = ["mpi", "omp", "seq", "stl", "tbb"] +list_of_type_of_tasks = ["all", "mpi", "omp", "seq", "stl", "tbb"] result_tables = {"pipeline": {}, "task_run": {}} set_of_task_name = [] diff --git a/scripts/run.bat b/scripts/run.bat index 9c82be453..bc20417e3 100644 --- a/scripts/run.bat +++ b/scripts/run.bat @@ -9,7 +9,9 @@ if "%CLANG_BUILD%" NEQ "1" build\bin\sample_omp.exe build\bin\sample_stl.exe build\bin\sample_tbb.exe +if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\all_func_tests.exe --gtest_repeat=10 || exit 1 if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\mpi_func_tests.exe --gtest_repeat=10 || exit 1 +if "%CLANG_BUILD%" NEQ "1" build\bin\all_func_tests.exe || exit 1 if "%CLANG_BUILD%" NEQ "1" build\bin\mpi_func_tests.exe || exit 1 if "%CLANG_BUILD%" NEQ "1" build\bin\omp_func_tests.exe --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating || exit 1 build\bin\seq_func_tests.exe --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating || exit 1 diff --git a/scripts/run_mpi.sh b/scripts/run_mpi.sh index b2fd19792..65bc2b0ba 100644 --- a/scripts/run_mpi.sh +++ b/scripts/run_mpi.sh @@ -4,6 +4,7 @@ if [[ $OSTYPE == "linux-gnu" && -z "$ASAN_RUN" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/core_func_tests valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/ref_func_tests +# valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/all_func_tests # valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/mpi_func_tests fi @@ -14,10 +15,12 @@ if [[ -z "$ASAN_RUN" ]]; then if [[ $OSTYPE == "linux-gnu" ]]; then mpirun --oversubscribe -np $PROC_COUNT ./build/bin/sample_mpi mpirun --oversubscribe -np $PROC_COUNT ./build/bin/sample_mpi_boost + mpirun --oversubscribe -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating mpirun --oversubscribe -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating elif [[ $OSTYPE == "darwin"* ]]; then mpirun -np $PROC_COUNT ./build/bin/sample_mpi mpirun -np $PROC_COUNT ./build/bin/sample_mpi_boost + mpirun -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating mpirun -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating fi fi diff --git a/scripts/run_perf_collector.bat b/scripts/run_perf_collector.bat index 7beb05df4..e5ac46cca 100644 --- a/scripts/run_perf_collector.bat +++ b/scripts/run_perf_collector.bat @@ -1,3 +1,4 @@ +REM mpiexec -np 4 build\bin\all_perf_tests.exe REM mpiexec -np 4 build\bin\mpi_perf_tests.exe build\bin\omp_perf_tests.exe build\bin\seq_perf_tests.exe diff --git a/scripts/run_perf_collector.sh b/scripts/run_perf_collector.sh index 124620faf..a27c18bca 100644 --- a/scripts/run_perf_collector.sh +++ b/scripts/run_perf_collector.sh @@ -2,8 +2,10 @@ if [[ -z "$ASAN_RUN" ]]; then if [[ $OSTYPE == "linux-gnu" ]]; then + mpirun --oversubscribe -np 4 ./build/bin/all_perf_tests mpirun --oversubscribe -np 4 ./build/bin/mpi_perf_tests elif [[ $OSTYPE == "darwin"* ]]; then + mpirun -np 2 ./build/bin/all_perf_tests mpirun -np 2 ./build/bin/mpi_perf_tests fi fi diff --git a/scripts/run_perf_count_checker.sh b/scripts/run_perf_count_checker.sh index 180b1d695..b470a4bf4 100644 --- a/scripts/run_perf_count_checker.sh +++ b/scripts/run_perf_count_checker.sh @@ -40,6 +40,7 @@ run_check() { fi } +run_check "all" run_check "mpi" run_check "omp" run_check "seq" From 3fd82a3105556c2966dff3583f2d2af7ae0f7211 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Mon, 13 Jan 2025 19:49:21 +0100 Subject: [PATCH 03/16] update examples --- tasks/all/example_mpi/func_tests/main.cpp | 120 +++++++++++----------- tasks/all/example_mpi/include/ops_mpi.hpp | 34 +++--- tasks/all/example_mpi/perf_tests/main.cpp | 20 ++-- tasks/all/example_mpi/src/ops_mpi.cpp | 86 ++++++++-------- tasks/all/example_omp/func_tests/main.cpp | 120 +++++++++++----------- tasks/all/example_omp/include/ops_omp.hpp | 32 +++--- tasks/all/example_omp/perf_tests/main.cpp | 4 +- tasks/all/example_omp/src/ops_omp.cpp | 62 +++++------ tasks/all/example_seq/func_tests/main.cpp | 60 +++++------ tasks/all/example_seq/include/ops_seq.hpp | 12 +-- tasks/all/example_seq/perf_tests/main.cpp | 4 +- tasks/all/example_seq/src/ops_seq.cpp | 18 ++-- tasks/all/example_stl/func_tests/main.cpp | 120 +++++++++++----------- tasks/all/example_stl/include/ops_stl.hpp | 32 +++--- tasks/all/example_stl/perf_tests/main.cpp | 4 +- tasks/all/example_stl/src/ops_stl.cpp | 52 +++++----- tasks/all/example_tbb/func_tests/main.cpp | 120 +++++++++++----------- tasks/all/example_tbb/include/ops_tbb.hpp | 32 +++--- tasks/all/example_tbb/perf_tests/main.cpp | 4 +- tasks/all/example_tbb/src/ops_tbb.cpp | 64 ++++++------ 20 files changed, 500 insertions(+), 500 deletions(-) diff --git a/tasks/all/example_mpi/func_tests/main.cpp b/tasks/all/example_mpi/func_tests/main.cpp index c22598e57..0d31387c8 100644 --- a/tasks/all/example_mpi/func_tests/main.cpp +++ b/tasks/all/example_mpi/func_tests/main.cpp @@ -24,7 +24,7 @@ TEST(Parallel_Operations_MPI, Test_Sum) { boost::mpi::communicator world; std::vector global_vec; std::vector global_sum(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -37,16 +37,16 @@ TEST(Parallel_Operations_MPI, Test_Sum) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_sum(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -55,10 +55,10 @@ TEST(Parallel_Operations_MPI, Test_Sum) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_sum[0], global_sum[0]); } @@ -68,7 +68,7 @@ TEST(Parallel_Operations_MPI, Test_Diff) { boost::mpi::communicator world; std::vector global_vec; std::vector global_diff(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -81,16 +81,16 @@ TEST(Parallel_Operations_MPI, Test_Diff) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_diff(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -99,10 +99,10 @@ TEST(Parallel_Operations_MPI, Test_Diff) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_diff[0], global_diff[0]); } @@ -112,7 +112,7 @@ TEST(Parallel_Operations_MPI, Test_Diff_2) { boost::mpi::communicator world; std::vector global_vec; std::vector global_diff(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -125,16 +125,16 @@ TEST(Parallel_Operations_MPI, Test_Diff_2) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_diff(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -143,10 +143,10 @@ TEST(Parallel_Operations_MPI, Test_Diff_2) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_diff[0], global_diff[0]); } @@ -156,7 +156,7 @@ TEST(Parallel_Operations_MPI, Test_Max) { boost::mpi::communicator world; std::vector global_vec; std::vector global_max(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -169,16 +169,16 @@ TEST(Parallel_Operations_MPI, Test_Max) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_max(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -187,10 +187,10 @@ TEST(Parallel_Operations_MPI, Test_Max) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_max[0], global_max[0]); } @@ -200,7 +200,7 @@ TEST(Parallel_Operations_MPI, Test_Max_2) { boost::mpi::communicator world; std::vector global_vec; std::vector global_max(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -213,16 +213,16 @@ TEST(Parallel_Operations_MPI, Test_Max_2) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_max(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -231,10 +231,10 @@ TEST(Parallel_Operations_MPI, Test_Max_2) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_max[0], global_max[0]); } @@ -244,7 +244,7 @@ TEST(Parallel_Operations_MPI, Test_Max_2_File) { boost::mpi::communicator world; std::vector global_vec; std::vector global_max(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); if (world.rank() == 0) { @@ -264,16 +264,16 @@ TEST(Parallel_Operations_MPI, Test_Max_2_File) { } nesterov_a_test_task_mpi::TestMPITaskParallel test_mpi_task_parallel(task_data_par, "max"); - ASSERT_EQ(test_mpi_task_parallel.validation(), true); - test_mpi_task_parallel.pre_processing(); - test_mpi_task_parallel.run(); - test_mpi_task_parallel.post_processing(); + ASSERT_EQ(test_mpi_task_parallel.Validation(), true); + test_mpi_task_parallel.PreProcessing(); + test_mpi_task_parallel.Run(); + test_mpi_task_parallel.PostProcessing(); if (world.rank() == 0) { // Create data std::vector reference_max(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_seq->inputs_count.emplace_back(global_vec.size()); @@ -282,10 +282,10 @@ TEST(Parallel_Operations_MPI, Test_Max_2_File) { // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential test_mpi_task_sequential(task_data_seq, "max"); - ASSERT_EQ(test_mpi_task_sequential.validation(), true); - test_mpi_task_sequential.pre_processing(); - test_mpi_task_sequential.run(); - test_mpi_task_sequential.post_processing(); + ASSERT_EQ(test_mpi_task_sequential.Validation(), true); + test_mpi_task_sequential.PreProcessing(); + test_mpi_task_sequential.Run(); + test_mpi_task_sequential.PostProcessing(); ASSERT_EQ(reference_max[0], global_max[0]); } diff --git a/tasks/all/example_mpi/include/ops_mpi.hpp b/tasks/all/example_mpi/include/ops_mpi.hpp index 9b04fcc54..fca1cb81a 100644 --- a/tasks/all/example_mpi/include/ops_mpi.hpp +++ b/tasks/all/example_mpi/include/ops_mpi.hpp @@ -16,33 +16,33 @@ namespace nesterov_a_test_task_mpi { class TestMPITaskSequential : public ppc::core::Task { public: - explicit TestMPITaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestMPITaskSequential(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; class TestMPITaskParallel : public ppc::core::Task { public: - explicit TestMPITaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestMPITaskParallel(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_, local_input_; - int res{}; - std::string ops; - boost::mpi::communicator world; + int res_{}; + std::string ops_; + boost::mpi::communicator world_; }; } // namespace nesterov_a_test_task_mpi \ No newline at end of file diff --git a/tasks/all/example_mpi/perf_tests/main.cpp b/tasks/all/example_mpi/perf_tests/main.cpp index a18d819a3..2d002f56f 100644 --- a/tasks/all/example_mpi/perf_tests/main.cpp +++ b/tasks/all/example_mpi/perf_tests/main.cpp @@ -10,7 +10,7 @@ TEST(mpi_example_perf_test, test_pipeline_run) { boost::mpi::communicator world; std::vector global_vec; std::vector global_sum(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); int count_size_vector; if (world.rank() == 0) { @@ -23,10 +23,10 @@ TEST(mpi_example_perf_test, test_pipeline_run) { } auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); - ASSERT_EQ(test_mpi_task_parallel->validation(), true); - test_mpi_task_parallel->pre_processing(); - test_mpi_task_parallel->run(); - test_mpi_task_parallel->post_processing(); + ASSERT_EQ(test_mpi_task_parallel->Validation(), true); + test_mpi_task_parallel->PreProcessing(); + test_mpi_task_parallel->Run(); + test_mpi_task_parallel->PostProcessing(); // Create Perf attributes auto perf_attr = std::make_shared(); @@ -50,7 +50,7 @@ TEST(mpi_example_perf_test, test_task_run) { boost::mpi::communicator world; std::vector global_vec; std::vector global_sum(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); int count_size_vector; if (world.rank() == 0) { @@ -63,10 +63,10 @@ TEST(mpi_example_perf_test, test_task_run) { } auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); - ASSERT_EQ(test_mpi_task_parallel->validation(), true); - test_mpi_task_parallel->pre_processing(); - test_mpi_task_parallel->run(); - test_mpi_task_parallel->post_processing(); + ASSERT_EQ(test_mpi_task_parallel->Validation(), true); + test_mpi_task_parallel->PreProcessing(); + test_mpi_task_parallel->Run(); + test_mpi_task_parallel->PostProcessing(); // Create Perf attributes auto perf_attr = std::make_shared(); diff --git a/tasks/all/example_mpi/src/ops_mpi.cpp b/tasks/all/example_mpi/src/ops_mpi.cpp index 6a824f8c7..8a273fe07 100644 --- a/tasks/all/example_mpi/src/ops_mpi.cpp +++ b/tasks/all/example_mpi/src/ops_mpi.cpp @@ -7,97 +7,97 @@ #include #include -bool nesterov_a_test_task_mpi::TestMPITaskSequential::pre_processing_impl() { +bool nesterov_a_test_task_mpi::TestMPITaskSequential::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 0; + res_ = 0; return true; } -bool nesterov_a_test_task_mpi::TestMPITaskSequential::validation_impl() { +bool nesterov_a_test_task_mpi::TestMPITaskSequential::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_mpi::TestMPITaskSequential::run_impl() { - if (ops == "+") { - res = std::accumulate(input_.begin(), input_.end(), 0); - } else if (ops == "-") { - res = -std::accumulate(input_.begin(), input_.end(), 0); - } else if (ops == "max") { - res = *std::ranges::max_element(input_); +bool nesterov_a_test_task_mpi::TestMPITaskSequential::RunImpl() { + if (ops_ == "+") { + res_ = std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops_ == "-") { + res_ = -std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops_ == "max") { + res_ = *std::ranges::max_element(input_); } return true; } -bool nesterov_a_test_task_mpi::TestMPITaskSequential::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_mpi::TestMPITaskSequential::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } -bool nesterov_a_test_task_mpi::TestMPITaskParallel::pre_processing_impl() { +bool nesterov_a_test_task_mpi::TestMPITaskParallel::PreProcessingImpl() { unsigned int delta = 0; - if (world.rank() == 0) { - delta = taskData->inputs_count[0] / world.size(); + if (world_.rank() == 0) { + delta = task_data->inputs_count[0] / world_.size(); } - broadcast(world, delta, 0); + broadcast(world_, delta, 0); - if (world.rank() == 0) { + if (world_.rank() == 0) { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } - for (int proc = 1; proc < world.size(); proc++) { - world.send(proc, 0, input_.data() + (proc * delta), delta); + for (int proc = 1; proc < world_.size(); proc++) { + world_.send(proc, 0, input_.data() + (proc * delta), delta); } } local_input_ = std::vector(delta); - if (world.rank() == 0) { + if (world_.rank() == 0) { local_input_ = std::vector(input_.begin(), input_.begin() + delta); } else { - world.recv(0, 0, local_input_.data(), delta); + world_.recv(0, 0, local_input_.data(), delta); } // Init value for output - res = 0; + res_ = 0; return true; } -bool nesterov_a_test_task_mpi::TestMPITaskParallel::validation_impl() { - if (world.rank() == 0) { +bool nesterov_a_test_task_mpi::TestMPITaskParallel::ValidationImpl() { + if (world_.rank() == 0) { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } return true; } -bool nesterov_a_test_task_mpi::TestMPITaskParallel::run_impl() { +bool nesterov_a_test_task_mpi::TestMPITaskParallel::RunImpl() { int local_res; - if (ops == "+") { + if (ops_ == "+") { local_res = std::accumulate(local_input_.begin(), local_input_.end(), 0); - } else if (ops == "-") { + } else if (ops_ == "-") { local_res = -std::accumulate(local_input_.begin(), local_input_.end(), 0); - } else if (ops == "max") { + } else if (ops_ == "max") { local_res = *std::ranges::max_element(local_input_); } - if (ops == "+" || ops == "-") { - reduce(world, local_res, res, std::plus(), 0); - } else if (ops == "max") { - reduce(world, local_res, res, boost::mpi::maximum(), 0); + if (ops_ == "+" || ops_ == "-") { + reduce(world_, local_res, res_, std::plus(), 0); + } else if (ops_ == "max") { + reduce(world_, local_res, res_, boost::mpi::maximum(), 0); } return true; } -bool nesterov_a_test_task_mpi::TestMPITaskParallel::post_processing_impl() { - if (world.rank() == 0) { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_mpi::TestMPITaskParallel::PostProcessingImpl() { + if (world_.rank() == 0) { + reinterpret_cast(task_data->outputs[0])[0] = res_; } return true; } diff --git a/tasks/all/example_omp/func_tests/main.cpp b/tasks/all/example_omp/func_tests/main.cpp index 73f357b9a..4fe8dcf88 100644 --- a/tasks/all/example_omp/func_tests/main.cpp +++ b/tasks/all/example_omp/func_tests/main.cpp @@ -23,7 +23,7 @@ TEST(Parallel_Operations_OpenMP, Test_Sum) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -32,15 +32,15 @@ TEST(Parallel_Operations_OpenMP, Test_Sum) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -49,10 +49,10 @@ TEST(Parallel_Operations_OpenMP, Test_Sum) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -62,7 +62,7 @@ TEST(Parallel_Operations_OpenMP, Test_Diff) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -71,15 +71,15 @@ TEST(Parallel_Operations_OpenMP, Test_Diff) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -88,10 +88,10 @@ TEST(Parallel_Operations_OpenMP, Test_Diff) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -100,7 +100,7 @@ TEST(Parallel_Operations_OpenMP, Test_Diff_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -109,15 +109,15 @@ TEST(Parallel_Operations_OpenMP, Test_Diff_2) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -126,10 +126,10 @@ TEST(Parallel_Operations_OpenMP, Test_Diff_2) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -138,7 +138,7 @@ TEST(Parallel_Operations_OpenMP, Test_Mult) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -147,15 +147,15 @@ TEST(Parallel_Operations_OpenMP, Test_Mult) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -164,10 +164,10 @@ TEST(Parallel_Operations_OpenMP, Test_Mult) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -176,7 +176,7 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -185,15 +185,15 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -202,10 +202,10 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -221,7 +221,7 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -230,15 +230,15 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { // Create Task nesterov_a_test_task_omp::TestOMPTaskSequential test_omp_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_omp_task_sequential.validation(), true); - test_omp_task_sequential.pre_processing(); - test_omp_task_sequential.run(); - test_omp_task_sequential.post_processing(); + ASSERT_EQ(test_omp_task_sequential.Validation(), true); + test_omp_task_sequential.PreProcessing(); + test_omp_task_sequential.Run(); + test_omp_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -247,9 +247,9 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel test_omp_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_omp_task_parallel.validation(), true); - test_omp_task_parallel.pre_processing(); - test_omp_task_parallel.run(); - test_omp_task_parallel.post_processing(); + ASSERT_EQ(test_omp_task_parallel.Validation(), true); + test_omp_task_parallel.PreProcessing(); + test_omp_task_parallel.Run(); + test_omp_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } diff --git a/tasks/all/example_omp/include/ops_omp.hpp b/tasks/all/example_omp/include/ops_omp.hpp index 6cf742b80..dfdbb94ba 100644 --- a/tasks/all/example_omp/include/ops_omp.hpp +++ b/tasks/all/example_omp/include/ops_omp.hpp @@ -9,32 +9,32 @@ namespace nesterov_a_test_task_omp { class TestOMPTaskSequential : public ppc::core::Task { public: - explicit TestOMPTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestOMPTaskSequential(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; class TestOMPTaskParallel : public ppc::core::Task { public: - explicit TestOMPTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestOMPTaskParallel(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; } // namespace nesterov_a_test_task_omp \ No newline at end of file diff --git a/tasks/all/example_omp/perf_tests/main.cpp b/tasks/all/example_omp/perf_tests/main.cpp index 38b3daaa0..3eaabbbd2 100644 --- a/tasks/all/example_omp/perf_tests/main.cpp +++ b/tasks/all/example_omp/perf_tests/main.cpp @@ -13,7 +13,7 @@ TEST(openmp_example_perf_test, test_pipeline_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -45,7 +45,7 @@ TEST(openmp_example_perf_test, test_task_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); diff --git a/tasks/all/example_omp/src/ops_omp.cpp b/tasks/all/example_omp/src/ops_omp.cpp index 0666e6bbe..27d55aa51 100644 --- a/tasks/all/example_omp/src/ops_omp.cpp +++ b/tasks/all/example_omp/src/ops_omp.cpp @@ -8,82 +8,82 @@ #include #include -bool nesterov_a_test_task_omp::TestOMPTaskSequential::pre_processing_impl() { +bool nesterov_a_test_task_omp::TestOMPTaskSequential::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 1; + res_ = 1; return true; } -bool nesterov_a_test_task_omp::TestOMPTaskSequential::validation_impl() { +bool nesterov_a_test_task_omp::TestOMPTaskSequential::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_omp::TestOMPTaskSequential::run_impl() { - if (ops == "+") { - res = std::accumulate(input_.begin(), input_.end(), 1); - } else if (ops == "-") { - res -= std::accumulate(input_.begin(), input_.end(), 0); - } else if (ops == "*") { - res = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); +bool nesterov_a_test_task_omp::TestOMPTaskSequential::RunImpl() { + if (ops_ == "+") { + res_ = std::accumulate(input_.begin(), input_.end(), 1); + } else if (ops_ == "-") { + res_ -= std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops_ == "*") { + res_ = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); } return true; } -bool nesterov_a_test_task_omp::TestOMPTaskSequential::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_omp::TestOMPTaskSequential::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } -bool nesterov_a_test_task_omp::TestOMPTaskParallel::pre_processing_impl() { +bool nesterov_a_test_task_omp::TestOMPTaskParallel::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 1; + res_ = 1; return true; } -bool nesterov_a_test_task_omp::TestOMPTaskParallel::validation_impl() { +bool nesterov_a_test_task_omp::TestOMPTaskParallel::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_omp::TestOMPTaskParallel::run_impl() { +bool nesterov_a_test_task_omp::TestOMPTaskParallel::RunImpl() { double start = omp_get_wtime(); - auto temp_res = res; - if (ops == "+") { + auto temp_res = res_; + if (ops_ == "+") { #pragma omp parallel for reduction(+ : temp_res) for (int i = 0; i < static_cast(input_.size()); i++) { temp_res += input_[i]; } - } else if (ops == "-") { + } else if (ops_ == "-") { #pragma omp parallel for reduction(- : temp_res) for (int i = 0; i < static_cast(input_.size()); i++) { temp_res -= input_[i]; } - } else if (ops == "*") { + } else if (ops_ == "*") { #pragma omp parallel for reduction(* : temp_res) for (int i = 0; i < static_cast(input_.size()); i++) { temp_res *= input_[i]; } } - res = temp_res; + res_ = temp_res; double finish = omp_get_wtime(); std::cout << "How measure time in OpenMP: " << finish - start << '\n'; return true; } -bool nesterov_a_test_task_omp::TestOMPTaskParallel::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_omp::TestOMPTaskParallel::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } diff --git a/tasks/all/example_seq/func_tests/main.cpp b/tasks/all/example_seq/func_tests/main.cpp index c00a899a9..00dbe12e9 100644 --- a/tasks/all/example_seq/func_tests/main.cpp +++ b/tasks/all/example_seq/func_tests/main.cpp @@ -12,7 +12,7 @@ TEST(Sequential, Test_Sum_10) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -21,10 +21,10 @@ TEST(Sequential, Test_Sum_10) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } @@ -35,7 +35,7 @@ TEST(Sequential, Test_Sum_20) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -44,10 +44,10 @@ TEST(Sequential, Test_Sum_20) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } @@ -58,7 +58,7 @@ TEST(Sequential, Test_Sum_50) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -67,10 +67,10 @@ TEST(Sequential, Test_Sum_50) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } @@ -81,7 +81,7 @@ TEST(Sequential, Test_Sum_70) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -90,10 +90,10 @@ TEST(Sequential, Test_Sum_70) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } @@ -104,7 +104,7 @@ TEST(Sequential, Test_Sum_100) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -113,10 +113,10 @@ TEST(Sequential, Test_Sum_100) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } @@ -134,7 +134,7 @@ TEST(Sequential, Test_Sum_100_From_File) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -143,9 +143,9 @@ TEST(Sequential, Test_Sum_100_From_File) { // Create Task nesterov_a_test_task_seq::TestTaskSequential test_task_sequential(task_data_seq); - ASSERT_EQ(test_task_sequential.validation(), true); - test_task_sequential.pre_processing(); - test_task_sequential.run(); - test_task_sequential.post_processing(); + ASSERT_EQ(test_task_sequential.Validation(), true); + test_task_sequential.PreProcessing(); + test_task_sequential.Run(); + test_task_sequential.PostProcessing(); ASSERT_EQ(count, out[0]); } diff --git a/tasks/all/example_seq/include/ops_seq.hpp b/tasks/all/example_seq/include/ops_seq.hpp index 5f68f5ecb..5efb3cc4e 100644 --- a/tasks/all/example_seq/include/ops_seq.hpp +++ b/tasks/all/example_seq/include/ops_seq.hpp @@ -9,14 +9,14 @@ namespace nesterov_a_test_task_seq { class TestTaskSequential : public ppc::core::Task { public: - explicit TestTaskSequential(ppc::core::TaskDataPtr taskData_) : Task(std::move(taskData_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestTaskSequential(ppc::core::TaskDataPtr task_data) : Task(std::move(task_data)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: - int input_{}, res{}; + int input_{}, res_{}; }; } // namespace nesterov_a_test_task_seq \ No newline at end of file diff --git a/tasks/all/example_seq/perf_tests/main.cpp b/tasks/all/example_seq/perf_tests/main.cpp index a308a51ed..3ea5aabe9 100644 --- a/tasks/all/example_seq/perf_tests/main.cpp +++ b/tasks/all/example_seq/perf_tests/main.cpp @@ -12,7 +12,7 @@ TEST(sequential_example_perf_test, test_pipeline_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -49,7 +49,7 @@ TEST(sequential_example_perf_test, test_task_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); diff --git a/tasks/all/example_seq/src/ops_seq.cpp b/tasks/all/example_seq/src/ops_seq.cpp index 1051f75f7..436f7b200 100644 --- a/tasks/all/example_seq/src/ops_seq.cpp +++ b/tasks/all/example_seq/src/ops_seq.cpp @@ -2,26 +2,26 @@ #include -bool nesterov_a_test_task_seq::TestTaskSequential::pre_processing_impl() { +bool nesterov_a_test_task_seq::TestTaskSequential::PreProcessingImpl() { // Init value for input and output - input_ = reinterpret_cast(taskData->inputs[0])[0]; - res = 0; + input_ = reinterpret_cast(task_data->inputs[0])[0]; + res_ = 0; return true; } -bool nesterov_a_test_task_seq::TestTaskSequential::validation_impl() { +bool nesterov_a_test_task_seq::TestTaskSequential::ValidationImpl() { // Check count elements of output - return taskData->inputs_count[0] == 1 && taskData->outputs_count[0] == 1; + return task_data->inputs_count[0] == 1 && task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_seq::TestTaskSequential::run_impl() { +bool nesterov_a_test_task_seq::TestTaskSequential::RunImpl() { for (int i = 0; i < input_; i++) { - res++; + res_++; } return true; } -bool nesterov_a_test_task_seq::TestTaskSequential::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_seq::TestTaskSequential::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } diff --git a/tasks/all/example_stl/func_tests/main.cpp b/tasks/all/example_stl/func_tests/main.cpp index ad4701309..99ba424c4 100644 --- a/tasks/all/example_stl/func_tests/main.cpp +++ b/tasks/all/example_stl/func_tests/main.cpp @@ -25,7 +25,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -34,15 +34,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -51,10 +51,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -64,7 +64,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -73,15 +73,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_2) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -90,10 +90,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_2) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -103,7 +103,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_3) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -112,15 +112,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_3) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -129,10 +129,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_3) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -142,7 +142,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -151,15 +151,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -168,10 +168,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -181,7 +181,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -190,15 +190,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -207,10 +207,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -227,7 +227,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -236,15 +236,15 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { // Create Task nesterov_a_test_task_stl::TestSTLTaskSequential test_stl_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_stl_task_sequential.validation(), true); - test_stl_task_sequential.pre_processing(); - test_stl_task_sequential.run(); - test_stl_task_sequential.post_processing(); + ASSERT_EQ(test_stl_task_sequential.Validation(), true); + test_stl_task_sequential.PreProcessing(); + test_stl_task_sequential.Run(); + test_stl_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -253,9 +253,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel test_stl_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_stl_task_parallel.validation(), true); - test_stl_task_parallel.pre_processing(); - test_stl_task_parallel.run(); - test_stl_task_parallel.post_processing(); + ASSERT_EQ(test_stl_task_parallel.Validation(), true); + test_stl_task_parallel.PreProcessing(); + test_stl_task_parallel.Run(); + test_stl_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } diff --git a/tasks/all/example_stl/include/ops_stl.hpp b/tasks/all/example_stl/include/ops_stl.hpp index 66a611161..6f5aaed0b 100644 --- a/tasks/all/example_stl/include/ops_stl.hpp +++ b/tasks/all/example_stl/include/ops_stl.hpp @@ -10,32 +10,32 @@ namespace nesterov_a_test_task_stl { class TestSTLTaskSequential : public ppc::core::Task { public: - explicit TestSTLTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestSTLTaskSequential(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; class TestSTLTaskParallel : public ppc::core::Task { public: - explicit TestSTLTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestSTLTaskParallel(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; } // namespace nesterov_a_test_task_stl diff --git a/tasks/all/example_stl/perf_tests/main.cpp b/tasks/all/example_stl/perf_tests/main.cpp index 66bdc42f3..ee06cdda9 100644 --- a/tasks/all/example_stl/perf_tests/main.cpp +++ b/tasks/all/example_stl/perf_tests/main.cpp @@ -12,7 +12,7 @@ TEST(stl_example_perf_test, test_pipeline_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -49,7 +49,7 @@ TEST(stl_example_perf_test, test_task_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); diff --git a/tasks/all/example_stl/src/ops_stl.cpp b/tasks/all/example_stl/src/ops_stl.cpp index 46cf82ddf..ccc1bc058 100644 --- a/tasks/all/example_stl/src/ops_stl.cpp +++ b/tasks/all/example_stl/src/ops_stl.cpp @@ -8,34 +8,34 @@ #include #include -bool nesterov_a_test_task_stl::TestSTLTaskSequential::pre_processing_impl() { +bool nesterov_a_test_task_stl::TestSTLTaskSequential::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto *tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto *tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 0; + res_ = 0; return true; } -bool nesterov_a_test_task_stl::TestSTLTaskSequential::validation_impl() { +bool nesterov_a_test_task_stl::TestSTLTaskSequential::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_stl::TestSTLTaskSequential::run_impl() { - if (ops == "+") { - res = std::accumulate(input_.begin(), input_.end(), 0); - } else if (ops == "-") { - res -= std::accumulate(input_.begin(), input_.end(), 0); +bool nesterov_a_test_task_stl::TestSTLTaskSequential::RunImpl() { + if (ops_ == "+") { + res_ = std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops_ == "-") { + res_ -= std::accumulate(input_.begin(), input_.end(), 0); } return true; } -bool nesterov_a_test_task_stl::TestSTLTaskSequential::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_stl::TestSTLTaskSequential::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } @@ -60,24 +60,24 @@ void AtomOps(std::vector vec, const std::string &ops, std::promise &&p } } // namespace -bool nesterov_a_test_task_stl::TestSTLTaskParallel::pre_processing_impl() { +bool nesterov_a_test_task_stl::TestSTLTaskParallel::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto *tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto *tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 0; + res_ = 0; return true; } -bool nesterov_a_test_task_stl::TestSTLTaskParallel::validation_impl() { +bool nesterov_a_test_task_stl::TestSTLTaskParallel::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_stl::TestSTLTaskParallel::run_impl() { +bool nesterov_a_test_task_stl::TestSTLTaskParallel::RunImpl() { const auto nthreads = std::thread::hardware_concurrency(); const auto delta = (input_.end() - input_.begin()) / nthreads; @@ -88,9 +88,9 @@ bool nesterov_a_test_task_stl::TestSTLTaskParallel::run_impl() { for (unsigned i = 0; i < nthreads; i++) { futures[i] = promises[i].get_future(); std::vector tmp_vec(input_.begin() + i * delta, input_.begin() + (i + 1) * delta); - threads[i] = std::thread(AtomOps, tmp_vec, ops, std::move(promises[i])); + threads[i] = std::thread(AtomOps, tmp_vec, ops_, std::move(promises[i])); threads[i].join(); - res += futures[i].get(); + res_ += futures[i].get(); } delete[] promises; @@ -99,7 +99,7 @@ bool nesterov_a_test_task_stl::TestSTLTaskParallel::run_impl() { return true; } -bool nesterov_a_test_task_stl::TestSTLTaskParallel::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_stl::TestSTLTaskParallel::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } diff --git a/tasks/all/example_tbb/func_tests/main.cpp b/tasks/all/example_tbb/func_tests/main.cpp index 93bde0295..5eb6d53eb 100644 --- a/tasks/all/example_tbb/func_tests/main.cpp +++ b/tasks/all/example_tbb/func_tests/main.cpp @@ -23,7 +23,7 @@ TEST(Parallel_Operations_TBB, Test_Sum) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -32,15 +32,15 @@ TEST(Parallel_Operations_TBB, Test_Sum) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "+"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -49,10 +49,10 @@ TEST(Parallel_Operations_TBB, Test_Sum) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "+"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -61,7 +61,7 @@ TEST(Parallel_Operations_TBB, Test_Diff) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -70,15 +70,15 @@ TEST(Parallel_Operations_TBB, Test_Diff) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -87,10 +87,10 @@ TEST(Parallel_Operations_TBB, Test_Diff) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -99,7 +99,7 @@ TEST(Parallel_Operations_TBB, Test_Diff_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -108,15 +108,15 @@ TEST(Parallel_Operations_TBB, Test_Diff_2) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "-"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -125,10 +125,10 @@ TEST(Parallel_Operations_TBB, Test_Diff_2) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "-"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -137,7 +137,7 @@ TEST(Parallel_Operations_TBB, Test_Mult) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -146,15 +146,15 @@ TEST(Parallel_Operations_TBB, Test_Mult) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -163,10 +163,10 @@ TEST(Parallel_Operations_TBB, Test_Mult) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -175,7 +175,7 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -184,15 +184,15 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -201,10 +201,10 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } @@ -220,7 +220,7 @@ TEST(Parallel_Operations_TBB, Test_Mult_2_File) { // Create data std::vector ref_res(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_seq->inputs_count.emplace_back(vec.size()); @@ -229,15 +229,15 @@ TEST(Parallel_Operations_TBB, Test_Mult_2_File) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskSequential test_tbb_task_sequential(task_data_seq, "*"); - ASSERT_EQ(test_tbb_task_sequential.validation(), true); - test_tbb_task_sequential.pre_processing(); - test_tbb_task_sequential.run(); - test_tbb_task_sequential.post_processing(); + ASSERT_EQ(test_tbb_task_sequential.Validation(), true); + test_tbb_task_sequential.PreProcessing(); + test_tbb_task_sequential.Run(); + test_tbb_task_sequential.PostProcessing(); // Create data std::vector par_res(1, 0); - // Create TaskData + // Create task_data auto task_data_par = std::make_shared(); task_data_par->inputs.emplace_back(reinterpret_cast(vec.data())); task_data_par->inputs_count.emplace_back(vec.size()); @@ -246,9 +246,9 @@ TEST(Parallel_Operations_TBB, Test_Mult_2_File) { // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel test_tbb_task_parallel(task_data_par, "*"); - ASSERT_EQ(test_tbb_task_parallel.validation(), true); - test_tbb_task_parallel.pre_processing(); - test_tbb_task_parallel.run(); - test_tbb_task_parallel.post_processing(); + ASSERT_EQ(test_tbb_task_parallel.Validation(), true); + test_tbb_task_parallel.PreProcessing(); + test_tbb_task_parallel.Run(); + test_tbb_task_parallel.PostProcessing(); ASSERT_EQ(ref_res[0], par_res[0]); } diff --git a/tasks/all/example_tbb/include/ops_tbb.hpp b/tasks/all/example_tbb/include/ops_tbb.hpp index 0d212c986..168ff279e 100644 --- a/tasks/all/example_tbb/include/ops_tbb.hpp +++ b/tasks/all/example_tbb/include/ops_tbb.hpp @@ -10,32 +10,32 @@ namespace nesterov_a_test_task_tbb { class TestTBBTaskSequential : public ppc::core::Task { public: - explicit TestTBBTaskSequential(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestTBBTaskSequential(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; class TestTBBTaskParallel : public ppc::core::Task { public: - explicit TestTBBTaskParallel(ppc::core::TaskDataPtr taskData_, std::string ops_) - : Task(std::move(taskData_)), ops(std::move(ops_)) {} - bool pre_processing_impl() override; - bool validation_impl() override; - bool run_impl() override; - bool post_processing_impl() override; + explicit TestTBBTaskParallel(ppc::core::TaskDataPtr task_data, std::string ops) + : Task(std::move(task_data)), ops_(std::move(ops)) {} + bool PreProcessingImpl() override; + bool ValidationImpl() override; + bool RunImpl() override; + bool PostProcessingImpl() override; private: std::vector input_; - int res{}; - std::string ops; + int res_{}; + std::string ops_; }; } // namespace nesterov_a_test_task_tbb diff --git a/tasks/all/example_tbb/perf_tests/main.cpp b/tasks/all/example_tbb/perf_tests/main.cpp index db04bc1e2..39709cc60 100644 --- a/tasks/all/example_tbb/perf_tests/main.cpp +++ b/tasks/all/example_tbb/perf_tests/main.cpp @@ -13,7 +13,7 @@ TEST(tbb_example_perf_test, test_pipeline_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); @@ -46,7 +46,7 @@ TEST(tbb_example_perf_test, test_task_run) { std::vector in(1, count); std::vector out(1, 0); - // Create TaskData + // Create task_data auto task_data_seq = std::make_shared(); task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); task_data_seq->inputs_count.emplace_back(in.size()); diff --git a/tasks/all/example_tbb/src/ops_tbb.cpp b/tasks/all/example_tbb/src/ops_tbb.cpp index e18f2217c..8f8c5118a 100644 --- a/tasks/all/example_tbb/src/ops_tbb.cpp +++ b/tasks/all/example_tbb/src/ops_tbb.cpp @@ -9,75 +9,75 @@ #include #include -bool nesterov_a_test_task_tbb::TestTBBTaskSequential::pre_processing_impl() { +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 1; + res_ = 1; return true; } -bool nesterov_a_test_task_tbb::TestTBBTaskSequential::validation_impl() { +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_tbb::TestTBBTaskSequential::run_impl() { - if (ops == "+") { - res = std::accumulate(input_.begin(), input_.end(), 1); - } else if (ops == "-") { - res -= std::accumulate(input_.begin(), input_.end(), 0); - } else if (ops == "*") { - res = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::RunImpl() { + if (ops_ == "+") { + res_ = std::accumulate(input_.begin(), input_.end(), 1); + } else if (ops_ == "-") { + res_ -= std::accumulate(input_.begin(), input_.end(), 0); + } else if (ops_ == "*") { + res_ = std::accumulate(input_.begin(), input_.end(), 1, std::multiplies<>()); } return true; } -bool nesterov_a_test_task_tbb::TestTBBTaskSequential::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_tbb::TestTBBTaskSequential::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } -bool nesterov_a_test_task_tbb::TestTBBTaskParallel::pre_processing_impl() { +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::PreProcessingImpl() { // Init vectors - input_ = std::vector(taskData->inputs_count[0]); - auto* tmp_ptr = reinterpret_cast(taskData->inputs[0]); - for (unsigned i = 0; i < taskData->inputs_count[0]; i++) { + input_ = std::vector(task_data->inputs_count[0]); + auto* tmp_ptr = reinterpret_cast(task_data->inputs[0]); + for (unsigned i = 0; i < task_data->inputs_count[0]; i++) { input_[i] = tmp_ptr[i]; } // Init value for output - res = 1; + res_ = 1; return true; } -bool nesterov_a_test_task_tbb::TestTBBTaskParallel::validation_impl() { +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::ValidationImpl() { // Check count elements of output - return taskData->outputs_count[0] == 1; + return task_data->outputs_count[0] == 1; } -bool nesterov_a_test_task_tbb::TestTBBTaskParallel::run_impl() { - if (ops == "+") { - res += oneapi::tbb::parallel_reduce( +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::RunImpl() { + if (ops_ == "+") { + res_ += oneapi::tbb::parallel_reduce( oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 0, [](tbb::blocked_range::iterator> r, int running_total) { running_total += std::accumulate(r.begin(), r.end(), 0); return running_total; }, std::plus<>()); - } else if (ops == "-") { - res -= oneapi::tbb::parallel_reduce( + } else if (ops_ == "-") { + res_ -= oneapi::tbb::parallel_reduce( oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 0, [](tbb::blocked_range::iterator> r, int running_total) { running_total += std::accumulate(r.begin(), r.end(), 0); return running_total; }, std::plus<>()); - } else if (ops == "*") { - res *= oneapi::tbb::parallel_reduce( + } else if (ops_ == "*") { + res_ *= oneapi::tbb::parallel_reduce( oneapi::tbb::blocked_range::iterator>(input_.begin(), input_.end()), 1, [](tbb::blocked_range::iterator> r, int running_total) { running_total *= std::accumulate(r.begin(), r.end(), 1, std::multiplies<>()); @@ -88,7 +88,7 @@ bool nesterov_a_test_task_tbb::TestTBBTaskParallel::run_impl() { return true; } -bool nesterov_a_test_task_tbb::TestTBBTaskParallel::post_processing_impl() { - reinterpret_cast(taskData->outputs[0])[0] = res; +bool nesterov_a_test_task_tbb::TestTBBTaskParallel::PostProcessingImpl() { + reinterpret_cast(task_data->outputs[0])[0] = res_; return true; } From 00995e6e339913f0935c2f7d799e44457caba242 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Mon, 13 Jan 2025 20:19:20 +0100 Subject: [PATCH 04/16] update examples --- .../test.txt => example/data/test_mpi.txt} | 0 .../test.txt => example/data/test_omp.txt} | 0 .../test.txt => example/data/test_seq.txt} | 0 .../test.txt => example/data/test_stl.txt} | 0 .../test.txt => example/data/test_tbb.txt} | 0 .../func_tests/func_mpi.cpp} | 2 +- .../func_tests/func_omp.cpp} | 2 +- .../func_tests/func_seq.cpp} | 2 +- .../func_tests/func_stl.cpp} | 2 +- .../func_tests/func_tbb.cpp} | 2 +- .../include/ops_mpi.hpp | 0 .../include/ops_omp.hpp | 0 .../include/ops_seq.hpp | 0 .../include/ops_stl.hpp | 0 .../include/ops_tbb.hpp | 0 .../perf_tests/perf_omp.cpp} | 32 ------- .../perf_tests/perf_tbb.cpp} | 33 ------- .../{example_mpi => example}/src/ops_mpi.cpp | 0 .../{example_omp => example}/src/ops_omp.cpp | 0 .../{example_seq => example}/src/ops_seq.cpp | 0 .../{example_stl => example}/src/ops_stl.cpp | 0 .../{example_tbb => example}/src/ops_tbb.cpp | 0 tasks/all/example_mpi/perf_tests/main.cpp | 87 ------------------- tasks/all/example_seq/perf_tests/main.cpp | 80 ----------------- tasks/all/example_stl/perf_tests/main.cpp | 80 ----------------- 25 files changed, 5 insertions(+), 317 deletions(-) rename tasks/all/{example_mpi/data/test.txt => example/data/test_mpi.txt} (100%) rename tasks/all/{example_omp/data/test.txt => example/data/test_omp.txt} (100%) rename tasks/all/{example_seq/data/test.txt => example/data/test_seq.txt} (100%) rename tasks/all/{example_stl/data/test.txt => example/data/test_stl.txt} (100%) rename tasks/all/{example_tbb/data/test.txt => example/data/test_tbb.txt} (100%) rename tasks/all/{example_mpi/func_tests/main.cpp => example/func_tests/func_mpi.cpp} (99%) rename tasks/all/{example_omp/func_tests/main.cpp => example/func_tests/func_omp.cpp} (99%) rename tasks/all/{example_seq/func_tests/main.cpp => example/func_tests/func_seq.cpp} (98%) rename tasks/all/{example_stl/func_tests/main.cpp => example/func_tests/func_stl.cpp} (99%) rename tasks/all/{example_tbb/func_tests/main.cpp => example/func_tests/func_tbb.cpp} (99%) rename tasks/all/{example_mpi => example}/include/ops_mpi.hpp (100%) rename tasks/all/{example_omp => example}/include/ops_omp.hpp (100%) rename tasks/all/{example_seq => example}/include/ops_seq.hpp (100%) rename tasks/all/{example_stl => example}/include/ops_stl.hpp (100%) rename tasks/all/{example_tbb => example}/include/ops_tbb.hpp (100%) rename tasks/all/{example_omp/perf_tests/main.cpp => example/perf_tests/perf_omp.cpp} (53%) rename tasks/all/{example_tbb/perf_tests/main.cpp => example/perf_tests/perf_tbb.cpp} (52%) rename tasks/all/{example_mpi => example}/src/ops_mpi.cpp (100%) rename tasks/all/{example_omp => example}/src/ops_omp.cpp (100%) rename tasks/all/{example_seq => example}/src/ops_seq.cpp (100%) rename tasks/all/{example_stl => example}/src/ops_stl.cpp (100%) rename tasks/all/{example_tbb => example}/src/ops_tbb.cpp (100%) delete mode 100644 tasks/all/example_mpi/perf_tests/main.cpp delete mode 100644 tasks/all/example_seq/perf_tests/main.cpp delete mode 100644 tasks/all/example_stl/perf_tests/main.cpp diff --git a/tasks/all/example_mpi/data/test.txt b/tasks/all/example/data/test_mpi.txt similarity index 100% rename from tasks/all/example_mpi/data/test.txt rename to tasks/all/example/data/test_mpi.txt diff --git a/tasks/all/example_omp/data/test.txt b/tasks/all/example/data/test_omp.txt similarity index 100% rename from tasks/all/example_omp/data/test.txt rename to tasks/all/example/data/test_omp.txt diff --git a/tasks/all/example_seq/data/test.txt b/tasks/all/example/data/test_seq.txt similarity index 100% rename from tasks/all/example_seq/data/test.txt rename to tasks/all/example/data/test_seq.txt diff --git a/tasks/all/example_stl/data/test.txt b/tasks/all/example/data/test_stl.txt similarity index 100% rename from tasks/all/example_stl/data/test.txt rename to tasks/all/example/data/test_stl.txt diff --git a/tasks/all/example_tbb/data/test.txt b/tasks/all/example/data/test_tbb.txt similarity index 100% rename from tasks/all/example_tbb/data/test.txt rename to tasks/all/example/data/test_tbb.txt diff --git a/tasks/all/example_mpi/func_tests/main.cpp b/tasks/all/example/func_tests/func_mpi.cpp similarity index 99% rename from tasks/all/example_mpi/func_tests/main.cpp rename to tasks/all/example/func_tests/func_mpi.cpp index 0d31387c8..1dbc5c5f6 100644 --- a/tasks/all/example_mpi/func_tests/main.cpp +++ b/tasks/all/example/func_tests/func_mpi.cpp @@ -249,7 +249,7 @@ TEST(Parallel_Operations_MPI, Test_Max_2_File) { if (world.rank() == 0) { std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("mpi/example/data/test.txt")); + std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_mpi.txt")); if (test_file.is_open()) { getline(test_file, line); } diff --git a/tasks/all/example_omp/func_tests/main.cpp b/tasks/all/example/func_tests/func_omp.cpp similarity index 99% rename from tasks/all/example_omp/func_tests/main.cpp rename to tasks/all/example/func_tests/func_omp.cpp index 4fe8dcf88..3e590a619 100644 --- a/tasks/all/example_omp/func_tests/main.cpp +++ b/tasks/all/example/func_tests/func_omp.cpp @@ -211,7 +211,7 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("omp/example/data/test.txt")); + std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_omp.txt")); if (test_file.is_open()) { getline(test_file, line); } diff --git a/tasks/all/example_seq/func_tests/main.cpp b/tasks/all/example/func_tests/func_seq.cpp similarity index 98% rename from tasks/all/example_seq/func_tests/main.cpp rename to tasks/all/example/func_tests/func_seq.cpp index 00dbe12e9..cda2304e9 100644 --- a/tasks/all/example_seq/func_tests/main.cpp +++ b/tasks/all/example/func_tests/func_seq.cpp @@ -122,7 +122,7 @@ TEST(Sequential, Test_Sum_100) { TEST(Sequential, Test_Sum_100_From_File) { std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("seq/example/data/test.txt")); + std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_seq.txt")); if (test_file.is_open()) { getline(test_file, line); } diff --git a/tasks/all/example_stl/func_tests/main.cpp b/tasks/all/example/func_tests/func_stl.cpp similarity index 99% rename from tasks/all/example_stl/func_tests/main.cpp rename to tasks/all/example/func_tests/func_stl.cpp index 99ba424c4..1a3ade05c 100644 --- a/tasks/all/example_stl/func_tests/main.cpp +++ b/tasks/all/example/func_tests/func_stl.cpp @@ -216,7 +216,7 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("stl/example/data/test.txt")); + std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_stl.txt")); if (test_file.is_open()) { getline(test_file, line); } diff --git a/tasks/all/example_tbb/func_tests/main.cpp b/tasks/all/example/func_tests/func_tbb.cpp similarity index 99% rename from tasks/all/example_tbb/func_tests/main.cpp rename to tasks/all/example/func_tests/func_tbb.cpp index 5eb6d53eb..eeb5e3c50 100644 --- a/tasks/all/example_tbb/func_tests/main.cpp +++ b/tasks/all/example/func_tests/func_tbb.cpp @@ -210,7 +210,7 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { TEST(Parallel_Operations_TBB, Test_Mult_2_File) { std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("tbb/example/data/test.txt")); + std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_tbb.txt")); if (test_file.is_open()) { getline(test_file, line); } diff --git a/tasks/all/example_mpi/include/ops_mpi.hpp b/tasks/all/example/include/ops_mpi.hpp similarity index 100% rename from tasks/all/example_mpi/include/ops_mpi.hpp rename to tasks/all/example/include/ops_mpi.hpp diff --git a/tasks/all/example_omp/include/ops_omp.hpp b/tasks/all/example/include/ops_omp.hpp similarity index 100% rename from tasks/all/example_omp/include/ops_omp.hpp rename to tasks/all/example/include/ops_omp.hpp diff --git a/tasks/all/example_seq/include/ops_seq.hpp b/tasks/all/example/include/ops_seq.hpp similarity index 100% rename from tasks/all/example_seq/include/ops_seq.hpp rename to tasks/all/example/include/ops_seq.hpp diff --git a/tasks/all/example_stl/include/ops_stl.hpp b/tasks/all/example/include/ops_stl.hpp similarity index 100% rename from tasks/all/example_stl/include/ops_stl.hpp rename to tasks/all/example/include/ops_stl.hpp diff --git a/tasks/all/example_tbb/include/ops_tbb.hpp b/tasks/all/example/include/ops_tbb.hpp similarity index 100% rename from tasks/all/example_tbb/include/ops_tbb.hpp rename to tasks/all/example/include/ops_tbb.hpp diff --git a/tasks/all/example_omp/perf_tests/main.cpp b/tasks/all/example/perf_tests/perf_omp.cpp similarity index 53% rename from tasks/all/example_omp/perf_tests/main.cpp rename to tasks/all/example/perf_tests/perf_omp.cpp index 3eaabbbd2..caae0a4a6 100644 --- a/tasks/all/example_omp/perf_tests/main.cpp +++ b/tasks/all/example/perf_tests/perf_omp.cpp @@ -37,35 +37,3 @@ TEST(openmp_example_perf_test, test_pipeline_run) { ppc::core::Perf::PrintPerfStatistic(perf_results); ASSERT_EQ(count + 1, out[0]); } - -TEST(openmp_example_perf_test, test_task_run) { - const int count = 100; - - // Create data - std::vector in(1, count); - std::vector out(1, 0); - - // Create task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_omp = std::make_shared(task_data_seq, "+"); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - perf_attr->current_timer = [&] { return omp_get_wtime(); }; - - // Create and init perf results - auto perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_omp); - perf_analyzer->TaskRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count + 1, out[0]); -} diff --git a/tasks/all/example_tbb/perf_tests/main.cpp b/tasks/all/example/perf_tests/perf_tbb.cpp similarity index 52% rename from tasks/all/example_tbb/perf_tests/main.cpp rename to tasks/all/example/perf_tests/perf_tbb.cpp index 39709cc60..518d0bd61 100644 --- a/tasks/all/example_tbb/perf_tests/main.cpp +++ b/tasks/all/example/perf_tests/perf_tbb.cpp @@ -6,39 +6,6 @@ #include "core/perf/include/perf.hpp" #include "tbb/example/include/ops_tbb.hpp" -TEST(tbb_example_perf_test, test_pipeline_run) { - const int count = 100; - - // Create data - std::vector in(1, count); - std::vector out(1, 0); - - // Create task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_tbb = std::make_shared(task_data_seq, "+"); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const auto t0 = oneapi::tbb::tick_count::now(); - perf_attr->current_timer = [&] { return (oneapi::tbb::tick_count::now() - t0).seconds(); }; - - // Create and init perf results - auto perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_tbb); - perf_analyzer->PipelineRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count + 1, out[0]); -} - TEST(tbb_example_perf_test, test_task_run) { const int count = 100; diff --git a/tasks/all/example_mpi/src/ops_mpi.cpp b/tasks/all/example/src/ops_mpi.cpp similarity index 100% rename from tasks/all/example_mpi/src/ops_mpi.cpp rename to tasks/all/example/src/ops_mpi.cpp diff --git a/tasks/all/example_omp/src/ops_omp.cpp b/tasks/all/example/src/ops_omp.cpp similarity index 100% rename from tasks/all/example_omp/src/ops_omp.cpp rename to tasks/all/example/src/ops_omp.cpp diff --git a/tasks/all/example_seq/src/ops_seq.cpp b/tasks/all/example/src/ops_seq.cpp similarity index 100% rename from tasks/all/example_seq/src/ops_seq.cpp rename to tasks/all/example/src/ops_seq.cpp diff --git a/tasks/all/example_stl/src/ops_stl.cpp b/tasks/all/example/src/ops_stl.cpp similarity index 100% rename from tasks/all/example_stl/src/ops_stl.cpp rename to tasks/all/example/src/ops_stl.cpp diff --git a/tasks/all/example_tbb/src/ops_tbb.cpp b/tasks/all/example/src/ops_tbb.cpp similarity index 100% rename from tasks/all/example_tbb/src/ops_tbb.cpp rename to tasks/all/example/src/ops_tbb.cpp diff --git a/tasks/all/example_mpi/perf_tests/main.cpp b/tasks/all/example_mpi/perf_tests/main.cpp deleted file mode 100644 index 2d002f56f..000000000 --- a/tasks/all/example_mpi/perf_tests/main.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include - -#include -#include - -#include "core/perf/include/perf.hpp" -#include "mpi/example/include/ops_mpi.hpp" - -TEST(mpi_example_perf_test, test_pipeline_run) { - boost::mpi::communicator world; - std::vector global_vec; - std::vector global_sum(1, 0); - // Create task_data - auto task_data_par = std::make_shared(); - int count_size_vector; - if (world.rank() == 0) { - count_size_vector = 120; - global_vec = std::vector(count_size_vector, 1); - task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); - task_data_par->inputs_count.emplace_back(global_vec.size()); - task_data_par->outputs.emplace_back(reinterpret_cast(global_sum.data())); - task_data_par->outputs_count.emplace_back(global_sum.size()); - } - - auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); - ASSERT_EQ(test_mpi_task_parallel->Validation(), true); - test_mpi_task_parallel->PreProcessing(); - test_mpi_task_parallel->Run(); - test_mpi_task_parallel->PostProcessing(); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const boost::mpi::timer current_timer; - perf_attr->current_timer = [&] { return current_timer.elapsed(); }; - - // Create and init perf results - auto perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_mpi_task_parallel); - perf_analyzer->PipelineRun(perf_attr, perf_results); - if (world.rank() == 0) { - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count_size_vector, global_sum[0]); - } -} - -TEST(mpi_example_perf_test, test_task_run) { - boost::mpi::communicator world; - std::vector global_vec; - std::vector global_sum(1, 0); - // Create task_data - auto task_data_par = std::make_shared(); - int count_size_vector; - if (world.rank() == 0) { - count_size_vector = 120; - global_vec = std::vector(count_size_vector, 1); - task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); - task_data_par->inputs_count.emplace_back(global_vec.size()); - task_data_par->outputs.emplace_back(reinterpret_cast(global_sum.data())); - task_data_par->outputs_count.emplace_back(global_sum.size()); - } - - auto test_mpi_task_parallel = std::make_shared(task_data_par, "+"); - ASSERT_EQ(test_mpi_task_parallel->Validation(), true); - test_mpi_task_parallel->PreProcessing(); - test_mpi_task_parallel->Run(); - test_mpi_task_parallel->PostProcessing(); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const boost::mpi::timer current_timer; - perf_attr->current_timer = [&] { return current_timer.elapsed(); }; - - // Create and init perf results - auto perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_mpi_task_parallel); - perf_analyzer->TaskRun(perf_attr, perf_results); - if (world.rank() == 0) { - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count_size_vector, global_sum[0]); - } -} diff --git a/tasks/all/example_seq/perf_tests/main.cpp b/tasks/all/example_seq/perf_tests/main.cpp deleted file mode 100644 index 3ea5aabe9..000000000 --- a/tasks/all/example_seq/perf_tests/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include - -#include - -#include "core/perf/include/perf.hpp" -#include "seq/example/include/ops_seq.hpp" - -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 task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_sequential = std::make_shared(task_data_seq); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const auto t0 = std::chrono::high_resolution_clock::now(); - perf_attr->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 perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_sequential); - perf_analyzer->PipelineRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count, out[0]); -} - -TEST(sequential_example_perf_test, test_task_run) { - const int count = 100; - - // Create data - std::vector in(1, count); - std::vector out(1, 0); - - // Create task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_sequential = std::make_shared(task_data_seq); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const auto t0 = std::chrono::high_resolution_clock::now(); - perf_attr->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 perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_sequential); - perf_analyzer->TaskRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count, out[0]); -} diff --git a/tasks/all/example_stl/perf_tests/main.cpp b/tasks/all/example_stl/perf_tests/main.cpp deleted file mode 100644 index ee06cdda9..000000000 --- a/tasks/all/example_stl/perf_tests/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include - -#include - -#include "core/perf/include/perf.hpp" -#include "stl/example/include/ops_stl.hpp" - -TEST(stl_example_perf_test, test_pipeline_run) { - const int count = 100; - - // Create data - std::vector in(1, count); - std::vector out(1, 0); - - // Create task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_stl = std::make_shared(task_data_seq, "+"); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const auto t0 = std::chrono::high_resolution_clock::now(); - perf_attr->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 perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_stl); - perf_analyzer->PipelineRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count, out[0]); -} - -TEST(stl_example_perf_test, test_task_run) { - const int count = 100; - - // Create data - std::vector in(1, count); - std::vector out(1, 0); - - // Create task_data - auto task_data_seq = std::make_shared(); - task_data_seq->inputs.emplace_back(reinterpret_cast(in.data())); - task_data_seq->inputs_count.emplace_back(in.size()); - task_data_seq->outputs.emplace_back(reinterpret_cast(out.data())); - task_data_seq->outputs_count.emplace_back(out.size()); - - // Create Task - auto test_task_stl = std::make_shared(task_data_seq, "+"); - - // Create Perf attributes - auto perf_attr = std::make_shared(); - perf_attr->num_running = 10; - const auto t0 = std::chrono::high_resolution_clock::now(); - perf_attr->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 perf_results = std::make_shared(); - - // Create Perf analyzer - auto perf_analyzer = std::make_shared(test_task_stl); - perf_analyzer->TaskRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count, out[0]); -} From 4e4757cfc3cb9623651b3006428e7414e65bd06f Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Mon, 13 Jan 2025 20:31:20 +0100 Subject: [PATCH 05/16] update coverage --- .github/workflows/main.yml | 2 +- codecov.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6dd15a6e4..05e2274c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -883,7 +883,7 @@ jobs: run: | cd build lcov --capture --directory . --output-file ../coverage.info - lcov --remove ../coverage.info '*/3rdparty/*' '/usr/*' '*/perf_tests/*' '*/func_tests/*' --output-file ../coverage.info + lcov --remove ../coverage.info '*/3rdparty/*' '/usr/*' '*/perf_tests/*' '*/func_tests/*' '*/all/runner.cpp' '*/mpi/runner.cpp' '*/omp/runner.cpp' '*/seq/runner.cpp' '*/stl/runner.cpp' '*/tbb/runner.cpp' --output-file ../coverage.info cd .. genhtml coverage.info --output-directory cov-report - name: Upload coverage report artifact diff --git a/codecov.yml b/codecov.yml index 7da7e12f2..2e8324752 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,12 @@ ignore: - "**/perf_tests/**" - "**/func_tests/**" + - "**/all/runner.cpp" + - "**/mpi/runner.cpp" + - "**/omp/runner.cpp" + - "**/seq/runner.cpp" + - "**/stl/runner.cpp" + - "**/tbb/runner.cpp" coverage: status: project: From 501a87194c400ce0c22c539f50393836420c2687 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Tue, 14 Jan 2025 23:01:26 +0100 Subject: [PATCH 06/16] Update main.yml --- .github/workflows/main.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05e2274c4..3ccd151da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,15 +48,14 @@ jobs: sudo apt-get install libomp-dev sudo apt-get install valgrind python3 -m pip install xlsxwriter - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} - create-symlink: true + # - name: ccache + # uses: hendrikmuhs/ccache-action@v1.2 + # with: + # key: ${{ github.job }} + # create-symlink: true - name: CMake configure run: > cmake -S . -B build - -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE From 9e0aed4797d48733b5ad5bb9814f035389ecf593 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Tue, 14 Jan 2025 23:15:23 +0100 Subject: [PATCH 07/16] Update main.yml --- .github/workflows/main.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ccd151da..509de0d10 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,32 +42,33 @@ jobs: run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update - sudo apt-get install gcc-13 g++-13 + sudo apt-get install gcc-12 g++-12 sudo apt-get install ninja-build sudo apt-get install mpich libmpich* mpi* openmpi-bin sudo apt-get install libomp-dev sudo apt-get install valgrind python3 -m pip install xlsxwriter - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2 - # with: - # key: ${{ github.job }} - # create-symlink: true + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + create-symlink: true - name: CMake configure run: > cmake -S . -B build + -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE env: - CC: gcc-13 - CXX: g++-13 + CC: gcc-12 + CXX: g++-12 - name: Ninja build run: | cmake --build build env: - CC: gcc-13 - CXX: g++-13 + CC: gcc-12 + CXX: g++-12 - name: Run func tests (MPI, num_proc=2) run: | source scripts/run_mpi.sh From eef359589b5c6e1b7db14e08b716752d134ed289 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Tue, 14 Jan 2025 23:48:37 +0100 Subject: [PATCH 08/16] Update main.yml --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 509de0d10..698093ff4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,9 +42,9 @@ jobs: run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update - sudo apt-get install gcc-12 g++-12 + sudo apt-get install gcc-13 g++-13 sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install libomp-dev sudo apt-get install valgrind python3 -m pip install xlsxwriter @@ -61,14 +61,14 @@ jobs: -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE env: - CC: gcc-12 - CXX: g++-12 + CC: gcc-13 + CXX: g++-13 - name: Ninja build run: | cmake --build build env: - CC: gcc-12 - CXX: g++-12 + CC: gcc-13 + CXX: g++-13 - name: Run func tests (MPI, num_proc=2) run: | source scripts/run_mpi.sh From 7c24425ba5e3c466a69fac5cd4d7953850e5ecc5 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Wed, 15 Jan 2025 13:28:11 +0100 Subject: [PATCH 09/16] test mpi part --- .github/workflows/main.yml | 14 +++++++------- scripts/run_mpi.sh | 7 ------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 698093ff4..5dcafae61 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -114,7 +114,7 @@ jobs: sudo apt-get update sudo apt-get install gcc-13 g++-13 sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install libomp-dev sudo apt-get install valgrind python3 -m pip install xlsxwriter @@ -185,7 +185,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install python3-pip sudo apt-get install valgrind wget https://apt.llvm.org/llvm.sh @@ -255,7 +255,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install python3-pip sudo apt-get install valgrind wget https://apt.llvm.org/llvm.sh @@ -326,7 +326,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh @@ -391,7 +391,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh @@ -834,7 +834,7 @@ jobs: sudo apt-get update sudo apt-get install gcc g++ sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install libomp-dev sudo apt-get install valgrind sudo apt-get install gcovr lcov @@ -911,7 +911,7 @@ jobs: sudo apt-get update sudo apt-get install gcc-12 g++-12 sudo apt-get install ninja-build - sudo apt-get install mpich libmpich* mpi* openmpi-bin + sudo apt-get install mpich sudo apt-get install libomp-dev sudo apt-get install valgrind python3 -m pip install xlsxwriter diff --git a/scripts/run_mpi.sh b/scripts/run_mpi.sh index 65bc2b0ba..2994fa3c5 100644 --- a/scripts/run_mpi.sh +++ b/scripts/run_mpi.sh @@ -12,15 +12,8 @@ fi ./build/bin/ref_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating if [[ -z "$ASAN_RUN" ]]; then - if [[ $OSTYPE == "linux-gnu" ]]; then - mpirun --oversubscribe -np $PROC_COUNT ./build/bin/sample_mpi - mpirun --oversubscribe -np $PROC_COUNT ./build/bin/sample_mpi_boost - mpirun --oversubscribe -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating - mpirun --oversubscribe -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating - elif [[ $OSTYPE == "darwin"* ]]; then mpirun -np $PROC_COUNT ./build/bin/sample_mpi mpirun -np $PROC_COUNT ./build/bin/sample_mpi_boost mpirun -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating mpirun -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating - fi fi From 02c2fbd967f543f4457747e4f56c6c2bc9fb5853 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Wed, 15 Jan 2025 14:58:13 +0100 Subject: [PATCH 10/16] fix sanitizer --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5dcafae61..798f37f13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -326,7 +326,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich + sudo apt-get install openmpi sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh @@ -391,7 +391,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich + sudo apt-get install openmpi sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh From 6ca62f9cb8c66fedcdd0310d3b78f52a1ff20798 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Wed, 15 Jan 2025 15:29:53 +0100 Subject: [PATCH 11/16] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 798f37f13..54cdcb66e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -326,7 +326,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install openmpi + sudo apt-get install openmpi-bin sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh @@ -391,7 +391,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install openmpi + sudo apt-get install openmpi-bin sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh From a1684cda4ed37347f6c2f9cda7f63d3d02fdd8c5 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Wed, 15 Jan 2025 14:58:13 +0100 Subject: [PATCH 12/16] fix sanitizer --- .github/workflows/main.yml | 6 +++--- scripts/run_mpi.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5dcafae61..44a5c31be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -326,7 +326,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich + sudo apt-get install mpich libmpich* mpi* openmpi-bin sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh @@ -355,7 +355,7 @@ jobs: - name: Run tests (MPI) run: | export ASAN_RUN=1 - source scripts/run_mpi.sh + source scripts/run_mpi.sh "--oversubscribe" env: PROC_COUNT: 2 - name: Run tests (threads, num_threads=1) @@ -391,7 +391,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install ninja-build - sudo apt-get install mpich + sudo apt-get install mpich libmpich* mpi* openmpi-bin sudo apt-get install python3-pip wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh diff --git a/scripts/run_mpi.sh b/scripts/run_mpi.sh index 2994fa3c5..9eb1bac5f 100644 --- a/scripts/run_mpi.sh +++ b/scripts/run_mpi.sh @@ -12,8 +12,8 @@ fi ./build/bin/ref_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating if [[ -z "$ASAN_RUN" ]]; then - mpirun -np $PROC_COUNT ./build/bin/sample_mpi - mpirun -np $PROC_COUNT ./build/bin/sample_mpi_boost - mpirun -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating - mpirun -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating + mpirun $1 -np $PROC_COUNT ./build/bin/sample_mpi + mpirun $1 -np $PROC_COUNT ./build/bin/sample_mpi_boost + mpirun $1 -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating + mpirun $1 -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating fi From d5fea1a94ecb2351752852b1cf2950a85a80582e Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Wed, 15 Jan 2025 19:34:00 +0100 Subject: [PATCH 13/16] fix perf counter checker --- tasks/all/example/perf_tests/perf_omp.cpp | 2 +- tasks/all/example/perf_tests/perf_tbb.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/all/example/perf_tests/perf_omp.cpp b/tasks/all/example/perf_tests/perf_omp.cpp index caae0a4a6..d1addf558 100644 --- a/tasks/all/example/perf_tests/perf_omp.cpp +++ b/tasks/all/example/perf_tests/perf_omp.cpp @@ -6,7 +6,7 @@ #include "core/perf/include/perf.hpp" #include "omp/example/include/ops_omp.hpp" -TEST(openmp_example_perf_test, test_pipeline_run) { +TEST(all_example_perf_test, test_pipeline_run) { const int count = 100; // Create data diff --git a/tasks/all/example/perf_tests/perf_tbb.cpp b/tasks/all/example/perf_tests/perf_tbb.cpp index 518d0bd61..5b67597b7 100644 --- a/tasks/all/example/perf_tests/perf_tbb.cpp +++ b/tasks/all/example/perf_tests/perf_tbb.cpp @@ -6,7 +6,7 @@ #include "core/perf/include/perf.hpp" #include "tbb/example/include/ops_tbb.hpp" -TEST(tbb_example_perf_test, test_task_run) { +TEST(all_example_perf_test, test_task_run) { const int count = 100; // Create data From 8bda7db4026c85e5b8d5ee22456913406b537253 Mon Sep 17 00:00:00 2001 From: Alexander Nesterov Date: Wed, 15 Jan 2025 23:35:59 +0100 Subject: [PATCH 14/16] fix scripts --- scripts/create_perf_table.py | 5 ++++- scripts/run_perf_collector.sh | 8 ++++---- tasks/all/example/perf_tests/perf_omp.cpp | 9 +++++++-- tasks/all/example/perf_tests/perf_tbb.cpp | 8 ++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/create_perf_table.py b/scripts/create_perf_table.py index d33b26aff..79a7e0f56 100644 --- a/scripts/create_perf_table.py +++ b/scripts/create_perf_table.py @@ -83,7 +83,10 @@ continue par_time = result_tables[table_name][task_name][type_of_task] seq_time = result_tables[table_name][task_name]["seq"] - speed_up = seq_time / par_time + if par_time == 0: + speed_up = -1 + else: + speed_up = seq_time / par_time efficiency = speed_up / cpu_num worksheet.write(it_j, it_i, par_time) it_i += 1 diff --git a/scripts/run_perf_collector.sh b/scripts/run_perf_collector.sh index a27c18bca..f319b0f0d 100644 --- a/scripts/run_perf_collector.sh +++ b/scripts/run_perf_collector.sh @@ -2,11 +2,11 @@ if [[ -z "$ASAN_RUN" ]]; then if [[ $OSTYPE == "linux-gnu" ]]; then - mpirun --oversubscribe -np 4 ./build/bin/all_perf_tests - mpirun --oversubscribe -np 4 ./build/bin/mpi_perf_tests + mpirun -np 4 ./build/bin/all_perf_tests --gtest_color=no + mpirun -np 4 ./build/bin/mpi_perf_tests --gtest_color=no elif [[ $OSTYPE == "darwin"* ]]; then - mpirun -np 2 ./build/bin/all_perf_tests - mpirun -np 2 ./build/bin/mpi_perf_tests + mpirun -np 2 ./build/bin/all_perf_tests --gtest_color=no + mpirun -np 2 ./build/bin/mpi_perf_tests --gtest_color=no fi fi ./build/bin/omp_perf_tests diff --git a/tasks/all/example/perf_tests/perf_omp.cpp b/tasks/all/example/perf_tests/perf_omp.cpp index d1addf558..31922ef15 100644 --- a/tasks/all/example/perf_tests/perf_omp.cpp +++ b/tasks/all/example/perf_tests/perf_omp.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include "core/perf/include/perf.hpp" @@ -34,6 +35,10 @@ TEST(all_example_perf_test, test_pipeline_run) { // Create Perf analyzer auto perf_analyzer = std::make_shared(test_task_omp); perf_analyzer->PipelineRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count + 1, out[0]); + + boost::mpi::communicator world; + if (world.rank() == 0) { + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); + } } diff --git a/tasks/all/example/perf_tests/perf_tbb.cpp b/tasks/all/example/perf_tests/perf_tbb.cpp index 5b67597b7..6d56c0016 100644 --- a/tasks/all/example/perf_tests/perf_tbb.cpp +++ b/tasks/all/example/perf_tests/perf_tbb.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include "core/perf/include/perf.hpp" @@ -35,6 +36,9 @@ TEST(all_example_perf_test, test_task_run) { // Create Perf analyzer auto perf_analyzer = std::make_shared(test_task_tbb); perf_analyzer->TaskRun(perf_attr, perf_results); - ppc::core::Perf::PrintPerfStatistic(perf_results); - ASSERT_EQ(count + 1, out[0]); + boost::mpi::communicator world; + if (world.rank() == 0) { + ppc::core::Perf::PrintPerfStatistic(perf_results); + ASSERT_EQ(count + 1, out[0]); + } } From f004bce2cdcb7bad896d899fd3b4d2af2857ffb3 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Wed, 15 Jan 2025 23:59:04 +0100 Subject: [PATCH 15/16] Update main.yml --- .github/workflows/main.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44a5c31be..fff87db33 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -892,14 +892,6 @@ jobs: name: cov-report path: 'cov-report' ubuntu-gcc-build-perf-stats: - needs: - - macos-clang-build-extended - - ubuntu-gcc-build-codecov - - ubuntu-gcc-build-extended - - ubuntu-clang-build-extended - - ubuntu-clang-sanitizer-build-extended - - windows-clang-build-extended - - windows-msvc-build-extended runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From a0d0a56547f9e2155ab9b3cd56191f4644698d91 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Thu, 16 Jan 2025 00:13:04 +0100 Subject: [PATCH 16/16] Update main.yml --- .github/workflows/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fff87db33..44a5c31be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -892,6 +892,14 @@ jobs: name: cov-report path: 'cov-report' ubuntu-gcc-build-perf-stats: + needs: + - macos-clang-build-extended + - ubuntu-gcc-build-codecov + - ubuntu-gcc-build-extended + - ubuntu-clang-build-extended + - ubuntu-clang-sanitizer-build-extended + - windows-clang-build-extended + - windows-msvc-build-extended runs-on: ubuntu-latest steps: - uses: actions/checkout@v4