Skip to content

Commit

Permalink
Cleanup existing std::shared_ptr usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kmichaelk committed Nov 4, 2024
1 parent 0cfd881 commit ecc912c
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 100 deletions.
38 changes: 14 additions & 24 deletions tasks/mpi/example/func_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ TEST(Parallel_Operations_MPI, Test_Sum) {
std::vector<int32_t> reference_sum(1, 0);

// Create TaskData
auto taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t*>(global_vec.data()));
taskDataSeq->inputs_count.emplace_back(global_vec.size());
auto taskDataSeq = std::make_shared<ppc::core::TaskData>(*taskDataPar);
taskDataSeq->outputs.clear();
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_sum.data()));
taskDataSeq->outputs_count.emplace_back(reference_sum.size());

// Create Task
nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "+");
Expand Down Expand Up @@ -77,11 +75,9 @@ TEST(Parallel_Operations_MPI, Test_Diff) {
std::vector<int32_t> reference_diff(1, 0);

// Create TaskData
auto taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t*>(global_vec.data()));
taskDataSeq->inputs_count.emplace_back(global_vec.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_diff.data()));
taskDataSeq->outputs_count.emplace_back(reference_diff.size());
auto taskDataSeq = std::make_shared<ppc::core::TaskData>(*taskDataPar);
taskDataSeq->outputs.clear();
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_sum.data()));

// Create Task
nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "-");
Expand Down Expand Up @@ -121,11 +117,9 @@ TEST(Parallel_Operations_MPI, Test_Diff_2) {
std::vector<int32_t> reference_diff(1, 0);

// Create TaskData
auto taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t*>(global_vec.data()));
taskDataSeq->inputs_count.emplace_back(global_vec.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_diff.data()));
taskDataSeq->outputs_count.emplace_back(reference_diff.size());
auto taskDataSeq = std::make_shared<ppc::core::TaskData>(*taskDataPar);
taskDataSeq->outputs.clear();
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_sum.data()));

// Create Task
nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "-");
Expand Down Expand Up @@ -165,11 +159,9 @@ TEST(Parallel_Operations_MPI, Test_Max) {
std::vector<int32_t> reference_max(1, 0);

// Create TaskData
auto taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t*>(global_vec.data()));
taskDataSeq->inputs_count.emplace_back(global_vec.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_max.data()));
taskDataSeq->outputs_count.emplace_back(reference_max.size());
auto taskDataSeq = std::make_shared<ppc::core::TaskData>(*taskDataPar);
taskDataSeq->outputs.clear();
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_sum.data()));

// Create Task
nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "max");
Expand Down Expand Up @@ -209,11 +201,9 @@ TEST(Parallel_Operations_MPI, Test_Max_2) {
std::vector<int32_t> reference_max(1, 0);

// Create TaskData
auto taskDataSeq = std::make_shared<ppc::core::TaskData>();
taskDataSeq->inputs.emplace_back(reinterpret_cast<uint8_t*>(global_vec.data()));
taskDataSeq->inputs_count.emplace_back(global_vec.size());
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_max.data()));
taskDataSeq->outputs_count.emplace_back(reference_max.size());
auto taskDataSeq = std::make_shared<ppc::core::TaskData>(*taskDataPar);
taskDataSeq->outputs.clear();
taskDataSeq->outputs.emplace_back(reinterpret_cast<uint8_t*>(reference_sum.data()));

// Create Task
nesterov_a_test_task_mpi::TestMPITaskSequential testMpiTaskSequential(taskDataSeq, "max");
Expand Down
8 changes: 4 additions & 4 deletions tasks/mpi/example/perf_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TEST(mpi_example_perf_test, test_pipeline_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
Expand Down Expand Up @@ -78,8 +78,8 @@ TEST(mpi_example_perf_test, test_task_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
Expand Down
24 changes: 8 additions & 16 deletions tasks/omp/example/func_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ TEST(Parallel_Operations_OpenMP, Test_Diff) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "-");
Expand Down Expand Up @@ -104,11 +102,9 @@ TEST(Parallel_Operations_OpenMP, Test_Diff_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "-");
Expand Down Expand Up @@ -142,11 +138,9 @@ TEST(Parallel_Operations_OpenMP, Test_Mult) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "*");
Expand Down Expand Up @@ -180,11 +174,9 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_omp::TestOMPTaskParallel testOmpTaskParallel(taskDataPar, "*");
Expand Down
8 changes: 4 additions & 4 deletions tasks/omp/example/perf_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ TEST(openmp_example_perf_test, test_pipeline_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down Expand Up @@ -64,8 +64,8 @@ TEST(openmp_example_perf_test, test_task_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down
8 changes: 4 additions & 4 deletions tasks/seq/example/perf_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ TEST(sequential_example_perf_test, test_pipeline_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down Expand Up @@ -73,8 +73,8 @@ TEST(sequential_example_perf_test, test_task_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down
31 changes: 11 additions & 20 deletions tasks/stl/example/func_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());

auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+");
Expand Down Expand Up @@ -68,11 +67,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+");
Expand Down Expand Up @@ -107,11 +104,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Sum_3) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "+");
Expand Down Expand Up @@ -146,11 +141,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "-");
Expand Down Expand Up @@ -185,11 +178,9 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_stl::TestSTLTaskParallel TestSTLTaskParallel(taskDataPar, "-");
Expand Down
8 changes: 4 additions & 4 deletions tasks/stl/example/perf_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ TEST(stl_example_perf_test, test_pipeline_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down Expand Up @@ -73,8 +73,8 @@ TEST(stl_example_perf_test, test_task_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down
30 changes: 10 additions & 20 deletions tasks/tbb/example/func_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ TEST(Parallel_Operations_TBB, Test_Sum) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "+");
Expand Down Expand Up @@ -65,11 +63,9 @@ TEST(Parallel_Operations_TBB, Test_Diff) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "-");
Expand Down Expand Up @@ -103,11 +99,9 @@ TEST(Parallel_Operations_TBB, Test_Diff_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "-");
Expand Down Expand Up @@ -141,11 +135,9 @@ TEST(Parallel_Operations_TBB, Test_Mult) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "*");
Expand Down Expand Up @@ -179,11 +171,9 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) {
std::vector<int> par_res(1, 0);

// Create TaskData
auto taskDataPar = std::make_shared<ppc::core::TaskData>();
taskDataPar->inputs.emplace_back(reinterpret_cast<uint8_t *>(vec.data()));
taskDataPar->inputs_count.emplace_back(vec.size());
auto taskDataPar = std::make_shared<ppc::core::TaskData>(*taskDataSeq);
taskDataPar->outputs.clear();
taskDataPar->outputs.emplace_back(reinterpret_cast<uint8_t *>(par_res.data()));
taskDataPar->outputs_count.emplace_back(par_res.size());

// Create Task
nesterov_a_test_task_tbb::TestTBBTaskParallel testTbbTaskParallel(taskDataPar, "*");
Expand Down
8 changes: 4 additions & 4 deletions tasks/tbb/example/perf_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ TEST(tbb_example_perf_test, test_pipeline_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down Expand Up @@ -66,8 +66,8 @@ TEST(tbb_example_perf_test, test_task_run) {
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(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]);
}
Expand Down

0 comments on commit ecc912c

Please sign in to comment.