Merge pull request #2876 from Flamefire/omp_fork_fix

Lazyly reinit threads after a fork in OMP mode
This commit is contained in:
Martin Kroeker 2020-10-03 22:52:17 +02:00 committed by GitHub
commit f6e4cf2f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -48,6 +48,21 @@
#else #else
#ifndef likely
#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
#else
#define likely(x) (x)
#endif
#endif
#ifndef unlikely
#ifdef __GNUC__
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define unlikely(x) (x)
#endif
#endif
#ifndef OMP_SCHED #ifndef OMP_SCHED
#define OMP_SCHED static #define OMP_SCHED static
#endif #endif
@ -350,6 +365,9 @@ static void exec_threads(blas_queue_t *queue, int buf_index){
int exec_blas(BLASLONG num, blas_queue_t *queue){ int exec_blas(BLASLONG num, blas_queue_t *queue){
// Handle lazy re-init of the thread-pool after a POSIX fork
if (unlikely(blas_server_avail == 0)) blas_thread_init();
BLASLONG i, buf_index; BLASLONG i, buf_index;
if ((num <= 0) || (queue == NULL)) return 0; if ((num <= 0) || (queue == NULL)) return 0;