From b659e63c44b52bf0117db049f2e3d8e5a7752b67 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 4 Jun 2007 20:03:56 +0000
Subject: [PATCH] BLUEGENE added fix for overlap mode to only look for nodes we
 are asking for.

---
 NEWS                                          |  7 +-
 .../block_allocator/block_allocator.c         | 74 +++++++++++++++++++
 .../block_allocator/block_allocator.h         |  1 +
 src/plugins/select/bluegene/plugin/bluegene.c |  4 +-
 4 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index bbdb7bf6e51..7b68dcc3a44 100644
--- a/NEWS
+++ b/NEWS
@@ -10,8 +10,11 @@ documents those changes that are of interest to users and admins.
     multiple dlopens after forking (and to avoid a glibc bug
     that leaves dlopen locks in a bad state after a fork).
  -- Added MPICH1_P4 patch to launch tasks using srun rather than rsh and
-    automatically generate mpirun's machinefile based upon the job's allocation.
-    See "etc/mpich1.slurm.patch".
+    automatically generate mpirun's machinefile based upon the job's 
+    allocation.    See "etc/mpich1.slurm.patch".
+ -- BLUEGENE - fix for overlap mode to mark all other base partitions as used
+    when creating a new block from the file to insure we only use the base 
+    partitions we are asking for.
 
 * Changes in SLURM 1.2.8
 ========================
diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.c b/src/plugins/select/bluegene/block_allocator/block_allocator.c
index 393e061a14c..0993e842d4d 100644
--- a/src/plugins/select/bluegene/block_allocator/block_allocator.c
+++ b/src/plugins/select/bluegene/block_allocator/block_allocator.c
@@ -1476,6 +1476,80 @@ extern int reset_ba_system(bool track_down_nodes)
 				
 	return 1;
 }
+
+extern int set_all_bps_except(char *bps)
+{
+	int x;
+#ifdef HAVE_BG
+	int y, z;
+#endif
+	hostlist_t hl = hostlist_create(bps);
+	char *host = NULL, *numeric = NULL;
+	int start, temp;
+
+	while((host = hostlist_shift(hl))){
+		numeric = host;
+		start = 0;
+		while (numeric) {
+			if (numeric[0] < '0' || numeric[0] > 'Z'
+			    || (numeric[0] > '9' 
+				&& numeric[0] < 'A')) {
+				numeric++;
+				continue;
+			}
+			start = xstrntol(numeric, NULL, 
+					 BA_SYSTEM_DIMENSIONS,
+					 HOSTLIST_BASE);
+			break;
+		}
+		
+		temp = start / (HOSTLIST_BASE * HOSTLIST_BASE);
+		x = temp;
+#ifdef HAVE_BG
+		temp = (start % (HOSTLIST_BASE * HOSTLIST_BASE))
+			/ HOSTLIST_BASE;
+		y = temp;
+		temp = start % HOSTLIST_BASE;
+		z = temp;
+		ba_system_ptr->grid[x][y][z].state = NODE_STATE_END;
+#else
+		ba_system_ptr->grid[x].state = NODE_STATE_END;
+#endif
+		free(host);
+	}
+	hostlist_destroy(hl);
+
+	for (x = 0; x < DIM_SIZE[X]; x++) {
+#ifdef HAVE_BG
+		for (y = 0; y < DIM_SIZE[Y]; y++)
+			for (z = 0; z < DIM_SIZE[Z]; z++) {
+				if(ba_system_ptr->grid[x][y][z].state
+				   == NODE_STATE_END) {
+					ba_system_ptr->grid[x][y][z].state = 
+						NODE_STATE_IDLE;
+					ba_system_ptr->grid[x][y][z].used = 
+						false;
+				} else {
+					ba_system_ptr->grid[x][y][z].state = 
+						NODE_STATE_IDLE;
+					ba_system_ptr->grid[x][y][z].used = 
+						true;
+				}
+			}
+#else
+		if(ba_system_ptr->grid[x].state != NODE_STATE_END) {
+			ba_system_ptr->grid[x].state = NODE_STATE_IDLE;
+			ba_system_ptr->grid[x].used = false;
+		} else {
+			ba_system_ptr->grid[x].state = NODE_STATE_IDLE;
+			ba_system_ptr->grid[x].used = true;
+		}
+#endif
+	}
+				
+	return 1;
+}
+
 /* init_grid - set values of every grid point */
 extern void init_grid(node_info_msg_t * node_info_ptr)
 {
diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.h b/src/plugins/select/bluegene/block_allocator/block_allocator.h
index f882e197b88..936117f5c26 100644
--- a/src/plugins/select/bluegene/block_allocator/block_allocator.h
+++ b/src/plugins/select/bluegene/block_allocator/block_allocator.h
@@ -351,6 +351,7 @@ extern char *set_bg_block(List results, int *start,
 			  int *geometry, int conn_type);
 
 extern int reset_ba_system(bool track_down_nodes);
+extern int set_all_bps_except(char *bps);
 
 extern void init_grid(node_info_msg_t *node_info_ptr);
 /*
diff --git a/src/plugins/select/bluegene/plugin/bluegene.c b/src/plugins/select/bluegene/plugin/bluegene.c
index 487bdc36ee5..1fb9ba87705 100644
--- a/src/plugins/select/bluegene/plugin/bluegene.c
+++ b/src/plugins/select/bluegene/plugin/bluegene.c
@@ -1008,8 +1008,10 @@ extern int create_defined_blocks(bg_layout_t overlapped)
 			   && !bg_record->full_block
 			   && bg_record->cpus_per_bp == procs_per_node) {
 				char *name = NULL;
-				if(overlapped == LAYOUT_OVERLAP)
+				if(overlapped == LAYOUT_OVERLAP) {
 					reset_ba_system(false);
+					set_all_bps_except(bg_record->nodes);
+				}
 				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
 					geo[i] = bg_record->geo[i];
 				debug2("adding %s %c%c%c %c%c%c",
-- 
GitLab