Skip to content

Commit 6af8e35

Browse files
authored
Merge pull request #1837 from embray/set-num-thread-after-fork
Ensure that blas_thread_init has been called in openblas_set_num_threads
2 parents 8a43baa + 38cf5d9 commit 6af8e35

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

driver/others/blas_server.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ void goto_set_num_threads(int num_threads) {
850850

851851
long i;
852852

853+
#ifdef SMP_SERVER
854+
// Handle lazy re-init of the thread-pool after a POSIX fork
855+
if (unlikely(blas_server_avail == 0)) blas_thread_init();
856+
#endif
857+
853858
if (num_threads < 1) num_threads = blas_num_threads;
854859

855860
#ifndef NO_AFFINITY

driver/others/blas_server_win32.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,12 @@ int BLASFUNC(blas_thread_shutdown)(void){
478478

479479
void goto_set_num_threads(int num_threads)
480480
{
481-
long i;
481+
long i;
482+
483+
#if defined(SMP_SERVER) && defined(OS_CYGWIN_NT)
484+
// Handle lazy re-init of the thread-pool after a POSIX fork
485+
if (unlikely(blas_server_avail == 0)) blas_thread_init();
486+
#endif
482487

483488
if (num_threads < 1) num_threads = blas_cpu_number;
484489

0 commit comments

Comments
 (0)