Observe any stricter (OpenMP) thread count limit imposed by openblas_set_num_threads()tags/v0.3.22^2
| @@ -53,6 +53,7 @@ extern void goto_set_num_threads(int nthreads); | |||||
| /* Global Parameter */ | /* Global Parameter */ | ||||
| extern int blas_cpu_number; | extern int blas_cpu_number; | ||||
| extern int blas_num_threads; | extern int blas_num_threads; | ||||
| extern int blas_num_threads_set; | |||||
| extern int blas_omp_linked; | extern int blas_omp_linked; | ||||
| #define BLAS_LEGACY 0x8000U | #define BLAS_LEGACY 0x8000U | ||||
| @@ -137,9 +138,13 @@ typedef struct blas_queue { | |||||
| extern int blas_server_avail; | extern int blas_server_avail; | ||||
| static __inline int num_cpu_avail(int level) { | static __inline int num_cpu_avail(int level) { | ||||
| int openmp_nthreads; | |||||
| #ifdef USE_OPENMP | #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 | #endif | ||||
| #ifndef USE_OPENMP | #ifndef USE_OPENMP | ||||
| @@ -100,6 +100,8 @@ static void adjust_thread_buffers() { | |||||
| void goto_set_num_threads(int num_threads) { | void goto_set_num_threads(int num_threads) { | ||||
| blas_num_threads_set = 1; | |||||
| if (num_threads < 0) blas_num_threads_set = 0; | |||||
| if (num_threads < 1) num_threads = blas_num_threads; | if (num_threads < 1) num_threads = blas_num_threads; | ||||
| if (num_threads > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER; | if (num_threads > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER; | ||||
| @@ -422,6 +422,8 @@ This value is equal or large than blas_cpu_number. This means some threads are s | |||||
| */ | */ | ||||
| int blas_num_threads = 0; | int blas_num_threads = 0; | ||||
| int blas_num_threads_set = 0; | |||||
| int goto_get_num_procs (void) { | int goto_get_num_procs (void) { | ||||
| return blas_cpu_number; | return blas_cpu_number; | ||||
| } | } | ||||
| @@ -1994,6 +1996,8 @@ This value is equal or large than blas_cpu_number. This means some threads are s | |||||
| */ | */ | ||||
| int blas_num_threads = 0; | int blas_num_threads = 0; | ||||
| int blas_num_threads_set = 0; | |||||
| int goto_get_num_procs (void) { | int goto_get_num_procs (void) { | ||||
| return blas_cpu_number; | return blas_cpu_number; | ||||
| } | } | ||||
| @@ -283,6 +283,7 @@ The numbers of threads in the thread pool. | |||||
| This value is equal or large than blas_cpu_number. This means some threads are sleep. | This value is equal or large than blas_cpu_number. This means some threads are sleep. | ||||
| */ | */ | ||||
| int blas_num_threads = 0; | int blas_num_threads = 0; | ||||
| int blas_num_threads_set = 0; | |||||
| int goto_get_num_procs (void) { | int goto_get_num_procs (void) { | ||||
| return blas_cpu_number; | return blas_cpu_number; | ||||