Browse Source

fixes #2238

Always obey omp_get_max_threads() when build with USE_OPENMP
tags/v0.3.11^2
Jussi Enkovaara 5 years ago
parent
commit
10a2923f64
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      common_thread.h

+ 5
- 5
common_thread.h View File

@@ -132,18 +132,18 @@ extern int blas_server_avail;
static __inline int num_cpu_avail(int level) { static __inline int num_cpu_avail(int level) {


#ifdef USE_OPENMP #ifdef USE_OPENMP
int openmp_nthreads=0;
int openmp_nthreads=omp_get_max_threads();
#endif #endif


#ifndef USE_OPENMP
if (blas_cpu_number == 1 if (blas_cpu_number == 1
#endif
#ifdef USE_OPENMP #ifdef USE_OPENMP
|| omp_in_parallel()
if (openmp_nthreads == 1 || omp_in_parallel()
#endif #endif
) return 1;
) return 1;


#ifdef USE_OPENMP #ifdef USE_OPENMP
openmp_nthreads=omp_get_max_threads();
if (blas_cpu_number != openmp_nthreads) { if (blas_cpu_number != openmp_nthreads) {
goto_set_num_threads(openmp_nthreads); goto_set_num_threads(openmp_nthreads);
} }


Loading…
Cancel
Save