File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ extern "C" {
1212/*Set the number of threads on runtime.*/
1313void openblas_set_num_threads (int num_threads );
1414void goto_set_num_threads (int num_threads );
15+ int openblas_set_num_threads_local (int num_threads );
1516
1617/*Get the number of threads on runtime.*/
1718int openblas_get_num_threads (void );
Original file line number Diff line number Diff line change @@ -137,19 +137,20 @@ typedef struct blas_queue {
137137
138138extern int blas_server_avail ;
139139extern int blas_omp_number_max ;
140+ extern int blas_omp_threads_local ;
140141
141142static __inline int num_cpu_avail (int level ) {
142143
143144#ifdef USE_OPENMP
144145int openmp_nthreads ;
145146 openmp_nthreads = omp_get_max_threads ();
147+ if (omp_in_parallel ()) openmp_nthreads = blas_omp_threads_local ;
146148#endif
147149
148150#ifndef USE_OPENMP
149151 if (blas_cpu_number == 1
150- #endif
151- #ifdef USE_OPENMP
152- if (openmp_nthreads == 1 || omp_in_parallel ()
152+ #else
153+ if (openmp_nthreads == 1
153154#endif
154155 ) return 1 ;
155156
You can’t perform that action at this time.
0 commit comments