diff --git a/etc/lanl_resources.xml b/etc/lanl_resources.xml index a5dd94449b..17d34ac7ae 100644 --- a/etc/lanl_resources.xml +++ b/etc/lanl_resources.xml @@ -8,8 +8,11 @@ pfe1.lanl.gov /net/scratch1 + true - pfe2.lanl.gov + + pfe2.lanl.gov + 1 1024 @@ -34,7 +37,7 @@ lsf bproc - + 2 xeon intel @@ -43,7 +46,7 @@ myrinet 1.0 - + @@ -52,26 +55,32 @@ ll-1.lanl.gov /net/scratch1 + true ll-2.lanl.gov /net/scratch1 + true ll-3.lanl.gov /net/scratch1 + true ll-4.lanl.gov /net/scratch1 + true ll-5.lanl.gov /net/scratch1 + true ll-6.lanl.gov /net/scratch1 + true linux @@ -97,7 +106,7 @@ lsf bproc - + 2> opteron amd @@ -106,7 +115,7 @@ myrinet 2.0 - + @@ -115,8 +124,10 @@ ffe1.lanl.gov /net/scratch1 + true - ffe2.lanl.gov + + ffe2.lanl.gov /net/scratch1 @@ -160,6 +171,7 @@ cluster qafe.lanl.gov + true lsf rms @@ -200,6 +212,7 @@ cluster qbfe.lanl.gov + true lsf rms @@ -241,6 +254,7 @@ cfe1.lanl.gov /scratch1 + true lsf lsf @@ -279,6 +293,7 @@ cfe1.lanl.gov /scratch1 + true lsf lsf @@ -317,6 +332,7 @@ cfe1.lanl.gov /scratch1 + true lsf lsf @@ -355,6 +371,7 @@ lambda.lanl.gov /scratch + true lsf bproc @@ -388,6 +405,7 @@ cluster qscfe1.lanl.gov + true lsf lsf @@ -425,6 +443,7 @@ cxfe.lanl.gov /scratch1 + true lsf lsf @@ -432,14 +451,14 @@ 32 4 4.0 - + cx0 16.0 - - + + cx1 16.0 - + quadrics 1 @@ -470,6 +489,7 @@ mauve.lanl.gov /scratch + true lsf lsf @@ -493,4 +513,4 @@ - \ No newline at end of file + diff --git a/src/include/orte_constants.h b/src/include/orte_constants.h index 634d7bcee2..37e8c7cc83 100644 --- a/src/include/orte_constants.h +++ b/src/include/orte_constants.h @@ -71,7 +71,9 @@ enum { ORTE_ERR_GPR_DATA_CORRUPT = -44, ORTE_ERR_PERM = -45, /* no permission */ ORTE_ERR_TYPE_MISMATCH = -46, - ORTE_ERR_VALUE_OUT_OF_BOUNDS = -47 + ORTE_ERR_VALUE_OUT_OF_BOUNDS = -47, + ORTE_ERR_FILE_READ_FAILURE = -48, + ORTE_ERR_FILE_WRITE_FAILURE = -49 }; #endif /* ORTE_CONSTANTS_H */ diff --git a/src/mca/gpr/base/Makefile.am b/src/mca/gpr/base/Makefile.am index 235a0ebc1b..70c986b0bc 100644 --- a/src/mca/gpr/base/Makefile.am +++ b/src/mca/gpr/base/Makefile.am @@ -33,7 +33,8 @@ libmca_gpr_base_la_SOURCES = \ $(headers) \ gpr_base_open.c \ gpr_base_close.c \ - gpr_base_select.c + gpr_base_select.c \ + gpr_base_xfer_payload.c # Conditionally install the header files diff --git a/src/mca/gpr/base/base.h b/src/mca/gpr/base/base.h index 11765edbd6..dcd0d7b718 100644 --- a/src/mca/gpr/base/base.h +++ b/src/mca/gpr/base/base.h @@ -212,6 +212,11 @@ int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest, size_t *num_vals, orte_data_type_t type); +/* general utilities */ +int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest, + orte_gpr_value_union_t *src, + orte_data_type_t type); + /* * globals that might be needed inside the gpr */ diff --git a/src/mca/gpr/base/gpr_base_xfer_payload.c b/src/mca/gpr/base/gpr_base_xfer_payload.c new file mode 100644 index 0000000000..77680dc4e9 --- /dev/null +++ b/src/mca/gpr/base/gpr_base_xfer_payload.c @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * 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, + * 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$ + */ + +#include "orte_config.h" +#include "include/orte_constants.h" +#include "include/constants.h" + +#include "util/argv.h" +#include "util/output.h" + +#include "mca/errmgr/errmgr.h" + +#include "mca/gpr/base/base.h" + + +int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest, + orte_gpr_value_union_t *src, + orte_data_type_t type) +{ + size_t i; + + switch(type) { + + case ORTE_BOOL: + dest->tf_flag = src->tf_flag; + break; + + case ORTE_SIZE: + dest->size = src->size; + break; + + case ORTE_PID: + dest->pid = src->pid; + break; + + case ORTE_STRING: + dest->strptr = strdup(src->strptr); + if (NULL == dest->strptr) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + break; + + case ORTE_UINT8: + dest->ui8 = src->ui8; + break; + + case ORTE_UINT16: + dest->ui16 = src->ui16; + break; + + case ORTE_UINT32: + dest->ui32 = src->ui32; + break; + +#ifdef HAVE_INT64_T + case ORTE_UINT64: + dest->ui64 = src->ui64; + break; +#endif + + case ORTE_INT8: + dest->i8 = src->i8; + break; + + case ORTE_INT16: + dest->i16 = src->i16; + break; + + case ORTE_INT32: + dest->i32 = src->i32; + break; + +#ifdef HAVE_INT64_T + case ORTE_INT64: + dest->i64 = src->i64; + break; +#endif + + case ORTE_NAME: + dest->proc = src->proc;; + break; + + case ORTE_JOBID: + dest->jobid = src->jobid; + break; + + case ORTE_CELLID: + dest->cellid = src->cellid; + break; + + case ORTE_VPID: + dest->vpid = src->vpid; + break; + + case ORTE_NODE_STATE: + dest->node_state = src->node_state; + break; + + case ORTE_PROC_STATE: + dest->proc_state = src->proc_state; + break; + + case ORTE_EXIT_CODE: + dest->exit_code = src->exit_code; + break; + + case ORTE_BYTE_OBJECT: + (dest->byteobject).size = (src->byteobject).size; + (dest->byteobject).bytes = (uint8_t*)malloc((dest->byteobject).size); + if (NULL == (dest->byteobject).bytes) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + memcpy((dest->byteobject).bytes, (src->byteobject).bytes, (dest->byteobject).size); + break; + + case ORTE_APP_CONTEXT: + if(NULL == src->app_context) { + dest->app_context = NULL; + break; + } + dest->app_context = OBJ_NEW(orte_app_context_t); + dest->app_context->idx = src->app_context->idx; + if(NULL != src->app_context->app) { + dest->app_context->app = strdup(src->app_context->app); + } else { + dest->app_context->app = NULL; + } + dest->app_context->num_procs = src->app_context->num_procs; + dest->app_context->argc = src->app_context->argc; + dest->app_context->argv = ompi_argv_copy(src->app_context->argv); + dest->app_context->num_env = src->app_context->num_env; + dest->app_context->env = ompi_argv_copy(src->app_context->env); + if(NULL != src->app_context->cwd) { + dest->app_context->cwd = strdup(src->app_context->cwd); + } else { + dest->app_context->cwd = NULL; + } + dest->app_context->num_map = src->app_context->num_map; + if (NULL != src->app_context->map_data) { + dest->app_context->map_data = (orte_app_context_map_t **) malloc(sizeof(orte_app_context_map_t *) * src->app_context->num_map); + for (i = 0; i < src->app_context->num_map; ++i) { + dest->app_context->map_data[i] = + OBJ_NEW(orte_app_context_map_t); + dest->app_context->map_data[i]->map_type = + src->app_context->map_data[i]->map_type; + dest->app_context->map_data[i]->map_data = + strdup(src->app_context->map_data[i]->map_data); + } + } else { + dest->app_context->map_data = NULL; + } + break; + + case ORTE_NULL: + break; + + default: + return ORTE_ERR_BAD_PARAM; + break; + } + return ORTE_SUCCESS; +} diff --git a/src/mca/gpr/gpr.h b/src/mca/gpr/gpr.h index 90a93f3524..1b7f99557c 100644 --- a/src/mca/gpr/gpr.h +++ b/src/mca/gpr/gpr.h @@ -512,6 +512,21 @@ typedef int (*orte_gpr_base_module_increment_value_fn_t)(orte_gpr_value_t *value typedef int (*orte_gpr_base_module_decrement_value_fn_t)(orte_gpr_value_t *value); +/* Transfer a payload between keyval values + * Because the data type of the value dictates how it must be transferred, it can be + * a burden to transfer the payload. This function centralizes that action so it only + * need be defined once. + * + * @param dest The address of the value union where the data is to be placed. + * @param src The address of the value union currently holding the data. + * @param type The type of the data + * + * @retval ORTE_SUCCESS Operation successfully completed. + * @retval ORTE_ERROR(s) Operation failed, returning the provided error code. + */ +typedef int (*orte_gpr_base_module_xfer_payload_fn_t)(orte_gpr_value_union_t *dest, + orte_gpr_value_union_t *src, orte_data_type_t type); + /* * Ver 1.0.0 */ @@ -532,6 +547,7 @@ struct orte_gpr_base_module_1_0_0_t { orte_gpr_base_module_index_nb_fn_t index_nb; /* GENERAL OPERATIONS */ orte_gpr_base_module_preallocate_segment_fn_t preallocate_segment; + orte_gpr_base_module_xfer_payload_fn_t xfer_payload; /* ARITHMETIC OPERATIONS */ orte_gpr_base_module_increment_value_fn_t increment_value; orte_gpr_base_module_decrement_value_fn_t decrement_value; diff --git a/src/mca/gpr/gpr_types.h b/src/mca/gpr/gpr_types.h index 68fc2a17f5..72ba9053c3 100644 --- a/src/mca/gpr/gpr_types.h +++ b/src/mca/gpr/gpr_types.h @@ -134,6 +134,7 @@ typedef uint16_t orte_gpr_addr_mode_t; typedef union { /* shared storage for the value */ char *strptr; size_t size; + bool tf_flag; pid_t pid; uint8_t ui8; uint16_t ui16; diff --git a/src/mca/gpr/proxy/gpr_proxy_component.c b/src/mca/gpr/proxy/gpr_proxy_component.c index 9c6fc94241..0459de080b 100644 --- a/src/mca/gpr/proxy/gpr_proxy_component.c +++ b/src/mca/gpr/proxy/gpr_proxy_component.c @@ -81,6 +81,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = { orte_gpr_proxy_index_nb, /* GENERAL OPERATIONS */ orte_gpr_proxy_preallocate_segment, + orte_gpr_base_xfer_payload, /* ARITHMETIC OPERATIONS */ orte_gpr_proxy_increment_value, orte_gpr_proxy_decrement_value, diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_dict_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_dict_fn.c index dcf5dac743..ae5dfd7e07 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_dict_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_dict_fn.c @@ -42,7 +42,7 @@ bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t addr_mode, size_t i, j; /* check for trivial case */ - if (NULL == itags || 0 >= num_itags_search) { /* wildcard case - automatically true */ + if (NULL == itags || 0 == num_itags_search) { /* wildcard case - automatically true */ return true; } diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_dump_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_dump_fn.c index 6f61bb34e0..280bc0a0f1 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_dump_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_dump_fn.c @@ -482,7 +482,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer, break; case ORTE_BOOL: - sprintf(tmp, "\t\tData type: ORTE_BOOL"); + sprintf(tmp, "\t\tData type: ORTE_BOOL\tValue: %s", iptr->value.tf_flag ? "TRUE" : "FALSE"); break; case ORTE_STRING: diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_fn.h b/src/mca/gpr/replica/functional_layer/gpr_replica_fn.h index 9ffd623205..882ccae731 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_fn.h +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_fn.h @@ -200,10 +200,6 @@ typedef int (*orte_gpr_replica_update_keyval_fn_t) orte_gpr_replica_container_t *cptr, orte_gpr_keyval_t *kptr); -int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest, - orte_gpr_value_union_t *src, - orte_data_type_t type); - int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1, orte_gpr_replica_itagval_t *ival2); diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_messaging_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_messaging_fn.c index 8ea2976e64..cc046d3cd4 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_messaging_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_messaging_fn.c @@ -459,7 +459,7 @@ MOVEON: return ORTE_ERR_OUT_OF_RESOURCE; } kptr[n]->type = (values[i]->keyvals[n])->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload( + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload( &(kptr[n]->value), &((values[i]->keyvals[n])->value), (values[i]->keyvals[n])->type))) { ORTE_ERROR_LOG(rc); diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_put_get_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_put_get_fn.c index eeec1e088e..71989c9711 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_put_get_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_put_get_fn.c @@ -335,7 +335,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode, ival_list = OBJ_NEW(orte_gpr_replica_ival_list_t); ival_list->itag = iptr[j]->itag; ival_list->type = iptr[j]->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload( + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload( &(ival_list->value), &(iptr[j]->value), iptr[j]->type))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(ival_list); @@ -411,7 +411,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode, goto CLEANUP; } kptr[j]->type = ival_list->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload( + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload( &(kptr[j]->value), &(ival_list->value), ival_list->type))) { goto CLEANUP; } diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_segment_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_segment_fn.c index 3f6f7459db..e21101312c 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_segment_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_segment_fn.c @@ -142,7 +142,7 @@ int orte_gpr_replica_add_keyval(orte_gpr_replica_itagval_t **ivalptr, } iptr->type = kptr->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload(&(iptr->value), + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(&(iptr->value), &(kptr->value), kptr->type))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(iptr); @@ -369,152 +369,6 @@ int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival) } -int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest, - orte_gpr_value_union_t *src, - orte_data_type_t type) -{ - size_t i; - - switch(type) { - - case ORTE_SIZE: - dest->size = src->size; - break; - - case ORTE_PID: - dest->pid = src->pid; - break; - - case ORTE_STRING: - dest->strptr = strdup(src->strptr); - if (NULL == dest->strptr) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - break; - - case ORTE_UINT8: - dest->ui8 = src->ui8; - break; - - case ORTE_UINT16: - dest->ui16 = src->ui16; - break; - - case ORTE_UINT32: - dest->ui32 = src->ui32; - break; - -#ifdef HAVE_INT64_T - case ORTE_UINT64: - dest->ui64 = src->ui64; - break; -#endif - - case ORTE_INT8: - dest->i8 = src->i8; - break; - - case ORTE_INT16: - dest->i16 = src->i16; - break; - - case ORTE_INT32: - dest->i32 = src->i32; - break; - -#ifdef HAVE_INT64_T - case ORTE_INT64: - dest->i64 = src->i64; - break; -#endif - - case ORTE_NAME: - dest->proc = src->proc;; - break; - - case ORTE_JOBID: - dest->jobid = src->jobid; - break; - - case ORTE_CELLID: - dest->cellid = src->cellid; - break; - - case ORTE_VPID: - dest->vpid = src->vpid; - break; - - case ORTE_NODE_STATE: - dest->node_state = src->node_state; - break; - - case ORTE_PROC_STATE: - dest->proc_state = src->proc_state; - break; - - case ORTE_EXIT_CODE: - dest->exit_code = src->exit_code; - break; - - case ORTE_BYTE_OBJECT: - (dest->byteobject).size = (src->byteobject).size; - (dest->byteobject).bytes = (uint8_t*)malloc((dest->byteobject).size); - if (NULL == (dest->byteobject).bytes) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - memcpy((dest->byteobject).bytes, (src->byteobject).bytes, (dest->byteobject).size); - break; - - case ORTE_APP_CONTEXT: - if(NULL == src->app_context) { - dest->app_context = NULL; - break; - } - dest->app_context = OBJ_NEW(orte_app_context_t); - dest->app_context->idx = src->app_context->idx; - if(NULL != src->app_context->app) { - dest->app_context->app = strdup(src->app_context->app); - } else { - dest->app_context->app = NULL; - } - dest->app_context->num_procs = src->app_context->num_procs; - dest->app_context->argc = src->app_context->argc; - dest->app_context->argv = ompi_argv_copy(src->app_context->argv); - dest->app_context->num_env = src->app_context->num_env; - dest->app_context->env = ompi_argv_copy(src->app_context->env); - if(NULL != src->app_context->cwd) { - dest->app_context->cwd = strdup(src->app_context->cwd); - } else { - dest->app_context->cwd = NULL; - } - dest->app_context->num_map = src->app_context->num_map; - if (NULL != src->app_context->map_data) { - dest->app_context->map_data = (orte_app_context_map_t **) malloc(sizeof(orte_app_context_map_t *) * src->app_context->num_map); - for (i = 0; i < src->app_context->num_map; ++i) { - dest->app_context->map_data[i] = - OBJ_NEW(orte_app_context_map_t); - dest->app_context->map_data[i]->map_type = - src->app_context->map_data[i]->map_type; - dest->app_context->map_data[i]->map_data = - strdup(src->app_context->map_data[i]->map_data); - } - } else { - dest->app_context->map_data = NULL; - } - break; - - case ORTE_NULL: - break; - - default: - return ORTE_ERR_BAD_PARAM; - break; - } - return ORTE_SUCCESS; -} - int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1, orte_gpr_replica_itagval_t *ival2) { diff --git a/src/mca/gpr/replica/functional_layer/gpr_replica_subscribe_fn.c b/src/mca/gpr/replica/functional_layer/gpr_replica_subscribe_fn.c index 4559cf105a..13b40ee9a4 100644 --- a/src/mca/gpr/replica/functional_layer/gpr_replica_subscribe_fn.c +++ b/src/mca/gpr/replica/functional_layer/gpr_replica_subscribe_fn.c @@ -220,7 +220,7 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_su cntr->cptr = cptr2; cntr->iptr = iptr; cntr->trigger_level.type = (trigs[j]->keyvals[i])->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload(&(cntr->trigger_level.value), + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(&(cntr->trigger_level.value), &((trigs[j]->keyvals[i])->value), (trigs[j]->keyvals[i])->type))) { ORTE_ERROR_LOG(rc); goto CLEANUP; @@ -265,7 +265,7 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_su cntr->cptr = cptr[k]; cntr->iptr = iptr; cntr->trigger_level.type = (trigs[j]->keyvals[i])->type; - if (ORTE_SUCCESS != (rc = orte_gpr_replica_xfer_payload(&(cntr->trigger_level.value), + if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(&(cntr->trigger_level.value), &((trigs[j]->keyvals[i])->value), (trigs[j]->keyvals[i])->type))) { ORTE_ERROR_LOG(rc); goto CLEANUP; diff --git a/src/mca/gpr/replica/gpr_replica_component.c b/src/mca/gpr/replica/gpr_replica_component.c index 7d3f6b0cab..5370b700c6 100644 --- a/src/mca/gpr/replica/gpr_replica_component.c +++ b/src/mca/gpr/replica/gpr_replica_component.c @@ -78,6 +78,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = { orte_gpr_replica_index_nb, /* GENERAL OPERATIONS */ orte_gpr_replica_preallocate_segment, + orte_gpr_base_xfer_payload, /* ARITHMETIC OPERATIONS */ orte_gpr_replica_increment_value, orte_gpr_replica_decrement_value, diff --git a/src/mca/ns/base/base.h b/src/mca/ns/base/base.h index 3f06dd1257..466a1d65eb 100644 --- a/src/mca/ns/base/base.h +++ b/src/mca/ns/base/base.h @@ -128,10 +128,15 @@ OMPI_DECLSPEC int orte_ns_base_compare(orte_ns_cmp_bitmask_t fields, OMPI_DECLSPEC int orte_ns_base_free_name(orte_process_name_t **name); +/* not available functions */ OMPI_DECLSPEC int orte_ns_base_module_init_not_available(void); -OMPI_DECLSPEC int orte_ns_base_create_cellid_not_available(orte_cellid_t *cellid); +OMPI_DECLSPEC int orte_ns_base_create_cellid_not_available(orte_cellid_t *cellid, + char *site, char *resource); +OMPI_DECLSPEC int orte_ns_base_get_cell_info_not_available(orte_cellid_t cellid, + char **site, char **resource); + OMPI_DECLSPEC int orte_ns_base_create_jobid_not_available(orte_jobid_t *jobid); OMPI_DECLSPEC int orte_ns_base_get_vpid_range_not_available(orte_jobid_t job, diff --git a/src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c b/src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c index 64bd7409b0..b880f2540d 100644 --- a/src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c +++ b/src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c @@ -21,6 +21,8 @@ #include #endif +#include "util/output.h" + #include "mca/errmgr/errmgr.h" #include "dps/dps_internal.h" diff --git a/src/mca/ns/base/ns_base_local_fns.c b/src/mca/ns/base/ns_base_local_fns.c index 37e37c77a7..b1173351fc 100644 --- a/src/mca/ns/base/ns_base_local_fns.c +++ b/src/mca/ns/base/ns_base_local_fns.c @@ -51,13 +51,23 @@ orte_ns_base_module_init_not_available(void) } int -orte_ns_base_create_cellid_not_available(orte_cellid_t *cellid) +orte_ns_base_create_cellid_not_available(orte_cellid_t *cellid, char *site, char *resource) { *cellid = ORTE_CELLID_MAX; ORTE_ERROR_LOG(ORTE_ERR_UNREACH); return ORTE_ERR_UNREACH; } +int +orte_ns_base_get_cell_info_not_available(orte_cellid_t cellid, + char **site, char **resource) +{ + *site = NULL; + *resource = NULL; + ORTE_ERROR_LOG(ORTE_ERR_UNREACH); + return ORTE_ERR_UNREACH; +} + int orte_ns_base_create_jobid_not_available(orte_jobid_t *jobid) { diff --git a/src/mca/ns/base/ns_base_open.c b/src/mca/ns/base/ns_base_open.c index 2fcff7a480..4247e60fef 100644 --- a/src/mca/ns/base/ns_base_open.c +++ b/src/mca/ns/base/ns_base_open.c @@ -50,6 +50,7 @@ int mca_ns_base_output = -1; OMPI_DECLSPEC mca_ns_base_module_t orte_ns = { orte_ns_base_module_init_not_available, orte_ns_base_create_cellid_not_available, + orte_ns_base_get_cell_info_not_available, orte_ns_base_assign_cellid_to_process, orte_ns_base_create_jobid_not_available, orte_ns_base_create_process_name, diff --git a/src/mca/ns/ns.h b/src/mca/ns/ns.h index 8763b25e59..4dfca45798 100644 --- a/src/mca/ns/ns.h +++ b/src/mca/ns/ns.h @@ -62,19 +62,38 @@ typedef int (*orte_ns_base_module_init_fn_t)(void); * 1 to MCA_NS_BASE_CELLID_MAX-1 (zero is reserved for the seed name and cannot therefore be * allocated). * - * @param None - * @retval cellid The numerical value of the allocated cell id. A value of + * @param site The name of the site where the cell is located. + * @param resource The name of the resource associated with this cell (e.g., the name + * of the cluster). + * @param cellid The numerical value of the allocated cell id. A value of * MCA_NS_BASE_CELLID_MAX indicates * that an error occurred - this represents a very unlikely * event meaning that the system ran out of cell id's. This probably indicates * an error in the calling program as the number of available cell id's is extremely large. + * + * @retval ORTE_SUCCESS A cellid was created and returned. + * @retval ORTE_ERROR_VALUE An error code indicative of the problem. * * @code * new_cellid = ompi_name_server.create_cellid() * @endcode */ -typedef int (*orte_ns_base_module_create_cellid_fn_t)(orte_cellid_t *cellid); +typedef int (*orte_ns_base_module_create_cellid_fn_t)(orte_cellid_t *cellid, + char *site, char *resource); +/** + * Get cell info + * Retrieve the site and resource info on a cell. + * + * @param cellid The id of the cell who's info is being requested. + * @param site Returns a pointer to a strdup'd string containing the site name. + * @param resource Returns a pointer to a strdup'd string containg the resource name. + * @retval ORTE_SUCCESS A cellid was created and returned. + * @retval ORTE_ERROR_VALUE An error code indicative of the problem. + */ +typedef int (*orte_ns_base_module_get_cell_info_fn_t)(orte_cellid_t cellid, + char **site, char **resource); + /** * Get the cell id for a process. * The cellid designator represents the physical location of the process - it is associated with @@ -571,6 +590,7 @@ typedef int (*orte_ns_base_module_get_peers_fn_t)(orte_process_name_t **procs, struct mca_ns_base_module_1_0_0_t { orte_ns_base_module_init_fn_t init; orte_ns_base_module_create_cellid_fn_t create_cellid; + orte_ns_base_module_get_cell_info_fn_t get_cell_info; orte_ns_base_module_assign_cellid_to_process_fn_t assign_cellid_to_process; orte_ns_base_module_create_jobid_fn_t create_jobid; orte_ns_base_module_create_proc_name_fn_t create_process_name; diff --git a/src/mca/ns/proxy/src/ns_proxy.c b/src/mca/ns/proxy/src/ns_proxy.c index 6e9249fecb..af9d13aff7 100644 --- a/src/mca/ns/proxy/src/ns_proxy.c +++ b/src/mca/ns/proxy/src/ns_proxy.c @@ -38,17 +38,24 @@ * functions */ -int orte_ns_proxy_create_cellid(orte_cellid_t *cellid) +int orte_ns_proxy_create_cellid(orte_cellid_t *cellid, char *site, char *resource) { orte_buffer_t* cmd; orte_buffer_t* answer; orte_ns_cmd_flag_t command; size_t count; int rc; + orte_ns_proxy_cell_info_t *cptr; /* set the default value of error */ *cellid = ORTE_CELLID_MAX; + /* check for errors */ + if (NULL == site || NULL == resource) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + command = ORTE_NS_CREATE_CELLID_CMD; cmd = OBJ_NEW(orte_buffer_t); @@ -57,7 +64,19 @@ int orte_ns_proxy_create_cellid(orte_cellid_t *cellid) return ORTE_ERR_OUT_OF_RESOURCE; } - if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, (void*)&command, 1, ORTE_NS_CMD))) { + if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_NS_CMD))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(cmd); + return rc; + } + + if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &site, 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(cmd); + return rc; + } + + if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &resource, 1, ORTE_STRING))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); return rc; @@ -102,10 +121,45 @@ int orte_ns_proxy_create_cellid(orte_cellid_t *cellid) return rc; } OBJ_RELEASE(answer); + + /* store the info locally for later retrieval */ + cptr = OBJ_NEW(orte_ns_proxy_cell_info_t); + if (NULL == cptr) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + cptr->cellid = *cellid; + cptr->site = strdup(site); + cptr->resource = strdup(resource); + ompi_list_append(&orte_ns_proxy_cell_info_list, &cptr->item); + return ORTE_SUCCESS; } +int orte_ns_proxy_get_cell_info(orte_cellid_t cellid, + char **site, char **resource) +{ + ompi_list_item_t *item; + orte_ns_proxy_cell_info_t *cell; + + *site = NULL; + *resource = NULL; + + for (item = ompi_list_get_first(&orte_ns_proxy_cell_info_list); + item != ompi_list_get_end(&orte_ns_proxy_cell_info_list); + item = ompi_list_get_next(item)) { + cell = (orte_ns_proxy_cell_info_t*)item; + if (cellid == cell->cellid) { + *site = strdup(cell->site); + *resource = strdup(cell->resource); + return ORTE_SUCCESS; + } + } + return ORTE_ERR_NOT_FOUND; +} + int orte_ns_proxy_create_jobid(orte_jobid_t *job) { orte_buffer_t* cmd; diff --git a/src/mca/ns/proxy/src/ns_proxy.h b/src/mca/ns/proxy/src/ns_proxy.h index 535c42758f..80c87c2f37 100644 --- a/src/mca/ns/proxy/src/ns_proxy.h +++ b/src/mca/ns/proxy/src/ns_proxy.h @@ -31,6 +31,16 @@ extern "C" { #endif +struct orte_ns_proxy_cell_info_t { + ompi_list_item_t item; /**< Allows this item to be placed on a list */ + orte_cellid_t cellid; + char *site; + char *resource; +}; +typedef struct orte_ns_proxy_cell_info_t orte_ns_proxy_cell_info_t; + +OBJ_CLASS_DECLARATION(orte_ns_proxy_cell_info_t); + struct orte_ns_proxy_tagitem_t { ompi_list_item_t item; /**< Allows this item to be placed on a list */ orte_rml_tag_t tag; /**< OOB tag */ @@ -70,6 +80,7 @@ int orte_ns_proxy_finalize(void); extern orte_process_name_t *orte_ns_my_replica; extern int orte_ns_proxy_debug; +extern ompi_list_t orte_ns_proxy_cell_info_list; extern ompi_list_t orte_ns_proxy_taglist; extern ompi_list_t orte_ns_proxy_dtlist; extern ompi_mutex_t orte_ns_proxy_mutex; @@ -77,7 +88,9 @@ extern ompi_mutex_t orte_ns_proxy_mutex; /* * proxy function prototypes */ -int orte_ns_proxy_create_cellid(orte_cellid_t *cellid); +int orte_ns_proxy_create_cellid(orte_cellid_t *cellid, char *site, char *resource); + +int orte_ns_proxy_get_cell_info(orte_cellid_t cellid, char **site, char **resource); int orte_ns_proxy_create_jobid(orte_jobid_t *jobid); diff --git a/src/mca/ns/proxy/src/ns_proxy_component.c b/src/mca/ns/proxy/src/ns_proxy_component.c index 473df26948..cbd1c48ba8 100644 --- a/src/mca/ns/proxy/src/ns_proxy_component.c +++ b/src/mca/ns/proxy/src/ns_proxy_component.c @@ -67,6 +67,7 @@ OMPI_COMP_EXPORT mca_ns_base_component_t mca_ns_proxy_component = { static mca_ns_base_module_t orte_ns_proxy = { orte_ns_proxy_module_init, orte_ns_proxy_create_cellid, + orte_ns_proxy_get_cell_info, orte_ns_base_assign_cellid_to_process, orte_ns_proxy_create_jobid, orte_ns_base_create_process_name, @@ -100,6 +101,31 @@ static mca_ns_base_module_t orte_ns_proxy = { */ static bool initialized = false; +/* constructor - used to initialize state of cell info list instance */ +static void orte_ns_proxy_cell_info_construct(orte_ns_proxy_cell_info_t* ptr) +{ + ptr->resource = NULL; + ptr->site = NULL; +} + +/* destructor - used to free any resources held by instance */ +static void orte_ns_proxy_cell_info_destructor(orte_ns_proxy_cell_info_t* ptr) +{ + if (NULL != ptr->resource) { + free(ptr->resource); + } + if (NULL != ptr->site) { + free(ptr->site); + } +} + +/* define instance of ompi_class_t */ +OBJ_CLASS_INSTANCE( + orte_ns_proxy_cell_info_t, /* type name */ + ompi_list_item_t, /* parent "class" name */ + orte_ns_proxy_cell_info_construct, /* constructor */ + orte_ns_proxy_cell_info_destructor); /* destructor */ + /* constructor - used to initialize state of taglist instance */ static void orte_ns_proxy_tagitem_construct(orte_ns_proxy_tagitem_t* tagitem) { @@ -150,6 +176,7 @@ OBJ_CLASS_INSTANCE( orte_process_name_t* orte_ns_my_replica=NULL; int orte_ns_proxy_debug=0; +ompi_list_t orte_ns_proxy_cell_info_list; ompi_list_t orte_ns_proxy_taglist; ompi_list_t orte_ns_proxy_dtlist; ompi_mutex_t orte_ns_proxy_mutex; @@ -206,6 +233,9 @@ mca_ns_base_module_t* orte_ns_proxy_init(int *priority) return NULL; } + /* initialize the cell info list */ + OBJ_CONSTRUCT(&orte_ns_proxy_cell_info_list, ompi_list_t); + /* initialize the taglist */ OBJ_CONSTRUCT(&orte_ns_proxy_taglist, ompi_list_t); @@ -238,14 +268,19 @@ int orte_ns_proxy_module_init(void) int orte_ns_proxy_finalize(void) { orte_ns_proxy_tagitem_t *tagitem; + orte_ns_proxy_cell_info_t *cptr; if (orte_ns_proxy_debug) { ompi_output(0, "finalizing ns proxy"); } - /* free the taglist storage, but only if this component was initialized */ + /* free the storage, but only if this component was initialized */ if (initialized) { + while (NULL != (cptr = (orte_ns_proxy_cell_info_t*)ompi_list_remove_first(&orte_ns_proxy_cell_info_list))) { + OBJ_RELEASE(cptr); + } + OBJ_DESTRUCT(&orte_ns_proxy_cell_info_list); while (NULL != (tagitem = (orte_ns_proxy_tagitem_t*)ompi_list_remove_first(&orte_ns_proxy_taglist))) { OBJ_RELEASE(tagitem); } diff --git a/src/mca/ns/replica/src/ns_replica.c b/src/mca/ns/replica/src/ns_replica.c index 5ee60e3541..ba25a11626 100644 --- a/src/mca/ns/replica/src/ns_replica.c +++ b/src/mca/ns/replica/src/ns_replica.c @@ -37,13 +37,26 @@ * functions */ -int orte_ns_replica_create_cellid(orte_cellid_t *cellid) +int orte_ns_replica_create_cellid(orte_cellid_t *cellid, char *site, char *resource) { + orte_ns_replica_cell_tracker_t *new_cell; + OMPI_THREAD_LOCK(&orte_ns_replica_mutex); if (ORTE_CELLID_MAX > orte_ns_replica_next_cellid) { - *cellid = orte_ns_replica_next_cellid; - orte_ns_replica_next_cellid++; + *cellid = orte_ns_replica_next_cellid; + orte_ns_replica_next_cellid++; + new_cell = OBJ_NEW(orte_ns_replica_cell_tracker_t); + if (NULL == new_cell) { + *cellid = ORTE_CELLID_MAX; + OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + new_cell->cell = *cellid; + new_cell->site = strdup(site); + new_cell->resource = strdup(resource); + ompi_list_append(&orte_ns_replica_cell_tracker, &new_cell->item); OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); return ORTE_SUCCESS; } @@ -54,6 +67,26 @@ int orte_ns_replica_create_cellid(orte_cellid_t *cellid) return ORTE_ERR_OUT_OF_RESOURCE; } +int orte_ns_replica_get_cell_info(orte_cellid_t cellid, + char **site, char **resource) +{ + ompi_list_item_t *item; + orte_ns_replica_cell_tracker_t *cell; + + for (item = ompi_list_get_first(&orte_ns_replica_cell_tracker); + item != ompi_list_get_end(&orte_ns_replica_cell_tracker); + item = ompi_list_get_next(item)) { + cell = (orte_ns_replica_cell_tracker_t*)item; + if (cellid == cell->cell) { + *site = strdup(cell->site); + *resource = strdup(cell->resource); + return ORTE_SUCCESS; + } + } + return ORTE_ERR_NOT_FOUND; +} + + int orte_ns_replica_create_jobid(orte_jobid_t *jobid) { orte_ns_replica_name_tracker_t *new_nt; diff --git a/src/mca/ns/replica/src/ns_replica.h b/src/mca/ns/replica/src/ns_replica.h index a5685524be..0753e110c8 100644 --- a/src/mca/ns/replica/src/ns_replica.h +++ b/src/mca/ns/replica/src/ns_replica.h @@ -30,6 +30,20 @@ #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif + +/* list class for tracking cellid's + */ +struct orte_ns_replica_cell_tracker_t { + ompi_list_item_t item; + orte_cellid_t cell; + char *site; + char *resource; +}; +typedef struct orte_ns_replica_cell_tracker_t orte_ns_replica_cell_tracker_t; + +OBJ_CLASS_DECLARATION(orte_ns_replica_cell_tracker_t); + + /* * list class for tracking vpids/jobid * This structure is used to create a linked list of jobid-max vpid pairs. Basically, we @@ -67,6 +81,7 @@ OBJ_CLASS_DECLARATION(orte_ns_replica_dti_t); */ extern orte_cellid_t orte_ns_replica_next_cellid; extern orte_jobid_t orte_ns_replica_next_jobid; +extern ompi_list_t orte_ns_replica_cell_tracker; extern ompi_list_t orte_ns_replica_name_tracker; extern orte_rml_tag_t orte_ns_replica_next_rml_tag; extern orte_data_type_t orte_ns_replica_next_dti; @@ -99,7 +114,13 @@ void orte_ns_replica_recv(int status, orte_process_name_t* sender, /* * Implementation of create_cellid(). */ -int orte_ns_replica_create_cellid(orte_cellid_t *cellid); +int orte_ns_replica_create_cellid(orte_cellid_t *cellid, char *site, char *resource); + +/* + * Implementation of get_cell_info() + */ +int orte_ns_replica_get_cell_info(orte_cellid_t cellid, + char **site, char **resource); /* * Implementation of create_jobid(). diff --git a/src/mca/ns/replica/src/ns_replica_component.c b/src/mca/ns/replica/src/ns_replica_component.c index 86255193ae..4b30685c66 100644 --- a/src/mca/ns/replica/src/ns_replica_component.c +++ b/src/mca/ns/replica/src/ns_replica_component.c @@ -70,6 +70,7 @@ OMPI_COMP_EXPORT mca_ns_base_component_t mca_ns_replica_component = { static mca_ns_base_module_t orte_ns_replica = { orte_ns_replica_module_init, orte_ns_replica_create_cellid, + orte_ns_replica_get_cell_info, orte_ns_base_assign_cellid_to_process, orte_ns_replica_create_jobid, orte_ns_base_create_process_name, @@ -104,6 +105,29 @@ static mca_ns_base_module_t orte_ns_replica = { static bool initialized = false; +/* constructor - used to initialize state of cell_tracker instance */ +static void orte_ns_replica_cell_tracker_construct(orte_ns_replica_cell_tracker_t* cell_tracker) +{ + cell_tracker->cell = 0; + cell_tracker->site = NULL; + cell_tracker->resource = NULL; +} + +/* destructor - used to free any resources held by instance */ +static void orte_ns_replica_cell_tracker_destructor(orte_ns_replica_cell_tracker_t* cell_tracker) +{ + if (NULL != cell_tracker->site) free(cell_tracker->site); + if (NULL != cell_tracker->resource) free(cell_tracker->resource); +} + +/* define instance of ompi_class_t */ +OBJ_CLASS_INSTANCE( + orte_ns_replica_cell_tracker_t, /* type name */ + ompi_list_item_t, /* parent "class" name */ + orte_ns_replica_cell_tracker_construct, /* constructor */ + orte_ns_replica_cell_tracker_destructor); /* destructor */ + + /* constructor - used to initialize state of name_tracker instance */ static void orte_ns_replica_tracker_construct(orte_ns_replica_name_tracker_t* name_tracker) { @@ -123,6 +147,7 @@ OBJ_CLASS_INSTANCE( orte_ns_replica_tracker_construct, /* constructor */ orte_ns_replica_tracker_destructor); /* destructor */ + /* constructor - used to initialize state of taglist instance */ static void orte_ns_replica_tagitem_construct(orte_ns_replica_tagitem_t* tagitem) { @@ -145,6 +170,7 @@ OBJ_CLASS_INSTANCE( orte_ns_replica_tagitem_construct, /* constructor */ orte_ns_replica_tagitem_destructor); /* destructor */ + /* constructor - used to initialize state of dtilist instance */ static void orte_ns_replica_dti_construct(orte_ns_replica_dti_t* dti) { @@ -172,6 +198,7 @@ OBJ_CLASS_INSTANCE( */ orte_cellid_t orte_ns_replica_next_cellid; orte_jobid_t orte_ns_replica_next_jobid; +ompi_list_t orte_ns_replica_cell_tracker; ompi_list_t orte_ns_replica_name_tracker; orte_rml_tag_t orte_ns_replica_next_rml_tag; orte_data_type_t orte_ns_replica_next_dti; @@ -225,6 +252,11 @@ mca_ns_base_module_t* orte_ns_replica_init(int *priority) *priority = 50; + /* initialize the cell tracker */ + + OBJ_CONSTRUCT(&orte_ns_replica_cell_tracker, ompi_list_t); + orte_ns_replica_next_cellid = 0; + /* initialize the name tracker */ OBJ_CONSTRUCT(&orte_ns_replica_name_tracker, ompi_list_t); @@ -331,14 +363,14 @@ void orte_ns_replica_recv(int status, orte_process_name_t* sender, orte_cellid_t cell; orte_jobid_t job; orte_vpid_t startvpid, range; - char *tagname; + char *tagname, *site, *resource; orte_rml_tag_t oob_tag; orte_data_type_t type; size_t count; int rc=ORTE_SUCCESS, ret; count = 1; - if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, (void*)&command, &count, ORTE_NS_CMD))) { + if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &count, ORTE_NS_CMD))) { ORTE_ERROR_LOG(rc); rc = ORTE_ERR_BAD_PARAM; goto RETURN_ERROR; @@ -348,22 +380,36 @@ void orte_ns_replica_recv(int status, orte_process_name_t* sender, switch (command) { case ORTE_NS_CREATE_CELLID_CMD: - if (ORTE_SUCCESS != (rc = orte_dps.pack(&answer, (void*)&command, 1, ORTE_NS_CMD))) { - ORTE_ERROR_LOG(rc); - goto RETURN_ERROR; - } - - rc = orte_ns_replica_create_cellid(&cell); - - if (ORTE_SUCCESS != (ret = orte_dps.pack(&answer, (void*)&cell, 1, ORTE_CELLID))) { - ORTE_ERROR_LOG(ret); - goto RETURN_ERROR; - } - if (0 > orte_rml.send_buffer(sender, &answer, tag, 0)) { - ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); - goto RETURN_ERROR; - } - break; + if (ORTE_SUCCESS != (rc = orte_dps.pack(&answer, &command, 1, ORTE_NS_CMD))) { + ORTE_ERROR_LOG(rc); + goto RETURN_ERROR; + } + + count = 1; + if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &site, &count, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + rc = ORTE_ERR_BAD_PARAM; + goto RETURN_ERROR; + } + + count = 1; + if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &resource, &count, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + rc = ORTE_ERR_BAD_PARAM; + goto RETURN_ERROR; + } + + rc = orte_ns_replica_create_cellid(&cell, site, resource); + + if (ORTE_SUCCESS != (ret = orte_dps.pack(&answer, &cell, 1, ORTE_CELLID))) { + ORTE_ERROR_LOG(ret); + goto RETURN_ERROR; + } + if (0 > orte_rml.send_buffer(sender, &answer, tag, 0)) { + ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); + goto RETURN_ERROR; + } + break; case ORTE_NS_CREATE_JOBID_CMD: if (ORTE_SUCCESS != (rc = orte_dps.pack(&answer, (void*)&command, 1, ORTE_NS_CMD))) { diff --git a/src/mca/rds/base/Makefile.am b/src/mca/rds/base/Makefile.am index 5e5534abcb..99376cb8f4 100644 --- a/src/mca/rds/base/Makefile.am +++ b/src/mca/rds/base/Makefile.am @@ -34,7 +34,8 @@ libmca_rds_base_la_SOURCES = \ rds_base_close.c \ rds_base_select.c \ rds_base_open.c \ - rds_base_query.c + rds_base_query.c \ + rds_base_registry_fns.c # Conditionally install the header files diff --git a/src/mca/rds/base/base.h b/src/mca/rds/base/base.h index 3ca9377ed7..ad0ff8c8c7 100644 --- a/src/mca/rds/base/base.h +++ b/src/mca/rds/base/base.h @@ -50,7 +50,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_rds_base_selected_t); /* - * function definitions + * API function definitions */ OMPI_DECLSPEC int orte_rds_base_open(void); OMPI_DECLSPEC int orte_rds_base_select(void); @@ -74,6 +74,11 @@ OMPI_DECLSPEC extern orte_rds_base_t orte_rds_base; * external API functions will be documented in the mca/ns/ns.h file */ +/* + * utility functions for use within the RDS + */ +int orte_rds_base_store_resource(ompi_list_t *resource_list); + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/mca/rds/base/rds_base_open.c b/src/mca/rds/base/rds_base_open.c index 72509152ee..246244d51d 100644 --- a/src/mca/rds/base/rds_base_open.c +++ b/src/mca/rds/base/rds_base_open.c @@ -21,6 +21,7 @@ #include "mca/mca.h" #include "mca/base/base.h" #include "mca/base/mca_base_param.h" +#include "mca/gpr/gpr_types.h" #include "util/output.h" #include "mca/rds/base/base.h" @@ -34,10 +35,52 @@ #include "mca/rds/base/static-components.h" -/* - * globals +/** + * Local functions. */ +static void orte_rds_base_cell_desc_constructor(orte_rds_cell_desc_t *cell) +{ + cell->site = NULL; + cell->name = NULL; + cell->type = NULL; + + OBJ_CONSTRUCT(&cell->attributes, ompi_list_t); +} + +static void orte_rds_base_cell_desc_destructor(orte_rds_cell_desc_t *cell) +{ + if (NULL != cell->site) free(cell->site); + if (NULL != cell->name) free(cell->name); + if (NULL != cell->type) free(cell->type); + + OBJ_DESTRUCT(&cell->attributes); +} + +OBJ_CLASS_INSTANCE( + orte_rds_cell_desc_t, + ompi_list_item_t, + orte_rds_base_cell_desc_constructor, + orte_rds_base_cell_desc_destructor); + + +static void orte_rds_base_cell_attr_constructor(orte_rds_cell_attr_t *cell) +{ + OBJ_CONSTRUCT(&cell->keyval, orte_gpr_keyval_t); +} + +static void orte_rds_base_cell_attr_destructor(orte_rds_cell_attr_t *cell) +{ + OBJ_DESTRUCT(&cell->keyval); +} + +OBJ_CLASS_INSTANCE( + orte_rds_cell_attr_t, + ompi_list_item_t, + orte_rds_base_cell_attr_constructor, + orte_rds_base_cell_attr_destructor); + + /* * Global variables */ diff --git a/src/mca/rds/base/rds_base_registry_fns.c b/src/mca/rds/base/rds_base_registry_fns.c new file mode 100644 index 0000000000..ddbbdad7a2 --- /dev/null +++ b/src/mca/rds/base/rds_base_registry_fns.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * 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, + * 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$ + */ +/** @file: + */ + +/* + * includes + */ +#include "orte_config.h" +#include "include/orte_constants.h" + +#include "class/ompi_list.h" +#include "util/output.h" +#include "mca/errmgr/errmgr.h" +#include "mca/gpr/gpr.h" +#include "mca/schema/schema.h" + +#include "mca/rds/base/base.h" + +int orte_rds_base_store_resource(ompi_list_t *resources) +{ + orte_rds_cell_desc_t *cell; + ompi_list_item_t *item; + orte_gpr_value_t **values; + orte_rds_cell_attr_t *attr; + size_t i, j, num_vals; + int rc; + + if (NULL == resources) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + + num_vals = ompi_list_get_size(resources); + if (0 == num_vals) { /* nothing to do */ + return ORTE_SUCCESS; + } + + values = (orte_gpr_value_t**)malloc(num_vals * sizeof(orte_gpr_value_t*)); + if (NULL == values) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + for (i=0; i < num_vals && NULL != (cell = (orte_rds_cell_desc_t*)ompi_list_remove_first(resources)); i++) { + values[i] = OBJ_NEW(orte_gpr_value_t); + if (NULL == values[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + rc = ORTE_ERR_OUT_OF_RESOURCE; + goto CLEANUP; + } + + values[i]->addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR; + values[i]->segment = strdup(ORTE_RESOURCE_SEGMENT); + + if (ORTE_SUCCESS != (rc = orte_schema.get_cell_tokens(&(values[i]->tokens), + &(values[i]->num_tokens), cell->cellid))) { + ORTE_ERROR_LOG(rc); + goto CLEANUP; + } + + values[i]->cnt = ompi_list_get_size(&cell->attributes); + values[i]->keyvals = (orte_gpr_keyval_t**)malloc(values[i]->cnt * sizeof(orte_gpr_keyval_t*)); + if (NULL == values[i]->keyvals) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + rc = ORTE_ERR_OUT_OF_RESOURCE; + goto CLEANUP; + } + + for (j=0, item = ompi_list_get_first(&cell->attributes); + j < values[i]->cnt && item != ompi_list_get_end(&cell->attributes); + j++, item = ompi_list_get_next(item)) { + attr = (orte_rds_cell_attr_t*)item; + + values[i]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t); + if (NULL == values[i]->keyvals[j]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + rc = ORTE_ERR_OUT_OF_RESOURCE; + goto CLEANUP; + } + + values[i]->keyvals[j]->key = strdup(attr->keyval.key); + values[i]->keyvals[j]->type = attr->keyval.type; + if (ORTE_SUCCESS != (rc = orte_gpr.xfer_payload( + &(values[i]->keyvals[j]->value), + &(attr->keyval.value), + values[i]->keyvals[j]->type))) { + ORTE_ERROR_LOG(rc); + goto CLEANUP; + } + } + OBJ_RELEASE(cell); + } + + if (ORTE_SUCCESS != (rc = orte_gpr.put(num_vals, values))) { + ORTE_ERROR_LOG(rc); + } + +CLEANUP: + for (i=0; i < num_vals; i++) { + if (NULL != values[i]) OBJ_RELEASE(values[i]); + } + + return rc; +} diff --git a/src/mca/rds/rds.h b/src/mca/rds/rds.h index e8f83cecfe..82bb5ff937 100644 --- a/src/mca/rds/rds.h +++ b/src/mca/rds/rds.h @@ -37,10 +37,11 @@ * access to at some foreign site). * * 2. A hostfile (e.g., etc/openmpi-default-hostfile) describes a set of hosts to - * which a specific user has access and/or wishes to use to run an application. The + * which a specific user has access and may wish to use to run applications. The * information in the hostfile is much less detailed than in a resource file - it - * is primarily intended to allow a user to specify which hosts are to be used for - * an application, and potentially how the application's processes can/are to be + * is primarily intended to allow a user to specify which hosts are available for + * use in an unmanaged environment (e.g, one spawned by rsh/ssh as opposed + * to a BProc system), and potentially how the application's processes can/are to be * distributed across them. Thus, one would not expect to find info on memory/node * in a hostfile, but would expect to find info on user id for a given host and the * maximum number of processes the user wants put on a given host. @@ -113,7 +114,7 @@ #include "mca/mca.h" #include "mca/ns/ns_types.h" -#include "rds_types.h" +#include "mca/rds/rds_types.h" /* diff --git a/src/mca/rds/rds_types.h b/src/mca/rds/rds_types.h index 44df57ba29..9407984023 100644 --- a/src/mca/rds/rds_types.h +++ b/src/mca/rds/rds_types.h @@ -14,9 +14,47 @@ * $HEADER$ */ +#include "orte_config.h" + +#include "class/ompi_list.h" +#include "mca/gpr/gpr_types.h" +#include "mca/ns/ns_types.h" + #ifndef ORTE_MCA_RDS_TYPES_H #define ORTE_MCA_RDS_TYPES_H +/* resource descriptor object */ +typedef struct { + /** Base object */ + ompi_list_item_t super; + /** id of cell in which this resource resides */ + orte_cellid_t cellid; + /** string name of the site */ + char *site; + /** string name of the resource */ + char *name; + /** string type of the resource */ + char *type; + /** list of attributes */ + ompi_list_t attributes; +} orte_rds_cell_desc_t; + +OBJ_CLASS_DECLARATION(orte_rds_cell_desc_t); + +/* resource attribute object */ +typedef struct { + /** Base object */ + ompi_list_item_t super; + /** key-value pair describing attribute */ + orte_gpr_keyval_t keyval; +} orte_rds_cell_attr_t; + +OBJ_CLASS_DECLARATION(orte_rds_cell_attr_t); + + +/* name of resource */ +#define ORTE_RDS_NAME "orte-rds-name" + /* type of resource (e.g., "cluster") */ #define ORTE_RDS_TYPE "orte-rds-type" @@ -24,7 +62,9 @@ #define ORTE_RDS_FE_NAME "orte-rds-fe-name" /* location of the temporary directory on the frontend - required because * some machines do not allow the frontend to access scratch filesystem space */ -#define ORTE_RDS_FE_TMP "orte-rds-fe-tmpdir" +#define ORTE_RDS_FE_TMP "orte-rds-fe-tmpdir" +/* whether or not ssh to the frontend is allowed */ +#define ORTE_RDS_FE_SSH "orte-rds-fe-ssh" /* node architecture info */ #define ORTE_RDS_NUM_NODES "orte-rds-arch-num-nodes" @@ -52,12 +92,16 @@ #define ORTE_RDS_OS_VENDOR "orte-rds-os-vendor" #define ORTE_RDS_OS_VERSION "orte-rds-os-version" +/* compute domains */ +#define ORTE_RDS_COMP_NUM_DOMAINS "orte-rds-comp-domains" +#define ORTE_RDS_COMP_NODES_DOMAIN "orte-rds-comp-nodes-domain" + /* filesystem type (e.g., "panasys") */ #define ORTE_RDS_FS_TYPE "orte-rds-fs-type" /* home directory for users */ #define ORTE_RDS_FS_HOME "orte-rds-fs-home" /* scratch directory */ -#define ORTE_RDS_FS_SCRATCH "orte-rds-fs-scratch-dir" +#define ORTE_RDS_FS_SCRATCH_ROOT "orte-rds-fs-scratch-dir" /* size of the scratch filesystem */ #define ORTE_RDS_FS_SCRATCH_SIZE "orte-rds-fs-scratch-size" /* number of domains in the filesystem */ @@ -70,8 +114,16 @@ #define ORTE_RDS_FS_GIVE "orte-rds-fs-give-dir" /* allocator and launcher info */ -#define ORTE_RDS_ALLOCATOR "orte-rds-allocator" -#define ORTE_RDS_LAUNCHER "orte-rds-launcher" +/* the allocator used to get resources allocated to me on this resource + * (e.g., LSF) + */ +#define ORTE_RDS_ALLOCATOR "orte-rds-allocator" +/* the type of launch environment on this resource (e.g., BProc, rsh/ssh) */ +#define ORTE_RDS_LAUNCHER "orte-rds-launcher" + /* where in the order this resource should be allocated when looking for resources + * with the given type of launcher + */ +#define ORTE_RDS_ALLOCATION_SEQUENCE "orte-rds-allocate-sequence" /* operational limits */ #define ORTE_RDS_MAX_PROCS_CPU "orte-rds-max-procs-per-cpu" diff --git a/src/mca/rds/resfile/.ompi_ignore b/src/mca/rds/resfile/.ompi_ignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mca/rds/resfile/.ompi_unignore b/src/mca/rds/resfile/.ompi_unignore deleted file mode 100644 index 97b20ffb20..0000000000 --- a/src/mca/rds/resfile/.ompi_unignore +++ /dev/null @@ -1 +0,0 @@ -rhc diff --git a/src/mca/rds/resfile/Makefile.am b/src/mca/rds/resfile/Makefile.am index a876e2564b..313a5a57f5 100644 --- a/src/mca/rds/resfile/Makefile.am +++ b/src/mca/rds/resfile/Makefile.am @@ -32,6 +32,7 @@ endif proxy_SOURCES = \ rds_resfile.c \ + rds_resfile_parse_attributes.c \ rds_resfile.h \ rds_resfile_component.c diff --git a/src/mca/rds/resfile/configure.params b/src/mca/rds/resfile/configure.params index 6667994b57..217a6a78e7 100644 --- a/src/mca/rds/resfile/configure.params +++ b/src/mca/rds/resfile/configure.params @@ -18,5 +18,4 @@ # Specific to this module PARAM_INIT_FILE=rds_resfile.c -PARAM_CONFIG_HEADER_FILE="rds_resfile_config.h" PARAM_CONFIG_FILES="Makefile" diff --git a/src/mca/rds/resfile/configure.stub b/src/mca/rds/resfile/configure.stub deleted file mode 100644 index f91733ff66..0000000000 --- a/src/mca/rds/resfile/configure.stub +++ /dev/null @@ -1,114 +0,0 @@ -# -*- shell-script -*- -# -# Copyright (c) 2004-2005 The Trustees of Indiana University. -# 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, -# 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$ -# - -# -# Main function. This will be invoked in the middle of the templated -# configure script. -# -AC_DEFUN([MCA_CONFIGURE_STUB],[ - - # Additional --with flags that can be specified - - AC_ARG_WITH(rds-resfile-xml2-config, - AC_HELP_STRING([--with-rds-resfile-xml2-config=EXEC], - [Specify the location of xml2-config executable])) - - # Did the user specify where xml2-config is? - - xml2_config= - if test -n "$with_rds_resfile_xml2_config"; then - if test -x "$with_rds_resfile_xml2_config"; then - xml2_config="$with_rds_resfile_xml2_config" - elif test -x "$with_rds_resfile_xml2_config/xml2-config"; then - xml2_config="$with_rds_resfile_xml2_config/xml2-config" - elif test -x "$with_rds_resfile_xml2_config/bin/xml2-config"; then - xml2_config="$with_rds_resfile_xml2_config/bin/xml2-config" - else - AC_MSG_WARN([$with_rds_resfile_xml2_config does not appear to point to anything close to an xml2-config file]) - AC_MSG_WARN([Going to try to find libxml2 without it...]) - fi - else - AC_PATH_PROG(xml2_config, [xml2-config]) - if test -z "$xml2_config"; then - AC_MSG_WARN([Could not find xml2-config helper script]) - AC_MSG_WARN([Going to try to find libxml2 without it...]) - fi - fi - - # Add to CPPFLAGS, but only if necessary (note that xml2-config - # will output -I/path even if /path is already in the default - # search path of the compiler) - - EXTRA_CPPFLAGS= - AC_CHECK_HEADER(libxml/parser.h, HAPPY=1, HAPPY=0) - if test "$HAPPY" = "0"; then - if test -x "$xml2_config"; then - AC_MSG_CHECKING([for CPPFLAGS with xml2-config]) - EXTRA_CPPFLAGS="`$xml2_config --cflags`" - CPPFLAGS="$CPPFLAGS $EXTRA_CPPFLAGS" - AC_MSG_RESULT([$EXTRA_CPPFLAGS]) - AC_CHECK_HEADER(libxml/tree.h, HAPPY=1, HAPPY=0) - else - HAPPY=0 - fi - - if test "$HAPPY" = "0"; then - AC_MSG_ERROR([Cannot find libxml2 header files]) - fi - fi - - # Similar to above, add to LDFLAGS only if necessary. - - EXTRA_LDFLAGS= - AC_CHECK_LIB([xml2], [xmlReadFile], HAPPY=1, HAPPY=0) - if test "$HAPPY" = "0"; then - if test -x "$xml2_config"; then - AC_MSG_CHECKING([for CPPFLAGS with xml2-config]) - EXTRA_LDFLAGS="`$xml2_config --libs`" - LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" - AC_MSG_RESULT([$EXTRA_LDFLAGS]) - AC_CHECK_LIB([xml2], [xmlFreeDoc], HAPPY=1, HAPPY=0) - else - HAPPY=0 - fi - - if test "$HAPPY" = "0"; then - AC_MSG_ERROR([Cannot find libxml2 library]) - fi - fi - LIBS="$LIBS -lxml2" - - # Save extra compiler/linker flags so that they can be added in - # the wrapper compilers, if necessary. Separate out the LIBS from - # the LDFLAGS (because xml2-config [incorrectly] lumps them all - # together into one string. - - WRAPPER_EXTRA_LIBS="$LIBS" - WRAPPER_EXTRA_LDFLAGS= - for flag in $EXTRA_LDFLAGS; do - case $flag in - -l*) - WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $flag" - ;; - *) - WRAPPER_EXTRA_LDFLAGS="$WRAPPER_EXTRA_LDFLAGS $flag" - ;; - esac - done - LIBMPI_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS" - LIBMPI_EXTRA_LDFLAGS="$WRAPPER_EXTRA_LDFLAGS" -])dnl diff --git a/src/mca/rds/resfile/rds_resfile.c b/src/mca/rds/resfile/rds_resfile.c index 9364bcdad9..511b474695 100644 --- a/src/mca/rds/resfile/rds_resfile.c +++ b/src/mca/rds/resfile/rds_resfile.c @@ -16,106 +16,238 @@ #include "orte_config.h" #include -#include -#include #include "include/orte_constants.h" #include "mca/base/mca_base_param.h" +#include "mca/errmgr/errmgr.h" +#include "mca/ns/ns.h" #include "rds_resfile.h" -static void -process_resource(xmlChar *site, xmlDoc *doc, xmlNode *a_node) +#define ORTE_RDS_RESFILE_MAX_LINE_LENGTH 512 + +static ompi_list_t orte_rds_resfile_resource_list; + +static int orte_rds_resfile_parse_site(char *site, FILE *fp); + +static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp); + + +static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp) { - xmlNode *cur_node = NULL; - xmlChar *resource; - char *tokens[3]; - - tokens[0] = strdup((char*)site); - tokens[2] = NULL; - - cur_node = a_node->children; - while (NULL != cur_node) { - if ((!xmlStrcmp(cur_node->name, (const xmlChar *)"name"))) { - resource = xmlNodeListGetString(doc, cur_node->children, 1); - printf("site[resource]: %s[%s]\n", site, resource); - tokens[1] = strdup((char*)resource); - xmlFree(resource); + char *line; + bool name_given = false; + int rc; + orte_rds_cell_attr_t *na; + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + /* check for end of resource description */ + if (0 == strncmp(line, "name = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + /* get new cellid for this site/resource */ + if (ORTE_SUCCESS != (rc = orte_ns.create_cellid(&(cell->cellid), cell->site, cell->name))) { + ORTE_ERROR_LOG(rc); + return rc; + } + na = OBJ_NEW(orte_rds_cell_attr_t); + if (NULL == na) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + na->keyval.key = strdup(ORTE_RDS_NAME); + na->keyval.type = ORTE_STRING; + na->keyval.value.strptr = strdup(cell->name); + ompi_list_append(&(cell->attributes), &na->super); + na = OBJ_NEW(orte_rds_cell_attr_t); + if (NULL == na) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + na->keyval.key = strdup(ORTE_CELLID_KEY); + na->keyval.type = ORTE_CELLID; + na->keyval.value.cellid = cell->cellid; + ompi_list_append(&(cell->attributes), &na->super); + } else if (0 == strncmp(line, "type = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + na = OBJ_NEW(orte_rds_cell_attr_t); + if (NULL == na) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + na->keyval.key = strdup(ORTE_RDS_TYPE); + na->keyval.type = ORTE_STRING; + na->keyval.value.strptr = strdup(cell->type); + ompi_list_append(&(cell->attributes), &na->super); + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_ALLOCATOR); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + ompi_list_append(&(cell->attributes), &na->super); + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_LAUNCHER); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + ompi_list_append(&(cell->attributes), &na->super); + } else if (0 == strncmp(line, "next; } + return ORTE_SUCCESS; } -static void -process_site(xmlChar *site, xmlDoc *doc, xmlNode *a_node) + +static int orte_rds_resfile_parse_site(char *site, FILE *fp) { - xmlNode *cur_node = NULL; + char *line; + orte_rds_cell_desc_t *cell; + int rc; - cur_node = a_node->children; - while (NULL != cur_node) { - if ((!xmlStrcmp(cur_node->name, (const xmlChar *)"resource"))) { - process_resource(site, doc, cur_node); + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "site = strdup(site); + /* parse the resource description */ + if (ORTE_SUCCESS != (rc = orte_rds_resfile_parse_resource(cell, fp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + ompi_list_append(&orte_rds_resfile_resource_list, &cell->super); } - cur_node = cur_node->next; } + return ORTE_SUCCESS; } int orte_rds_resfile_query(void) { -#if 0 - xmlDoc *doc = NULL; - xmlNode *root_element = NULL; - xmlNode *cur = NULL; - xmlChar *site; - int fileid; - char *resfile; + int fileid, rc; + FILE *fp; + char *input_line, *resfile, *site; - /* - * this initializes the library and checks potential ABI mismatches - * between the version it was compiled for and the actual shared - * library used. - */ - LIBXML_TEST_VERSION + OMPI_LOCK(&mca_rds_resfile_component.lock); /* get the resource filename */ - fileid = mca_base_param_register_string("rds", "resfile", "name", "RESOURCE_FILE", NULL); - mca_base_param_lookup_string(fileid, &resfile); - if (NULL == resfile) { /* no resource file provided */ - return ORTE_ERR_NOT_FOUND; - } - - /*parse the file and get the DOM */ - doc = xmlReadFile(resfile, NULL, 0); - - if (doc == NULL) { - printf("error: could not parse file %s\n", resfile); + fileid = mca_base_param_register_string("rds", "resfile", "name", NULL, NULL); + mca_base_param_lookup_string(fileid, &resfile); + if (NULL == resfile) { /* no resource file provided */ + /* DO NOT ORTE_ERROR_LOG OR RETURN AN ERROR - THIS IS NOT AN ERROR CONDITION */ + return ORTE_SUCCESS; } - - /*Get the root element node */ - root_element = xmlDocGetRootElement(doc); - - /* walk the document tree looking for sites and save their info to the registry */ - cur = root_element->children; - while (NULL != cur) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"site-name"))) { - site = xmlNodeListGetString(doc, cur->children, 1); - printf("site: %s\n", site); - process_site(site, doc, cur); - xmlFree(site); - } - cur = cur->next; + + /* open the resource file */ + fp = fopen(resfile, "r"); + if (NULL == fp) { + ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); + return ORTE_ERR_NOT_FOUND; } - /*free the document */ - xmlFreeDoc(doc); + /* setup the resource list */ + OBJ_CONSTRUCT(&orte_rds_resfile_resource_list, ompi_list_t); + + /* dump the initial line containing the DOM */ + input_line = orte_rds_resfile_getline(fp); + if (NULL == input_line || 0 != strncmp(input_line, "", strlen(""))) { + /* extract the site name from input_line */ + if (NULL == (site = orte_rds_resfile_parse_field(input_line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(input_line); + rc = ORTE_ERR_FILE_READ_FAILURE; + goto CLEANUP; + } + if (ORTE_SUCCESS != (rc = orte_rds_resfile_parse_site(site, fp))) { + ORTE_ERROR_LOG(rc); + free(input_line); + goto CLEANUP; + } + } + free(input_line); + } - /* - *Free the global variables that may - *have been allocated by the parser. - */ - xmlCleanupParser(); -#endif + /* place resource list on registry */ + if (ORTE_SUCCESS != (rc = orte_rds_base_store_resource(&orte_rds_resfile_resource_list))) { + ORTE_ERROR_LOG(rc); + return rc; + } + +CLEANUP: + fclose(fp); + OBJ_DESTRUCT(&orte_rds_resfile_resource_list); + + OMPI_UNLOCK(&mca_rds_resfile_component.lock); return ORTE_SUCCESS; } @@ -125,3 +257,53 @@ int orte_rds_resfile_finalize(void) { return ORTE_SUCCESS; } + + +char *orte_rds_resfile_getline(FILE *fp) +{ + int i; + char *ret, *buff, *start; + char input[ORTE_RDS_RESFILE_MAX_LINE_LENGTH]; + + /* find the next non-blank line, stop at end-of-file */ + ret = fgets(input, ORTE_RDS_RESFILE_MAX_LINE_LENGTH, fp); + while (NULL != ret) { + input[strlen(input)-1] = '\0'; /* remove newline */ + /* strip leading whitespace */ + for (i=0; i < (int)strlen(input) && (input[i] == ' ' || input[i] == '\t'); i++); + if (i < (int)strlen(input)) { + start = &input[i]; + buff = strdup(start); + return buff; + } + ret = fgets(input, ORTE_RDS_RESFILE_MAX_LINE_LENGTH, fp); + } + + return NULL; +} + + +char *orte_rds_resfile_parse_field(char *input) +{ + char *start, *stop, *ans; + + start = strchr(input, '>'); + if (NULL == start) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return NULL; + } + start++; + stop = strchr(start, '<'); + if (NULL == stop) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return NULL; + } + *stop = '\0'; /* terminate the string */ + + if (start == stop) { + return NULL; + } + + ans = strdup(start); + return ans; +} diff --git a/src/mca/rds/resfile/rds_resfile.h b/src/mca/rds/resfile/rds_resfile.h index 07ea3ef927..832c61c94c 100644 --- a/src/mca/rds/resfile/rds_resfile.h +++ b/src/mca/rds/resfile/rds_resfile.h @@ -21,11 +21,19 @@ #ifndef ORTE_RDS_RESFILE_H #define ORTE_RDS_RESFILE_H -#include "mca/rds/rds.h" +#include "orte_config.h" + +#include "threads/mutex.h" + +#include "mca/rds/base/base.h" + #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif +/* resfile internal globals */ +extern ompi_list_t resource_list; + /* * RDS Resource file functions */ @@ -33,6 +41,23 @@ int orte_rds_resfile_query(void); int orte_rds_resfile_finalize(void); +/* RDS resource file internal functions */ +char *orte_rds_resfile_getline(FILE *fp); + +char *orte_rds_resfile_parse_field(char *input); + +/* RDS resource file attribute parsers */ +int orte_rds_resfile_parse_fe(orte_rds_cell_desc_t *cell, FILE *fp); + +int orte_rds_resfile_parse_cd(orte_rds_cell_desc_t *cell, FILE *fp); + +int orte_rds_resfile_parse_os(orte_rds_cell_desc_t *cell, FILE *fp); + +int orte_rds_resfile_parse_fs(orte_rds_cell_desc_t *cell, FILE *fp); + +int orte_rds_resfile_parse_se(orte_rds_cell_desc_t *cell, FILE *fp); + +int orte_rds_resfile_parse_na(orte_rds_cell_desc_t *cell, FILE *fp); /** * RDS Resource file Component @@ -41,6 +66,7 @@ struct orte_rds_resfile_component_t { orte_rds_base_component_t super; int debug; char *filename; + ompi_mutex_t lock; }; typedef struct orte_rds_resfile_component_t orte_rds_resfile_component_t; diff --git a/src/mca/rds/resfile/rds_resfile_component.c b/src/mca/rds/resfile/rds_resfile_component.c index a44409f2c0..b4bd23da37 100644 --- a/src/mca/rds/resfile/rds_resfile_component.c +++ b/src/mca/rds/resfile/rds_resfile_component.c @@ -96,6 +96,7 @@ static char* orte_rds_resfile_param_register_string( */ static int orte_rds_resfile_open(void) { + OBJ_CONSTRUCT(&mca_rds_resfile_component.lock, ompi_mutex_t); mca_rds_resfile_component.debug = orte_rds_resfile_param_register_int("debug",1); mca_rds_resfile_component.filename = orte_rds_resfile_param_register_string("file", NULL); @@ -105,6 +106,7 @@ static int orte_rds_resfile_open(void) static orte_rds_base_module_t *orte_rds_resfile_init(void) { + OBJ_DESTRUCT(&mca_rds_resfile_component.lock); return &orte_rds_resfile_module; } diff --git a/src/mca/rds/resfile/rds_resfile_parse_attributes.c b/src/mca/rds/resfile/rds_resfile_parse_attributes.c new file mode 100644 index 0000000000..9c96539280 --- /dev/null +++ b/src/mca/rds/resfile/rds_resfile_parse_attributes.c @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * 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, + * 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$ + */ +#include "orte_config.h" + +#include +#include + + +#include "include/orte_constants.h" +#include "util/output.h" +#include "mca/errmgr/errmgr.h" + +#include "rds_resfile.h" + +int orte_rds_resfile_parse_fe(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line, *ssh; + orte_rds_cell_attr_t *na; + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FE_NAME); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FE_TMP); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FE_SSH); + na->keyval.type = ORTE_BOOL; + if (NULL == (ssh = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + return ORTE_ERR_FILE_READ_FAILURE; + } + if (0 == strncmp(ssh, "true", 4)) { + na->keyval.value.tf_flag = true; + } else { + na->keyval.value.tf_flag = false; + } + } else { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + ompi_list_append(&(cell->attributes), &na->super); + } + + return ORTE_SUCCESS; +} + +int orte_rds_resfile_parse_cd(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line, *tmp; + orte_rds_cell_attr_t *na; + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_COMP_NUM_DOMAINS); + na->keyval.type = ORTE_INT16; + if (NULL == (tmp = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + na->keyval.value.i16 = 13; /* strtoi(tmp); */ + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_COMP_NODES_DOMAIN); + na->keyval.type = ORTE_INT16; + if (NULL == (tmp = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + na->keyval.value.i16 = 13; /*strtoi(tmp); */ + } else { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + free(line); + return ORTE_ERR_BAD_PARAM; + } + ompi_list_append(&(cell->attributes), &na->super); + free(line); + } + + return ORTE_SUCCESS; +} + +int orte_rds_resfile_parse_os(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line; + orte_rds_cell_attr_t *na; + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_OS_TYPE); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_OS_VENDOR); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_OS_VERSION); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + free(line); + return ORTE_ERR_BAD_PARAM; + } + ompi_list_append(&(cell->attributes), &na->super); + free(line); + } + + return ORTE_SUCCESS; +} + +int orte_rds_resfile_parse_fs(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line; +/* orte_rds_cell_attr_t *na; */ + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FS_TYPE); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FS_HOME); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FS_SCRATCH); + na->keyval.type = ORTE_STRING; + if (NULL == (na->keyval.value.strptr = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FS_DOMAINS); + na->keyval.type = ORTE_INT16; + if (NULL == (tmp = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + na->keyval.value.i16 = 13; /* strtoi(tmp); */ + } else if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_FS_NODES_DOMAIN); + na->keyval.type = ORTE_INT16; + if (NULL == (tmp = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + na->keyval.value.i16 = 13; /*strtoi(tmp); */ + } else { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + free(line); + return ORTE_ERR_BAD_PARAM; + } + ompi_list_append(&(cell->attributes), &na->super); +#endif + free(line); + } + + return ORTE_SUCCESS; +} + +int orte_rds_resfile_parse_se(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line; + orte_rds_cell_attr_t *na; + char *tmp; + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "keyval.key = strdup(ORTE_RDS_ALLOCATION_SEQUENCE); + na->keyval.type = ORTE_INT16; + if (NULL == (tmp = orte_rds_resfile_parse_field(line))) { + ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); + free(line); + return ORTE_ERR_FILE_READ_FAILURE; + } + na->keyval.value.i16 = 13; /*strtoi(tmp); */ + free(line); + } + + return ORTE_SUCCESS; +} + +int orte_rds_resfile_parse_na(orte_rds_cell_desc_t *cell, FILE *fp) +{ + char *line; +/* orte_rds_cell_attr_t *na; */ + + while (NULL != (line = orte_rds_resfile_getline(fp))) { + if (0 == strncmp(line, "dump_all(0); + fprintf(stderr, "get with no tokens, KEYS_OR\n"); + keys[0] = strdup("stupid-test-1"); + keys[1] = strdup("stupid-test-3"); + keys[2] = strdup("stupid-test-5"); + keys[3] = strdup("stupid-test-8"); + keys[4] = NULL; + if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR, + "test-put-segment", + NULL, keys, + &cnt, &values))) { + fprintf(test_out, "gpr_test: get failed with error code %s\n", + ORTE_ERROR_NAME(rc)); + test_failure("gpr_test: get failed"); + test_finalize(); + return rc; + } else { + fprintf(test_out, "gpr_test: get with no tokens, KEYS_OR passed\n"); + } + for (i=0; i < 4; i++) free(keys[i]); + free(names[0]); + + fprintf(stderr, "get results:\n"); + for (j=0; j < cnt; j++) { + fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n", + (unsigned long) j, (unsigned long) values[j]->cnt, + values[j]->segment, (unsigned long) values[j]->num_tokens); + for (i=0; i < values[j]->num_tokens; i++) { + fprintf(stderr, "token: %lu %s\n", (unsigned long) i, + values[j]->tokens[i]); + } + kvals = values[j]->keyvals; + for (i=0; i < values[j]->cnt; i++) { + fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->type); + } + OBJ_RELEASE(values[j]); + } + free(values); + + fprintf(stderr, "get with no tokens, KEYS_AND\n"); + keys[0] = strdup("stupid-test-1"); + keys[1] = strdup("stupid-test-3"); + keys[2] = strdup("stupid-test-5"); + keys[3] = strdup("stupid-test-8"); + keys[4] = NULL; + if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_AND | ORTE_GPR_TOKENS_OR, + "test-put-segment", + NULL, keys, + &cnt, &values))) { + fprintf(test_out, "gpr_test: get failed with error code %s\n", + ORTE_ERROR_NAME(rc)); + test_failure("gpr_test: get failed"); + test_finalize(); + return rc; + } else { + fprintf(test_out, "gpr_test: get with no tokens, KEYS_AND passed\n"); + } + for (i=0; i < 4; i++) free(keys[i]); + free(names[0]); + + fprintf(stderr, "get results:\n"); + for (j=0; j < cnt; j++) { + fprintf(stderr, "value %lu: cnt %lu\t segment %s num_tokens %lu\n", + (unsigned long) j, (unsigned long) values[j]->cnt, + values[j]->segment, (unsigned long) values[j]->num_tokens); + for (i=0; i < values[j]->num_tokens; i++) { + fprintf(stderr, "token: %lu %s\n", (unsigned long) i, + values[j]->tokens[i]); + } + kvals = values[j]->keyvals; + for (i=0; i < values[j]->cnt; i++) { + fprintf(stderr, "\tkey %s type %d\n", kvals[i]->key, kvals[i]->type); + } + OBJ_RELEASE(values[j]); + } + free(values); + fprintf(stderr, "now finalize and see if all memory cleared\n"); test_component_close(&handle); orte_dps_close(); diff --git a/test/mca/ns/ns_replica.c b/test/mca/ns/ns_replica.c index 1b59184163..17d59f561d 100644 --- a/test/mca/ns/ns_replica.c +++ b/test/mca/ns/ns_replica.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) orte_jobid_t job; orte_vpid_t vpid; int i, j, rc; - char *tmp; + char *tmp, *site, *resource; test_component_handle_t ns_handle; mca_ns_base_component_t *ns_component = NULL; mca_ns_base_module_t *ns_module = NULL; @@ -130,7 +130,7 @@ int main(int argc, char **argv) free(test_name); /* create a cellid */ - if (ORTE_SUCCESS != (rc = ns_module->create_cellid(&cell))) { /* got error */ + if (ORTE_SUCCESS != (rc = ns_module->create_cellid(&cell, "dummy-site", "dummy-resource"))) { /* got error */ test_failure("test_ns_replica orte_ns test create_cellid failed"); fprintf(test_out, "create cellid: error with error %s\n", ORTE_ERROR_NAME(rc)); test_finalize(); @@ -140,6 +140,17 @@ int main(int argc, char **argv) test_success(); } + /* get cellid info */ + if (ORTE_SUCCESS != (rc = ns_module->get_cell_info(cell, &site, &resource))) { /* got error */ + test_failure("test_ns_replica orte_ns test get_cell_info failed"); + fprintf(test_out, "get_cell_info: error with error %s\n", ORTE_ERROR_NAME(rc)); + test_finalize(); + exit(1); + } else { + fprintf(test_out, "get_cell_info: %lu %s %s\n", (unsigned long) cell, site, resource); + test_success(); + } + for (i=0; i<10; i++) { /* loop through */ /* create jobid */ if (ORTE_SUCCESS != (rc = ns_module->create_jobid(&job))) { /* got error */ diff --git a/test/mca/rds/Makefile.am b/test/mca/rds/Makefile.am index 9f0c3b59b1..aa1df83236 100644 --- a/test/mca/rds/Makefile.am +++ b/test/mca/rds/Makefile.am @@ -19,7 +19,8 @@ include $(top_srcdir)/config/Makefile.options AM_CPPFLAGS = -I$(top_srcdir)/test/support check_PROGRAMS = \ - test_rds + test_rds \ + test_rds2 TESTS = \ $(check_PROGRAMS) @@ -29,3 +30,9 @@ test_rds_LDADD = \ $(top_builddir)/test/support/libsupport.a \ $(top_builddir)/src/libmpi.la test_rds_DEPENDENCIES = $(test_rds_LDADD) + +test_rds2_SOURCES = test_rds2.c +test_rds2_LDADD = \ + $(top_builddir)/test/support/libsupport.a \ + $(top_builddir)/src/libmpi.la +test_rds2_DEPENDENCIES = $(test_rds2_LDADD) diff --git a/test/mca/rds/test_rds.c b/test/mca/rds/test_rds.c index a5d4047808..c951d27e7f 100644 --- a/test/mca/rds/test_rds.c +++ b/test/mca/rds/test_rds.c @@ -31,6 +31,7 @@ #include "util/output.h" #include "mca/gpr/base/base.h" +#include "mca/ns/base/base.h" #include "mca/rds/base/base.h" /* output files needed by the test */ @@ -45,9 +46,11 @@ main(int argc, char **argv) int rc; bool allow, have; int priority; - test_component_handle_t gpr_handle; + test_component_handle_t gpr_handle, ns_handle; mca_gpr_base_component_t *gpr_component = NULL; orte_gpr_base_module_t *gpr_module = NULL; + mca_ns_base_component_t *ns_component = NULL; + mca_ns_base_module_t *ns_module = NULL; test_component_handle_t rds_handle; orte_rds_base_component_t *rds_component = NULL; orte_rds_base_module_t *rds_module = NULL; @@ -68,6 +71,9 @@ main(int argc, char **argv) /* ENSURE THE GPR REPLICA IS ISOLATED */ setenv("OMPI_MCA_gpr_replica_isolate", "1", 1); + /* ensure the NS replica is isolated */ + setenv("OMPI_MCA_ns_replica_isolate", "1", 1); + /* Open up the output streams */ if (!ompi_output_init()) { return OMPI_ERROR; @@ -107,7 +113,19 @@ main(int argc, char **argv) exit (1); } - /* Open the gpr replica component and initialize a module */ + /* Open the ns replica component and initialize a module */ + if (OMPI_SUCCESS != + test_component_open("ns", "replica", &ns_handle, + (mca_base_component_t**) &ns_component) || + NULL == ns_component) { + test_fail_stop("Could not open ns replica\n", 1); + } + ns_module = ns_component->ns_init(&priority); + if (NULL == ns_module) { + test_fail_stop("NS replica component did not return a module\n", 1); + } + + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &gpr_handle, (mca_base_component_t**) &gpr_component) || @@ -137,9 +155,33 @@ main(int argc, char **argv) if (NULL == rds_module) { test_fail_stop("rds hostfile component did not return a module\n", 1); } - fprintf(test_out, "RDS host component started\n"); - fprintf(stderr, "now finalize and see if all memory cleared\n"); +// rds_module->query(); + + fprintf(test_out, "RDS hostfile component executed\n"); + + if (NULL != rds_module->finalize) { + rds_module->finalize(); + } + test_component_close(&rds_handle); + + fprintf(stderr, "test the resource file component\n"); + if (OMPI_SUCCESS != + test_component_open("rds", "resfile", &rds_handle, + (mca_base_component_t**) &rds_component) || + NULL == rds_component) { + test_fail_stop("Could not open rds resource file component\n", 1); + } + rds_module = rds_component->rds_init(); + if (NULL == rds_module) { + test_fail_stop("rds resource file component did not return a module\n", 1); + } + + rds_module->query(); + + fprintf(test_out, "RDS resource file component executed\n"); + + gpr_module->dump_segments(0); if (NULL != rds_module->finalize) { rds_module->finalize(); diff --git a/test/mca/rds/test_rds2.c b/test/mca/rds/test_rds2.c new file mode 100644 index 0000000000..5a8d6ad1be --- /dev/null +++ b/test/mca/rds/test_rds2.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University. + * 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, + * 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$ + */ + +#include "orte_config.h" +#include +#include + +#include "support.h" +#include "components.h" + +#include "include/orte_constants.h" + +#include "runtime/runtime.h" +#include "mca/gpr/gpr.h" +#include "mca/rds/base/base.h" + +/* output files needed by the test */ +static FILE *test_out=NULL; + +static char *cmd_str="diff ./test_ns_replica_out ./test_ns_replica_out_std"; + + +int +main(int argc, char **argv) +{ + int rc; + + test_init("test_rds_fn"); + + if (getenv("TEST_WRITE_TO_FILE") != NULL) { + test_out = fopen( "test_rds_fn", "w+" ); + } else { + test_out = stderr; + } + if( test_out == NULL ) { + test_failure("rds_fn couldn't open test file failed"); + test_finalize(); + exit(1); + } + + orte_init(); + + orte_rds_base_query(); + + orte_gpr.dump_segments(0); + + orte_finalize(); + + fclose( test_out ); +/* result = system( cmd_str ); + if( result == 0 ) { + test_success(); + } + else { + test_failure( "test_rds failed"); + } +*/ + test_finalize(); + + exit (0); +}