File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ extern void goto_set_num_threads(int nthreads);
5353/* Global Parameter */
5454extern int blas_cpu_number ;
5555extern int blas_num_threads ;
56+ extern int blas_num_threads_set ;
5657extern int blas_omp_linked ;
5758
5859#define BLAS_LEGACY 0x8000U
@@ -137,9 +138,13 @@ typedef struct blas_queue {
137138extern int blas_server_avail ;
138139
139140static __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
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ static void adjust_thread_buffers() {
100100
101101void goto_set_num_threads (int num_threads ) {
102102
103+ blas_num_threads_set = 1 ;
104+ if (num_threads < 0 ) blas_num_threads_set = 0 ;
103105 if (num_threads < 1 ) num_threads = blas_num_threads ;
104106
105107 if (num_threads > MAX_CPU_NUMBER ) num_threads = MAX_CPU_NUMBER ;
Original file line number Diff line number Diff line change @@ -422,6 +422,8 @@ This value is equal or large than blas_cpu_number. This means some threads are s
422422*/
423423int blas_num_threads = 0 ;
424424
425+ int blas_num_threads_set = 0 ;
426+
425427int goto_get_num_procs (void ) {
426428 return blas_cpu_number ;
427429}
@@ -1994,6 +1996,8 @@ This value is equal or large than blas_cpu_number. This means some threads are s
19941996*/
19951997int blas_num_threads = 0 ;
19961998
1999+ int blas_num_threads_set = 0 ;
2000+
19972001int goto_get_num_procs (void ) {
19982002 return blas_cpu_number ;
19992003}
Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ The numbers of threads in the thread pool.
283283This value is equal or large than blas_cpu_number. This means some threads are sleep.
284284*/
285285int blas_num_threads = 0 ;
286+ int blas_num_threads_set = 0 ;
286287
287288int goto_get_num_procs (void ) {
288289 return blas_cpu_number ;
You can’t perform that action at this time.
0 commit comments