From b20538f94d8d23ad710ed4149a08c69a2e17560c Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 2 Nov 2004 22:24:47 +0000 Subject: [PATCH] General clean-up of the select/bluegene plugin just to get it to build. There is still code that will not build properly, but it is #ifdef'ed out. --- .../select/bluegene/bgl_switch_connections.h | 31 ++- src/plugins/select/bluegene/bluegene.c | 136 ++++++---- src/plugins/select/bluegene/bluegene.h | 28 +- src/plugins/select/bluegene/partition_sys.c | 254 ++++++------------ src/plugins/select/bluegene/partition_sys.h | 17 +- 5 files changed, 208 insertions(+), 258 deletions(-) diff --git a/src/plugins/select/bluegene/bgl_switch_connections.h b/src/plugins/select/bluegene/bgl_switch_connections.h index 3952a53fa50..8bdfcb508a6 100644 --- a/src/plugins/select/bluegene/bgl_switch_connections.h +++ b/src/plugins/select/bluegene/bgl_switch_connections.h @@ -25,7 +25,7 @@ \*****************************************************************************/ #ifndef _BGL_SWITCH_CONNECTIONS_H_ -#define +#define _BGL_SWITCH_CONNECTIONS_H_ /** * connect the given switch up in the "A" pattern @@ -37,9 +37,8 @@ * \__|__|__/ * 3 4 */ -void connect_switch_A(rm_BGL_t *bgl, rm_partition_t *my_part, - rm_switch_t *my_switch, - int first); +extern void connect_switch_A(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the given switch up in the "B" pattern @@ -51,8 +50,8 @@ void connect_switch_A(rm_BGL_t *bgl, rm_partition_t *my_part, * \__|__|__/ * 3 4 */ -void connect_switch_B(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_switch, - int first); +extern void connect_switch_B(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the given switch up in the "C" pattern @@ -64,8 +63,8 @@ void connect_switch_B(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_sw * \__|__|__/ * 3 4 */ -void connect_switch_C(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_switch, - int first); +extenn void connect_switch_C(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the given switch up in the "D" pattern @@ -77,8 +76,8 @@ void connect_switch_C(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_sw * \__|__|__/ * 3 4 */ -void connect_switch_D(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_switch, - int first); +extern void connect_switch_D(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the given switch up in the "E" pattern (loopback) @@ -90,8 +89,8 @@ void connect_switch_D(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_sw * \__|__|__/ * 3 4 */ -void connect_switch_E(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_switch, - int first); +extern void connect_switch_E(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the given switch up in the "F" pattern (loopback) @@ -103,8 +102,8 @@ void connect_switch_E(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_sw * \__|__|__/ * 3 4 */ -void connect_switch_F(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_switch, - int first); +extern void connect_switch_F(rm_BGL_t *bgl, rm_partition_t *my_part, + rm_switch_t *my_switch, int first); /** * connect the node to the next node (higher up number) @@ -116,7 +115,7 @@ void connect_switch_F(rm_BGL_t *bgl, rm_partition_t *my_part, rm_switch_t *my_sw * \__|__|__/ * 3 4 */ -void connect_next(rm_partition_t *my_part, rm_switch_t *my_switch); +extern void connect_next(rm_partition_t *my_part, rm_switch_t *my_switch); /** * connect the given switch up to the previous node @@ -128,6 +127,6 @@ void connect_next(rm_partition_t *my_part, rm_switch_t *my_switch); * \__|__|__/ * 3 4 */ -void connect_prev(rm_partition_t *my_part, rm_switch_t *my_switch); +extern void connect_prev(rm_partition_t *my_part, rm_switch_t *my_switch); #endif /* _BGL_SWITCH_CONNECTIONS_H_ */ diff --git a/src/plugins/select/bluegene/bluegene.c b/src/plugins/select/bluegene/bluegene.c index dc3e3e4c761..f2384790279 100644 --- a/src/plugins/select/bluegene/bluegene.c +++ b/src/plugins/select/bluegene/bluegene.c @@ -23,7 +23,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. \*****************************************************************************/ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include <stdlib.h> +#include <time.h> +#include <slurm/slurm.h> #include "src/slurmctld/proc_req.h" #include "src/common/hostlist.h" @@ -77,6 +83,11 @@ static void _diff_tv_str(struct timeval *tv1,struct timeval *tv2, /* Rotate a geometry array through six permutations */ static void _rotate_geo(uint16_t *req_geometry, int rot_cnt); +#ifdef USE_BGL_FILES +static char *_convert_bp_state(rm_BP_state_t state); +static void _set_bp_node_state(rm_BP_state_t state, rm_element_t *element); +#endif + /** * create_static_partitions - create the static partitions that will be used * for scheduling. @@ -154,12 +165,12 @@ static void _process_config() bgl_part->nodes); else { /** - * bgl_part->part_type should have been extracted in + * bgl_part->conn_type should have been extracted in * copy_slurm_partition_list */ request_result->bgl_record_ptr = bgl_part; request_result->node_use = bgl_part->node_use; - request_result->part_type = bgl_part->part_type; + request_result->conn_type = bgl_part->conn_type; bgl_part->alloc_part = request_result; } } @@ -182,7 +193,7 @@ static int _copy_slurm_partition_list(List slurm_part_list) /** * try to find the corresponding bgl_conf_record for the * nodes specified in the slurm_part_list, but if not - * found, _find_part_type will default to RM_MESH + * found, _find_conn_type will default to RM_MESH */ while ((slurm_part = (struct part_record *) list_next(itr))) { /* no need to create record for slurm partition without nodes*/ @@ -216,7 +227,7 @@ static int _copy_slurm_partition_list(List slurm_part_list) bgl_record->slurm_part_id = xstrdup(slurm_part->name); bgl_record->node_use = config_ptr->node_use; - bgl_record->part_type = config_ptr->part_type; + bgl_record->conn_type = config_ptr->conn_type; bgl_record->hostlist = hostlist_create(cur_nodes); bgl_record->size = hostlist_count(bgl_record->hostlist); if (node_name2bitmap(cur_nodes, false, &(bgl_record->bitmap))){ @@ -333,20 +344,20 @@ extern int read_bgl_conf(void) static int _parse_bgl_spec(char *in_line) { int error_code = SLURM_SUCCESS; - char *nodes = NULL, *node_use = NULL, *part_type = NULL; + char *nodes = NULL, *node_use = NULL, *conn_type = NULL; bgl_conf_record_t* new_record; error_code = slurm_parser(in_line, "Nodes=", 's', &nodes, - "Type=", 's', &part_type, + "Type=", 's', &conn_type, "Use=", 's', &node_use, "END"); if (error_code) goto cleanup; - if (!nodes && !node_use && !part_type) + if (!nodes && !node_use && !conn_type) goto cleanup; /* only comment */ - if (!nodes && (node_use || part_type)) { + if (!nodes && (node_use || conn_type)) { error("bluegene.conf lacks Nodes value, but has Type or Use value"); error_code = SLURM_ERROR; goto cleanup; @@ -356,17 +367,17 @@ static int _parse_bgl_spec(char *in_line) new_record->nodes = nodes; nodes = NULL; /* pointer moved, nothing left to xfree */ - if (!part_type) - new_record->part_type = RM_MESH; - else if (strcasecmp(part_type, "TORUS") == 0) - new_record->part_type = RM_TORUS; - else if (strcasecmp(part_type, "MESH") == 0) - new_record->part_type = RM_MESH; + if (!conn_type) + new_record->conn_type = RM_MESH; + else if (strcasecmp(conn_type, "TORUS") == 0) + new_record->conn_type = RM_TORUS; + else if (strcasecmp(conn_type, "MESH") == 0) + new_record->conn_type = RM_MESH; else { error("_parse_bgl_spec: partition type %s invalid for nodes " "%s, defaulting to type: MESH", - part_type, new_record->nodes); - new_record->part_type = RM_MESH; + conn_type, new_record->nodes); + new_record->conn_type = RM_MESH; } if (!node_use) @@ -385,12 +396,13 @@ static int _parse_bgl_spec(char *in_line) #if _DEBUG debug("_parse_bgl_spec: added nodes=%s type=%s use=%s", - new_record->nodes, convert_part_type(new_record->part_type), + new_record->nodes, + convert_conn_type(new_record->conn_type), convert_node_use(new_record->node_use)); #endif cleanup: - xfree(part_type); + xfree(conn_type); xfree(node_use); xfree(nodes); return error_code; @@ -454,8 +466,10 @@ static int _parse_request(char* request_string, partition_t** request_result) { int loc = 0, i,j, rc = SLURM_ERROR; - if (!request_string) + if (!request_string) { + error("_parse_request request_string is NULL"); return SLURM_ERROR; + } debug("incoming request %s", request_string); *request_result = (partition_t*) xmalloc(sizeof(partition_t)); @@ -487,14 +501,21 @@ static int _parse_request(char* request_string, partition_t** request_result) break; } } - if (loc != 5) + if (loc != 5) { + error("_parse_request: Mal-formed node list: %s", + request_string); +error("DIM=%d, loc=%d i=%d", SYSTEM_DIMENSIONS, loc, i); goto cleanup; + } (*request_result)->size = 1; for (i=0; i<SYSTEM_DIMENSIONS; i++) { if (((*request_result)->bl_coord[i] < 0) - || ((*request_result)->tr_coord[i] < 0)) + || ((*request_result)->tr_coord[i] < 0)) { + error("_parse_request: Bad node list values: %s", + request_string); goto cleanup; + } /* count self */ (*request_result)->dimensions[i] = (*request_result)->tr_coord[i] - @@ -513,11 +534,11 @@ static int _parse_request(char* request_string, partition_t** request_result) /* Initialize all plugin variables */ extern int init_bgl(void) { -#ifdef _RM_API_H__ +#ifdef USE_BGL_FILES int rc; // FIXME, this needs to be read in from conf file. - rc = set_rm_serial("BGL"); + rc = rm_set_serial("BGL"); if (rc != STATUS_OK){ error("init_bgl: rm_set_serial failed"); return SLURM_ERROR; @@ -566,7 +587,7 @@ extern void print_bgl_record(bgl_record_t* record) info("\tnodes: %s", record->nodes); info("\tsize: %d", record->size); info("\tlifecycle: %s", convert_lifecycle(record->part_lifecycle)); - info("\tpart_type: %s", convert_part_type(record->part_type)); + info("\tconn_type: %s", convert_conn_type(record->conn_type)); info("\tnode_use: %s", convert_node_use(record->node_use)); if (record->hostlist){ @@ -598,9 +619,9 @@ extern char* convert_lifecycle(lifecycle_type_t lifecycle) return "STATIC"; } -extern char* convert_part_type(rm_partition_t pt) +extern char* convert_conn_type(rm_connection_type_t conn_type) { - switch (pt) { + switch (conn_type) { case (RM_MESH): return "RM_MESH"; case (RM_TORUS): @@ -718,7 +739,7 @@ static int _find_best_partition_match(struct job_record* job_ptr, /***********************************************/ /* check the connection type specified matches */ /***********************************************/ - if ((conn_type != record->part_type) + if ((conn_type != record->conn_type) && (conn_type != RM_NAV)) { debug("bgl partition %s conn-type not usable", record->nodes); continue; @@ -856,8 +877,8 @@ extern int submit_job(struct job_record *job_ptr, bitstr_t *slurm_part_bitmap, * we'll create an LLNL_#, i.e. LLNL_4 = 6 chars + 1 for NULL */ char bgl_part_id[BITSIZE]; -#ifdef _RM_API_H__ - snprintf(bgl_part_id, BITSIZE, "LLNL_%i", *(record->bgl_part_id)); +#ifdef USE_BGL_FILES + snprintf(bgl_part_id, BITSIZE, "%s", *record->bgl_part_id); #else snprintf(bgl_part_id, BITSIZE, "LLNL_128_16"); #endif @@ -880,18 +901,15 @@ extern int submit_job(struct job_record *job_ptr, bitstr_t *slurm_part_bitmap, */ static void _update_bgl_node_bitmap(void) { -#ifdef _RM_API_H__ - int bp_num,wire_num,switch_num,i; +#ifdef USE_BGL_FILES + int bp_num,i; rm_BP_t *my_bp; - rm_switch_t *my_switch; - rm_wire_t *my_wire; rm_BP_state_t bp_state; rm_location_t bp_loc; - // rm_size3D_t bp_size,size_in_bp,m_size; - // rm_size3D_t bp_size,size_in_bp,m_size; - char* reason = NULL; + rm_size3D_t bp_size; char down_node_list[BUFSIZE] = ""; char bgl_down_node[128]; + char *bp_id; if (!bgl) { error("error, BGL is not initialized"); @@ -907,34 +925,35 @@ static void _update_bgl_node_bitmap(void) rm_get_data(bgl,RM_BPNum,&bp_num); debug("- - - - - BPS (%d) - - - - - -",bp_num); - for(i=0;i<bp_num;i++){ - if(i==0) + for (i=0;i<bp_num;i++) { + if (i==0) rm_get_data(bgl,RM_FirstBP,&my_bp); else rm_get_data(bgl,RM_NextBP,&my_bp); // is this blocking call? - rm_get_data(my_bp,RM_BPState,&bp_state); - rm_get_data(my_bp,RM_BPLoc,&bp_loc); + rm_get_data(my_bp, RM_BPState, &bp_state); + rm_get_data(my_bp, RM_BPLoc, &bp_loc); + rm_get_data(my_bp, RM_PartitionID, &bp_id); /* from here we either update the node or bitmap entry */ /** translate the location to the "node name" */ - snprintf(bgl_down_node, sizeof[bgl_down_node], "bgl%d%d%d", + snprintf(bgl_down_node, sizeof(bgl_down_node), "bgl%d%d%d", bp_loc.X, bp_loc.Y, bp_loc.Z); debug("update bgl node bitmap: %s loc(%s) is in state %s", - BPID, - bgl_down_node, - convert_bp_state(RM_BPState)); + bp_id, bgl_down_node, _convert_bp_state(RM_BPState)); // convert_partition_state(BPPartState); - // BPID,convert_bp_state(BPState),bp_loc.X,bp_loc.Y,bp_loc.Z,BPPartID + // BPID,_convert_bp_state(BPState),bp_loc.X,bp_loc.Y, + // bp_loc.Z,BPPartID if (RM_BPState == RM_BP_DOWN) { /* now we have to convert the BGL BP to a node * that slurm knows about = comma separated * node list */ - if (strlen(down_node_list) + strlen(bgl_down_node) + 2) < BUFSIZE) { - if (done_node_list[0] != '\0') + if ((strlen(down_node_list) + strlen(bgl_down_node) + +2) < BUFSIZE) { + if (down_node_list[0] != '\0') strcat(down_node_list,","); strcat(down_node_list, bgl_down_node); } else @@ -955,9 +974,10 @@ static void _update_bgl_node_bitmap(void) } -#ifdef _RM_API_H__ -/** */ -extern char *convert_bp_state(rm_BP_state_t state){ +#ifdef USE_BGL_FILES +/* Convert base partition state value to a string */ +static char *_convert_bp_state(rm_BP_state_t state) +{ switch(state){ case RM_BP_UP: return "RM_BP_UP"; @@ -967,14 +987,16 @@ extern char *convert_bp_state(rm_BP_state_t state){ break; case RM_BP_NAV: return "RM_BP_NAV"; - defalt: + default: return "BP_STATE_UNIDENTIFIED!"; } -}; +} -/** */ -extern void set_bp_node_state(rm_BP_state_t state, node_record node){ - switch(state){ +/* Set a base partition's state */ +static void _set_bp_node_state(rm_BP_state_t state, rm_element_t* element) +{ + /* rm_set_data(element, RM_PartitionState, state) */ + switch(state) { case RM_BP_UP: debug("RM_BP_UP"); break; @@ -984,11 +1006,11 @@ extern void set_bp_node_state(rm_BP_state_t state, node_record node){ case RM_BP_NAV: debug("RM_BP_NAV"); break; - defalt: + default: debug("BGL state update returned UNKNOWN state"); break; } -}; +} #endif /* diff --git a/src/plugins/select/bluegene/bluegene.h b/src/plugins/select/bluegene/bluegene.h index 40c056ec1c3..4be41304d4c 100644 --- a/src/plugins/select/bluegene/bluegene.h +++ b/src/plugins/select/bluegene/bluegene.h @@ -34,15 +34,27 @@ #include "src/common/hostlist.h" #include "src/slurmctld/slurmctld.h" -// #include "rm_api.h" -#ifndef _RM_API_H__ - typedef uint16_t pm_partition_id_t; +#ifdef HAVE_BGL_FILES +# include "rm_api.h" + +/* + * There is presently a huge amount of untested code to use the APIs. + * Surround the code with "#ifdef USE_BGL_FILES". When it is confirmed + * to work, use "#ifdef HAVE_BGL_FILES" around the code using the APIs. + */ +/* #define USE_BGL_FILES 1 */ + +#else + typedef char * pm_partition_id_t; + typedef uint16_t rm_connection_type_t; typedef uint16_t rm_partition_t; typedef uint16_t rm_partition_mode_t; -#else - rm_BGL_t *bgl; + typedef char * rm_BGL_t; #endif +/* Global variables */ +rm_BGL_t *bgl; + typedef int lifecycle_type_t; enum part_lifecycle {DYNAMIC, STATIC}; @@ -55,7 +67,7 @@ typedef struct bgl_record { bitstr_t *bitmap; /* bitmap of nodes for this partition */ struct partition* alloc_part; /* the allocated partition */ int size; /* node count for the partitions */ - rm_partition_t part_type; /* Mesh or Torus or NAV */ + rm_connection_type_t conn_type;/* Mesh or Torus or NAV */ rm_partition_mode_t node_use; /* either COPROCESSOR or VIRTUAL */ } bgl_record_t; @@ -65,7 +77,7 @@ typedef struct bgl_record { */ typedef struct bgl_conf_record{ char* nodes; - rm_partition_t part_type; + rm_connection_type_t conn_type;/* Mesh or Torus or NAV */ rm_partition_mode_t node_use; } bgl_conf_record_t; @@ -104,7 +116,7 @@ extern void print_bgl_record(bgl_record_t* record); /* Return strings representing blue gene data types */ extern char* convert_lifecycle(lifecycle_type_t lifecycle); -extern char* convert_part_type(rm_partition_t pt); +extern char* convert_conn_type(rm_connection_type_t conn_type); extern char* convert_node_use(rm_partition_mode_t pt); /* bluegene_agent - detached thread periodically updates status of bluegene nodes */ diff --git a/src/plugins/select/bluegene/partition_sys.c b/src/plugins/select/bluegene/partition_sys.c index 538139d1a69..79610ebf91e 100755 --- a/src/plugins/select/bluegene/partition_sys.c +++ b/src/plugins/select/bluegene/partition_sys.c @@ -25,10 +25,6 @@ // #define DEBUG_ALLOCATE // #define DEBUG_PART -// #define _RM_API_H__ - -/** need this to have it compile with the BGL header*/ -// typedef int MPIR_PROCDESC; #include <math.h> #include <stdlib.h> @@ -38,10 +34,9 @@ #include "src/common/xmalloc.h" #include "partition_sys.h" #include "bluegene.h" -// #include "rm_api.h" -#ifdef _RM_API_H__ -#include "bgl_switch_connections.h" +#ifdef USE_BGL_FILES +# include "bgl_switch_connections.h" #endif /****************************/ @@ -50,16 +45,8 @@ uint16_t BGL_PARTITION_NUMBER; /****************************/ #ifdef _UNIT_TEST_ -extern void * lsd_fatal_error(char *file, int line, char *mesg){} -extern void * lsd_nomem_error(char *file, int line, char *mesg){} -#endif - -/** */ -#ifdef _RM_API_H__ -char *BGL_MLOADER_IMAGE = "/bgl/edi/build/bglsys/bin/mmcs-mloader.rts"; -char *BGL_BLRTS_IMAGE = "/bgl/edi/build/bglsys/bin//rts_hw.rts"; -char *BGL_LINUX_IMAGE = "/bgl/edi/build/bglsys/bin/zImage.elf"; -char *BGL_RAMDISK_IMAGE = "/bgl/edi/build/bglsys/bin/ramdisk.elf"; + extern void * lsd_fatal_error(char *file, int line, char *mesg){} + extern void * lsd_nomem_error(char *file, int line, char *mesg){} #endif /** these are used in the dynamic partitioning algorithm */ @@ -68,53 +55,46 @@ List bgl_sys_free = NULL; /* global system = list of allocated partitions */ List bgl_sys_allocated = NULL; -void _init_sys(partition_t*); -int _is_not_equals_all_coord(uint16_t* rec_a, uint16_t* rec_b); -int _is_not_equals_some_coord(uint16_t* rec_a, uint16_t* rec_b); - -#ifdef _RM_API_H__ -/** - * _get_bp: get the BP at location loc - * - * IN - bgl: pointer to preinitialized bgl pointer - * IN - bp: pointer to preinitailized rm_element_t that will - * hold the BP that we resolve to. - * IN - loc: location of the desired BP - * OUT - bp: will point to BP at location loc - * OUT - rc: error code (0 = success) - */ - int _get_bp(rm_element_t *bp, rm_location_t *loc); - int _check_bp_status(rm_location_t *loc); - void _pre_allocate(rm_partition_t* my_part, rm_connection_type_t* part_conn); - int _post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id); - int _get_switch_list(partition_t* partition, List* switch_list); - int _get_bp_by_location(int* cur_coord, rm_BP_t** bp); - void _rm_switch_t_destroy(void* object); - -#else - int _create_bgl_partitions(List requests); - +static void _init_sys(partition_t*); + +#ifdef USE_BGL_FILES + char *BGL_MLOADER_IMAGE = "/bgl/edi/build/bglsys/bin/mmcs-mloader.rts"; + char *BGL_BLRTS_IMAGE = "/bgl/edi/build/bglsys/bin//rts_hw.rts"; + char *BGL_LINUX_IMAGE = "/bgl/edi/build/bglsys/bin/zImage.elf"; + char *BGL_RAMDISK_IMAGE = "/bgl/edi/build/bglsys/bin/ramdisk.elf"; + + /** + * _get_bp: get the BP at location loc + * + * IN - bgl: pointer to preinitialized bgl pointer + * IN - bp: pointer to preinitailized rm_element_t that will + * hold the BP that we resolve to. + * IN - loc: location of the desired BP + * OUT - bp: will point to BP at location loc + * OUT - rc: error code (0 = success) + */ + static int _get_bp(rm_element_t *bp, rm_location_t *loc); + static int _is_not_equals_all_coord (int* rec_a, int* rec_b); + static int _is_not_equals_some_coord(int* rec_a, int* rec_b); + static void _pre_allocate(rm_partition_t* my_part, + rm_connection_type_t part_conn); + static int _post_allocate(rm_partition_t *my_part, + pm_partition_id_t *part_id); + static int _get_switch_list(partition_t* partition, List* switch_list); + static int _get_bp_by_location(int* cur_coord, rm_BP_t** bp); #endif - int _break_up_partition(List sys, partition_t* partition_to_break, int index); - int _fit_request(List sys, List allocated, uint16_t* request); - void _int_array_destroy(void* object); - int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b); +static int _create_bgl_partitions(List requests); - int _partition_cmpf_inc(struct partition* rec_a, struct partition* rec_b); - int _partition_cmpf_dec(struct partition* rec_a, struct partition* rec_b); +static int _break_up_partition(List sys, partition_t* partition_to_break, + int index); +static int _fit_request(List sys, List allocated, uint16_t* request); -#ifdef _RM_API_H__ - void _preallocate(rm_BGL_t* bgl, rm_partition_t* my_part, - char* username, rm_connection_type_t* part_conn); - int _postallocate(rm_BGL_t *bgl, rm_partition_t *my_part, - pm_partition_id_t *part_id); -#endif +static void _int_array_destroy(void* object); +static int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b); - List _get_bgl_sys_free(); - List _get_bgl_sys_allocated(); #ifdef _UNIT_TESTS_ -extern void debug(const char *fmt, ...); + extern void debug(const char *fmt, ...); #endif @@ -190,7 +170,7 @@ int partition_sys(List requests) * IN - requests: List <partition_t*> to wire up. * */ - int _create_bgl_partitions(List requests) +static int _create_bgl_partitions(List requests) { partition_t* cur_partition; ListIterator itr; @@ -537,20 +517,16 @@ void sort_int_array_by_dec_size(List configs) * * returns 0 for success, 1 for failure */ -#ifdef _RM_API_H__ -int configure_switches(rm_partition_t* partition, partition_t* partition) -#else -int configure_switches(partition_t* partition) -#endif +extern int configure_switches(partition_t* partition) { bgl_record_t* bgl_rec; int cur_coord[SYSTEM_DIMENSIONS]; pm_partition_id_t* bgl_part_id; -#ifdef _RM_API_H__ +#ifdef USE_BGL_FILES rm_switch_t* my_switch; rm_partition_t *bgl_part; - pre_allocate(bgl_part, cur_partition->part_type); + _pre_allocate(bgl_part, partition->conn_type); #endif if (partition == NULL){ @@ -574,21 +550,22 @@ int configure_switches(partition_t* partition) */ /* for each of the dimensions */ - // int first = 1; for (cur_coord[0] = partition->bl_coord[0]; cur_coord[0] <= partition->tr_coord[0]; - cur_coord[0]++){ + cur_coord[0]++) { for (cur_coord[1] = partition->bl_coord[1]; cur_coord[1] <= partition->tr_coord[1]; - cur_coord[1]++){ + cur_coord[1]++) { for (cur_coord[2] = partition->bl_coord[2]; cur_coord[2] <= partition->tr_coord[2]; - cur_coord[2]++){ + cur_coord[2]++) { + +#ifdef USE_BGL_FILES + /***** BGL SPECIFIC ******/ + int first = 1; -#ifdef _RM_API_H__ - /***** BGL SPECIFIC ******/ /** below, we wire up each all three switches of each BP **/ /* SPECIAL CASE FIRST BP */ if (!_is_not_equals_some_coord(cur_coord, partition->bl_coord)){ @@ -685,18 +662,17 @@ int configure_switches(partition_t* partition) bgl_part_id = (pm_partition_id_t*) xmalloc(sizeof(pm_partition_id_t)); -#ifdef _RM_API_H__ - post_allocate(bgl_part, bgl_part_id); +#ifdef USE_BGL_FILES + _post_allocate(bgl_part, bgl_part_id); bgl_rec = (bgl_record_t*) partition->bgl_record_ptr; bgl_rec->bgl_part_id = bgl_part_id; partition->bgl_part_id = bgl_part_id; #else - // *bgl_part_id = (int)(rand()%100); - *bgl_part_id = BGL_PARTITION_NUMBER++; + *bgl_part_id = "LLNL_128_16"; bgl_rec = (bgl_record_t*) partition->bgl_record_ptr; - bgl_rec->bgl_part_id = bgl_part_id; + bgl_rec->bgl_part_id = bgl_part_id; partition->bgl_part_id = bgl_part_id; #endif @@ -835,7 +811,7 @@ void rotate_part(const uint16_t* config, uint16_t** new_config) * this should really go out and get BGL specific information * */ - void _init_sys(partition_t *part) +static void _init_sys(partition_t *part) { /* initialize the system wide partition */ bgl_sys_free = list_create((ListDelF) _int_array_destroy); @@ -866,55 +842,57 @@ void rotate_part(const uint16_t* config, uint16_t** new_config) xfree(object); } -#ifdef _RM_API_H__ +#ifdef USE_BGL_FILES /** * initialize the BGL partition in the resource manager */ -void pre_allocate(rm_partition_t *my_part, rm_connection_type_t *part_conn) +static void _pre_allocate(rm_partition_t *my_part, + rm_connection_type_t part_conn) { - rm_new_partition(&my_part); //here we go... new partition to be added - rm_set_data(my_part,RM_PartitionMloaderImg, BGL_MLOADER_IMAGE); - rm_set_data(my_part,RM_PartitionBlrtsImg, BGL_BLRTS_IMAGE); - rm_set_data(my_part,RM_PartitionLinuxImg, BGL_LINUX_IMAGE); - rm_set_data(my_part,RM_PartitionRamdiskImg, BGL_RAMDISK_IMAGE); - rm_set_data(my_part,RM_PartitionConnection, part_conn); + rm_new_partition(&my_part); /* new partition to be added */ + rm_set_data(my_part, RM_PartitionMloaderImg, BGL_MLOADER_IMAGE); + rm_set_data(my_part, RM_PartitionBlrtsImg, BGL_BLRTS_IMAGE); + rm_set_data(my_part, RM_PartitionLinuxImg, BGL_LINUX_IMAGE); + rm_set_data(my_part, RM_PartitionRamdiskImg, BGL_RAMDISK_IMAGE); + rm_set_data(my_part, RM_PartitionConnection, part_conn); } /** * add the partition record to the DB and boot it up! */ -int post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id) +static int _post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id) { int rc; rm_partition_state_t state; - //Add partition record to the DB + /* Add partition record to the DB */ rc = rm_add_partition(my_part); - if (rc != STATUS_OK){ + if (rc != STATUS_OK) { error("Error adding partition"); return(-1); } - // Get back the new partition id + /* Get back the new partition id */ rm_get_data(my_part, RM_PartitionID, &part_id); //Initiate boot of the partition debug("Booting Partition %s", part_id); rc = pm_create_partition(part_id); - if (rc != STATUS_OK){ + if (rc != STATUS_OK) { error("Error booting_partition partition"); return(-1); } - //Wait for Partition to be booted + /* Wait for Partition to be booted */ rc = rm_get_partition(part_id, &my_part); - if (rc != STATUS_OK){ + if (rc != STATUS_OK) { error("Error in GetPartition"); return(-1); } rm_get_data(my_part, RM_PartitionState, &state); - error("Partition %s state = %s. Waiting...", part_id, convert_partition_state(state)); + error("Partition %s state = %s. Waiting...", part_id, + convert_partition_state(state)); fflush(stdout); } @@ -925,13 +903,13 @@ int _get_switch_list(int* cur_coord, List* switch_list) { int switch_num, i; rm_BP_t * bp; - rm_BP_id_t *cur_bpid, *bpid; + rm_bp_id_t *cur_bpid, *bpid; rm_switch_t* bgl_switch; int found_bpid; - *switch_list = list_create(rm_switch_t_destroy); + *switch_list = list_create(rm_free_switch); - if (_get_bp_by_location(cur_coord, &bp)){ + if (_get_bp_by_location(cur_coord, &bp)) { return SLURM_ERROR; } @@ -940,7 +918,7 @@ int _get_switch_list(int* cur_coord, List* switch_list) rm_get_data(bgl, RM_SwitchNum, &switch_num); rm_get_data(my_bgl,RM_FirstSwitch,&my_switch); found_bpid = 0; - for (i=0; i<SwitchNum; i++){ + for (i=0; i<SwitchNum; i++) { rm_get_data(my_switch, RM_SwitchBPID, &cur_bpid); /** FIXME is there an equality function for BPID? */ if (*bpid == *cur_bpid){ @@ -957,14 +935,14 @@ int _get_switch_list(int* cur_coord, List* switch_list) * get these three switches in a row, and they should be XYZ */ - list_push(switch_list, my_switch); + list_push(*switch_list, my_switch); for (i=0; i<2; i++){ rm_get_data(my_bgl,RM_NextSwitch,&my_switch); /* i'm just going to check here again for my sanity*/ if (*bpid != *cur_bpid) break; - list_push(switch_list, my_switch); + list_push(*switch_list, my_switch); } return SLURM_SUCCESS; @@ -987,7 +965,7 @@ void rm_switch_t_destroy(void* object) * this is just stupid. there are some implicit rules for where * "NextBP" goes to, but we don't know, so we have to do this. */ -int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) +static int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) { int i, bp_num; rm_location_t loc; @@ -997,7 +975,9 @@ int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) for (i=0; i<bp_num; i++){ rm_get_data(*bp, RM_BPLoc, &loc); - if (loc.X == cur_coord[0] && loc.Y == cur_coord[1] && loc.Z == cur_coord[2]){ + if ((loc.X == cur_coord[0]) + && (loc.Y == cur_coord[1]) + && (loc.Z == cur_coord[2])) { return SLURM_SUCCESS; } rm_get_data(my_bgl, RM_NextBP, bp); @@ -1007,14 +987,12 @@ int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) return SLURM_ERROR; } -#endif - /** * non-equality for at least one coordinate * * returns 0 if equals, 1 if not equals */ - int _is_not_equals_some_coord(uint16_t* rec_a, uint16_t* rec_b) +static int _is_not_equals_some_coord(int* rec_a, int* rec_b) { int i; for (i=0; i<SYSTEM_DIMENSIONS; i++){ @@ -1029,7 +1007,7 @@ int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) * * returns 0 if equals, 1 if not equals */ - int _is_not_equals_all_coord(uint16_t* rec_a, uint16_t* rec_b) +static int _is_not_equals_all_coord(int* rec_a, int* rec_b) { int i; for (i=0; i<SYSTEM_DIMENSIONS; i++){ @@ -1038,69 +1016,7 @@ int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp) } return 0; } - -/** - * sort the partitions by increasing size - */ - void _sort_partitions_by_inc_size(List parts){ - if (parts == NULL) - return; - list_sort(parts, (ListCmpF) _partition_cmpf_inc); -} - -/** - * sort the partitions by decreasing size - */ - void _sort_partitions_by_dec_size(List parts){ - if (parts == NULL) - return; - list_sort(parts, (ListCmpF) _partition_cmpf_dec); -} - - -/** - * Comparator used for sorting partitions smallest to largest - * - * returns: -1: rec_a < rec_b 0: rec_a == rec_b 1: rec_a > rec_b - * - */ - int _partition_cmpf_inc(struct partition* rec_a, struct partition* rec_b) -{ - if (rec_a->size < rec_b->size) - return -1; - else if (rec_a->size > rec_b->size) - return 1; - else - return 0; -} - -/** - * Comparator used for sorting partitions largest to smallest - * - * returns: -1: rec_a > rec_b 0: rec_a == rec_b 1: rec_a < rec_b - * - */ - int _partition_cmpf_dec(struct partition* rec_a, struct partition* rec_b) -{ - if (rec_a->size > rec_b->size) - return -1; - else if (rec_a->size < rec_b->size) - return 1; - else - return 0; -} - -/** */ - List _get_bgl_sys_allocated() -{ - return bgl_sys_allocated; -} - -/** */ - List _get_bgl_sys_free() -{ - return bgl_sys_free; -} +#endif #ifdef _UNIT_TESTS_ extern void debug(const char *fmt, ...) diff --git a/src/plugins/select/bluegene/partition_sys.h b/src/plugins/select/bluegene/partition_sys.h index 51067b2c680..acd42cc7a07 100644 --- a/src/plugins/select/bluegene/partition_sys.h +++ b/src/plugins/select/bluegene/partition_sys.h @@ -25,9 +25,15 @@ #ifndef _PARTITION_SYS_H_ #define _PARTITION_SYS_H_ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include <math.h> #include <slurm/slurm.h> +#include "bluegene.h" + #define X_DIMENSION 8 #define Y_DIMENSION 4 #define Z_DIMENSION 4 @@ -36,20 +42,15 @@ * structure for use by partitioning algorithm to refer to the * structural elements of the BGL partition system. */ -typedef struct partition{ +typedef struct partition { int bl_coord[SYSTEM_DIMENSIONS]; /* bottom left coordinates */ int tr_coord[SYSTEM_DIMENSIONS]; /* top right coordinates */ ushort dimensions[SYSTEM_DIMENSIONS]; /* X,Y,Z dimensions */ void* bgl_record_ptr; /* pointer to referring bgl_record */ int size; -#ifdef _RM_API_H__ - pm_partition_id_t* bgl_part_id; /* ID returned from CMCS */ - -#else - ushort* bgl_part_id; /* ID returned from CMCS */ - ushort part_type; /* Type=Mesh/Torus/NAV */ + pm_partition_id_t *bgl_part_id; /* ID returned from CMCS */ + ushort conn_type; /* Type=Mesh/Torus/NAV */ ushort node_use; /* Use=Virtual/Coprocessor */ -#endif } partition_t; extern int configure_switches(partition_t* partition); -- GitLab