1
1

Commit 2 of 4 for bringing the changes over from the hetero branch.

Merged in from:

svn merge -r5448:5496 https://svn.open-mpi.org/svn/ompi/tmp/hetero .

This commit was SVN r5550.

The following SVN revisions from the original message are invalid or
inconsistent and therefore were not cross-referenced:
  r5448
  r5496
Этот коммит содержится в:
Jeff Squyres 2005-05-01 00:53:00 +00:00
родитель 462adee81a
Коммит aa70022dc2
142 изменённых файлов: 3248 добавлений и 5522 удалений

Просмотреть файл

@ -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 dps 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 soh topo"
AC_MSG_RESULT([$found_types])
# Get the list of all the non-configure MCA components that were found by

Просмотреть файл

@ -1645,7 +1645,6 @@ AC_CONFIG_FILES([
src/include/sys/win32/Makefile
src/class/Makefile
src/dps/Makefile
src/runtime/Makefile
src/threads/Makefile
src/util/Makefile
@ -1658,6 +1657,7 @@ AC_CONFIG_FILES([
src/asm/Makefile
src/communicator/Makefile
src/datatype/Makefile
src/dps/Makefile
src/errhandler/Makefile
src/file/Makefile
src/group/Makefile
@ -1671,8 +1671,6 @@ AC_CONFIG_FILES([
src/mca/base/Makefile
src/mca/common/Makefile
src/mca/dps/Makefile
src/mca/dps/base/Makefile
src/mca/errmgr/Makefile
src/mca/errmgr/base/Makefile
src/mca/iof/Makefile
@ -1719,7 +1717,6 @@ AC_CONFIG_FILES([
src/dynamic-mca/common/Makefile
src/dynamic-mca/dps/Makefile
src/dynamic-mca/errmgr/Makefile
src/dynamic-mca/iof/Makefile
src/dynamic-mca/gpr/Makefile
@ -1766,7 +1763,7 @@ AC_CONFIG_FILES([
test/Makefile
test/asm/Makefile
test/class/Makefile
test/mca/dps/Makefile
test/dps/Makefile
test/mca/Makefile
test/mca/gpr/Makefile
test/mca/ns/Makefile

Просмотреть файл

@ -21,7 +21,6 @@
#define ORTE_CONFIG_H_
#include "ompi_config.h"
#include "ompi_stdint.h"
#define ORTE_DECLSPEC OMPI_DECLSPEC
#endif

Просмотреть файл

@ -132,6 +132,7 @@ libmpi_la_LIBADD = \
class/liblfc.la \
communicator/libcommunicator.la \
datatype/libdatatype.la \
dps/libdps.la \
errhandler/liberrhandler.la \
event/libevent.la \
file/libfile.la \
@ -141,7 +142,6 @@ libmpi_la_LIBADD = \
mca/allocator/base/libmca_allocator_base.la $(MCA_allocator_STATIC_LTLIBS) \
mca/coll/base/libmca_coll_base.la $(MCA_coll_STATIC_LTLIBS) \
$(MCA_common_STATIC_LTLIBS) \
mca/dps/base/libmca_dps_base.la $(MCA_dps_STATIC_LTLIBS) \
mca/errmgr/base/libmca_errmgr_base.la \
mca/gpr/base/pack_api_cmd/libmca_gpr_base_pack.la \
mca/gpr/base/unpack_api_response/libmca_gpr_base_unpack.la \
@ -159,7 +159,7 @@ libmpi_la_LIBADD = \
mca/rmaps/base/libmca_rmaps_base.la $(MCA_rmaps_STATIC_LTLIBS) \
mca/rmgr/base/libmca_orte_rmgr_base.la $(MCA_rmgr_STATIC_LTLIBS) \
mca/rml/base/libmca_rml_base.la $(MCA_rml_STATIC_LTLIBS) \
mca/schema/base/libmca_schema_base.la $(MCA_schema_STATIC_LTLIBS) \
mca/schema/base/libmca_schema_base.la \
mca/soh/base/libmca_soh_base.la $(MCA_soh_STATIC_LTLIBS) \
mca/topo/base/libmca_topo_base.la $(MCA_topo_STATIC_LTLIBS) \
mpi/c/libmpi_c.la $(c_mpi_lib) $(c_pmpi_lib) \

Просмотреть файл

@ -16,18 +16,29 @@
include $(top_srcdir)/config/Makefile.options
SUBDIRS = base $(MCA_dps_STATIC_SUBDIRS)
DIST_SUBDIRS = base $(MCA_dps_ALL_SUBDIRS)
noinst_LTLIBRARIES = libdps.la
# Source code files
headers = dps.h \
dps_types.h
headers = \
dps.h \
dps_types.h \
dps_internal.h
libdps_la_SOURCES = \
$(headers) \
dps_internal_functions.c \
dps_load_unload.c \
dps_pack.c \
dps_peek.c \
dps_register.c \
dps_unpack.c \
orte_dps_open_close.c
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/openmpi/mca/dps
ompidir = $(includedir)/openmpi/dps
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)

369
src/dps/dps.h Обычный файл
Просмотреть файл

@ -0,0 +1,369 @@
/* -*- 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
*
* Data packing subsystem.
*/
#ifndef ORTE_DPS_H_
#define ORTE_DPS_H_
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps_types.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* Top-level itnerface function to pack one or more values into a
* buffer.
*
* The pack function packs one or more values of a specified type into
* the specified buffer. The buffer must have already been
* initialized via an OBJ_NEW or OBJ_CONSTRUCT call - otherwise, the
* pack_value function will return an error. Providing an unsupported
* type flag will likewise be reported as an error.
*
* Note that any data to be packed that is not hard type cast (i.e.,
* not type cast to a specific size) may lose precision when unpacked
* by a non-homogeneous recipient. The DPS will do its best to deal
* with heterogeneity issues between the packer and unpacker in such
* cases. Sending a number larger than can be handled by the recipient
* will return an error code (generated by the DPS upon unpacking) via
* the RML upon transmission - the DPS cannot detect such errors
* during packing.
*
* @param *buffer A pointer to the buffer into which the value is to
* be packed.
*
* @param *src A void* pointer to the data that is to be packed. Note
* that strings are to be passed as (char **) - i.e., the caller must
* pass the address of the pointer to the string as the void*. This
* allows the DPS to use a single interface function, but still allow
* the caller to pass multiple strings in a single call.
*
* @param num A size_t value indicating the number of values that are
* to be packed, beginning at the location pointed to by src. A string
* value is counted as a single value regardless of length. The values
* must be contiguous in memory. Arrays of pointers (e.g., string
* arrays) should be contiguous, although (obviously) the data pointed
* to need not be contiguous across array entries.
*
* @param type The type of the data to be packed - must be one of the
* DPS defined data types.
*
* @retval ORTE_SUCCESS The data was packed as requested.
*
* @retval ORTE_ERROR(s) An appropriate ORTE error code indicating the
* problem encountered. This error code should be handled
* appropriately.
*
* @code
* orte_buffer_t *buffer;
* int32_t src;
*
* status_code = orte_dps.pack(buffer, &src, 1, ORTE_INT32);
* @endcode
*/
typedef int (*orte_dps_pack_fn_t)(orte_buffer_t *buffer, void *src,
size_t num_values,
orte_data_type_t type);
/**
* Unpack values from a buffer.
*
* The unpack function unpacks the next value (or values) of a
* specified type from the specified buffer.
*
* The buffer must have already been initialized via an OBJ_NEW or
* OBJ_CONSTRUCT call (and assumedly filled with some data) -
* otherwise, the unpack_value function will return an
* error. Providing an unsupported type flag will likewise be reported
* as an error, as will specifying a data type that DOES NOT match the
* type of the next item in the buffer. An attempt to read beyond the
* end of the stored data held in the buffer will also return an
* error.
*
* NOTE: it is possible for the buffer to be corrupted and that
* the DPS will *think* there is a proper variable type at the
* beginning of an unpack region - but that the value is bogus (e.g., just
* a byte field in a string array that so happens to have a value that
* matches the specified data type flag). Therefore, the data type error check
* is NOT completely safe. This is true for ALL unpack functions.
*
*
* Unpacking values is a "destructive" process - i.e., the values are
* removed from the buffer, thus reducing the buffer size. It is
* therefore not possible for the caller to re-unpack a value from the
* same buffer.
*
* Warning: The caller is responsible for providing adequate memory
* storage for the requested data. The orte_dps_peek() function is
* provided to assist in meeting this requirement. As noted below, the user
* must provide a parameter indicating the maximum number of values that
* can be unpacked into the allocated memory. If more values exist in the
* buffer than can fit into the memory storage, then the dps will unpack
* what it can fit into that location and return an error code indicating
* that the buffer was only partially unpacked.
*
* Note that any data that was not hard type cast (i.e., not type cast
* to a specific size) when packed may lose precision when unpacked by
* a non-homogeneous recipient. The DPS will do its best to deal with
* heterogeneity issues between the packer and unpacker in such
* cases. Sending a number larger than can be handled by the recipient
* will return an error code (generated by the DPS upon unpacking) via
* the RML upon transmission - the DPS cannot detect such errors
* during packing.
*
* @param *buffer A pointer to the buffer from which the value will be
* extracted.
*
* @param *dest A void* pointer to the memory location into which the
* data is to be stored. Note that these values will be stored
* contiguously in memory. For strings, this pointer must be to (char
* **) to provide a means of supporting multiple string
* operations. The DPS unpack function will allocate memory for each
* string in the array - the caller must only provide adequate memory
* for the array of pointers.
*
* @param *num A pointer to a size_t value indicating the maximum
* number of values that are to be unpacked, beginning at the location
* pointed to by src. This is provided to help protect the caller from
* memory overrun. Note that a string
* value is counted as a single value regardless of length.
*
* @note The unpack function will return the actual number of values
* unpacked in this location.
*
* @param type The type of the data to be unpacked - must be one of
* the DPS defined data types.
*
* @retval *max_num_values The number of values actually unpacked. In
* most cases, this should match the maximum number provided in the
* parameters - but in no case will it exceed the value of this
* parameter. Note that if you unpack fewer values than are actually
* available, the buffer will be in an unpackable state - the dps will
* return an error code to warn of this condition.
*
* @retval ORTE_SUCCESS The next item in the buffer was successfully
* unpacked.
*
* @retval ORTE_ERROR(s) The unpack function returns an error code
* under one of several conditions: (a) the number of values in the
* item exceeds the max num provided by the caller; (b) the type of
* the next item in the buffer does not match the type specified by
* the caller; or (c) the unpack failed due to either an error in the
* buffer or an attempt to read past the end of the buffer.
*
* @code
* orte_buffer_t *buffer;
* int32_t dest;
* char **string_array;
* size_t num_values;
*
* num_values = 1;
* status_code = orte_dps.unpack(buffer, (void*)&dest, &num_values, ORTE_INT32);
*
* num_values = 5;
* string_array = malloc(num_values*sizeof(char *));
* status_code = orte_dps.unpack(buffer, (void*)(string_array), &num_values, ORTE_STRING);
*
* @endcode
*/
typedef int (*orte_dps_unpack_fn_t)(orte_buffer_t *buffer, void *dest,
size_t *max_num_values,
orte_data_type_t type);
/**
* Get the type and number of values of the next item in the buffer.
*
* The peek function looks at the next item in the buffer and returns
* both its type and the number of values in the item. This is a
* non-destructive function call that does not disturb the buffer, so
* it can be called multiple times if desired.
*
* @param buffer A pointer to the buffer in question.
*
* @param type A pointer to an orte_data_type_t variable where the
* type of the next item in the buffer is to be stored. Caller must
* have memory backing this location.
*
* @param number A pointer to a size_t variable where the number of
* data values in the next item is to be stored. Caller must have
* memory backing this location.
*
* @retval ORTE_SUCCESS Requested info was successfully returned.
* @retval ORTE_ERROR(s) An appropriate error code indicating the
* problem will be returned. This should be handled appropriately by
* the caller.
*
*/
typedef int (*orte_dps_peek_next_item_fn_t)(orte_buffer_t *buffer,
orte_data_type_t *type,
size_t *number);
/**
* Unload the data payload from a buffer.
*
* The unload function provides the caller with a pointer to the data
* payload within the buffer and the size of that payload. This allows
* the user to directly access the payload - typically used in the RML
* to unload the payload from the buffer for transmission.
*
* @note This is a destructive operation. While the payload is
* undisturbed, the function will clear the buffer's pointers to the
* payload. Thus, the buffer and the payload are completely separated,
* leaving the caller free to OBJ_RELEASE the buffer.
*
* @param buffer A pointer to the buffer whose payload is to be
* unloaded.
*
* @param payload The address to a void* pointer that is to be loaded
* with the address of the data payload in the buffer.
*
* @param size The size (in bytes) of the data payload in the buffer.
*
* @retval ORTE_SUCCESS The request was succesfully completed.
*
* @retval ORTE_ERROR(s) An appropriate error code indicating the
* problem will be returned. This should be handled appropriately by
* the caller.
*
* @code
* orte_buffer_t *buffer;
* uint8_t *bytes;
* size_t size;
*
* status_code = orte_dps.unload(buffer, (void**)(&bytes), &size);
* OBJ_RELEASE(buffer);
* @endcode
*/
typedef int (*orte_dps_unload_fn_t)(orte_buffer_t *buffer,
void **payload,
size_t *size);
/**
* Load a data payload into a buffer.
*
* The load function allows the caller to replace the payload in a
* buffer with one provided by the caller. If a payload already exists
* in the buffer, the function will "free" the existing data to
* release it, and then replace the data payload with the one provided
* by the caller.
*
* @note The buffer must be allocated in advance via the OBJ_NEW
* function call - failing to do so will cause the load function to
* return an error code.
*
* @note The caller is responsible for pre-packing the provided
* payload - the load function cannot convert to network byte order
* any data contained in the provided payload.
*
* @param buffer A pointer to the buffer into which lthe payload is to
* be loaded.
*
* @param payload A void* pointer to the payload to be loaded into the
* buffer.
*
* @param size The size (in bytes) of the provided payload.
*
* @retval ORTE_SUCCESS The request was successfully completed
*
* @retval ORTE_ERROR(s) An appropriate error code indicating the
* problem will be returned. This should be handled appropriately by
* the caller.
*
* @code
* orte_buffer_t *buffer;
* uint8_t bytes;
* size_t size;
*
* buffer = OBJ_NEW(orte_buffer_t);
* status_code = orte_dps.load(buffer, (void*)(&bytes), size);
* @endcode
*/
typedef int (*orte_dps_load_fn_t)(orte_buffer_t *buffer,
void *payload,
size_t size);
/**
* DPS initialization function.
*
* In dynamic libraries, declared objects and functions don't get
* loaded until called. We need to ensure that the orte_dps function
* structure gets loaded, so we provide an "open" call that is
* executed as part of the program startup.
*/
OMPI_DECLSPEC int orte_dps_open(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. 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);
/**
* DPS finalize function
*/
OMPI_DECLSPEC int orte_dps_close(void);
/**
* Base structure for the DPS
*
* Base module structure for the DPS - presents the required function
* pointers to the calling interface.
*/
struct orte_dps_t {
orte_dps_pack_fn_t pack;
orte_dps_unpack_fn_t unpack;
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;
};
typedef struct orte_dps_t orte_dps_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
OMPI_DECLSPEC extern orte_dps_t orte_dps; /* holds dps function pointers */
#endif /* ORTE_DPS_H */

191
src/dps/dps_internal.h Обычный файл
Просмотреть файл

@ -0,0 +1,191 @@
/* -*- 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$
*
*/
#ifndef ORTE_DPS_INTERNAL_H_
#define ORTE_DPS_INTERNAL_H_
#include "orte_config.h"
#include "include/orte_constants.h"
#include "class/orte_value_array.h"
#include "dps/dps.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/*
* DEFINE THE DEFAULT PAGE SIZE FOR THE DPS BUFFERS - IN KILOBYTES
*/
#define ORTE_DPS_DEFAULT_PAGE_SIZE 1
/*
* ORTE type corresponding to size_t
*/
#if SIZEOF_SIZE_T == 1
#define DPS_TYPE_SIZE_T ORTE_UINT8
#elif SIZEOF_SIZE_T == 2
#define DPS_TYPE_SIZE_T ORTE_UINT16
#elif SIZEOF_SIZE_T == 4
#define DPS_TYPE_SIZE_T ORTE_UINT32
#elif SIZEOF_SIZE_T == 8
#define DPS_TYPE_SIZE_T ORTE_UINT64
#else
#error Unsupported size_t size!
#endif
/*
* ORTE type corresponding to bool
*/
#if SIZEOF_BOOL == 1
#define DPS_TYPE_BOOL ORTE_UINT8
#elif SIZEOF_BOOL == 2
#define DPS_TYPE_BOOL ORTE_UINT16
#elif SIZEOF_BOOL == 4
#define DPS_TYPE_BOOL ORTE_UINT32
#elif SIZEOF_BOOL == 8
#define DPS_TYPE_BOOL ORTE_UINT64
#else
#error Unsupported bool size!
#endif
/*
* ORTE type corresponding to int and unsigned int
*/
#if SIZEOF_INT == 1
#define DPS_TYPE_INT ORTE_INT8
#define DPS_TYPE_UINT ORTE_UINT8
#elif SIZEOF_INT == 2
#define DPS_TYPE_INT ORTE_INT16
#define DPS_TYPE_UINT ORTE_UINT16
#elif SIZEOF_INT == 4
#define DPS_TYPE_INT ORTE_INT32
#define DPS_TYPE_UINT ORTE_UINT32
#elif SIZEOF_INT == 8
#define DPS_TYPE_INT ORTE_INT64
#define DPS_TYPE_UINT ORTE_UINT64
#else
#error Unsupported int size!
#endif
/**
* Internal struct used for holding registered dps functions
*/
struct orte_dps_type_info_t {
/** Debugging string name */
char *odti_name;
/** local number of type */
orte_data_type_t odti_num;
/** 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_value_array_t orte_dps_types;
/*
* Implementations of API functions
*/
int orte_dps_pack(orte_buffer_t *buffer, void *src,
size_t num_vals,
char *type);
int orte_dps_unpack(orte_buffer_t *buffer, void *dest,
size_t *max_num_vals,
char *type);
int orte_dps_peek(orte_buffer_t *buffer, char **type,
size_t *number);
int orte_dps_unload(orte_buffer_t *buffer, void **payload,
size_t *bytes_used);
int orte_dps_load(orte_buffer_t *buffer, void *payload, size_t bytes_used);
/*
* Internal pack functions
*/
int orte_dps_pack_null(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_byte(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_bool(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_int(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_int16(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_int32(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_int64(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_sizet(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
int orte_dps_pack_string(orte_buffer_t *buffer, void *src,
size_t num_vals, char *type);
/*
* Internal unpack functions
*/
int orte_dps_unpack_null(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_byte(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_bool(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_int(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_int16(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_int32(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_int64(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_sizet(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest,
size_t num_vals, char *type);
/*
* Internal helper functions
*/
int orte_dps_buffer_extend(orte_buffer_t *bptr, size_t bytes_to_add);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

197
src/dps/dps_internal_functions.c Обычный файл
Просмотреть файл

@ -0,0 +1,197 @@
/*
* 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 <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "util/output.h"
#include "mca/errmgr/errmgr.h"
#include "dps/dps_internal.h"
/**
* Internal function that resizes (expands) an inuse buffer if
* necessary.
*/
char* orte_dps_buffer_extend(orte_buffer_t *buffer, size_t bytes_to_add)
{
size_t required, num_pages;
size_t pack_offset, unpack_offset;
/* Check to see if we have enough space already */
if (buffer->bytes_avail >= bytes_to_add) {
return buffer->pack_ptr;
}
/* If we don't, see how many pages will be required and alloc
that */
required = buffer->bytes_used + bytes_to_add;
num_pages = required / orte_dps_page_size;
if (0 != required % orte_dps_page_size) {
++num_pages;
}
if (NULL != buffer->base_ptr) {
pack_offset = ((char*) buffer->pack_ptr) - ((char*) buffer->base_ptr);
unpack_offset = ((char*) buffer->unpack_ptr) -
((char*) buffer->base_ptr);
buffer->base_ptr = realloc(buffer->base_ptr,
num_pages * orte_dps_page_size);
} else {
pack_offset = 0;
unpack_offset = 0;
buffer->bytes_used = 0;
buffer->base_ptr = malloc(num_pages * orte_dps_page_size);
}
if (NULL == buffer->base_ptr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return NULL;
}
buffer->pack_ptr = ((char*) buffer->base_ptr) + pack_offset;
buffer->unpack_ptr = ((char*) buffer->base_ptr) + unpack_offset;
buffer->bytes_allocated = num_pages * orte_dps_page_size;
buffer->bytes_avail = buffer->bytes_allocated - buffer->bytes_used;
/* All done */
return buffer->pack_ptr;
}
/*
* Internal function that checks to see if the specified number of bytes
* remain in the buffer for unpacking
*/
bool orte_dps_too_small(orte_buffer_t *buffer, size_t bytes_reqd)
{
size_t bytes_remaining_packed;
if (buffer->pack_ptr < buffer->unpack_ptr) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE);
return true;
}
bytes_remaining_packed = buffer->pack_ptr - buffer->unpack_ptr;
if (bytes_remaining_packed < bytes_reqd) {
ORTE_ERROR_LOG(ORTE_UNPACK_READ_PAST_END_OF_BUFFER);
return true;
}
return false;
}
/*
* Internal function to store data type in buffer
*/
int orte_dps_store_data_type(orte_buffer_t *buffer, 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_pack_byte(buffer, &type, 1, ORTE_BYTE))) {
ORTE_ERROR_LOG(rc);
}
break;
case 2:
if (ORTE_SUCCESS != (
rc = orte_dps_pack_int16(buffer, &type, 1, ORTE_INT16))) {
ORTE_ERROR_LOG(rc);
}
break;
case 4:
if (ORTE_SUCCESS != (
rc = orte_dps_pack_int32(buffer, &type, 1, ORTE_INT32))) {
ORTE_ERROR_LOG(rc);
}
break;
case 8:
if (ORTE_SUCCESS != (
rc = orte_dps_pack_int64(buffer, &type, 1, ORTE_INT64))) {
ORTE_ERROR_LOG(rc);
}
break;
default:
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
return rc;
}
/*
* Internal function to retrieve data type from buffer
*/
int orte_dps_get_data_type(orte_buffer_t *buffer, orte_data_type_t *type)
{
size_t required;
int rc;
switch (required) {
case 1:
if (ORTE_SUCCESS != (
rc = orte_dps_unpack_byte(buffer, &type, 1, ORTE_BYTE))) {
ORTE_ERROR_LOG(rc);
}
break;
case 2:
if (ORTE_SUCCESS != (
rc = orte_dps_unpack_int16(buffer, &type, 1, ORTE_INT16))) {
ORTE_ERROR_LOG(rc);
}
break;
case 4:
if (ORTE_SUCCESS != (
rc = orte_dps_unpack_int32(buffer, &type, 1, ORTE_INT32))) {
ORTE_ERROR_LOG(rc);
}
break;
case 8:
if (ORTE_SUCCESS != (
rc = orte_dps_unpack_int64(buffer, &type, 1, ORTE_INT64))) {
ORTE_ERROR_LOG(rc);
}
break;
default:
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
return rc;
}

Просмотреть файл

@ -34,9 +34,8 @@
#include "dps/dps_internal.h"
int orte_dps_unload(orte_buffer_t *buffer,
void **payload,
size_t *size)
int orte_dps_unload(orte_buffer_t *buffer, void **payload,
size_t *bytes_used)
{
/* check that buffer is not null */
if (!buffer) {
@ -49,32 +48,29 @@ int orte_dps_unload(orte_buffer_t *buffer,
}
/* anything in the buffer - if not, nothing to do */
if (NULL == buffer->base_ptr || 0 == buffer->len) {
if (NULL == buffer->base_ptr || 0 == buffer->bytes_used) {
*payload = NULL;
*size = 0;
*bytes_used = 0;
return ORTE_SUCCESS;
}
/* okay, we have something to provide - pass it back
*/
/* okay, we have something to provide - pass it back */
*payload = buffer->base_ptr;
*size = buffer->len;
*bytes_used = buffer->bytes_used;
/* dereference everything in buffer */
buffer->base_ptr = NULL;
buffer->size = 0;
buffer->len = 0;
buffer->space = 0;
buffer->toend = 0;
return (OMPI_SUCCESS);
buffer->pack_ptr = buffer->unpack_ptr = NULL;
buffer->bytes_allocated = buffer->bytes_used = buffer->bytes_avail = 0;
/* All done */
return OMPI_SUCCESS;
}
int orte_dps_load(orte_buffer_t *buffer,
void *payload,
size_t size)
int orte_dps_load(orte_buffer_t *buffer, void *payload,
size_t bytes_used)
{
/* check to see if the buffer has been initialized */
if (NULL == buffer) {
@ -82,7 +78,7 @@ int orte_dps_load(orte_buffer_t *buffer,
}
/* check that the payload is there */
if (NULL == payload || 0 >= size) {
if (NULL == payload || bytes_used < 0) {
return ORTE_SUCCESS;
}
@ -92,22 +88,18 @@ int orte_dps_load(orte_buffer_t *buffer,
}
/* populate the buffer */
buffer->base_ptr = payload; /* set the start of the buffer */
buffer->base_ptr = payload;
/* set data pointer to END of the buffer */
buffer->data_ptr = ((char*)buffer->base_ptr) + size;
/* set pack/unpack pointers */
buffer->pack_ptr = ((char*)buffer->base_ptr) + bytes_used;
buffer->unpack_ptr = buffer->base_ptr;
buffer->from_ptr = buffer->base_ptr; /* set the unpack start at start */
/* set counts for size and space */
buffer->bytes_allocated = buffer->bytes_used = bytes_used;
buffer->bytes_avail = 0;
/* set counts for size and space */
buffer->size = size;
buffer->len = size; /* users buffer is expected to be full */
buffer->space = 0; /* ditto */
buffer->toend = size; /* ditto */
/* All done */
/* dereference the payload pointer to protect it */
payload = NULL;
return ORTE_SUCCESS;
}

284
src/dps/dps_pack.c Обычный файл
Просмотреть файл

@ -0,0 +1,284 @@
/*
* 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"
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "mca/errmgr/errmgr.h"
#include "dps/dps_internal.h"
int orte_dps_pack(orte_buffer_t *buffer, void *src, size_t num_vals,
orte_data_type_t type)
{
int rc;
/* check for error */
if (NULL == buffer || NULL == src || num_vals < 0 ||
type > orte_value_array_get_size(&orte_dps_types)) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* Pack the number of values */
if (ORTE_SUCCESS != (rc = orte_dps_pack_sizet(buffer, &num_vals, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* Pack the value(s) */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_buffer(orte_buffer_t *buffer, void *src, size_t num_vals,
orte_data_type_t type)
{
orte_dps_type_info_t *info;
int rc;
/* Pack the declared data type */
if (ORTE_SUCCESS != (rc = orte_dps_store_data_type(buffer, type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* Lookup the pack function for this type and call it */
info = orte_value_array_get_item(&orte_dps_types, type);
if (ORTE_SUCCESS != (rc = info->odti_pack_fn(buffer, src, num_vals, type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/* PACK FUNCTIONS FOR GENERIC SYSTEM TYPES */
/*
* NULL
*/
int orte_dps_pack_null(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
char null=NULL;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_byte(buffer, &null, num_vals, ORTE_BYTE))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* BOOL
*/
int orte_dps_pack_bool(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_BOOL))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}
/*
* INT
*/
int orte_dps_pack_int(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_INT))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}
/*
* SIZE_T
*/
int orte_dps_pack_sizet(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;
}
/* PACK FUNCTIONS FOR NON-GENERIC SYSTEM TYPES */
/*
* BYTE, CHAR, INT8
*/
int orte_dps_pack_byte(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
char *dst;
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, num_vals))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* store the data */
memcpy(dst, src, num_vals);
/* update buffer pointers */
buffer->pack_ptr += num_bytes;
buffer->bytes_used += num_bytes;
buffer->bytes_avail -= num_bytes;
return ORTE_SUCCESS;
}
/*
* INT16
*/
int orte_dps_pack_int16(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int ret;
size_t i;
uint16_t tmp, *srctmp = (uint16_t*) src;
char *dst;
/* 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) {
tmp = htons(srctmp[i]);
memcpy(((uint16_t*) dst) + i, &tmp, sizeof(tmp));
}
buffer->pack_ptr += num_vals * sizeof(tmp);
buffer->bytes_used += num_vals * sizeof(tmp);
buffer->bytes_avail -= num_vals * sizeof(tmp);
return ORTE_SUCCESS;
}
/*
* INT32
*/
int orte_dps_pack_int32(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int ret;
size_t i;
uint32_t tmp, *srctmp = (uint32_t*) src;
char *dst;
/* 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) {
tmp = htonl(srctmp[i]);
memcpy(((uint32_t*) dst) + i, &tmp, sizeof(tmp));
}
buffer->pack_ptr += num_vals * sizeof(tmp);
buffer->bytes_used += num_vals * sizeof(tmp);
buffer->bytes_avail -= num_vals * sizeof(tmp);
return ORTE_SUCCESS;
}
/*
* INT64
*/
int orte_dps_pack_int64(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int ret;
size_t i;
uint32_t tmp, *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) {
tmp = htonl(srctmp[i]);
memcpy(((uint32_t*) dst) + i, &tmp, sizeof(tmp));
}
buffer->pack_ptr += num_vals * sizeof(tmp);
buffer->bytes_used += num_vals * sizeof(tmp);
buffer->bytes_avail -= num_vals * sizeof(tmp);
return ORTE_SUCCESS;
}
/*
* STRING
*/
int orte_dps_pack_string(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int ret = ORTE_SUCCESS;
size_t i, len;
char **ssrc = (char**) src;
for (i = 0; i < num_vals; ++i) {
len = strlen(ssrc[i]) + 1;
if (ORTE_SUCCESS != (ret = orte_dps_pack_sizet(buffer, &len, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (ORTE_SUCCESS != (ret =
orte_dps_pack_byte(buffer, ssrc[i], len, ORTE_BYTE))) {
ORTE_ERROR_LOG(ret);
return ret;
}
}
return ORTE_SUCCESS;
}

49
src/dps/dps_peek.c Обычный файл
Просмотреть файл

@ -0,0 +1,49 @@
/*
* 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 "mca/errmgr/errmgr.h"
#include "dps/dps_internal.h"
int orte_dps_peek(orte_buffer_t *buffer, orte_data_type_t *type,
size_t *num_vals)
{
int ret;
orte_buffer_t tmp;
/* check for errors */
if (buffer == NULL) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* 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))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (ORTE_SUCCESS != (ret = orte_dps_get_data_type(&tmp, type))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}

50
src/dps/dps_register.c Обычный файл
Просмотреть файл

@ -0,0 +1,50 @@
/*
* 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 "mca/errmgr/errmgr.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 == type || NULL == name) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* Add a new entry to the table */
info.odti_name = strdup(name);
info.odti_num = type;
info.odti_pack_fn = pack_fn;
info.odti_unpack_fn = unpack_fn;
ret = orte_value_array_append_item(&orte_dps_types, &info);
/* All done */
return ret;
}

124
src/dps/dps_types.h Обычный файл
Просмотреть файл

@ -0,0 +1,124 @@
/* -*- 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
*
* Buffer management types.
*/
#ifndef ORTE_DPS_TYPES_H_
#define ORTE_DPS_TYPES_H_
#include "orte_config.h"
#include "class/ompi_object.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* Structure for holding a buffer to be used with the RML or OOB
* subsystems.
*/
struct orte_buffer_t {
/** First member must be the object's parent */
ompi_object_t parent;
/** Start of my memory */
char *base_ptr;
/** Where the next data will be packed to (within the allocated
memory starting at base_ptr) */
char *pack_ptr;
/** Where the next data will be unpacked from (within the
allocated memory starting as base_ptr) */
char *unpack_ptr;
/** Number of bytes allocated (starting at base_ptr),
typically in multiples of orte_dps_pages, but may not be
if the buffer was initialized with orte_dps_load(). */
size_t bytes_allocated;
/** Number of bytes used by the buffer (i.e., amount of data --
including overhead -- packed in the buffer) */
size_t bytes_used;
/** How many bytes are available in the allocated buffer -- kept
here for convenience rather than recalculating it all the
time */
size_t bytes_avail;
};
/**
* Convenience typedef
*/
typedef struct orte_buffer_t orte_buffer_t;
/** formalize the declaration */
OMPI_DECLSPEC OBJ_CLASS_DECLARATION (orte_buffer_t);
/* define the basic orte data type */
typedef uint8_t orte_data_type_t;
/* define an object for holding blocks of bytes */
typedef struct {
size_t size;
uint8_t *bytes;
} orte_byte_object_t;
/* DEFINE INTRINSIC DATA TYPE NAMES */
/** Intrinsic type: nothing */
#define ORTE_NULL 42
/** Intrinsic type: byte */
#define ORTE_BYTE 1
/** Intrinsic type: bool */
#define ORTE_BOOL 2
/** Intrinsic type: int */
#define ORTE_INT 6
/** Intrinsic type: uint */
#define ORTE_UINT 11
/** Intrinsic type: int8 */
#define ORTE_INT8 7
/** Intrinsic type: uint8 */
#define ORTE_UINT8 12
/** Intrinsic type: int16 */
#define ORTE_INT16 8
/** Intrinsic type: uint16 */
#define ORTE_UINT16 13
/** Intrinsic type: int32 */
#define ORTE_INT32 9
/** Intrinsic type: uint32 */
#define ORTE_UINT32 14
/** Intrinsic type: int64 */
#define ORTE_INT64 10
/** Intrinsic type: uint64 */
#define ORTE_UINT64 15
/** Intrinsic type: size_t */
#define ORTE_SIZE 4
/** Intrinsic type: string */
#define ORTE_STRING 3
/** Intrinsic type: byte object */
#define ORTE_BYTE_OBJECT 30
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* ORTE_DPS_TYPES_H */

308
src/dps/dps_unpack.c Обычный файл
Просмотреть файл

@ -0,0 +1,308 @@
/*
* 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 <sys/types.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <string.h>
#include "mca/errmgr/errmgr.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;
/* check for error */
if (NULL == buffer || NULL == dst || NULL == num_vals || 0 > *num_vals ||
type >= orte_value_array_get_size(&orte_dps_types)) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* if user provides a zero for num_vals, then there is no storage allocated
* so return an appropriate error
*/
if (0 == *num_vals) {
ORTE_ERROR_LOG(ORTE_UNPACK_INADEQUATE_SPACE);
return ORTE_UNPACK_INADEQUATE_SPACE;
}
/* Unpack the stored 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
* a byte field in a string array that so happens to have a value that
* matches the size_t data type flag). Therefore, this error check is
* NOT completely safe. This is true for ALL unpack functions, not just
* size_t as used here.
*/
if (ORTE_SUCCESS != (
rc = orte_dps_unpack_sizet(buffer, &local_num, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
*num_vals = 0;
return rc;
}
/* if the storage provided is inadequate, set things up
* to unpack as much as we can and to return an error code
* indicating that everything was not unpacked - the buffer
* is left in a state where it can not be further unpacked.
*/
if (local_num > *num_vals) {
ORTE_ERROR_LOG(ORTE_UNPACK_INADEQUATE_SPACE);
local_num = *num_vals;
ret = ORTE_UNPACK_INADEQUATE_SPACE;
} else if (local_num < *num_vals) { /* more than enough storage */
*num_vals = local_num; /* let the user know how many we actually unpacked */
}
/* Unpack the value(s) */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dst, local_num, type))) {
ORTE_ERROR_LOG(rc);
*num_vals = 0;
}
if (ORTE_SUCCESS != ret) {
return ret;
}
return rc;
}
int orte_dps_unpack_buffer(orte_buffer_t *buffer, void *dst, size_t num_vals,
orte_data_type_t type)
{
int rc;
orte_dps_type_info_t *info;
orte_data_type_t local_type;
/* Unpack the data type and check it for compatibility */
if (ORTE_SUCCESS != (rc = orte_dps_get_data_type(buffer, &local_type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if the data types don't match, then return an error */
if (type != local_type) {
ORTE_ERROR_LOG(ORTE_PACK_MISMATCH);
return ORTE_PACK_MISMATCH;
}
/* Lookup the unpack function for this type and call it */
info = orte_value_array_get_item(&orte_dps_types, type);
if (ORTE_SUCCESS != (rc = info->odti_unpack_fn(buffer, dst, num_vals, type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/* UNPACK GENERIC SYSTEM TYPES */
/*
* NULL
*/
int orte_dps_unpack_null(orte_buffer_t *buffer, void *dest,
size_t num_vals, orte_data_type_t type)
{
int rc;
/* Turn around and unpack the real type */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_byte(buffer, dest, num_vals, ORTE_BYTE))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* BOOL
*/
int orte_dps_unpack_bool(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_BOOL))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}
/*
* INT
*/
int orte_dps_unpack_int(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_INT))) {
ORTE_ERROR_LOG(ret);
}
return ret;
}
/*
* SIZE_T
*/
int orte_dps_unpack_sizet(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;
}
/* UNPACK FUNCTIONS FOR NON-GENERIC SYSTEM TYPES */
/*
* BYTE, CHAR, INT8
*/
int orte_dps_unpack_byte(orte_buffer_t *buffer, void *dest,
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) {
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);
/* update buffer pointer */
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 i;
uint16_t tmp, *desttmp = (uint16_t*) dest;
/* check to see if there's enough data in buffer */
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]);
memcpy(&desttmp[i], &tmp, 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 i;
uint32_t tmp, *desttmp = (uint32_t*) dest;
/* check to see if there's enough data in buffer */
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));
}
buffer->unpack_ptr += num_vals * sizeof(tmp);
return ret;
}
int orte_dps_unpack_int64(orte_buffer_t *buffer, void *dest,
size_t num_vals, orte_data_type_t type)
{
int ret;
size_t i;
uint32_t tmp, *desttmp = (uint32_t*) dest;
num_vals *= 2;
/* check to see if there's enough data in buffer */
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));
}
buffer->unpack_ptr += num_vals * sizeof(tmp);
return ret;
}
int orte_dps_unpack_string(orte_buffer_t *buffer, void *dest,
size_t num_vals, orte_data_type_t type)
{
int ret;
size_t i, len;
char **sdest = (char**) dest;
for (i = 0; i < num_vals; ++i) {
if (ORTE_SUCCESS != (ret = orte_dps_unpack_sizet(buffer, &len, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
return ret;
}
sdest[i] = malloc(len);
if (NULL == sdest[i]) {
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))) {
ORTE_ERROR_LOG(ret);
return ret;
}
}
return ORTE_SUCCESS;
}

195
src/dps/orte_dps_open_close.c Обычный файл
Просмотреть файл

@ -0,0 +1,195 @@
/*
* 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:
*
*/
#include "orte_config.h"
#include "mca/base/mca_base_param.h"
#include "dps/dps_internal.h"
/**
* globals
*/
bool orte_dps_initialized = false;
bool orte_dps_debug = false;
int orte_dps_page_size;
orte_value_array_t orte_dps_types;
orte_data_type_t ORTE_NULL = -1;
orte_data_type_t ORTE_BYTE = -1;
orte_data_type_t ORTE_DATATYPE = -1;
orte_data_type_t ORTE_BOOL = -1;
orte_data_type_t ORTE_INT = -1;
orte_data_type_t ORTE_UINT = -1;
orte_data_type_t ORTE_INT8 = -1;
orte_data_type_t ORTE_UINT8 = -1;
orte_data_type_t ORTE_INT16 = -1;
orte_data_type_t ORTE_UINT16 = -1;
orte_data_type_t ORTE_INT32 = -1;
orte_data_type_t ORTE_UINT32 = -1;
orte_data_type_t ORTE_INT64 = -1;
orte_data_type_t ORTE_UINT64 = -1;
orte_data_type_t ORTE_SIZE = -1;
orte_data_type_t ORTE_STRING = -1;
orte_dps_t orte_dps = {
orte_dps_pack,
orte_dps_unpack,
orte_dps_peek,
orte_dps_unload,
orte_dps_load,
orte_dps_register
};
/**
* Object constructors, destructors, and instantiations
*/
static void orte_buffer_construct (orte_buffer_t* buffer)
{
/* Make everything NULL to begin with */
buffer->base_ptr = buffer->pack_ptr = buffer->unpack_ptr = NULL;
buffer->bytes_allocated = buffer->bytes_used = buffer->bytes_avail = 0;
}
static void orte_buffer_destruct (orte_buffer_t* buffer)
{
if (NULL != buffer) {
if (NULL != buffer->base_ptr) {
free (buffer->base_ptr);
}
}
}
OBJ_CLASS_INSTANCE(orte_buffer_t,
ompi_object_t,
orte_buffer_construct,
orte_buffer_destruct);
int orte_dps_open(void)
{
char *enviro_val;
int id, page_size;
if (orte_dps_initialized) {
return ORTE_SUCCESS;
}
enviro_val = getenv("ORTE_dps_debug");
if (NULL != enviro_val) { /* debug requested */
orte_dps_debug = true;
} else {
orte_dps_debug = false;
}
/* setup the page size, convert to bytes */
id = mca_base_param_register_int("dps", "page", "size", NULL, ORTE_DPS_DEFAULT_PAGE_SIZE);
mca_base_param_lookup_int(id, &page_size);
orte_dps_page_size = 1024 * page_size;
/* Setup the value array */
OBJ_CONSTRUCT(&orte_dps_types, orte_value_array_t);
orte_value_array_init(&orte_dps_types, sizeof(orte_dps_type_info_t));
/* Register all the intrinsic types */
if (ORTE_SUCCESS != orte_dps_register(orte_dps_pack_null,
orte_dps_unpack_null,
"ORTE_NULL", &ORTE_NULL) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_byte,
orte_dps_unpack_byte,
"ORTE_BYTE", &ORTE_BYTE) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_byte,
orte_dps_unpack_byte,
"ORTE_DATA_TYPE", &ORTE_DATATYPE) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_bool,
orte_dps_unpack_bool,
"ORTE_BOOL", &ORTE_BOOL) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int,
orte_dps_unpack_int,
"ORTE_INT", &ORTE_INT) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int,
orte_dps_unpack_int,
"ORTE_UINT", &ORTE_UINT) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_byte,
orte_dps_unpack_byte,
"ORTE_INT8", &ORTE_INT8) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_byte,
orte_dps_unpack_byte,
"ORTE_UINT8", &ORTE_UINT8) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int16,
orte_dps_unpack_int16,
"ORTE_INT16", &ORTE_INT16) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int16,
orte_dps_unpack_int16,
"ORTE_UINT16", &ORTE_UINT16) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int32,
orte_dps_unpack_int32,
"ORTE_INT32", &ORTE_INT32) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int32,
orte_dps_unpack_int32,
"ORTE_UINT32", &ORTE_UINT32) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int64,
orte_dps_unpack_int64,
"ORTE_INT64", &ORTE_INT64) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_int64,
orte_dps_unpack_int64,
"ORTE_UINT64", &ORTE_UINT64) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_sizet,
orte_dps_unpack_sizet,
"ORTE_SIZE", &ORTE_SIZE) ||
ORTE_SUCCESS != orte_dps_register(orte_dps_pack_string,
orte_dps_unpack_string,
"ORTE_STRING", &ORTE_STRING) ||
0) {
return ORTE_ERROR;
}
/* All done */
return ORTE_SUCCESS;
}
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;
}

Просмотреть файл

@ -20,7 +20,6 @@ SUBDIRS = \
common \
allocator \
coll \
dps \
errmgr \
gpr \
io \

Просмотреть файл

@ -21,8 +21,6 @@ SUBDIRS = sys
noinst_HEADERS = \
constants.h \
orte_constants.h \
orte_schema.h \
orte_types.h \
totalview.h \
types.h \
ompi_socket_errno.h

Просмотреть файл

@ -1,138 +0,0 @@
/*
* 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$
*/
#ifndef ORTE_SCHEMA_H
#define ORTE_SCHEMA_H
#include "orte_config.h"
#include "include/orte_types.h"
#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
* 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.
*
* * THE ACTUAL ARRAY IS INSTANTIATED IN runtime/ompi_init.c
*/
#define ORTE_ERROR_NAME(n) orte_error_strings[-1*n]
extern char *orte_error_strings[];
/*
* ORTE SEGMENT NAMES
* There are some predefined segments that are used across the entire ORTE system.
* These defines establish those names so everyone can access them, and so they
* can be easily changed if required.
*/
#define ORTE_JOB_SEGMENT "orte-job"
#define ORTE_NODE_SEGMENT "orte-node"
#define ORTE_RESOURCE_SEGMENT "orte-resources"
/*
* ORTE pre-defined tokens for special containers
*/
#define ORTE_JOB_GLOBALS "orte-job-globals"
/*
* ORTE-wide key names for storing/retrieving data from the registry.
* Subsystem-specific keys will be defined in each=/ subsystem's xxx_types.h file.
*/
#define ORTE_CELLID_KEY "orte-cellid"
#define ORTE_JOBID_KEY "orte-jobid"
#define ORTE_VPID_KEY "orte-vpid"
#define ORTE_NODE_NAME_KEY "orte-node-name"
#define ORTE_NODE_ARCH_KEY "orte-node-arch"
#define ORTE_NODE_STATE_KEY "orte-node-state"
#define ORTE_NODE_SLOTS_KEY "orte-node-slots"
#define ORTE_NODE_SLOTS_ALLOC_KEY "orte-node-slots-alloc"
#define ORTE_NODE_SLOTS_MAX_KEY "orte-node-slots-max"
#define ORTE_NODE_ALLOC_KEY "orte-node-alloc"
#define ORTE_NODE_BOOTPROXY_KEY "orte-node-bootproxy"
#define ORTE_JOB_APP_CONTEXT_KEY "orte-job-app-context"
#define ORTE_JOB_SLOTS_KEY "orte-job-slots" /**< number of procs in job */
#define ORTE_JOB_VPID_START_KEY "orte-job-vpid-start"
#define ORTE_JOB_VPID_RANGE_KEY "orte-job-vpid-range"
#define ORTE_JOB_IOF_KEY "orte-job-iof"
#define ORTE_PROC_NAME_KEY "orte-proc-name"
#define ORTE_PROC_RANK_KEY "orte-proc-rank"
#define ORTE_PROC_PID_KEY "orte-proc-pid"
#define ORTE_PROC_STATE_KEY "orte-proc-state"
#define ORTE_PROC_APP_CONTEXT_KEY "orte-proc-app-context"
#define ORTE_PROC_EXIT_CODE_KEY "orte-proc-exit-code"
#define ORTE_PROC_NUM_ALIVE "orte-proc-num-alive"
#define ORTE_PROC_NUM_ABORTED "orte-proc-num-aborted"
#define ORTE_PROC_NUM_AT_STG1 "orte-proc-num-stg1"
#define ORTE_PROC_NUM_AT_STG2 "orte-proc-num-stg2"
#define ORTE_PROC_NUM_AT_STG3 "orte-proc-num-stg3"
#define ORTE_PROC_NUM_FINALIZED "orte-proc-num-finalized"
#define ORTE_PROC_NUM_TERMINATED "orte-proc-num-terminated"
/*
* Convenience functions for accessing ORTE data
*/
typedef int (*orte_schema_get_proc_tokens_fn_t)(
char ***tokens,
size_t* num_tokens,
orte_process_name_t *proc);
typedef int (*orte_schema_get_node_tokens_fn_t)(
char ***tokens,
size_t* num_tokens,
orte_cellid_t cellid,
char *nodename);
typedef int (*orte_schema_get_cell_tokens_fn_t)(
char ***tokens,
size_t* num_tokens,
orte_cellid_t cellid);
typedef int (*orte_schema_get_job_segment_name_fn_t)(char **name, orte_jobid_t jobid);
typedef int (*orte_schema_extract_jobid_from_segment_name_fn_t)(orte_jobid_t *jobid, char *name);
/*
* Base structure for the convenience functions
*/
typedef struct {
orte_schema_get_proc_tokens_fn_t get_proc_tokens;
orte_schema_get_node_tokens_fn_t get_node_tokens;
orte_schema_get_cell_tokens_fn_t get_cell_tokens;
orte_schema_get_job_segment_name_fn_t get_job_segment_name;
orte_schema_extract_jobid_from_segment_name_fn_t extract_jobid_from_segment_name;
} orte_schema_t;
OMPI_DECLSPEC extern orte_schema_t orte_schema;
/*
* Open function to ensure orte_schema is loaded
*/
int orte_schema_open(void);
#endif

Просмотреть файл

@ -1,145 +0,0 @@
/*
* 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 */
#ifndef ORTE_TYPES_H
#define ORTE_TYPES_H
#include "class/ompi_object.h"
/**
* Supported datatypes for messaging and storage operations.
*
* ANY CHANGES TO THESE DEFINITIONS MUST BE REFLECTED IN THE TEXT ARRAY
* orte_data_strings DEFINED IN src/runtime/orte_init.c.
*
*/
typedef uint8_t orte_data_type_t ;
#define ORTE_BYTE (orte_data_type_t) 1 /**< a byte of data */
#define ORTE_BOOL (orte_data_type_t) 2 /**< boolean */
#define ORTE_STRING (orte_data_type_t) 3 /**< a NULL terminated string */
#define ORTE_SIZE (orte_data_type_t) 4 /**< the generic size_t */
#define ORTE_PID (orte_data_type_t) 5 /**< process pid */
/* all the integer flavors */
#define ORTE_INT (orte_data_type_t) 6 /**< generic integer */
#define ORTE_INT8 (orte_data_type_t) 7 /**< an 8-bit integer */
#define ORTE_INT16 (orte_data_type_t) 8 /**< a 16-bit integer */
#define ORTE_INT32 (orte_data_type_t) 9 /**< a 32-bit integer */
#define ORTE_INT64 (orte_data_type_t) 10 /**< a 64-bit integer */
/* all the unsigned integer flavors */
#define ORTE_UINT (orte_data_type_t) 11 /**< generic unsigned integer */
#define ORTE_UINT8 (orte_data_type_t) 12 /**< an 8-bit unsigned integer */
#define ORTE_UINT16 (orte_data_type_t) 13 /**< a 16-bit unsigned integer */
#define ORTE_UINT32 (orte_data_type_t) 14 /**< a 32-bit unsigned integer */
#define ORTE_UINT64 (orte_data_type_t) 15 /**< a 64-bit unsigned integer */
/* all the floating point flavors */
#define ORTE_FLOAT (orte_data_type_t) 16 /**< single-precision float */
#define ORTE_FLOAT4 (orte_data_type_t) 17 /**< 4-byte float - usually equiv to single */
#define ORTE_DOUBLE (orte_data_type_t) 18 /**< double-precision float */
#define ORTE_FLOAT8 (orte_data_type_t) 19 /**< 8-byte float - usually equiv to double */
#define ORTE_LONG_DOUBLE (orte_data_type_t) 20 /**< long-double precision float */
#define ORTE_FLOAT12 (orte_data_type_t) 21 /**< 12-byte float - used as long-double on some systems */
#define ORTE_FLOAT16 (orte_data_type_t) 22 /**< 16-byte float - used as long-double on some systems */
/* orte-specific typedefs */
#define ORTE_NAME (orte_data_type_t) 23 /**< an ompi_process_name_t */
#define ORTE_VPID (orte_data_type_t) 24 /**< a vpid */
#define ORTE_JOBID (orte_data_type_t) 25 /**< a jobid */
#define ORTE_CELLID (orte_data_type_t) 26 /**< a cellid */
#define ORTE_NODE_STATE (orte_data_type_t) 27 /**< node status flag */
#define ORTE_PROC_STATE (orte_data_type_t) 28 /**< process/resource status */
#define ORTE_EXIT_CODE (orte_data_type_t) 29 /**< process exit code */
#define ORTE_BYTE_OBJECT (orte_data_type_t) 30 /**< byte object structure */
#define ORTE_KEYVAL (orte_data_type_t) 31 /**< registry key-value pair */
#define ORTE_NOTIFY_ACTION (orte_data_type_t) 32 /**< registry notify action */
#define ORTE_GPR_CMD (orte_data_type_t) 33 /**< registry command */
#define ORTE_GPR_NOTIFY_ID (orte_data_type_t) 34 /**< registry notify id tag */
#define ORTE_GPR_VALUE (orte_data_type_t) 35 /**< registry return value */
#define ORTE_DATA_TYPE (orte_data_type_t) 36 /**< data type */
#define ORTE_APP_CONTEXT (orte_data_type_t) 37 /**< argv and enviro arrays */
#define ORTE_APP_CONTEXT_MAP (orte_data_type_t) 38 /**< application context mapping array */
#define ORTE_GPR_ADDR_MODE (orte_data_type_t) 39 /**< Addressing mode for registry cmds */
#define ORTE_GPR_SUBSCRIPTION (orte_data_type_t) 40 /**< describes data returned by subscription */
#define ORTE_GPR_NOTIFY_DATA (orte_data_type_t) 41 /**< data returned from a subscription */
#define ORTE_NULL (orte_data_type_t) 42 /**< don't interpret data type */
typedef struct {
size_t size;
uint8_t *bytes;
} orte_byte_object_t;
/** Value for orte_app_context_map_t: the data is uninitialized (!) */
#define ORTE_APP_CONTEXT_MAP_INVALID 0
/** Value for orte_app_context_map_t: the data is a comma-delimited
string of hostnames */
#define ORTE_APP_CONTEXT_MAP_HOSTNAME 1
/** Value for orte_app_context_map_t: the data is a comma-delimited
list of architecture names */
#define ORTE_APP_CONTEXT_MAP_ARCH 2
/** Value for orte_app_context_map_t: the data is a comma-delimited
list of C, cX, N, nX mappsing */
#define ORTE_APP_CONTEXT_MAP_CN 3
/**
* Information about mapping requested by the user
*/
typedef struct {
/** Parent object */
ompi_object_t super;
/** One of the ORTE_APP_CONTEXT_MAP_* values */
uint8_t map_type;
/** String data */
char *map_data;
} orte_app_context_map_t;
OBJ_CLASS_DECLARATION(orte_app_context_map_t);
/**
* Information about a specific application to be launched in the RTE.
*/
typedef struct {
/** Parent object */
ompi_object_t super;
/** Unique index when multiple apps per job */
size_t idx;
/** Absolute pathname of argv[0] */
char *app;
/** Number of copies of this process that are to be launched */
size_t num_procs;
/** Length of the argv array, not including final NULL entry */
int argc;
/** Standard argv-style array, including a final NULL pointer */
char **argv;
/** Length of the env array, not including the final NULL entry */
size_t num_env;
/** Standard environ-style array, including a final NULL pointer */
char **env;
/** Current working directory for this app */
char *cwd;
/** Length of the map_data array, not including the final NULL entry */
size_t num_map;
/** Mapping data about how this app should be laid out across CPUs
/ nodes */
orte_app_context_map_t **map_data;
} orte_app_context_t;
OBJ_CLASS_DECLARATION(orte_app_context_t);
#endif

Просмотреть файл

@ -23,7 +23,6 @@ SUBDIRS = \
base \
coll \
common \
dps \
errmgr \
io \
iof \

Просмотреть файл

@ -21,7 +21,7 @@
#include "util/output.h"
#include "util/proc_info.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/errmgr/errmgr.h"

Просмотреть файл

@ -1,120 +0,0 @@
/* -*- 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$
*
*/
#ifndef ORTE_DPS_INTERNAL_H_
#define ORTE_DPS_INTERNAL_H_
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/*
* DEFINE THE DEFAULT PAGE SIZE FOR THE DPS BUFFERS - IN KILOBYTES
*/
#define ORTE_DPS_DEFAULT_PAGE_SIZE 1
/*
* ORTE type corresponding to size_t
*/
#if SIZEOF_SIZE_T == 1
#define DPS_TYPE_SIZE_T ORTE_UINT8
#elif SIZEOF_SIZE_T == 2
#define DPS_TYPE_SIZE_T ORTE_UINT16
#elif SIZEOF_SIZE_T == 4
#define DPS_TYPE_SIZE_T ORTE_UINT32
#elif SIZEOF_SIZE_T == 8
#define DPS_TYPE_SIZE_T ORTE_UINT64
#else
#error Unsupported size_t size!
#endif
/*
* ORTE type corresponding to int and unsigned int
*/
#if SIZEOF_INT == 1
#define DPS_TYPE_INT ORTE_INT8
#define DPS_TYPE_UINT ORTE_UINT8
#elif SIZEOF_INT == 2
#define DPS_TYPE_INT ORTE_INT16
#define DPS_TYPE_UINT ORTE_UINT16
#elif SIZEOF_INT == 4
#define DPS_TYPE_INT ORTE_INT32
#define DPS_TYPE_UINT ORTE_UINT32
#elif SIZEOF_INT == 8
#define DPS_TYPE_INT ORTE_INT64
#define DPS_TYPE_UINT ORTE_UINT64
#else
#error Unsupported int size!
#endif
/*
* globals needed within dps
*/
extern bool orte_dps_debug;
extern int orte_dps_page_size;
/*
* Implementations of API functions
*/
int orte_dps_pack(orte_buffer_t *buffer, void *src,
size_t num_vals,
orte_data_type_t type);
int orte_dps_unpack(orte_buffer_t *buffer, void *dest,
size_t *max_num_vals,
orte_data_type_t type);
int orte_dps_pack_nobuffer(void *dst, void *src, size_t num_vals,
orte_data_type_t type, size_t *num_bytes);
int orte_dps_unpack_nobuffer(void *dst, void *src, size_t num_values,
orte_data_type_t type,
size_t *mem_left, size_t *num_bytes);
int orte_dps_peek(orte_buffer_t *buffer,
orte_data_type_t *type,
size_t *number);
int orte_dps_unload(orte_buffer_t *buffer,
void **payload,
size_t *size);
int orte_dps_load(orte_buffer_t *buffer,
void *payload,
size_t size);
int orte_dps_dump_buffer_simple(orte_buffer_t *buffer, int outid);
int orte_dps_dump_buffer(orte_buffer_t *buffer, int outid);
/*
* Totally internal functions
*/
size_t orte_dps_memory_required(void *src, size_t num_vals, orte_data_type_t type);
int orte_dps_buffer_extend (orte_buffer_t *bptr, size_t mem_req);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

Просмотреть файл

@ -1,101 +0,0 @@
/*
* 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:
*
*/
#include "orte_config.h"
#include "mca/base/mca_base_param.h"
#include "dps/dps_internal.h"
/**
* globals
*/
bool orte_dps_debug;
int orte_dps_page_size;
orte_dps_t orte_dps = {
orte_dps_pack,
orte_dps_unpack,
orte_dps_pack_nobuffer,
orte_dps_unpack_nobuffer,
orte_dps_peek,
orte_dps_unload,
orte_dps_load,
orte_dps_dump_buffer
};
/**
* Object constructors, destructors, and instantiations
*/
static void orte_buffer_construct (orte_buffer_t* buffer)
{
/* allocate the initial data space */
buffer->base_ptr = (void *)malloc(orte_dps_page_size);
if (NULL == buffer->base_ptr) { /* got an error = can't init */
buffer->base_ptr = buffer->data_ptr = buffer->from_ptr = NULL;
buffer->pages = buffer->size = buffer->len = buffer-> space = buffer-> toend = 0;
} else {
buffer->data_ptr = buffer->base_ptr;
buffer->from_ptr = buffer->base_ptr;
buffer->pages = 1;
buffer->size = orte_dps_page_size;
buffer->space = orte_dps_page_size;
buffer->len = 0;
buffer->toend = 0;
}
}
static void orte_buffer_destruct (orte_buffer_t* buffer)
{
/* paranoid check */
if (NULL != buffer) {
if (NULL != buffer->base_ptr) free (buffer->base_ptr);
}
}
OBJ_CLASS_INSTANCE(orte_buffer_t,
ompi_object_t,
orte_buffer_construct,
orte_buffer_destruct);
int orte_dps_open(void)
{
char *enviro_val;
int id, page_size;
enviro_val = getenv("ORTE_dps_debug");
if (NULL != enviro_val) { /* debug requested */
orte_dps_debug = true;
} else {
orte_dps_debug = false;
}
/* setup the page size */
id = mca_base_param_register_int("dps", "page", "size", NULL, ORTE_DPS_DEFAULT_PAGE_SIZE);
mca_base_param_lookup_int(id, &page_size);
orte_dps_page_size = 1000*page_size; /* convert to bytes */
return ORTE_SUCCESS;
}
int orte_dps_close(void)
{
/* no idea what this would do right now - include it for completeness */
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,212 +0,0 @@
/*
* 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:
*
*/
#include "orte_config.h"
#include <stdio.h>
#include <sys/types.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include "util/output.h"
#include "mca/gpr/gpr_types.h"
#include "mca/ns/ns_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "dps/dps_internal.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
int orte_dps_pack_system_types(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int rc;
/* CHECK FOR A GENERIC SYSTEM TYPE */
real_type = orte_dps_get_real_type(type);
if (real_type != type) {
if (ORTE_SUCCESS != (rc = orte_dps_store_data_type(buffer, real_type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
/* now pack the native values */
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer, src, num_vals, real_type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_native_types(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
switch(type) {
case ORTE_BYTE:
case ORTE_INT8:
case ORTE_UINT8:
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, num_vals))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE);
}
/* store the data */
memcpy(dst, src, num_vals);
/* update the buffer counters and pointers */
buffer->data_ptr = (void*)((char*)dst + num_vals);
buffer->len += num_vals;
buffer->space -= num_vals;
buffer->toend += num_vals;
return ORTE_SUCCESS;
case ORTE_INT16:
case ORTE_UINT16:
elementsize = sizeof (uint16_t);
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, elementsize*num_vals))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE);
}
/* store the data */
dptr = (char *) dst;
s16 = (uint16_t *) src;
for (i=0; i<num_vals; i++) {
/* convert the host order to network order */
tmp_16 = htons(*s16);
memcpy (dptr, (char*) &tmp_16, elementsize);
dptr+=elementsize;
s16++;
}
/* update the buffer counters and pointers */
buffer->data_ptr = (void*)dptr;
buffer->len += elementsize*num_vals;
buffer->space -= elementsize*num_vals;
buffer->toend += elementsize*num_vals;
return ORTE_SUCCESS;
case ORTE_INT32:
case ORTE_UINT32:
elementsize = sizeof (uint32_t);
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, elementsize*num_vals))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE);
}
/* store the data */
dptr = (char *) dst;
s32 = (uint32_t *) src;
for (i=0; i<num_vals; i++) {
/* convert the host order to network order */
tmp_32 = htonl(*s32);
memcpy (dptr, (char*) &tmp_32, elementsize);
dptr+=elementsize;
s32++;
}
/* update the buffer counters and pointers */
buffer->data_ptr = (void*)dptr;
buffer->len += elementsize*num_vals;
buffer->space -= elementsize*num_vals;
buffer->toend += elementsize*num_vals;
return ORTE_SUCCESS;
case ORTE_INT64:
case ORTE_UINT64:
elementsize = 2*sizeof (uint32_t);
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, elementsize*num_vals))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE);
}
/* store the data */
dptr = (char *) dst;
s32 = (uint32_t *) src;
for (i=0; i<num_vals; i++) {
/* convert the host order to network order */
tmp_32 = htonl(*s32);
memcpy (dptr, (char*) &tmp_32, sizeof(uint32_t));
dptr += sizeof(uint32_t);
s32++;
/* do it twice to get 64 bits */
tmp_32 = htonl(*s32);
memcpy (dptr, (char*) &tmp_32, sizeof(uint32_t));
dptr += sizeof(uint32_t);
s32++;
}
/* update the buffer counters and pointers */
buffer->data_ptr = (void*)dptr;
buffer->len += elementsize*num_vals;
buffer->space -= elementsize*num_vals;
buffer->toend += elementsize*num_vals;
return ORTE_SUCCESS;
case ORTE_FLOAT:
case ORTE_FLOAT4:
case ORTE_FLOAT8:
case ORTE_FLOAT12:
case ORTE_FLOAT16:
case ORTE_DOUBLE:
case ORTE_LONG_DOUBLE:
ORTE_ERROR_LOG(ORTE_ERR_NOT_IMPLEMENTED);
return ORTE_ERR_NOT_IMPLEMENTED;
break;
case ORTE_STRING:
str = (char **) src;
for (i=0; i<num_vals; i++) {
len = strlen(str[i]); /* exclude the null terminator */
/* store the size data type */
if (ORTE_SUCCESS != (rc = orte_dps_store_data_type(buffer, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* store the real size data type */
if (ORTE_SUCCESS != (rc = orte_dps_store_data_type(buffer, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* store the length */
if (ORTE_SUCCESS != (rc =
orte_dps_pack_buffer(buffer, &len, 1, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* check to see if buffer needs extending */
if (NULL == (dst = orte_dps_buffer_extend(buffer, len))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE);
}
dptr = (char*)dst;
memcpy(dptr, str[i], len); /* copy str to buffer */
/* update the buffer counters and pointers */
buffer->data_ptr = (void*)(dptr + len);
buffer->len += len;
buffer->space -= len;
buffer->toend += len;
}
return ORTE_SUCCESS;
}
}

Просмотреть файл

@ -1,192 +0,0 @@
/*
* 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:
*
*/
#include "ompi_config.h"
#include <stdio.h>
#include <sys/types.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include "util/output.h"
#include "mca/gpr/gpr_types.h"
#include "mca/ns/ns_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "dps/dps_internal.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
int orte_dps_pack_name(orte_buffer_t *buffer,
orte_process_name_t *proc,
size_t num_vals)
{
orte_cellid_t cellid;
orte_jobid_t jobid;
orte_vpid_t vpid;
size_t i;
int rc;
for (i=0; i<num_vals; i++) {
if (ORTE_SUCCESS != (rc = orte_ns.get_cellid(&cellid, proc))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps_pack_cellid(buffer,
&cellid, 1))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid, proc))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps_pack_jobid(buffer,
&jobid, 1))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns.get_vpid(&vpid, proc))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps_pack_vpid(buffer,
&vpid, 1))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
return ORTE_SUCCESS;
}
int orte_dps_pack_cellid(orte_buffer_t *buffer,
orte_cellid_t *cellid,
size_t num_vals)
{
orte_data_type_t real_type;
int rc;
real_type = orte_dps_real_type(ORTE_CELLID);
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)cellid, num_vals, real_type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_jobid(orte_buffer_t *buffer,
orte_jobid_t *jobid,
size_t num_vals)
{
orte_data_type_t real_type;
int rc;
real_type = orte_dps_real_type(ORTE_JOBID);
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)jobid, num_vals, real_type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_vpid(orte_buffer_t *buffer,
orte_vpid_t *vpid,
size_t num_vals)
{
orte_data_type_t real_type;
int rc;
real_type = orte_dps_real_type(ORTE_VPID);
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)vpid, num_vals, real_type))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_node_state(orte_buffer_t *buffer,
orte_node_state_t *state,
size_t num_vals)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)state, num_vals, ORTE_UINT8))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_proc_state(orte_buffer_t *buffer,
orte_proc_state_t *state,
size_t num_vals)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)state, num_vals, ORTE_UINT8))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_gpr_addr_mode(orte_buffer_t *buffer,
orte_gpr_addr_mode_t *mode,
size_t num_vals)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)mode, num_vals, ORTE_UINT16))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_gpr_cmd(orte_buffer_t *buffer,
orte_gpr_cmd_t *cmd,
size_t num_vals)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)cmd, num_vals, ORTE_UINT16))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_dps_pack_notify_action(orte_buffer_t *buffer,
orte_notify_action_t *action,
size_t num_vals)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_native_types(buffer,
(void*)action, num_vals, ORTE_UINT16))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}

Просмотреть файл

@ -1,86 +0,0 @@
/*
* 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$
*/
/*
* DPS Buffer Operations
*/
/** @file:
*
*/
#include "orte_config.h"
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "dps/dps_internal.h"
int orte_dps_peek(orte_buffer_t *buffer,
orte_data_type_t *type,
size_t *number)
{
int rc=ORTE_SUCCESS;
size_t num_vals;
size_t mem_left;
size_t num_bytes, hdr_bytes;
void *src;
orte_data_type_t stored_type;
/* check for errors */
if (buffer == NULL) {
return (ORTE_ERR_BAD_PARAM);
}
num_bytes = 0; /* have not unpacked any yet */
hdr_bytes = 0;
src = buffer->from_ptr; /* get location in buffer */
mem_left = buffer->toend; /* how much data is left in buffer */
/* check to see if there is enough in the buffer to hold the pack type */
if (mem_left < sizeof(orte_data_type_t)) {
return ORTE_ERR_UNPACK_FAILURE;
}
/* first thing in the current buffer space must be the type */
if (ORTE_SUCCESS != (rc =orte_dps_unpack_nobuffer(&stored_type, src, 1,
ORTE_DATA_TYPE, &mem_left, &hdr_bytes))) {
return rc;
}
src = (void*)((char*)src + hdr_bytes);
/* got enough left for num_vals? */
if (sizeof(size_t) > mem_left) { /* not enough memory */
return ORTE_ERR_UNPACK_FAILURE;
}
/* unpack the number of values */
if (ORTE_SUCCESS != (rc =orte_dps_unpack_nobuffer(&num_vals, src, 1,
DPS_TYPE_SIZE_T, &mem_left, &num_bytes))) {
return rc;
}
if (type != NULL) {
*type = stored_type;
}
if (number != NULL) {
*number = num_vals;
}
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,823 +0,0 @@
/*
* 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$
*/
/*
* DPS Buffer Operations
*/
/** @file:
*
*/
#include "orte_config.h"
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <string.h>
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "mca/gpr/gpr_types.h"
#include "mca/ns/ns_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "dps/dps_internal.h"
/**
* DPS UNPACK VALUE
*/
int orte_dps_unpack(orte_buffer_t *buffer, void *dst,
size_t *max_num_vals,
orte_data_type_t type)
{
int rc=ORTE_SUCCESS;
size_t num_vals;
size_t mem_left;
size_t num_bytes, hdr_bytes;
void *src;
orte_data_type_t stored_type;
/* check for errors */
if (buffer == NULL || dst == NULL || max_num_vals == NULL) {
return (ORTE_ERR_BAD_PARAM);
}
num_bytes = 0; /* have not unpacked any yet */
hdr_bytes = 0;
src = buffer->from_ptr; /* get location in buffer */
mem_left = buffer->toend; /* how much data is left in buffer */
/* check to see if there is enough in the buffer to hold the pack type */
if (mem_left < sizeof(orte_data_type_t)) {
return ORTE_ERR_UNPACK_FAILURE;
}
/* first thing in the current buffer space must be the type */
if (ORTE_SUCCESS != (rc =orte_dps_unpack_nobuffer(&stored_type, src, 1,
ORTE_DATA_TYPE, &mem_left, &hdr_bytes))) {
return rc;
}
src = (void*)((char*)src + hdr_bytes);
/* check for size of generic data types so they can be properly
packed NOTE we convert the generic data type flag to a hard
type for storage to handle heterogeneity */
if (ORTE_INT == type) {
type = DPS_TYPE_INT;
} else if (ORTE_UINT == type) {
type = DPS_TYPE_UINT;
} else if (ORTE_SIZE == type) {
type = DPS_TYPE_SIZE_T;
}
/* check for type match - for now we require this to be an exact match -
* though we should probably support conversions when there is no loss
* of precision.
*/
if (stored_type != type) {
return ORTE_PACK_MISMATCH;
}
/* got enough left for num_vals? */
if (mem_left < sizeof(size_t)) { /* not enough memory */
return ORTE_ERR_UNPACK_FAILURE;
}
/* unpack the number of values */
if (ORTE_SUCCESS != (rc =orte_dps_unpack_nobuffer(&num_vals, src, 1,
DPS_TYPE_SIZE_T, &mem_left, &num_bytes))) {
return rc;
}
src = (void*)((char*)src + num_bytes);
hdr_bytes += num_bytes;
/* will check to see if adequate storage in buffer prior
* to unpacking the item
*/
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(dst, src, num_vals,
stored_type, &mem_left, &num_bytes))) {
return rc;
}
#if OMPI_ENABLE_DEBUG
/* fflush(stdout); fflush(stderr); */
/* fprintf(stderr,"unpacked total bytes %d, (hdr %d datatype %d)\n", num_bytes+hdr_bytes, hdr_bytes, num_bytes); */
/* fflush(stdout); fflush(stderr); */
#endif
/* ok, we managed to unpack some stuff, so update all ptrs/cnts */
buffer->from_ptr = (void*)((char*)src + num_bytes); /* move by data type size only as src is after the header */
buffer->toend = mem_left; /* closer to the end */
buffer->len -= (num_bytes+hdr_bytes); /* and less data left */
/* return the number of values unpacked */
*max_num_vals = num_vals;
return rc;
}
int orte_dps_unpack_nobuffer(void *dst, void *src, size_t num_vals,
orte_data_type_t type,
size_t *mem_left, size_t *num_bytes)
{
int rc;
size_t i;
size_t n;
size_t elementsize; /* size in bytes of an unpacked element */
char* srcptr; /* temp moving source pointer */
uint16_t * d16;
uint32_t * d32;
uint16_t tmp_16;
uint32_t tmp_32;
uint8_t* bool_src;
bool *bool_dst;
char **dstr;
orte_process_name_t* dn;
orte_process_name_t tmp_procname;
orte_byte_object_t* dbyteptr;
orte_gpr_keyval_t **keyval;
orte_gpr_value_t **values;
orte_app_context_t **app_context;
orte_app_context_map_t **app_context_map;
uint32_t len;
char *str;
orte_gpr_subscription_t **subs;
orte_gpr_notify_data_t **data;
/* defaults */
rc = ORTE_SUCCESS;
*num_bytes = 0;
switch(type) {
case ORTE_DATA_TYPE:
case ORTE_NODE_STATE:
case ORTE_PROC_STATE:
case ORTE_EXIT_CODE:
case ORTE_BYTE:
case ORTE_INT8:
case ORTE_UINT8:
if (num_vals > *mem_left) {
num_vals = *mem_left;
rc = ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
memcpy(dst, src, num_vals);
*num_bytes = num_vals * sizeof(uint8_t);
break;
case ORTE_NOTIFY_ACTION:
case ORTE_GPR_ADDR_MODE:
case ORTE_GPR_CMD:
case ORTE_INT16:
case ORTE_UINT16:
srcptr = (char *) src;
d16 = (uint16_t *) dst;
elementsize = sizeof (uint16_t);
if(num_vals * elementsize > *mem_left) {
num_vals = *mem_left / elementsize;
rc = ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
for(i=0; i<num_vals; i++) {
memcpy ((char*)&tmp_16, srcptr, elementsize);
/* convert the network order to host order */
*d16 = ntohs(tmp_16);
d16++; srcptr+=elementsize;
}
*num_bytes = num_vals * elementsize;
break;
case ORTE_VPID:
case ORTE_JOBID:
case ORTE_CELLID:
case ORTE_GPR_NOTIFY_ID:
case ORTE_INT32:
case ORTE_UINT32:
srcptr = (char *) src;
d32 = (uint32_t *) dst;
elementsize = sizeof (uint32_t);
if(num_vals * elementsize > *mem_left) {
num_vals = *mem_left / elementsize;
rc = ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
for(i=0; i<num_vals; i++) {
memcpy ((char*)&tmp_32, srcptr, elementsize);
/* convert the network order to host order */
*d32 = ntohl(tmp_32);
d32++;
srcptr+=elementsize;
}
*num_bytes = num_vals * elementsize;
break;
case ORTE_INT64:
case ORTE_UINT64:
srcptr = (char *) src;
d32 = (uint32_t *) dst;
if(num_vals * sizeof(uint64_t) > *mem_left) {
num_vals = *mem_left / sizeof(uint64_t);
rc = ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
for(i=0; i<num_vals; i++) {
memcpy ((char*)&tmp_32, srcptr, sizeof(uint32_t));
/* convert the network order to host order */
*d32 = ntohl(tmp_32);
d32++;
srcptr += sizeof(uint32_t);
/* do it twice to get 64 bits */
memcpy ((char*)&tmp_32, srcptr, sizeof(uint32_t));
/* convert the network order to host order */
*d32 = ntohl(tmp_32);
d32++;
srcptr += sizeof(uint32_t);
}
*num_bytes = num_vals * sizeof(uint64_t);
break;
case ORTE_FLOAT:
case ORTE_FLOAT4:
case ORTE_FLOAT8:
case ORTE_FLOAT12:
case ORTE_FLOAT16:
case ORTE_DOUBLE:
case ORTE_LONG_DOUBLE:
return ORTE_ERR_NOT_IMPLEMENTED;
break;
case ORTE_BOOL:
if(num_vals * sizeof(uint8_t) > *mem_left) {
num_vals = *mem_left / sizeof(uint8_t);
rc = ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
bool_src = (uint8_t *) src;
bool_dst = (bool *) dst;
for(i=0; i<num_vals; i++) {
/* convert packed uint8_t to native bool */
*bool_dst = (*bool_src) ? true : false;
bool_dst++; bool_src++;
}
*num_bytes = num_vals * sizeof(uint8_t);
break;
case ORTE_STRING:
dstr = (char**)dst;
srcptr = (char *) src;
elementsize = sizeof (uint32_t);
for(i=0; i<num_vals; i++) {
/* unpack length of string first */
if(*mem_left < elementsize) {
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
memcpy ((char*)&tmp_32, srcptr, elementsize);
len = ntohl(tmp_32);
srcptr += elementsize;
*num_bytes += elementsize;
*mem_left -= elementsize;
/* now unpack string */
if(*mem_left < len) {
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
if(NULL == (str = malloc(len+1))) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
memcpy(str, srcptr, len);
str[len] = '\0';
dstr[i] = str;
srcptr += len;
*mem_left -= len;
*num_bytes += len;
}
return ORTE_SUCCESS;
break;
case ORTE_NAME:
dn = (orte_process_name_t*) dst;
srcptr = (char *) src;
elementsize = sizeof (orte_process_name_t);
for (i=0; i<num_vals; i++) {
memcpy ((char*) &tmp_procname, srcptr, elementsize);
dn->cellid = ntohl(tmp_procname.cellid);
dn->jobid = ntohl(tmp_procname.jobid);
dn->vpid = ntohl(tmp_procname.vpid);
dn++; srcptr+=elementsize;
}
*num_bytes = num_vals * elementsize;
break;
case ORTE_BYTE_OBJECT:
dbyteptr = (orte_byte_object_t*)dst;
srcptr = (char*) src; /* iterate from start of buffer */
elementsize = sizeof (uint32_t);
for(i=0; i<num_vals; i++) {
/* unpack object size in bytes first */
if(*mem_left < elementsize) {
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
memcpy ((char*)&tmp_32, srcptr, elementsize);
dbyteptr->size = ntohl(tmp_32);
srcptr += elementsize;
*num_bytes += elementsize;
*mem_left -= elementsize;
if(*mem_left < dbyteptr->size) {
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
if(NULL == (dbyteptr->bytes = malloc(dbyteptr->size))) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
memcpy(dbyteptr->bytes, srcptr, dbyteptr->size);
srcptr += dbyteptr->size;
*mem_left -= dbyteptr->size;
*num_bytes += dbyteptr->size;
dbyteptr++;
}
return ORTE_SUCCESS;
break;
case ORTE_KEYVAL:
/* unpack into an array of keyval objects */
keyval = (orte_gpr_keyval_t**) dst;
/* use temp count of unpacked 'n' which we sum to produce correct value later */
for (i=0; i < num_vals; i++) {
keyval[i] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == keyval[i]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(keyval[i]->key),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(keyval[i]->type),
src, 1, ORTE_DATA_TYPE, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(keyval[i]->value),
src, 1, keyval[i]->type, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* must return here for composite unpacks that change mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_GPR_VALUE:
/* unpack into array of value objects */
values = (orte_gpr_value_t**) dst;
for (i=0; i < num_vals; i++) {
/* create the value object */
values[i] = OBJ_NEW(orte_gpr_value_t);
if (NULL == values[i]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the address mode */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(values[i]->addr_mode),
src, 1, ORTE_GPR_ADDR_MODE, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the segment name */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(values[i]->segment),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* get the number of tokens */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(values[i]->num_tokens),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(values[i]->tokens,
src, values[i]->num_tokens, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* get the number of keyval pairs */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(values[i]->cnt),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* allocate the required space for the keyval object pointers */
if(values[i]->cnt) {
values[i]->keyvals = (orte_gpr_keyval_t**)malloc(values[i]->cnt * sizeof(orte_gpr_keyval_t*));
if (NULL == values[i]->keyvals) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the keyval pairs */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(values[i]->keyvals,
src, values[i]->cnt, ORTE_KEYVAL, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
}
/* must return here for composite unpacks that change mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_APP_CONTEXT:
/* unpack into array of app_context objects */
app_context = (orte_app_context_t**) dst;
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]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* get the app index number */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->idx),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the application name */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->app),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* get the number of processes */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->num_procs),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* get the number of argv strings */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->argc),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
app_context[i]->argv[app_context[i]->argc] = NULL;
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(app_context[i]->argv,
src, app_context[i]->argc, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* get the number of env strings */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->num_env),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
app_context[i]->env[app_context[i]->num_env] = NULL;
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(app_context[i]->env,
src, app_context[i]->num_env, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* unpack the cwd */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&app_context[i]->cwd,
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the map data */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context[i]->num_map),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(app_context[i]->map_data,
src, app_context[i]->num_map, ORTE_APP_CONTEXT_MAP, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes += n;
}
}
/* must return here for composite unpacks that change
mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_APP_CONTEXT_MAP:
/* unpack into array of app_context_map objects */
app_context_map = (orte_app_context_map_t**) dst;
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]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* map type */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context_map[i]->map_type),
src, 1, ORTE_UINT8, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* map data */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(app_context_map[i]->map_data),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* must return here for composite unpacks that change mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_GPR_SUBSCRIPTION:
/* unpack into array of subscription objects */
subs = (orte_gpr_subscription_t**) dst;
for (i=0; i < num_vals; i++) {
/* create the subscription object */
subs[i] = OBJ_NEW(orte_gpr_subscription_t);
if (NULL == subs[i]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the address mode */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(subs[i]->addr_mode),
src, 1, ORTE_GPR_ADDR_MODE, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the segment name */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(subs[i]->segment),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* get the number of tokens */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(subs[i]->num_tokens),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(subs[i]->tokens,
src, subs[i]->num_tokens, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* get the number of keys */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(subs[i]->num_keys),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(subs[i]->keys,
src, subs[i]->num_keys, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
/* the pointer fields for cb_func and user_tag were NOT packed
* so ignore them here as well
*/
}
/* must return here for composite unpacks that change mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_GPR_NOTIFY_DATA:
/* unpack into array of notify_data objects */
data = (orte_gpr_notify_data_t**) dst;
for (i=0; i < num_vals; i++) {
/* create the data object */
data[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (NULL == data[i]) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the callback number */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(data[i]->cb_num),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the address mode */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(data[i]->addr_mode),
src, 1, ORTE_GPR_ADDR_MODE, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* unpack the segment name */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(data[i]->segment),
src, 1, ORTE_STRING, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* get the number of values */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(&(data[i]->cnt),
src, 1, ORTE_INT32, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
/* 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) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
n = 0;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_nobuffer(data[i]->values,
src, data[i]->cnt, ORTE_GPR_VALUE, mem_left, &n))) {
return rc;
}
src = (void*)((char*)src + n);
*num_bytes+=n;
}
}
/* must return here for composite unpacks that change mem_left directly */
return ORTE_SUCCESS;
break;
case ORTE_NULL:
break;
default:
return ORTE_ERROR;
}
*mem_left -= *num_bytes;
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,472 +0,0 @@
/*
* 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:
*
*/
#include "ompi_config.h"
#include <stdio.h>
#include <sys/types.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include "util/output.h"
#include "mca/gpr/gpr_types.h"
#include "mca/ns/ns_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "dps/dps_internal.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
/**
* Internal-use only functions
*/
/**
* Calculate the memory storage required for the requested operation
*/
size_t orte_dps_memory_required(void *src, size_t num_vals, orte_data_type_t type)
{
char **strptr=NULL;
size_t i=0, mem_req=0;
orte_byte_object_t *sbyteptr=NULL;
orte_gpr_keyval_t **keyval;
orte_gpr_value_t **values;
orte_app_context_t **app_context;
orte_app_context_map_t **app_context_map;
orte_gpr_subscription_t **subs;
orte_gpr_notify_data_t **data;
switch(type) {
case ORTE_DATA_TYPE:
case ORTE_NODE_STATE:
case ORTE_PROC_STATE:
case ORTE_EXIT_CODE:
case ORTE_BOOL:
case ORTE_BYTE:
case ORTE_INT8:
case ORTE_UINT8:
return num_vals;
case ORTE_NOTIFY_ACTION:
case ORTE_GPR_ADDR_MODE:
case ORTE_GPR_CMD:
case ORTE_INT16:
case ORTE_UINT16:
return (size_t)(num_vals * sizeof(uint16_t));
case ORTE_VPID:
case ORTE_JOBID:
case ORTE_CELLID:
case ORTE_GPR_NOTIFY_ID:
case ORTE_INT32:
case ORTE_UINT32:
return (size_t)(num_vals * sizeof(uint32_t));
case ORTE_INT64:
case ORTE_UINT64:
return (size_t)(num_vals * sizeof(uint64_t));
case ORTE_NULL:
return 0;
case ORTE_STRING:
strptr = (char **) src;
for (i=0; i<num_vals; i++) {
/* need to reserve sizeof(uint32_t) for length */
mem_req += sizeof(uint32_t);
mem_req += strlen(*strptr); /* string - null-terminator */
strptr++;
}
return mem_req;
case ORTE_NAME:
return (size_t)(num_vals * sizeof(orte_process_name_t));
case ORTE_BYTE_OBJECT:
sbyteptr = (orte_byte_object_t *) src;
for (i=0; i<num_vals; i++) {
mem_req += sizeof(uint32_t); /* length */
mem_req += sbyteptr->size; /* bytes */
sbyteptr++;
}
return mem_req;
case ORTE_KEYVAL:
mem_req = 0;
keyval = (orte_gpr_keyval_t**) src;
for (i=0; i < num_vals; i++) {
mem_req += orte_dps_memory_required(
(void*)(&(keyval[i]->key)), 1, ORTE_STRING);
mem_req += sizeof(orte_data_type_t); /* store data type */
mem_req += orte_dps_memory_required(
(void*)(&(keyval[i]->value)), 1, keyval[i]->type);
}
return mem_req;
case ORTE_GPR_VALUE:
mem_req = 0;
values = (orte_gpr_value_t**) src;
for (i=0; i<num_vals; i++) {
mem_req += orte_dps_memory_required(
(void*)(&(values[i]->addr_mode)), 1,
ORTE_GPR_ADDR_MODE);
mem_req += orte_dps_memory_required(
(void*)(&(values[i]->segment)), 1, ORTE_STRING);
mem_req += sizeof(int32_t); /* number of tokens */
mem_req += orte_dps_memory_required(
(void*)(values[i]->tokens), values[i]->num_tokens,
ORTE_STRING);
mem_req += sizeof(int32_t); /* number of keyvals */
mem_req += orte_dps_memory_required(
(void*)(values[i]->keyvals), values[i]->cnt,
ORTE_KEYVAL);
}
return mem_req;
case ORTE_APP_CONTEXT:
mem_req = 0;
app_context = (orte_app_context_t**) src;
for (i=0; i < num_vals; i++) {
mem_req += sizeof(int32_t); /* app index number */
mem_req += orte_dps_memory_required(
(void*)(&(app_context[i]->app)), 1, ORTE_STRING); /* application name */
mem_req += sizeof(int32_t); /* number or processes */
mem_req += sizeof(int32_t); /* number of argv entries */
mem_req += orte_dps_memory_required(
(void*)(app_context[i]->argv),
app_context[i]->argc, ORTE_STRING); /* length of all argvs */
mem_req += sizeof(int32_t); /* number of env entries */
mem_req += orte_dps_memory_required(
(void*)(app_context[i]->env),
app_context[i]->num_env, ORTE_STRING); /* length of all envs */
mem_req += orte_dps_memory_required(
(void*)(&(app_context[i]->cwd)), 1, ORTE_STRING); /* cwd string */
mem_req += sizeof(int32_t); /* number of maps */
mem_req += orte_dps_memory_required(
(void*)(app_context[i]->map_data),
app_context[i]->num_map, ORTE_APP_CONTEXT_MAP); /* proc map */
}
return mem_req;
case ORTE_APP_CONTEXT_MAP:
mem_req = 0;
app_context_map = (orte_app_context_map_t**) src;
for (i=0; i < num_vals; i++) {
mem_req += sizeof(uint8_t); /* map_type */
mem_req += orte_dps_memory_required(
(void*)(&(app_context_map[i]->map_data)), 1, ORTE_STRING); /* map data */
}
return mem_req;
case ORTE_GPR_SUBSCRIPTION:
mem_req = 0;
subs = (orte_gpr_subscription_t**) src;
for (i=0; i<num_vals; i++) {
mem_req += orte_dps_memory_required(
(void*)(&(subs[i]->addr_mode)), 1,
ORTE_GPR_ADDR_MODE);
mem_req += orte_dps_memory_required(
(void*)(&(subs[i]->segment)), 1, ORTE_STRING);
mem_req += sizeof(int32_t); /* number of tokens */
mem_req += orte_dps_memory_required(
(void*)(subs[i]->tokens), subs[i]->num_tokens,
ORTE_STRING);
mem_req += sizeof(int32_t); /* number of keys */
mem_req += orte_dps_memory_required(
(void*)(subs[i]->keys), subs[i]->num_keys,
ORTE_STRING);
/* don't store the cb_func and user_tag pointers, so
* don't reserve memory for them
*/
}
return mem_req;
case ORTE_GPR_NOTIFY_DATA:
mem_req = 0;
data = (orte_gpr_notify_data_t**) src;
for (i=0; i<num_vals; i++) {
mem_req += sizeof(int32_t); /* callback number */
mem_req += orte_dps_memory_required(
(void*)(&(data[i]->addr_mode)), 1,
ORTE_GPR_ADDR_MODE);
mem_req += orte_dps_memory_required(
(void*)(&(data[i]->segment)), 1, ORTE_STRING);
mem_req += sizeof(int32_t); /* number of values */
mem_req += orte_dps_memory_required(
(void*)(data[i]->values), data[i]->cnt,
ORTE_GPR_VALUE);
}
return mem_req;
default:
return 0; /* unrecognized type */
}
}
/**
* Internal function that resizes (expands) an inuse buffer...adds
* requested memory in units of memory pages to the current buffer.
*/
int orte_dps_buffer_extend(orte_buffer_t *bptr, size_t mem_req)
{
/* no buffer checking, we should know what we are doing in here */
size_t newsize;
int pages;
void* newbaseptr;
int num_pages;
ssize_t mdiff;
size_t sdiff; /* difference (increase) in space */
/* how many pages are required */
num_pages = mem_req / orte_dps_page_size;
if (0 != mem_req % orte_dps_page_size) {
++num_pages;
}
/* push up page count */
pages = bptr->pages + num_pages;
newsize = (size_t)(pages*orte_dps_page_size);
sdiff = newsize - bptr->size; /* actual increase in space */
/* have to use relative change as no absolute without */
/* doing pointer maths for some counts such as space */
newbaseptr = realloc (bptr->base_ptr, newsize);
if (!newbaseptr) { return (ORTE_ERR_OUT_OF_RESOURCE); }
/* ok, we have new memory */
/* update all the pointers in the buffer */
/* first calc change in memory location */
mdiff = ((char*)newbaseptr) - ((char*)bptr->base_ptr);
bptr->base_ptr = newbaseptr;
bptr->data_ptr = ((char*)bptr->data_ptr) + mdiff;
bptr->from_ptr = ((char*)bptr->from_ptr) + mdiff;
/* now update all pointers & counters */
bptr->size = newsize;
bptr->space += sdiff;
bptr->pages = pages;
return (ORTE_SUCCESS);
}
int orte_dps_dump_buffer_simple (orte_buffer_t *buffer, int outid)
{
void *src;
size_t mem_left;
char* dptr;
char* sptr;
src = buffer->from_ptr;
mem_left = buffer->toend;
dptr = (char*) buffer->data_ptr;
sptr = (char*) buffer->base_ptr;
/* output buffer's vitals */
ompi_output(outid, "Buffer vitals:\n\tbase_ptr: %p\tdata_ptr %p\tfrom_ptr %p\n",
buffer->base_ptr, buffer->data_ptr, buffer->from_ptr);
ompi_output(outid, "\tpages %d\tsize %d\tlen %d\tspace %d\ttoend %d\n\n",
buffer->pages, buffer->size, buffer->len,
buffer->space, buffer->toend);
if ((size_t)buffer->len != (size_t)(dptr-sptr)) {
ompi_output(outid, "data_ptr - base_ptr = %ld length %ld diff %ld\n\n",
(dptr-sptr), buffer->len, buffer->len - (dptr-sptr));
return (ORTE_ERROR);
}
return (ORTE_SUCCESS);
}
int orte_dps_dump_buffer(orte_buffer_t *buffer, int outid)
{
void *src;
uint32_t *s32, *d32;
char *sstr;
uint8_t *sptr;
size_t num, nbytes, mem_left, i, len;
orte_data_type_t type;
src = buffer->from_ptr;
mem_left = buffer->toend;
/* output buffer's vitals */
ompi_output(outid, "Buffer vitals:\n\tbase_ptr: %p\tdata_ptr %p\tfrom_ptr %p\n",
buffer->base_ptr, buffer->data_ptr, buffer->from_ptr);
ompi_output(outid, "\tpages %d\tsize %d\tlen %d\tspace %d\ttoend %d\n\n",
buffer->pages, buffer->size, buffer->len,
buffer->space, buffer->toend);
if (buffer->len != ((char*)buffer->data_ptr - (char*)buffer->base_ptr)) {
ompi_output(outid, "data_ptr - base_ptr = %ld length %ld diff %ld\n\n",
((char*)buffer->data_ptr - (char*)buffer->base_ptr), buffer->len,
buffer->len - ((char*)buffer->data_ptr - (char*)buffer->base_ptr));
}
while (0 < mem_left) {
/* got enough for type? */
if (sizeof(uint32_t) > mem_left) {
ompi_output(outid, "Not enough memory for type");
return ORTE_ERR_UNPACK_FAILURE;
}
s32 = (uint32_t *) src;
type = (orte_data_type_t)ntohl(*s32);
s32++;
src = (void *)s32;
mem_left -= sizeof(uint32_t);
/* got enough left for num_vals? */
if (sizeof(uint32_t) > mem_left) { /* not enough memory */
ompi_output(outid, "Not enough memory for number of values");
return ORTE_ERR_UNPACK_FAILURE;
}
/* unpack the number of values */
s32 = (uint32_t *) src;
num = (size_t)ntohl(*s32);
s32++;
src = (void *)s32;
mem_left -= sizeof(uint32_t);
ompi_output(outid, "Item: type %d number %d", (int)type, (int)num);
switch(type) {
case ORTE_BYTE:
case ORTE_INT8:
case ORTE_UINT8:
mem_left -= num*sizeof(uint8_t);
src = ((char*) src) + num * sizeof(uint8_t);
break;
case ORTE_INT16:
case ORTE_UINT16:
mem_left -= num * sizeof(uint16_t);
src = ((char*) src) + num * sizeof(uint16_t);
break;
case ORTE_INT32:
case ORTE_UINT32:
mem_left -= num * sizeof(uint32_t);
src = ((char*) src) + num * sizeof(uint32_t);
break;
case ORTE_INT64:
case ORTE_UINT64:
case ORTE_FLOAT:
case ORTE_FLOAT4:
case ORTE_FLOAT8:
case ORTE_FLOAT12:
case ORTE_FLOAT16:
case ORTE_DOUBLE:
case ORTE_LONG_DOUBLE:
ompi_output(outid, "Attempt to unpack unimplemented type");
return ORTE_ERR_PACK_FAILURE;
break;
case ORTE_BOOL:
mem_left -= num * sizeof(uint8_t);
src = ((char*) src) + num * sizeof(uint8_t);
break;
case ORTE_NAME:
mem_left -= num * sizeof(orte_process_name_t);
src = ((char*) src) + num * sizeof(orte_process_name_t);
break;
case ORTE_STRING:
sstr = (char *) src;
for(i=0; i<num; i++) {
if(mem_left < sizeof(uint32_t)) {
ompi_output(outid, "Attempt to read past end of buffer");
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
d32 = (uint32_t*)sstr;
len = ntohl(*d32);
d32++;
sstr= (char*)d32;
mem_left -= sizeof(uint32_t);
if(mem_left < len) {
ompi_output(outid, "Attempt to read past end of buffer");
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
src = sstr = (char*)(sstr + len);
mem_left -= len;
}
break;
case ORTE_BYTE_OBJECT:
for(i=0; i<num; i++) {
if(mem_left < sizeof(uint32_t)) {
ompi_output(outid, "Attempt to read past end of buffer");
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
d32 = (uint32_t*)src;
nbytes = (size_t)ntohl(*d32);
d32++;
sptr = (void*)d32;
mem_left -= sizeof(uint32_t);
if(mem_left < nbytes) {
ompi_output(outid, "Attempt to read past end of buffer");
return ORTE_UNPACK_READ_PAST_END_OF_BUFFER;
}
src = sptr = (void*)((uint8_t*)sptr + nbytes);
mem_left -= nbytes;
}
break;
case ORTE_NULL:
break;
default:
ompi_output(outid, "Attempt to unpack unknown type");
return ORTE_ERROR;
}
/* output buffer's vitals */
ompi_output(outid, "Buffer vitals:\n\tbase_ptr: %p\tdata_ptr %p\tfrom_ptr %p\n",
buffer->base_ptr, buffer->data_ptr, buffer->from_ptr);
ompi_output(outid, "\tpages %d\tsize %d\tlen %d\tspace %d\ttoend %d\n\n",
buffer->pages, buffer->size, buffer->len,
buffer->space, buffer->toend);
if (buffer->len != ((char*)buffer->data_ptr - (char*)buffer->base_ptr)) {
ompi_output(outid, "data_ptr - base_ptr = %ld length %ld diff %ld\n\n",
((char*)buffer->data_ptr - (char*)buffer->base_ptr), buffer->len,
buffer->len - ((char*)buffer->data_ptr - (char*)buffer->base_ptr));
}
}
return ORTE_SUCCESS;
}

Просмотреть файл

@ -1,371 +0,0 @@
/* -*- 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
*
* Resource Discovery & Allocation Subsystem (RDAS)
*
* The RDAS is responsible for discovering the resources available to the universe, and
* for allocating them to the requesting job.
*
*/
#ifndef ORTE_DPS_H_
#define ORTE_DPS_H_
#include "orte_config.h"
#include "include/orte_types.h"
#include "include/orte_constants.h"
#include "dps_types.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/*
* DPS initialization function
* In dynamic libraries, declared objects and functions don't get loaded
* until called. We need to ensure that the orte_dps function structure
* gets loaded, so we provide an "open" call that is executed as part of
* the program startup. It simply checks for debug parameters - good enough
* to ensure that the DPS gets loaded!
*/
OMPI_DECLSPEC int orte_dps_open(void);
/*
* DPS finalize function
*/
OMPI_DECLSPEC int orte_dps_close(void);
/*
* DPS interface functions
*/
/*
* Pack one or more values into a buffer
* The pack function packs one or more values of a specified type into the specified buffer.
* The buffer must have already been initialized via an OBJ_NEW call -
* otherwise, the pack_value function will return an error. Providing an
* unsupported type flag will likewise be reported as an error.
*
* Note that any data to be packed that is not hard type cast (i.e., not type cast
* to a specific size) may lose precision when unpacked by a non-homogeneous recipient.
* The DPS will do its best to
* deal with heterogeneity issues between the packer and unpacker in such cases. Sending
* a number larger than can be handled by the recipient will return an error code (generated
* by the DPS upon unpacking) via the RML upon transmission - the DPS cannot detect
* such errors during packing.
*
* @param *buffer A pointer to the buffer into which the value is to be packed.
* @param *src A void* pointer to the data that is to be packed. Note that strings are
* to be passed as (char **) - i.e., the caller must pass the address of the pointer
* to the string as the void*. This allows the DPS to use a single interface function,
* but still allow the caller to pass multiple strings in a single call.
* @param num A size_t value indicating the number of values that are to be
* packed, beginning at the location pointed to by src. A string value is counted as a
* single value regardless of length. The values must be contiguous in memory. Arrays of
* pointers (e.g., string arrays) should be contiguous, although (obviously) the data
* pointed to need not be contiguous across array entries.
* @param type The type of the data to be packed - must be one of the DPS defined
* data types.
*
* @retval ORTE_SUCCESS The data was packed as requested.
* @retval ORTE_ERROR(s) An appropriate ORTE error code indicating the problem
* encountered. This error code should be handled appropriately.
*
* @code
* orte_buffer_t *buffer;
* int32_t src;
*
* status_code = orte_dps.pack(buffer, &src, 1, ORTE_INT32);
* @endcode
*/
typedef int (*orte_dps_pack_fn_t)(orte_buffer_t *buffer, void *src,
size_t num_values,
orte_data_type_t type);
/* Unpack one or more values from a buffer
* The unpack function unpacks one or more values of a specified type from the
* specified buffer.
* The buffer must have already been initialized via an OBJ_NEW call -
* otherwise, the unpack_value function will return an error. Providing an
* unsupported type flag will likewise be reported as an error, as will specifying a
* data type that DOES NOT match the type of the next item in the buffer. An attempt
* to read beyond the end of the stored data held in the buffer will also return
* an error.
*
* Unpacking values is a "destructive" process - i.e., the values are removed from
* the buffer, thus reducing the buffer size. It is therefore not possible for the
* caller to re-unpack a value from the same buffer.
*
* Warning: The caller is responsible for providing adequate memory storage for
* the requested data. The DPS peek_next_item function is provided to assist in
* meeting this requirement. The user can provide a max_num_values argument to ensure
* that memory overruns are prevented. If more values are present in the buffer, the
* unpack function will unpack as much as it can - and then return an error
* ORTE_UNPACK_READ_PAST_END_OF_BUFFER.
*
* Note that any data that was not hard type cast (i.e., not type cast
* to a specific size) when packed may lose precision when unpacked by a non-homogeneous recipient.
* The DPS will do its best to
* deal with heterogeneity issues between the packer and unpacker in such cases. Sending
* a number larger than can be handled by the recipient will return an error code (generated
* by the DPS upon unpacking) via the RML upon transmission - the DPS cannot detect
* such errors during packing.
*
* @param *buffer A pointer to the buffer from which the value will be extracted.
* @param *dest A void* pointer to the memory location into which the data is to be
* stored. Note that these values will be stored contiguously in memory. For strings,
* this pointer must be to (char **) to provide a means of supporting multiple string
* operations. The DPS unpack function will allocate memory for each string in the array -
* the caller must only provide adequate memory for the array of pointers.
* @param *num A pointer to a size_t value indicating the maximum number of values that are to be
* unpacked, beginning at the location pointed to by src. This is provided to help
* protect the caller from memory overrun - providing a value of "0" tells the DPS
* to unpack ALL of the values stored in this item. This should be used with caution
* as the caller must then be absolutely certain that adequate memory has been allocated
* for this operation. Note that a string value is counted as a single value regardless
* of length.
*
* @note The unpack function will return the actual number of values unpacked in
* this location.
*
* @param type The type of the data to be unpacked - must be one of the DPS defined
* data types.
*
* @retval *num The number of values actually unpacked. In most cases,
* this should match the maximum number provided in the parameters - but in no case
* will it exceed that parameter.
*
* @retval ORTE_SUCCESS The next item in the buffer was successfully unpacked.
*
* @retval ORTE_ERROR(s) The unpack function returns an error code under one of several
* conditions: (a) the number of values in the item exceeds the max num provided by the
* caller; (b) the type of the next item in the buffer does not match the type specified
* by the caller; or (c) the unpack failed due to either an error in the buffer or
* an attempt to read past the end of the buffer.
*
* @code
* orte_buffer_t *buffer;
* int32_t dest;
* char **string_array;
* size_t num_values;
*
* num_values = 1;
* status_code = orte_dps.unpack(buffer, (void*)&dest, &num_values, ORTE_INT32);
*
* num_values = 5;
* string_array = malloc(num_values*sizeof(char *));
* status_code = orte_dps.unpack(buffer, (void*)(string_array), &num_values, ORTE_STRING);
*
* @endcode
*
*/
typedef int (*orte_dps_unpack_fn_t)(orte_buffer_t *buffer, void *dest,
size_t *max_num_values,
orte_data_type_t type);
/*
* Pack a value into a non-buffer destination
* This function will translate host-ordered values into their network byte-ordered
* equivalents. The results are placed in the dest location and NOT into a buffer.
* The function is intended for use in areas where a buffer is not required, but data
* storage must still be prepared for heterogeneous operations (i.e., it may be sent
* at some later time). Primary use is in the packing of data placed on the registry.
*
* @param *dest (IN) A pointer to the destination. Must have memory backing it. Strings
* are handled by passing a char** pointer - the pack function will allocate memory
* in this case for each string. However, there must be adequate storage for the number
* of string pointers that will be required.
* @param *src (IN) A pointer to the src
* @param num_values (IN) The number of values to be packed - must be contiguous
* beginning at src. For strings, src is assumed to point to an array of character
* pointers (char**) - this number, therefore, would be the number of null-terminated
* strings (and not the total number of characters).
* @param type (IN) The data type to be converted
* @param *num_bytes (OUT) A pointer to a variable where the function can return
* the number of bytes moved from src to dest. Used by some functions to update
* the dest location.
*
* @retval ORTE_SUCCESS The value was successfully packed
* @retval ORTE_ERROR(s) An appropriate error code.
*/
typedef int (*orte_dps_pack_nobuffer_fn_t)(void *dest, void *src, size_t num_values,
orte_data_type_t type, size_t *num_bytes);
/*
* Unpack a value from a non-buffer location
* Converts a network byte-ordered value into its host-ordered equivalent.
*
* @param *dest (IN) A pointer to the destination. Must have memory backing it. Strings
* are handled by passing a char** pointer - the unpack function will allocate memory
* in this case.
* @param *src (IN) A pointer to the src
* @param num_values (IN) The number of values to be unpacked - must be contiguous
* beginning at src. For strings, src is assumed to point to an array of character
* pointers (char**) - this number, therefore, would be the number of null-terminated
* strings (and not the total number of characters).
* @param type (IN) The data type to be converted
* @param *max_bytes (IN/OUT) The max number of bytes in the src - will be returned
* as an updated value that reflects the number of bytes actually removed.
* @param *num_bytes (OUT) A pointer to a variable where the function can return
* the number of bytes moved from src to dest. Used by some functions to update
* the dest location.
*
* @retval ORTE_SUCCESS The value was successfully packed
* @retval ORTE_ERROR(s) An appropriate error code.
*/
typedef int (*orte_dps_unpack_nobuffer_fn_t)(void *dest, void *src, size_t num_values,
orte_data_type_t type,
size_t *max_bytes, size_t *num_bytes);
/*
* Get the type and number of values of the next item in the buffer
* The peek function looks at the next item in the buffer and returns both its
* type and the number of values in the item. This is a non-destructive function
* call that does not disturb the buffer, so it can be called multiple times if desired.
*
* @param buffer A pointer to the buffer in question.
* @param type A pointer to an orte_data_type_t variable where the type of the
* next item in the buffer is to be stored. Caller must have memory backing this
* location.
* @param number A pointer to a size_t variable where the number of data values
* in the next item is to be stored. Caller must have memory backing this location.
*
* @retval ORTE_SUCCESS Requested info was successfully returned.
* @retval ORTE_ERROR(s) An appropriate error code indicating the problem will be
* returned. This should be handled appropriately by the caller.
*
* For string types, the number of values corresponds to the length of the string.
*/
typedef int (*orte_dps_peek_next_item_fn_t)(orte_buffer_t *buffer,
orte_data_type_t *type,
size_t *number);
/*
* Unload the data payload from a buffer
* The unload function provides the caller with a pointer to the data payload within
* the buffer and the size of that payload. This allows the user to directly access
* the payload - typically used in the RML to unload the payload from the buffer
* for transmission.
*
* @note This is a destructive operation. While the payload is undisturbed, the function
* will clear the buffer's pointers to the payload. Thus, the buffer and the payload
* are completely separated, leaving the caller free to OBJ_RELEASE the buffer.
*
* @param buffer A pointer to the buffer whose payload is to be unloaded.
* @param payload The address to a void* pointer that is to be loaded with the address
* of the data payload in the buffer.
* @param size The size (in bytes) of the data payload in the buffer.
*
* @retval ORTE_SUCCESS The request was succesfully completed.
* @retval ORTE_ERROR(s) An appropriate error code indicating the problem will be
* returned. This should be handled appropriately by the caller.
*
* @code
* orte_buffer_t *buffer;
* uint8_t *bytes;
* size_t size;
*
* status_code = orte_dps.unload(buffer, (void**)(&bytes), &size);
* OBJ_RELEASE(buffer);
* @endcode
*/
typedef int (*orte_dps_unload_fn_t)(orte_buffer_t *buffer,
void **payload,
size_t *size);
/*
* Load a data payload into a buffer
* The load function allows the caller to replace the payload in a buffer with one
* provided by the caller. If a payload already exists in the buffer, the function will
* "free" the existing data to release it, and then replace the data payload with the
* one provided by the caller.
*
* @note The buffer must be allocated in advance via the OBJ_NEW function call - failing
* to do so will cause the load function to return an error code.
*
* @note The caller is responsible for pre-packing the provided payload - the load
* function cannot convert to network byte order any data contained in the provided
* payload.
*
* @param buffer A pointer to the buffer into which lthe payload is to be loaded.
* @param payload A void* pointer to the payload to be loaded into the buffer.
* @param size The size (in bytes) of the provided payload.
*
* @retval ORTE_SUCCESS The request was successfully completed
* @retval ORTE_ERROR(s) An appropriate error code indicating the problem will be
* returned. This should be handled appropriately by the caller.
*
* @code
* orte_buffer_t *buffer;
* uint8_t bytes;
* size_t size;
*
* buffer = OBJ_NEW(orte_buffer_t);
* status_code = orte_dps.load(buffer, (void*)(&bytes), size);
* @endcode
*/
typedef int (*orte_dps_load_fn_t)(orte_buffer_t *buffer,
void *payload,
size_t size);
/*
* Output the buffer's internals to the screen
* For debugging purposes, it can be useful to see the types of items
* stored in the buffer. This function outputs the type and number of
* elements in each item to the specified output id.
*
* @param *buffer A pointer to the buffer
* @param id The output id to use
*
* @retval ORTE_SUCCESS Operation successfully completed
* @retval ORTE_ERROR(s) Error code indicating problem with buffer
*/
typedef int (*orte_dps_dump_fn_t)(orte_buffer_t *buffer, int outid);
/**
* Base structure for the DPS
*
* Base module structure for the DPS - presents the required function
* pointers to the calling interface.
*/
struct orte_dps_t {
orte_dps_pack_fn_t pack;
orte_dps_unpack_fn_t unpack;
orte_dps_pack_nobuffer_fn_t pack_nobuffer;
orte_dps_unpack_nobuffer_fn_t unpack_nobuffer;
orte_dps_peek_next_item_fn_t peek;
orte_dps_unload_fn_t unload;
orte_dps_load_fn_t load;
orte_dps_dump_fn_t dump;
};
typedef struct orte_dps_t orte_dps_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
OMPI_DECLSPEC extern orte_dps_t orte_dps; /* holds dps function pointers */
#endif /* ORTE_DPS_H */

Просмотреть файл

@ -1,66 +0,0 @@
/* -*- 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
*
* Resource Discovery & Allocation Subsystem (RDAS)
*
* The RDAS is responsible for discovering the resources available to the universe, and
* for allocating them to the requesting job.
*
*/
#ifndef ORTE_DPS_TYPES_H_
#define ORTE_DPS_TYPES_H_
#include "orte_config.h"
#include "class/ompi_object.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
typedef struct orte_buffer_t {
/* first member must be the objects parent */
ompi_object_t parent;
void* base_ptr; /* start of my memory */
void* data_ptr; /* location of where next data will go */
void* from_ptr; /* location of where to get the next data from */
/* counters */
int32_t pages; /* number of orte_dps_size pages of memory used (pages) */
int32_t size; /* total size of this buffer (bytes) */
int32_t len; /* total amount already packed (bytes) */
int32_t space; /* how much space we have left (bytes) */
/* yep, size=len+space */
int32_t toend; /* how many bytes till the end when unpacking :) */
/* yep, toend is the opposite of len */
} orte_buffer_t;
/* formalise the declaration */
OMPI_DECLSPEC OBJ_CLASS_DECLARATION (orte_buffer_t);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* ORTE_DPS_TYPES_H */

Просмотреть файл

@ -21,7 +21,7 @@
#endif
#include <stdlib.h>
#include "include/orte_constants.h"
#include "include/orte_schema.h"
#include "mca/schema/schema.h"
#include "runtime/runtime.h"
#include "runtime/orte_wait.h"

Просмотреть файл

@ -28,7 +28,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "include/orte_schema.h"
#include "mca/schema/schema.h"
#include "mca/mca.h"

Просмотреть файл

@ -66,7 +66,7 @@
#include "threads/condition.h"
#include "class/ompi_list.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "mca/mca.h"
#include "mca/base/base.h"
@ -114,9 +114,9 @@ extern "C" {
char **index);
OMPI_DECLSPEC int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
orte_gpr_notify_action_t action, int num_subs,
orte_gpr_notify_action_t action, size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs, orte_gpr_value_t **trig);
size_t num_trigs, orte_gpr_value_t **trig);
OMPI_DECLSPEC int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret,
orte_gpr_notify_id_t *remote_idtag);
@ -125,20 +125,15 @@ extern "C" {
OMPI_DECLSPEC int orte_gpr_base_unpack_unsubscribe(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_put(orte_buffer_t *cmd,
int cnt, orte_gpr_value_t **values);
size_t cnt, orte_gpr_value_t **values);
OMPI_DECLSPEC int orte_gpr_base_unpack_put(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_get(orte_buffer_t *cmd,
orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
OMPI_DECLSPEC int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret,
int *cnt, orte_gpr_value_t ***values);
size_t *cnt, orte_gpr_value_t ***values);
OMPI_DECLSPEC void orte_gpr_base_decode_startup_msg(int status,
orte_process_name_t *peer,
orte_buffer_t* msg,
orte_rml_tag_t tag, void *cbdata);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_all(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd);
@ -151,6 +146,8 @@ extern "C" {
orte_gpr_notify_message_t *msg);
OMPI_DECLSPEC int orte_gpr_base_dump_notify_data(orte_buffer_t *buffer,
orte_gpr_notify_data_t *data);
OMPI_DECLSPEC int orte_gpr_base_dump_value(orte_buffer_t *buffer,
orte_gpr_value_t *value);
OMPI_DECLSPEC int orte_gpr_base_pack_cleanup_job(orte_buffer_t *buffer,
orte_jobid_t jobid);

Просмотреть файл

Просмотреть файл

@ -20,6 +20,8 @@
#include "util/output.h"
#include "dps/dps.h"
#include "mca/gpr/base/base.h"
@ -92,7 +94,7 @@ static void orte_gpr_value_construct(orte_gpr_value_t* reg_val)
static void orte_gpr_value_destructor(orte_gpr_value_t* reg_val)
{
char **tokens;
int32_t i;
size_t i;
if (NULL != reg_val->segment) free(reg_val->segment);
@ -136,7 +138,7 @@ static void orte_gpr_notify_data_construct(orte_gpr_notify_data_t* ptr)
/* destructor - used to free any resources held by instance */
static void orte_gpr_notify_data_destructor(orte_gpr_notify_data_t* ptr)
{
int32_t i;
size_t i;
if (NULL != ptr->segment) free(ptr->segment);
@ -175,7 +177,7 @@ static void orte_gpr_subscription_construct(orte_gpr_subscription_t* sub)
static void orte_gpr_subscription_destructor(orte_gpr_subscription_t* sub)
{
char **tokens;
int32_t i;
size_t i;
if (NULL != sub->segment) free(sub->segment);
@ -219,7 +221,7 @@ static void orte_gpr_notify_message_construct(orte_gpr_notify_message_t* msg)
/* destructor - used to free any resources held by instance */
static void orte_gpr_notify_message_destructor(orte_gpr_notify_message_t* msg)
{
int i;
size_t i;
if (0 < msg->cnt && NULL != msg->data) {
for (i=0; i < msg->cnt; i++) {
@ -238,33 +240,6 @@ OBJ_CLASS_INSTANCE(
orte_gpr_notify_message_destructor); /* destructor */
/** TEST RESULTS */
/* constructor - used to initialize state of test results instance */
static void orte_gpr_internal_test_results_construct(orte_gpr_internal_test_results_t* results)
{
results->test = NULL;
results->message = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_internal_test_results_destructor(orte_gpr_internal_test_results_t* results)
{
if (NULL != results->test) {
free(results->test);
}
if (NULL != results->message) {
free(results->message);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_internal_test_results_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_internal_test_results_construct, /* constructor */
orte_gpr_internal_test_results_destructor); /* destructor */
/*
* Global variables
*/
@ -295,6 +270,8 @@ int orte_gpr_base_open(void)
orte_gpr_base_output = -1;
}
/* register data types */
/* Open up all available components */
if (OMPI_SUCCESS !=

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -25,7 +25,7 @@
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -21,7 +21,7 @@
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
@ -80,7 +80,7 @@ int orte_gpr_base_pack_delete_entries(orte_buffer_t *cmd,
}
/* pack number of tokens */
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, (int*)&n, 1, ORTE_INT))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_SIZE))) {
return rc;
}
@ -102,7 +102,7 @@ int orte_gpr_base_pack_delete_entries(orte_buffer_t *cmd,
}
/* pack number of keys */
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, (int*)&n, 1, ORTE_INT))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_SIZE))) {
return rc;
}

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -27,14 +27,14 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
int orte_gpr_base_pack_put(orte_buffer_t *cmd,
int cnt, orte_gpr_value_t **values)
size_t cnt, orte_gpr_value_t **values)
{
orte_gpr_cmd_flag_t command;
int rc;
@ -45,7 +45,7 @@ int orte_gpr_base_pack_put(orte_buffer_t *cmd,
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, values, (size_t)cnt, ORTE_GPR_VALUE))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, values, cnt, ORTE_GPR_VALUE))) {
return rc;
}
@ -60,7 +60,7 @@ int orte_gpr_base_pack_get(orte_buffer_t *cmd,
orte_gpr_cmd_flag_t command;
char **ptr;
int rc;
int n;
size_t n;
command = ORTE_GPR_GET_CMD;
@ -86,12 +86,12 @@ int orte_gpr_base_pack_get(orte_buffer_t *cmd,
}
/* pack number of tokens */
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_INT))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_SIZE))) {
return rc;
}
if (n > 0) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, tokens, (size_t)n, ORTE_STRING))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, tokens, n, ORTE_STRING))) {
return rc;
}
}
@ -106,12 +106,12 @@ int orte_gpr_base_pack_get(orte_buffer_t *cmd,
}
/* pack number of keys */
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_INT))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &n, 1, ORTE_SIZE))) {
return rc;
}
if (n > 0) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, keys, (size_t)n, ORTE_STRING))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, keys, n, ORTE_STRING))) {
return rc;
}
}

Просмотреть файл

@ -27,15 +27,15 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
orte_gpr_notify_action_t action, int num_subs,
orte_gpr_notify_action_t action, size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs)
{
orte_gpr_cmd_flag_t command;

Просмотреть файл

@ -1,84 +0,0 @@
/* -*- 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
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/rml/rml_types.h"
#include "util/output.h"
#include "util/proc_info.h"
#include "mca/gpr/base/base.h"
void
orte_gpr_base_decode_startup_msg(int status, orte_process_name_t *peer,
orte_buffer_t* msg,
orte_rml_tag_t tag, void *cbdata)
{
#if 0
char *segment;
orte_gpr_notify_message_t *notify_msg;
orte_gpr_value_t *data_value;
int32_t num_objects, i;
size_t buf_size;
while (0 < ompi_unpack_string(msg, &segment)) {
if (ompi_rte_globals.debug_flag) {
ompi_output(0, "[%d,%d,%d] decoding msg for segment %s",
ORTE_NAME_ARGS(*ompi_rte_get_self()), segment);
}
ompi_unpack(msg, &num_objects, 1, OMPI_INT32); /* unpack #data objects */
if (ompi_rte_globals.debug_flag) {
ompi_output(0, "\twith %d objects", num_objects);
}
if (0 < num_objects) {
notify_msg = OBJ_NEW(orte_gpr_notify_message_t);
notify_msg->segment = strdup(segment);
for (i=0; i < num_objects; i++) {
data_value = OBJ_NEW(orte_gpr_value_t);
ompi_unpack(msg, &data_obj_size, 1, MCA_GPR_OOB_PACK_OBJECT_SIZE);
data_object = (orte_gpr_object_t)malloc(data_obj_size);
ompi_unpack(msg, data_object, data_obj_size, OMPI_BYTE);
data_value->object = data_object;
data_value->object_size = data_obj_size;
ompi_list_append(&notify_msg->data, &data_value->item);
}
if (ompi_rte_globals.debug_flag) {
ompi_output(0, "[%d,%d,%d] delivering msg for segment %s with %d data objects",
ORTE_NAME_ARGS(*ompi_rte_get_self()), segment, (int)num_objects);
}
orte_gpr.deliver_notify_msg(OMPI_REGISTRY_NOTIFY_ON_STARTUP, notify_msg);
}
free(segment);
}
#endif
return;
}

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "mca/gpr/base/base.h"
@ -40,7 +40,7 @@ int orte_gpr_base_dump_notify_msg(orte_buffer_t *buffer,
orte_gpr_notify_message_t *msg)
{
char *tmp_out;
int i;
size_t i;
asprintf(&tmp_out, "\nDUMP OF NOTIFY MESSAGE STRUCTURE");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
@ -88,9 +88,8 @@ static void orte_gpr_base_dump_data(orte_buffer_t *buffer,
orte_gpr_notify_data_t *data)
{
char *tmp_out;
orte_gpr_addr_mode_t addr;
orte_gpr_value_t **values;
int i, j;
size_t i;
asprintf(&tmp_out, "%d Values from segment %s", data->cnt, data->segment);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
@ -105,86 +104,94 @@ static void orte_gpr_base_dump_data(orte_buffer_t *buffer,
asprintf(&tmp_out, "\tError encountered: NULL value pointer");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
} else {
addr = values[i]->addr_mode;
if (NULL == values[i]->tokens) {
asprintf(&tmp_out, "\tNULL tokens (wildcard)");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
} else {
asprintf(&tmp_out, "\t%d Tokens returned", values[i]->num_tokens);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
for (j=0; j < values[i]->num_tokens; j++) {
asprintf(&tmp_out, "\tToken %d: %s", j, values[i]->tokens[j]);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
}
asprintf(&tmp_out, "\tToken addressing mode:");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_TOKENS_AND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_AND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_OR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_OR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XAND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_XAND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XOR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_XOR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_NOT & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_NOT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
asprintf(&tmp_out, "\n\tKey addressing mode:");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (0x0000 == addr) {
asprintf(&tmp_out, "\t\tNONE");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_AND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_AND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_OR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_OR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XAND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_XAND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XOR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_XOR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_NOT & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_NOT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (NULL == values[i]->keyvals) {
asprintf(&tmp_out, "\tNo keyvals returned");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
} else {
asprintf(&tmp_out, "\t%d Keyvals returned", values[i]->cnt);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
for (j=0; j < values[i]->cnt; j++) {
asprintf(&tmp_out, "\t\tData for keyval %d: Key: %s", j,
(values[i]->keyvals[j])->key);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_keyval_value(buffer, values[i]->keyvals[j]);
}
}
orte_gpr_base_dump_value(buffer, values[i]);
}
}
}
}
int orte_gpr_base_dump_value(orte_buffer_t *buffer, orte_gpr_value_t *value)
{
char *tmp_out;
orte_gpr_addr_mode_t addr;
size_t j;
asprintf(&tmp_out, "\tValue from segment %s with %d keyvals",
value->segment, value->cnt);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
addr = value->addr_mode;
if (NULL == value->tokens) {
asprintf(&tmp_out, "\tNULL tokens (wildcard)");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
} else {
asprintf(&tmp_out, "\t%d Tokens returned", value->num_tokens);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
for (j=0; j < value->num_tokens; j++) {
asprintf(&tmp_out, "\tToken %d: %s", j, value->tokens[j]);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
}
asprintf(&tmp_out, "\tToken addressing mode:");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_TOKENS_AND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_AND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_OR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_OR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XAND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_XAND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XOR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_XOR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_NOT & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_TOKENS_NOT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
asprintf(&tmp_out, "\n\tKey addressing mode:");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (0x0000 == addr) {
asprintf(&tmp_out, "\t\tNONE");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_AND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_AND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_OR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_OR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XAND & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_XAND");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XOR & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_XOR");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_NOT & addr) {
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_NOT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
for (j=0; j < value->cnt; j++) {
asprintf(&tmp_out, "\t\tData for keyval %d: Key: %s", j,
(value->keyvals[j])->key);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_keyval_value(buffer, value->keyvals[j]);
}
return ORTE_SUCCESS;
}
void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *iptr)
{
@ -208,7 +215,7 @@ void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *i
break;
case ORTE_SIZE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_SIZE: no value field");
asprintf(&tmp_out, "\t\t\tData type: ORTE_SIZE:\tValue: %d", iptr->value.size);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
@ -232,7 +239,7 @@ void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *i
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
asprintf(&tmp_out, "\t\t\tData type: ORTE_UINT64\tValue: %d", (int)iptr->value.ui64);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
@ -254,7 +261,7 @@ void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *i
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_INT64:
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT64\tValue: %d", (int)iptr->value.i64);
orte_gpr_base_dump_load_string(buffer, &tmp_out);

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
@ -77,7 +77,7 @@ int orte_gpr_base_unpack_decrement_value(orte_buffer_t *cmd, int *ret)
}
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, ret, &n, ORTE_INT32))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, ret, &n, ORTE_INT))) {
ORTE_ERROR_LOG(rc);
return rc;
}

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -21,7 +21,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
@ -60,11 +60,13 @@ int orte_gpr_base_unpack_put(orte_buffer_t *buffer, int *ret)
}
int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret, int *cnt, orte_gpr_value_t ***values)
int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret, size_t *cnt, orte_gpr_value_t ***values)
{
orte_gpr_cmd_flag_t command;
int rc, num;
size_t n;
int rc;
size_t n, num;
ompi_output(0, "UNPACK GET: NUMBER OF BYTES PACKED IN BUFFER %d", buffer->len);
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) {
@ -78,11 +80,13 @@ int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret, int *cnt, orte_gpr
}
/* find out how many values came back */
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &num, &n, ORTE_INT))) {
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &num, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
ompi_output(0, "UNPACK GET: NUMBER OF VALUES %d", num);
/* if there were some, then get them */
if (0 < num) {
*values = (orte_gpr_value_t**)malloc(num*sizeof(orte_gpr_value_t*));
@ -91,19 +95,25 @@ int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret, int *cnt, orte_gpr
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, *values, (size_t*)&num, ORTE_GPR_VALUE))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, *values, &num, ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
free(*values);
return rc;
}
for (n=0; n < num; n++) {
orte_gpr.dump_value((*values)[n], 0);
}
}
/* unpack the response code */
ompi_output(0, "UNPACKING GET RESPONSE CODE");
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, ret, &n, ORTE_INT))) {
ORTE_ERROR_LOG(rc);
return rc;
}
ompi_output(0, "COMPLETED UNPACKING GET RESPONSE CODE");
if (ORTE_SUCCESS != *ret) {
ORTE_ERROR_LOG(*ret);
return rc;

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"

Просмотреть файл

@ -35,7 +35,6 @@
#include <sys/types.h>
#include "include/orte_types.h"
#include "include/orte_constants.h"
#include "class/ompi_list.h"
@ -176,7 +175,7 @@ typedef int (*orte_gpr_base_module_cleanup_proc_fn_t)(orte_process_name_t *proc)
* status_code = orte_gpr.preallocate_segment("MY_SEGMENT", num_slots);
* @endcode
*/
typedef int (*orte_gpr_base_module_preallocate_segment_fn_t)(char *name, int num_slots);
typedef int (*orte_gpr_base_module_preallocate_segment_fn_t)(char *name, size_t num_slots);
/*
* Delete a segment from the registry (BLOCKING)
@ -245,13 +244,13 @@ typedef int (*orte_gpr_base_module_delete_segment_nb_fn_t)(char *segment,
* status_code = orte_gpr.put(1, &value);
* @endcode
*/
typedef int (*orte_gpr_base_module_put_fn_t)(int cnt, orte_gpr_value_t **values);
typedef int (*orte_gpr_base_module_put_fn_t)(size_t cnt, orte_gpr_value_t **values);
/*
* Put data on the registry (NON-BLOCKING)
* A non-blocking version of put.
*/
typedef int (*orte_gpr_base_module_put_nb_fn_t)(int cnt, orte_gpr_value_t **values,
typedef int (*orte_gpr_base_module_put_nb_fn_t)(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
@ -296,7 +295,7 @@ typedef int (*orte_gpr_base_module_put_nb_fn_t)(int cnt, orte_gpr_value_t **valu
*/
typedef int (*orte_gpr_base_module_get_fn_t)(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
int *cnt, orte_gpr_value_t ***values);
size_t *cnt, orte_gpr_value_t ***values);
/*
* Get data from the registry (NON-BLOCKING)
@ -446,9 +445,9 @@ typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
*/
typedef int (*orte_gpr_base_module_subscribe_fn_t)(
orte_gpr_notify_action_t actions,
int num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trig_value,
orte_gpr_notify_id_t *sub_number);
@ -496,36 +495,7 @@ typedef int (*orte_gpr_base_module_dump_notify_msg_fn_t)(orte_gpr_notify_message
typedef int (*orte_gpr_base_module_dump_notify_data_fn_t)(orte_gpr_notify_data_t *data, int output_id);
/* Deliver a notify message.
* The registry generates notify messages whenever a subscription is fired. Normally,
* this happens completely "under the covers" - i.e., the notification process is transparent
* to the rest of the system, with the message simply delivered to the specified callback function.
* However, there are two circumstances when the system needs to explicitly deliver a notify
* message - namely, during startup and shutdown. In these two cases, a special message is
* "xcast" to all processes, with each process receiving the identical message. In order to
* ensure that the correct data gets to each subsystem, the message must be disassembled and
* the appropriate callback function called.
*
* This, unfortunately, means that the decoder must explicitly call the message notification
* subsystem in order to find the callback function. Alternatively, the entire startup/shutdown
* logic could be buried in the registry, but this violates the design philosophy of the registry
* acting solely as a publish/subscribe-based cache memory - it should not contain logic pertinent
* to any usage of that memory.
*
* This function provides the necessary "hook" for an external program to request delivery of
* a message via the publish/subscribe's notify mechanism.
*
* @param message The message to be delivered.
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
* @code
* status_code = orte_gpr.deliver_notify_msg(message);
* @endcode
*
*/
typedef int (*orte_gpr_base_module_deliver_notify_msg_fn_t)(orte_gpr_notify_message_t *message);
typedef int (*orte_gpr_base_module_dump_value_fn_t)(orte_gpr_value_t *value, int output_id);
/*
* Increment value
@ -562,7 +532,6 @@ struct orte_gpr_base_module_1_0_0_t {
orte_gpr_base_module_index_nb_fn_t index_nb;
/* GENERAL OPERATIONS */
orte_gpr_base_module_preallocate_segment_fn_t preallocate_segment;
orte_gpr_base_module_deliver_notify_msg_fn_t deliver_notify_msg;
/* ARITHMETIC OPERATIONS */
orte_gpr_base_module_increment_value_fn_t increment_value;
orte_gpr_base_module_decrement_value_fn_t decrement_value;
@ -580,6 +549,7 @@ struct orte_gpr_base_module_1_0_0_t {
orte_gpr_base_module_dump_callbacks_fn_t dump_callbacks;
orte_gpr_base_module_dump_notify_msg_fn_t dump_notify_msg;
orte_gpr_base_module_dump_notify_data_fn_t dump_notify_data;
orte_gpr_base_module_dump_value_fn_t dump_value;
/* CLEANUP OPERATIONS */
orte_gpr_base_module_cleanup_job_fn_t cleanup_job;
orte_gpr_base_module_cleanup_proc_fn_t cleanup_process;

Просмотреть файл

@ -29,11 +29,11 @@
#define ORTE_GPR_TYPES_H_
#include "orte_config.h"
#include "include/orte_types.h"
#include "include/orte_schema.h"
#include "mca/schema/schema.h"
#include "class/ompi_object.h"
#include "dps/dps_types.h"
#include "mca/ns/ns_types.h"
#include "mca/rmgr/rmgr_types.h"
#include "mca/soh/soh_types.h"
/** Define the notify actions for the subscription system - can be OR'd
@ -61,8 +61,8 @@
typedef uint16_t orte_gpr_notify_action_t;
typedef int32_t orte_gpr_notify_id_t;
#define ORTE_GPR_NOTIFY_ID_MAX INT32_MAX
typedef size_t orte_gpr_notify_id_t;
#define ORTE_GPR_NOTIFY_ID_MAX SIZE_MAX
/*
* Define flag values for remote commands - normally used internally, but required
@ -121,16 +121,17 @@ typedef uint16_t orte_gpr_addr_mode_t;
*/
typedef union { /* shared storage for the value */
char *strptr;
size_t size;
uint8_t ui8;
uint16_t ui16;
uint32_t ui32;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
uint64_t ui64;
#endif
int8_t i8;
int16_t i16;
int32_t i32;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
int64_t i64;
#endif
orte_byte_object_t byteobject;
@ -172,9 +173,9 @@ typedef struct {
ompi_object_t super; /**< Makes this an object */
orte_gpr_addr_mode_t addr_mode; /**< Address mode that was used for combining keys/tokens */
char *segment; /**< Name of the segment this came from */
int32_t cnt; /**< Number of keyval objects returned */
size_t cnt; /**< Number of keyval objects returned */
orte_gpr_keyval_t **keyvals; /**< Contiguous array of keyval object pointers */
int32_t num_tokens; /**< Number of tokens from the container that held these keyvals */
size_t num_tokens; /**< Number of tokens from the container that held these keyvals */
char **tokens; /**< List of tokens that described the container */
} orte_gpr_value_t;
@ -187,10 +188,10 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_value_t);
*/
typedef struct {
ompi_object_t super; /**< Makes this an object */
int32_t cb_num; /**< Number of the subscribed data - indicates which callback to use */
size_t cb_num; /**< Number of the subscribed data - indicates which callback to use */
orte_gpr_addr_mode_t addr_mode; /**< Address mode that was used for combining keys/tokens */
char *segment; /**< Name of the segment this came from */
int32_t cnt; /**< Number of value objects returned, one per container */
size_t cnt; /**< Number of value objects returned, one per container */
orte_gpr_value_t **values; /**< Array of value objects returned */
} orte_gpr_notify_data_t;
@ -201,7 +202,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_notify_data_t);
typedef struct {
ompi_object_t super; /**< Make this an object */
orte_gpr_notify_id_t idtag; /**< Referenced notify request */
int32_t cnt; /**< number of data objects */
size_t cnt; /**< number of data objects */
orte_gpr_notify_data_t **data; /**< Contiguous array of pointers to data objects */
} orte_gpr_notify_message_t;
@ -227,9 +228,9 @@ typedef struct {
ompi_object_t super; /**< Makes this an object */
orte_gpr_addr_mode_t addr_mode; /**< Address mode for combining keys/tokens */
char *segment; /**< Name of the segment where the data is located */
int32_t num_tokens; /**< Number of tokens used to describe data */
size_t num_tokens; /**< Number of tokens used to describe data */
char **tokens; /**< List of tokens that describe the data */
int32_t num_keys; /**< Number of keys describing data */
size_t num_keys; /**< Number of keys describing data */
char **keys; /**< Contiguous array of keys */
orte_gpr_notify_cb_fn_t cbfunc; /**< Function to be called with this data */
void *user_tag; /**< User-provided tag to be used in cbfunc */
@ -237,16 +238,14 @@ typedef struct {
OBJ_CLASS_DECLARATION(orte_gpr_subscription_t);
/** Return value for test results on internal test
*/
struct orte_gpr_internal_test_results_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
char *test;
char *message;
int exit_code;
};
typedef struct orte_gpr_internal_test_results_t orte_gpr_internal_test_results_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_internal_test_results_t);
/** Type name definitions for pack/unpack functions */
#define ORTE_KEYVAL 31
#define ORTE_NOTIFY_ACTION 32
#define ORTE_GPR_CMD 33
#define ORTE_GPR_NOTIFY_ID 34
#define ORTE_GPR_VALUE 35
#define ORTE_GPR_ADDR_MODE 39
#define ORTE_GPR_SUBSCRIPTION 40
#define ORTE_GPR_NOTIFY_DATA 41
#endif /* GPR_TYPES_H */

Просмотреть файл

@ -24,7 +24,7 @@
#include "include/orte_types.h"
#include "class/ompi_object.h"
#include "class/orte_pointer_array.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "util/proc_info.h"
#include "mca/gpr/base/base.h"
@ -50,7 +50,7 @@ int orte_gpr_proxy_finalize(void);
*/
typedef struct {
ompi_object_t super; /**< Allows this to be an object */
int index; /**< Index of this callback */
size_t index; /**< Index of this callback */
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */
void *user_tag; /**< User-provided tag for callback function */
} orte_gpr_proxy_subscriber_t;
@ -76,8 +76,8 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_proxy_notify_tracker_t);
*/
typedef struct {
int debug;
int32_t block_size;
int32_t max_size;
size_t block_size;
size_t max_size;
orte_pointer_array_t *notify_tracker;
ompi_mutex_t mutex;
bool compound_cmd_mode;
@ -139,14 +139,14 @@ int orte_gpr_proxy_cleanup_proc(orte_process_name_t *proc);
/*
* Put-get functions
*/
int orte_gpr_proxy_put(int cnt, orte_gpr_value_t **values);
int orte_gpr_proxy_put(size_t cnt, orte_gpr_value_t **values);
int orte_gpr_proxy_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_proxy_put_nb(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_proxy_get(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
int *cnt, orte_gpr_value_t ***values);
size_t *cnt, orte_gpr_value_t ***values);
int orte_gpr_proxy_get_nb(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
@ -157,9 +157,9 @@ int orte_gpr_proxy_get_nb(orte_gpr_addr_mode_t addr_mode,
* Subscribe functions
*/
int orte_gpr_proxy_subscribe(orte_gpr_notify_action_t action,
int num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t *sub_number);
@ -181,13 +181,12 @@ int orte_gpr_proxy_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_id
int orte_gpr_proxy_dump_notify_data(orte_gpr_notify_data_t *data, int output_id);
int orte_gpr_proxy_dump_value(orte_gpr_value_t *value, int output_id);
/*
* General operations
*/
int orte_gpr_proxy_preallocate_segment(char *name, int num_slots);
int orte_gpr_proxy_deliver_notify_msg(orte_gpr_notify_message_t *message);
int orte_gpr_proxy_preallocate_segment(char *name, size_t num_slots);
/*
* Functions that interface to the replica
@ -203,7 +202,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
int
orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
int cnt, orte_gpr_subscription_t **subscriptions);
size_t cnt, orte_gpr_subscription_t **subscriptions);
int
orte_gpr_proxy_remove_notify_request(orte_gpr_notify_id_t local_idtag,

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "util/output.h"
#include "util/proc_info.h"

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "mca/errmgr/errmgr.h"
#include "mca/ns/ns_types.h"

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -81,7 +81,6 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
orte_gpr_proxy_index_nb,
/* GENERAL OPERATIONS */
orte_gpr_proxy_preallocate_segment,
orte_gpr_proxy_deliver_notify_msg,
/* ARITHMETIC OPERATIONS */
orte_gpr_proxy_increment_value,
orte_gpr_proxy_decrement_value,
@ -99,6 +98,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
orte_gpr_proxy_dump_callbacks,
orte_gpr_proxy_dump_notify_msg,
orte_gpr_proxy_dump_notify_data,
orte_gpr_proxy_dump_value,
/* CLEANUP OPERATIONS */
orte_gpr_proxy_cleanup_job,
orte_gpr_proxy_cleanup_proc
@ -179,11 +179,13 @@ int orte_gpr_proxy_open(void)
id = mca_base_param_register_int("gpr", "proxy", "maxsize", NULL,
ORTE_GPR_PROXY_MAX_SIZE);
mca_base_param_lookup_int(id, &orte_gpr_proxy_globals.max_size);
mca_base_param_lookup_int(id, &tmp);
orte_gpr_proxy_globals.max_size = (size_t)tmp;
id = mca_base_param_register_int("gpr", "proxy", "blocksize", NULL,
ORTE_GPR_PROXY_BLOCK_SIZE);
mca_base_param_lookup_int(id, &orte_gpr_proxy_globals.block_size);
mca_base_param_lookup_int(id, &tmp);
orte_gpr_proxy_globals.block_size = (size_t)tmp;
return ORTE_SUCCESS;
}
@ -295,7 +297,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
orte_gpr_proxy_subscriber_t **subs;
size_t n;
int rc;
int32_t num_msgs, cnt, i, j, k;
size_t num_msgs, cnt, i, j, k;
if (orte_gpr_proxy_globals.debug) {
ompi_output(0, "[%d,%d,%d] gpr proxy: received trigger message",
@ -314,7 +316,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &num_msgs, &n, ORTE_INT32))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &num_msgs, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
@ -334,7 +336,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &cnt, &n, ORTE_INT32))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &cnt, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
@ -347,8 +349,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
goto RETURN_ERROR;
}
n = cnt;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, data, &n, ORTE_GPR_NOTIFY_DATA))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, data, &cnt, ORTE_GPR_NOTIFY_DATA))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"

Просмотреть файл

@ -21,7 +21,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"

Просмотреть файл

@ -37,7 +37,7 @@
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/oob/oob_types.h"
@ -339,3 +339,28 @@ int orte_gpr_proxy_dump_notify_data(orte_gpr_notify_data_t *data, int output_id)
OBJ_RELEASE(answer);
return rc;
}
int orte_gpr_proxy_dump_value(orte_gpr_value_t *value, int output_id)
{
orte_buffer_t *answer;
int rc;
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) { /* got a problem */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_dump_value(answer, value))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_print_dump(answer, output_id))) {
ORTE_ERROR_LOG(rc);
}
OBJ_RELEASE(answer);
return rc;
}

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -36,7 +36,7 @@
#include "gpr_proxy.h"
int orte_gpr_proxy_preallocate_segment(char *name, int num_slots)
int orte_gpr_proxy_preallocate_segment(char *name, size_t num_slots)
{
return ORTE_ERR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -38,11 +38,11 @@
int
orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
int cnt, orte_gpr_subscription_t **subscriptions)
size_t cnt, orte_gpr_subscription_t **subscriptions)
{
orte_gpr_proxy_notify_tracker_t *trackptr;
orte_gpr_proxy_subscriber_t *sub;
int idtag, i;
size_t idtag, i;
*local_idtag = ORTE_GPR_NOTIFY_ID_MAX;
@ -62,13 +62,13 @@ orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
sub->index = i;
sub->callback = subscriptions[i]->cbfunc;
sub->user_tag = subscriptions[i]->user_tag;
if (0 > (idtag = orte_pointer_array_add(trackptr->callbacks, sub))) {
if (0 > orte_pointer_array_add(&idtag, trackptr->callbacks, sub)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
if (0 > (idtag = orte_pointer_array_add(orte_gpr_proxy_globals.notify_tracker, trackptr))) {
if (0 > orte_pointer_array_add(&idtag, orte_gpr_proxy_globals.notify_tracker, trackptr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}

Просмотреть файл

@ -1,62 +0,0 @@
/* -*- 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
*/
#include "orte_config.h"
#include "util/proc_info.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_proxy.h"
int orte_gpr_proxy_deliver_notify_msg(orte_gpr_notify_message_t *message)
{
orte_gpr_proxy_notify_tracker_t *trackptr;
orte_gpr_proxy_subscriber_t **subs;
int32_t i, j;
/* protect system from threadlock */
/* OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
*/
/* locate the request corresponding to this notify */
trackptr = (orte_gpr_proxy_notify_tracker_t*)
((orte_gpr_proxy_globals.notify_tracker)->addr[message->idtag]);
if (NULL == trackptr) {
/* OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); */
OBJ_RELEASE(message);
return ORTE_ERR_BAD_PARAM;
}
for (i=0; i < message->cnt; i++) { /* unpack each notify_data object */
/* locate the data callback */
subs = (orte_gpr_proxy_subscriber_t**)((trackptr->callbacks)->addr);
for (j=0; j < (trackptr->callbacks)->size; j++) {
if (NULL != subs[j] && subs[j]->index == (message->data[i])->cb_num) {
/* process request */
subs[j]->callback(message->data[i], subs[j]->user_tag);
break;
}
}
}
OBJ_RELEASE(message);
return ORTE_SUCCESS;
}

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps_types.h"
#include "mca/dps/dps_types.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -37,7 +37,7 @@
#include "gpr_proxy.h"
int orte_gpr_proxy_put(int cnt, orte_gpr_value_t **values)
int orte_gpr_proxy_put(size_t cnt, orte_gpr_value_t **values)
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
@ -92,7 +92,7 @@ int orte_gpr_proxy_put(int cnt, orte_gpr_value_t **values)
return ret;
}
int orte_gpr_proxy_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_proxy_put_nb(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_ERR_NOT_IMPLEMENTED;
@ -100,7 +100,7 @@ int orte_gpr_proxy_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_proxy_get(orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys,
int *cnt, orte_gpr_value_t ***values)
size_t *cnt, orte_gpr_value_t ***values)
{
orte_buffer_t *cmd;

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -39,9 +39,9 @@
int
orte_gpr_proxy_subscribe(orte_gpr_notify_action_t action,
int num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t *sub_number)
{

Просмотреть файл

@ -24,7 +24,6 @@ libmca_gpr_replica_api_la_SOURCES = \
gpr_replica_compound_cmd_api.c \
gpr_replica_del_index_api.c \
gpr_replica_dump_api.c \
gpr_replica_messaging_api.c \
gpr_replica_arithmetic_ops_api.c \
gpr_replica_put_get_api.c \
gpr_replica_put_get_api.c \
gpr_replica_subscribe_api.c

Просмотреть файл

@ -91,14 +91,14 @@ int orte_gpr_replica_cleanup_proc(orte_process_name_t *proc);
/*
* Put-get functions
*/
int orte_gpr_replica_put(int cnt, orte_gpr_value_t **values);
int orte_gpr_replica_put(size_t cnt, orte_gpr_value_t **values);
int orte_gpr_replica_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_replica_put_nb(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_replica_get(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
int *cnt, orte_gpr_value_t ***values);
size_t *cnt, orte_gpr_value_t ***values);
int orte_gpr_replica_get_nb(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
@ -109,9 +109,9 @@ int orte_gpr_replica_get_nb(orte_gpr_addr_mode_t addr_mode,
* Subscribe functions
*/
int orte_gpr_replica_subscribe(orte_gpr_notify_action_t action,
int num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t *sub_number);
@ -133,13 +133,12 @@ int orte_gpr_replica_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_
int orte_gpr_replica_dump_notify_data(orte_gpr_notify_data_t *data, int output_id);
int orte_gpr_replica_dump_value(orte_gpr_value_t *value, int output_id);
/*
* General functions
*/
int orte_gpr_replica_preallocate_segment(char *name, int num_slots);
int orte_gpr_replica_deliver_notify_msg(orte_gpr_notify_message_t *msg);
int orte_gpr_replica_preallocate_segment(char *name, size_t num_slots);
#endif

Просмотреть файл

@ -25,7 +25,7 @@
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"

Просмотреть файл

@ -76,7 +76,7 @@ int orte_gpr_replica_delete_entries(orte_gpr_addr_mode_t addr_mode,
int rc;
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_itag_t *token_itags=NULL, *key_itags=NULL;
int num_tokens, num_keys;
size_t num_tokens, num_keys;
/* protect against errors */
if (NULL == segment) {

Просмотреть файл

@ -25,7 +25,7 @@
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -244,3 +244,28 @@ int orte_gpr_replica_dump_notify_data(orte_gpr_notify_data_t *data, int output_i
OBJ_RELEASE(answer);
return rc;
}
int orte_gpr_replica_dump_value(orte_gpr_value_t *value, int output_id)
{
orte_buffer_t *answer;
int rc;
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) { /* got a problem */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_dump_value(answer, value))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_print_dump(answer, output_id))) {
ORTE_ERROR_LOG(rc);
}
OBJ_RELEASE(answer);
return rc;
}

Просмотреть файл

@ -1,62 +0,0 @@
/* -*- 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
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "util/output.h"
#include "util/proc_info.h"
#include "mca/rml/rml_types.h"
#include "gpr_replica_api.h"
int orte_gpr_replica_deliver_notify_msg(orte_gpr_notify_message_t *message)
{
#if 0
orte_gpr_replica_notify_request_tracker_t *ptr;
/* don't deliver messages with zero data - also check for correct cmd */
if (0 < message->cnt && ORTE_GPR_SUBSCRIBE_CMD == message->cmd) {
/* protect system from threadlock */
if ((ORTE_GPR_NOTIFY_ON_STARTUP & message->flag.trig_action) ||
(ORTE_GPR_NOTIFY_ON_SHUTDOWN & message->flag.trig_action)) {
OMPI_THREAD_LOCK(&orte_gpr_replica_mutex);
/* find the request corresponding to this notify */
ptr = (orte_gpr_replica_notify_request_tracker_t*)orte_pointer_array_get_item(
orte_gpr_replica_notify_request_tracker, message->idtag);
if (ptr->flag.trig_action & message->flag.trig_action) { /* make one last check */
OMPI_THREAD_UNLOCK(&orte_gpr_replica_mutex);
/* process request - callback function responsible for releasing memory */
ptr->callback(message, ptr->user_tag);
return;
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_mutex);
}
}
OBJ_RELEASE(message);
#endif
return ORTE_ERR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -32,9 +32,10 @@
#include "gpr_replica_api.h"
int orte_gpr_replica_put(int cnt, orte_gpr_value_t **values)
int orte_gpr_replica_put(size_t cnt, orte_gpr_value_t **values)
{
int rc = ORTE_SUCCESS, i, j;
int rc = ORTE_SUCCESS;
size_t i, j;
int8_t action_taken;
orte_gpr_value_t *val;
orte_gpr_replica_segment_t *seg=NULL;
@ -112,7 +113,7 @@ CLEANUP:
}
int orte_gpr_replica_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_replica_put_nb(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_ERR_NOT_IMPLEMENTED;
@ -121,11 +122,12 @@ int orte_gpr_replica_put_nb(int cnt, orte_gpr_value_t **values,
int orte_gpr_replica_get(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
int *cnt, orte_gpr_value_t ***values)
size_t *cnt, orte_gpr_value_t ***values)
{
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_itag_t *tokentags=NULL, *keytags=NULL;
int num_tokens=0, num_keys=0, rc;
size_t num_tokens=0, num_keys=0;
int rc;
*cnt = 0;
*values = NULL;

Просмотреть файл

@ -30,7 +30,7 @@
#include "gpr_replica_api.h"
int orte_gpr_replica_preallocate_segment(char *name, int num_slots)
int orte_gpr_replica_preallocate_segment(char *name, size_t num_slots)
{
int rc;
orte_gpr_replica_segment_t *seg=NULL;

Просмотреть файл

@ -25,7 +25,7 @@
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/ns/ns.h"
#include "mca/errmgr/errmgr.h"
@ -34,9 +34,9 @@
int
orte_gpr_replica_subscribe(orte_gpr_notify_action_t action,
int num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t *sub_number)
{

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "util/output.h"
#include "gpr_replica_comm.h"

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"
@ -74,8 +74,8 @@ int orte_gpr_replica_recv_delete_entries_cmd(orte_buffer_t *buffer, orte_buffer_
orte_gpr_replica_itag_t *token_itags=NULL, *key_itags=NULL;
orte_gpr_replica_segment_t *seg=NULL;
char *segment=NULL, **tokens=NULL, **keys=NULL;
int num_tokens=0, num_keys=0, rc, i, ret;
size_t n;
size_t num_tokens=0, num_keys=0, i, n;
int rc, ret;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
@ -95,7 +95,7 @@ int orte_gpr_replica_recv_delete_entries_cmd(orte_buffer_t *buffer, orte_buffer_
}
n = 1;
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, &num_tokens, &n, ORTE_INT))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, &num_tokens, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -109,14 +109,14 @@ int orte_gpr_replica_recv_delete_entries_cmd(orte_buffer_t *buffer, orte_buffer_
ret = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, tokens, (size_t*)&num_tokens, ORTE_STRING))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, tokens, &num_tokens, ORTE_STRING))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
}
n = 1;
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, &num_keys, &n, ORTE_INT))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, &num_keys, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -130,7 +130,7 @@ int orte_gpr_replica_recv_delete_entries_cmd(orte_buffer_t *buffer, orte_buffer_
ret = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, keys, (size_t*)&num_keys, ORTE_STRING))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(buffer, keys, &num_keys, ORTE_STRING))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "gpr_replica_comm.h"
@ -38,8 +38,8 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
orte_gpr_replica_itag_t *itags=NULL;
orte_data_type_t type;
int8_t action_taken=0;
int i=0, rc, ret;
size_t cnt;
int rc, ret;
size_t i=0, cnt;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
@ -73,7 +73,7 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
goto RETURN_ERROR;
}
for (i=0; i < (int)cnt; i++) {
for (i=0; i < cnt; i++) {
val = values[i];
/* find the segment */
@ -117,7 +117,7 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
/* release values */
if (NULL != values) {
for (i=0; i < (int)cnt; i++) {
for (i=0; i < cnt; i++) {
if (NULL != values[i]) {
OBJ_RELEASE(values[i]);
}
@ -140,10 +140,10 @@ int orte_gpr_replica_recv_get_cmd(orte_buffer_t *input_buffer,
orte_gpr_addr_mode_t addr_mode;
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_itag_t *tokentags=NULL, *keytags=NULL;
int num_tokens=0, num_keys=0, rc, ret;
int rc, ret;
char *segment=NULL, **tokens=NULL, **keys=NULL;
int i=0, cnt=0;
size_t n;
size_t i=0, cnt=0;
size_t num_tokens=0, num_keys=0, n;
orte_gpr_value_t **values=NULL;
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &command, 1, ORTE_GPR_CMD))) {
@ -164,7 +164,7 @@ int orte_gpr_replica_recv_get_cmd(orte_buffer_t *input_buffer,
}
n = 1;
if (ORTE_SUCCESS != (ret = orte_dps.unpack(input_buffer, &num_tokens, &n, ORTE_INT))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(input_buffer, &num_tokens, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -187,7 +187,7 @@ int orte_gpr_replica_recv_get_cmd(orte_buffer_t *input_buffer,
}
n = 1;
if (ORTE_SUCCESS != (ret = orte_dps.unpack(input_buffer, &num_keys, &n, ORTE_INT))) {
if (ORTE_SUCCESS != (ret = orte_dps.unpack(input_buffer, &num_keys, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -240,7 +240,7 @@ int orte_gpr_replica_recv_get_cmd(orte_buffer_t *input_buffer,
RETURN_ERROR:
/* pack the number of values */
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &cnt, 1, ORTE_INT))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &cnt, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
ret = rc;
}
@ -292,6 +292,7 @@ int orte_gpr_replica_recv_get_cmd(orte_buffer_t *input_buffer,
ORTE_ERROR_LOG(rc);
}
ompi_output(0, "REPLICA-GET: FINAL NUMBER OF BYTES PACKED %d", output_buffer->len);
return ret;
}

Просмотреть файл

@ -27,7 +27,7 @@
#include "include/orte_types.h"
#include "util/output.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/rml/rml.h"
@ -39,7 +39,7 @@ int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *
orte_gpr_replica_notify_msg_list_t *msg;
orte_gpr_notify_message_t *message;
orte_gpr_cmd_flag_t command;
int32_t count;
size_t count;
int rc;
if (orte_gpr_replica_globals.debug) {
@ -55,8 +55,8 @@ int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *
return rc;
}
count = (int32_t)ompi_list_get_size(messages);
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &count, 1, ORTE_INT32))) {
count = (size_t)ompi_list_get_size(messages);
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &count, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
@ -70,7 +70,7 @@ int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &(message->cnt), 1, ORTE_INT32))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &(message->cnt), 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}

Просмотреть файл

@ -25,7 +25,7 @@
*/
#include "orte_config.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "util/proc_info.h"
#include "util/output.h"
@ -39,8 +39,8 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
orte_gpr_cmd_flag_t command=ORTE_GPR_SUBSCRIBE_CMD;
orte_data_type_t type;
orte_gpr_notify_id_t local_idtag=ORTE_GPR_NOTIFY_ID_MAX, idtag=ORTE_GPR_NOTIFY_ID_MAX;
int rc, ret, num_subs, num_trigs;
size_t n;
int rc, ret;
size_t n, num_subs, num_trigs;
orte_gpr_notify_action_t action;
orte_gpr_value_t **trigs;
orte_gpr_subscription_t **subscriptions;

Просмотреть файл

@ -36,14 +36,15 @@
int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags,
int num_tokens, int cnt,
size_t num_tokens, size_t cnt,
orte_gpr_keyval_t **keyvals)
{
orte_gpr_replica_container_t **cptr;
orte_gpr_replica_itag_t itag;
orte_gpr_replica_addr_mode_t tok_mode;
orte_gpr_replica_itagval_t **ival;
int rc, i, j, k, num_found;
int rc;
size_t i, j, k, num_found;
/* extract the token address mode */
tok_mode = 0x004f & addr_mode;
@ -77,6 +78,10 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
for (k=0; k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */
if (NULL != ival[k]) {
switch (ival[k]->type) {
case ORTE_SIZE:
ival[k]->value.size++;
break;
case ORTE_UINT8:
ival[k]->value.ui8++;
break;
@ -89,7 +94,7 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
ival[k]->value.ui32++;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
ival[k]->value.ui64++;
break;
@ -125,14 +130,15 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags,
int num_tokens, int cnt,
size_t num_tokens, size_t cnt,
orte_gpr_keyval_t **keyvals)
{
orte_gpr_replica_container_t **cptr;
orte_gpr_replica_itag_t itag;
orte_gpr_replica_addr_mode_t tok_mode;
orte_gpr_replica_itagval_t **ival;
int rc, i, j, k, num_found;
int rc;
size_t i, j, k, num_found;
/* extract the token address mode */
tok_mode = 0x004f & addr_mode;
@ -166,6 +172,10 @@ int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
for (k=0; k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */
if (NULL != ival[k]) {
switch (ival[k]->type) {
case ORTE_SIZE:
ival[k]->value.size--;
break;
case ORTE_UINT8:
ival[k]->value.ui8--;
break;
@ -178,7 +188,7 @@ int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
ival[k]->value.ui32--;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
ival[k]->value.ui64--;
break;

Просмотреть файл

@ -68,7 +68,8 @@ int orte_gpr_replica_cleanup_proc_fn(orte_process_name_t *proc)
orte_gpr_replica_itag_t itag;
char *procname, *segment, *jobidstring;
orte_jobid_t jobid;
int rc, i, j;
int rc;
size_t i, j;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%d,%d,%d] gpr_replica_cleanup_proc: function entered for process [%d,%d,%d]",

Просмотреть файл

@ -35,8 +35,8 @@
int orte_gpr_replica_delete_entries_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
orte_gpr_replica_itag_t *key_itags, int num_keys)
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
orte_gpr_replica_itag_t *key_itags, size_t num_keys)
{
#if 0
orte_gpr_replica_container_t **ptr;
@ -125,8 +125,8 @@ int orte_gpr_replica_delete_entries_fn(orte_gpr_addr_mode_t addr_mode,
int orte_gpr_replica_delete_entries_nb_fn(
orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
orte_gpr_replica_itag_t *key_tags, int num_keys)
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
orte_gpr_replica_itag_t *key_tags, size_t num_keys)
{
return ORTE_ERR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -32,14 +32,14 @@
/*
*/
bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t addr_mode,
int num_itags_search,
size_t num_itags_search,
orte_gpr_replica_itag_t *itags,
int num_itags_entry,
size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags)
{
int num_found;
size_t num_found;
bool exclusive, no_match, not_set;
int i, j;
size_t i, j;
/* check for trivial case */
if (NULL == itags || 0 >= num_itags_search) { /* wildcard case - automatically true */
@ -122,7 +122,7 @@ bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t addr_mode,
int orte_gpr_replica_copy_itag_list(orte_gpr_replica_itag_t **dest,
orte_gpr_replica_itag_t *src, int num_itags)
orte_gpr_replica_itag_t *src, size_t num_itags)
{
if (0 == num_itags || NULL == src) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);

Просмотреть файл

@ -28,7 +28,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "util/output.h"
#include "mca/errmgr/errmgr.h"
@ -43,7 +43,7 @@ static void orte_gpr_replica_dump_load_string(orte_buffer_t *buffer, char **tmp)
void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr);
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, int cnt,
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_triggers_t *trig);
@ -72,8 +72,8 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
orte_gpr_replica_itag_t *itaglist;
orte_gpr_replica_itagval_t **iptr;
char *token;
int num_objects;
int i, j, k;
size_t num_objects;
size_t i, j, k;
char *tmp_out;
tmp_out = (char*)malloc(1000);
@ -157,7 +157,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_notify_msg_list_t *msg;
char *tmp_out;
int i, j, k;
size_t i, j, k;
tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) {
@ -220,7 +220,7 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
{
orte_gpr_replica_triggers_t **trig;
char tmp_out[100], *tmp;
int j, k;
size_t j, k;
tmp = tmp_out;
sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n");
@ -246,11 +246,11 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
return ORTE_SUCCESS;
}
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, int cnt,
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_triggers_t *trig)
{
char *tmp_out, *token;
int i, j, k;
size_t i, j, k;
orte_gpr_replica_subscribed_data_t **data;
orte_gpr_replica_counter_t **cntr;
@ -472,7 +472,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
break;
case ORTE_SIZE:
sprintf(tmp, "\t\tData type: ORTE_SIZE");
sprintf(tmp, "\t\tData type: ORTE_SIZE\tValue: %d", iptr->value.size);
break;
case ORTE_INT:
@ -491,7 +491,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
sprintf(tmp, "\t\tData type: ORTE_UINT32\tValue: %d", (int)iptr->value.ui32);
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
sprintf(tmp, "\t\tData type: ORTE_UINT64\tValue: %d", (int)iptr->value.ui64);
break;
@ -509,7 +509,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
sprintf(tmp, "\t\tData type: ORTE_INT32\tValue: %d", (int)iptr->value.i32);
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_INT64:
sprintf(tmp, "\t\tData type: ORTE_INT64\tValue: %d", (int)iptr->value.i64);
break;

Просмотреть файл

@ -39,13 +39,13 @@
int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *itags,
int num_tokens, int cnt,
size_t num_tokens, size_t cnt,
orte_gpr_keyval_t **keyvals);
int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *itags,
int num_tokens, int cnt,
size_t num_tokens, size_t cnt,
orte_gpr_keyval_t **keyvals);
/*
@ -53,14 +53,14 @@ int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
*/
int orte_gpr_replica_delete_entries_fn(orte_gpr_addr_mode_t mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
orte_gpr_replica_itag_t *key_tags, int num_keys);
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
orte_gpr_replica_itag_t *key_tags, size_t num_keys);
int orte_gpr_replica_delete_entries_nb_fn(
orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
orte_gpr_replica_itag_t *key_tags, int num_keys);
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
orte_gpr_replica_itag_t *key_tags, size_t num_keys);
int orte_gpr_replica_index_fn(orte_gpr_replica_segment_t *seg,
size_t *cnt, char **index);
@ -82,35 +82,35 @@ int orte_gpr_replica_cleanup_proc_fn(orte_process_name_t *proc);
*/
int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
int cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
size_t cnt, orte_gpr_keyval_t **keyvals,
int8_t *action_taken);
int orte_gpr_replica_put_nb_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
int cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
size_t cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags, int num_tokens,
orte_gpr_replica_itag_t *keytags, int num_keys,
int *cnt, orte_gpr_value_t ***values);
orte_gpr_replica_itag_t *tokentags, size_t num_tokens,
orte_gpr_replica_itag_t *keytags, size_t num_keys,
size_t *cnt, orte_gpr_value_t ***values);
int orte_gpr_replica_get_nb_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags, int num_tokens,
orte_gpr_replica_itag_t *keytags, int num_keys,
orte_gpr_replica_itag_t *tokentags, size_t num_tokens,
orte_gpr_replica_itag_t *keytags, size_t num_keys,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
/*
* Subscribe functions
*/
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t idtag);
@ -144,13 +144,13 @@ int orte_gpr_replica_release_segment(orte_gpr_replica_segment_t **seg);
typedef int (*orte_gpr_replica_release_segment_fn_t)
(orte_gpr_replica_segment_t **seg);
int orte_gpr_replica_find_containers(int *num_found, orte_gpr_replica_segment_t *seg,
int orte_gpr_replica_find_containers(size_t *num_found, orte_gpr_replica_segment_t *seg,
orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *taglist, int num_tags);
orte_gpr_replica_itag_t *taglist, size_t num_tags);
int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
orte_gpr_replica_segment_t *seg,
int num_itags,
size_t num_itags,
orte_gpr_replica_itag_t *itags);
/**
* Typedef of the orte_gpr_replica_create_container() function
@ -160,7 +160,7 @@ int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
typedef int (*orte_gpr_replica_create_container_fn_t)
(orte_gpr_replica_container_t **cptr,
orte_gpr_replica_segment_t *seg,
int num_itags,
size_t num_itags,
orte_gpr_replica_itag_t *itags);
int orte_gpr_replica_release_container(orte_gpr_replica_segment_t *seg,
@ -200,11 +200,14 @@ int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest,
orte_gpr_value_union_t *src,
orte_data_type_t type);
int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1,
orte_gpr_replica_itagval_t *ival2);
int orte_gpr_replica_purge_itag(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t itag);
int orte_gpr_replica_search_container(int *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, int num_itags,
int orte_gpr_replica_search_container(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr);
/**
@ -213,8 +216,8 @@ int orte_gpr_replica_search_container(int *cnt, orte_gpr_replica_addr_mode_t add
* unit test.
*/
typedef int (*orte_gpr_replica_search_container_fn_t)
(int *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, int num_itags,
(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr);
int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival);
@ -228,9 +231,9 @@ int orte_gpr_replica_delete_itagval(orte_gpr_replica_segment_t *seg,
*/
bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t mode,
int num_itags_search,
size_t num_itags_search,
orte_gpr_replica_itag_t *itags,
int num_itags_entry,
size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags);
/**
@ -240,13 +243,13 @@ bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t mode,
*/
typedef bool (*orte_gpr_replica_check_itag_list_fn_t)
(orte_gpr_replica_addr_mode_t mode,
int num_itags_search,
size_t num_itags_search,
orte_gpr_replica_itag_t *itags,
int num_itags_entry,
size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags);
int orte_gpr_replica_copy_itag_list(orte_gpr_replica_itag_t **dest,
orte_gpr_replica_itag_t *src, int num_itags);
orte_gpr_replica_itag_t *src, size_t num_itags);
void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr);
@ -267,7 +270,7 @@ int
orte_gpr_replica_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
orte_process_name_t *requestor,
orte_gpr_notify_id_t remote_idtag,
int cnt, orte_gpr_subscription_t **subscriptions);
size_t cnt, orte_gpr_subscription_t **subscriptions);
int
orte_gpr_replica_remove_notify_request(orte_gpr_notify_id_t local_idtag,

Просмотреть файл

@ -26,7 +26,7 @@
#include "orte_config.h"
#include "include/orte_constants.h"
#include "include/orte_schema.h"
#include "mca/schema/schema.h"
#include "util/output.h"
#include "util/proc_info.h"
@ -35,6 +35,7 @@
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/base/base.h"
#include "mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "mca/gpr/replica/communications/gpr_replica_comm.h"
#include "gpr_replica_fn.h"
@ -47,7 +48,8 @@ int orte_gpr_replica_process_callbacks(void)
orte_gpr_replica_subscribed_data_t **sdata;
orte_gpr_replica_triggers_t *trig, **trigs;
bool processed;
int i, k, rc;
size_t i, k;
int rc;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "gpr replica: process_callbacks entered");
@ -74,6 +76,8 @@ 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++) {
@ -240,7 +244,7 @@ int orte_gpr_replica_construct_notify_message(orte_gpr_notify_message_t **msg,
int rc=ORTE_SUCCESS;
orte_gpr_notify_data_t **data;
orte_gpr_replica_subscribed_data_t **sptr;
int i, k;
size_t i, k;
/* if we don't have data, just return */
if (0 >= trig->num_subscribed_data) {
@ -311,13 +315,14 @@ MOVEON:
int orte_gpr_replica_add_values(orte_gpr_notify_data_t **data,
orte_gpr_replica_subscribed_data_t *sptr)
{
int i, rc, j, k, n, m, matches, num_tokens, num_keys, cnt;
size_t i, j, k, n, m, matches, num_tokens, num_keys, cnt;
int rc;
orte_gpr_value_t **values = NULL, **data_values;
orte_gpr_keyval_t **kptr;
/* get the data off the registry */
num_tokens = (int)orte_value_array_get_size(&(sptr->tokentags));
num_keys = (int) orte_value_array_get_size(&(sptr->keytags));
num_tokens = orte_value_array_get_size(&(sptr->tokentags));
num_keys = orte_value_array_get_size(&(sptr->keytags));
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "add_values: performing a get");

Просмотреть файл

@ -31,6 +31,7 @@
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/replica/transition_layer/gpr_replica_tl.h"
#include "mca/gpr/replica/api_layer/gpr_replica_api.h"
#include "gpr_replica_fn.h"
@ -60,8 +61,13 @@ static void orte_gpr_replica_ival_list_destructor(orte_gpr_replica_ival_list_t*
{
if (ORTE_BYTE_OBJECT == ptr->type) {
free(((ptr->value).byteobject).bytes);
} else if (ORTE_STRING == ptr->type) {
if (NULL != ptr->value.strptr)
free(ptr->value.strptr);
} else if (ORTE_APP_CONTEXT == ptr->type) {
if (NULL != ptr->value.app_context)
OBJ_RELEASE(ptr->value.app_context);
}
}
/* define instance of ival_list_t */
@ -117,8 +123,8 @@ OBJ_CLASS_INSTANCE(
int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
int cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
size_t cnt, orte_gpr_keyval_t **keyvals,
int8_t *action_taken)
{
orte_gpr_replica_container_t **cptr, *cptr2;
@ -128,7 +134,8 @@ int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_itagval_t *iptr;
bool overwrite;
char **tmp;
int rc, i, j, num_found;
int rc;
size_t i, j, num_found;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%d,%d,%d] gpr replica: put entered on segment %s\nValues:",
@ -231,8 +238,8 @@ int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
int orte_gpr_replica_put_nb_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, int num_tokens,
int cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
size_t cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_ERR_NOT_IMPLEMENTED;
@ -241,9 +248,9 @@ int orte_gpr_replica_put_nb_fn(orte_gpr_addr_mode_t addr_mode,
int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags, int num_tokens,
orte_gpr_replica_itag_t *keytags, int num_keys,
int *cnt, orte_gpr_value_t ***values)
orte_gpr_replica_itag_t *tokentags, size_t num_tokens,
orte_gpr_replica_itag_t *keytags, size_t num_keys,
size_t *cnt, orte_gpr_value_t ***values)
{
ompi_list_t get_list;
orte_gpr_replica_get_list_t *gptr;
@ -252,7 +259,8 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_itagval_t **iptr;
orte_gpr_keyval_t **kptr;
orte_gpr_replica_addr_mode_t tokmode, keymode;
int rc, i, j, num_found;
int rc;
size_t i, j, num_found;
char *token;
if (orte_gpr_replica_globals.debug) {
@ -347,6 +355,7 @@ 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);
@ -410,6 +419,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
OBJ_RELEASE(ival_list);
}
OBJ_RELEASE(gptr);
orte_gpr_replica_dump_value((*values)[i], 0);
}
CLEANUP:
@ -428,8 +438,8 @@ CLEANUP:
int orte_gpr_replica_get_nb_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags, int num_tokens,
orte_gpr_replica_itag_t *keytags, int num_keys,
orte_gpr_replica_itag_t *tokentags, size_t num_tokens,
orte_gpr_replica_itag_t *keytags, size_t num_keys,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_ERR_NOT_IMPLEMENTED;

Просмотреть файл

@ -33,12 +33,12 @@
#include "gpr_replica_fn.h"
int orte_gpr_replica_find_containers(int *num_found, orte_gpr_replica_segment_t *seg,
int orte_gpr_replica_find_containers(size_t *num_found, orte_gpr_replica_segment_t *seg,
orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *taglist, int num_tags)
orte_gpr_replica_itag_t *taglist, size_t num_tags)
{
orte_gpr_replica_container_t **cptr;
int i;
size_t i, index;
/* ensure the search array is clear */
orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr);
@ -49,7 +49,7 @@ int orte_gpr_replica_find_containers(int *num_found, orte_gpr_replica_segment_t
if (NULL != cptr[i] && orte_gpr_replica_check_itag_list(addr_mode,
num_tags, taglist,
cptr[i]->num_itags, cptr[i]->itags)) {
if (0 > orte_pointer_array_add(orte_gpr_replica_globals.srch_cptr, cptr[i])) {
if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_cptr, cptr[i])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr);
return ORTE_ERR_OUT_OF_RESOURCE;
@ -63,10 +63,11 @@ int orte_gpr_replica_find_containers(int *num_found, orte_gpr_replica_segment_t
int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
orte_gpr_replica_segment_t *seg,
int num_itags,
size_t num_itags,
orte_gpr_replica_itag_t *itags)
{
int rc;
size_t index;
*cptr = OBJ_NEW(orte_gpr_replica_container_t);
if (NULL == *cptr) {
@ -82,11 +83,12 @@ int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
(*cptr)->num_itags = num_itags;
if (0 > ((*cptr)->index = orte_pointer_array_add(seg->containers, (void*)(*cptr)))) {
if (0 > orte_pointer_array_add(&index, seg->containers, (void*)(*cptr))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(*cptr)->index = index;
return ORTE_SUCCESS;
}
@ -95,7 +97,8 @@ int orte_gpr_replica_release_container(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr)
{
orte_gpr_replica_itagval_t **iptr;
int i, rc;
size_t i;
int rc;
/* delete all the itagvals in the container */
iptr = (orte_gpr_replica_itagval_t**)((cptr->itagvals)->addr);
@ -146,7 +149,7 @@ int orte_gpr_replica_add_keyval(orte_gpr_replica_itagval_t **ivalptr,
return rc;
}
if (0 > (iptr->index = orte_pointer_array_add(cptr->itagvals, (void*)iptr))) {
if (0 > orte_pointer_array_add(&(iptr->index), cptr->itagvals, (void*)iptr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(iptr);
return ORTE_ERR_OUT_OF_RESOURCE;
@ -168,7 +171,7 @@ int orte_gpr_replica_delete_itagval(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr,
orte_gpr_replica_itagval_t *iptr)
{
int i;
size_t i;
/* see if anyone cares that this value is deleted */
/* trig = (orte_gpr_replica_triggers_t**)((orte_gpr_replica.triggers)->addr);
@ -202,7 +205,8 @@ int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr,
orte_gpr_keyval_t *kptr)
{
int i, rc;
size_t i;
int rc;
orte_pointer_array_t *ptr;
orte_gpr_replica_itagval_t *iptr;
@ -235,12 +239,12 @@ int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg,
}
int orte_gpr_replica_search_container(int *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, int num_itags,
int orte_gpr_replica_search_container(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr)
{
orte_gpr_replica_itagval_t **ptr;
int i;
size_t i, index;
/* ensure the search array is clear */
orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival);
@ -250,7 +254,7 @@ int orte_gpr_replica_search_container(int *cnt, orte_gpr_replica_addr_mode_t add
* to addr_mode spec
*/
if (orte_gpr_replica_check_itag_list(addr_mode, num_itags, itags,
(int)orte_value_array_get_size(&(cptr->itaglist)),
orte_value_array_get_size(&(cptr->itaglist)),
ORTE_VALUE_ARRAY_GET_BASE(&(cptr->itaglist), orte_gpr_replica_itag_t))) {
/* there is! so now collect those values into the search array */
ptr = (orte_gpr_replica_itagval_t**)((cptr->itagvals)->addr);
@ -259,7 +263,7 @@ int orte_gpr_replica_search_container(int *cnt, orte_gpr_replica_addr_mode_t add
num_itags, itags,
1, &(ptr[i]->itag))) {
if (0 > orte_pointer_array_add(orte_gpr_replica_globals.srch_ival, ptr[i])) {
if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_ival, ptr[i])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival);
return ORTE_ERR_OUT_OF_RESOURCE;
@ -281,6 +285,14 @@ int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival)
switch(ival->type) {
case ORTE_STRING:
value = strdup(src->strptr);
break;
case ORTE_SIZE:
*((size_t*)value) = src->size;
break;
case ORTE_UINT8:
*((uint8_t*)value) = src->ui8;
break;
@ -293,7 +305,7 @@ int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival)
*((uint32_t*)value) = src->ui32;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
*((uint64_t*)value) = src->ui64;
break;
@ -311,7 +323,7 @@ int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival)
*((int32_t*)value) = src->i32;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_INT64:
*((int64_t*)value) = src->i64;
break;
@ -357,10 +369,14 @@ int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest,
orte_gpr_value_union_t *src,
orte_data_type_t type)
{
int i;
size_t i;
switch(type) {
case ORTE_SIZE:
dest->size = src->size;
break;
case ORTE_STRING:
dest->strptr = strdup(src->strptr);
if (NULL == dest->strptr) {
@ -381,7 +397,7 @@ int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest,
dest->ui32 = src->ui32;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_UINT64:
dest->ui64 = src->ui64;
break;
@ -399,7 +415,7 @@ int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest,
dest->i32 = src->i32;
break;
#ifdef HAVE_I64
#ifdef HAVE_INT64_T
case ORTE_INT64:
dest->i64 = src->i64;
break;
@ -491,10 +507,201 @@ int orte_gpr_replica_xfer_payload(orte_gpr_value_union_t *dest,
return ORTE_SUCCESS;
}
int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1,
orte_gpr_replica_itagval_t *ival2)
{
/* sanity check */
if (ival1->type != ival2->type) { /* can't compare mismatch */
ORTE_ERROR_LOG(ORTE_ERR_TYPE_MISMATCH);
return ORTE_ERR_TYPE_MISMATCH;
}
switch(ival1->type) {
case ORTE_STRING:
*cmp = strcmp(ival1->value.strptr, ival2->value.strptr);
break;
case ORTE_SIZE:
if (ival1->value.size == ival2->value.size) {
*cmp = 0;
} else if (ival1->value.size < ival2->value.size) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_UINT8:
if (ival1->value.ui8 == ival2->value.ui8) {
*cmp = 0;
} else if (ival1->value.ui8 < ival2->value.ui8) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_UINT16:
if (ival1->value.ui16 == ival2->value.ui16) {
*cmp = 0;
} else if (ival1->value.ui16 < ival2->value.ui16) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_UINT32:
if (ival1->value.ui32 == ival2->value.ui32) {
*cmp = 0;
} else if (ival1->value.ui32 < ival2->value.ui32) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
#ifdef HAVE_INT64_T
case ORTE_UINT64:
if (ival1->value.ui64 == ival2->value.ui64) {
*cmp = 0;
} else if (ival1->value.ui64 < ival2->value.ui64) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_INT64:
if (ival1->value.i64 == ival2->value.i64) {
*cmp = 0;
} else if (ival1->value.i64 < ival2->value.i64) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
#endif
case ORTE_INT8:
if (ival1->value.i8 == ival2->value.i8) {
*cmp = 0;
} else if (ival1->value.i8 < ival2->value.i8) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_INT16:
if (ival1->value.i16 == ival2->value.i16) {
*cmp = 0;
} else if (ival1->value.i16 < ival2->value.i16) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_INT32:
if (ival1->value.i32 == ival2->value.i32) {
*cmp = 0;
} else if (ival1->value.i32 < ival2->value.i32) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
case ORTE_JOBID:
if (ival1->value.jobid == ival2->value.jobid) {
*cmp = 0;
} else if (ival1->value.jobid < ival2->value.jobid) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_CELLID:
if (ival1->value.cellid == ival2->value.cellid) {
*cmp = 0;
} else if (ival1->value.cellid < ival2->value.cellid) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_VPID:
if (ival1->value.vpid == ival2->value.vpid) {
*cmp = 0;
} else if (ival1->value.vpid < ival2->value.vpid) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_NODE_STATE:
if (ival1->value.node_state == ival2->value.node_state) {
*cmp = 0;
} else if (ival1->value.node_state < ival2->value.node_state) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_PROC_STATE:
if (ival1->value.proc_state == ival2->value.proc_state) {
*cmp = 0;
} else if (ival1->value.proc_state < ival2->value.proc_state) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_EXIT_CODE:
if (ival1->value.exit_code == ival2->value.exit_code) {
*cmp = 0;
} else if (ival1->value.exit_code < ival2->value.exit_code) {
*cmp = -1;
} else {
*cmp = 1;
}
break;
break;
case ORTE_NULL:
*cmp = 0;
break;
default:
return ORTE_ERR_BAD_PARAM;
break;
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_release_segment(orte_gpr_replica_segment_t **seg)
{
int rc, i;
int rc;
size_t i;
i = (*seg)->itag;
OBJ_RELEASE(*seg);

Просмотреть файл

@ -33,9 +33,9 @@
#include "mca/gpr/replica/transition_layer/gpr_replica_tl.h"
#include "gpr_replica_fn.h"
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_subs,
orte_gpr_subscription_t **subscriptions,
int num_trigs,
size_t num_trigs,
orte_gpr_value_t **trigs,
orte_gpr_notify_id_t idtag)
{
@ -47,12 +47,13 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
orte_gpr_replica_itag_t itag, *tokentags=NULL, *keytags=NULL;
orte_gpr_replica_itagval_t *iptr=NULL;
orte_gpr_replica_addr_mode_t tok_mode, key_mode;
int i, j, k, rc, num_tokens, num_keys, num_found;
size_t i, j, k, index, num_tokens, num_keys, num_found;
int rc;
bool found;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%d,%d,%d] gpr replica: subscribe entered",
ORTE_NAME_ARGS(orte_process_info.my_name));
ompi_output(0, "[%d,%d,%d] gpr replica: subscribe entered - registering idtag %d",
ORTE_NAME_ARGS(orte_process_info.my_name), idtag);
ompi_output(0, "Received %d subscriptions", num_subs);
for (i=0; i < num_subs; i++) {
ompi_output(0, "Subscription %d on segment %s with %d tokens, %d keys",
@ -65,6 +66,16 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
ompi_output(0, "\tKey num: %d\tKey: %s", j, subscriptions[i]->keys[j]);
}
}
for (i=0; i < num_trigs; i++) {
ompi_output(0, "Trigger %d on segment %s with %d tokens, %d keyvals",
i, trigs[i]->segment, trigs[i]->num_tokens, trigs[i]->cnt);
for (j=0; j < trigs[i]->num_tokens; j++) {
ompi_output(0, "\tToken num: %d\tToken: %s", j, trigs[i]->tokens[j]);
}
for (j=0; j < trigs[i]->cnt; j++) {
ompi_output(0, "\tKey num: %d\tKey: %s", j, (trigs[i]->keyvals[j])->key);
}
}
}
trig = (orte_gpr_replica_triggers_t*)((orte_gpr_replica.triggers)->addr[idtag]);
@ -214,7 +225,7 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 > orte_pointer_array_add(trig->counters, cntr)) {
if (0 > orte_pointer_array_add(&index, trig->counters, cntr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
@ -259,7 +270,7 @@ int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, int num_subs,
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 > orte_pointer_array_add(trig->counters, cntr)) {
if (0 > orte_pointer_array_add(&index, trig->counters, cntr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;

Просмотреть файл

@ -37,10 +37,11 @@ int
orte_gpr_replica_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
orte_process_name_t *requestor,
orte_gpr_notify_id_t remote_idtag,
int cnt, orte_gpr_subscription_t **subscriptions)
size_t cnt, orte_gpr_subscription_t **subscriptions)
{
orte_gpr_replica_triggers_t *trig;
int rc, i;
int rc;
size_t i, index;
orte_gpr_replica_subscribed_data_t *data;
*local_idtag = ORTE_GPR_NOTIFY_ID_MAX;
@ -73,7 +74,7 @@ orte_gpr_replica_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
data->callback = subscriptions[i]->cbfunc;
data->user_tag = subscriptions[i]->user_tag;
/* add the object to the trigger's subscribed_data pointer array */
if (0 > (rc = orte_pointer_array_add(trig->subscribed_data, data))) {
if (0 > (rc = orte_pointer_array_add(&index, trig->subscribed_data, data))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
@ -81,13 +82,12 @@ orte_gpr_replica_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
}
trig->num_subscribed_data = cnt;
if (0 > (rc = orte_pointer_array_add(orte_gpr_replica.triggers, trig))) {
if (0 > (rc = orte_pointer_array_add(&(trig->index), orte_gpr_replica.triggers, trig))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig->index = rc;
*local_idtag = (orte_gpr_notify_id_t)rc;
*local_idtag = (orte_gpr_notify_id_t)trig->index;
return ORTE_SUCCESS;
}
@ -117,7 +117,7 @@ int orte_gpr_replica_update_storage_locations(orte_gpr_replica_itagval_t *new_ip
orte_gpr_replica_triggers_t **trig;
orte_gpr_replica_counter_t **cntrs;
orte_gpr_replica_itagval_t **old_iptrs;
int i, j, k;
size_t i, j, k;
bool replaced;
trig = (orte_gpr_replica_triggers_t**)((orte_gpr_replica.triggers)->addr);
@ -151,7 +151,8 @@ int orte_gpr_replica_check_subscriptions(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_action_t action_taken)
{
orte_gpr_replica_triggers_t **trig;
int i, rc;
size_t i;
int rc;
trig = (orte_gpr_replica_triggers_t**)((orte_gpr_replica.triggers)->addr);
for (i=0; i < (orte_gpr_replica.triggers)->size; i++) {
@ -172,8 +173,11 @@ int orte_gpr_replica_check_subscriptions(orte_gpr_replica_segment_t *seg,
int orte_gpr_replica_check_trig(orte_gpr_replica_triggers_t *trig)
{
orte_gpr_replica_counter_t **cntr;
orte_gpr_replica_itagval_t *base_value;
bool first, fire;
int i, rc, level, level2;
size_t i;
int cmp;
int rc;
if (ORTE_GPR_TRIG_CMP_LEVELS & trig->action) { /* compare the levels of the counters */
cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
@ -182,17 +186,16 @@ int orte_gpr_replica_check_trig(orte_gpr_replica_triggers_t *trig)
for (i=0; i < (trig->counters)->size && fire; i++) {
if (NULL != cntr[i]) {
if (first) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_value((void*)&level, cntr[i]->iptr))) {
ORTE_ERROR_LOG(rc);
return rc;
}
base_value = cntr[i]->iptr;
first = false;
} else {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_value((void*)&level2, cntr[i]->iptr))) {
if (ORTE_SUCCESS != (rc =
orte_gpr_replica_compare_values(&cmp, base_value,
cntr[i]->iptr))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (level2 != level) {
if (0 != cmp) {
fire = false;
}
}
@ -215,17 +218,15 @@ int orte_gpr_replica_check_trig(orte_gpr_replica_triggers_t *trig)
fire = true;
for (i=0; i < (trig->counters)->size && fire; i++) {
if (NULL != cntr[i]) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_value(&level, cntr[i]->iptr))) {
if (ORTE_SUCCESS != (rc =
orte_gpr_replica_compare_values(&cmp, cntr[i]->iptr,
&(cntr[i]->trigger_level)))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_value(&level2, &(cntr[i]->trigger_level)))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (level2 != level) {
}
if (0 != cmp) {
fire = false;
}
}
}
}
if (fire) { /* all counters at specified trigger level */
@ -260,7 +261,8 @@ FIRED:
int orte_gpr_replica_purge_subscriptions(orte_process_name_t *proc)
{
orte_gpr_replica_triggers_t **trig;
int i, rc;
size_t i;
int rc;
/* locate any notification events that have proc as the recipient
*/

Просмотреть файл

@ -40,12 +40,12 @@
* typedefs needed in replica component
*/
#define ORTE_GPR_REPLICA_MAX_SIZE INT32_MAX
#define ORTE_GPR_REPLICA_MAX_SIZE SIZE_MAX
#define ORTE_GPR_REPLICA_BLOCK_SIZE 100
typedef int32_t orte_gpr_replica_itag_t;
#define ORTE_GPR_REPLICA_ITAG_MAX INT32_MAX
typedef size_t orte_gpr_replica_itag_t;
#define ORTE_GPR_REPLICA_ITAG_MAX SIZE_MAX
typedef uint8_t orte_gpr_replica_addr_mode_t;
@ -74,8 +74,8 @@ typedef int8_t orte_gpr_replica_action_t;
typedef struct {
int debug;
int isolate;
int32_t block_size;
int32_t max_size;
size_t block_size;
size_t max_size;
ompi_mutex_t mutex;
bool compound_cmd_mode;
bool exec_compound_cmd_mode;
@ -161,9 +161,9 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_segment_t);
*/
struct orte_gpr_replica_container_t {
ompi_object_t super; /**< Make this an object */
int index; /**< Location in the pointer array */
size_t index; /**< Location in the pointer array */
orte_gpr_replica_itag_t *itags; /**< Array of itags that define this container */
int num_itags; /**< Number of itags in array */
size_t num_itags; /**< Number of itags in array */
orte_pointer_array_t *itagvals; /**< Array of itagval pointers */
orte_value_array_t itaglist; /**< Array of itags from all itagvals - used for rapid search */
};
@ -176,7 +176,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_container_t);
*/
typedef struct {
ompi_object_t super; /**< required for this to be an object */
int index; /**< index of this itagval on the container array */
size_t index; /**< index of this itagval on the container array */
orte_gpr_replica_itag_t itag; /**< itag for this value's key */
orte_data_type_t type; /**< the type of value stored */
orte_gpr_value_union_t value; /**< Actual stored value */
@ -196,7 +196,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_counter_t);
typedef struct {
ompi_object_t super; /**< Makes this an object */
int index; /**< Index of this entry in original subscription */
size_t index; /**< Index of this entry in original subscription */
/* the segment upon which this data is located */
orte_gpr_replica_segment_t *seg;
/* describe the data to be returned with the message -
@ -216,7 +216,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_subscribed_data_t);
struct orte_gpr_replica_triggers_t {
ompi_object_t super; /**< Make this an object */
/* index of this trigger in the triggers array */
int index;
size_t index;
/* flag that indicates this trigger is a one-shot, has fired and
* now should be cleaned up
*/
@ -234,14 +234,14 @@ struct orte_gpr_replica_triggers_t {
* fires. for subscriptions that do not involve trigger events, these objects
* describe the data being monitored
*/
int num_subscribed_data;
size_t num_subscribed_data;
orte_pointer_array_t *subscribed_data;
/* for triggers, store a pointer to the counters being monitored. This could
* be counters we are using ourselves, or could be counters being run by someone
* else. Store the trigger level for each counter that we are monitoring until they reach
* a specified level (as opposed to comparing values in two or more counters).
*/
int num_counters;
size_t num_counters;
orte_pointer_array_t *counters;
};
typedef struct orte_gpr_replica_triggers_t orte_gpr_replica_triggers_t;

Просмотреть файл

@ -78,7 +78,6 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
orte_gpr_replica_index_nb,
/* GENERAL OPERATIONS */
orte_gpr_replica_preallocate_segment,
orte_gpr_replica_deliver_notify_msg,
/* ARITHMETIC OPERATIONS */
orte_gpr_replica_increment_value,
orte_gpr_replica_decrement_value,
@ -96,6 +95,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
orte_gpr_replica_dump_callbacks,
orte_gpr_replica_dump_notify_msg,
orte_gpr_replica_dump_notify_data,
orte_gpr_replica_dump_value,
/* CLEANUP OPERATIONS */
orte_gpr_replica_cleanup_job,
orte_gpr_replica_cleanup_proc
@ -138,7 +138,7 @@ static void orte_gpr_replica_segment_construct(orte_gpr_replica_segment_t* seg)
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_segment_destructor(orte_gpr_replica_segment_t* seg)
{
int i, j;
size_t i, j;
orte_gpr_replica_dict_t **dptr;
orte_gpr_replica_container_t **cptr;
@ -200,7 +200,7 @@ static void orte_gpr_replica_container_construct(orte_gpr_replica_container_t* r
static void orte_gpr_replica_container_destructor(orte_gpr_replica_container_t* reg)
{
orte_gpr_replica_itagval_t **ptr;
int i, j;
size_t i, j;
if (NULL != reg->itags) {
free(reg->itags);
@ -343,7 +343,7 @@ static void orte_gpr_replica_trigger_construct(orte_gpr_replica_triggers_t* trig
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_trigger_destructor(orte_gpr_replica_triggers_t* trig)
{
int i, j;
size_t i, j;
orte_gpr_replica_subscribed_data_t **data;
orte_gpr_replica_counter_t **cntrs;
@ -490,12 +490,14 @@ int orte_gpr_replica_open(void)
id = mca_base_param_register_int("gpr", "replica", "maxsize", NULL,
ORTE_GPR_REPLICA_MAX_SIZE);
mca_base_param_lookup_int(id, &orte_gpr_replica_globals.max_size);
mca_base_param_lookup_int(id, &tmp);
orte_gpr_replica_globals.max_size = (size_t)tmp;
id = mca_base_param_register_int("gpr", "replica", "blocksize", NULL,
ORTE_GPR_REPLICA_BLOCK_SIZE);
mca_base_param_lookup_int(id, &orte_gpr_replica_globals.block_size);
mca_base_param_lookup_int(id, &tmp);
orte_gpr_replica_globals.block_size = (size_t)tmp;
id = mca_base_param_register_int("gpr", "replica", "isolate", NULL, 0);
mca_base_param_lookup_int(id, &tmp);
if (tmp) {
@ -606,7 +608,7 @@ int orte_gpr_replica_module_init(void)
*/
int orte_gpr_replica_finalize(void)
{
int i, j;
size_t i, j;
orte_gpr_replica_segment_t** seg;
orte_gpr_replica_triggers_t** trig;
orte_gpr_replica_callbacks_t* cb;

Просмотреть файл

@ -37,7 +37,7 @@ orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
orte_gpr_replica_segment_t *seg, char *name)
{
orte_gpr_replica_dict_t **ptr, *new;
int i;
size_t i;
size_t len, len2;
/* default to illegal value */
@ -69,7 +69,7 @@ orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
return ORTE_ERR_OUT_OF_RESOURCE;
}
new->entry = strdup(name);
if (0 > (i = orte_pointer_array_add(seg->dict, (void*)new))) {
if (0 > orte_pointer_array_add(&i, seg->dict, (void*)new)) {
*itag = ORTE_GPR_REPLICA_ITAG_MAX;
free(new);
return ORTE_ERR_OUT_OF_RESOURCE;
@ -125,7 +125,7 @@ orte_gpr_replica_dict_lookup(orte_gpr_replica_itag_t *itag,
orte_gpr_replica_segment_t *seg, char *name)
{
orte_gpr_replica_dict_t **ptr;
int i;
size_t i;
size_t len, len2;
/* initialize to illegal value */
@ -202,10 +202,11 @@ int orte_gpr_replica_dict_reverse_lookup(char **name,
int
orte_gpr_replica_get_itag_list(orte_gpr_replica_itag_t **itaglist,
orte_gpr_replica_segment_t *seg, char **names,
int *num_names)
size_t *num_names)
{
char **namptr;
int rc, i;
int rc;
size_t i;
*itaglist = NULL;

Просмотреть файл

@ -31,7 +31,8 @@ int orte_gpr_replica_find_seg(orte_gpr_replica_segment_t **seg,
bool create, char *segment)
{
size_t len;
int rc, i;
int rc;
size_t i;
orte_gpr_replica_segment_t **ptr;
/* initialize to nothing */
@ -58,10 +59,10 @@ int orte_gpr_replica_find_seg(orte_gpr_replica_segment_t **seg,
/* add the segment to the registry */
*seg = OBJ_NEW(orte_gpr_replica_segment_t);
(*seg)->name = strdup(segment);
if (0 > (rc = orte_pointer_array_add(orte_gpr_replica.segments, (void*)(*seg)))) {
if (0 > orte_pointer_array_add(&i, orte_gpr_replica.segments, (void*)(*seg))) {
OBJ_RELEASE(*seg);
return rc;
}
(*seg)->itag = rc;
(*seg)->itag = i;
return ORTE_SUCCESS;
}

Просмотреть файл

@ -123,7 +123,7 @@ typedef int (*orte_gpr_replica_dict_reverse_lookup_fn_t)
*/
int orte_gpr_replica_get_itag_list(orte_gpr_replica_itag_t **itaglist,
orte_gpr_replica_segment_t *seg, char **names,
int *num_names);
size_t *num_names);
/**
* Typedef of the orte_gpr_replica_get_itag_list() function signature
@ -132,7 +132,7 @@ int orte_gpr_replica_get_itag_list(orte_gpr_replica_itag_t **itaglist,
typedef int (*orte_gpr_replica_get_itag_list_fn_t)
(orte_gpr_replica_itag_t **itaglist,
orte_gpr_replica_segment_t *seg, char **names,
int *num_names);
size_t *num_names);
/*

Просмотреть файл

@ -95,4 +95,10 @@ typedef struct orte_name_services_namelist_t orte_name_services_namelist_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_name_services_namelist_t);
/** Type name definitions for pack/unpack functions */
#define ORTE_NAME 23
#define ORTE_VPID 24
#define ORTE_JOBID 25
#define ORTE_CELLID 26
#endif

Просмотреть файл

@ -24,7 +24,7 @@
#include "include/orte_constants.h"
#include "include/orte_types.h"
#include "mca/mca.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/errmgr/errmgr.h"
#include "mca/rml/rml.h"

Просмотреть файл

@ -23,7 +23,7 @@
#include "include/orte_constants.h"
#include "threads/mutex.h"
#include "class/ompi_list.h"
#include "dps/dps.h"
#include "mca/dps/dps.h"
#include "mca/oob/oob_types.h"
#include "mca/ns/base/base.h"

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше