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

 ##########
 File path: src/engine/openmp.cc
 ##########
 @@ -74,17 +74,17 @@ void OpenMP::set_reserve_cores(int cores) {
   reserve_cores_ = cores;
 #ifdef _OPENMP
   if (reserve_cores_ >= omp_thread_max_) {
-    omp_set_num_threads(1);
+    omp_thread_max_ = 1;
   } else {
-    omp_set_num_threads(omp_thread_max_ - reserve_cores_);
+    omp_thread_max_ -= reserve_cores_;
   }
 #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();
 
 Review comment:
   these are the lines I changed. I removed the call and replaced it with the 
cached result.
   
   the only call is in the constructor (line 55).
   
   

----------------------------------------------------------------
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