Merge pull request #1837 from embray/set-num-thread-after-fork

Ensure that blas_thread_init has been called in openblas_set_num_threads
This commit is contained in:
Martin Kroeker 2018-10-30 12:41:24 +01:00 committed by GitHub
commit 6af8e35a24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -850,6 +850,11 @@ void goto_set_num_threads(int num_threads) {
long i; long i;
#ifdef SMP_SERVER
// Handle lazy re-init of the thread-pool after a POSIX fork
if (unlikely(blas_server_avail == 0)) blas_thread_init();
#endif
if (num_threads < 1) num_threads = blas_num_threads; if (num_threads < 1) num_threads = blas_num_threads;
#ifndef NO_AFFINITY #ifndef NO_AFFINITY

View File

@ -478,7 +478,12 @@ int BLASFUNC(blas_thread_shutdown)(void){
void goto_set_num_threads(int num_threads) void goto_set_num_threads(int num_threads)
{ {
long i; long i;
#if defined(SMP_SERVER) && defined(OS_CYGWIN_NT)
// Handle lazy re-init of the thread-pool after a POSIX fork
if (unlikely(blas_server_avail == 0)) blas_thread_init();
#endif
if (num_threads < 1) num_threads = blas_cpu_number; if (num_threads < 1) num_threads = blas_cpu_number;