Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add patch for OpenBLAS 0.3.23 to fix hanging tests #18790

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ patches = [
'OpenBLAS-0.3.21_fix-order-vectorization.patch',
'OpenBLAS-0.3.23_fix-parallel-build.patch',
'OpenBLAS-0.3.23_fix-lapack-test.patch',
'OpenBLAS-0.3.23_fix-tests-hang.patch',
]
checksums = [
{'v0.3.23.tar.gz': '5d9491d07168a5d00116cdc068a40022c3455bf9293c7cb86a65b1054d7e5114'},
Expand All @@ -30,6 +31,7 @@ checksums = [
'08af834e5d60441fd35c128758ed9c092ba6887c829e0471ecd489079539047d'},
{'OpenBLAS-0.3.23_fix-parallel-build.patch': 'abe10ba3b0ca54772dbf235596e35325a5159018f6a60cfc88824c2c220d99d9'},
{'OpenBLAS-0.3.23_fix-lapack-test.patch': 'f6b3d81061f136e34aaf5359bb80fb9d2bba28825cc1dd26179b8dd01a9a0054'},
{'OpenBLAS-0.3.23_fix-tests-hang.patch': '9de1fdee6edf3b2bb55e4639fdd92d2877b5f0ac880f7df2cfea47ecebf16609'},
]

builddependencies = [
Expand Down
165 changes: 165 additions & 0 deletions easybuild/easyconfigs/o/OpenBLAS/OpenBLAS-0.3.23_fix-tests-hang.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
From ea669c8ae938450e101140d634cca291bffd3898 Mon Sep 17 00:00:00 2001
From: Martin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Date: Wed, 26 Jul 2023 00:27:14 +0200
Subject: [PATCH 1/4] simplify openmp thread limit handling

---
common_thread.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/common_thread.h b/common_thread.h
index 05e1d5489d..0a4c703b7c 100644
--- a/common_thread.h
+++ b/common_thread.h
@@ -136,15 +136,13 @@ typedef struct blas_queue {
#ifdef SMP_SERVER

extern int blas_server_avail;
+extern int blas_omp_number_max;

static __inline int num_cpu_avail(int level) {

#ifdef USE_OPENMP
int openmp_nthreads;
- if (blas_num_threads_set == 0)
openmp_nthreads=omp_get_max_threads();
- else
- openmp_nthreads=blas_cpu_number;
#endif

#ifndef USE_OPENMP
@@ -156,7 +154,13 @@ int openmp_nthreads;
) return 1;

#ifdef USE_OPENMP
- if (blas_cpu_number != openmp_nthreads) {
+ if (openmp_nthreads > blas_omp_number_max){
+#ifdef DEBUG
+ fprintf(stderr,"WARNING - more OpenMP threads requested (%d) than available (%d)\n",openmp_nthreads,blas_omp_number_max);
+#endif
+ openmp_nthreads = blas_omp_number_max;
+ }
+ if (blas_cpu_number != openmp_nthreads) {
goto_set_num_threads(openmp_nthreads);
}
#endif

From 3326b924b324d49960e0f657f049e5658e7e6c69 Mon Sep 17 00:00:00 2001
From: Martin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Date: Wed, 26 Jul 2023 00:31:24 +0200
Subject: [PATCH 2/4] 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 2e0c0f38c1..43764df00c 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 3cbd17bc2f..4fceae7545 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 0b38d1887c..6174d9b75e 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;

From 94adf98bb80b36c9faa2fa90fe7f33b36d30748c Mon Sep 17 00:00:00 2001
From: Martin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Date: Wed, 26 Jul 2023 08:31:37 +0200
Subject: [PATCH 3/4] remove unused status variable

---
common_thread.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/common_thread.h b/common_thread.h
index 0a4c703b7c..06a7a1a38c 100644
--- a/common_thread.h
+++ b/common_thread.h
@@ -53,7 +53,6 @@ extern void goto_set_num_threads(int nthreads);
/* Global Parameter */
extern int blas_cpu_number;
extern int blas_num_threads;
-extern int blas_num_threads_set;
extern int blas_omp_linked;

#define BLAS_LEGACY 0x8000U

From 9ff84dc3f2536ce94e0a300a098485c7ff3d771d Mon Sep 17 00:00:00 2001
From: Martin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Date: Wed, 26 Jul 2023 10:02:44 +0200
Subject: [PATCH 4/4] remove unused status variable

---
driver/others/blas_server_omp.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/driver/others/blas_server_omp.c b/driver/others/blas_server_omp.c
index 43764df00c..fe6b4a7c06 100644
--- a/driver/others/blas_server_omp.c
+++ b/driver/others/blas_server_omp.c
@@ -101,7 +101,6 @@ static void adjust_thread_buffers() {

void goto_set_num_threads(int num_threads) {

- if (num_threads < 0) blas_num_threads_set = 0;
if (num_threads < 1) num_threads = blas_num_threads;

if (num_threads > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER;
Loading