From b541992309265188036620f356f2ebfbe3d5b64e Mon Sep 17 00:00:00 2001
From: Sebastian Achilles <s.achilles@fz-juelich.de>
Date: Wed, 8 Mar 2023 09:47:54 +0100
Subject: [PATCH] psmpi: add singleton patch

---
 .../p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb       |  5 ++-
 .../p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb       |  5 ++-
 .../psmpi-5.7.0-1-intel-compilers-2022.1.0.eb |  5 ++-
 .../p/psmpi/psmpi-5.7.0-1_singleton-fix.patch | 40 +++++++++++++++++++
 .../p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb       |  5 ++-
 .../p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb       |  5 ++-
 .../psmpi-5.7.0-1-intel-compilers-2022.1.0.eb |  5 ++-
 7 files changed, 64 insertions(+), 6 deletions(-)
 create mode 100644 Golden_Repo/p/psmpi/psmpi-5.7.0-1_singleton-fix.patch

diff --git a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
index 0673d2176..ce96cbc89 100644
--- a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
+++ b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
@@ -17,6 +17,8 @@ checksums = [
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
     # psmpi-5.5.0-1_ime.patch
     'c2418b9511560dca197242508de9c7b6b117122912b6d3a4aa18398834f465ff',
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -29,7 +31,8 @@ dependencies = [
 
 patches = [
     'psmpi_shebang.patch',
-    'psmpi-5.5.0-1_ime.patch'
+    'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 mpich_opts = '--enable-static --with-file-system=ime+ufs+gpfs --enable-romio'
diff --git a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
index 531aa376d..0b358cbbe 100644
--- a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
+++ b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
@@ -17,6 +17,8 @@ checksums = [
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
     # psmpi-5.5.0-1_ime.patch
     'c2418b9511560dca197242508de9c7b6b117122912b6d3a4aa18398834f465ff',
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -29,7 +31,8 @@ dependencies = [
 
 patches = [
     'psmpi_shebang.patch',
-    'psmpi-5.5.0-1_ime.patch'
+    'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 mpich_opts = '--enable-static --with-file-system=ime+ufs+gpfs --enable-romio'
diff --git a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
index ba1eecdd4..fec18db29 100644
--- a/Golden_Repo/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
+++ b/Golden_Repo/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
@@ -17,6 +17,8 @@ checksums = [
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
     # psmpi-5.5.0-1_ime.patch
     'c2418b9511560dca197242508de9c7b6b117122912b6d3a4aa18398834f465ff',
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -29,7 +31,8 @@ dependencies = [
 
 patches = [
     'psmpi_shebang.patch',
-    'psmpi-5.5.0-1_ime.patch'
+    'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 mpich_opts = '--enable-static --with-file-system=ime+ufs+gpfs --enable-romio'
diff --git a/Golden_Repo/p/psmpi/psmpi-5.7.0-1_singleton-fix.patch b/Golden_Repo/p/psmpi/psmpi-5.7.0-1_singleton-fix.patch
new file mode 100644
index 000000000..4643f36c3
--- /dev/null
+++ b/Golden_Repo/p/psmpi/psmpi-5.7.0-1_singleton-fix.patch
@@ -0,0 +1,40 @@
+From 56ce43874fe1f97b2cc7cbd1a1a0b487432404f4 Mon Sep 17 00:00:00 2001
+From: Carsten Clauss <clauss@par-tec.com>
+Date: Thu, 22 Sep 2022 13:08:18 +0200
+Subject: [PATCH] init: Fix version check for the singleton case.
+
+In the singleton case, there is no need to check the version -- and
+moreover, there is no KVS available (and hence put/get functions for
+it must not be called) since no process manager connected.
+---
+ mpich2/src/mpid/psp/src/mpid_init.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/mpich2/src/mpid/psp/src/mpid_init.c b/mpich2/src/mpid/psp/src/mpid_init.c
+index 5654d5cb9..f31d301b4 100644
+--- a/mpich2/src/mpid/psp/src/mpid_init.c
++++ b/mpich2/src/mpid/psp/src/mpid_init.c
+@@ -245,6 +245,11 @@ static
+ int i_version_set(int pg_rank, const char *ver)
+ {
+ 	int mpi_errno = MPI_SUCCESS;
++
++	/* There is no need to check for version in the singleton case and we moreover must
++	   not use MPIR_pmi_kvs_put() in this case either since there is no process manager. */
++	if (MPIDI_Process.singleton_but_no_pm) goto fn_exit;
++
+ 	if (pg_rank == 0) {
+ 		mpi_errno = MPIR_pmi_kvs_put("i_version", ver);
+ 		MPIR_ERR_CHECK(mpi_errno);
+@@ -262,6 +267,11 @@ static
+ int i_version_check(int pg_rank, const char *ver)
+ {
+         int mpi_errno = MPI_SUCCESS;
++
++	/* There is no need to check for version in the singleton case and we moreover must
++	   not use MPIR_pmi_kvs_get() in this case either since there is no process manager. */
++	if (MPIDI_Process.singleton_but_no_pm) goto fn_exit;
++
+ 	if (pg_rank != 0) {
+ 		char val[100] = "unknown";
+ 		mpi_errno = MPIR_pmi_kvs_get(0, "i_version", val, sizeof(val));
diff --git a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
index 8f16abaa8..6e27104e8 100644
--- a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
+++ b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-GCC-11.3.0.eb
@@ -15,6 +15,8 @@ checksums = [
     # psmpi-5.7.0-1.tar.gz
     '0c1c8556afedfb08cd612f379ddb6327ef1bb0867d6f6fed3d610f3d8c790883',
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -28,7 +30,8 @@ dependencies = [
 patches = [
     'psmpi_shebang.patch',
     # We don't have IME in HDFML so we skip this
-    # 'psmpi-5.5.0-1_ime.patch'
+    # 'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 # We don't have IME in HDFML so we skip this
diff --git a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
index b06425298..ecab844fd 100644
--- a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
+++ b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-NVHPC-23.1.eb
@@ -15,6 +15,8 @@ checksums = [
     # psmpi-5.7.0-1.tar.gz
     '0c1c8556afedfb08cd612f379ddb6327ef1bb0867d6f6fed3d610f3d8c790883',
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -28,7 +30,8 @@ dependencies = [
 patches = [
     'psmpi_shebang.patch',
     # We don't have IME in HDFML so we skip this
-    # 'psmpi-5.5.0-1_ime.patch'
+    # 'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 # We don't have IME in HDFML so we skip this
diff --git a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
index cf308960e..8e3fce51d 100644
--- a/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
+++ b/Overlays/hdfml_overlay/p/psmpi/psmpi-5.7.0-1-intel-compilers-2022.1.0.eb
@@ -15,6 +15,8 @@ checksums = [
     # psmpi-5.7.0-1.tar.gz
     '0c1c8556afedfb08cd612f379ddb6327ef1bb0867d6f6fed3d610f3d8c790883',
     '978eb3223c978477c40987f745c07fda26ccbad2f468616faf92f0d71b81a156',  # psmpi_shebang.patch
+    # psmpi-5.7.0-1_singleton-fix.patch
+    '5ab46de53f6025367f444e77cd3374fe36a0728cde38c72db55603ebc08b50a2',
 ]
 
 dependencies = [
@@ -28,7 +30,8 @@ dependencies = [
 patches = [
     'psmpi_shebang.patch',
     # We don't have IME in HDFML so we skip this
-    # 'psmpi-5.5.0-1_ime.patch'
+    # 'psmpi-5.5.0-1_ime.patch',
+    'psmpi-5.7.0-1_singleton-fix.patch'
 ]
 
 # We don't have IME in HDFML so we skip this
-- 
GitLab