From cd7d87aa7bad88f681d798dfa019fff55071c536 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 3 Oct 2006 17:40:00 +0000 Subject: [PATCH] Define the map data types for dss compatibility. Setup to debug bproc This commit was SVN r11955. --- orte/dss/dss_open_close.c | 3 +- orte/include/orte/orte_types.h | 6 +- orte/mca/pls/bproc/pls_bproc.c | 3 + orte/mca/pls/rsh/pls_rsh_module.c | 1 + orte/mca/rmaps/base/Makefile.am | 9 +- .../rmaps_data_type_compare_fns.c | 51 ++++ .../rmaps_data_type_copy_fns.c | 172 +++++++++++++ .../rmaps_data_type_packing_fns.c | 195 +++++++++++++++ .../rmaps_data_type_print_fns.c | 230 +++++++++++++++++ .../rmaps_data_type_release_fns.c | 36 +++ .../rmaps_data_type_size_fns.c | 72 ++++++ .../rmaps_data_type_unpacking_fns.c | 233 ++++++++++++++++++ orte/mca/rmaps/base/rmaps_base_open.c | 49 +++- orte/mca/rmaps/base/rmaps_private.h | 33 +++ 14 files changed, 1089 insertions(+), 4 deletions(-) create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_compare_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_copy_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_packing_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_print_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_release_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_size_fns.c create mode 100644 orte/mca/rmaps/base/data_type_support/rmaps_data_type_unpacking_fns.c diff --git a/orte/dss/dss_open_close.c b/orte/dss/dss_open_close.c index a17cb8332e..29d9fe9510 100644 --- a/orte/dss/dss_open_close.c +++ b/orte/dss/dss_open_close.c @@ -58,7 +58,8 @@ orte_dss_t orte_dss = { orte_dss_load, orte_dss_register, orte_dss_lookup_data_type, - orte_dss_dump_data_types + orte_dss_dump_data_types, + orte_dss_dump }; /** diff --git a/orte/include/orte/orte_types.h b/orte/include/orte/orte_types.h index c28c0e07ad..f7a654d331 100644 --- a/orte/include/orte/orte_types.h +++ b/orte/include/orte/orte_types.h @@ -123,8 +123,12 @@ typedef void* orte_iov_base_ptr_t; #define ORTE_CELL_DESC (orte_data_type_t) 51 /**< describe attributes of cells */ #define ORTE_SLOT_DESC (orte_data_type_t) 52 /**< describes slot allocations/reservations */ #define ORTE_RAS_NODE (orte_data_type_t) 53 /**< node information */ +#define ORTE_JOB_MAP (orte_data_type_t) 54 /**< map of process locations */ +#define ORTE_MAPPED_PROC (orte_data_type_t) 55 /**< process entry on map */ +#define ORTE_MAPPED_NODE (orte_data_type_t) 56 /**< node entry on map */ + /* DAEMON communication type */ -#define ORTE_DAEMON_CMD (orte_data_type_t) 54 /**< command flag for communicating with the daemon */ +#define ORTE_DAEMON_CMD (orte_data_type_t) 57 /**< command flag for communicating with the daemon */ /* define the starting point for dynamically assigning data types */ #define ORTE_DSS_ID_DYNAMIC 60 diff --git a/orte/mca/pls/bproc/pls_bproc.c b/orte/mca/pls/bproc/pls_bproc.c index 5f6e0bfe5d..a6f8392c06 100644 --- a/orte/mca/pls/bproc/pls_bproc.c +++ b/orte/mca/pls/bproc/pls_bproc.c @@ -1112,6 +1112,9 @@ int orte_pls_bproc_launch(orte_jobid_t jobid) { item = opal_list_get_next(item)) { orte_std_cntr_t i; map = (orte_rmaps_base_map_t*) item; + + orte_dss.dump(0, map, ORTE_JOB_MAP); + for (i = 0; i < map->num_procs; ++i) { orte_app_context_t *context = map->app; diff --git a/orte/mca/pls/rsh/pls_rsh_module.c b/orte/mca/pls/rsh/pls_rsh_module.c index cfaf21d444..e19b2c60d3 100644 --- a/orte/mca/pls/rsh/pls_rsh_module.c +++ b/orte/mca/pls/rsh/pls_rsh_module.c @@ -74,6 +74,7 @@ #include "orte/util/session_dir.h" #include "orte/runtime/orte_wait.h" +#include "orte/dss/dss.h" #include "orte/mca/ns/ns.h" #include "orte/mca/rml/rml.h" diff --git a/orte/mca/rmaps/base/Makefile.am b/orte/mca/rmaps/base/Makefile.am index 6fc3ed40fd..06dbee45d8 100644 --- a/orte/mca/rmaps/base/Makefile.am +++ b/orte/mca/rmaps/base/Makefile.am @@ -30,4 +30,11 @@ libmca_rmaps_la_SOURCES += \ base/rmaps_base_no_ops.c \ base/rmaps_base_open.c \ base/rmaps_base_receive.c \ - base/rmaps_base_find_avail.c + base/rmaps_base_find_avail.c \ + base/data_type_support/rmaps_data_type_compare_fns.c \ + base/data_type_support/rmaps_data_type_copy_fns.c \ + base/data_type_support/rmaps_data_type_packing_fns.c \ + base/data_type_support/rmaps_data_type_print_fns.c \ + base/data_type_support/rmaps_data_type_release_fns.c \ + base/data_type_support/rmaps_data_type_size_fns.c \ + base/data_type_support/rmaps_data_type_unpacking_fns.c diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_compare_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_compare_fns.c new file mode 100644 index 0000000000..265a54641d --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_compare_fns.c @@ -0,0 +1,51 @@ +/* + * 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss_internal.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_compare_map(orte_rmaps_base_map_t *value1, orte_rmaps_base_map_t *value2, orte_data_type_t type) +{ + return ORTE_EQUAL; +} + + +/* MAPPED_PROC */ +int orte_rmaps_base_compare_mapped_proc(orte_rmaps_base_proc_t *value1, orte_rmaps_base_proc_t *value2, orte_data_type_t type) +{ + return ORTE_EQUAL; +} + + + +/* MAPPED_NODE */ +int orte_rmaps_base_compare_mapped_node(orte_rmaps_base_node_t *value1, orte_rmaps_base_node_t *value2, orte_data_type_t type) +{ + return ORTE_EQUAL; +} + diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_copy_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_copy_fns.c new file mode 100644 index 0000000000..d37d430379 --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_copy_fns.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "opal/util/argv.h" +#include "opal/class/opal_list.h" + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_copy_map(orte_rmaps_base_map_t **dest, orte_rmaps_base_map_t *src, orte_data_type_t type) +{ + orte_std_cntr_t i; + int rc; + opal_list_item_t *item; + orte_rmaps_base_node_t *srcnode, *nodeptr; + + if (NULL == src) { + *dest = NULL; + return ORTE_SUCCESS; + } + + /* create the new object */ + *dest = OBJ_NEW(orte_rmaps_base_map_t); + if (NULL == *dest) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* copy data into it */ + (*dest)->app = src->app; + + (*dest)->procs = (orte_rmaps_base_proc_t**)malloc(src->num_procs * sizeof(orte_rmaps_base_proc_t)); + if (NULL == (*dest)->procs) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(*dest); + return ORTE_ERR_OUT_OF_RESOURCE; + } + for (i=0; i < src->num_procs; i++) { + if (ORTE_SUCCESS != (rc = orte_rmaps_base_copy_mapped_proc(&((*dest)->procs[i]), src->procs[i], ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(*dest); + return rc; + } + } + (*dest)->num_procs = src->num_procs; + + for (item = opal_list_get_first(&(src->nodes)); + item != opal_list_get_end(&(src->nodes)); + item = opal_list_get_next(item)) { + srcnode = (orte_rmaps_base_node_t*)item; + if (ORTE_SUCCESS != (rc = orte_rmaps_base_copy_mapped_node(&nodeptr, srcnode, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(*dest); + return rc; + } + opal_list_append(&((*dest)->nodes), &nodeptr->super); + } + + return ORTE_SUCCESS; +} + +/* + * MAPPED_PROC + */ +int orte_rmaps_base_copy_mapped_proc(orte_rmaps_base_proc_t **dest, orte_rmaps_base_proc_t *src, orte_data_type_t type) +{ + int rc; + + if (NULL == src) { + *dest = NULL; + return ORTE_SUCCESS; + } + + /* create the new object */ + *dest = OBJ_NEW(orte_rmaps_base_proc_t); + if (NULL == *dest) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* copy data into it */ + if (NULL != src->app) { + (*dest)->app = strdup(src->app); + } + + if (ORTE_SUCCESS != (rc = orte_rmaps_base_copy_mapped_node(&((*dest)->proc_node), src->proc_node, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(*dest); + return rc; + } + + (*dest)->proc_name = src->proc_name; + + (*dest)->proc_rank = src->proc_rank; + + (*dest)->pid = src->pid; + + (*dest)->local_pid = src->local_pid; + + return ORTE_SUCCESS; +} + +/* + * MAPPED_NODE + */ +int orte_rmaps_base_copy_mapped_node(orte_rmaps_base_node_t **dest, orte_rmaps_base_node_t *src, orte_data_type_t type) +{ + int rc; + opal_list_item_t *item; + orte_rmaps_base_proc_t *srcproc, *procptr; + + if (NULL == src) { + *dest = NULL; + return ORTE_SUCCESS; + } + + /* create the new object */ + *dest = OBJ_NEW(orte_rmaps_base_node_t); + if (NULL == *dest) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* copy data into it */ + if (ORTE_SUCCESS != (rc = orte_dss.copy((void**)&((*dest)->node), src->node, ORTE_RAS_NODE))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(*dest); + return rc; + } + + for (item = opal_list_get_first(&(src->node_procs)); + item != opal_list_get_end(&(src->node_procs)); + item = opal_list_get_next(item)) { + srcproc = (orte_rmaps_base_proc_t*)item; + if (ORTE_SUCCESS != (rc = orte_rmaps_base_copy_mapped_proc(&procptr, srcproc, ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(*dest); + return rc; + } + opal_list_append(&((*dest)->node_procs), &procptr->super); + } + + return ORTE_SUCCESS; + +} \ No newline at end of file diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_packing_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_packing_fns.c new file mode 100644 index 0000000000..ff5dd1bf13 --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_packing_fns.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "opal/util/argv.h" + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss_internal.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_pack_map(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i, num_nodes; + orte_rmaps_base_map_t **maps; + opal_list_item_t *item; + orte_rmaps_base_node_t *srcnode; + + /* array of pointers to orte_rmaps_base_map_t objects - need to pack the objects a set of fields at a time */ + maps = (orte_rmaps_base_map_t**) src; + + for (i=0; i < num_vals; i++) { + /* pack the app_context */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, maps[i]->app, 1, ORTE_APP_CONTEXT))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of procs */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(maps[i]->num_procs), 1, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the procs array */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, (void*)(maps[i]->procs), + maps[i]->num_procs, ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of nodes */ + num_nodes = (orte_std_cntr_t)opal_list_get_size(&(maps[i]->nodes)); + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &num_nodes, 1, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the nodes list */ + if (0 < num_nodes) { + for (item = opal_list_get_first(&(maps[i]->nodes)); + item != opal_list_get_end(&(maps[i]->nodes)); + item = opal_list_get_next(item)) { + srcnode = (orte_rmaps_base_node_t*)item; + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, (void*)srcnode, + 1, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + } + + return ORTE_SUCCESS; +} + + +/* + * MAPPED_PROC + */ +int orte_rmaps_base_pack_mapped_proc(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i; + orte_rmaps_base_proc_t **procs; + + /* array of pointers to orte_rmaps_base_proc_t objects - need to pack the objects a set of fields at a time */ + procs = (orte_rmaps_base_proc_t**) src; + + for (i=0; i < num_vals; i++) { + /* pack the app */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, procs[i]->app, 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the proc_node */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, procs[i]->proc_node, 1, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the proc name */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, (void*)(&(procs[i]->proc_name)), + 1, ORTE_NAME))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the rank */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(procs[i]->proc_rank), 1, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the pls-pid */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(procs[i]->pid), 1, ORTE_PID))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the local pid */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(procs[i]->local_pid), 1, ORTE_PID))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + + +/* + * MAPPED_NODE + */ +int orte_rmaps_base_pack_mapped_node(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i, num_procs; + orte_rmaps_base_node_t **nodes; + opal_list_item_t *item; + orte_rmaps_base_proc_t *srcproc; + + /* array of pointers to orte_rmaps_base_node_t objects - need to pack the objects a set of fields at a time */ + nodes = (orte_rmaps_base_node_t**) src; + + for (i=0; i < num_vals; i++) { + /* pack the node object */ + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, nodes[i]->node, 1, ORTE_RAS_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of procs */ + num_procs = (orte_std_cntr_t)opal_list_get_size(&(nodes[i]->node_procs)); + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &num_procs, 1, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the procs list */ + if (0 < num_procs) { + for (item = opal_list_get_first(&(nodes[i]->node_procs)); + item != opal_list_get_end(&(nodes[i]->node_procs)); + item = opal_list_get_next(item)) { + srcproc = (orte_rmaps_base_proc_t*)item; + if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, (void*)srcproc, + 1, ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + } + return ORTE_SUCCESS; +} + diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_print_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_print_fns.c new file mode 100644 index 0000000000..9812f481ac --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_print_fns.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "opal/util/argv.h" +#include "opal/class/opal_list.h" + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_print_map(char **output, char *prefix, orte_rmaps_base_map_t *src, orte_data_type_t type) +{ + char *tmp, *tmp2, *tmp3, *pfx, *pfx2; + orte_rmaps_base_node_t *srcnode; + orte_std_cntr_t i, num_nodes; + opal_list_item_t *item; + int rc; + + /* set default result */ + *output = NULL; + + /* protect against NULL prefix */ + if (NULL == prefix) { + asprintf(&pfx2, " "); + } else { + asprintf(&pfx2, "%s", prefix); + } + + asprintf(&tmp, "%sMap for app_context:", pfx2); + + asprintf(&pfx, "%s\t", pfx2); + free(pfx2); + + if (ORTE_SUCCESS != (rc = orte_dss.print(&tmp2, pfx, src->app, ORTE_APP_CONTEXT))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp); + return rc; + } + asprintf(&tmp3, "%s\n%s\n%sNum elements in procs array: %ld", tmp, tmp2, pfx, (long)src->num_procs); + free(tmp); + free(tmp2); + + for (i=0; i < src->num_procs; i++) { + if (ORTE_SUCCESS != (rc = orte_rmaps_base_print_mapped_proc(&tmp, pfx, src->procs[i], ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp3); + return rc; + } + asprintf(&tmp2, "%s\n%s", tmp3, tmp); + free(tmp); + free(tmp3); + tmp3 = tmp2; + } + + num_nodes = (orte_std_cntr_t)opal_list_get_size(&(src->nodes)); + asprintf(&tmp, "%s\n%sNum elements in nodes list: %ld", tmp3, pfx, (long)num_nodes); + + for (item = opal_list_get_first(&(src->nodes)); + item != opal_list_get_end(&(src->nodes)); + item = opal_list_get_next(item)) { + srcnode = (orte_rmaps_base_node_t*)item; + if (ORTE_SUCCESS != (rc = orte_rmaps_base_print_mapped_node(&tmp2, pfx, srcnode, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp); + return rc; + } + asprintf(&tmp3, "%s\n%s", tmp, tmp2); + free(tmp); + free(tmp2); + tmp = tmp3; + } + + /* set the return */ + *output = tmp; + + free(pfx); + return ORTE_SUCCESS; +} + + +/* + * MAPPED_PROC + */ +int orte_rmaps_base_print_mapped_proc(char **output, char *prefix, orte_rmaps_base_proc_t *src, orte_data_type_t type) +{ + char *tmp, *tmp2, *tmp3, *pfx, *pfx2; + int rc; + + /* set default result */ + *output = NULL; + + /* protect against NULL prefix */ + if (NULL == prefix) { + asprintf(&pfx2, " "); + } else { + asprintf(&pfx2, "%s", prefix); + } + + asprintf(&tmp, "%sMapped proc:", pfx2); + + asprintf(&pfx, "%s\t", pfx2); + + if (NULL != src->app) { + asprintf(&tmp2, "%s\n%sApp name: %s", tmp, pfx, src->app); + } else { + asprintf(&tmp2, "%s\n%sApplication has NULL name", tmp, pfx); + } + free(tmp); + + if (ORTE_SUCCESS != (rc = orte_rmaps_base_print_mapped_node(&tmp, pfx, src->proc_node, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp2); + return rc; + } + asprintf(&tmp3, "%s\n%s\n%s\n%sProc Name:", tmp2, pfx, tmp, pfx); + free(tmp2); + free(tmp); + + if (ORTE_SUCCESS != (rc = orte_dss.print(&tmp2, pfx, &(src->proc_name), ORTE_NAME))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp3); + return rc; + } + asprintf(&tmp, "%s\n%s\n%sProc Rank: %ld\tPLS pid: %ld\tLocal PID: %ld\n", tmp3, tmp2, pfx, + (long)src->proc_rank, (long)src->pid, (long)src->local_pid); + free(tmp2); + free(tmp3); + + /* set the return */ + *output = tmp; + + free(pfx); + free(pfx2); + return ORTE_SUCCESS; +} + +/* + * MAPPED_NODE + */ +int orte_rmaps_base_print_mapped_node(char **output, char *prefix, orte_rmaps_base_node_t *src, orte_data_type_t type) +{ + int rc; + char *tmp, *tmp2, *tmp3, *pfx, *pfx2; + orte_std_cntr_t num_procs; +#if 0 + opal_list_item_t *item; + orte_rmaps_base_proc_t *srcproc; +#endif + + /* set default result */ + *output = NULL; + + /* protect against NULL prefix */ + if (NULL == prefix) { + asprintf(&pfx2, " "); + } else { + asprintf(&pfx2, "%s", prefix); + } + + asprintf(&tmp, "%sMapped node:", pfx2); + + asprintf(&pfx, "%s\t", pfx2); + free(pfx2); + + if (ORTE_SUCCESS != (rc = orte_dss.print(&tmp2, pfx, src->node, ORTE_RAS_NODE))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp); + return rc; + } + + num_procs = (orte_std_cntr_t)opal_list_get_size(&(src->node_procs)); + asprintf(&tmp3, "%s\n%s\n%sNum elements in procs list: %ld", tmp, tmp2, pfx, (long)num_procs); + free(tmp); + free(tmp2); +#if 0 + for (item = opal_list_get_first(&(src->node_procs)); + item != opal_list_get_end(&(src->node_procs)); + item = opal_list_get_next(item)) { + srcproc = (orte_rmaps_base_proc_t*)item; + if (ORTE_SUCCESS != (rc = orte_rmaps_base_print_mapped_proc(&tmp2, pfx, srcproc, ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + free(pfx); + free(tmp); + return rc; + } + asprintf(&tmp, "%s\n%s", tmp3, tmp2); + free(tmp3); + free(tmp2); + tmp3 = tmp; + } +#endif + /* set the return */ + *output = tmp3; + + free(pfx); + return ORTE_SUCCESS; +} + diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_release_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_release_fns.c new file mode 100644 index 0000000000..43cade79a3 --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_release_fns.c @@ -0,0 +1,36 @@ +/* + * 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss_internal.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * STANDARD OBJECT RELEASE + */ +void orte_rmaps_base_std_obj_release(orte_data_value_t *value) +{ + OBJ_RELEASE(value->data); +} + diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_size_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_size_fns.c new file mode 100644 index 0000000000..cbb1be5f27 --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_size_fns.c @@ -0,0 +1,72 @@ +/* + * 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 +#if HAVE_NETINET_IN_H +#include +#endif + +#include "opal/util/argv.h" +#include "opal/class/opal_list.h" + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_size_map(size_t *size, orte_rmaps_base_map_t *src, orte_data_type_t type) +{ + /* account for the object itself */ + *size = sizeof(orte_rmaps_base_map_t); + + /* if src is NULL, then that's all we wanted */ + if (NULL == src) return ORTE_SUCCESS; + + return ORTE_SUCCESS; +} + +/* + * MAPPED_PROC + */ +int orte_rmaps_base_size_mapped_proc(size_t *size, orte_rmaps_base_proc_t *src, orte_data_type_t type) +{ + /* account for the object itself */ + *size = sizeof(orte_rmaps_base_proc_t); + + /* if src is NULL, then that's all we wanted */ + if (NULL == src) return ORTE_SUCCESS; + + return ORTE_SUCCESS; +} + +/* + * MAPPED_NODE + */ +int orte_rmaps_base_size_mapped_node(size_t *size, orte_rmaps_base_node_t *src, orte_data_type_t type) +{ + /* account for the object itself */ + *size = sizeof(orte_rmaps_base_node_t); + + /* if src is NULL, then that's all we wanted */ + if (NULL == src) return ORTE_SUCCESS; + + return ORTE_SUCCESS; +} diff --git a/orte/mca/rmaps/base/data_type_support/rmaps_data_type_unpacking_fns.c b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_unpacking_fns.c new file mode 100644 index 0000000000..4904953b08 --- /dev/null +++ b/orte/mca/rmaps/base/data_type_support/rmaps_data_type_unpacking_fns.c @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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 "orte/orte_constants.h" +#include "orte/orte_types.h" + +#include +#if HAVE_NETINET_IN_H +#include +#endif + +#include "opal/class/opal_list.h" + +#include "orte/mca/errmgr/errmgr.h" +#include "orte/dss/dss_internal.h" + +#include "orte/mca/rmaps/base/rmaps_private.h" + +/* + * JOB_MAP + */ +int orte_rmaps_base_unpack_map(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i, j, n, num_nodes; + orte_rmaps_base_map_t **maps; + orte_rmaps_base_node_t *node; + + /* unpack into array of orte_rmaps_base_map_t objects */ + maps = (orte_rmaps_base_map_t**) dest; + for (i=0; i < *num_vals; i++) { + + /* create the orte_rmaps_base_map_t object */ + maps[i] = OBJ_NEW(orte_rmaps_base_map_t); + if (NULL == maps[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the app_context */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(maps[i]->app), &n, ORTE_APP_CONTEXT))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the number of procs */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(maps[i]->num_procs), &n, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if we have some, allocate space for them */ + if (0 < maps[i]->num_procs) { + maps[i]->procs = (orte_rmaps_base_proc_t**)malloc(maps[i]->num_procs * sizeof(orte_rmaps_base_proc_t*)); + if (NULL == maps[i]->procs) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, maps[i]->procs, &(maps[i]->num_procs), ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* unpack the number of nodes */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &num_nodes, &n, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + for (j=0; j < num_nodes; j++) { + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &node, &n, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + opal_list_append(&(maps[i]->nodes), &node->super); + } + } + + return ORTE_SUCCESS; +} + +/* + * MAPPED_PROC + */ +int orte_rmaps_base_unpack_mapped_proc(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i, n; + orte_rmaps_base_proc_t **procs; + + /* unpack into array of orte_rmaps_base_proc_t objects */ + procs = (orte_rmaps_base_proc_t**) dest; + for (i=0; i < *num_vals; i++) { + + /* create the orte_rmaps_base_proc_t object */ + procs[i] = OBJ_NEW(orte_rmaps_base_proc_t); + if (NULL == procs[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the app name */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->app), &n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the proc_node */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->proc_node), &n, ORTE_MAPPED_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the proc name */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->proc_name), &n, ORTE_NAME))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the rank */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->proc_rank), &n, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the pls-pid */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->pid), &n, ORTE_PID))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the local pid */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(procs[i]->local_pid), &n, ORTE_PID))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + +/* + * MAPPED_NODE + */ +int orte_rmaps_base_unpack_mapped_node(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_std_cntr_t i, j, n, num_procs; + orte_rmaps_base_node_t **nodes; + orte_rmaps_base_proc_t *srcproc; + + /* unpack into array of orte_rmaps_base_node_t objects */ + nodes = (orte_rmaps_base_node_t**) dest; + for (i=0; i < *num_vals; i++) { + + /* create the orte_rmaps_base_node_t object */ + nodes[i] = OBJ_NEW(orte_rmaps_base_node_t); + if (NULL == nodes[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the node object */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, + &(nodes[i]->node), &n, ORTE_RAS_NODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the number of procs */ + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &num_procs, &n, ORTE_STD_CNTR))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if we have some, unpack them */ + if (0 < num_procs) { + for (j=0; j < num_procs; j++) { + n = 1; + if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &srcproc, &n, ORTE_MAPPED_PROC))) { + ORTE_ERROR_LOG(rc); + return rc; + } + opal_list_append(&(nodes[i]->node_procs), &srcproc->super); + } + } + } + + return ORTE_SUCCESS; +} + + diff --git a/orte/mca/rmaps/base/rmaps_base_open.c b/orte/mca/rmaps/base/rmaps_base_open.c index 3ac5799f53..873b83b52a 100644 --- a/orte/mca/rmaps/base/rmaps_base_open.c +++ b/orte/mca/rmaps/base/rmaps_base_open.c @@ -25,6 +25,9 @@ #include "opal/mca/base/mca_base_param.h" #include "opal/util/output.h" +#include "orte/dss/dss.h" +#include "orte/mca/errmgr/errmgr.h" + #include "orte/mca/rmaps/base/rmaps_private.h" #include "orte/mca/rmaps/base/base.h" @@ -62,8 +65,9 @@ orte_rmaps_base_module_t orte_rmaps_no_op = { */ int orte_rmaps_base_open(void) { - int param, value; + int param, rc, value; char *policy, *requested; + orte_data_type_t tmp; /* Debugging / verbose output */ @@ -102,6 +106,49 @@ int orte_rmaps_base_open(void) orte_rmaps_base.oversubscribe = false; } + /** register the base system types with the DSS */ + tmp = ORTE_JOB_MAP; + if (ORTE_SUCCESS != (rc = orte_dss.register_type(orte_rmaps_base_pack_map, + orte_rmaps_base_unpack_map, + (orte_dss_copy_fn_t)orte_rmaps_base_copy_map, + (orte_dss_compare_fn_t)orte_rmaps_base_compare_map, + (orte_dss_size_fn_t)orte_rmaps_base_size_map, + (orte_dss_print_fn_t)orte_rmaps_base_print_map, + (orte_dss_release_fn_t)orte_rmaps_base_std_obj_release, + ORTE_DSS_STRUCTURED, + "ORTE_JOB_MAP", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_MAPPED_PROC; + if (ORTE_SUCCESS != (rc = orte_dss.register_type(orte_rmaps_base_pack_mapped_proc, + orte_rmaps_base_unpack_mapped_proc, + (orte_dss_copy_fn_t)orte_rmaps_base_copy_mapped_proc, + (orte_dss_compare_fn_t)orte_rmaps_base_compare_mapped_proc, + (orte_dss_size_fn_t)orte_rmaps_base_size_mapped_proc, + (orte_dss_print_fn_t)orte_rmaps_base_print_mapped_proc, + (orte_dss_release_fn_t)orte_rmaps_base_std_obj_release, + ORTE_DSS_STRUCTURED, + "ORTE_MAPPED_PROC", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_MAPPED_NODE; + if (ORTE_SUCCESS != (rc = orte_dss.register_type(orte_rmaps_base_pack_mapped_node, + orte_rmaps_base_unpack_mapped_node, + (orte_dss_copy_fn_t)orte_rmaps_base_copy_mapped_node, + (orte_dss_compare_fn_t)orte_rmaps_base_compare_mapped_node, + (orte_dss_size_fn_t)orte_rmaps_base_size_mapped_node, + (orte_dss_print_fn_t)orte_rmaps_base_print_mapped_node, + (orte_dss_release_fn_t)orte_rmaps_base_std_obj_release, + ORTE_DSS_STRUCTURED, + "ORTE_MAPPED_NODE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Some systems do not want any RMAPS support. In those cases, * memory consumption is also an issue. For those systems, we diff --git a/orte/mca/rmaps/base/rmaps_private.h b/orte/mca/rmaps/base/rmaps_private.h index 1aa0db0b23..8ec5c0e033 100644 --- a/orte/mca/rmaps/base/rmaps_private.h +++ b/orte/mca/rmaps/base/rmaps_private.h @@ -117,6 +117,39 @@ int orte_rmaps_base_claim_slot(orte_rmaps_base_map_t *map, int orte_rmaps_base_set_vpid_range(orte_jobid_t jobid, orte_vpid_t start, orte_vpid_t range); int orte_rmaps_base_get_vpid_range(orte_jobid_t jobid, orte_vpid_t *start, orte_vpid_t *range); +/** Local data type functions */ +void orte_rmaps_base_std_obj_release(orte_data_value_t *value); + +/* JOB_MAP */ +int orte_rmaps_base_copy_map(orte_rmaps_base_map_t **dest, orte_rmaps_base_map_t *src, orte_data_type_t type); +int orte_rmaps_base_compare_map(orte_rmaps_base_map_t *value1, orte_rmaps_base_map_t *value2, orte_data_type_t type); +int orte_rmaps_base_pack_map(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type); +int orte_rmaps_base_print_map(char **output, char *prefix, orte_rmaps_base_map_t *src, orte_data_type_t type); +int orte_rmaps_base_size_map(size_t *size, orte_rmaps_base_map_t *src, orte_data_type_t type); +int orte_rmaps_base_unpack_map(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type); + +/* MAPPED_PROC */ +int orte_rmaps_base_copy_mapped_proc(orte_rmaps_base_proc_t **dest, orte_rmaps_base_proc_t *src, orte_data_type_t type); +int orte_rmaps_base_compare_mapped_proc(orte_rmaps_base_proc_t *value1, orte_rmaps_base_proc_t *value2, orte_data_type_t type); +int orte_rmaps_base_pack_mapped_proc(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type); +int orte_rmaps_base_print_mapped_proc(char **output, char *prefix, orte_rmaps_base_proc_t *src, orte_data_type_t type); +int orte_rmaps_base_size_mapped_proc(size_t *size, orte_rmaps_base_proc_t *src, orte_data_type_t type); +int orte_rmaps_base_unpack_mapped_proc(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type); + +/* MAPPED_NODE */ +int orte_rmaps_base_copy_mapped_node(orte_rmaps_base_node_t **dest, orte_rmaps_base_node_t *src, orte_data_type_t type); +int orte_rmaps_base_compare_mapped_node(orte_rmaps_base_node_t *value1, orte_rmaps_base_node_t *value2, orte_data_type_t type); +int orte_rmaps_base_pack_mapped_node(orte_buffer_t *buffer, void *src, + orte_std_cntr_t num_vals, orte_data_type_t type); +int orte_rmaps_base_print_mapped_node(char **output, char *prefix, orte_rmaps_base_node_t *src, orte_data_type_t type); +int orte_rmaps_base_size_mapped_node(size_t *size, orte_rmaps_base_node_t *src, orte_data_type_t type); +int orte_rmaps_base_unpack_mapped_node(orte_buffer_t *buffer, void *dest, + orte_std_cntr_t *num_vals, orte_data_type_t type); + /* * external API functions will be documented in the mca/rmaps/rmaps.h file */