📄 dss_internal.h
字号:
/* -*- C -*- * * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2006 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ * */#ifndef ORTE_DSS_INTERNAL_H_#define ORTE_DSS_INTERNAL_H_#include "orte_config.h"#include "orte/orte_constants.h"#include "orte/class/orte_pointer_array.h"#include "orte/dss/dss.h"#if HAVE_STRING_H# if !defined(STDC_HEADERS) && HAVE_MEMORY_H# include <memory.h># endif# include <string.h>#endif#if defined(c_plusplus) || defined(__cplusplus)extern "C" {#endif/* * DEFINE THE DEFAULT PAGE SIZE FOR THE DSS BUFFERS - IN KILOBYTES */#define ORTE_DSS_DEFAULT_PAGE_SIZE 1/* * Internal type corresponding to size_t. Do not use this in * interface calls - use ORTE_SIZE instead. */#if SIZEOF_SIZE_T == 1#define DSS_TYPE_SIZE_T ORTE_UINT8#elif SIZEOF_SIZE_T == 2#define DSS_TYPE_SIZE_T ORTE_UINT16#elif SIZEOF_SIZE_T == 4#define DSS_TYPE_SIZE_T ORTE_UINT32#elif SIZEOF_SIZE_T == 8#define DSS_TYPE_SIZE_T ORTE_UINT64#else#error Unsupported size_t size!#endif/* * Internal type corresponding to bool. Do not use this in interface * calls - use ORTE_BOOL instead. */#if SIZEOF_BOOL == 1#define DSS_TYPE_BOOL ORTE_UINT8#elif SIZEOF_BOOL == 2#define DSS_TYPE_BOOL ORTE_UINT16#elif SIZEOF_BOOL == 4#define DSS_TYPE_BOOL ORTE_UINT32#elif SIZEOF_BOOL == 8#define DSS_TYPE_BOOL ORTE_UINT64#else#error Unsupported bool size!#endif/* * Internal type corresponding to int and unsigned int. Do not use * this in interface calls - use ORTE_INT / ORTE_UINT instead. */#if SIZEOF_INT == 1#define DSS_TYPE_INT ORTE_INT8#define DSS_TYPE_UINT ORTE_UINT8#elif SIZEOF_INT == 2#define DSS_TYPE_INT ORTE_INT16#define DSS_TYPE_UINT ORTE_UINT16#elif SIZEOF_INT == 4#define DSS_TYPE_INT ORTE_INT32#define DSS_TYPE_UINT ORTE_UINT32#elif SIZEOF_INT == 8#define DSS_TYPE_INT ORTE_INT64#define DSS_TYPE_UINT ORTE_UINT64#else#error Unsupported int size!#endif/* * Internal type corresponding to pid_t. Do not use this in interface * calls - use ORTE_PID instead. */#if SIZEOF_PID_T == 1#define DSS_TYPE_PID_T ORTE_UINT8#elif SIZEOF_PID_T == 2#define DSS_TYPE_PID_T ORTE_UINT16#elif SIZEOF_PID_T == 4#define DSS_TYPE_PID_T ORTE_UINT32#elif SIZEOF_PID_T == 8#define DSS_TYPE_PID_T ORTE_UINT64#else#error Unsupported pid_t size!#endif/* Unpack generic size macros */#define UNPACK_SIZE_MISMATCH(unpack_type, remote_type, ret) \do { \ switch(remote_type) { \ case ORTE_UINT8: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint8_t, remote_type); \ break; \ case ORTE_INT8: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int8_t, remote_type); \ break; \ case ORTE_UINT16: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint16_t, remote_type); \ break; \ case ORTE_INT16: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int16_t, remote_type); \ break; \ case ORTE_UINT32: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint32_t, remote_type); \ break; \ case ORTE_INT32: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int32_t, remote_type); \ break; \ case ORTE_UINT64: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint64_t, remote_type); \ break; \ case ORTE_INT64: \ UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int64_t, remote_type); \ break; \ default: \ ret = ORTE_ERR_NOT_FOUND; \ ORTE_ERROR_LOG(ret); \ } \} while (0) /* NOTE: do not need to deal with endianness here, as the unpacking ofthe underling sender-side type will do that for us. Repeat: thedata in tmpbuf[] is already in host byte order. */#define UNPACK_SIZE_MISMATCH_FOUND(unpack_type, tmptype, tmpdsstype) \do { \ orte_std_cntr_t i; \ tmptype *tmpbuf = (tmptype*)malloc(sizeof(tmptype) * (*num_vals)); \ ret = orte_dss_unpack_buffer(buffer, tmpbuf, num_vals, tmpdsstype); \ for (i = 0 ; i < *num_vals ; ++i) { \ ((unpack_type*) dest)[i] = (unpack_type)(tmpbuf[i]); \ } \ free(tmpbuf); \} while (0) /** * Internal struct used for holding registered dss functions */struct orte_dss_type_info_t { opal_object_t super; /* type identifier */ orte_data_type_t odti_type; /** Debugging string name */ char *odti_name; /** Pack function */ orte_dss_pack_fn_t odti_pack_fn; /** Unpack function */ orte_dss_unpack_fn_t odti_unpack_fn; /** copy function */ orte_dss_copy_fn_t odti_copy_fn; /** compare function */ orte_dss_compare_fn_t odti_compare_fn; /** size function */ orte_dss_size_fn_t odti_size_fn; /** print function */ orte_dss_print_fn_t odti_print_fn; /** Release function */ orte_dss_release_fn_t odti_release_fn; /** flag to indicate structured data */ bool odti_structured;};/** * Convenience typedef */typedef struct orte_dss_type_info_t orte_dss_type_info_t;ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_dss_type_info_t);/* * globals needed within dss */extern bool orte_dss_initialized;extern bool orte_dss_debug;extern int orte_dss_verbose;extern int orte_dss_page_size;extern orte_pointer_array_t *orte_dss_types;extern orte_data_type_t orte_dss_num_reg_types; /* * Implementations of API functions */ int orte_dss_set(orte_data_value_t *value, void *new_value, orte_data_type_t type); int orte_dss_get(void **data, orte_data_value_t *value, orte_data_type_t type); int orte_dss_arith(orte_data_value_t *value, orte_data_value_t *operand, orte_dss_arith_op_t operation); int orte_dss_increment(orte_data_value_t *value); int orte_dss_decrement(orte_data_value_t *value); int orte_dss_set_buffer_type(orte_buffer_t *buffer, orte_dss_buffer_type_t type); int orte_dss_pack(orte_buffer_t *buffer, void *src, orte_std_cntr_t num_vals, orte_data_type_t type); int orte_dss_unpack(orte_buffer_t *buffer, void *dest, orte_std_cntr_t *max_num_vals, orte_data_type_t type); int orte_dss_copy(void **dest, void *src, orte_data_type_t type); int orte_dss_compare(void *value1, void *value2, orte_data_type_t type); int orte_dss_print(char **output, char *prefix, void *src, orte_data_type_t type); int orte_dss_dump(int output_stream, void *src, orte_data_type_t type); int orte_dss_size(size_t *size, void *src, orte_data_type_t type); int orte_dss_peek(orte_buffer_t *buffer, orte_data_type_t *type, orte_std_cntr_t *number);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -