From 76e622a55209e4a6087b9d3918b0a95798cbdd35 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 1 Sep 2005 17:38:04 +0000 Subject: [PATCH] Clean up a few memory leaks - more to go... This commit was SVN r7134. --- orte/class/orte_bitmap.c | 90 ++-- orte/class/orte_bitmap.h | 33 +- orte/mca/gpr/replica/gpr_replica_component.c | 87 +++- orte/mca/oob/tcp/oob_tcp.c | 10 +- orte/mca/rmgr/base/rmgr_base_stage_gate.c | 11 + orte/mca/sds/base/sds_base_universe.c | 2 + orte/runtime/orte_init_stage1.c | 60 +-- test/dps/dps_test.c | 458 +++++++++---------- 8 files changed, 393 insertions(+), 358 deletions(-) diff --git a/orte/class/orte_bitmap.c b/orte/class/orte_bitmap.c index a47a328e8b..33037d2277 100644 --- a/orte/class/orte_bitmap.c +++ b/orte/class/orte_bitmap.c @@ -3,14 +3,14 @@ * All rights reserved. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * All rights reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ - * + * * Additional copyrights may follow - * + * * $HEADER$ */ @@ -25,20 +25,26 @@ #define SIZE_OF_CHAR (sizeof(char) * 8) +#define DEFAULT_BITMAP_SIZE 64 static void orte_bitmap_construct(orte_bitmap_t *bm); static void orte_bitmap_destruct(orte_bitmap_t *bm); -OBJ_CLASS_INSTANCE(orte_bitmap_t, opal_object_t, +OBJ_CLASS_INSTANCE(orte_bitmap_t, opal_object_t, orte_bitmap_construct, orte_bitmap_destruct); -static void -orte_bitmap_construct(orte_bitmap_t *bm) +static void +orte_bitmap_construct(orte_bitmap_t *bm) { - bm->legal_numbits = 0; - bm->array_size = 0; - bm->bitmap = NULL; + size_t size; + + size = DEFAULT_BITMAP_SIZE / SIZE_OF_CHAR; + + bm->array_size = size + ((size % SIZE_OF_CHAR == 0) ? 0 : 1); + bm->bitmap = (unsigned char *) malloc(bm->array_size); + bm->legal_numbits = SIZE_OF_CHAR*bm->array_size; + memset(bm->bitmap, 0, bm->array_size); } @@ -51,38 +57,12 @@ orte_bitmap_destruct(orte_bitmap_t *bm) } -int -orte_bitmap_init(orte_bitmap_t *bm, size_t size) -{ - size_t actual_size; - - if (NULL == bm) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - return ORTE_ERR_BAD_PARAM; - } - - actual_size = size / SIZE_OF_CHAR; - - actual_size += (size % SIZE_OF_CHAR == 0) ? 0 : 1; - bm->bitmap = (unsigned char *) malloc(actual_size); - if (NULL == bm->bitmap) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - - bm->array_size = actual_size; - bm->legal_numbits = SIZE_OF_CHAR*actual_size; - orte_bitmap_clear_all_bits(bm); - return ORTE_SUCCESS; -} - - int orte_bitmap_resize(orte_bitmap_t *bm, size_t bit) { size_t index, new_size, i; - index = bit / SIZE_OF_CHAR; + index = bit / SIZE_OF_CHAR; index += (bit % SIZE_OF_CHAR == 0) ? 0 : 1; if (index >= bm->array_size) { @@ -90,28 +70,28 @@ orte_bitmap_resize(orte_bitmap_t *bm, size_t bit) /* We need to allocate more space for the bitmap, since we are out of range. We dont throw any error here, because this is valid and we simply expand the bitmap */ - + new_size = (index / bm->array_size + 1 ) * bm->array_size; /* New size is just a multiple of the original size to fit in the index. */ - + bm->bitmap = (unsigned char *) realloc(bm->bitmap, new_size); if (NULL == bm->bitmap) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } - + /* zero out the new elements */ for (i = bm->array_size; i < new_size; ++i) { bm->bitmap[i] = 0; } - + /* Update the array_size */ bm->array_size = new_size; bm->legal_numbits = new_size*SIZE_OF_CHAR; } - + return ORTE_SUCCESS; } @@ -131,8 +111,8 @@ orte_bitmap_set_bit(orte_bitmap_t *bm, size_t bit) ORTE_ERROR_LOG(rc); return rc; } - - index = bit / SIZE_OF_CHAR; + + index = bit / SIZE_OF_CHAR; offset = bit % SIZE_OF_CHAR; /* Now set the bit */ @@ -150,7 +130,7 @@ orte_bitmap_clear_bit(orte_bitmap_t *bm, size_t bit) if (NULL == bm) { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - return ORTE_ERR_BAD_PARAM; + return ORTE_ERR_BAD_PARAM; } /* make sure the bitmap covers the requested bit */ @@ -158,11 +138,11 @@ orte_bitmap_clear_bit(orte_bitmap_t *bm, size_t bit) ORTE_ERROR_LOG(rc); return rc; } - - index = bit / SIZE_OF_CHAR; + + index = bit / SIZE_OF_CHAR; offset = bit % SIZE_OF_CHAR; - - /* now clear the bit */ + + /* now clear the bit */ bm->bitmap[index] &= ~(1 << offset); return ORTE_SUCCESS; } @@ -172,20 +152,20 @@ int orte_bitmap_is_set_bit(orte_bitmap_t *bm, size_t bit) { size_t index, offset; - + if ((bit > bm->legal_numbits - 1) || (NULL == bm)) { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); return ORTE_ERR_BAD_PARAM; } - index = bit / SIZE_OF_CHAR; + index = bit / SIZE_OF_CHAR; offset = bit % SIZE_OF_CHAR; - + if (index >= bm->array_size) { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); return ORTE_ERR_BAD_PARAM; } - + if (0 != (bm->bitmap[index] & (1 << offset))) { return (int) true; } @@ -211,12 +191,12 @@ int orte_bitmap_set_all_bits(orte_bitmap_t *bm) { size_t i; - + if (NULL == bm) { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); return ORTE_ERR_BAD_PARAM; } - + for (i = 0; i < bm->array_size; ++i) { bm->bitmap[i] = ~((char) 0); } @@ -255,7 +235,7 @@ orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm, size_t *position) ++(*position); temp >>= 1; } - + /* Now set the bit number */ bm->bitmap[i] |= (bm->bitmap[i] + 1); diff --git a/orte/class/orte_bitmap.h b/orte/class/orte_bitmap.h index 78491cdc62..b5bfc8bee6 100644 --- a/orte/class/orte_bitmap.h +++ b/orte/class/orte_bitmap.h @@ -3,14 +3,14 @@ * All rights reserved. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * All rights reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ - * + * * Additional copyrights may follow - * + * * $HEADER$ * */ @@ -49,26 +49,15 @@ struct orte_bitmap_t { unsigned char *bitmap; /**< The actual bitmap array of characters */ size_t array_size; /**< The actual array size that maintains the bitmap */ size_t legal_numbits; /**< The number of bits which are legal (the - actual bitmap may contain more bits, since - it needs to be rounded to the nearest - char */ + actual bitmap may contain more bits, since + it needs to be rounded to the nearest + char */ }; typedef struct orte_bitmap_t orte_bitmap_t; OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_bitmap_t); -/** - * Initializes the bitmap and sets its size. This must be called - * before the bitmap can be actually used - * - * @param bitmap The input bitmap (IN) - * @param size The initial size of the bitmap in terms of bits (IN) - * @return ORTE error code or success - * - */ -OMPI_DECLSPEC int orte_bitmap_init (orte_bitmap_t *bm, size_t size); - /** * Sizes the bitmap to ensure it has at least the specified number of @@ -94,7 +83,7 @@ OMPI_DECLSPEC int orte_bitmap_resize(orte_bitmap_t *bm, size_t bit); * @return OMPI error code or success * */ -OMPI_DECLSPEC int orte_bitmap_set_bit(orte_bitmap_t *bm, size_t bit); +OMPI_DECLSPEC int orte_bitmap_set_bit(orte_bitmap_t *bm, size_t bit); /** @@ -130,8 +119,8 @@ OMPI_DECLSPEC int orte_bitmap_is_set_bit(orte_bitmap_t *bm, size_t bit); * @return err ORTE_SUCCESS on success */ -OMPI_DECLSPEC int orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm, - size_t *position); +OMPI_DECLSPEC int orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm, + size_t *position); /** @@ -139,7 +128,7 @@ OMPI_DECLSPEC int orte_bitmap_find_and_set_first_unset_bit(orte_bitmap_t *bm, * * @param bitmap The input bitmap (IN) * @return ORTE error code if bm is NULL - * + * */ OMPI_DECLSPEC int orte_bitmap_clear_all_bits(orte_bitmap_t *bm); @@ -169,5 +158,5 @@ static inline int orte_bitmap_size(orte_bitmap_t *bm) #if defined(c_plusplus) || defined(__cplusplus) } #endif - + #endif diff --git a/orte/mca/gpr/replica/gpr_replica_component.c b/orte/mca/gpr/replica/gpr_replica_component.c index 7d6cccbf2e..30396e3544 100644 --- a/orte/mca/gpr/replica/gpr_replica_component.c +++ b/orte/mca/gpr/replica/gpr_replica_component.c @@ -275,10 +275,7 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo } orte_gpr_replica_globals.num_acted_upon = 0; - if (ORTE_SUCCESS != (rc = orte_bitmap_init(&(orte_gpr_replica_globals.srch_itag), 64))) { - ORTE_ERROR_LOG(rc); - return NULL; - } + OBJ_CONSTRUCT(&(orte_gpr_replica_globals.srch_itag), orte_bitmap_t); if (orte_gpr_replica_globals.debug) { opal_output(0, "nb receive setup"); @@ -316,31 +313,50 @@ int orte_gpr_replica_finalize(void) size_t i, j; orte_gpr_replica_segment_t** seg; orte_gpr_replica_trigger_t** trig; + orte_gpr_replica_subscription_t** subs; orte_gpr_replica_callbacks_t* cb; + orte_gpr_replica_local_subscriber_t **lsubs; + orte_gpr_replica_local_trigger_t **ltrigs; if (orte_gpr_replica_globals.debug) { opal_output(0, "finalizing gpr replica"); } - seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr; - for (i=0, j=0; j < orte_gpr_replica.num_segs && - i < (orte_gpr_replica.segments)->size; i++) { - if (NULL != seg[i]) { - j++; - OBJ_RELEASE(seg[i]); - } + if (NULL != orte_gpr_replica.segments) { + seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr; + for (i=0, j=0; j < orte_gpr_replica.num_segs && + i < (orte_gpr_replica.segments)->size; i++) { + if (NULL != seg[i]) { + j++; + OBJ_RELEASE(seg[i]); + } + } + OBJ_RELEASE(orte_gpr_replica.segments); } - OBJ_RELEASE(orte_gpr_replica.segments); - trig = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr; - for (i=0, j=0; j < orte_gpr_replica.num_trigs && - i < (orte_gpr_replica.triggers)->size; i++) { - if (NULL != trig[i]) { - j++; - OBJ_RELEASE(trig[i]); - } + if (NULL != orte_gpr_replica.triggers) { + trig = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr; + for (i=0, j=0; j < orte_gpr_replica.num_trigs && + i < (orte_gpr_replica.triggers)->size; i++) { + if (NULL != trig[i]) { + j++; + OBJ_RELEASE(trig[i]); + } + } + OBJ_RELEASE(orte_gpr_replica.triggers); + } + + if (NULL != orte_gpr_replica.subscriptions) { + subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr; + for (i=0, j=0; j < orte_gpr_replica.num_subs && + i < (orte_gpr_replica.subscriptions)->size; i++) { + if (NULL != subs[i]) { + j++; + OBJ_RELEASE(subs[i]); + } + } + OBJ_RELEASE(orte_gpr_replica.subscriptions); } - OBJ_RELEASE(orte_gpr_replica.triggers); while (NULL != (cb = (orte_gpr_replica_callbacks_t*)opal_list_remove_first(&orte_gpr_replica.callbacks))) { OBJ_RELEASE(cb); @@ -348,6 +364,31 @@ int orte_gpr_replica_finalize(void) OBJ_DESTRUCT(&orte_gpr_replica.callbacks); + /* clear the local subscriptions and triggers */ + lsubs = (orte_gpr_replica_local_subscriber_t**)(orte_gpr_replica_globals.local_subscriptions)->addr; + if (NULL != orte_gpr_replica_globals.local_subscriptions) { + for (i=0, j=0; j < orte_gpr_replica_globals.num_local_subs && + i < (orte_gpr_replica_globals.local_subscriptions)->size; i++) { + if (NULL != lsubs[i]) { + j++; + OBJ_RELEASE(lsubs[i]); + } + } + OBJ_RELEASE(orte_gpr_replica_globals.local_subscriptions); + } + + ltrigs = (orte_gpr_replica_local_trigger_t**)(orte_gpr_replica_globals.local_triggers)->addr; + if (NULL != orte_gpr_replica_globals.local_triggers) { + for (i=0, j=0; j < orte_gpr_replica_globals.num_local_trigs && + i < (orte_gpr_replica_globals.local_triggers)->size; i++) { + if (NULL != ltrigs[i]) { + j++; + OBJ_RELEASE(ltrigs[i]); + } + } + OBJ_RELEASE(orte_gpr_replica_globals.local_triggers); + } + /* clean up the globals */ if (NULL != orte_gpr_replica_globals.srch_cptr) { @@ -358,6 +399,10 @@ int orte_gpr_replica_finalize(void) OBJ_RELEASE(orte_gpr_replica_globals.overwritten); } + if (NULL != orte_gpr_replica_globals.sub_ptrs) { + OBJ_RELEASE(orte_gpr_replica_globals.sub_ptrs); + } + if (NULL != orte_gpr_replica_globals.srch_ival) { OBJ_RELEASE(orte_gpr_replica_globals.srch_ival); } @@ -366,6 +411,8 @@ int orte_gpr_replica_finalize(void) OBJ_RELEASE(orte_gpr_replica_globals.acted_upon); } + OBJ_DESTRUCT(&(orte_gpr_replica_globals.srch_itag)); + /* All done */ if (orte_gpr_replica_globals.isolate) { return ORTE_SUCCESS; diff --git a/orte/mca/oob/tcp/oob_tcp.c b/orte/mca/oob/tcp/oob_tcp.c index dd79cbad8d..79c2122e3c 100644 --- a/orte/mca/oob/tcp/oob_tcp.c +++ b/orte/mca/oob/tcp/oob_tcp.c @@ -715,7 +715,7 @@ int mca_oob_tcp_init(void) int rc; opal_list_item_t* item; char *tmp, *tmp2, *tmp3; - size_t num_tokens; + size_t i, num_tokens; /* random delay to stagger connections back to seed */ #if defined(WIN32) @@ -860,6 +860,11 @@ int mca_oob_tcp_init(void) } free(segment); + for(i=0; i < num_tokens; i++) { + free(tokens[i]); + tokens[i] = NULL; + } + if (NULL != tokens) free(tokens); free(values[0].byteobject.bytes); free(values[1].strptr); @@ -951,7 +956,8 @@ char* mca_oob_tcp_get_addr(void) if(ptr != contact_info) { ptr += sprintf(ptr, ";"); } - ptr += sprintf(ptr, "tcp://%s:%d", inet_ntoa(addr.sin_addr), ntohs(mca_oob_tcp_component.tcp_listen_port)); + ptr += sprintf(ptr, "tcp://%s:%d", inet_ntoa(addr.sin_addr), + ntohs(mca_oob_tcp_component.tcp_listen_port)); } return contact_info; } diff --git a/orte/mca/rmgr/base/rmgr_base_stage_gate.c b/orte/mca/rmgr/base/rmgr_base_stage_gate.c index 8982457b21..2300bf8c7e 100644 --- a/orte/mca/rmgr/base/rmgr_base_stage_gate.c +++ b/orte/mca/rmgr/base/rmgr_base_stage_gate.c @@ -126,6 +126,8 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job) if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name, trig_names[i], job))) { ORTE_ERROR_LOG(rc); + free(tokens[0]); + free(segment); free(trig_keys[0]); free(trig_keys[1]); return rc; @@ -137,6 +139,8 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job) segment, tokens, 2, trig_keys, orte_rmgr_base_proc_stage_gate_mgr, NULL))) { ORTE_ERROR_LOG(rc); + free(tokens[0]); + free(segment); free(trig_name); free(trig_keys[0]); free(trig_keys[1]); @@ -155,6 +159,9 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job) if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name, ORTE_NUM_ABORTED_TRIGGER, job))) { ORTE_ERROR_LOG(rc); + free(tokens[0]); + free(segment); + free(trig_keys[0]); return rc; } trig_level = 1; @@ -165,10 +172,14 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job) segment, tokens, 1, trig_keys, &trig_level, orte_rmgr_base_proc_stage_gate_mgr_abort, NULL))) { ORTE_ERROR_LOG(rc); + free(tokens[0]); + free(segment); free(trig_name); free(trig_keys[0]); return rc; } + free(tokens[0]); + free(segment); free(trig_name); free(trig_keys[0]); diff --git a/orte/mca/sds/base/sds_base_universe.c b/orte/mca/sds/base/sds_base_universe.c index daf186482d..0bf9e980c1 100644 --- a/orte/mca/sds/base/sds_base_universe.c +++ b/orte/mca/sds/base/sds_base_universe.c @@ -95,8 +95,10 @@ orte_sds_base_basic_contact_universe(void) pid = getpid(); if (0 > asprintf(&orte_universe_info.name, "%s-%d", universe, (int)pid)) { opal_output(0, "orte_init: failed to create unique universe name"); + free(universe); return ret; } + free(universe); } else { /* user-specified name - abort */ opal_output(0, "orte_init: could not contact the specified universe name %s", orte_universe_info.name); diff --git a/orte/runtime/orte_init_stage1.c b/orte/runtime/orte_init_stage1.c index c81090f2a4..2ef790e24e 100644 --- a/orte/runtime/orte_init_stage1.c +++ b/orte/runtime/orte_init_stage1.c @@ -3,14 +3,14 @@ * All rights reserved. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * All rights reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ - * + * * Additional copyrights may follow - * + * * $HEADER$ */ @@ -86,7 +86,7 @@ int orte_init_stage1(bool infrastructure) if (ORTE_SUCCESS != (ret = orte_proc_info())) { return ret; } - + /* Ensure the universe_info structure is instantiated and initialized */ if (ORTE_SUCCESS != (ret = orte_univ_info())) { return ret; @@ -99,9 +99,9 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + /* - * Open the name services to ensure access to local functions + * Open the name services to ensure access to local functions */ if (OMPI_SUCCESS != (ret = orte_ns_base_open())) { return ret; @@ -111,9 +111,9 @@ int orte_init_stage1(bool infrastructure) if (ORTE_SUCCESS != (ret = orte_errmgr_base_open())) { return ret; } - + /***** ERROR LOGGING NOW AVAILABLE *****/ - + /* check for debug flag */ if (0 > (ret = mca_base_param_register_int("orte", "debug", NULL, NULL, 0))) { ORTE_ERROR_LOG(ret); @@ -125,7 +125,7 @@ int orte_init_stage1(bool infrastructure) } /* - * Initialize the event library + * Initialize the event library */ if (OMPI_SUCCESS != (ret = opal_event_init())) { ORTE_ERROR_LOG(ret); @@ -199,7 +199,7 @@ int orte_init_stage1(bool infrastructure) } /* - * Name Server + * Name Server */ if (OMPI_SUCCESS != (ret = orte_ns_base_select())) { ORTE_ERROR_LOG(ret); @@ -207,13 +207,13 @@ int orte_init_stage1(bool infrastructure) } /* - * Registry + * Registry */ if (ORTE_SUCCESS != (ret = orte_gpr_base_select())) { ORTE_ERROR_LOG(ret); return ret; } - + /* set contact info for ns/gpr */ if(NULL != orte_process_info.ns_replica_uri) { orte_rml.set_uri(orte_process_info.ns_replica_uri); @@ -235,7 +235,7 @@ int orte_init_stage1(bool infrastructure) if (orte_process_info.seed) { orte_universe_info.seed_uri = orte_rml.get_uri(); } - + /* setup my session directory */ if (ORTE_SUCCESS != (ret = orte_ns.get_jobid_string(&jobid_str, orte_process_info.my_name))) { ORTE_ERROR_LOG(ret); @@ -245,7 +245,7 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + if (orte_debug_flag) { opal_output(0, "[%lu,%lu,%lu] setting up session dir with", ORTE_NAME_ARGS(orte_process_info.my_name)); @@ -303,8 +303,8 @@ int orte_init_stage1(bool infrastructure) free(contact_path); } - /* - * setup the resource manager + /* + * setup the resource manager */ if (ORTE_SUCCESS != (ret = orte_rmgr_base_open())) { @@ -316,7 +316,7 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + /* * setup the state-of-health monitor */ @@ -329,9 +329,9 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + /* if we are a singleton or the seed, setup the infrastructure for our job */ - + if(orte_process_info.singleton || orte_process_info.seed) { char *site, *resource; @@ -339,7 +339,7 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + /* If there is no existing cellid, create one */ my_cellid = 0; /* JJH Assertion/Repair until cellid's are fixed */ ret = orte_ns.get_cell_info(my_cellid, &site, &resource); @@ -350,7 +350,7 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + if(my_cellid != 0) { /* JJH Assertion/Repair until cellid's are fixed */ my_cellid = 0; } @@ -359,7 +359,7 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + if (ORTE_SUCCESS != (ret = orte_ns.get_cellid(&my_cellid, orte_process_info.my_name))) { ORTE_ERROR_LOG(ret); return ret; @@ -372,7 +372,7 @@ int orte_init_stage1(bool infrastructure) * really know that info for a singleton, we make the assumption * that the allocation is unity and place a structure on the * registry for it - * + * * THIS ONLY SHOULD BE DONE FOR SINGLETONS - DO NOT DO IT * FOR ANY OTHER CASE */ @@ -389,11 +389,11 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } - + rds_item->site = strdup("Singleton"); rds_item->name = strdup(orte_system_info.nodename); rds_item->cellid = my_cellid; - + /* Set up data structure for RAS item */ ras_item->node_name = strdup(rds_item->name); ras_item->node_arch = strdup("unknown"); @@ -413,7 +413,7 @@ int orte_init_stage1(bool infrastructure) new_attr->keyval.type = ORTE_STRING; new_attr->keyval.value.strptr = strdup(ras_item->node_name); opal_list_append(&(rds_item->attributes), &new_attr->super); - + new_attr = OBJ_NEW(orte_rds_cell_attr_t); if (NULL == new_attr) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); @@ -423,7 +423,7 @@ int orte_init_stage1(bool infrastructure) new_attr->keyval.type = ORTE_CELLID; new_attr->keyval.value.cellid = rds_item->cellid; opal_list_append(&(rds_item->attributes), &new_attr->super); - + opal_list_append(&rds_single_host, &rds_item->super); /* Store into registry */ @@ -438,11 +438,11 @@ int orte_init_stage1(bool infrastructure) ORTE_ERROR_LOG(ret); return ret; } - + OBJ_DESTRUCT(&single_host); OBJ_DESTRUCT(&rds_single_host); } - + /* set the rest of the infrastructure */ if (ORTE_SUCCESS != (ret = orte_rmgr_base_set_job_slots(my_jobid,1))) { ORTE_ERROR_LOG(ret); @@ -554,7 +554,7 @@ orte_err2str(int errnum) case ORTE_ERR_TYPE_MISMATCH: retval = "Type mismatch"; break; - default: + default: retval = NULL; } diff --git a/test/dps/dps_test.c b/test/dps/dps_test.c index 4c628dff0d..d3be9fbfe9 100644 --- a/test/dps/dps_test.c +++ b/test/dps/dps_test.c @@ -3,14 +3,14 @@ * All rights reserved. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * All rights reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ - * + * * Additional copyrights may follow - * + * * $HEADER$ */ @@ -79,9 +79,9 @@ int main (int argc, char* argv[]) test_init("orte_dps"); test_out = stderr; - - /* + + /* * If threads are supported - assume that we are using threads - * and reset otherwise. */ @@ -139,7 +139,7 @@ int main (int argc, char* argv[]) } /* run the tests */ - + fprintf(test_out, "executing test1\n"); if (test1()) { test_success(); @@ -293,14 +293,14 @@ int main (int argc, char* argv[]) static bool test1(void) /* verify different buffer inits */ { orte_buffer_t *bufA; - + bufA = OBJ_NEW(orte_buffer_t); if (NULL == bufA) { test_comment("orte_buffer failed init in OBJ_NEW"); fprintf(test_out, "OBJ_NEW failed\n"); return false; } - + OBJ_RELEASE(bufA); if (NULL != bufA) { test_comment("OBJ_RELEASE did not NULL the buffer pointer"); @@ -313,7 +313,7 @@ static bool test1(void) /* verify different buffer inits */ /* * OMPI_INT16 pack/unpack */ -static bool test2(void) +static bool test2(void) { orte_buffer_t *bufA; int rc; @@ -330,7 +330,7 @@ static bool test2(void) fprintf(test_out, "OBJ_NEW failed\n"); return false; } - + for (i=0;ikeyvals = (orte_gpr_keyval_t**)malloc(src[i]->cnt * sizeof(orte_gpr_keyval_t*)); for (j=0; j < src[i]->cnt; j++) { src[i]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t); - asprintf(&((src[i]->keyvals[j])->key), "%lu", + asprintf(&((src[i]->keyvals[j])->key), "%lu", (unsigned long) j); (src[i]->keyvals[j])->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32; if (ORTE_INT16 == (src[i]->keyvals[j])->type) @@ -1170,7 +1170,7 @@ static bool test10(void) fprintf(test_out, "OBJ_NEW failed\n"); return false; } - + for (i=0;iidx = i; + src[i]->idx = i; src[i]->app = strdup("test-application-name"); - src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */ + src[i]->num_procs = i; /* test between 0 and NUM_ELEMS-1 proc counts */ - /* test arg counts of 1 to NUM_ELEMS+1 */ - src[i]->argc = i+1; - if (src[i]->argc) { /* if to allow testing of argv count of zero */ - src[i]->argv = (char**)malloc(src[i]->argc * sizeof(char*)); - for (n=0; n < src[i]->argc; n++) { - src[i]->argv[n] = strdup("test-argv"); - } - } + /* test arg counts of 1 to NUM_ELEMS+1 */ + src[i]->argc = i+1; + if (src[i]->argc) { /* if to allow testing of argv count of zero */ + src[i]->argv = (char**)malloc(src[i]->argc * sizeof(char*)); + for (n=0; n < src[i]->argc; n++) { + src[i]->argv[n] = strdup("test-argv"); + } + } - /* test env counts of 1 to NUM_ELEMS+1 */ - src[i]->num_env = i+1; - if (src[i]->num_env) { /* if to allow testing of num_env count of zero */ - src[i]->env = (char**)malloc(src[i]->num_env * sizeof(char*)); - for (j=0; j < src[i]->num_env; j++) { - src[i]->env[j] = strdup("test-env"); - } - } + /* test env counts of 1 to NUM_ELEMS+1 */ + src[i]->num_env = i+1; + if (src[i]->num_env) { /* if to allow testing of num_env count of zero */ + src[i]->env = (char**)malloc(src[i]->num_env * sizeof(char*)); + for (j=0; j < src[i]->num_env; j++) { + src[i]->env[j] = strdup("test-env"); + } + } - src[i]->cwd = strdup ("test-cwd"); + src[i]->cwd = strdup ("test-cwd"); - /* test imap data for map count = num_procs */ - src[i]->num_map = i+1; - if (src[i]->num_map) { /* if to allow testing of map count of zero */ - src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */ - for (j=0; j < src[i]->num_map; j++) { - src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */ - src[i]->map_data[j]->map_type = (uint8_t) j; - src[i]->map_data[j]->map_data = strdup("test-map-data"); - } - } - } + /* test imap data for map count = num_procs */ + src[i]->num_map = i+1; + if (src[i]->num_map) { /* if to allow testing of map count of zero */ + src[i]->map_data = (orte_app_context_map_t**)malloc(src[i]->num_map * sizeof(orte_app_context_map_t *)); /* map data type */ + for (j=0; j < src[i]->num_map; j++) { + src[i]->map_data[j] = OBJ_NEW(orte_app_context_map_t); /* assume we create with new rather than malloc? */ + src[i]->map_data[j]->map_type = (uint8_t) j; + src[i]->map_data[j]->map_data = strdup("test-map-data"); + } + } + } - /* source data set, now create buffer and pack source data */ + /* source data set, now create buffer and pack source data */ bufA = OBJ_NEW(orte_buffer_t); if (NULL == bufA) { @@ -1369,9 +1369,9 @@ static bool test12(void) /* fprintf(test_out,"New buffer ready\n"); */ /* fflush(test_out); */ -/* orte_dps_dump_buffer_simple (bufA, 0); */ +/* orte_dps_dump_buffer_simple (bufA, 0); */ + - for (i=0;iidx != dst[j]->idx || - 0 != strcmp(src[j]->app, dst[j]->app) || + if ( + src[j]->idx != dst[j]->idx || + 0 != strcmp(src[j]->app, dst[j]->app) || src[j]->num_procs != dst[j]->num_procs || src[j]->argc != dst[j]->argc || src[j]->num_env != dst[j]->num_env || - 0 != strcmp(src[j]->cwd, dst[j]->cwd) || - src[j]->num_map != dst[j]->num_map - ) { + 0 != strcmp(src[j]->cwd, dst[j]->cwd) || + src[j]->num_map != dst[j]->num_map + ) { test_comment ("test12: invalid results from unpack"); return(false); } - /* now compare each of the size/cnt depedant values */ + /* now compare each of the size/cnt depedant values */ for (n=0; nargc; n++) { if (0 != strcmp(src[j]->argv[n], dst[j]->argv[n])) { test_comment ("test12: invalid results (argv) from unpack"); @@ -1442,7 +1442,7 @@ static bool test12(void) } } } - + OBJ_RELEASE(bufA); if (NULL != bufA) { test_comment("OBJ_RELEASE did not NULL the buffer pointer"); @@ -1468,40 +1468,40 @@ static bool test13(void) src[i]->name = strdup("dummy-name"); } src[i]->id = (orte_gpr_subscription_id_t)i; - + /* test value counts of 1 to NUM_ELEMS+1 */ src[i]->cnt = i + 1; src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*)); - + for (k=0; k < src[i]->cnt; k++) { src[i]->values[k] = OBJ_NEW(orte_gpr_value_t); src[i]->values[k]->addr_mode = (uint16_t) i; src[i]->values[k]->segment = strdup("test-segment"); - - /* test token counts of 0! to NUM_ELEMS */ - src[i]->values[k]->num_tokens = i; - if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */ - src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*)); - for (j=0; j < src[i]->values[k]->num_tokens; j++) { - src[i]->values[k]->tokens[j] = strdup("test-token"); - } - } - /* test key counts of 0 to NUM_ELEMS */ - src[i]->values[k]->cnt = i; - if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */ - src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc( + /* test token counts of 0! to NUM_ELEMS */ + src[i]->values[k]->num_tokens = i; + if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */ + src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*)); + for (j=0; j < src[i]->values[k]->num_tokens; j++) { + src[i]->values[k]->tokens[j] = strdup("test-token"); + } + } + + /* test key counts of 0 to NUM_ELEMS */ + src[i]->values[k]->cnt = i; + if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */ + src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc( src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*)); - for (j=0; j < src[i]->values[k]->cnt; j++) { + for (j=0; j < src[i]->values[k]->cnt; j++) { src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t); - src[i]->values[k]->keyvals[j]->key = strdup("test-key"); - } - } + src[i]->values[k]->keyvals[j]->key = strdup("test-key"); + } + } /* skip the pointers for cb_func and user_tag */ } - } + } - /* source data set, now create buffer and pack source data */ + /* source data set, now create buffer and pack source data */ bufA = OBJ_NEW(orte_buffer_t); if (NULL == bufA) { @@ -1510,7 +1510,7 @@ static bool test13(void) return false; } - + for (i=0;iname && 0 != strcmp(src[j]->name, dst[j]->name)) || src[j]->id != dst[j]->id || src[j]->cnt != dst[j]->cnt - ) { + ) { test_comment ("test13: invalid results from unpack"); return(false); } - /* now compare each of the size/cnt dependent values */ + /* now compare each of the size/cnt dependent values */ for (k=0; kcnt; k++) { if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) { test_comment ("test13: invalid results (value num_tokens) from unpack"); return(false); } - + for (m=0; m < src[j]->values[k]->num_tokens; m++) { if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) { test_comment ("test13: invalid results (tokens) from unpack"); @@ -1568,7 +1568,7 @@ static bool test13(void) test_comment ("test13: invalid results (value cnt) from unpack"); return(false); } - + for (m=0; m < src[j]->values[k]->cnt; m++) { if (0 != strcmp(src[j]->values[k]->keyvals[m]->key, dst[j]->values[k]->keyvals[m]->key)) { @@ -1579,7 +1579,7 @@ static bool test13(void) } } } - + OBJ_RELEASE(bufA); if (NULL != bufA) { test_comment("OBJ_RELEASE did not NULL the buffer pointer"); @@ -1603,46 +1603,46 @@ static bool test14(void) for(i=0; iname = strdup("test-notify-data-name"); + src[i]->target = strdup("test-notify-data-name"); src[i]->remove = true; } - src[i]->id = i; + src[i]->id = i; - /* test value counts of 0 to NUM_ELEMS-1 */ - src[i]->cnt = i; /* value count */ + /* test value counts of 0 to NUM_ELEMS-1 */ + src[i]->cnt = i; /* value count */ - for (j=0; j < src[i]->cnt; j++) { - value = OBJ_NEW(orte_gpr_value_t); - value->addr_mode = (orte_gpr_addr_mode_t) i+j+1; - value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */ + for (j=0; j < src[i]->cnt; j++) { + value = OBJ_NEW(orte_gpr_value_t); + value->addr_mode = (orte_gpr_addr_mode_t) i+j+1; + value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */ - /* tokens */ - value->num_tokens = j; /* test tokens within gpr values within notify message between 0-NUM_ELEMS-1 */ - if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */ - value->tokens = (char**)malloc(value->num_tokens * sizeof(char*)); - for (k=0; k < value->num_tokens; k++) { - value->tokens[k] = strdup("test-grp-notify-value-token"); - } /* for each token */ - } /* if tokens */ + /* tokens */ + value->num_tokens = j; /* test tokens within gpr values within notify message between 0-NUM_ELEMS-1 */ + if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */ + value->tokens = (char**)malloc(value->num_tokens * sizeof(char*)); + for (k=0; k < value->num_tokens; k++) { + value->tokens[k] = strdup("test-grp-notify-value-token"); + } /* for each token */ + } /* if tokens */ + + /* keyval pairs (field name is 'cnt' same as used for value count so be carefull) */ + value->cnt = j; /* test keyval pairs within gpr values within notify message between 0-NUM_ELEMS-1 */ + if (value->cnt) { /* if to allow testing of keyval pair count of zero */ + value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*)); + for (k=0; k < value->cnt; k++) { + value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t); + value->keyvals[k]->key = strdup("test-grp-notify-value-key"); + value->keyvals[k]->type = ORTE_INT32; /* make it simplier */ + value->keyvals[k]->value.i32 = (uint32_t) (i*100)+(j*10)+k; /* something variable */ + } /* for each keyval pair */ + } /* if keyvals */ - /* keyval pairs (field name is 'cnt' same as used for value count so be carefull) */ - value->cnt = j; /* test keyval pairs within gpr values within notify message between 0-NUM_ELEMS-1 */ - if (value->cnt) { /* if to allow testing of keyval pair count of zero */ - value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*)); - for (k=0; k < value->cnt; k++) { - value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t); - value->keyvals[k]->key = strdup("test-grp-notify-value-key"); - value->keyvals[k]->type = ORTE_INT32; /* make it simplier */ - value->keyvals[k]->value.i32 = (uint32_t) (i*100)+(j*10)+k; /* something variable */ - } /* for each keyval pair */ - } /* if keyvals */ - /* add the value to the data object */ orte_pointer_array_add(&k, src[i]->values, value); - } /* for each value */ + } /* for each value */ } - /* source data set, now create buffer and pack source data */ + /* source data set, now create buffer and pack source data */ bufA = OBJ_NEW(orte_buffer_t); if (NULL == bufA) { @@ -1651,7 +1651,7 @@ static bool test14(void) return false; } - + for (i=0;iid != dst[j]->id || src[j]->cnt != dst[j]->cnt || src[j]->remove != dst[j]->remove - ) { + ) { test_comment ("test14: invalid results from unpack"); return(false); } - if ((NULL == src[j]->name && NULL != dst[j]->name) || - (NULL != src[j]->name && NULL == dst[j]->name)) { + if ((NULL == src[j]->target && NULL != dst[j]->target) || + (NULL != src[j]->target && NULL == dst[j]->target)) { test_comment ("orte_dps.pack failed"); fprintf(test_out, "test14 (ORTE_GPR_NOTIFY_DATA) failed with mismatched names"); return(false); } - if (NULL != src[j]->name && NULL != dst[j]->name && - 0 != strcmp(src[j]->name, dst[j]->name)) { + if (NULL != src[j]->target && NULL != dst[j]->target && + 0 != strcmp(src[j]->target, dst[j]->target)) { test_comment ("orte_dps.pack failed"); fprintf(test_out, "test14 (ORTE_GPR_NOTIFY_DATA) failed with mismatched names"); return(false); } - /* now compare each value of the cnt depedant values */ + /* now compare each value of the cnt depedant values */ sval = (orte_gpr_value_t**)(src[j]->values)->addr; dval = (orte_gpr_value_t**)(dst[j]->values)->addr; /* because of the way this has been done, we can safely assume @@ -1708,52 +1708,52 @@ static bool test14(void) k < (src[j]->values)->size; k++) { if (NULL != sval[k]) { n++; - - if (sval[k]->addr_mode != dval[k]->addr_mode) { + + if (sval[k]->addr_mode != dval[k]->addr_mode) { test_comment ("test14: invalid results (values-addr-mode) from unpack"); return(false); - } + } if (0 != strcmp(sval[k]->segment, dval[k]->segment)) { test_comment ("test14: invalid results (values-segment) from unpack"); return(false); } - if (sval[k]->num_tokens != dval[k]->num_tokens) { + if (sval[k]->num_tokens != dval[k]->num_tokens) { test_comment ("test14: invalid results (values-num_tokens) from unpack"); return(false); - } - for (l=0; lnum_tokens; l++) { - if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) { - test_comment ("test14: invalid results (values-tokens) from unpack"); - return(false); - } - } /* for each token inside each grp value */ + } + for (l=0; lnum_tokens; l++) { + if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) { + test_comment ("test14: invalid results (values-tokens) from unpack"); + return(false); + } + } /* for each token inside each grp value */ - if (sval[k]->cnt != dval[k]->cnt) { + if (sval[k]->cnt != dval[k]->cnt) { test_comment ("test14: invalid results (values-cnt (of keyval pairs)) from unpack"); return(false); - } - for (l=0; l< sval[k]->cnt; l++) { - if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) { - test_comment ("test14: invalid results (values-keyvals-key) from unpack"); - return(false); - } - if (sval[k]->keyvals[l]->type != dval[k]->keyvals[l]->type) { - test_comment ("test14: invalid results (values-keyvals-type) from unpack"); - return(false); - } - if (sval[k]->keyvals[l]->value.i32 != dval[k]->keyvals[l]->value.i32) { - test_comment ("test14: invalid results (values-keyvals-value.i32) from unpack"); - return(false); - } - }/* for each keyvalpair inside each grp value */ + } + for (l=0; l< sval[k]->cnt; l++) { + if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) { + test_comment ("test14: invalid results (values-keyvals-key) from unpack"); + return(false); + } + if (sval[k]->keyvals[l]->type != dval[k]->keyvals[l]->type) { + test_comment ("test14: invalid results (values-keyvals-type) from unpack"); + return(false); + } + if (sval[k]->keyvals[l]->value.i32 != dval[k]->keyvals[l]->value.i32) { + test_comment ("test14: invalid results (values-keyvals-value.i32) from unpack"); + return(false); + } + }/* for each keyvalpair inside each grp value */ } /* for each grp value */ } } /* for each ELEMENT */ } - + OBJ_RELEASE(bufA); if (NULL != bufA) { test_comment("OBJ_RELEASE did not NULL the buffer pointer"); @@ -1768,7 +1768,7 @@ static bool test14(void) /* * pid_t pack/unpack */ -static bool test15(void) +static bool test15(void) { orte_buffer_t *bufA; int rc; @@ -1785,7 +1785,7 @@ static bool test15(void) fprintf(test_out, "OBJ_NEW failed\n"); return false; } - + for (i=0;i