This is an automated email from the ASF dual-hosted git repository. haibin pushed a commit to branch v1.4.x in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/v1.4.x by this push: new d772a4b Revert "Manually track num_max_thread (#12380)" (#13501) (#13517) d772a4b is described below commit d772a4b64e600eb55e019cdaec4e5a09de7643e6 Author: Anirudh Subramanian <anirudh2...@apache.org> AuthorDate: Mon Dec 3 15:39:53 2018 -0800 Revert "Manually track num_max_thread (#12380)" (#13501) (#13517) This reverts commit 75410210e07a5fab5e044348aee276d578d5857e. --- src/engine/openmp.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/engine/openmp.cc b/src/engine/openmp.cc index 64899b0..8fe3939 100644 --- a/src/engine/openmp.cc +++ b/src/engine/openmp.cc @@ -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(); @@ -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();