From 56285a834d68a4a014e28dde0446e9f0bedfbe99 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 21 Jan 2011 23:58:08 +0000
Subject: [PATCH] get resource selection working in topology optimized fashion
 with select/cray

---
 src/plugins/select/cray/other_select.c    | 20 ++++++++++++++++++++
 src/plugins/select/cray/other_select.h    | 11 +++++++++++
 src/plugins/select/cray/select_cray.c     | 14 ++++++++++++++
 src/plugins/select/linear/select_linear.c |  1 +
 4 files changed, 46 insertions(+)

diff --git a/src/plugins/select/cray/other_select.c b/src/plugins/select/cray/other_select.c
index 29d1c10071a..22a4ebab8bd 100644
--- a/src/plugins/select/cray/other_select.c
+++ b/src/plugins/select/cray/other_select.c
@@ -112,6 +112,7 @@ static slurm_select_ops_t *_other_select_get_ops(slurm_select_context_t *c)
 		"select_p_update_node_state",
 		"select_p_alter_node_cnt",
 		"select_p_reconfigure",
+		"select_p_resv_test",
 	};
 	int n_syms = sizeof(syms) / sizeof(char *);
 
@@ -730,3 +731,22 @@ extern int other_reconfigure (void)
 
 	return (*(other_select_context->ops.reconfigure))();
 }
+
+/*
+ * other_resv_test - Identify the nodes which "best" satisfy a reservation
+ *	request. "best" is defined as either single set of consecutive nodes
+ *	satisfying the request and leaving the minimum number of unused nodes
+ *	OR the fewest number of consecutive node sets
+ * IN avail_bitmap - nodes available for the reservation
+ * IN node_cnt - count of required nodes
+ * RET - nodes selected for use by the reservation
+ */
+extern bitstr_t * other_resv_test(bitstr_t *avail_bitmap, uint32_t node_cnt)
+{
+	if (other_select_init() < 0)
+		return SLURM_ERROR;
+
+	return (*(other_select_context->ops.select_resv_test)) (avail_bitmap,
+							        node_cnt);
+}
+
diff --git a/src/plugins/select/cray/other_select.h b/src/plugins/select/cray/other_select.h
index d6509eca5ae..df631143f1f 100644
--- a/src/plugins/select/cray/other_select.h
+++ b/src/plugins/select/cray/other_select.h
@@ -326,4 +326,15 @@ extern int other_pack_select_info(time_t last_query_time, uint16_t show_flags,
 /* Note reconfiguration or change in partition configuration */
 extern int other_reconfigure(void);
 
+/*
+ * other_resv_test - Identify the nodes which "best" satisfy a reservation
+ *	request. "best" is defined as either single set of consecutive nodes
+ *	satisfying the request and leaving the minimum number of unused nodes
+ *	OR the fewest number of consecutive node sets
+ * IN avail_bitmap - nodes available for the reservation
+ * IN node_cnt - count of required nodes
+ * RET - nodes selected for use by the reservation
+ */
+extern bitstr_t * other_resv_test(bitstr_t *avail_bitmap, uint32_t node_cnt);
+
 #endif /* _CRAY_OTHER_SELECT_H */
diff --git a/src/plugins/select/cray/select_cray.c b/src/plugins/select/cray/select_cray.c
index a8242e0967d..ef788696f12 100644
--- a/src/plugins/select/cray/select_cray.c
+++ b/src/plugins/select/cray/select_cray.c
@@ -656,3 +656,17 @@ extern int select_p_reconfigure(void)
 {
 	return other_reconfigure();
 }
+
+/*
+ * select_p_resv_test - Identify the nodes which "best" satisfy a reservation
+ *	request. "best" is defined as either single set of consecutive nodes
+ *	satisfying the request and leaving the minimum number of unused nodes
+ *	OR the fewest number of consecutive node sets
+ * IN avail_bitmap - nodes available for the reservation
+ * IN node_cnt - count of required nodes
+ * RET - nodes selected for use by the reservation
+ */
+extern bitstr_t * select_p_resv_test(bitstr_t *avail_bitmap, uint32_t node_cnt)
+{
+	return other_resv_test(avail_bitmap, node_cnt);
+}
diff --git a/src/plugins/select/linear/select_linear.c b/src/plugins/select/linear/select_linear.c
index adb37086847..ec646e66e69 100644
--- a/src/plugins/select/linear/select_linear.c
+++ b/src/plugins/select/linear/select_linear.c
@@ -2888,6 +2888,7 @@ extern bitstr_t * select_p_resv_test(bitstr_t *avail_bitmap, uint32_t node_cnt)
 	}
 	return bit_pick_cnt(avail_bitmap, node_cnt);
 }
+
 /*
  * _resv_test_topo - A topology aware node selection function
  * NOTE: The logic here is almost identical to that of _job_test_topo()
-- 
GitLab