Ref #62. In OpenMP implementation, check the return value of omp_get_max_threads().
It makes sure the return value as same as blas_cpu_numbers which is an internal global variable to store the number of threads in OpenBLAS.
This commit is contained in:
parent
66a3c6df4e
commit
ba31b19c00
|
@ -39,6 +39,11 @@
|
||||||
#ifndef COMMON_THREAD
|
#ifndef COMMON_THREAD
|
||||||
#define COMMON_THREAD
|
#define COMMON_THREAD
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
|
#include <omp.h>
|
||||||
|
extern void goto_set_num_threads(int nthreads);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Basic Thread Debugging */
|
/* Basic Thread Debugging */
|
||||||
#undef SMP_DEBUG
|
#undef SMP_DEBUG
|
||||||
|
|
||||||
|
@ -126,6 +131,10 @@ extern int blas_server_avail;
|
||||||
|
|
||||||
static __inline int num_cpu_avail(int level) {
|
static __inline int num_cpu_avail(int level) {
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
|
int openmp_nthreads=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((blas_cpu_number == 1)
|
if ((blas_cpu_number == 1)
|
||||||
|
|
||||||
#ifdef USE_OPENMP
|
#ifdef USE_OPENMP
|
||||||
|
@ -133,6 +142,13 @@ static __inline int num_cpu_avail(int level) {
|
||||||
#endif
|
#endif
|
||||||
) return 1;
|
) return 1;
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
|
openmp_nthreads=omp_get_max_threads();
|
||||||
|
if (blas_cpu_number != openmp_nthreads) {
|
||||||
|
goto_set_num_threads(openmp_nthreads);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return blas_cpu_number;
|
return blas_cpu_number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue