From 3326b924b324d49960e0f657f049e5658e7e6c69 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 26 Jul 2023 00:31:24 +0200 Subject: [PATCH] remove status variable blas_num_threads_set; initialize openmp thread maximum on startup --- driver/others/blas_server_omp.c | 4 +++- driver/others/memory.c | 4 ---- driver/others/memory_qalloc.c | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/driver/others/blas_server_omp.c b/driver/others/blas_server_omp.c index 2e0c0f38c..43764df00 100644 --- a/driver/others/blas_server_omp.c +++ b/driver/others/blas_server_omp.c @@ -68,6 +68,7 @@ #endif int blas_server_avail = 0; +int blas_omp_number_max = 0; extern int openblas_omp_adaptive_env(); @@ -100,7 +101,6 @@ static void adjust_thread_buffers() { void goto_set_num_threads(int num_threads) { - blas_num_threads_set = 1; if (num_threads < 0) blas_num_threads_set = 0; if (num_threads < 1) num_threads = blas_num_threads; @@ -125,6 +125,8 @@ void openblas_set_num_threads(int num_threads) { } int blas_thread_init(void){ +if(blas_omp_number_max <= 0) + blas_omp_number_max = omp_get_max_threads(); blas_get_cpu_number(); diff --git a/driver/others/memory.c b/driver/others/memory.c index 3cbd17bc2..4fceae754 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -422,8 +422,6 @@ This value is equal or large than blas_cpu_number. This means some threads are s */ int blas_num_threads = 0; -int blas_num_threads_set = 0; - int goto_get_num_procs (void) { return blas_cpu_number; } @@ -1996,8 +1994,6 @@ This value is equal or large than blas_cpu_number. This means some threads are s */ int blas_num_threads = 0; -int blas_num_threads_set = 0; - int goto_get_num_procs (void) { return blas_cpu_number; } diff --git a/driver/others/memory_qalloc.c b/driver/others/memory_qalloc.c index 0b38d1887..6174d9b75 100644 --- a/driver/others/memory_qalloc.c +++ b/driver/others/memory_qalloc.c @@ -283,7 +283,6 @@ The numbers of threads in the thread pool. This value is equal or large than blas_cpu_number. This means some threads are sleep. */ int blas_num_threads = 0; -int blas_num_threads_set = 0; int goto_get_num_procs (void) { return blas_cpu_number;