diff --git a/src/plugins/select/bluegene/bluegene.c b/src/plugins/select/bluegene/bluegene.c index 19dd3f94fc59209a1b49fa67978088d39f7b4c8d..749c174b1666ebdaeb7c855a6fd3388d006d6b48 100644 --- a/src/plugins/select/bluegene/bluegene.c +++ b/src/plugins/select/bluegene/bluegene.c @@ -39,6 +39,7 @@ #define BUFSIZE 4096 #define BITSIZE 128 #define SLEEP_TIME 60 /* BLUEGENE_PTHREAD checks every 60 secs */ +#define _DEBUG 0 char* bgl_conf = BLUEGENE_CONFIG_FILE; @@ -86,10 +87,12 @@ static void _rotate_geo(uint16_t *req_geometry, int rot_cnt); extern int create_static_partitions(List part_list) { /** purge the old list. Later on, it may be more efficient just to amend the list */ - if (bgl_list){ - list_destroy(bgl_list); - } - bgl_list = list_create(_destroy_bgl_record); + if (bgl_list) { + bgl_record_t *record; + while ((record = list_pop(bgl_list))) + _destroy_bgl_record(record); + } else + bgl_list = list_create(_destroy_bgl_record); /** copy the slurm conf partition info, this will fill in bgl_list */ if (_copy_slurm_partition_list(part_list)){ @@ -97,8 +100,8 @@ extern int create_static_partitions(List part_list) } _process_config(); - /* after reading in the configuration, we have a list of partition requests (List <int*>) - * that we can use to partition up the system + /* after reading in the configuration, we have a list of partition + * requests (List <int*>) that we can use to partition up the system */ _wire_bgl_partitions(); @@ -146,7 +149,7 @@ static void _process_config() itr = list_iterator_create(bgl_list); while ((bgl_part = (bgl_record_t*) list_next(itr))) { /** - * parse request will fill up the partition_t's + * _parse_request() will fill up the partition_t's * bl_coord, tr_coord, dimensions, and size */ request_result = NULL; @@ -176,7 +179,7 @@ static int _copy_slurm_partition_list(List slurm_part_list) bgl_record_t* bgl_record; ListIterator itr; char* cur_nodes, *delimiter=",", *nodes_tmp, *next_ptr, *orig_ptr; - int err, rc; + int rc = SLURM_SUCCESS; itr = list_iterator_create(slurm_part_list); /** @@ -184,28 +187,22 @@ static int _copy_slurm_partition_list(List slurm_part_list) * nodes specified in the slurm_part_list, but if not * found, _find_part_type will default to RM_MESH */ - rc = SLURM_SUCCESS; while ((slurm_part = (struct part_record *) list_next(itr))) { + /* no need to create record for slurm partition without nodes*/ + if ((slurm_part->nodes == NULL) + || (slurm_part->nodes[0] == '\0')) + continue; nodes_tmp = xstrdup(slurm_part->nodes); orig_ptr = nodes_tmp; cur_nodes = strtok_r(nodes_tmp, delimiter, &next_ptr); - /** debugging info */ - /* - { - debug("current slurm nodes to parse <%s>", slurm_part->nodes); - debug("slurm_part->node_bitmap"); - _print_bitmap(slurm_part->node_bitmap); - } - */ - // debug("received token"); - // debug("received token <%s>", cur_nodes); + debug3("_copy_slurm_partition_list parse:%s, token[0]:%s", + slurm_part->nodes, cur_nodes); /** * for each of the slurm partitions, there may be * several bgl partitions, so we need to find how to * wire each of those bgl partitions. */ - err = 0; while(cur_nodes != NULL){ bgl_record = (bgl_record_t*) xmalloc(sizeof(bgl_record_t)); bgl_record->nodes = xstrdup(cur_nodes); @@ -216,7 +213,11 @@ static int _copy_slurm_partition_list(List slurm_part_list) bgl_record->hostlist = hostlist_create(cur_nodes); bgl_record->size = hostlist_count(bgl_record->hostlist); if (node_name2bitmap(cur_nodes, false, &(bgl_record->bitmap))){ - error("unable to convert nodes %s to bitmap", cur_nodes); + error("_copy_slurm_partition_list unable to convert nodes " + "%s to bitmap", cur_nodes); + _destroy_bgl_record(bgl_record); + rc = SLURM_ERROR; + goto cleanup; } if (slurm_part->min_nodes == slurm_part->max_nodes && @@ -224,16 +225,11 @@ static int _copy_slurm_partition_list(List slurm_part_list) bgl_record->part_lifecycle = STATIC; else bgl_record->part_lifecycle = DYNAMIC; - // print_bgl_record(bgl_record); + print_bgl_record(bgl_record); list_push(bgl_list, bgl_record); nodes_tmp = next_ptr; cur_nodes = strtok_r(nodes_tmp, delimiter, &next_ptr); - if (err) { - rc = SLURM_ERROR; - goto cleanup; - } - } /* end while(cur_nodes) */ cleanup: @@ -252,6 +248,7 @@ extern int read_bgl_conf() int line_num; /* line number in input file */ char in_line[BUFSIZE]; /* input line */ int i, j, error_code; + bgl_conf_record_t *conf_rec; /* initialization */ START_TIMER; @@ -260,6 +257,9 @@ extern int read_bgl_conf() if (bgl_spec_file == NULL) fatal("read_bgl_conf error opening file %s, %m", bgl_conf); + /* empty the old list before reading new data */ + while ((conf_rec = list_pop(bgl_conf_list))) + _destroy_bgl_conf_record(conf_rec); /* process the data file */ line_num = 0; @@ -304,8 +304,7 @@ extern int read_bgl_conf() fclose(bgl_spec_file); END_TIMER; - debug("select_bluegene _read_bgl_conf: finished loading configuration %s", - TIME_STR); + debug("read_bgl_conf: finished loading configuration %s", TIME_STR); return error_code; } @@ -376,7 +375,8 @@ static void _destroy_bgl_record(void* object) xfree(this_record->nodes); xfree(this_record->slurm_part_id); xfree(this_record->part_type); - hostlist_destroy(this_record->hostlist); + if (this_record->hostlist) + hostlist_destroy(this_record->hostlist); if (this_record->bitmap) bit_free(this_record->bitmap); #ifdef _RM_API_H__ @@ -441,7 +441,7 @@ static int _parse_request(char* request_string, partition_t** request_result) if (!request_string) return SLURM_ERROR; - + debug("incoming request %s", request_string); *request_result = (partition_t*) xmalloc(sizeof(partition_t)); @@ -526,33 +526,35 @@ extern void print_bgl_record(bgl_record_t* record) return; } - debug(" bgl_record:"); - debug(" \tslurm_part_id: %s", record->slurm_part_id); +#if _DEBUG + info(" bgl_record: "); + info("\tslurm_part_id: %s", record->slurm_part_id); if (record->bgl_part_id) - debug(" \tbgl_part_id: %d", *(record->bgl_part_id)); - debug(" \tnodes: %s", record->nodes); - // debug(" size: %d", record->size); - debug(" \tlifecycle: %s", convert_lifecycle(record->part_lifecycle)); - debug(" \tpart_type: %s", convert_part_type(record->part_type)); + info("\tbgl_part_id: %d", *(record->bgl_part_id)); + 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)); if (record->hostlist){ char buffer[BUFSIZE]; hostlist_ranged_string(record->hostlist, BUFSIZE, buffer); - debug(" \thostlist %s", buffer); + info("\thostlist %s", buffer); } if (record->alloc_part){ - debug(" \talloc_part:"); + info("\talloc_part:"); print_partition(record->alloc_part); } else { - debug(" \talloc_part: NULL"); + info("\talloc_part: NULL"); } if (record->bitmap){ char bitstring[BITSIZE]; bit_fmt(bitstring, BITSIZE, record->bitmap); - debug("\tbitmap: %s", bitstring); + info("\tbitmap: %s", bitstring); } +#endif } extern char* convert_lifecycle(lifecycle_type_t lifecycle) @@ -965,7 +967,7 @@ bluegene_agent(void *args) _update_bgl_node_bitmap(); gettimeofday(&tv2, NULL); _diff_tv_str(&tv1, &tv2, tv_str, 20); -#if DEBUG +#if _DEBUG info("Bluegene status update: completed, %s", tv_str); #endif sleep(SLEEP_TIME); /* don't run continuously */ diff --git a/src/plugins/select/bluegene/partition_sys.c b/src/plugins/select/bluegene/partition_sys.c index f066923999412ba0629446d0cecdeb4657a38dfa..90a472a7b11d278b755c40d8f6a7e09b35bba7b7 100755 --- a/src/plugins/select/bluegene/partition_sys.c +++ b/src/plugins/select/bluegene/partition_sys.c @@ -143,7 +143,7 @@ extern void debug(const char *fmt, ...); * essentially wires up the system */ -int partition_sys(List requests) +extern int partition_sys(List requests) { ListIterator itr; @@ -191,7 +191,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; @@ -362,7 +362,7 @@ static int _break_up_partition(List sys, partition_t* partition_to_break, return 0; } -void print_partition(partition_t* part) +extern void print_partition(partition_t* part) { if (part == NULL) return; @@ -377,7 +377,7 @@ void print_partition(partition_t* part) debug("\tbgl_record_ptr addr: %d", part->bgl_record_ptr); } -void copy_partition(partition_t* src, partition_t* dest) +extern void copy_partition(partition_t* src, partition_t* dest) { int i; @@ -395,7 +395,7 @@ void copy_partition(partition_t* src, partition_t* dest) /** * returns 0 for equals, 1 for not equals */ -int is_partition_not_equals(partition_t* A, partition_t* B) +extern int is_partition_not_equals(partition_t* A, partition_t* B) { if (A == NULL || B == NULL) return 1; @@ -410,7 +410,7 @@ int is_partition_not_equals(partition_t* A, partition_t* B) /** * return - the int array's size */ -int int_array_size(uint16_t* part_geometry){ +extern int int_array_size(uint16_t* part_geometry){ int size = 1; int i; @@ -427,7 +427,7 @@ int int_array_size(uint16_t* part_geometry){ /** * print out a list */ -void print_list(List list) +extern void print_list(List list) { int* stuff = NULL, i = 0; ListIterator itr; @@ -458,7 +458,7 @@ void print_list(List list) /** * print out list of the system partitions */ -void print_sys_list(List list) +extern void print_sys_list(List list) { ListIterator itr; int i, part_count=0; @@ -500,7 +500,7 @@ void print_sys_list(List list) /** * sort the configurations by decreasing size */ -void sort_int_array_by_dec_size(List configs){ +extern void sort_int_array_by_dec_size(List configs){ if (configs == NULL) return; list_sort(configs, (ListCmpF) _int_array_cmpf); @@ -514,7 +514,7 @@ void sort_int_array_by_dec_size(List configs){ * Note: return values are "reversed" so that we can have the list * sorted in decreasing order (largest to smallest) */ -int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b) +static int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b) { int vol_a, vol_b; @@ -537,9 +537,9 @@ int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b) * returns 0 for success, 1 for failure */ #ifdef _RM_API_H__ -int configure_switches(rm_partition_t* partition, partition_t* partition) +extern int configure_switches(rm_partition_t* partition, partition_t* partition) #else -int configure_switches(partition_t* partition) +extern int configure_switches(partition_t* partition) #endif { bgl_record_t* bgl_rec; @@ -705,7 +705,7 @@ int configure_switches(partition_t* partition) * find if the cur_part fits the same dimensions as the given request * return 0 for affirmative (correct dimension), and 1 for negative (not correct dimension) */ -int is_not_correct_dimension(uint16_t* cur_part, uint16_t* request) +extern int is_not_correct_dimension(uint16_t* cur_part, uint16_t* request) { int i, j; int cur_part_tmp[SYSTEM_DIMENSIONS]; @@ -748,7 +748,7 @@ int is_not_correct_dimension(uint16_t* cur_part, uint16_t* request) } } -int factorial(int numb) +extern int factorial(int numb) { int i, fact = 1; for (i=numb; i > 0; i++) @@ -759,7 +759,7 @@ int factorial(int numb) /** * return the index */ -int max_dim_index(int* array) +extern int max_dim_index(int* array) { int i, max = -1, max_index = 0; for (i=0; i<SYSTEM_DIMENSIONS; i++){ @@ -778,7 +778,7 @@ int max_dim_index(int* array) * * note: this is for 3d only! */ -void rotate_part(const uint16_t* config, uint16_t** new_config) +extern void rotate_part(const uint16_t* config, uint16_t** new_config) { if (config == NULL) return; @@ -833,7 +833,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); @@ -841,13 +841,13 @@ void _init_sys(partition_t *part) part->bl_coord[0] = 0; part->bl_coord[1] = 0; part->bl_coord[2] = 0; - part->tr_coord[0] = 7; - part->tr_coord[1] = 3; - part->tr_coord[2] = 3; - part->dimensions[0] = 8; - part->dimensions[1] = 4; - part->dimensions[2] = 4; - part->size = 128; + part->tr_coord[0] = (X_DIMENSION - 1); + part->tr_coord[1] = (Y_DIMENSION - 1); + part->tr_coord[2] = (Z_DIMENSION - 1); + part->dimensions[0] = X_DIMENSION; + part->dimensions[1] = Y_DIMENSION; + part->dimensions[2] = Z_DIMENSION; + part->size = X_DIMENSION * Y_DIMENSION * Z_DIMENSION; /** ??? FIXME, I get a segfault if I have the list_create before the use of bgl_sys_free (swapping * the following two statements. WHY??? @@ -868,7 +868,7 @@ static void _int_array_destroy(void* object) /** * initialize the BGL partition in the resource manager */ -void pre_allocate(rm_partition_t *my_part, rm_connection_type_t *part_conn) +extern 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); @@ -881,7 +881,7 @@ void pre_allocate(rm_partition_t *my_part, rm_connection_type_t *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) +extern int post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id) { int rc; rm_partition_state_t state; @@ -919,7 +919,7 @@ int post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id) /** * get switch of the BP of these coordinates */ -int get_switch(int* cur_coord, List switch_list) +extern int get_switch(int* cur_coord, List switch_list) { int switch_num, i; rm_BP_t * bp; @@ -979,7 +979,7 @@ int get_switch(int* cur_coord, List switch_list) /** * to be used by list object to destroy the array elements */ -void rm_switch_t_destroy(void* object) +extern void rm_switch_t_destroy(void* object) { /** FIXME, find out how to destroy one of these */ xfree(object); @@ -1103,13 +1103,13 @@ static List _get_bgl_sys_free() } #ifdef _UNIT_TESTS_ -void debug(const char *fmt, ...) +extern void debug(const char *fmt, ...) { printf(fmt, ...); } #endif -void init_bgl_partition_num() +extern void init_bgl_partition_num() { BGL_PARTITION_NUMBER = 0; } diff --git a/src/plugins/select/bluegene/partition_sys.h b/src/plugins/select/bluegene/partition_sys.h index 08a06a27e039ce9cb0654503a97f3628b55226ec..07c3a2a33f7a2e5a931f0d2d2e447793fe6add9a 100644 --- a/src/plugins/select/bluegene/partition_sys.h +++ b/src/plugins/select/bluegene/partition_sys.h @@ -51,22 +51,22 @@ typedef struct partition{ #endif } partition_t; -int configure_switches(partition_t* partition); -int partition_sys(List requests); +extern int configure_switches(partition_t* partition); +extern int partition_sys(List requests); -void copy_partition(partition_t* rec_a, partition_t* rec_b); -void print_partition(partition_t* part); -void print_list(List list); -void print_sys_list(List list); +extern void copy_partition(partition_t* rec_a, partition_t* rec_b); +extern void print_partition(partition_t* part); +extern void print_list(List list); +extern void print_sys_list(List list); -int is_not_correct_dimension(ushort* cur_part, ushort* req); -int is_partition_not_equals(partition_t* rec_a, partition_t* rec_b); -void rotate_part(const ushort* config, ushort** new_config); +extern int is_not_correct_dimension(ushort* cur_part, ushort* req); +extern int is_partition_not_equals(partition_t* rec_a, partition_t* rec_b); +extern void rotate_part(const ushort* config, ushort** new_config); -int int_array_size(ushort* part_geometry); -void sort_int_array_by_dec_size(List configs); -void sort_partitions_by_inc_size(List partitions); -void sort_partitions_by_dec_size(List partitions); -void init_bgl_partition_num(); +extern int int_array_size(ushort* part_geometry); +extern void sort_int_array_by_dec_size(List configs); +extern void sort_partitions_by_inc_size(List partitions); +extern void sort_partitions_by_dec_size(List partitions); +extern void init_bgl_partition_num(); #endif /* _PARTITION_SYS_H_ */