fixes #2238
authorJussi Enkovaara <jussi.enkovaara@csc.fi>
Tue, 7 Jul 2020 10:35:43 +0000 (13:35 +0300)
committerJussi Enkovaara <jussi.enkovaara@csc.fi>
Tue, 7 Jul 2020 10:35:43 +0000 (13:35 +0300)
Always obey omp_get_max_threads() when build with USE_OPENMP

common_thread.h

index 6ec40e096dabc903bb0f0d5baf0ade86eb199b22..ec0c65b2204346418f839201aaa6cb1064614528 100644 (file)
@@ -132,18 +132,18 @@ extern int blas_server_avail;
 static __inline int num_cpu_avail(int level) {
 
 #ifdef USE_OPENMP
-       int openmp_nthreads=0;
+       int openmp_nthreads=omp_get_max_threads();
 #endif
 
+#ifndef USE_OPENMP 
   if (blas_cpu_number == 1
-
+#endif
 #ifdef USE_OPENMP
-      || omp_in_parallel()
+     if (openmp_nthreads == 1 || omp_in_parallel()
 #endif
-      ) return 1;
+      ) return 1;        
 
 #ifdef USE_OPENMP
-  openmp_nthreads=omp_get_max_threads();
   if (blas_cpu_number != openmp_nthreads) {
          goto_set_num_threads(openmp_nthreads);
   }