From 9f9d0012a3c953ce36bc739e9dd1905d9f007cb7 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 8 Mar 2023 23:38:34 +0100 Subject: [PATCH] observe thread limit imposed by openblas_set_num_threads() --- common_thread.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common_thread.h b/common_thread.h index a18df0d78..9de901826 100644 --- a/common_thread.h +++ b/common_thread.h @@ -53,6 +53,7 @@ extern void goto_set_num_threads(int nthreads); /* Global Parameter */ extern int blas_cpu_number; extern int blas_num_threads; +extern int blas_num_threads_set; extern int blas_omp_linked; #define BLAS_LEGACY 0x8000U @@ -137,9 +138,13 @@ typedef struct blas_queue { extern int blas_server_avail; static __inline int num_cpu_avail(int level) { +int openmp_nthreads; #ifdef USE_OPENMP - int openmp_nthreads=omp_get_max_threads(); + if (blas_num_threads_set == 0) + openmp_nthreads=omp_get_max_threads(); + else + openmp_nthreads=blas_cpu_number; #endif #ifndef USE_OPENMP