From d2cd76c9459dba51f557ed026d3f8d665a22f5f2 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Tue, 2 Dec 2014 11:57:15 -0800
Subject: [PATCH] ALPS - Fix issue with CLE >5.2.0 and <5.2.46 where the depth
 of MEMARRAY in BASIL was changed.

---
 NEWS                                          |  2 ++
 src/plugins/select/alps/basil_alps.h          |  1 +
 src/plugins/select/alps/libalps/do_query.c    | 21 +++++++++++++++----
 .../select/alps/libalps/parser_basil_5.2.c    |  8 +++----
 .../select/alps/libalps/parser_common.c       |  3 ++-
 .../select/alps/libalps/parser_internal.h     |  2 +-
 src/plugins/select/alps/parser_common.h       |  6 ++++--
 7 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index a0035e21eb1..eb0b6245dff 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ documents those changes that are of interest to users and admins.
  -- Double max string that Slurm can pack from 16MB to 32MB to support
     larger MPI2 configurations.
  -- Fix Centos5 compile issues.
+ -- ALPS - Fix issue with CLE >5.2.0 and <5.2.46 where the depth of MEMARRAY
+    in BASIL was changed.
 
 * Changes in Slurm 14.03.10
 ===========================
diff --git a/src/plugins/select/alps/basil_alps.h b/src/plugins/select/alps/basil_alps.h
index ad6f29bb988..3411deb4e6c 100644
--- a/src/plugins/select/alps/basil_alps.h
+++ b/src/plugins/select/alps/basil_alps.h
@@ -60,6 +60,7 @@ enum basil_version {
 	BV_5_0,		/* Basil 1.2 CLE 5.x unconfirmed simulator version  */
 	BV_5_1,		/* Basil 1.3 CLE 5.x unconfirmed simulator version  */
 	BV_5_2,		/* Basil 1.3 CLE 5.2 */
+	BV_5_2_46,	/* Basil 1.3 CLE 5.2.46+ */
 	BV_MAX
 };
 
diff --git a/src/plugins/select/alps/libalps/do_query.c b/src/plugins/select/alps/libalps/do_query.c
index 2e72248c91f..bdd21e013a9 100644
--- a/src/plugins/select/alps/libalps/do_query.c
+++ b/src/plugins/select/alps/libalps/do_query.c
@@ -5,6 +5,7 @@
  * Licensed under the GPLv2.
  */
 #include "../basil_alps.h"
+#include "parser_internal.h"
 
 /**
  * _get_alps_engine  -  run QUERY of type ENGINE
@@ -80,10 +81,15 @@ extern enum basil_version get_basil_version(void)
 
 	if (_get_alps_engine(engine_version, sizeof(engine_version)) == NULL)
 		fatal("can not determine ALPS Engine version");
-	else if ((strncmp(engine_version, "latest", 6) == 0) ||
-		 (strncmp(engine_version, "5.2", 3) == 0))
-		bv = BV_5_2;
-	else if (strncmp(engine_version, "5.1", 3) == 0)
+	else if (strncmp(engine_version, "latest", 6) == 0) {
+		bv = BV_5_2_46;
+	} else if (strncmp(engine_version, "5.2", 3) == 0) {
+		int macro = atoi(engine_version+4);
+		if (macro >= 46)
+			bv = BV_5_2_46;
+		else
+			bv = BV_5_2;
+	} else if (strncmp(engine_version, "5.1", 3) == 0)
 		bv = BV_5_1;
 	else if (strncmp(engine_version, "5.0", 3) == 0)
 		bv = BV_5_0;
@@ -112,6 +118,13 @@ extern enum basil_version get_basil_version(void)
 		      "src/plugins/select/cray/libalps/do_query.c "
 		      "for this version",
 		      engine_version);
+
+	if (bv == BV_5_2_46) {
+		basil_5_2_elements[BT_MEMARRAY].depth = 9;
+		basil_5_2_elements[BT_MEMORY].depth = 10;
+		basil_5_2_elements[BT_MEMALLOC].depth = 8;
+	}
+
 	return bv;
 }
 
diff --git a/src/plugins/select/alps/libalps/parser_basil_5.2.c b/src/plugins/select/alps/libalps/parser_basil_5.2.c
index 2a69c3ec375..c08f71f2cbd 100644
--- a/src/plugins/select/alps/libalps/parser_basil_5.2.c
+++ b/src/plugins/select/alps/libalps/parser_basil_5.2.c
@@ -6,7 +6,7 @@
  */
 #include "parser_internal.h"
 
-const struct element_handler basil_5_2_elements[] = {
+struct element_handler basil_5_2_elements[] = {
 	[BT_MESSAGE]	= {
 			.tag	= "Message",
 			.depth	= 0xff,	/* unused, can appear at any depth */
@@ -135,19 +135,19 @@ const struct element_handler basil_5_2_elements[] = {
 	},
 	[BT_MEMARRAY]	= {
 			.tag	= "MemoryArray",
-			.depth	= 9,
+			.depth	= 5,
 			.uniq	= true,
 			.hnd	= NULL
 	},
 	[BT_MEMORY]	= {
 			.tag	= "Memory",
-			.depth	= 10,
+			.depth	= 6,
 			.uniq	= false,
 			.hnd	= eh_mem
 	},
 	[BT_MEMALLOC]	= {
 			.tag	= "MemoryAllocation",
-			.depth	= 8,
+			.depth	= 7,
 			.uniq	= false,
 			.hnd	= eh_mem_alloc
 	},
diff --git a/src/plugins/select/alps/libalps/parser_common.c b/src/plugins/select/alps/libalps/parser_common.c
index 332fe1c565b..8551fc46c3f 100644
--- a/src/plugins/select/alps/libalps/parser_common.c
+++ b/src/plugins/select/alps/libalps/parser_common.c
@@ -515,7 +515,8 @@ static const struct element_handler *basil_tables[BV_MAX] = {
 	[BV_4_1] = basil_4_0_elements,
 	[BV_5_0] = basil_4_0_elements,
 	[BV_5_1] = basil_5_1_elements,
-	[BV_5_2] = basil_5_2_elements
+	[BV_5_2] = basil_5_2_elements,
+	[BV_5_2_46] = basil_5_2_elements
 };
 
 /**
diff --git a/src/plugins/select/alps/libalps/parser_internal.h b/src/plugins/select/alps/libalps/parser_internal.h
index 84bf28ea76e..9df224e996c 100644
--- a/src/plugins/select/alps/libalps/parser_internal.h
+++ b/src/plugins/select/alps/libalps/parser_internal.h
@@ -59,7 +59,7 @@ extern const struct element_handler basil_1_1_elements[];
 extern const struct element_handler basil_3_1_elements[];
 extern const struct element_handler basil_4_0_elements[];
 extern const struct element_handler basil_5_1_elements[];
-extern const struct element_handler basil_5_2_elements[];
+extern struct element_handler basil_5_2_elements[];
 /* atoul.c */
 extern int atou64(const char *str, uint64_t *value);
 extern int atou32(const char *str, uint32_t *value);
diff --git a/src/plugins/select/alps/parser_common.h b/src/plugins/select/alps/parser_common.h
index 00dd1b63bd6..f6976efb680 100644
--- a/src/plugins/select/alps/parser_common.h
+++ b/src/plugins/select/alps/parser_common.h
@@ -23,7 +23,8 @@ const char *bv_names[BV_MAX] = {	/* Basil Protocol version */
 	[BV_4_1] = "1.2",
 	[BV_5_0] = "1.2",
 	[BV_5_1] = "1.3",
-	[BV_5_2] = "1.3"
+	[BV_5_2] = "1.3",
+	[BV_5_2_46] = "1.3"
 };
 
 const char *bv_names_long[BV_MAX] = {	/* Actual version name */
@@ -35,7 +36,8 @@ const char *bv_names_long[BV_MAX] = {	/* Actual version name */
 	[BV_4_1] = "4.1",
 	[BV_5_0] = "5.0",
 	[BV_5_1] = "5.1",
-	[BV_5_2] = "5.2"
+	[BV_5_2] = "5.2",
+	[BV_5_2_46] = "5.2"
 };
 
 /* Basil methods */
-- 
GitLab