From b627ce1ff6af386bbbd0cf0d7c464d59d19d5135 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Mon, 2 Jun 2025 12:52:26 +0200 Subject: [PATCH] Rename GetPPCNumThreads function --- modules/core/util/func_tests/util_tests.cpp | 8 ++++---- modules/core/util/include/util.hpp | 2 +- modules/core/util/src/util.cpp | 2 +- tasks/all/example/src/ops_all.cpp | 4 ++-- tasks/all/runner.cpp | 2 +- tasks/stl/example/src/ops_stl.cpp | 2 +- tasks/tbb/example/src/ops_tbb.cpp | 2 +- tasks/tbb/runner.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/core/util/func_tests/util_tests.cpp b/modules/core/util/func_tests/util_tests.cpp index 2b7ca7970..b55e7c2f2 100644 --- a/modules/core/util/func_tests/util_tests.cpp +++ b/modules/core/util/func_tests/util_tests.cpp @@ -8,11 +8,11 @@ TEST(util_tests, check_unset_env) { #ifndef _WIN32 - int save_var = ppc::util::GetPPCNumThreads(); + int save_var = ppc::util::GetNumThreads(); unsetenv("PPC_NUM_THREADS"); // NOLINT(concurrency-mt-unsafe) - EXPECT_EQ(ppc::util::GetPPCNumThreads(), 1); + EXPECT_EQ(ppc::util::GetNumThreads(), 1); setenv("PPC_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(concurrency-mt-unsafe) #else @@ -22,12 +22,12 @@ TEST(util_tests, check_unset_env) { TEST(util_tests, check_set_env) { #ifndef _WIN32 - int save_var = ppc::util::GetPPCNumThreads(); + int save_var = ppc::util::GetNumThreads(); const int num_threads = static_cast(std::thread::hardware_concurrency()); setenv("PPC_NUM_THREADS", std::to_string(num_threads).c_str(), 1); // NOLINT(concurrency-mt-unsafe) - EXPECT_EQ(ppc::util::GetPPCNumThreads(), num_threads); + EXPECT_EQ(ppc::util::GetNumThreads(), num_threads); setenv("PPC_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(concurrency-mt-unsafe) #else diff --git a/modules/core/util/include/util.hpp b/modules/core/util/include/util.hpp index 80070d14a..14da7994e 100644 --- a/modules/core/util/include/util.hpp +++ b/modules/core/util/include/util.hpp @@ -13,6 +13,6 @@ namespace ppc::util { std::string GetAbsolutePath(const std::string &relative_path); -int GetPPCNumThreads(); +int GetNumThreads(); } // namespace ppc::util diff --git a/modules/core/util/src/util.cpp b/modules/core/util/src/util.cpp index a1516e8d7..c5d94be91 100644 --- a/modules/core/util/src/util.cpp +++ b/modules/core/util/src/util.cpp @@ -16,7 +16,7 @@ std::string ppc::util::GetAbsolutePath(const std::string &relative_path) { return path.string(); } -int ppc::util::GetPPCNumThreads() { +int ppc::util::GetNumThreads() { #ifdef _WIN32 size_t len; char omp_env[100]; diff --git a/tasks/all/example/src/ops_all.cpp b/tasks/all/example/src/ops_all.cpp index eecb816e2..e59799d5b 100644 --- a/tasks/all/example/src/ops_all.cpp +++ b/tasks/all/example/src/ops_all.cpp @@ -23,7 +23,7 @@ void nesterov_a_test_task_all::MatMul(const std::vector &in_vec, int rc_siz } void nesterov_a_test_task_all::MatMulTBB(const std::vector &in_vec, int rc_size, std::vector &out_vec) { - tbb::parallel_for(0, ppc::util::GetPPCNumThreads(), [&](int i) { MatMul(in_vec, rc_size - i, out_vec); }); + tbb::parallel_for(0, ppc::util::GetNumThreads(), [&](int i) { MatMul(in_vec, rc_size - i, out_vec); }); MatMul(in_vec, rc_size, out_vec); } @@ -52,7 +52,7 @@ bool nesterov_a_test_task_all::TestTaskALL::RunImpl() { MatMulTBB(input_, rc_size_, output_); } - const int num_threads = ppc::util::GetPPCNumThreads(); + const int num_threads = ppc::util::GetNumThreads(); std::vector threads(num_threads); for (int i = 0; i < num_threads; i++) { threads[i] = std::thread(MatMul, std::cref(input_), rc_size_, std::ref(output_)); diff --git a/tasks/all/runner.cpp b/tasks/all/runner.cpp index 378c34a4c..745fa84d9 100644 --- a/tasks/all/runner.cpp +++ b/tasks/all/runner.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) { MPI_Init(&argc, &argv); // Limit the number of threads in TBB - tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetPPCNumThreads()); + tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads()); ::testing::InitGoogleTest(&argc, argv); diff --git a/tasks/stl/example/src/ops_stl.cpp b/tasks/stl/example/src/ops_stl.cpp index 608360d54..145d987e8 100644 --- a/tasks/stl/example/src/ops_stl.cpp +++ b/tasks/stl/example/src/ops_stl.cpp @@ -33,7 +33,7 @@ bool nesterov_a_test_task_stl::TestTaskSTL::PreProcessingImpl() { } bool nesterov_a_test_task_stl::TestTaskSTL::RunImpl() { - const int num_threads = ppc::util::GetPPCNumThreads(); + const int num_threads = ppc::util::GetNumThreads(); std::vector threads(num_threads); for (int i = 0; i < num_threads; i++) { threads[i] = std::thread(MatMul, std::cref(input_), rc_size_, std::ref(output_)); diff --git a/tasks/tbb/example/src/ops_tbb.cpp b/tasks/tbb/example/src/ops_tbb.cpp index 191dce5da..aaa423ebc 100644 --- a/tasks/tbb/example/src/ops_tbb.cpp +++ b/tasks/tbb/example/src/ops_tbb.cpp @@ -34,7 +34,7 @@ bool nesterov_a_test_task_tbb::TestTaskTBB::PreProcessingImpl() { } bool nesterov_a_test_task_tbb::TestTaskTBB::RunImpl() { - tbb::parallel_for(0, ppc::util::GetPPCNumThreads(), [&](int i) { MatMul(input_, rc_size_ - i, output_); }); + tbb::parallel_for(0, ppc::util::GetNumThreads(), [&](int i) { MatMul(input_, rc_size_ - i, output_); }); MatMul(input_, rc_size_, output_); return true; } diff --git a/tasks/tbb/runner.cpp b/tasks/tbb/runner.cpp index 2020b5414..7c18b9654 100644 --- a/tasks/tbb/runner.cpp +++ b/tasks/tbb/runner.cpp @@ -6,7 +6,7 @@ int main(int argc, char** argv) { // Limit the number of threads in TBB - tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetPPCNumThreads()); + tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads()); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();