azai91 commented on a change in pull request #12380: Manually track 
num_max_thread
URL: https://github.com/apache/incubator-mxnet/pull/12380#discussion_r227076318
 
 

 ##########
 File path: src/engine/openmp.cc
 ##########
 @@ -73,34 +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();
-  }
-  if (enabled_) {
-    int thread_count = omp_get_max_threads();
-    if (exclude_reserved) {
-      if (reserve_cores_ >= thread_count) {
-        thread_count = 1;
-      } else {
-        thread_count -= reserve_cores_;
-      }
-    }
-    // Check that OMP doesn't suggest more than our 'omp_thread_max_' value
-    if (!omp_thread_max_ || thread_count < omp_thread_max_) {
-      return thread_count;
-    }
+  if (omp_num_threads_set_in_environment_ || enabled_)
 
 Review comment:
   kk

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to