Skip to content

Commit 10a2923

Browse files
committed
fixes #2238
Always obey omp_get_max_threads() when build with USE_OPENMP
1 parent 5ff83a4 commit 10a2923

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

common_thread.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ extern int blas_server_avail;
132132
static __inline int num_cpu_avail(int level) {
133133

134134
#ifdef USE_OPENMP
135-
int openmp_nthreads=0;
135+
int openmp_nthreads=omp_get_max_threads();
136136
#endif
137137

138+
#ifndef USE_OPENMP
138139
if (blas_cpu_number == 1
139-
140+
#endif
140141
#ifdef USE_OPENMP
141-
|| omp_in_parallel()
142+
if (openmp_nthreads == 1 || omp_in_parallel()
142143
#endif
143-
) return 1;
144+
) return 1;
144145

145146
#ifdef USE_OPENMP
146-
openmp_nthreads=omp_get_max_threads();
147147
if (blas_cpu_number != openmp_nthreads) {
148148
goto_set_num_threads(openmp_nthreads);
149149
}

0 commit comments

Comments
 (0)