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/08/30 16:32:13 UTC

[GitHub] lupesko commented on a change in pull request #12380: Manually track num_max_thread

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

 ##########
 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:
   You mention you want to call `omp_get_max_threads()` once and cache the results. This is another place where the API is called (in addition to line 55). Is that intentional? will it not create the same issue?

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