From bcd47973891468f8d2e37e0c6bcc0f7ed028859a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sun, 1 May 2005 00:58:06 +0000 Subject: [PATCH] Commit 4 of 4 for bringing the changes over from the hetero branch. Merged in from: svn merge -r5506:5553 https://svn.open-mpi.org/svn/ompi/tmp/hetero . This commit was SVN r5552. The following SVN revisions from the original message are invalid or inconsistent and therefore were not cross-referenced: r5506 r5553 --- config/ompi_mca.m4 | 7 +- configure.ac | 4 + src/Makefile.am | 10 +- src/class/orte_pointer_array.h | 3 +- src/class/orte_value_array.c | 1 + src/dps/Makefile.am | 2 + src/dps/dps.h | 33 ++ src/dps/dps_internal.h | 60 ++- src/dps/dps_internal_functions.c | 11 +- src/dps/dps_lookup.c | 38 ++ src/dps/dps_pack.c | 67 ++-- src/dps/dps_peek.c | 28 +- src/dps/dps_register.c | 68 ++++ src/dps/dps_unpack.c | 192 ++++++--- src/dps/orte_dps_open_close.c | 116 +++--- src/mca/gpr/base/Makefile.am | 2 +- src/mca/gpr/base/base.h | 49 +++ .../gpr/base/data_type_support/Makefile.am | 38 ++ .../gpr_data_type_packing_fns.c | 311 +++++++++++++++ .../gpr_data_type_unpacking_fns.c | 373 ++++++++++++++++++ .../gpr_type_notify_action.c | 0 src/mca/gpr/base/gpr_base_open.c | 69 +++- src/mca/gpr/gpr_types.h | 7 +- .../gpr_replica_cmd_processor.c | 11 +- .../gpr_replica_messaging_fn.c | 2 - .../functional_layer/gpr_replica_put_get_fn.c | 2 - src/mca/ns/base/Makefile.am | 4 +- src/mca/ns/base/base.h | 31 +- src/mca/ns/base/data_type_support/Makefile.am | 38 ++ .../ns_data_type_packing_fns.c | 167 ++++++++ .../ns_data_type_unpacking_fns.c | 165 ++++++++ src/mca/ns/base/ns_base_local_fns.c | 14 - src/mca/ns/base/ns_base_open.c | 40 +- src/mca/ns/ns.h | 18 +- src/mca/ns/proxy/src/ns_proxy.c | 75 +--- src/mca/ns/proxy/src/ns_proxy.h | 12 +- src/mca/ns/proxy/src/ns_proxy_component.c | 3 - src/mca/ns/replica/src/ns_replica.c | 93 +---- src/mca/ns/replica/src/ns_replica.h | 10 +- src/mca/ns/replica/src/ns_replica_component.c | 15 +- src/mca/rmgr/base/Makefile.am | 2 + src/mca/rmgr/base/base.h | 19 + .../rmgr/base/data_type_support/Makefile.am | 38 ++ .../rmgr_data_type_packing_fns.c | 148 +++++++ .../rmgr_data_type_unpacking_fns.c | 188 +++++++++ src/mca/rmgr/base/rmgr_base_open.c | 26 +- src/mca/schema/base/schema_base_fns.c | 158 ++++++++ src/mca/schema/schema_types.h | 15 +- src/mca/soh/base/Makefile.am | 2 + src/mca/soh/base/base.h | 25 ++ .../soh/base/data_type_support/Makefile.am | 38 ++ .../soh_data_type_packing_fns.c | 72 ++++ .../soh_data_type_unpacking_fns.c | 72 ++++ src/mca/soh/base/soh_base_open.c | 35 +- src/runtime/orte_init.c | 62 +-- src/runtime/orte_init_stage1.c | 16 +- src/tools/console/orteconsole.c | 2 +- src/tools/orted/orted.c | 2 +- test/dps/dps_test.c | 185 ++++++--- test/mca/gpr/gpr_internal_fns.c | 46 ++- test/mca/gpr/gpr_mem_leaks.c | 48 ++- test/mca/gpr/gpr_overwrite.c | 46 ++- test/mca/gpr/gpr_put_get.c | 48 ++- test/mca/gpr/gpr_threads.c | 2 +- test/mca/gpr/gpr_triggers.c | 45 +++ test/mca/ns/ns_replica.c | 2 +- 66 files changed, 3016 insertions(+), 515 deletions(-) create mode 100644 src/dps/dps_lookup.c create mode 100644 src/dps/dps_register.c create mode 100644 src/mca/gpr/base/data_type_support/Makefile.am create mode 100644 src/mca/gpr/base/data_type_support/gpr_data_type_packing_fns.c create mode 100644 src/mca/gpr/base/data_type_support/gpr_data_type_unpacking_fns.c delete mode 100644 src/mca/gpr/base/data_type_support/gpr_type_notify_action.c create mode 100644 src/mca/ns/base/data_type_support/Makefile.am create mode 100644 src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c create mode 100644 src/mca/ns/base/data_type_support/ns_data_type_unpacking_fns.c create mode 100644 src/mca/rmgr/base/data_type_support/Makefile.am create mode 100644 src/mca/rmgr/base/data_type_support/rmgr_data_type_packing_fns.c create mode 100644 src/mca/rmgr/base/data_type_support/rmgr_data_type_unpacking_fns.c create mode 100644 src/mca/soh/base/data_type_support/Makefile.am create mode 100644 src/mca/soh/base/data_type_support/soh_data_type_packing_fns.c create mode 100644 src/mca/soh/base/data_type_support/soh_data_type_unpacking_fns.c diff --git a/config/ompi_mca.m4 b/config/ompi_mca.m4 index c63dda10d3..70008d9f12 100644 --- a/config/ompi_mca.m4 +++ b/config/ompi_mca.m4 @@ -157,7 +157,7 @@ unset msg # The list of MCA types (it's fixed) AC_MSG_CHECKING([for MCA types]) -found_types="common allocator coll errmgr gpr io iof mpool ns oob pls pml ptl ras rds rmaps rmgr rml soh topo" +found_types="common allocator coll errmgr gpr io iof mpool ns oob pls pml ptl ras rds rmaps rmgr rml schema soh topo" AC_MSG_RESULT([$found_types]) # Get the list of all the non-configure MCA components that were found by @@ -530,6 +530,11 @@ AC_SUBST(MCA_rml_STATIC_SUBDIRS) AC_SUBST(MCA_rml_DSO_SUBDIRS) AC_SUBST(MCA_rml_STATIC_LTLIBS) +AC_SUBST(MCA_schema_ALL_SUBDIRS) +AC_SUBST(MCA_schema_STATIC_SUBDIRS) +AC_SUBST(MCA_schema_DSO_SUBDIRS) +AC_SUBST(MCA_schema_STATIC_LTLIBS) + AC_SUBST(MCA_soh_ALL_SUBDIRS) AC_SUBST(MCA_soh_STATIC_SUBDIRS) AC_SUBST(MCA_soh_DSO_SUBDIRS) diff --git a/configure.ac b/configure.ac index 4e073dfc73..499d685ea3 100644 --- a/configure.ac +++ b/configure.ac @@ -1677,10 +1677,12 @@ AC_CONFIG_FILES([ src/mca/iof/base/Makefile src/mca/gpr/Makefile src/mca/gpr/base/Makefile + src/mca/gpr/base/data_type_support/Makefile src/mca/gpr/base/pack_api_cmd/Makefile src/mca/gpr/base/unpack_api_response/Makefile src/mca/ns/Makefile src/mca/ns/base/Makefile + src/mca/ns/base/data_type_support/Makefile src/mca/oob/Makefile src/mca/oob/base/Makefile src/mca/pls/Makefile @@ -1693,10 +1695,12 @@ AC_CONFIG_FILES([ src/mca/rmaps/base/Makefile src/mca/rmgr/Makefile src/mca/rmgr/base/Makefile + src/mca/rmgr/base/data_type_support/Makefile src/mca/schema/Makefile src/mca/schema/base/Makefile src/mca/soh/Makefile src/mca/soh/base/Makefile + src/mca/soh/base/data_type_support/Makefile src/mca/allocator/Makefile src/mca/allocator/base/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 1019415c22..a585de80e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -128,12 +128,12 @@ lib_LTLIBRARIES = libmpi.la libmpi_la_SOURCES = libmpi_la_LIBADD = \ $(LIBLTDL_LTLIB) \ - asm/libasm.la \ + asm/libasm.la \ attribute/libattribute.la \ class/liblfc.la \ communicator/libcommunicator.la \ datatype/libdatatype.la \ - dps/libdps.la \ + dps/libdps.la \ errhandler/liberrhandler.la \ event/libevent.la \ file/libfile.la \ @@ -144,6 +144,7 @@ libmpi_la_LIBADD = \ mca/coll/base/libmca_coll_base.la $(MCA_coll_STATIC_LTLIBS) \ $(MCA_common_STATIC_LTLIBS) \ mca/errmgr/base/libmca_errmgr_base.la \ + mca/gpr/base/data_type_support/libmca_gpr_base_data_type.la \ mca/gpr/base/pack_api_cmd/libmca_gpr_base_pack.la \ mca/gpr/base/unpack_api_response/libmca_gpr_base_unpack.la \ mca/gpr/base/libmca_gpr_base.la $(MCA_gpr_STATIC_LTLIBS) \ @@ -151,6 +152,7 @@ libmpi_la_LIBADD = \ mca/iof/base/libmca_iof_base.la $(MCA_iof_STATIC_LTLIBS) \ mca/mpool/base/libmca_mpool_base.la $(MCA_mpool_STATIC_LTLIBS) \ mca/ns/base/libmca_ns_base.la $(MCA_ns_STATIC_LTLIBS) \ + mca/ns/base/data_type_support/libmca_ns_base_data_type.la \ mca/oob/base/libmca_oob_base.la $(MCA_oob_STATIC_LTLIBS) \ mca/pls/base/libmca_pls_base.la $(MCA_pls_STATIC_LTLIBS) \ mca/pml/base/libmca_pml_base.la $(MCA_pml_STATIC_LTLIBS) \ @@ -159,9 +161,11 @@ libmpi_la_LIBADD = \ mca/rds/base/libmca_rds_base.la $(MCA_rds_STATIC_LTLIBS) \ mca/rmaps/base/libmca_rmaps_base.la $(MCA_rmaps_STATIC_LTLIBS) \ mca/rmgr/base/libmca_orte_rmgr_base.la $(MCA_rmgr_STATIC_LTLIBS) \ + mca/rmgr/base/data_type_support/libmca_rmgr_base_data_type.la \ mca/rml/base/libmca_rml_base.la $(MCA_rml_STATIC_LTLIBS) \ - mca/schema/base/libmca_schema_base.la \ + mca/schema/base/libmca_schema_base.la $(MCA_schema_STATIC_LTLIBS) \ mca/soh/base/libmca_soh_base.la $(MCA_soh_STATIC_LTLIBS) \ + mca/soh/base/data_type_support/libmca_soh_base_data_type.la \ mca/topo/base/libmca_topo_base.la $(MCA_topo_STATIC_LTLIBS) \ mpi/c/libmpi_c.la $(c_mpi_lib) $(c_pmpi_lib) \ $(f77_base_lib) $(f77_mpi_lib) $(f77_pmpi_lib) \ diff --git a/src/class/orte_pointer_array.h b/src/class/orte_pointer_array.h index f3d687aaf4..ae164237f4 100644 --- a/src/class/orte_pointer_array.h +++ b/src/class/orte_pointer_array.h @@ -98,7 +98,8 @@ OMPI_DECLSPEC int orte_pointer_array_add(size_t *index, orte_pointer_array_t *ar /** * Set the value of an element in array - * + * Automatically extend array if required. + * * @param array Pointer to array (IN) * @param index Index of element to be reset (IN) * @param value New value to be set at element index (IN) diff --git a/src/class/orte_value_array.c b/src/class/orte_value_array.c index 0191845049..aa04e5c6cf 100644 --- a/src/class/orte_value_array.c +++ b/src/class/orte_value_array.c @@ -59,6 +59,7 @@ int orte_value_array_set_size(orte_value_array_t* array, size_t size) if (NULL == array->array_items) return ORTE_ERR_OUT_OF_RESOURCE; } + array->array_size = size; return ORTE_SUCCESS; } diff --git a/src/dps/Makefile.am b/src/dps/Makefile.am index d86bfa4b5a..25605f8309 100644 --- a/src/dps/Makefile.am +++ b/src/dps/Makefile.am @@ -29,8 +29,10 @@ libdps_la_SOURCES = \ $(headers) \ dps_internal_functions.c \ dps_load_unload.c \ + dps_lookup.c \ dps_pack.c \ dps_peek.c \ + dps_register.c \ dps_unpack.c \ orte_dps_open_close.c diff --git a/src/dps/dps.h b/src/dps/dps.h index f4bb46b145..5d4105e1ff 100644 --- a/src/dps/dps.h +++ b/src/dps/dps.h @@ -333,6 +333,37 @@ OMPI_DECLSPEC int orte_dps_open(void); OMPI_DECLSPEC int orte_dps_close(void); +/** + * Register a pack/unpack function pair. + * + * @param pack_fn [IN] Function pointer to the pack routine + * @param unpack_fn [IN] Function pointer to the unpack routine + * @param name [IN] String name for this pair (mainly for debugging) + * @param type [OUT] Type number for this registration + * + * @returns ORTE_SUCCESS upon success + * + * This function registers a pack/unpack function pair for a specific + * type. An integer is returned that should be used a an argument to + * future invocations of orte_dps.pack() and orte_dps.unpack(), which + * will trigger calls to pack_fn and unpack_fn (as appropriate). This + * is most useful when extending the datatypes that the DPS can + * handle; pack and unpack functions can nest calls to orte_dps.pack() + * / orte_dps.unpack(), so defining small pack/unpack functions can be + * used recursively to build larger types (e.g., packing/unpacking + * structs can use calls to orte_dps.pack()/unpack() to serialize / + * deserialize individual members). + */ +typedef int (*orte_dps_register_fn_t)(orte_dps_pack_fn_t pack_fn, + orte_dps_unpack_fn_t unpack_fn, + const char *name, orte_data_type_t *type); + +/* + * This function looks up the string name corresponding to the identified + * data type - used for debugging messages. + */ +typedef char* (*orte_dps_lookup_data_type_fn_t)(orte_data_type_t type); + /** * Base structure for the DPS * @@ -345,6 +376,8 @@ struct orte_dps_t { orte_dps_peek_next_item_fn_t peek; orte_dps_unload_fn_t unload; orte_dps_load_fn_t load; + orte_dps_register_fn_t register_type; + orte_dps_lookup_data_type_fn_t lookup_data_type; }; typedef struct orte_dps_t orte_dps_t; diff --git a/src/dps/dps_internal.h b/src/dps/dps_internal.h index e8239c3b54..439267a286 100644 --- a/src/dps/dps_internal.h +++ b/src/dps/dps_internal.h @@ -21,7 +21,7 @@ #include "orte_config.h" #include "include/orte_constants.h" -#include "class/orte_value_array.h" +#include "class/orte_pointer_array.h" #include "dps/dps.h" @@ -83,12 +83,31 @@ extern "C" { #error Unsupported int size! #endif +/** + * Internal struct used for holding registered dps functions + */ +struct orte_dps_type_info_t { + /* type identifier */ + orte_data_type_t odti_type; + /** Debugging string name */ + char *odti_name; + /** Pack function */ + orte_dps_pack_fn_t odti_pack_fn; + /** Unpack function */ + orte_dps_unpack_fn_t odti_unpack_fn; +}; +/** + * Convenience typedef + */ +typedef struct orte_dps_type_info_t orte_dps_type_info_t; + /* * globals needed within dps */ extern bool orte_dps_initialized; extern bool orte_dps_debug; extern int orte_dps_page_size; +extern orte_pointer_array_t *orte_dps_types; /* * Implementations of API functions @@ -106,6 +125,21 @@ extern int orte_dps_page_size; size_t *bytes_used); int orte_dps_load(orte_buffer_t *buffer, void *payload, size_t bytes_used); + int orte_dps_register(orte_dps_pack_fn_t pack_fn, + orte_dps_unpack_fn_t unpack_fn, + const char *name, orte_data_type_t *type); + + char *orte_dps_lookup_data_type(orte_data_type_t type); + + /* + * Non-API functions that need to be reachable + */ + int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_vals, + orte_data_type_t type); + + int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t *num_vals, + orte_data_type_t type); + /* * Internal pack functions */ @@ -144,33 +178,33 @@ extern int orte_dps_page_size; */ int orte_dps_unpack_null(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_byte(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_bool(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_int(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_int16(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_int32(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_int64(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_sizet(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_data_type(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); int orte_dps_unpack_byte_object(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type); + size_t *num_vals, orte_data_type_t type); /* * Internal helper functions @@ -184,6 +218,8 @@ extern int orte_dps_page_size; int orte_dps_get_data_type(orte_buffer_t *buffer, orte_data_type_t *type); + orte_dps_type_info_t* orte_dps_find_type(orte_data_type_t type); + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/dps/dps_internal_functions.c b/src/dps/dps_internal_functions.c index 45eb1dae40..3c72972280 100644 --- a/src/dps/dps_internal_functions.c +++ b/src/dps/dps_internal_functions.c @@ -155,35 +155,36 @@ int orte_dps_store_data_type(orte_buffer_t *buffer, orte_data_type_t type) */ int orte_dps_get_data_type(orte_buffer_t *buffer, orte_data_type_t *type) { - size_t required; + size_t required, n=1; int rc; + required = sizeof(orte_data_type_t); switch (required) { case 1: if (ORTE_SUCCESS != ( - rc = orte_dps_unpack_byte(buffer, type, 1, ORTE_BYTE))) { + rc = orte_dps_unpack_byte(buffer, type, &n, ORTE_BYTE))) { ORTE_ERROR_LOG(rc); } break; case 2: if (ORTE_SUCCESS != ( - rc = orte_dps_unpack_int16(buffer, type, 1, ORTE_INT16))) { + rc = orte_dps_unpack_int16(buffer, type, &n, ORTE_INT16))) { ORTE_ERROR_LOG(rc); } break; case 4: if (ORTE_SUCCESS != ( - rc = orte_dps_unpack_int32(buffer, type, 1, ORTE_INT32))) { + rc = orte_dps_unpack_int32(buffer, type, &n, ORTE_INT32))) { ORTE_ERROR_LOG(rc); } break; case 8: if (ORTE_SUCCESS != ( - rc = orte_dps_unpack_int64(buffer, type, 1, ORTE_INT64))) { + rc = orte_dps_unpack_int64(buffer, type, &n, ORTE_INT64))) { ORTE_ERROR_LOG(rc); } break; diff --git a/src/dps/dps_lookup.c b/src/dps/dps_lookup.c new file mode 100644 index 0000000000..b6c042eb5a --- /dev/null +++ b/src/dps/dps_lookup.c @@ -0,0 +1,38 @@ +/* + * 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_types.h" + +#include "mca/errmgr/errmgr.h" + +#include "dps/dps.h" +#include "dps/dps_internal.h" + + +char *orte_dps_lookup_data_type(orte_data_type_t type) +{ + orte_dps_type_info_t *info; + char *name; + + info = orte_pointer_array_get_item(orte_dps_types, type); + if (NULL != info) { /* type found on list */ + name = strdup(info->odti_name); + return name; + } + + return NULL; +} diff --git a/src/dps/dps_pack.c b/src/dps/dps_pack.c index 6e40e9bb16..f50b42e5a5 100644 --- a/src/dps/dps_pack.c +++ b/src/dps/dps_pack.c @@ -16,23 +16,19 @@ #include "orte_config.h" +#include #if HAVE_NETINET_IN_H #include #endif #include "mca/errmgr/errmgr.h" -#include "mca/ns/ns.h" #include "dps/dps_internal.h" -static int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_vals, - orte_data_type_t type); - int orte_dps_pack(orte_buffer_t *buffer, void *src, size_t num_vals, orte_data_type_t type) { int rc; - orte_data_type_t size_tmp=ORTE_SIZE; /* check for error */ if (NULL == buffer || NULL == src || num_vals < 0) { @@ -41,7 +37,7 @@ int orte_dps_pack(orte_buffer_t *buffer, void *src, size_t num_vals, } /* Pack the number of values */ - if (ORTE_SUCCESS != (rc = orte_dps_pack_data_type(buffer, &size_tmp, 1, ORTE_DATA_TYPE))) { + if (ORTE_SUCCESS != (rc = orte_dps_store_data_type(buffer, ORTE_SIZE))) { ORTE_ERROR_LOG(rc); return rc; } @@ -58,11 +54,11 @@ int orte_dps_pack(orte_buffer_t *buffer, void *src, size_t num_vals, return rc; } -static int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_vals, +int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_vals, orte_data_type_t type) { int rc; - orte_dps_pack_fn_t pack_fn; + orte_dps_type_info_t *info; /* Pack the declared data type */ if (ORTE_SUCCESS != (rc = orte_dps_pack_data_type(buffer, &type, 1, type))) { @@ -72,12 +68,12 @@ static int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_val /* Lookup the pack function for this type and call it */ - if (ORTE_SUCCESS != (rc = orte_ns.lookup_data_type(&pack_fn, NULL, NULL, type))) { - ORTE_ERROR_LOG(rc); - return rc; + if (NULL == (info = orte_pointer_array_get_item(orte_dps_types, type))) { + ORTE_ERROR_LOG(ORTE_ERR_PACK_FAILURE); + return ORTE_ERR_PACK_FAILURE; } - if (ORTE_SUCCESS != (rc = pack_fn(buffer, src, num_vals, type))) { + if (ORTE_SUCCESS != (rc = info->odti_pack_fn(buffer, src, num_vals, type))) { ORTE_ERROR_LOG(rc); } @@ -189,7 +185,7 @@ int orte_dps_pack_int16(orte_buffer_t *buffer, void *src, size_t num_vals, orte_data_type_t type) { size_t i; - uint16_t tmp, *srctmp = (uint16_t*) src; + uint16_t tmp, *dsttmp, *srctmp = (uint16_t*) src; char *dst; /* check to see if buffer needs extending */ @@ -198,9 +194,10 @@ int orte_dps_pack_int16(orte_buffer_t *buffer, void *src, return ORTE_ERR_OUT_OF_RESOURCE; } + dsttmp = (uint16_t*)dst; for (i = 0; i < num_vals; ++i) { tmp = htons(srctmp[i]); - memcpy(((uint16_t*) dst) + i, &tmp, sizeof(tmp)); + memcpy(&dsttmp[i], &tmp, sizeof(tmp)); } buffer->pack_ptr += num_vals * sizeof(tmp); buffer->bytes_used += num_vals * sizeof(tmp); @@ -216,7 +213,7 @@ int orte_dps_pack_int32(orte_buffer_t *buffer, void *src, size_t num_vals, orte_data_type_t type) { size_t i; - uint32_t tmp, *srctmp = (uint32_t*) src; + uint32_t tmp, *dsttmp, *srctmp = (uint32_t*) src; char *dst; /* check to see if buffer needs extending */ @@ -225,9 +222,10 @@ int orte_dps_pack_int32(orte_buffer_t *buffer, void *src, return ORTE_ERR_OUT_OF_RESOURCE; } + dsttmp = (uint32_t*)dst; for (i = 0; i < num_vals; ++i) { tmp = htonl(srctmp[i]); - memcpy(((uint32_t*) dst) + i, &tmp, sizeof(tmp)); + memcpy(&dsttmp[i], &tmp, sizeof(tmp)); } buffer->pack_ptr += num_vals * sizeof(tmp); buffer->bytes_used += num_vals * sizeof(tmp); @@ -243,23 +241,24 @@ int orte_dps_pack_int64(orte_buffer_t *buffer, void *src, size_t num_vals, orte_data_type_t type) { size_t i; - uint32_t tmp, *srctmp = (uint32_t*) src; + uint32_t tmp, *dsttmp, *srctmp = (uint32_t*) src; char *dst; - num_vals *= 2; - /* check to see if buffer needs extending */ if (NULL == (dst = orte_dps_buffer_extend(buffer, num_vals*sizeof(tmp)))) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } - for (i = 0; i < num_vals; ++i) { + dsttmp = (uint32_t*)dst; + for (i = 0; i < num_vals; i += 2) { tmp = htonl(srctmp[i]); - memcpy(((uint32_t*) dst) + i, &tmp, sizeof(tmp)); + memcpy(&dsttmp[i], &tmp, sizeof(tmp)); + tmp = htonl(srctmp[i+1]); + memcpy(&dsttmp[i+1], &tmp, sizeof(tmp)); } - buffer->pack_ptr += num_vals * sizeof(tmp); - buffer->bytes_used += num_vals * sizeof(tmp); + buffer->pack_ptr += 2*num_vals * sizeof(tmp); + buffer->bytes_used += 2*num_vals * sizeof(tmp); buffer->bytes_avail -= num_vals * sizeof(tmp); return ORTE_SUCCESS; @@ -347,5 +346,27 @@ int orte_dps_pack_data_type(orte_buffer_t *buffer, void *src, size_t num, int orte_dps_pack_byte_object(orte_buffer_t *buffer, void *src, size_t num, orte_data_type_t type) { + orte_byte_object_t *sbyteptr; + size_t i, n; + int ret; + + sbyteptr = (orte_byte_object_t *) src; + + for (i = 0; i < num; ++i) { + n = sbyteptr->size; + if (0 < n) { + if (ORTE_SUCCESS != (ret = orte_dps_pack_sizet(buffer, &n, 1, ORTE_SIZE))) { + ORTE_ERROR_LOG(ret); + return ret; + } + if (ORTE_SUCCESS != (ret = + orte_dps_pack_byte(buffer, sbyteptr->bytes, n, ORTE_BYTE))) { + ORTE_ERROR_LOG(ret); + return ret; + } + } + sbyteptr++; + } + return ORTE_SUCCESS; } diff --git a/src/dps/dps_peek.c b/src/dps/dps_peek.c index 9a02810fe6..22f4c7a3dc 100644 --- a/src/dps/dps_peek.c +++ b/src/dps/dps_peek.c @@ -26,6 +26,8 @@ int orte_dps_peek(orte_buffer_t *buffer, orte_data_type_t *type, { int ret; orte_buffer_t tmp; + size_t n=1; + orte_data_type_t local_type; /* check for errors */ if (buffer == NULL) { @@ -33,16 +35,40 @@ int orte_dps_peek(orte_buffer_t *buffer, orte_data_type_t *type, return ORTE_ERR_BAD_PARAM; } + /* Double check and ensure that there is data left in the buffer. */ + + if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) { + *type = ORTE_NULL; + *num_vals = 0; + return ORTE_UNPACK_READ_PAST_END_OF_BUFFER; + } + /* cheat: unpack from a copy of the buffer -- leaving all the original pointers intact */ tmp = *buffer; - if (ORTE_SUCCESS != (ret = orte_dps_unpack_sizet(&tmp, num_vals, 1, ORTE_SIZE))) { + if (ORTE_SUCCESS != ( + ret = orte_dps_get_data_type(&tmp, &local_type))) { + *type = ORTE_NULL; + *num_vals = 0; + return ret; + } + if (ORTE_SIZE != local_type) { /* if the length wasn't first, then error */ + ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE); + *type = ORTE_NULL; + *num_vals = 0; + return ORTE_ERR_UNPACK_FAILURE; + } + if (ORTE_SUCCESS != (ret = orte_dps_unpack_sizet(&tmp, num_vals, &n, ORTE_SIZE))) { ORTE_ERROR_LOG(ret); + *type = ORTE_NULL; + *num_vals = 0; return ret; } if (ORTE_SUCCESS != (ret = orte_dps_get_data_type(&tmp, type))) { ORTE_ERROR_LOG(ret); + *type = ORTE_NULL; + *num_vals = 0; } return ret; diff --git a/src/dps/dps_register.c b/src/dps/dps_register.c new file mode 100644 index 0000000000..f6aff0c8ed --- /dev/null +++ b/src/dps/dps_register.c @@ -0,0 +1,68 @@ +/* + * 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_types.h" + +#include "mca/errmgr/errmgr.h" +#include "mca/ns/ns.h" + +#include "dps/dps.h" +#include "dps/dps_internal.h" + + +int orte_dps_register(orte_dps_pack_fn_t pack_fn, + orte_dps_unpack_fn_t unpack_fn, + const char *name, orte_data_type_t *type) +{ + int ret; + orte_dps_type_info_t *info; + + /* Check for bozo cases */ + + if (NULL == pack_fn || NULL == unpack_fn || NULL == name || NULL == type) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + + /* if type is given (i.e., *type > 0), then just use it. + * otherwise, go and get a new type id from the name + * service + */ + if (0 >= *type) { + if (ORTE_SUCCESS != (ret = orte_ns.define_data_type(name, type))) { + ORTE_ERROR_LOG(ret); + return ret; + } + } + + /* Add a new entry to the table */ + info = (orte_dps_type_info_t*)malloc(sizeof(orte_dps_type_info_t)); + if (NULL == info) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + info->odti_name = strdup(name); + info->odti_pack_fn = pack_fn; + info->odti_unpack_fn = unpack_fn; + if (ORTE_SUCCESS != (ret = orte_pointer_array_set_item(orte_dps_types, *type, info))) { + ORTE_ERROR_LOG(ret); + } + + /* All done */ + + return ret; +} diff --git a/src/dps/dps_unpack.c b/src/dps/dps_unpack.c index 2114584af0..b8d482164e 100644 --- a/src/dps/dps_unpack.c +++ b/src/dps/dps_unpack.c @@ -24,16 +24,15 @@ #include #include "mca/errmgr/errmgr.h" -#include "mca/ns/ns.h" #include "dps/dps_internal.h" - int orte_dps_unpack(orte_buffer_t *buffer, void *dst, size_t *num_vals, orte_data_type_t type) { int ret=ORTE_SUCCESS, rc=ORTE_SUCCESS; - size_t local_num; + size_t local_num, n=1; + orte_data_type_t local_type; /* check for error */ if (NULL == buffer || NULL == dst || NULL == num_vals || 0 > *num_vals) { @@ -49,7 +48,7 @@ int orte_dps_unpack(orte_buffer_t *buffer, void *dst, size_t *num_vals, return ORTE_UNPACK_INADEQUATE_SPACE; } - /* Unpack the stored number of values + /* Unpack the declared number of values * REMINDER: it is possible that the buffer is corrupted and that * the DPS will *think* there is a proper size_t variable at the * beginning of the unpack region - but that the value is bogus (e.g., just @@ -59,7 +58,18 @@ int orte_dps_unpack(orte_buffer_t *buffer, void *dst, size_t *num_vals, * size_t as used here. */ if (ORTE_SUCCESS != ( - rc = orte_dps_unpack_sizet(buffer, &local_num, 1, ORTE_SIZE))) { + rc = orte_dps_get_data_type(buffer, &local_type))) { + ORTE_ERROR_LOG(rc); + *num_vals = 0; + return rc; + } + if (ORTE_SIZE != local_type) { /* if the length wasn't first, then error */ + ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE); + *num_vals = 0; + return ORTE_ERR_UNPACK_FAILURE; + } + if (ORTE_SUCCESS != ( + rc = orte_dps_unpack_sizet(buffer, &local_num, &n, ORTE_SIZE))) { ORTE_ERROR_LOG(rc); *num_vals = 0; return rc; @@ -79,7 +89,7 @@ int orte_dps_unpack(orte_buffer_t *buffer, void *dst, size_t *num_vals, } /* Unpack the value(s) */ - if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dst, local_num, type))) { + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dst, &local_num, type))) { ORTE_ERROR_LOG(rc); *num_vals = 0; } @@ -91,13 +101,14 @@ int orte_dps_unpack(orte_buffer_t *buffer, void *dst, size_t *num_vals, return rc; } -int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t num_vals, +int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t *num_vals, orte_data_type_t type) { int rc; orte_data_type_t local_type; + orte_dps_type_info_t *info; - /* Unpack the data type */ + /* Unpack the declared data type */ if (ORTE_SUCCESS != (rc = orte_dps_get_data_type(buffer, &local_type))) { ORTE_ERROR_LOG(rc); return rc; @@ -110,7 +121,11 @@ int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t num_vals, /* Lookup the unpack function for this type and call it */ - info = orte_value_array_get_item(&orte_dps_types, type); + if (NULL == (info = orte_pointer_array_get_item(orte_dps_types, type))) { + ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE); + return ORTE_ERR_UNPACK_FAILURE; + } + if (ORTE_SUCCESS != (rc = info->odti_unpack_fn(buffer, dst, num_vals, type))) { ORTE_ERROR_LOG(rc); } @@ -125,7 +140,7 @@ int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t num_vals, * NULL */ int orte_dps_unpack_null(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { int rc; @@ -141,7 +156,7 @@ int orte_dps_unpack_null(orte_buffer_t *buffer, void *dest, * BOOL */ int orte_dps_unpack_bool(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { int ret; @@ -158,7 +173,7 @@ int orte_dps_unpack_bool(orte_buffer_t *buffer, void *dest, * INT */ int orte_dps_unpack_int(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { int ret; @@ -175,7 +190,7 @@ int orte_dps_unpack_int(orte_buffer_t *buffer, void *dest, * SIZE_T */ int orte_dps_unpack_sizet(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { int ret; @@ -195,101 +210,103 @@ int orte_dps_unpack_sizet(orte_buffer_t *buffer, void *dest, * BYTE, CHAR, INT8 */ int orte_dps_unpack_byte(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { /* check to see if there's enough data in buffer */ - if (orte_dps_too_small(buffer, num_vals) { + if (orte_dps_too_small(buffer, *num_vals)) { ORTE_ERROR_LOG(ORTE_UNPACK_READ_PAST_END_OF_BUFFER); return ORTE_UNPACK_READ_PAST_END_OF_BUFFER; } /* unpack the data */ - memcpy(dest, buffer->unpack_ptr, num_vals); + memcpy(dest, buffer->unpack_ptr, *num_vals); /* update buffer pointer */ - buffer->unpack_ptr += num_vals; + buffer->unpack_ptr += *num_vals; return ORTE_SUCCESS; } int orte_dps_unpack_int16(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { size_t i; uint16_t tmp, *desttmp = (uint16_t*) dest; + uint16_t *srctmp = (uint16_t*) buffer->unpack_ptr; /* check to see if there's enough data in buffer */ - if (orte_dps_too_small(buffer, num_vals*sizeof(tmp)) { + if (orte_dps_too_small(buffer, (*num_vals)*sizeof(tmp))) { ORTE_ERROR_LOG(ORTE_UNPACK_READ_PAST_END_OF_BUFFER); return ORTE_UNPACK_READ_PAST_END_OF_BUFFER; } /* unpack the data */ - for (i = 0; i < num_vals; ++i) { - tmp = ntohs(desttmp[i]); + for (i = 0; i < (*num_vals); ++i) { + tmp = ntohs(srctmp[i]); memcpy(&desttmp[i], &tmp, sizeof(tmp)); } - buffer->unpack_ptr += num_vals * sizeof(tmp); + buffer->unpack_ptr += (*num_vals) * sizeof(tmp); return ORTE_SUCCESS; } int orte_dps_unpack_int32(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { size_t i; uint32_t tmp, *desttmp = (uint32_t*) dest; + uint32_t *srctmp = (uint32_t*) buffer->unpack_ptr; /* check to see if there's enough data in buffer */ - if (orte_dps_too_small(buffer, num_vals*sizeof(tmp)) { + if (orte_dps_too_small(buffer, (*num_vals)*sizeof(tmp))) { ORTE_ERROR_LOG(ORTE_UNPACK_READ_PAST_END_OF_BUFFER); return ORTE_UNPACK_READ_PAST_END_OF_BUFFER; } /* unpack the data */ - for (i = 0; i < num_vals; ++i) { - tmp = ntohl(desttmp[i]); - memcpy(&tmp, &desttmp[i], sizeof(tmp)); + for (i = 0; i < (*num_vals); ++i) { + tmp = ntohl(srctmp[i]); + memcpy(&desttmp[i], &tmp, sizeof(tmp)); } - buffer->unpack_ptr += num_vals * sizeof(tmp); + buffer->unpack_ptr += (*num_vals) * sizeof(tmp); - return ret; + return ORTE_SUCCESS; } int orte_dps_unpack_int64(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { - int ret; size_t i; uint32_t tmp, *desttmp = (uint32_t*) dest; + uint32_t *srctmp = (uint32_t*) buffer->unpack_ptr; - num_vals *= 2; - /* check to see if there's enough data in buffer */ - if (orte_dps_too_small(buffer, num_vals*sizeof(tmp)) { + if (orte_dps_too_small(buffer, 2*(*num_vals)*sizeof(tmp))) { ORTE_ERROR_LOG(ORTE_UNPACK_READ_PAST_END_OF_BUFFER); return ORTE_UNPACK_READ_PAST_END_OF_BUFFER; } /* unpack the data */ - for (i = 0; i < num_vals; ++i) { - tmp = ntohl(desttmp[i]); - memcpy(&tmp, &desttmp[i], sizeof(tmp)); + for (i = 0; i < 2*(*num_vals); i += 2) { + tmp = ntohl(srctmp[i]); + memcpy(&desttmp[i], &tmp, sizeof(tmp)); + tmp = ntohl(srctmp[i+1]); + memcpy(&desttmp[i+1], &tmp, sizeof(tmp)); } - buffer->unpack_ptr += num_vals * sizeof(tmp); + buffer->unpack_ptr += 2*(*num_vals) * sizeof(tmp); - return ret; + return ORTE_SUCCESS; } int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest, - size_t num_vals, orte_data_type_t type) + size_t *num_vals, orte_data_type_t type) { int ret; - size_t i, len; + size_t i, len, n=1; char **sdest = (char**) dest; - for (i = 0; i < num_vals; ++i) { - if (ORTE_SUCCESS != (ret = orte_dps_unpack_sizet(buffer, &len, 1, ORTE_SIZE))) { + for (i = 0; i < (*num_vals); ++i) { + if (ORTE_SUCCESS != (ret = orte_dps_unpack_sizet(buffer, &len, &n, ORTE_SIZE))) { ORTE_ERROR_LOG(ret); return ret; } @@ -298,7 +315,7 @@ int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest, ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } - if (ORTE_SUCCESS != (ret = orte_dps_unpack_byte(buffer, sdest[i], len, ORTE_BYTE))) { + if (ORTE_SUCCESS != (ret = orte_dps_unpack_byte(buffer, sdest[i], &len, ORTE_BYTE))) { ORTE_ERROR_LOG(ret); return ret; } @@ -306,3 +323,90 @@ int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest, return ORTE_SUCCESS; } + + +/* UNPACK FUNCTIONS FOR GENERIC ORTE TYPES */ + +/* + * ORTE_DATA_TYPE + */ +int orte_dps_unpack_data_type(orte_buffer_t *buffer, void *dest, size_t *num, + orte_data_type_t type) +{ + size_t required; + int rc; + + required = sizeof(orte_data_type_t); + switch (required) { + + case 1: + if (ORTE_SUCCESS != ( + rc = orte_dps_unpack_byte(buffer, dest, num, ORTE_BYTE))) { + ORTE_ERROR_LOG(rc); + } + break; + + case 2: + if (ORTE_SUCCESS != ( + rc = orte_dps_unpack_int16(buffer, dest, num, ORTE_INT16))) { + ORTE_ERROR_LOG(rc); + } + break; + + case 4: + if (ORTE_SUCCESS != ( + rc = orte_dps_unpack_int32(buffer, dest, num, ORTE_INT32))) { + ORTE_ERROR_LOG(rc); + } + break; + + case 8: + if (ORTE_SUCCESS != ( + rc = orte_dps_unpack_int64(buffer, dest, num, ORTE_INT64))) { + ORTE_ERROR_LOG(rc); + } + break; + + default: + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + + return rc; +} + +/* + * ORTE_BYTE_OBJECT + */ +int orte_dps_unpack_byte_object(orte_buffer_t *buffer, void *dest, size_t *num, + orte_data_type_t type) +{ + int ret; + size_t i, n, m=1; + orte_byte_object_t *dbyteptr; + + dbyteptr = (orte_byte_object_t*)dest; + n = *num; + for(i=0; isize), &m, ORTE_SIZE))) { + ORTE_ERROR_LOG(ret); + return ret; + } + if (0 < dbyteptr->size) { + dbyteptr->bytes = (uint8_t*)malloc(dbyteptr->size); + if (NULL == dbyteptr->bytes) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (ret = orte_dps_unpack_byte(buffer, dbyteptr->bytes, + &dbyteptr->size, ORTE_BYTE))) { + ORTE_ERROR_LOG(ret); + return ret; + } + } + dbyteptr++; + } + + return ORTE_SUCCESS; +} diff --git a/src/dps/orte_dps_open_close.c b/src/dps/orte_dps_open_close.c index 73cd930320..9b2b3933dd 100644 --- a/src/dps/orte_dps_open_close.c +++ b/src/dps/orte_dps_open_close.c @@ -25,19 +25,26 @@ #include "dps/dps_internal.h" +/* definitions + */ +#define ORTE_DPS_TABLE_PAGE_SIZE 10 + /** * globals */ bool orte_dps_initialized = false; bool orte_dps_debug = false; int orte_dps_page_size; +orte_pointer_array_t *orte_dps_types; orte_dps_t orte_dps = { orte_dps_pack, orte_dps_unpack, orte_dps_peek, orte_dps_unload, - orte_dps_load + orte_dps_load, + orte_dps_register, + orte_dps_lookup_data_type }; /** @@ -70,6 +77,7 @@ int orte_dps_open(void) { char *enviro_val; int id, page_size, rc; + orte_data_type_t tmp; if (orte_dps_initialized) { return ORTE_SUCCESS; @@ -87,107 +95,134 @@ int orte_dps_open(void) mca_base_param_lookup_int(id, &page_size); orte_dps_page_size = 1024 * page_size; + /* Setup the value array */ + + if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&orte_dps_types, + ORTE_DPS_ID_DYNAMIC, + ORTE_DPS_ID_MAX, + ORTE_DPS_TABLE_PAGE_SIZE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Register all the intrinsic types */ - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_null, + tmp = ORTE_NULL; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_null, orte_dps_unpack_null, - "ORTE_NULL", ORTE_NULL))) { + "ORTE_NULL", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_byte, + tmp = ORTE_BYTE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_byte, orte_dps_unpack_byte, - "ORTE_BYTE", ORTE_BYTE))) { + "ORTE_BYTE", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_data_type, + tmp = ORTE_DATA_TYPE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_data_type, orte_dps_unpack_data_type, - "ORTE_DATA_TYPE", ORTE_DATA_TYPE))) { + "ORTE_DATA_TYPE", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_bool, + tmp = ORTE_BOOL; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_bool, orte_dps_unpack_bool, - "ORTE_BOOL", ORTE_BOOL))) { + "ORTE_BOOL", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int, + tmp = ORTE_INT; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int, orte_dps_unpack_int, - "ORTE_INT", ORTE_INT))) { + "ORTE_INT", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int, + tmp = ORTE_UINT; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int, orte_dps_unpack_int, - "ORTE_UINT", ORTE_UINT))) { + "ORTE_UINT", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_byte, + tmp = ORTE_INT8; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_byte, orte_dps_unpack_byte, - "ORTE_INT8", ORTE_INT8))) { + "ORTE_INT8", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_byte, + tmp = ORTE_UINT8; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_byte, orte_dps_unpack_byte, - "ORTE_UINT8", ORTE_UINT8))) { + "ORTE_UINT8", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int16, + tmp = ORTE_INT16; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int16, orte_dps_unpack_int16, - "ORTE_INT16", ORTE_INT16))) { + "ORTE_INT16", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int16, + tmp = ORTE_UINT16; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int16, orte_dps_unpack_int16, - "ORTE_UINT16", ORTE_UINT16))) { + "ORTE_UINT16", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int32, + tmp = ORTE_INT32; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int32, orte_dps_unpack_int32, - "ORTE_INT32", ORTE_INT32))) { + "ORTE_INT32", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int32, + tmp = ORTE_UINT32; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int32, orte_dps_unpack_int32, - "ORTE_UINT32", ORTE_UINT32))) { + "ORTE_UINT32", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int64, + tmp = ORTE_INT64; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int64, orte_dps_unpack_int64, - "ORTE_INT64", ORTE_INT64))) { + "ORTE_INT64", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_int64, + tmp = ORTE_UINT64; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_int64, orte_dps_unpack_int64, - "ORTE_UINT64", ORTE_UINT64))) { + "ORTE_UINT64", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_sizet, + tmp = ORTE_SIZE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_sizet, orte_dps_unpack_sizet, - "ORTE_SIZE", ORTE_SIZE))) { + "ORTE_SIZE", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_string, + tmp = ORTE_STRING; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_string, orte_dps_unpack_string, - "ORTE_STRING", ORTE_STRING))) { + "ORTE_STRING", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } - if (ORTE_SUCCESS != (rc = orte_ns.define_data_type(orte_dps_pack_byte_object, + tmp = ORTE_BYTE_OBJECT; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_dps_pack_byte_object, orte_dps_unpack_byte_object, - "ORTE_BYTE_OBJECT", ORTE_BYTE_OBJECT))) { + "ORTE_BYTE_OBJECT", &tmp))) { ORTE_ERROR_LOG(rc); return rc; } @@ -200,17 +235,6 @@ int orte_dps_open(void) int orte_dps_close(void) { - size_t i; - orte_dps_type_info_t *info; - - for (i = 0; i < orte_value_array_get_size(&orte_dps_types); ++i) { - info = orte_value_array_get_item(&orte_dps_types, i); - if (NULL != info->odti_name) { - free(info->odti_name); - } - } - OBJ_DESTRUCT(&orte_dps_types); - orte_dps_initialized = false; return ORTE_SUCCESS; diff --git a/src/mca/gpr/base/Makefile.am b/src/mca/gpr/base/Makefile.am index e4d23ebfbc..235a0ebc1b 100644 --- a/src/mca/gpr/base/Makefile.am +++ b/src/mca/gpr/base/Makefile.am @@ -16,7 +16,7 @@ include $(top_srcdir)/config/Makefile.options -SUBDIRS = pack_api_cmd unpack_api_response +SUBDIRS = pack_api_cmd unpack_api_response data_type_support noinst_LTLIBRARIES = libmca_gpr_base.la diff --git a/src/mca/gpr/base/base.h b/src/mca/gpr/base/base.h index 477678d946..bc99747100 100644 --- a/src/mca/gpr/base/base.h +++ b/src/mca/gpr/base/base.h @@ -163,6 +163,55 @@ extern "C" { OMPI_DECLSPEC int orte_gpr_base_pack_decrement_value(orte_buffer_t *cmd, orte_gpr_value_t *value); OMPI_DECLSPEC int orte_gpr_base_unpack_decrement_value(orte_buffer_t *buffer, int *ret); +/* GPR DATA TYPE PACKING FUNCTIONS */ +int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_notify_id(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_addr_mode(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_keyval(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_subscription(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +/* GPR DATA TYPE UNPACKING FUNCTIONS */ +int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_notify_id(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_addr_mode(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_keyval(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/src/mca/gpr/base/data_type_support/Makefile.am b/src/mca/gpr/base/data_type_support/Makefile.am new file mode 100644 index 0000000000..c44f679be6 --- /dev/null +++ b/src/mca/gpr/base/data_type_support/Makefile.am @@ -0,0 +1,38 @@ +# +# 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 $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_gpr_base_data_type.la + +# Source code files + +headers = + +libmca_gpr_base_data_type_la_SOURCES = \ + $(headers) \ + gpr_data_type_packing_fns.c \ + gpr_data_type_unpacking_fns.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +ompidir = $(includedir)/openmpi/mca/gpr/base/data_type_support +ompi_HEADERS = $(headers) +else +ompidir = $(includedir) +endif + diff --git a/src/mca/gpr/base/data_type_support/gpr_data_type_packing_fns.c b/src/mca/gpr/base/data_type_support/gpr_data_type_packing_fns.c new file mode 100644 index 0000000000..a700ebd76f --- /dev/null +++ b/src/mca/gpr/base/data_type_support/gpr_data_type_packing_fns.c @@ -0,0 +1,311 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/gpr/base/base.h" + +/* + * GPR CMD + */ +int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_CMD_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NOTIFY ID + */ +int orte_gpr_base_pack_notify_id(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_NOTIFY_ID_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NOTIFY ACTION + */ +int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_NOTIFY_ACTION_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * ADDR MODE + */ +int orte_gpr_base_pack_addr_mode(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_ADDR_MODE_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * KEYVAL + */ +int orte_gpr_base_pack_keyval(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_keyval_t **keyval; + size_t i; + + /* array of pointers to keyval objects - need to pack the + objects */ + keyval = (orte_gpr_keyval_t**) src; + + for (i=0; i < num_vals; i++) { + /* pack the key */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(keyval[i]->key)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the data type so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, &(keyval[i]->type), 1, + ORTE_DATA_TYPE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the value */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, &(keyval[i]->value), 1, + keyval[i]->type))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + +/* + * VALUE + */ +int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_value_t **values; + size_t i; + + /* array of pointers to value objects - need to pack the objects */ + values = (orte_gpr_value_t**) src; + for (i=0; iaddr_mode)), 1, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + + /* pack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(values[i]->segment)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + + /* pack the number of tokens so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(values[i]->num_tokens)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + + /* if there are tokens, pack them */ + if (0 < values[i]->num_tokens) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)((values[i]->tokens)), values[i]->num_tokens, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + } + + /* pack the number of keyval pairs so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(values[i]->cnt)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + + /* if there are keyval pairs, pack them */ + if (0 < values[i]->cnt) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)((values[i]->keyvals)), values[i]->cnt, ORTE_KEYVAL))) { + ORTE_ERROR_LOG(rc); + return ORTE_ERROR; + } + } + } + + return ORTE_SUCCESS; +} + +/* + * SUBSCRIPTION + */ +int orte_gpr_base_pack_subscription(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_subscription_t **subs; + size_t i; + + /* array of pointers to subscription objects - need to pack the objects */ + subs = (orte_gpr_subscription_t**) src; + for (i=0; iaddr_mode)), 1, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(subs[i]->segment)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of tokens so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(subs[i]->num_tokens)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are tokens, pack them */ + if (0 < subs[i]->num_tokens) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)((subs[i]->tokens)), subs[i]->num_tokens, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* pack the number of keys so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(subs[i]->num_keys)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are keys, pack them */ + if (0 < subs[i]->num_keys) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)((subs[i]->keys)), subs[i]->num_keys, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* skip the pointers for cb_func and user_tag */ + } + + return ORTE_SUCCESS; +} + +/* + * NOTIFY DATA + */ +int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_notify_data_t **data; + size_t i; + + /* array of pointers to notify data objects - need to pack the objects */ + data = (orte_gpr_notify_data_t**) src; + + for (i=0; icb_num)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the address mode */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(data[i]->addr_mode)), 1, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(data[i]->segment)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of values so we can read it for unpacking */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(data[i]->cnt)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are values, pack the values */ + if (0 < data[i]->cnt) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)((data[i]->values)), data[i]->cnt, ORTE_GPR_VALUE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + + return ORTE_SUCCESS; +} diff --git a/src/mca/gpr/base/data_type_support/gpr_data_type_unpacking_fns.c b/src/mca/gpr/base/data_type_support/gpr_data_type_unpacking_fns.c new file mode 100644 index 0000000000..0e26a8f9b1 --- /dev/null +++ b/src/mca/gpr/base/data_type_support/gpr_data_type_unpacking_fns.c @@ -0,0 +1,373 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/gpr/base/base.h" + +/* + * GPR CMD + */ +int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_CMD_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NOTIFY ID + */ +int orte_gpr_base_unpack_notify_id(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_NOTIFY_ID_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NOTIFY ACTION + */ +int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_NOTIFY_ACTION_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * ADDR MODE + */ +int orte_gpr_base_unpack_addr_mode(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_ADDR_MODE_T))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * KEYVAL + */ +int orte_gpr_base_unpack_keyval(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_keyval_t **keyval; + size_t i, max_n=1; + + /* unpack into an array of keyval objects */ + keyval = (orte_gpr_keyval_t**) dest; + for (i=0; i < *num_vals; i++) { + /* allocate the memory storage */ + keyval[i] = OBJ_NEW(orte_gpr_keyval_t); + if (NULL == keyval[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the key */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(keyval[i]->key), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the data type so we can unpack the value */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(keyval[i]->type), + &max_n, ORTE_DATA_TYPE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the value */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(keyval[i]->value), + &max_n, keyval[i]->type))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + +/* + * VALUE + */ +int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_value_t **values; + size_t i, max_n=1; + + /* unpack into array of value objects */ + values = (orte_gpr_value_t**) dest; + for (i=0; i < *num_vals; i++) { + /* create the value object */ + values[i] = OBJ_NEW(orte_gpr_value_t); + if (NULL == values[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the address mode */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->addr_mode), + &max_n, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->segment), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* get the number of tokens */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->num_tokens), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are tokens, allocate the required space for the char * pointers */ + if (0 < values[i]->num_tokens) { + values[i]->tokens = (char **)malloc(values[i]->num_tokens * sizeof(char*)); + if (NULL == values[i]->tokens) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, values[i]->tokens, + &(values[i]->num_tokens), ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* get the number of keyval pairs */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->cnt), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are keyvals, allocate the required space for the keyval object pointers */ + if(0 < values[i]->cnt) { + 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); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the keyval pairs */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, values[i]->keyvals, + &(values[i]->cnt), ORTE_KEYVAL))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + + return ORTE_SUCCESS; +} + +/* + * SUBSCRIPTION + */ +int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_subscription_t **subs; + size_t i, max_n=1; + + /* unpack into array of subscription objects */ + subs = (orte_gpr_subscription_t**) dest; + for (i=0; i < *num_vals; i++) { + /* create the subscription object */ + subs[i] = OBJ_NEW(orte_gpr_subscription_t); + if (NULL == subs[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the address mode */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->addr_mode), + &max_n, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->segment), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* get the number of tokens */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->num_tokens), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are tokens, allocate the required space for the char * pointers */ + if (0 < subs[i]->num_tokens) { + subs[i]->tokens = (char **)malloc(subs[i]->num_tokens * sizeof(char*)); + if (NULL == subs[i]->tokens) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, subs[i]->tokens, + &(subs[i]->num_tokens), ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* get the number of keys */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->num_keys), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are keys, allocate the required space for the char * pointers */ + if (0 < subs[i]->num_keys) { + subs[i]->keys = (char **)malloc(subs[i]->num_keys * sizeof(char*)); + if (NULL == subs[i]->keys) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, subs[i]->keys, + &(subs[i]->num_keys), ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* the pointer fields for cb_func and user_tag were NOT packed + * so ignore them here as well + */ + } + + return ORTE_SUCCESS; +} + +/* + * NOTIFY DATA + */ +int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_gpr_notify_data_t **data; + size_t i, max_n=1; + + /* unpack into array of notify_data objects */ + data = (orte_gpr_notify_data_t**) dest; + + for (i=0; i < *num_vals; i++) { + /* create the data object */ + data[i] = OBJ_NEW(orte_gpr_notify_data_t); + if (NULL == data[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* unpack the callback number */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->cb_num), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the address mode */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->addr_mode), + &max_n, ORTE_GPR_ADDR_MODE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the segment name */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->segment), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* get the number of values */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->cnt), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are values, allocate the required space for the value pointers */ + if (0 < data[i]->cnt) { + data[i]->values = (orte_gpr_value_t**)malloc(data[i]->cnt * sizeof(orte_gpr_value_t*)); + if (NULL == data[i]->values) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, data[i]->values, + &(data[i]->cnt), ORTE_GPR_VALUE))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + + return ORTE_SUCCESS; +} diff --git a/src/mca/gpr/base/data_type_support/gpr_type_notify_action.c b/src/mca/gpr/base/data_type_support/gpr_type_notify_action.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mca/gpr/base/gpr_base_open.c b/src/mca/gpr/base/gpr_base_open.c index 524f66b2ed..e86f0c23c3 100644 --- a/src/mca/gpr/base/gpr_base_open.c +++ b/src/mca/gpr/base/gpr_base_open.c @@ -21,6 +21,7 @@ #include "util/output.h" #include "dps/dps.h" +#include "mca/errmgr/errmgr.h" #include "mca/gpr/base/base.h" @@ -257,7 +258,8 @@ ompi_mutex_t orte_gpr_mutex; */ int orte_gpr_base_open(void) { - int param, value; + int param, value, rc; + orte_data_type_t tmp; /* Debugging / verbose output */ @@ -270,8 +272,71 @@ int orte_gpr_base_open(void) orte_gpr_base_output = -1; } - /* register data types */ + /* register the base data types with the DPS */ + tmp = ORTE_GPR_CMD; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_cmd, + orte_gpr_base_unpack_cmd, + "ORTE_GPR_CMD", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + tmp = ORTE_GPR_NOTIFY_ID; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_id, + orte_gpr_base_unpack_notify_id, + "ORTE_GPR_NOTIFY_ID", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_NOTIFY_ACTION; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_action, + orte_gpr_base_unpack_notify_action, + "ORTE_NOTIFY_ACTION", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_GPR_ADDR_MODE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_addr_mode, + orte_gpr_base_unpack_addr_mode, + "ORTE_GPR_ADDR_MODE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_KEYVAL; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_keyval, + orte_gpr_base_unpack_keyval, + "ORTE_KEYVAL", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_GPR_VALUE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_value, + orte_gpr_base_unpack_value, + "ORTE_GPR_VALUE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_GPR_SUBSCRIPTION; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_subscription, + orte_gpr_base_unpack_subscription, + "ORTE_GPR_SUBSCRIPTION", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_GPR_NOTIFY_DATA; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_data, + orte_gpr_base_unpack_notify_data, + "ORTE_GPR_NOTIFY_DATA", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Open up all available components */ if (OMPI_SUCCESS != diff --git a/src/mca/gpr/gpr_types.h b/src/mca/gpr/gpr_types.h index a9235be612..545fbcaba1 100644 --- a/src/mca/gpr/gpr_types.h +++ b/src/mca/gpr/gpr_types.h @@ -34,6 +34,7 @@ #include "mca/schema/schema.h" #include "class/ompi_object.h" #include "dps/dps_types.h" +#include "dps/dps_internal.h" #include "mca/ns/ns_types.h" #include "mca/rmgr/rmgr_types.h" #include "mca/soh/soh_types.h" @@ -62,8 +63,10 @@ #define ORTE_GPR_TRIG_ANY (uint16_t)0xff00 /**< Used to test if any trigs are set */ typedef uint16_t orte_gpr_notify_action_t; +#define ORTE_GPR_NOTIFY_ACTION_T ORTE_UINT16 typedef size_t orte_gpr_notify_id_t; +#define ORTE_GPR_NOTIFY_ID_T DPS_TYPE_SIZE_T #define ORTE_GPR_NOTIFY_ID_MAX SIZE_MAX /* @@ -91,7 +94,7 @@ typedef size_t orte_gpr_notify_id_t; #define ORTE_GPR_ERROR (uint16_t)0xffff typedef uint16_t orte_gpr_cmd_flag_t; - +#define ORTE_GPR_CMD_T ORTE_UINT16 /** Define the addressing mode bit-masks for registry operations. * @@ -117,7 +120,7 @@ typedef uint16_t orte_gpr_cmd_flag_t; #define ORTE_GPR_NO_OVERWRITE (uint16_t)0x0000 /**< Do not allow overwrite of existing info */ typedef uint16_t orte_gpr_addr_mode_t; - +#define ORTE_GPR_ADDR_MODE_T ORTE_UINT16 /* * typedefs */ diff --git a/src/mca/gpr/replica/communications/gpr_replica_cmd_processor.c b/src/mca/gpr/replica/communications/gpr_replica_cmd_processor.c index 81fd91ed9d..a0d66522ef 100644 --- a/src/mca/gpr/replica/communications/gpr_replica_cmd_processor.c +++ b/src/mca/gpr/replica/communications/gpr_replica_cmd_processor.c @@ -41,9 +41,9 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer, orte_buffer_t *answer; orte_gpr_cmd_flag_t command; int rc, ret, rc2; - size_t n; + size_t n, num_vals; bool compound_cmd=false; - + orte_data_type_t type; *output_buffer = OBJ_NEW(orte_buffer_t); if (NULL == *output_buffer) { @@ -55,9 +55,12 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer, n = 1; rc = ORTE_SUCCESS; ret = ORTE_SUCCESS; - - while (ORTE_SUCCESS == orte_dps.unpack(input_buffer, &command, &n, ORTE_GPR_CMD)) { + while (ORTE_SUCCESS == orte_dps.peek(input_buffer, &type, &num_vals)) { + if (ORTE_SUCCESS != + orte_dps.unpack(input_buffer, &command, &n, ORTE_GPR_CMD)) { + break; + } switch(command) { case ORTE_GPR_COMPOUND_CMD: /***** COMPOUND COMMAND ******/ 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 321375f281..f6139f222a 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 @@ -76,8 +76,6 @@ int orte_gpr_replica_process_callbacks(void) goto CLEANUP; } - orte_gpr_replica_dump_notify_msg(msg->message, 0); - data = (msg->message)->data; sdata = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr); for (i=0; i < (msg->message)->cnt; i++) { 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 71e3f5537b..2d618dd4be 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 @@ -355,7 +355,6 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode, } /* if something found, convert it to array of values */ -ompi_output(0, "REPLICA-GET: VALUES FOUND"); *values = (orte_gpr_value_t**)malloc((*cnt) * sizeof(orte_gpr_value_t*)); if (NULL == *values) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); @@ -419,7 +418,6 @@ ompi_output(0, "REPLICA-GET: VALUES FOUND"); OBJ_RELEASE(ival_list); } OBJ_RELEASE(gptr); - orte_gpr_replica_dump_value((*values)[i], 0); } CLEANUP: diff --git a/src/mca/ns/base/Makefile.am b/src/mca/ns/base/Makefile.am index 6dafc7a82a..15f7f7586d 100644 --- a/src/mca/ns/base/Makefile.am +++ b/src/mca/ns/base/Makefile.am @@ -16,6 +16,8 @@ include $(top_srcdir)/config/Makefile.options +SUBDIRS = data_type_support + noinst_LTLIBRARIES = libmca_ns_base.la # For VPATH builds, have to specify where static-modules.h will be found @@ -25,6 +27,7 @@ AM_CPPFLAGS = -I$(top_builddir)/src # Source code files headers = \ + ns_base_nds.h \ base.h # Library @@ -34,7 +37,6 @@ libmca_ns_base_la_SOURCES = \ ns_base_close.c \ ns_base_select.c \ ns_base_open.c \ - ns_base_nds.h \ ns_base_nds.c \ ns_base_nds_env.c \ ns_base_nds_pipe.c \ diff --git a/src/mca/ns/base/base.h b/src/mca/ns/base/base.h index 6733756e2d..3f06dd1257 100644 --- a/src/mca/ns/base/base.h +++ b/src/mca/ns/base/base.h @@ -145,20 +145,37 @@ OMPI_DECLSPEC int orte_ns_base_derive_vpid(orte_vpid_t *vpid, OMPI_DECLSPEC int orte_ns_base_assign_rml_tag_not_available(orte_rml_tag_t *tag, char *name); OMPI_DECLSPEC int orte_ns_base_define_data_type_not_available( - orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, const char *name, orte_data_type_t *type); -OMPI_DECLSPEC int orte_ns_base_lookup_data_type_not_available( - orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type); - OMPI_DECLSPEC int orte_ns_base_set_my_name(void); OMPI_DECLSPEC int orte_ns_base_get_peers(orte_process_name_t **procs, size_t *num_procs, size_t *self); + +OMPI_DECLSPEC int orte_ns_base_pack_name(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_pack_cellid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_pack_jobid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_pack_vpid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_unpack_name(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_unpack_cellid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_unpack_jobid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +OMPI_DECLSPEC int orte_ns_base_unpack_vpid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); /* * globals that might be needed */ diff --git a/src/mca/ns/base/data_type_support/Makefile.am b/src/mca/ns/base/data_type_support/Makefile.am new file mode 100644 index 0000000000..5d98659faf --- /dev/null +++ b/src/mca/ns/base/data_type_support/Makefile.am @@ -0,0 +1,38 @@ +# +# 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 $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_ns_base_data_type.la + +# Source code files + +headers = + +libmca_ns_base_data_type_la_SOURCES = \ + $(headers) \ + ns_data_type_packing_fns.c \ + ns_data_type_unpacking_fns.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +ompidir = $(includedir)/openmpi/mca/ns/base/data_type_support +ompi_HEADERS = $(headers) +else +ompidir = $(includedir) +endif + 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 new file mode 100644 index 0000000000..64bd7409b0 --- /dev/null +++ b/src/mca/ns/base/data_type_support/ns_data_type_packing_fns.c @@ -0,0 +1,167 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/ns/base/base.h" + +/* + * NAME + */ +int orte_ns_base_pack_name(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + size_t i; + orte_process_name_t* proc; + orte_cellid_t *cellid; + orte_jobid_t *jobid; + orte_vpid_t *vpid; + + /* collect all the cellids in a contiguous array */ + cellid = (orte_cellid_t*)malloc(num_vals * sizeof(orte_cellid_t)); + if (NULL == cellid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + proc = (orte_process_name_t*)src; + for (i=0; i < num_vals; i++) { + if (ORTE_SUCCESS != (rc = orte_ns.get_cellid(&cellid[i], proc))) { + ORTE_ERROR_LOG(rc); + free(cellid); + return rc; + } + proc++; + } + /* now pack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_pack_cellid(buffer, cellid, num_vals, ORTE_CELLID))) { + ORTE_ERROR_LOG(rc); + free(cellid); + return rc; + } + free(cellid); + + /* collect all the jobids in a contiguous array */ + jobid = (orte_jobid_t*)malloc(num_vals * sizeof(orte_jobid_t)); + if (NULL == jobid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + proc = (orte_process_name_t*)src; + for (i=0; i < num_vals; i++) { + if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid[i], proc))) { + ORTE_ERROR_LOG(rc); + free(jobid); + return rc; + } + proc++; + } + /* now pack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_pack_jobid(buffer, jobid, num_vals, ORTE_JOBID))) { + ORTE_ERROR_LOG(rc); + free(jobid); + return rc; + } + free(jobid); + + /* collect all the vpids in a contiguous array */ + vpid = (orte_vpid_t*)malloc(num_vals * sizeof(orte_vpid_t)); + if (NULL == vpid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + proc = (orte_process_name_t*)src; + for (i=0; i < num_vals; i++) { + if (ORTE_SUCCESS != (rc = orte_ns.get_vpid(&vpid[i], proc))) { + ORTE_ERROR_LOG(rc); + free(vpid); + return rc; + } + proc++; + } + /* now pack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_pack_vpid(buffer, vpid, num_vals, ORTE_VPID))) { + ORTE_ERROR_LOG(rc); + free(vpid); + return rc; + } + free(vpid); + + return ORTE_SUCCESS; +} + +/* + * CELLID + */ +int orte_ns_base_pack_cellid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and pack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_pack_buffer(buffer, src, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + +/* + * JOBID + */ +int orte_ns_base_pack_jobid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and pack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_pack_buffer(buffer, src, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + +/* + * VPID + */ +int orte_ns_base_pack_vpid(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and pack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_pack_buffer(buffer, src, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + diff --git a/src/mca/ns/base/data_type_support/ns_data_type_unpacking_fns.c b/src/mca/ns/base/data_type_support/ns_data_type_unpacking_fns.c new file mode 100644 index 0000000000..5d8f8b8414 --- /dev/null +++ b/src/mca/ns/base/data_type_support/ns_data_type_unpacking_fns.c @@ -0,0 +1,165 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/ns/base/base.h" + +/* + * NAME + */ +int orte_ns_base_unpack_name(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + size_t i, num; + orte_process_name_t* proc; + orte_cellid_t *cellid; + orte_jobid_t *jobid; + orte_vpid_t *vpid; + + num = *num_vals; + + /* allocate space for all the cellids in a contiguous array */ + cellid = (orte_cellid_t*)malloc(num * sizeof(orte_cellid_t)); + if (NULL == cellid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + *num_vals = 0; + return ORTE_ERR_OUT_OF_RESOURCE; + } + /* now unpack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_unpack_cellid(buffer, cellid, num_vals, ORTE_CELLID))) { + ORTE_ERROR_LOG(rc); + *num_vals = 0; + free(cellid); + return rc; + } + + /* allocate space for all the jobids in a contiguous array */ + jobid = (orte_jobid_t*)malloc(num * sizeof(orte_jobid_t)); + if (NULL == jobid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + *num_vals = 0; + free(cellid); + return ORTE_ERR_OUT_OF_RESOURCE; + } + /* now unpack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_unpack_jobid(buffer, jobid, num_vals, ORTE_JOBID))) { + ORTE_ERROR_LOG(rc); + *num_vals = 0; + free(jobid); + free(cellid); + return rc; + } + + /* collect all the vpids in a contiguous array */ + vpid = (orte_vpid_t*)malloc(num * sizeof(orte_vpid_t)); + if (NULL == vpid) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + *num_vals = 0; + free(jobid); + free(cellid); + return ORTE_ERR_OUT_OF_RESOURCE; + } + /* now unpack them in one shot */ + if (ORTE_SUCCESS != (rc = + orte_ns_base_unpack_vpid(buffer, vpid, num_vals, ORTE_VPID))) { + ORTE_ERROR_LOG(rc); + *num_vals = 0; + free(vpid); + free(jobid); + free(cellid); + return rc; + } + + /* build the names from the cellid/jobid/vpid arrays */ + proc = (orte_process_name_t*)dest; + for (i=0; i < num; i++) { + proc->cellid = cellid[i]; + proc->jobid = jobid[i]; + proc->vpid = vpid[i]; + proc++; + } + + /* cleanup */ + free(vpid); + free(jobid); + free(cellid); + + return ORTE_SUCCESS; +} + +/* + * CELLID + */ +int orte_ns_base_unpack_cellid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and unpack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_unpack_buffer(buffer, dest, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + +/* + * JOBID + */ +int orte_ns_base_unpack_jobid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and unpack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_unpack_buffer(buffer, dest, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + +/* + * VPID + */ +int orte_ns_base_unpack_vpid(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int ret; + + /* Turn around and unpack the real type */ + if (ORTE_SUCCESS != ( + ret = orte_dps_unpack_buffer(buffer, dest, num_vals, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(ret); + } + + return ret; +} + diff --git a/src/mca/ns/base/ns_base_local_fns.c b/src/mca/ns/base/ns_base_local_fns.c index 547570deff..884232dbca 100644 --- a/src/mca/ns/base/ns_base_local_fns.c +++ b/src/mca/ns/base/ns_base_local_fns.c @@ -79,8 +79,6 @@ orte_ns_base_assign_rml_tag_not_available(orte_rml_tag_t *tag, char *name) int orte_ns_base_define_data_type_not_available( - orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, const char *name, orte_data_type_t *type) { @@ -88,18 +86,6 @@ orte_ns_base_define_data_type_not_available( return ORTE_ERR_UNREACH; } -int -orte_ns_base_lookup_data_type_not_available( - orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type) -{ - *pack_fn = NULL; - *unpack_fn = NULL; - *name = NULL; - return ORTE_ERR_UNREACH; -} - /* * functions diff --git a/src/mca/ns/base/ns_base_open.c b/src/mca/ns/base/ns_base_open.c index c43ce4a13a..314889b813 100644 --- a/src/mca/ns/base/ns_base_open.c +++ b/src/mca/ns/base/ns_base_open.c @@ -21,8 +21,11 @@ #include "mca/mca.h" #include "mca/base/base.h" #include "mca/base/mca_base_param.h" +#include "mca/errmgr/errmgr.h" #include "util/output.h" +#include "dps/dps.h" + #include "mca/ns/base/base.h" @@ -71,7 +74,6 @@ mca_ns_base_module_t orte_ns = { orte_ns_base_derive_vpid, orte_ns_base_assign_rml_tag_not_available, orte_ns_base_define_data_type_not_available, - orte_ns_base_lookup_data_type_not_available, orte_ns_base_set_my_name, orte_ns_base_get_peers }; @@ -109,7 +111,8 @@ OBJ_CLASS_INSTANCE( */ int orte_ns_base_open(void) { - int param, value; + int param, value, rc; + orte_data_type_t tmp; /* Debugging / verbose output */ @@ -122,6 +125,39 @@ int orte_ns_base_open(void) mca_ns_base_output = -1; } + /* register the base system types with the DPS */ + tmp = ORTE_NAME; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_ns_base_pack_name, + orte_ns_base_unpack_name, + "ORTE_NAME", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_VPID; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_ns_base_pack_vpid, + orte_ns_base_unpack_vpid, + "ORTE_VPID", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_JOBID; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_ns_base_pack_jobid, + orte_ns_base_unpack_jobid, + "ORTE_JOBID", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_CELLID; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_ns_base_pack_cellid, + orte_ns_base_unpack_cellid, + "ORTE_CELLID", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Open up all available components */ if (ORTE_SUCCESS != diff --git a/src/mca/ns/ns.h b/src/mca/ns/ns.h index 0bd532606a..22ec661884 100644 --- a/src/mca/ns/ns.h +++ b/src/mca/ns/ns.h @@ -530,25 +530,14 @@ typedef int (*orte_ns_base_module_compare_fn_t)(orte_ns_cmp_bitmask_t fields, typedef int (*orte_ns_base_module_assign_rml_tag_fn_t)(orte_rml_tag_t *tag, char *name); -/* This function registers a pack/unpack function pair for a specific - * type. This - * is most useful when extending the datatypes that the DPS can - * handle; pack and unpack functions can nest calls to orte_dps.pack() - * / orte_dps.unpack(), so defining small pack/unpack functions can be - * used recursively to build larger types (e.g., packing/unpacking - * structs can use calls to orte_dps.pack()/unpack() to serialize / - * deserialize individual members). +/* This function defines a new data type and gives it a system-wide unique + * identifier for use in the data packing subsystem. Only called from the + * dps when needing a new identifier. */ typedef int (*orte_ns_base_module_define_data_type_fn_t)( - orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, const char *name, orte_data_type_t *type); -typedef int (*orte_ns_base_module_lookup_data_type_fn_t)( - orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type); /* * Discover my name @@ -602,7 +591,6 @@ struct mca_ns_base_module_1_0_0_t { orte_ns_base_module_derive_vpid_fn_t derive_vpid; orte_ns_base_module_assign_rml_tag_fn_t assign_rml_tag; orte_ns_base_module_define_data_type_fn_t define_data_type; - orte_ns_base_module_lookup_data_type_fn_t lookup_data_type; orte_ns_base_module_set_my_name_fn_t set_my_name; orte_ns_base_module_get_peers_fn_t get_peers; }; diff --git a/src/mca/ns/proxy/src/ns_proxy.c b/src/mca/ns/proxy/src/ns_proxy.c index bf13fa10ae..47baaf9bbe 100644 --- a/src/mca/ns/proxy/src/ns_proxy.c +++ b/src/mca/ns/proxy/src/ns_proxy.c @@ -368,10 +368,8 @@ int orte_ns_proxy_assign_rml_tag(orte_rml_tag_t *tag, } -int orte_ns_proxy_define_data_type(orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, - const char *name, - orte_data_type_t *type) +int orte_ns_proxy_define_data_type(const char *name, + orte_data_type_t *type) { orte_buffer_t* cmd; orte_buffer_t* answer; @@ -380,22 +378,25 @@ int orte_ns_proxy_define_data_type(orte_dps_pack_fn_t pack_fn, size_t count; int rc; + if (NULL == name || 0 < *type) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + OMPI_THREAD_LOCK(&orte_ns_proxy_mutex); - if (NULL != name) { - /* first, check to see if name is already on local list - * if so, return id - */ - for (dti = (orte_ns_proxy_dti_t*)ompi_list_get_first(&orte_ns_proxy_dtlist); - dti != (orte_ns_proxy_dti_t*)ompi_list_get_end(&orte_ns_proxy_dtlist); - dti = (orte_ns_proxy_dti_t*)ompi_list_get_next(dti)) { - if (0 == strcmp(name, dti->name)) { /* found name on list */ - *type = dti->id; - OMPI_THREAD_UNLOCK(&orte_ns_proxy_mutex); - return ORTE_SUCCESS; - } + /* first, check to see if name is already on local list + * if so, return id, ensure registered with dps + */ + for (dti = (orte_ns_proxy_dti_t*)ompi_list_get_first(&orte_ns_proxy_dtlist); + dti != (orte_ns_proxy_dti_t*)ompi_list_get_end(&orte_ns_proxy_dtlist); + dti = (orte_ns_proxy_dti_t*)ompi_list_get_next(dti)) { + if (0 == strcmp(name, dti->name)) { /* found name on list */ + *type = dti->id; + OMPI_THREAD_UNLOCK(&orte_ns_proxy_mutex); + return rc; } - } + } /* okay, not on local list - so go get one from tag server */ command = ORTE_NS_DEFINE_DATA_TYPE_CMD; @@ -414,10 +415,6 @@ int orte_ns_proxy_define_data_type(orte_dps_pack_fn_t pack_fn, return rc; } - if (NULL == name) { - name = "NULL"; - } - if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &name, 1, ORTE_STRING))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); @@ -479,43 +476,11 @@ int orte_ns_proxy_define_data_type(orte_dps_pack_fn_t pack_fn, return ORTE_ERR_OUT_OF_RESOURCE; } dti->id = *type; - if (NULL != name) { - dti->name = strdup(name); - } else { - dti->name = NULL; - } - dti->pack_fn = pack_fn; - dti->unpack_fn = unpack_fn; + dti->name = strdup(name); ompi_list_append(&orte_ns_proxy_taglist, &dti->item); OMPI_THREAD_UNLOCK(&orte_ns_proxy_mutex); /* all done */ - return ORTE_SUCCESS; + return rc; } -int orte_ns_proxy_lookup_data_type(orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type) -{ - orte_ns_proxy_dti_t *dti; - - OMPI_THREAD_LOCK(&orte_ns_proxy_mutex); - - for (dti = (orte_ns_proxy_dti_t*)ompi_list_get_first(&orte_ns_proxy_dtlist); - dti != (orte_ns_proxy_dti_t*)ompi_list_get_end(&orte_ns_proxy_dtlist); - dti = (orte_ns_proxy_dti_t*)ompi_list_get_next(dti)) { - if (dti->name != NULL && type != dti->id) { /* found name on list */ - if (NULL != name) { - *name = strdup(dti->name); - } - *pack_fn = dti->pack_fn; - *unpack_fn = dti->unpack_fn; - OMPI_THREAD_UNLOCK(&orte_ns_proxy_mutex); - return ORTE_SUCCESS; - } - } - - OMPI_THREAD_UNLOCK(&orte_ns_proxy_mutex); - ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); - return ORTE_ERR_NOT_FOUND; -} diff --git a/src/mca/ns/proxy/src/ns_proxy.h b/src/mca/ns/proxy/src/ns_proxy.h index e863173d63..535c42758f 100644 --- a/src/mca/ns/proxy/src/ns_proxy.h +++ b/src/mca/ns/proxy/src/ns_proxy.h @@ -44,8 +44,6 @@ struct orte_ns_proxy_dti_t { ompi_list_item_t item; /**< Allows this item to be placed on a list */ orte_data_type_t id; /**< data type id */ char *name; /**< Name associated with data type */ - orte_dps_pack_fn_t pack_fn; /**< packing fn for data type */ - orte_dps_unpack_fn_t unpack_fn; /**< unpack fn for data type */ }; typedef struct orte_ns_proxy_dti_t orte_ns_proxy_dti_t; @@ -88,14 +86,8 @@ int orte_ns_proxy_reserve_range(orte_jobid_t job, orte_vpid_t range, int orte_ns_proxy_assign_rml_tag(orte_rml_tag_t *tag, char *name); -int orte_ns_proxy_define_data_type(orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, - const char *name, - orte_data_type_t *type); - -int orte_ns_proxy_lookup_data_type(orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type); +int orte_ns_proxy_define_data_type(const char *name, + orte_data_type_t *type); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/src/mca/ns/proxy/src/ns_proxy_component.c b/src/mca/ns/proxy/src/ns_proxy_component.c index 62831c38b4..410072b82e 100644 --- a/src/mca/ns/proxy/src/ns_proxy_component.c +++ b/src/mca/ns/proxy/src/ns_proxy_component.c @@ -89,7 +89,6 @@ static mca_ns_base_module_t orte_ns_proxy = { orte_ns_base_derive_vpid, orte_ns_proxy_assign_rml_tag, orte_ns_proxy_define_data_type, - orte_ns_proxy_lookup_data_type, orte_ns_base_set_my_name, orte_ns_base_get_peers }; @@ -126,8 +125,6 @@ static void orte_ns_proxy_dti_construct(orte_ns_proxy_dti_t* dti) { dti->id = ORTE_DPS_ID_MAX; dti->name = NULL; - dti->pack_fn = NULL; - dti->unpack_fn = NULL; } /* destructor - used to free any resources held by instance */ diff --git a/src/mca/ns/replica/src/ns_replica.c b/src/mca/ns/replica/src/ns_replica.c index ed3044ffdb..5ee60e3541 100644 --- a/src/mca/ns/replica/src/ns_replica.c +++ b/src/mca/ns/replica/src/ns_replica.c @@ -172,52 +172,29 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag, } -int orte_ns_replica_define_data_type(orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, - const char *name, +int orte_ns_replica_define_data_type(const char *name, orte_data_type_t *type) { orte_ns_replica_dti_t *dti; + if (NULL == name || 0 < *type) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + OMPI_THREAD_LOCK(&orte_ns_replica_mutex); - if (NULL != name) { - /* see if this name is already in list - if so, return id */ - for (dti = (orte_ns_replica_dti_t*)ompi_list_get_first(&orte_ns_replica_dtlist); - dti != (orte_ns_replica_dti_t*)ompi_list_get_end(&orte_ns_replica_dtlist); - dti = (orte_ns_replica_dti_t*)ompi_list_get_next(dti)) { - if (dti->name != NULL && 0 == strcmp(name, dti->name)) { /* found name on list */ - *type = dti->id; - OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); - return ORTE_SUCCESS; - } + /* see if this name is already in list - if so, return id */ + for (dti = (orte_ns_replica_dti_t*)ompi_list_get_first(&orte_ns_replica_dtlist); + dti != (orte_ns_replica_dti_t*)ompi_list_get_end(&orte_ns_replica_dtlist); + dti = (orte_ns_replica_dti_t*)ompi_list_get_next(dti)) { + if (dti->name != NULL && 0 == strcmp(name, dti->name)) { /* found name on list */ + *type = dti->id; + OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); + return ORTE_SUCCESS; } } - /* if we are provided with the type (i.e., *type > 0), then - * just store the name and the pack/unpack fn pointers - * for later use - */ - if (0 < *type) { - if (NULL == name) { /* must provide the name in this situation */ - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); - return ORTE_ERR_BAD_PARAM; - } - dti = OBJ_NEW(orte_ns_replica_dti_t); - if (NULL == dti) { /* out of memory */ - OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - dti->id = *type; - dti->name = strdup(name); - dti->pack_fn = pack_fn; - dti->unpack_fn = unpack_fn; - ompi_list_append(&orte_ns_replica_dtlist, &dti->item); - return ORTE_SUCCESS; - } - /* not in list or not provided, so allocate next id * first check to see if one available - else error */ @@ -231,13 +208,7 @@ int orte_ns_replica_define_data_type(orte_dps_pack_fn_t pack_fn, return ORTE_ERR_OUT_OF_RESOURCE; } dti->id = orte_ns_replica_next_dti; - if (NULL != name) { /* provided - can look it up later */ - dti->name = strdup(name); - } else { - dti->name = NULL; - } - dti->pack_fn = pack_fn; - dti->unpack_fn = unpack_fn; + dti->name = strdup(name); orte_ns_replica_next_dti++; ompi_list_append(&orte_ns_replica_dtlist, &dti->item); @@ -254,37 +225,3 @@ int orte_ns_replica_define_data_type(orte_dps_pack_fn_t pack_fn, } -int orte_ns_replica_lookup_data_type(orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type) -{ - orte_ns_replica_dti_t *dti; - - OMPI_THREAD_LOCK(&orte_ns_replica_mutex); - - for (dti = (orte_ns_replica_dti_t*)ompi_list_get_first(&orte_ns_replica_dtlist); - dti != (orte_ns_replica_dti_t*)ompi_list_get_end(&orte_ns_replica_dtlist); - dti = (orte_ns_replica_dti_t*)ompi_list_get_next(dti)) { - if (dti->name != NULL && type != dti->id) { /* found name on list */ - if (NULL != name) { - *name = strdup(dti->name); - } - if (NULL != pack_fn) { - *pack_fn = dti->pack_fn; - } - if (NULL != unpack_fn) { - *unpack_fn = dti->unpack_fn; - } - OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); - return ORTE_SUCCESS; - } - } - - if (NULL != name) *name = NULL; - if (NULL != pack_fn) *pack_fn = NULL; - if (NULL != unpack_fn) *unpack_fn = NULL; - - OMPI_THREAD_UNLOCK(&orte_ns_replica_mutex); - ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); - return ORTE_ERR_NOT_FOUND; -} diff --git a/src/mca/ns/replica/src/ns_replica.h b/src/mca/ns/replica/src/ns_replica.h index 26781366f2..a5685524be 100644 --- a/src/mca/ns/replica/src/ns_replica.h +++ b/src/mca/ns/replica/src/ns_replica.h @@ -57,8 +57,6 @@ struct orte_ns_replica_dti_t { ompi_list_item_t item; /**< Allows this item to be placed on a list */ orte_data_type_t id; /**< data type id */ char *name; /**< Name associated with data type */ - orte_dps_pack_fn_t pack_fn; /**< packing fn for data type */ - orte_dps_unpack_fn_t unpack_fn; /**< unpack fn for data type */ }; typedef struct orte_ns_replica_dti_t orte_ns_replica_dti_t; @@ -123,15 +121,9 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag, char *name); -int orte_ns_replica_define_data_type(orte_dps_pack_fn_t pack_fn, - orte_dps_unpack_fn_t unpack_fn, - const char *name, +int orte_ns_replica_define_data_type(const char *name, orte_data_type_t *type); -int orte_ns_replica_lookup_data_type(orte_dps_pack_fn_t *pack_fn, - orte_dps_unpack_fn_t *unpack_fn, - char **name, orte_data_type_t type); - #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/mca/ns/replica/src/ns_replica_component.c b/src/mca/ns/replica/src/ns_replica_component.c index 64556534b3..20e8edaa36 100644 --- a/src/mca/ns/replica/src/ns_replica_component.c +++ b/src/mca/ns/replica/src/ns_replica_component.c @@ -94,7 +94,6 @@ static mca_ns_base_module_t orte_ns_replica = { orte_ns_base_derive_vpid, orte_ns_replica_assign_rml_tag, orte_ns_replica_define_data_type, - orte_ns_replica_lookup_data_type, orte_ns_base_set_my_name, orte_ns_base_get_peers }; @@ -151,8 +150,6 @@ static void orte_ns_replica_dti_construct(orte_ns_replica_dti_t* dti) { dti->id = ORTE_DPS_ID_MAX; dti->name = NULL; - dti->pack_fn = NULL; - dti->unpack_fn = NULL; } /* destructor - used to free any resources held by instance */ @@ -462,15 +459,9 @@ void orte_ns_replica_recv(int status, orte_process_name_t* sender, goto RETURN_ERROR; } - if (0 == strncmp(tagname, "NULL", 4)) { - if (ORTE_SUCCESS != (rc = orte_ns_replica_define_data_type(NULL, NULL, NULL, &type))) { - goto RETURN_ERROR; - } - } else { - if (ORTE_SUCCESS != (rc = orte_ns_replica_define_data_type(NULL, NULL, tagname, &type))) { - goto RETURN_ERROR; - } - } + if (ORTE_SUCCESS != (rc = orte_ns_replica_define_data_type(tagname, &type))) { + goto RETURN_ERROR; + } if (OMPI_SUCCESS != (rc = orte_dps.pack(&answer, (void*)&command, 1, ORTE_NS_CMD))) { goto RETURN_ERROR; diff --git a/src/mca/rmgr/base/Makefile.am b/src/mca/rmgr/base/Makefile.am index b14b40b582..a6aba7d924 100644 --- a/src/mca/rmgr/base/Makefile.am +++ b/src/mca/rmgr/base/Makefile.am @@ -16,6 +16,8 @@ include $(top_srcdir)/config/Makefile.options +SUBDIRS = data_type_support + noinst_LTLIBRARIES = libmca_orte_rmgr_base.la # For VPATH builds, have to specify where static-modules.h will be found diff --git a/src/mca/rmgr/base/base.h b/src/mca/rmgr/base/base.h index 9fbcfa96ef..f73ca953be 100644 --- a/src/mca/rmgr/base/base.h +++ b/src/mca/rmgr/base/base.h @@ -128,6 +128,25 @@ int orte_rmgr_base_spawn_not_available( orte_rmgr_cb_fn_t cbfn); int orte_rmgr_base_finalize_not_available(void); +/* + * DATA TYPE PACKING FUNCTIONS + */ +int orte_rmgr_base_pack_app_context(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_rmgr_base_pack_app_context_map(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +/* + * DATA TYPE UNPACKING FUNCTIONS + */ +int orte_rmgr_base_unpack_app_context(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_rmgr_base_unpack_app_context_map(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + + /* * globals that might be needed */ diff --git a/src/mca/rmgr/base/data_type_support/Makefile.am b/src/mca/rmgr/base/data_type_support/Makefile.am new file mode 100644 index 0000000000..f5a9347452 --- /dev/null +++ b/src/mca/rmgr/base/data_type_support/Makefile.am @@ -0,0 +1,38 @@ +# +# 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 $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_rmgr_base_data_type.la + +# Source code files + +headers = + +libmca_rmgr_base_data_type_la_SOURCES = \ + $(headers) \ + rmgr_data_type_packing_fns.c \ + rmgr_data_type_unpacking_fns.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +ompidir = $(includedir)/openmpi/mca/rmgr/base/data_type_support +ompi_HEADERS = $(headers) +else +ompidir = $(includedir) +endif + diff --git a/src/mca/rmgr/base/data_type_support/rmgr_data_type_packing_fns.c b/src/mca/rmgr/base/data_type_support/rmgr_data_type_packing_fns.c new file mode 100644 index 0000000000..96fc53c699 --- /dev/null +++ b/src/mca/rmgr/base/data_type_support/rmgr_data_type_packing_fns.c @@ -0,0 +1,148 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/rmgr/base/base.h" + +/* + * APP CONTEXT + */ +int orte_rmgr_base_pack_app_context(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + size_t i; + orte_app_context_t **app_context; + + /* array of pointers to orte_app_context objects - need to pack the objects a set of fields at a time */ + app_context = (orte_app_context_t**) src; + + for (i=0; i < num_vals; i++) { + /* pack the application index (for multiapp jobs) */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->idx)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the application name */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->app)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of processes */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->num_procs)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* pack the number of entries in the argv array */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->argc)), 1, ORTE_INT))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are entries, pack the argv entries */ + if (0 < app_context[i]->argc) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(app_context[i]->argv), (size_t)app_context[i]->argc, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* pack the number of entries in the enviro array */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->num_env)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are entries, pack the enviro entries */ + if (0 < app_context[i]->num_env) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(app_context[i]->env), app_context[i]->num_env, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* pack the cwd */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->cwd)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* Pack the map data */ + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context[i]->num_map)), 1, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + if (app_context[i]->num_map > 0) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(app_context[i]->map_data), app_context[i]->num_map, ORTE_APP_CONTEXT_MAP))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + } + + return ORTE_SUCCESS; +} + +/* + * APP CONTEXT MAP + */ +int orte_rmgr_base_pack_app_context_map(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + orte_app_context_map_t **app_context_map; + size_t i; + + app_context_map = (orte_app_context_map_t**) src; + for (i=0; i < num_vals; i++) { + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context_map[i]->map_type)), 1, ORTE_UINT8))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, + (void*)(&(app_context_map[i]->map_data)), 1, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} diff --git a/src/mca/rmgr/base/data_type_support/rmgr_data_type_unpacking_fns.c b/src/mca/rmgr/base/data_type_support/rmgr_data_type_unpacking_fns.c new file mode 100644 index 0000000000..d43af2a07d --- /dev/null +++ b/src/mca/rmgr/base/data_type_support/rmgr_data_type_unpacking_fns.c @@ -0,0 +1,188 @@ +/* + * 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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/rmgr/base/base.h" + +/* + * APP_CONTEXT + */ +int orte_rmgr_base_unpack_app_context(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_app_context_t **app_context; + size_t i, max_n=1; + + /* unpack into array of app_context objects */ + app_context = (orte_app_context_t**) dest; + for (i=0; i < *num_vals; i++) { + + /* create the app_context object */ + app_context[i] = OBJ_NEW(orte_app_context_t); + if (NULL == app_context[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* get the app index number */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->idx), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the application name */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->app), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* get the number of processes */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->num_procs), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* get the number of argv strings */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->argc), + &max_n, ORTE_INT))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are argv strings, allocate the required space for the char * pointers */ + if (0 < app_context[i]->argc) { + app_context[i]->argv = (char **)malloc((app_context[i]->argc+1) * sizeof(char*)); + if (NULL == app_context[i]->argv) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + app_context[i]->argv[app_context[i]->argc] = NULL; + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, app_context[i]->argv, + (size_t*)(&app_context[i]->argc), ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* get the number of env strings */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->num_env), + &max_n, DPS_TYPE_SIZE_T))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* if there are env strings, allocate the required space for the char * pointers */ + if (0 < app_context[i]->num_env) { + app_context[i]->env = (char **)malloc((app_context[i]->num_env+1) * sizeof(char*)); + if (NULL == app_context[i]->env) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + app_context[i]->env[app_context[i]->num_env] = NULL; + + /* and unpack them */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, app_context[i]->env, + &(app_context[i]->num_env), ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + /* unpack the cwd */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &app_context[i]->cwd, + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* unpack the map data */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context[i]->num_map), + &max_n, DPS_TYPE_SIZE_T))) { + return rc; + } + + if (app_context[i]->num_map > 0) { + app_context[i]->map_data = malloc(sizeof(orte_app_context_map_t*) * app_context[i]->num_map); + if (NULL == app_context[i]->map_data) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, app_context[i]->map_data, + &(app_context[i]->num_map), ORTE_APP_CONTEXT_MAP))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + } + + return ORTE_SUCCESS; +} + +/* + * APP_CONTEXT_MAP + */ +int orte_rmgr_base_unpack_app_context_map(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + orte_app_context_map_t **app_context_map; + size_t i, max_n=1; + + /* unpack into array of app_context_map objects */ + app_context_map = (orte_app_context_map_t**) dest; + for (i=0; i < *num_vals; i++) { + + /* create the app_context object */ + app_context_map[i] = OBJ_NEW(orte_app_context_map_t); + if (NULL == app_context_map[i]) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + /* map type */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context_map[i]->map_type), + &max_n, ORTE_UINT8))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* map data */ + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(app_context_map[i]->map_data), + &max_n, ORTE_STRING))) { + ORTE_ERROR_LOG(rc); + return rc; + } + } + + return ORTE_SUCCESS; +} + diff --git a/src/mca/rmgr/base/rmgr_base_open.c b/src/mca/rmgr/base/rmgr_base_open.c index 5f85883797..24b7cd7c3e 100644 --- a/src/mca/rmgr/base/rmgr_base_open.c +++ b/src/mca/rmgr/base/rmgr_base_open.c @@ -18,14 +18,16 @@ #include "orte_config.h" #include "include/orte_constants.h" +#include "dps/dps.h" #include "mca/mca.h" #include "mca/base/base.h" #include "mca/base/mca_base_param.h" +#include "mca/errmgr/errmgr.h" #include "util/output.h" -#include "mca/rmgr/base/base.h" - #include "util/argv.h" +#include "mca/rmgr/base/base.h" + /* @@ -144,7 +146,8 @@ OBJ_CLASS_INSTANCE(orte_app_context_map_t, int orte_rmgr_base_open(void) { - int param, value; + int param, value, rc; + orte_data_type_t tmp; /* Debugging / verbose output */ @@ -157,6 +160,23 @@ int orte_rmgr_base_open(void) orte_rmgr_base.rmgr_output = -1; } + /* register the base system types with the DPS */ + tmp = ORTE_APP_CONTEXT; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_rmgr_base_pack_app_context, + orte_rmgr_base_unpack_app_context, + "ORTE_APP_CONTEXT", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_APP_CONTEXT_MAP; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_rmgr_base_pack_app_context_map, + orte_rmgr_base_unpack_app_context_map, + "ORTE_APP_CONTEXT_MAP", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Open up all available components */ if (ORTE_SUCCESS != diff --git a/src/mca/schema/base/schema_base_fns.c b/src/mca/schema/base/schema_base_fns.c index e69de29bb2..b50842f7f5 100644 --- a/src/mca/schema/base/schema_base_fns.c +++ b/src/mca/schema/base/schema_base_fns.c @@ -0,0 +1,158 @@ +/* -*- C -*- + * + * 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: + * + * Convenience functions for accessing the General Purpose Registry + * + */ + +/* + * includes + */ +#include "orte_config.h" + +#include + +#include "include/orte_constants.h" +#include "util/output.h" +#include "mca/ns/ns.h" +#include "mca/errmgr/errmgr.h" + +#include "mca/schema/base/base.h" + + +int orte_schema_base_get_proc_tokens(char ***proc_tokens, size_t* num_tokens, orte_process_name_t *proc) +{ + int rc; + char** tokens; + char* vpid_string; + + tokens = (char**)malloc(3 * sizeof(char*)); + if (NULL == tokens) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_ns.get_proc_name_string(&tokens[0], proc))) { + ORTE_ERROR_LOG(rc); + goto CLEANUP; + } + if (ORTE_SUCCESS != (rc = orte_ns.get_vpid_string(&vpid_string, proc))) { + ORTE_ERROR_LOG(rc); + goto CLEANUP; + } + + asprintf(&tokens[1], "%s-%s", ORTE_VPID_KEY, vpid_string); + free(vpid_string); + tokens[2] = NULL; + *proc_tokens = tokens; + if(num_tokens != NULL) + *num_tokens = 2; + return ORTE_SUCCESS; + +CLEANUP: + if (NULL != tokens) { + if (NULL != tokens[0]) + free(tokens[0]); + if (NULL != tokens[1]) + free(tokens[1]); + free(tokens); + } + return rc; +} + +int orte_schema_base_get_node_tokens(char ***node_tokens, size_t* num_tokens, orte_cellid_t cellid, char *nodename) +{ + int rc; + char** tokens; + char* cellid_string; + tokens = (char**)malloc(3 * sizeof(char*)); + if (NULL == tokens) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_ns.convert_cellid_to_string(&cellid_string, cellid))) { + ORTE_ERROR_LOG(rc); + goto CLEANUP; + } + + asprintf(&tokens[0], "%s-%s", ORTE_CELLID_KEY, cellid_string); + free(cellid_string); + tokens[1] = strdup(nodename); + tokens[2] = NULL; + *node_tokens = tokens; + if(num_tokens != NULL) + *num_tokens = 2; + return ORTE_SUCCESS; + +CLEANUP: + if (NULL != tokens) { + if (NULL != tokens[0]) + free(tokens[0]); + if (NULL != tokens[1]) + free(tokens[1]); + free(tokens); + } + return rc; +} + +int orte_schema_base_get_cell_tokens(char ***tokens, size_t* num_tokens, orte_cellid_t cellid) +{ + return ORTE_ERR_NOT_IMPLEMENTED; +} + +int orte_schema_base_get_job_segment_name(char **name, orte_jobid_t jobid) +{ + char *jobidstring; + int rc; + + if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobidstring, jobid))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + if (0 > asprintf(name, "%s-%s", ORTE_JOB_SEGMENT, jobidstring)) { + free(jobidstring); + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + free(jobidstring); + return ORTE_SUCCESS; +} + + +int orte_schema_base_extract_jobid_from_segment_name(orte_jobid_t *jobid, char *name) +{ + char *jobstring; + orte_jobid_t job; + int rc; + + jobstring = strrchr(name, '-'); + if (NULL == jobstring) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + jobstring++; + if (ORTE_SUCCESS != (rc = orte_ns.convert_string_to_jobid(&job, jobstring))) { + ORTE_ERROR_LOG(rc); + ompi_output(0, "[%d,%d,%d] %s\n", ORTE_NAME_ARGS(orte_process_info.my_name), jobstring); + return rc; + } + *jobid = job; + return ORTE_SUCCESS; +} + diff --git a/src/mca/schema/schema_types.h b/src/mca/schema/schema_types.h index 9d911b9fc6..35f9ef1d71 100644 --- a/src/mca/schema/schema_types.h +++ b/src/mca/schema/schema_types.h @@ -21,20 +21,7 @@ #include "mca/ns/ns_types.h" /* - * ORTE_DATA_NAME macro - * This macro is provided so that users can output an intelligible name for a data - * type during debugging. It is called by passing the data type into the macro and - * outputing the result via some print variant. For example, you can call it as: - * ompi_output(0, "data type: %s", ORTE_DATA_NAME(keyval.type)); - * - * THE ACTUAL ARRAY IS INSTANTIATED IN runtime/ompi_init.c - */ - -#define ORTE_DATA_NAME(n) orte_data_strings[n] -extern char *orte_data_strings[]; - -/* - * Similar to the above, this macro and array are used to output intelligible error + * This macro and array are used to output intelligible error * messages. It is disturbing to think that we are still outputing error numbers and * expecting users to look them up in the "big book" to find out what they represent. * This macro allows the user to output an actual string representation of the error. diff --git a/src/mca/soh/base/Makefile.am b/src/mca/soh/base/Makefile.am index a0d57dee9e..0f73310dca 100644 --- a/src/mca/soh/base/Makefile.am +++ b/src/mca/soh/base/Makefile.am @@ -16,6 +16,8 @@ include $(top_srcdir)/config/Makefile.options +SUBDIRS = data_type_support + noinst_LTLIBRARIES = libmca_soh_base.la # For VPATH builds, have to specify where static-modules.h will be found diff --git a/src/mca/soh/base/base.h b/src/mca/soh/base/base.h index 52c605ce91..5eb957eaab 100644 --- a/src/mca/soh/base/base.h +++ b/src/mca/soh/base/base.h @@ -27,6 +27,7 @@ #include "include/orte_types.h" #include "class/ompi_list.h" +#include "dps/dps_types.h" #include "mca/mca.h" /* #include "mca/ns/ns_types.h" */ #include "mca/soh/soh.h" @@ -64,6 +65,30 @@ int orte_soh_base_begin_monitoring_not_available(orte_jobid_t job); int orte_soh_base_module_finalize_not_available (void); +/* + * DATA TYPE PACKING FUNCTIONS + */ +int orte_soh_base_pack_exit_code(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_soh_base_pack_node_state(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +int orte_soh_base_pack_proc_state(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type); + +/* + * DATA TYPE UNPACKING FUNCTIONS + */ +int orte_soh_base_unpack_exit_code(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_soh_base_unpack_node_state(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + +int orte_soh_base_unpack_proc_state(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type); + /* * globals that might be needed */ diff --git a/src/mca/soh/base/data_type_support/Makefile.am b/src/mca/soh/base/data_type_support/Makefile.am new file mode 100644 index 0000000000..aaa7b8fda1 --- /dev/null +++ b/src/mca/soh/base/data_type_support/Makefile.am @@ -0,0 +1,38 @@ +# +# 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 $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_soh_base_data_type.la + +# Source code files + +headers = + +libmca_soh_base_data_type_la_SOURCES = \ + $(headers) \ + soh_data_type_packing_fns.c \ + soh_data_type_unpacking_fns.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +ompidir = $(includedir)/openmpi/mca/soh/base/data_type_support +ompi_HEADERS = $(headers) +else +ompidir = $(includedir) +endif + diff --git a/src/mca/soh/base/data_type_support/soh_data_type_packing_fns.c b/src/mca/soh/base/data_type_support/soh_data_type_packing_fns.c new file mode 100644 index 0000000000..760c87158d --- /dev/null +++ b/src/mca/soh/base/data_type_support/soh_data_type_packing_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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/soh/base/base.h" + +/* + * EXIT CODE + */ +int orte_soh_base_pack_exit_code(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, DPS_TYPE_INT))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NODE STATE + */ +int orte_soh_base_pack_node_state(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_INT8))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * PROC STATE + */ +int orte_soh_base_pack_proc_state(orte_buffer_t *buffer, void *src, + size_t num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_INT8))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} diff --git a/src/mca/soh/base/data_type_support/soh_data_type_unpacking_fns.c b/src/mca/soh/base/data_type_support/soh_data_type_unpacking_fns.c new file mode 100644 index 0000000000..0031469b6f --- /dev/null +++ b/src/mca/soh/base/data_type_support/soh_data_type_unpacking_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 "mca/errmgr/errmgr.h" +#include "dps/dps_internal.h" + +#include "mca/soh/base/base.h" + +/* + * EXIT CODE + */ +int orte_soh_base_unpack_exit_code(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, DPS_TYPE_INT))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * NODE STATE + */ +int orte_soh_base_unpack_node_state(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_INT8))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} + +/* + * PROC STATE + */ +int orte_soh_base_unpack_proc_state(orte_buffer_t *buffer, void *dest, + size_t *num_vals, orte_data_type_t type) +{ + int rc; + + if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_INT8))) { + ORTE_ERROR_LOG(rc); + } + + return rc; +} diff --git a/src/mca/soh/base/soh_base_open.c b/src/mca/soh/base/soh_base_open.c index 60b6a64293..3bbde71802 100644 --- a/src/mca/soh/base/soh_base_open.c +++ b/src/mca/soh/base/soh_base_open.c @@ -15,12 +15,15 @@ */ -#include "ompi_config.h" +#include "orte_config.h" -#include "include/constants.h" +#include "include/orte_constants.h" + +#include "dps/dps.h" #include "mca/mca.h" #include "mca/base/base.h" #include "mca/base/mca_base_param.h" +#include "mca/errmgr/errmgr.h" #include "util/output.h" #include "util/proc_info.h" #include "mca/oob/base/base.h" @@ -64,7 +67,8 @@ orte_soh_base_module_t orte_soh = { int orte_soh_base_open(void) { - int param, value; + int param, value, rc; + orte_data_type_t tmp; /* fprintf(stderr,"orte_soh_base_open:enter\n"); */ @@ -80,6 +84,31 @@ int orte_soh_base_open(void) } + /* register the base system types with the DPS */ + tmp = ORTE_NODE_STATE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_soh_base_pack_node_state, + orte_soh_base_unpack_node_state, + "ORTE_NODE_STATE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_PROC_STATE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_soh_base_pack_proc_state, + orte_soh_base_unpack_proc_state, + "ORTE_PROC_STATE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + tmp = ORTE_EXIT_CODE; + if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_soh_base_pack_exit_code, + orte_soh_base_unpack_exit_code, + "ORTE_EXIT_CODE", &tmp))) { + ORTE_ERROR_LOG(rc); + return rc; + } + /* Open up all available components */ if (OMPI_SUCCESS != diff --git a/src/runtime/orte_init.c b/src/runtime/orte_init.c index bb84459caa..6adfe6f6e6 100644 --- a/src/runtime/orte_init.c +++ b/src/runtime/orte_init.c @@ -50,68 +50,8 @@ int orte_init(void) return ORTE_SUCCESS; } -/* This array is provided so that users can output an intelligible name for a data - * type during debugging. It is called by the ORTE_DATA_NAME macro defined in - * include/orte_names.h. For example, you can call it as: - * ompi_output(0, "data type: %s", ORTE_DATA_NAME(keyval.type)); - * - * THE CORRESPONDING MACRO IS DEFINED IN include/orte_schema.h - * AS IS THE EXTERN STATEMENT FOR ACCESSING THIS ARRAY - */ - -char *orte_data_strings[] = { - "DATA_TYPE_NOT_DEFINED", - "ORTE_BYTE", - "ORTE_BOOL", - "ORTE_STRING", - "ORTE_SIZE", - "ORTE_PID", - /* all the integer flavors */ - "ORTE_INT", - "ORTE_INT8", - "ORTE_INT16", - "ORTE_INT32", - "ORTE_INT64", - /* all the unsigned integer flavors */ - "ORTE_UINT", - "ORTE_UINT8", - "ORTE_UINT16", - "ORTE_UINT32", - "ORTE_UINT64", - /* all the floating point flavors */ - "ORTE_FLOAT", - "ORTE_FLOAT4", - "ORTE_DOUBLE", - "ORTE_FLOAT8", - "ORTE_LONG_DOUBLE", - "ORTE_FLOAT12", - "ORTE_FLOAT16", - /* orte-specific typedefs */ - "ORTE_NAME", - "ORTE_VPID", - "ORTE_JOBID", - "ORTE_CELLID", - "ORTE_NODE_STATE", - "ORTE_PROC_STATE", - "ORTE_EXIT_CODE", - "ORTE_BYTE_OBJECT", - "ORTE_KEYVAL", - "ORTE_NOTIFY_ACTION", - "ORTE_GPR_CMD", - "ORTE_GPR_NOTIFY_ID", - "ORTE_GPR_VALUE", - "ORTE_DATA_TYPE", - "ORTE_APP_CONTEXT", - "ORTE_APP_CONTEXT_MAP", - "ORTE_GPR_ADDR_MODE", - "ORTE_GPR_SUBSCRIPTION", - "ORTE_GPR_NOTIFY_DATA", - "ORTE_NULL" -}; - - /* - * Similar to the above, this array is used to output intelligible error + * This array is used to output intelligible error * messages. It is disturbing to think that we are still outputing error numbers and * expecting users to look them up in the "big book" to find out what they represent. * This array allows the user to output an actual string representation of the error. diff --git a/src/runtime/orte_init_stage1.c b/src/runtime/orte_init_stage1.c index 2a3f94d94c..7a36c4d1f6 100644 --- a/src/runtime/orte_init_stage1.c +++ b/src/runtime/orte_init_stage1.c @@ -94,6 +94,14 @@ int orte_init_stage1(void) return ret; } + /* + * Initialize the data packing service. + */ + if (ORTE_SUCCESS != (ret = orte_dps_open())) { + ORTE_ERROR_LOG(ret); + return ret; + } + /* * Open the name services to ensure access to local functions */ @@ -142,14 +150,6 @@ int orte_init_stage1(void) return ret; } - /* - * Initialize the data packing service. - */ - if (ORTE_SUCCESS != (ret = orte_dps_open())) { - ORTE_ERROR_LOG(ret); - return ret; - } - /* * Runtime Messaging Layer */ diff --git a/src/tools/console/orteconsole.c b/src/tools/console/orteconsole.c index 3245147a0e..003f969875 100644 --- a/src/tools/console/orteconsole.c +++ b/src/tools/console/orteconsole.c @@ -24,7 +24,7 @@ #include #include -#include "mca/dps/dps.h" +#include "dps/dps.h" #include "util/sys_info.h" #include "util/cmd_line.h" diff --git a/src/tools/orted/orted.c b/src/tools/orted/orted.c index 3a8f1e4cbb..e6fe42666d 100644 --- a/src/tools/orted/orted.c +++ b/src/tools/orted/orted.c @@ -35,7 +35,7 @@ #include "threads/mutex.h" #include "threads/condition.h" -#include "mca/dps/dps.h" +#include "dps/dps.h" #include "util/output.h" #include "util/show_help.h" #include "util/sys_info.h" diff --git a/test/dps/dps_test.c b/test/dps/dps_test.c index 570cff0dd8..2ca5856d51 100644 --- a/test/dps/dps_test.c +++ b/test/dps/dps_test.c @@ -17,7 +17,6 @@ #include "orte_config.h" #include "../src/include/orte_constants.h" #include "../src/include/orte_types.h" -#include "../src/include/orte_schema.h" #include "../../src/dps/dps.h" #include "../../src/dps/dps_types.h" @@ -36,9 +35,15 @@ #include "support.h" #include "../src/runtime/runtime.h" +#include "../src/util/proc_info.h" +#include "../src/util/sys_info.h" #include "../src/mca/base/base.h" #include "../src/dps/dps.h" -#include "../src/mca/ns/ns_types.h" +#include "../src/mca/ns/ns.h" +#include "../src/mca/ns/base/base.h" +#include "../src/mca/gpr/base/base.h" +#include "../src/mca/rmgr/base/base.h" +#include "../src/mca/soh/base/base.h" #define NUM_ITERS 2 #define NUM_ELEMS 3 @@ -68,18 +73,86 @@ int main (int argc, char* argv[]) test_init("orte_dps"); test_out = stderr; - /* open up the mca so we can get parameters */ - orte_init(); + /* Open up the output streams */ + if (!ompi_output_init()) { + return OMPI_ERROR; + } + + /* + * If threads are supported - assume that we are using threads - + * and reset otherwise. + */ + ompi_set_using_threads(OMPI_HAVE_THREAD_SUPPORT); + + /* For malloc debugging */ + ompi_malloc_init(); + + /* Ensure the system_info structure is instantiated and initialized */ + if (ORTE_SUCCESS != (ret = orte_sys_info())) { + return ret; + } + + /* Ensure the process info structure is instantiated and initialized */ + if (ORTE_SUCCESS != (ret = orte_proc_info())) { + return ret; + } + + orte_process_info.seed = true; + orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t)); + orte_process_info.my_name->cellid = 0; + orte_process_info.my_name->jobid = 0; + orte_process_info.my_name->vpid = 0; /* startup the MCA */ - if (OMPI_SUCCESS != mca_base_open()) { - fprintf(stderr, "can't open mca\n"); + if (OMPI_SUCCESS == mca_base_open()) { + fprintf(test_out, "MCA started\n"); + } else { + fprintf(test_out, "MCA could not start\n"); exit (1); } - - /* setup the dps */ - orte_dps_open(); + /* open the dps */ + if (ORTE_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* open the name services */ + if (ORTE_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* open the registry */ + if (ORTE_SUCCESS == orte_gpr_base_open()) { + fprintf(test_out, "GPR started\n"); + } else { + fprintf(test_out, "GPR could not start\n"); + exit (1); + } + + /* open the resource manager */ + if (ORTE_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* open the soh */ + if (ORTE_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* run the tests */ + fprintf(test_out, "executing test1\n"); if (test1()) { test_success(); @@ -136,7 +209,6 @@ int main (int argc, char* argv[]) test_failure("orte_dps test6 failed"); } -#if 0 fprintf(test_out, "executing test7\n"); if (test7()) { test_success(); @@ -200,7 +272,6 @@ int main (int argc, char* argv[]) else { test_failure("orte_dps test14 failed"); } -#endif ret = test_finalize(); fclose(test_out); @@ -487,18 +558,15 @@ static bool test4(void) static bool test5(void) { -#if 1 - return true; -#else orte_buffer_t *bufA; int rc; - int32_t i; + size_t i; orte_process_name_t src[NUM_ELEMS]; orte_process_name_t dst[NUM_ELEMS]; for(i=0; ikey, dst[j]->key) || src[j]->type != dst[j]->type) { - test_comment ("test9: invalid results from unpack"); + test_comment ("test9: invalid results type/key mismatch from unpack"); return(false); } if (ORTE_INT16 == src[j]->type) { if (src[j]->value.i16 != dst[j]->value.i16) { - test_comment ("test9: invalid results from unpack"); + test_comment ("test9: invalid results i16 value mismatch from unpack"); return(false); } } else if (ORTE_INT32 == src[j]->type) { if (src[j]->value.i32 != dst[j]->value.i32) { - test_comment ("test9: invalid results from unpack"); + test_comment ("test9: invalid results i32 mismatch from unpack"); return(false); } } @@ -997,7 +1064,7 @@ static bool test10(void) { orte_buffer_t *bufA; int rc; - int32_t i, j, k; + size_t i, j, k; orte_gpr_value_t *src[NUM_ELEMS]; orte_gpr_value_t *dst[NUM_ELEMS]; @@ -1172,8 +1239,8 @@ static bool test11(void) static bool test12(void) { orte_buffer_t *bufA; - int rc; - int32_t i, j, k; + int rc, n; + size_t i, j, k; orte_app_context_t *src[NUM_ELEMS]; orte_app_context_t *dst[NUM_ELEMS]; @@ -1187,8 +1254,8 @@ static bool test12(void) src[i]->argc = i+1; if (src[i]->argc) { /* if to allow testing of argv count of zero */ src[i]->argv = (char**)malloc(src[i]->argc * sizeof(char*)); - for (j=0; j < src[i]->argc; j++) { - src[i]->argv[j] = strdup("test-argv"); + for (n=0; n < src[i]->argc; n++) { + src[i]->argv[n] = strdup("test-argv"); } } @@ -1274,8 +1341,8 @@ static bool test12(void) } /* now compare each of the size/cnt depedant values */ - for (k=0; kargc; k++) { - if (0 != strcmp(src[j]->argv[k], dst[j]->argv[k])) { + for (n=0; nargc; n++) { + if (0 != strcmp(src[j]->argv[n], dst[j]->argv[n])) { test_comment ("test12: invalid results (argv) from unpack"); return(false); } @@ -1316,7 +1383,7 @@ static bool test13(void) { orte_buffer_t *bufA; int rc; - int32_t i, j, k; + size_t i, j, k; orte_gpr_subscription_t *src[NUM_ELEMS]; orte_gpr_subscription_t *dst[NUM_ELEMS]; @@ -1420,26 +1487,26 @@ static bool test14(void) { orte_buffer_t *bufA; int rc; - int32_t i, j, k, l; + size_t i, j, k, l; orte_gpr_notify_data_t *src[NUM_ELEMS]; orte_gpr_notify_data_t *dst[NUM_ELEMS]; for(i=0; icb_num = (uint32_t) i; - src[i]->addr_mode = (uint16_t) i; + src[i]->cb_num = i; + src[i]->addr_mode = (orte_gpr_addr_mode_t) i; src[i]->segment = strdup("test-segment-name"); /* test value counts of 0 to NUM_ELEMS-1 */ - src[i]->cnt = (uint32_t) i; /* value count */ + src[i]->cnt = i; /* value count */ - if (src[i]->cnt) { /* if to allow testing of GPR value count of zero */ + if (0 < src[i]->cnt) { /* if to allow testing of GPR value count of zero */ src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*)); for (j=0; j < src[i]->cnt; j++) { src[i]->values[j] = OBJ_NEW(orte_gpr_value_t); - src[i]->values[j]->addr_mode = (uint16_t) i+j+1; + src[i]->values[j]->addr_mode = (orte_gpr_addr_mode_t) i+j+1; src[i]->values[j]->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */ /* tokens */ @@ -1458,7 +1525,7 @@ static bool test14(void) for (k=0; k < src[i]->values[j]->cnt; k++) { src[i]->values[j]->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t); src[i]->values[j]->keyvals[k]->key = strdup("test-grp-notify-value-key"); - src[i]->values[j]->keyvals[k]->type = (uint8_t) (ORTE_INT32); /* make it simplier */ + src[i]->values[j]->keyvals[k]->type = ORTE_INT32; /* make it simplier */ src[i]->values[j]->keyvals[k]->value.i32 = (uint32_t) (i*100)+(j*10)+k; /* something variable */ } /* for each keyval pair */ } /* if keyvals */ @@ -1490,7 +1557,6 @@ static bool test14(void) for (i=0; i #include "include/orte_constants.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" +#include "mca/schema/base/base.h" +#include "mca/ns/base/base.h" +#include "mca/soh/base/base.h" +#include "mca/rmgr/base/base.h" #include "support.h" #include "components.h" @@ -146,6 +150,46 @@ int main(int argc, char **argv) exit (1); } + /* startup the dps */ + if (OMPI_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* startup the name services */ + if (OMPI_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* startup the soh */ + if (OMPI_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* startup the rmgr */ + if (OMPI_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* startup the schema */ + if (OMPI_SUCCESS == orte_schema_base_open()) { + fprintf(test_out, "SCHEMA started\n"); + } else { + fprintf(test_out, "SCHEMA could not start\n"); + exit (1); + } + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &handle, diff --git a/test/mca/gpr/gpr_mem_leaks.c b/test/mca/gpr/gpr_mem_leaks.c index 8a2d24aa47..473d29dc5f 100644 --- a/test/mca/gpr/gpr_mem_leaks.c +++ b/test/mca/gpr/gpr_mem_leaks.c @@ -28,7 +28,11 @@ #include #include "include/orte_constants.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" +#include "mca/schema/base/base.h" +#include "mca/ns/base/base.h" +#include "mca/soh/base/base.h" +#include "mca/rmgr/base/base.h" #include "support.h" #include "components.h" @@ -52,7 +56,7 @@ static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std"; int main(int argc, char **argv) { int rc; - int32_t i, cnt; + size_t i, cnt; char *names[15], *keys[5]; orte_gpr_value_t **values, *val; test_component_handle_t handle; @@ -112,6 +116,46 @@ int main(int argc, char **argv) exit (1); } + /* startup the dps */ + if (OMPI_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* startup the name services */ + if (OMPI_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* startup the soh */ + if (OMPI_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* startup the rmgr */ + if (OMPI_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* startup the schema */ + if (OMPI_SUCCESS == orte_schema_base_open()) { + fprintf(test_out, "SCHEMA started\n"); + } else { + fprintf(test_out, "SCHEMA could not start\n"); + exit (1); + } + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &handle, diff --git a/test/mca/gpr/gpr_overwrite.c b/test/mca/gpr/gpr_overwrite.c index 7c846232d6..b1dc5dbea1 100644 --- a/test/mca/gpr/gpr_overwrite.c +++ b/test/mca/gpr/gpr_overwrite.c @@ -17,7 +17,11 @@ #include "orte_config.h" #include "include/orte_constants.h" #include "include/orte_types.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" +#include "mca/schema/base/base.h" +#include "mca/ns/base/base.h" +#include "mca/soh/base/base.h" +#include "mca/rmgr/base/base.h" #include #include @@ -182,6 +186,46 @@ int main(int argc, char **argv) exit (1); } + /* startup the dps */ + if (OMPI_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* startup the name services */ + if (OMPI_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* startup the soh */ + if (OMPI_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* startup the rmgr */ + if (OMPI_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* startup the schema */ + if (OMPI_SUCCESS == orte_schema_base_open()) { + fprintf(test_out, "SCHEMA started\n"); + } else { + fprintf(test_out, "SCHEMA could not start\n"); + exit (1); + } + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &handle, diff --git a/test/mca/gpr/gpr_put_get.c b/test/mca/gpr/gpr_put_get.c index df796aab9b..4db738c118 100644 --- a/test/mca/gpr/gpr_put_get.c +++ b/test/mca/gpr/gpr_put_get.c @@ -31,7 +31,11 @@ #endif #include "include/orte_constants.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" +#include "mca/schema/base/base.h" +#include "mca/ns/base/base.h" +#include "mca/soh/base/base.h" +#include "mca/rmgr/base/base.h" #include "support.h" #include "components.h" @@ -58,7 +62,7 @@ static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std"; int main(int argc, char **argv) { int rc; - int32_t i, j, cnt; + size_t i, j, cnt; char *names[15], *keys[5]; orte_gpr_keyval_t **kvals; orte_gpr_value_t **values, *val; @@ -122,6 +126,46 @@ int main(int argc, char **argv) exit (1); } + /* startup the dps */ + if (OMPI_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* startup the name services */ + if (OMPI_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* startup the soh */ + if (OMPI_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* startup the rmgr */ + if (OMPI_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* startup the schema */ + if (OMPI_SUCCESS == orte_schema_base_open()) { + fprintf(test_out, "SCHEMA started\n"); + } else { + fprintf(test_out, "SCHEMA could not start\n"); + exit (1); + } + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &handle, diff --git a/test/mca/gpr/gpr_threads.c b/test/mca/gpr/gpr_threads.c index 16447da16d..63a6b00570 100644 --- a/test/mca/gpr/gpr_threads.c +++ b/test/mca/gpr/gpr_threads.c @@ -17,7 +17,7 @@ #include "orte_config.h" #include "include/orte_constants.h" #include "include/orte_types.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" #include #include diff --git a/test/mca/gpr/gpr_triggers.c b/test/mca/gpr/gpr_triggers.c index aa7edb3fea..cd19055f86 100644 --- a/test/mca/gpr/gpr_triggers.c +++ b/test/mca/gpr/gpr_triggers.c @@ -46,6 +46,11 @@ #include "mca/errmgr/errmgr.h" #include "mca/errmgr/base/base.h" +#include "mca/schema/schema.h" +#include "mca/schema/base/base.h" +#include "mca/ns/base/base.h" +#include "mca/soh/base/base.h" +#include "mca/rmgr/base/base.h" #include "mca/gpr/base/base.h" #include "mca/gpr/replica/api_layer/gpr_replica_api.h" @@ -130,6 +135,46 @@ int main(int argc, char **argv) exit (1); } + /* startup the dps */ + if (OMPI_SUCCESS == orte_dps_open()) { + fprintf(test_out, "DPS started\n"); + } else { + fprintf(test_out, "DPS could not start\n"); + exit (1); + } + + /* startup the name services */ + if (OMPI_SUCCESS == orte_ns_base_open()) { + fprintf(test_out, "NS started\n"); + } else { + fprintf(test_out, "NS could not start\n"); + exit (1); + } + + /* startup the soh */ + if (OMPI_SUCCESS == orte_soh_base_open()) { + fprintf(test_out, "SOH started\n"); + } else { + fprintf(test_out, "SOH could not start\n"); + exit (1); + } + + /* startup the rmgr */ + if (OMPI_SUCCESS == orte_rmgr_base_open()) { + fprintf(test_out, "RMGR started\n"); + } else { + fprintf(test_out, "RMGR could not start\n"); + exit (1); + } + + /* startup the schema */ + if (OMPI_SUCCESS == orte_schema_base_open()) { + fprintf(test_out, "SCHEMA started\n"); + } else { + fprintf(test_out, "SCHEMA could not start\n"); + exit (1); + } + /* Open the gpr replica component and initialize a module */ if (OMPI_SUCCESS != test_component_open("gpr", "replica", &handle, diff --git a/test/mca/ns/ns_replica.c b/test/mca/ns/ns_replica.c index 87406ab2fd..149b310152 100644 --- a/test/mca/ns/ns_replica.c +++ b/test/mca/ns/ns_replica.c @@ -22,7 +22,7 @@ #include "components.h" #include "include/orte_constants.h" -#include "include/orte_schema.h" +#include "mca/schema/schema.h" #include "util/proc_info.h" #include "util/malloc.h" #include "util/output.h"