Add openblas_set_num_threads_local() and use of blas_omp_threads_local in OMP parallel regions
This commit is contained in:
parent
f9b2d7f225
commit
2e2e538b7c
1
cblas.h
1
cblas.h
|
@ -12,6 +12,7 @@ extern "C" {
|
||||||
/*Set the number of threads on runtime.*/
|
/*Set the number of threads on runtime.*/
|
||||||
void openblas_set_num_threads(int num_threads);
|
void openblas_set_num_threads(int num_threads);
|
||||||
void goto_set_num_threads(int num_threads);
|
void goto_set_num_threads(int num_threads);
|
||||||
|
int openblas_set_num_threads_local(int num_threads);
|
||||||
|
|
||||||
/*Get the number of threads on runtime.*/
|
/*Get the number of threads on runtime.*/
|
||||||
int openblas_get_num_threads(void);
|
int openblas_get_num_threads(void);
|
||||||
|
|
|
@ -137,19 +137,20 @@ typedef struct blas_queue {
|
||||||
|
|
||||||
extern int blas_server_avail;
|
extern int blas_server_avail;
|
||||||
extern int blas_omp_number_max;
|
extern int blas_omp_number_max;
|
||||||
|
extern int blas_omp_threads_local;
|
||||||
|
|
||||||
static __inline int num_cpu_avail(int level) {
|
static __inline int num_cpu_avail(int level) {
|
||||||
|
|
||||||
#ifdef USE_OPENMP
|
#ifdef USE_OPENMP
|
||||||
int openmp_nthreads;
|
int openmp_nthreads;
|
||||||
openmp_nthreads=omp_get_max_threads();
|
openmp_nthreads=omp_get_max_threads();
|
||||||
|
if (omp_in_parallel()) openmp_nthreads = blas_omp_threads_local;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USE_OPENMP
|
#ifndef USE_OPENMP
|
||||||
if (blas_cpu_number == 1
|
if (blas_cpu_number == 1
|
||||||
#endif
|
#else
|
||||||
#ifdef USE_OPENMP
|
if (openmp_nthreads == 1
|
||||||
if (openmp_nthreads == 1 || omp_in_parallel()
|
|
||||||
#endif
|
#endif
|
||||||
) return 1;
|
) return 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue