Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Revert "Manually track num_max_thread (#12380)" (#13501) (#13517)
Browse files Browse the repository at this point in the history
This reverts commit 7541021.
  • Loading branch information
anirudh2290 authored and eric-haibin-lin committed Dec 3, 2018
1 parent 4ab82e1 commit d772a4b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/engine/openmp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ void OpenMP::set_reserve_cores(int cores) {
CHECK_GE(cores, 0);
reserve_cores_ = cores;
#ifdef _OPENMP
omp_thread_max_ = std::max(omp_thread_max_ - reserve_cores_, 1);
if (reserve_cores_ >= omp_thread_max_) {
omp_set_num_threads(1);
} else {
omp_set_num_threads(omp_thread_max_ - reserve_cores_);
}
#endif
}

int OpenMP::GetRecommendedOMPThreadCount(bool exclude_reserved) const {
#ifdef _OPENMP
if (omp_num_threads_set_in_environment_) {
return omp_thread_max_;
return omp_get_max_threads();
}
if (enabled_) {
int thread_count = omp_get_max_threads();
Expand All @@ -97,8 +101,10 @@ int OpenMP::GetRecommendedOMPThreadCount(bool exclude_reserved) const {
}
return omp_thread_max_;
}
#endif
return 1;
#else
return 1;
#endif
}

OpenMP *__init_omp__ = OpenMP::Get();
Expand Down

0 comments on commit d772a4b

Please sign in to comment.