From 04fa6094ac03a40436cf3f45931c5a8340786d61 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 28 Mar 2011 20:56:56 +0000
Subject: [PATCH] fixed corner case situations when building blocks

---
 .../select/bluegene/ba_bgq/block_allocator.c  | 31 ++++++++++++-------
 src/plugins/select/bluegene/bg_job_place.c    |  5 +++
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/plugins/select/bluegene/ba_bgq/block_allocator.c b/src/plugins/select/bluegene/ba_bgq/block_allocator.c
index 0bd26c42d7d..22fcbf84d78 100644
--- a/src/plugins/select/bluegene/ba_bgq/block_allocator.c
+++ b/src/plugins/select/bluegene/ba_bgq/block_allocator.c
@@ -73,7 +73,7 @@ static int _fill_in_coords(List results, int level, ba_mp_t *start_mp,
 			   ba_mp_t **check_mp, int *block_start,
 			   int *block_end, int *coords);
 
-static int _finish_torus(List results, int level, uint16_t *block_start,
+static int _finish_torus(List results, int level, int *block_start,
 			 int *block_end, uint16_t *conn_type, int *coords);
 
 /* */
@@ -649,8 +649,6 @@ extern char *set_bg_block(List results, uint16_t *start,
 		}
 	}
 
-	//ba_mp = coord2ba_mp(block_start);
-
 	if (ba_debug_flags & DEBUG_FLAG_BG_ALGO)
 		info("complete box is %c%c%c%c x %c%c%c%c",
 		     alpha_num[block_start[A]],
@@ -666,7 +664,7 @@ extern char *set_bg_block(List results, uint16_t *start,
 			    block_start, block_end, coords) == -1)
 		goto end_it;
 
-	if (_finish_torus(main_mps, A, start,
+	if (_finish_torus(main_mps, A, block_start,
 			  block_end, conn_type, coords) == -1)
 		goto end_it;
 
@@ -914,16 +912,22 @@ static int _fill_in_coords(List results, int level, ba_mp_t *start_mp,
 
 	/* info("looking at %s", curr_mp->coord_str); */
 	for (dim=0; dim<cluster_dims; dim++) {
-		/* If we get over 2 in any dim that we are
-		   greater here we are pass anything we need to
-		   passthrough, so break.
+		/* If this is only used for passthrough, skip since
+		   the _finish_torus code will catch things there.
 		*/
-		if (check_mp[dim]->used & BA_MP_USED_PASS_BIT)
+		if (check_mp[dim]->used & BA_MP_USED_PASS_BIT) {
 			used = check_mp[dim]->used;
+			break;
+		}
 
 		/* info("inside at %s %d %d %d", check_mp[dim]->coord_str, */
 		/*      dim, check_mp[dim]->used, used); */
 
+		/* If we get over 2 in any dim that we are
+		   greater here we are pass anything we need to
+		   passthrough, so break.
+		*/
+
 		/* info("passthrough %d used %d %d %d %d", dim, used, */
 		/*      curr_mp->coord[dim], block_start[dim], */
 		/*      block_end[dim]); */
@@ -936,10 +940,13 @@ static int _fill_in_coords(List results, int level, ba_mp_t *start_mp,
 		}
 	}
 
-	/* info("got used of %d", used); */
-	if (count_outside > 1) {
+	/* info("got used of %d %d", used, count_outside); */
+	if (dim < cluster_dims) {
 		if (ba_debug_flags & DEBUG_FLAG_BG_ALGO_DEEP)
-			info("skipping non-used %s", curr_mp->coord_str);
+			info("skipping non-used %s if needed for "
+			     "passthrough it should be handled in "
+			     "_finish_torus",
+			     curr_mp->coord_str);
 		return 1;
 	}
 
@@ -995,7 +1002,7 @@ static int _fill_in_coords(List results, int level, ba_mp_t *start_mp,
  *
  * RET: -1 on failure 1 on success
  */
-static int _finish_torus(List results, int level, uint16_t *block_start,
+static int _finish_torus(List results, int level, int *block_start,
 			 int *block_end, uint16_t *conn_type, int *coords)
 {
 	int dim;
diff --git a/src/plugins/select/bluegene/bg_job_place.c b/src/plugins/select/bluegene/bg_job_place.c
index ad80e635a44..2888db78a52 100644
--- a/src/plugins/select/bluegene/bg_job_place.c
+++ b/src/plugins/select/bluegene/bg_job_place.c
@@ -958,6 +958,11 @@ static int _find_best_block_match(List block_list,
 	request.size = target_size;
 	request.procs = req_procs;
 	request.elongate = request.rotate;
+	/* request.start[0] = 1; */
+	/* request.start[1] = 2; */
+	/* request.start[2] = 0; */
+	/* request.start[3] = 2; */
+	/* request.start_req = 1; */
 
 	if (job_ptr->details->req_node_bitmap)
 		request.avail_mp_bitmap = job_ptr->details->req_node_bitmap;
-- 
GitLab