Merge pull request #2706 from jussienko/use-always-omp-threads

Fix OpenMP builds defaulting to singlethreading with OMP_PLACES or OMP_PROC_BIND set
This commit is contained in:
Martin Kroeker 2020-07-12 20:17:11 +02:00 committed by GitHub
commit 4fa283de66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View 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
#ifdef USE_OPENMP
|| omp_in_parallel()
#endif
) return 1;
#ifdef USE_OPENMP
if (openmp_nthreads == 1 || omp_in_parallel()
#endif
) return 1;
#ifdef USE_OPENMP
openmp_nthreads=omp_get_max_threads();
if (blas_cpu_number != openmp_nthreads) {
goto_set_num_threads(openmp_nthreads);
}