Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/core/util/func_tests/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<int>(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
Expand Down
2 changes: 1 addition & 1 deletion modules/core/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
namespace ppc::util {

std::string GetAbsolutePath(const std::string &relative_path);
int GetPPCNumThreads();
int GetNumThreads();

} // namespace ppc::util
2 changes: 1 addition & 1 deletion modules/core/util/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions tasks/all/example/src/ops_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void nesterov_a_test_task_all::MatMul(const std::vector<int> &in_vec, int rc_siz
}

void nesterov_a_test_task_all::MatMulTBB(const std::vector<int> &in_vec, int rc_size, std::vector<int> &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);
}

Expand Down Expand Up @@ -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<std::thread> threads(num_threads);
for (int i = 0; i < num_threads; i++) {
threads[i] = std::thread(MatMul, std::cref(input_), rc_size_, std::ref(output_));
Expand Down
2 changes: 1 addition & 1 deletion tasks/all/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tasks/stl/example/src/ops_stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::thread> threads(num_threads);
for (int i = 0; i < num_threads; i++) {
threads[i] = std::thread(MatMul, std::cref(input_), rc_size_, std::ref(output_));
Expand Down
2 changes: 1 addition & 1 deletion tasks/tbb/example/src/ops_tbb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/tbb/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading