Skip to content

Commit 9f9d001

Browse files
authored
observe thread limit imposed by openblas_set_num_threads()
1 parent fe5d3ca commit 9f9d001

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

common_thread.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ extern void goto_set_num_threads(int nthreads);
5353
/* Global Parameter */
5454
extern int blas_cpu_number;
5555
extern int blas_num_threads;
56+
extern int blas_num_threads_set;
5657
extern int blas_omp_linked;
5758

5859
#define BLAS_LEGACY 0x8000U
@@ -137,9 +138,13 @@ typedef struct blas_queue {
137138
extern int blas_server_avail;
138139

139140
static __inline int num_cpu_avail(int level) {
141+
int openmp_nthreads;
140142

141143
#ifdef USE_OPENMP
142-
int openmp_nthreads=omp_get_max_threads();
144+
if (blas_num_threads_set == 0)
145+
openmp_nthreads=omp_get_max_threads();
146+
else
147+
openmp_nthreads=blas_cpu_number;
143148
#endif
144149

145150
#ifndef USE_OPENMP

0 commit comments

Comments
 (0)