You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/15 01:21:26 UTC

[GitHub] cjolivier01 closed pull request #12380: Manually track num_max_thread

cjolivier01 closed pull request #12380: Manually track num_max_thread
URL: https://github.com/apache/incubator-mxnet/pull/12380
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/engine/openmp.cc b/src/engine/openmp.cc
index 8fe3939892d..64899b09660 100644
--- a/src/engine/openmp.cc
+++ b/src/engine/openmp.cc
@@ -73,18 +73,14 @@ void OpenMP::set_reserve_cores(int cores) {
   CHECK_GE(cores, 0);
   reserve_cores_ = cores;
 #ifdef _OPENMP
-  if (reserve_cores_ >= omp_thread_max_) {
-    omp_set_num_threads(1);
-  } else {
-    omp_set_num_threads(omp_thread_max_ - reserve_cores_);
-  }
+  omp_thread_max_ = std::max(omp_thread_max_ - reserve_cores_, 1);
 #endif
 }
 
 int OpenMP::GetRecommendedOMPThreadCount(bool exclude_reserved) const {
 #ifdef _OPENMP
   if (omp_num_threads_set_in_environment_) {
-    return omp_get_max_threads();
+    return omp_thread_max_;
   }
   if (enabled_) {
     int thread_count = omp_get_max_threads();
@@ -101,10 +97,8 @@ int OpenMP::GetRecommendedOMPThreadCount(bool exclude_reserved) const {
     }
     return omp_thread_max_;
   }
-  return 1;
-#else
-  return 1;
 #endif
+  return 1;
 }
 
 OpenMP *__init_omp__ = OpenMP::Get();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services