From ecc912cb51792bdc04c496043dc398ffb466f1e6 Mon Sep 17 00:00:00 2001 From: kmichaelk <130953568+kmichaelk@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:06:40 +0300 Subject: [PATCH] Cleanup existing std::shared_ptr usage --- tasks/mpi/example/func_tests/main.cpp | 38 ++++++++++----------------- tasks/mpi/example/perf_tests/main.cpp | 8 +++--- tasks/omp/example/func_tests/main.cpp | 24 ++++++----------- tasks/omp/example/perf_tests/main.cpp | 8 +++--- tasks/seq/example/perf_tests/main.cpp | 8 +++--- tasks/stl/example/func_tests/main.cpp | 31 ++++++++-------------- tasks/stl/example/perf_tests/main.cpp | 8 +++--- tasks/tbb/example/func_tests/main.cpp | 30 +++++++-------------- tasks/tbb/example/perf_tests/main.cpp | 8 +++--- 9 files changed, 63 insertions(+), 100 deletions(-) diff --git a/tasks/mpi/example/func_tests/main.cpp b/tasks/mpi/example/func_tests/main.cpp index 127cce1d..c9203843 100644 --- a/tasks/mpi/example/func_tests/main.cpp +++ b/tasks/mpi/example/func_tests/main.cpp @@ -33,11 +33,9 @@ TEST(Parallel_Operations_MPI, Test_Sum) { std::vector reference_sum(1, 0); // Create TaskData - auto taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(global_vec.data())); - taskDataSeq->inputs_count.emplace_back(global_vec.size()); + auto taskDataSeq = std::make_shared(*taskDataPar); + taskDataSeq->outputs.clear(); taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); - taskDataSeq->outputs_count.emplace_back(reference_sum.size()); // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "+"); @@ -77,11 +75,9 @@ TEST(Parallel_Operations_MPI, Test_Diff) { std::vector reference_diff(1, 0); // Create TaskData - auto taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(global_vec.data())); - taskDataSeq->inputs_count.emplace_back(global_vec.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_diff.data())); - taskDataSeq->outputs_count.emplace_back(reference_diff.size()); + auto taskDataSeq = std::make_shared(*taskDataPar); + taskDataSeq->outputs.clear(); + taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "-"); @@ -121,11 +117,9 @@ TEST(Parallel_Operations_MPI, Test_Diff_2) { std::vector reference_diff(1, 0); // Create TaskData - auto taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(global_vec.data())); - taskDataSeq->inputs_count.emplace_back(global_vec.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_diff.data())); - taskDataSeq->outputs_count.emplace_back(reference_diff.size()); + auto taskDataSeq = std::make_shared(*taskDataPar); + taskDataSeq->outputs.clear(); + taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "-"); @@ -165,11 +159,9 @@ TEST(Parallel_Operations_MPI, Test_Max) { std::vector reference_max(1, 0); // Create TaskData - auto taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(global_vec.data())); - taskDataSeq->inputs_count.emplace_back(global_vec.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_max.data())); - taskDataSeq->outputs_count.emplace_back(reference_max.size()); + auto taskDataSeq = std::make_shared(*taskDataPar); + taskDataSeq->outputs.clear(); + taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "max"); @@ -209,11 +201,9 @@ TEST(Parallel_Operations_MPI, Test_Max_2) { std::vector reference_max(1, 0); // Create TaskData - auto taskDataSeq = std::make_shared(); - taskDataSeq->inputs.emplace_back(reinterpret_cast(global_vec.data())); - taskDataSeq->inputs_count.emplace_back(global_vec.size()); - taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_max.data())); - taskDataSeq->outputs_count.emplace_back(reference_max.size()); + auto taskDataSeq = std::make_shared(*taskDataPar); + taskDataSeq->outputs.clear(); + taskDataSeq->outputs.emplace_back(reinterpret_cast(reference_sum.data())); // Create Task nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "max"); diff --git a/tasks/mpi/example/perf_tests/main.cpp b/tasks/mpi/example/perf_tests/main.cpp index 6939645d..e5da07c0 100644 --- a/tasks/mpi/example/perf_tests/main.cpp +++ b/tasks/mpi/example/perf_tests/main.cpp @@ -38,8 +38,8 @@ TEST(mpi_example_perf_test, test_pipeline_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testMpiTaskParallel); - perfAnalyzer->pipeline_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testMpiTaskParallel); + perfAnalyzer.pipeline_run(perfAttr, perfResults); if (world.rank() == 0) { ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count_size_vector, global_sum[0]); @@ -78,8 +78,8 @@ TEST(mpi_example_perf_test, test_task_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testMpiTaskParallel); - perfAnalyzer->task_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testMpiTaskParallel); + perfAnalyzer.task_run(perfAttr, perfResults); if (world.rank() == 0) { ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count_size_vector, global_sum[0]); diff --git a/tasks/omp/example/func_tests/main.cpp b/tasks/omp/example/func_tests/main.cpp index 1a685bfa..8da6d0dd 100644 --- a/tasks/omp/example/func_tests/main.cpp +++ b/tasks/omp/example/func_tests/main.cpp @@ -66,11 +66,9 @@ TEST(Parallel_Operations_OpenMP, Test_Diff) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "-"); @@ -104,11 +102,9 @@ TEST(Parallel_Operations_OpenMP, Test_Diff_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "-"); @@ -142,11 +138,9 @@ TEST(Parallel_Operations_OpenMP, Test_Mult) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "*"); @@ -180,11 +174,9 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "*"); diff --git a/tasks/omp/example/perf_tests/main.cpp b/tasks/omp/example/perf_tests/main.cpp index a8b1cb78..a7ab2466 100644 --- a/tasks/omp/example/perf_tests/main.cpp +++ b/tasks/omp/example/perf_tests/main.cpp @@ -32,8 +32,8 @@ TEST(openmp_example_perf_test, test_pipeline_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskOMP); - perfAnalyzer->pipeline_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskOMP); + perfAnalyzer.pipeline_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count + 1, out[0]); } @@ -64,8 +64,8 @@ TEST(openmp_example_perf_test, test_task_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskOMP); - perfAnalyzer->task_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskOMP); + perfAnalyzer.task_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count + 1, out[0]); } diff --git a/tasks/seq/example/perf_tests/main.cpp b/tasks/seq/example/perf_tests/main.cpp index 23fed019..a335e008 100644 --- a/tasks/seq/example/perf_tests/main.cpp +++ b/tasks/seq/example/perf_tests/main.cpp @@ -36,8 +36,8 @@ TEST(sequential_example_perf_test, test_pipeline_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskSequential); - perfAnalyzer->pipeline_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskSequential); + perfAnalyzer.pipeline_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count, out[0]); } @@ -73,8 +73,8 @@ TEST(sequential_example_perf_test, test_task_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskSequential); - perfAnalyzer->task_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskSequential); + perfAnalyzer.task_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count, out[0]); } diff --git a/tasks/stl/example/func_tests/main.cpp b/tasks/stl/example/func_tests/main.cpp index e83dd809..a6d506dc 100644 --- a/tasks/stl/example/func_tests/main.cpp +++ b/tasks/stl/example/func_tests/main.cpp @@ -29,11 +29,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+"); @@ -68,11 +67,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+"); @@ -107,11 +104,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_3) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+"); @@ -146,11 +141,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "-"); @@ -185,11 +178,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "-"); diff --git a/tasks/stl/example/perf_tests/main.cpp b/tasks/stl/example/perf_tests/main.cpp index 0e81ce7e..0d85089e 100644 --- a/tasks/stl/example/perf_tests/main.cpp +++ b/tasks/stl/example/perf_tests/main.cpp @@ -36,8 +36,8 @@ TEST(stl_example_perf_test, test_pipeline_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskSTL); - perfAnalyzer->pipeline_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskSTL); + perfAnalyzer.pipeline_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count, out[0]); } @@ -73,8 +73,8 @@ TEST(stl_example_perf_test, test_task_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskSTL); - perfAnalyzer->task_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskSTL); + perfAnalyzer.task_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count, out[0]); } diff --git a/tasks/tbb/example/func_tests/main.cpp b/tasks/tbb/example/func_tests/main.cpp index e0a05ff7..ff6a34ef 100644 --- a/tasks/tbb/example/func_tests/main.cpp +++ b/tasks/tbb/example/func_tests/main.cpp @@ -27,11 +27,9 @@ TEST(Parallel_Operations_TBB, Test_Sum) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "+"); @@ -65,11 +63,9 @@ TEST(Parallel_Operations_TBB, Test_Diff) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "-"); @@ -103,11 +99,9 @@ TEST(Parallel_Operations_TBB, Test_Diff_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "-"); @@ -141,11 +135,9 @@ TEST(Parallel_Operations_TBB, Test_Mult) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "*"); @@ -179,11 +171,9 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { std::vector par_res(1, 0); // Create TaskData - auto taskDataPar = std::make_shared(); - taskDataPar->inputs.emplace_back(reinterpret_cast(vec.data())); - taskDataPar->inputs_count.emplace_back(vec.size()); + auto taskDataPar = std::make_shared(*taskDataSeq); + taskDataPar->outputs.clear(); taskDataPar->outputs.emplace_back(reinterpret_cast(par_res.data())); - taskDataPar->outputs_count.emplace_back(par_res.size()); // Create Task nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "*"); diff --git a/tasks/tbb/example/perf_tests/main.cpp b/tasks/tbb/example/perf_tests/main.cpp index 5b1e39a9..fac487b9 100644 --- a/tasks/tbb/example/perf_tests/main.cpp +++ b/tasks/tbb/example/perf_tests/main.cpp @@ -33,8 +33,8 @@ TEST(tbb_example_perf_test, test_pipeline_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskTBB); - perfAnalyzer->pipeline_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskTBB); + perfAnalyzer.pipeline_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count + 1, out[0]); } @@ -66,8 +66,8 @@ TEST(tbb_example_perf_test, test_task_run) { auto perfResults = std::make_shared(); // Create Perf analyzer - auto perfAnalyzer = std::make_shared(testTaskTBB); - perfAnalyzer->task_run(perfAttr, perfResults); + ppc::core::Perf perfAnalyzer(testTaskTBB); + perfAnalyzer.task_run(perfAttr, perfResults); ppc::core::Perf::print_perf_statistic(perfResults); ASSERT_EQ(count + 1, out[0]); }