From 6f92675c5623aceab97c768ca8e7e2bc59895981 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Fri, 22 Apr 2005 04:46:01 +0000 Subject: [PATCH] Get rid of dt_desc_t and use exclusively ompi_datatype_t. Correctly place the const on the functions prototypes and adapt all file to match the new prototypes. This commit was SVN r5484. --- src/datatype/datatype.h | 71 ++++++++++++++++---------------- src/datatype/dt_add.c | 2 +- src/datatype/dt_create.c | 10 ++--- src/datatype/dt_create_array.c | 6 +-- src/datatype/dt_create_indexed.c | 12 +++--- src/datatype/dt_destroy.c | 4 +- 6 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/datatype/datatype.h b/src/datatype/datatype.h index 78299b1300..c9e2445ae5 100644 --- a/src/datatype/datatype.h +++ b/src/datatype/datatype.h @@ -84,7 +84,7 @@ typedef struct __dt_elem_desc { uint16_t type; /**< the basic data type id */ uint32_t count; /**< number of elements */ long disp; /**< displacement of the first element */ - uint32_t extent; /**< extent of each element */ + int32_t extent; /**< extent of each element */ } dt_elem_desc_t; typedef struct __dt_struct_desc { @@ -121,69 +121,69 @@ typedef struct ompi_datatype_t { /* basic elements count used to compute the size of the datatype for * remote nodes */ uint32_t btypes[DT_MAX_PREDEFINED]; -} dt_desc_t, ompi_datatype_t; +} ompi_datatype_t; OBJ_CLASS_DECLARATION( ompi_datatype_t ); int32_t ompi_ddt_init( void ); int32_t ompi_ddt_finalize( void ); -dt_desc_t* ompi_ddt_create( int32_t expectedSize ); -int32_t ompi_ddt_commit( dt_desc_t** ); -int32_t ompi_ddt_destroy( dt_desc_t** ); +ompi_datatype_t* ompi_ddt_create( int32_t expectedSize ); +int32_t ompi_ddt_commit( ompi_datatype_t** ); +int32_t ompi_ddt_destroy( ompi_datatype_t** ); static inline int32_t ompi_ddt_is_committed( const ompi_datatype_t* type ) { return ((type->flags & DT_FLAG_COMMITED) == DT_FLAG_COMMITED); } static inline int32_t ompi_ddt_is_overlapped( const ompi_datatype_t* type ) { return ((type->flags & DT_FLAG_OVERLAP) == DT_FLAG_OVERLAP); } static inline int32_t ompi_ddt_is_acceptable_for_one_sided( const ompi_datatype_t* type ) { return ((type->flags & DT_FLAG_ONE_SIDED) == DT_FLAG_ONE_SIDED); } -void ompi_ddt_dump( const dt_desc_t* pData ); +void ompi_ddt_dump( const ompi_datatype_t* pData ); /* data creation functions */ -OMPI_DECLSPEC int32_t ompi_ddt_duplicate( const dt_desc_t* oldType, dt_desc_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_create_contiguous( int count, const dt_desc_t* oldType, dt_desc_t** newType ); +OMPI_DECLSPEC int32_t ompi_ddt_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** newType ); +OMPI_DECLSPEC int32_t ompi_ddt_create_contiguous( int count, const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_vector( int count, int bLength, long stride, - const dt_desc_t* oldType, dt_desc_t** newType ); + const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_hvector( int count, int bLength, long stride, - const dt_desc_t* oldType, dt_desc_t** newType ); + const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ); + const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ); + const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_indexed_block( int count, int bLength, const int* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ); + const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp, - const dt_desc_t** pTypes, dt_desc_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_create_resized( const dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType ); + ompi_datatype_t* const* pTypes, ompi_datatype_t** newType ); +OMPI_DECLSPEC int32_t ompi_ddt_create_resized( const ompi_datatype_t* oldType, long lb, long extent, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_subarray( int ndims, const int* pSizes, const int* pSubSizes, const int* pStarts, - int order, const dt_desc_t* oldType, dt_desc_t** newType ); + int order, const ompi_datatype_t* oldType, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_create_darray( int size, int rank, int ndims, const int* pGSizes, const int *pDistrib, const int* pDArgs, const int* pPSizes, - int order, const dt_desc_t* oldType, - dt_desc_t** newType ); + int order, const ompi_datatype_t* oldType, + ompi_datatype_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_add( dt_desc_t* pdtBase, const dt_desc_t* pdtAdd, uint32_t count, +OMPI_DECLSPEC int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, uint32_t count, long disp, long extent ); -static inline int32_t ompi_ddt_type_lb( const dt_desc_t* pData, long* disp ) +static inline int32_t ompi_ddt_type_lb( const ompi_datatype_t* pData, long* disp ) { *disp = pData->lb; return 0; } -static inline int32_t ompi_ddt_type_ub( const dt_desc_t* pData, long* disp ) +static inline int32_t ompi_ddt_type_ub( const ompi_datatype_t* pData, long* disp ) { *disp = pData->ub; return 0; } -static inline int32_t ompi_ddt_type_size ( const dt_desc_t* pData, int32_t *size ) +static inline int32_t ompi_ddt_type_size ( const ompi_datatype_t* pData, int32_t *size ) { *size = pData->size; return 0; } -static inline int32_t ompi_ddt_type_extent( const dt_desc_t* pData, long* extent ) +static inline int32_t ompi_ddt_type_extent( const ompi_datatype_t* pData, long* extent ) { *extent = (pData->ub - pData->lb); return 0; } -static inline int32_t ompi_ddt_get_extent( const dt_desc_t* pData, long* lb, long* extent) +static inline int32_t ompi_ddt_get_extent( const ompi_datatype_t* pData, long* lb, long* extent) { *lb = pData->lb; *extent = pData->ub - pData->lb; return 0; } -static inline int32_t ompi_ddt_get_true_extent( const dt_desc_t* pData, long* true_lb, long* true_extent) +static inline int32_t ompi_ddt_get_true_extent( const ompi_datatype_t* pData, long* true_lb, long* true_extent) { *true_lb = pData->true_lb; *true_extent = (pData->true_ub - pData->true_lb); return 0; } -OMPI_DECLSPEC int32_t ompi_ddt_get_element_count( const dt_desc_t* pData, int32_t iSize ); -OMPI_DECLSPEC int32_t ompi_ddt_copy_content_same_ddt( const dt_desc_t* pData, int32_t count, +OMPI_DECLSPEC int32_t ompi_ddt_get_element_count( const ompi_datatype_t* pData, int32_t iSize ); +OMPI_DECLSPEC int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* pData, int32_t count, char* pDestBuf, const char* pSrcBuf ); -OMPI_DECLSPEC int32_t ompi_ddt_optimize_short( dt_desc_t* pData, int32_t count, dt_type_desc_t* pTypeDesc ); +OMPI_DECLSPEC int32_t ompi_ddt_optimize_short( ompi_datatype_t* pData, int32_t count, dt_type_desc_t* pTypeDesc ); OMPI_DECLSPEC const ompi_datatype_t* ompi_ddt_match_size( int size, uint16_t datakind, uint16_t datalang ); typedef int32_t (*conversion_fct_t)( uint32_t count, @@ -210,7 +210,7 @@ struct ompi_convertor_t { ompi_object_t super; /**< basic superclass */ uint32_t remoteArch; /**< the remote architecture */ uint32_t flags; /**< the properties of this convertor */ - dt_desc_t* pDesc; /**< the datatype description associated with the convertor */ + ompi_datatype_t* pDesc; /**< the datatype description associated with the convertor */ uint32_t count; /**< the total number of full datatype elements */ char* pBaseBuf; /**< initial buffer as supplied by the user */ dt_stack_t* pStack; /**< the local stack for the actual conversion */ @@ -242,7 +242,7 @@ static inline int32_t ompi_convertor_pack( ompi_convertor_t* pConv, *max_data = 0; return 1; /* nothing to do */ } - + assert( pConv->bConverted < (pConv->pDesc->size * pConv->count) ); /* We dont allocate any memory. The packing function should allocate it * if it need. If it's possible to find iovec in the derived datatype * description then we dont have to allocate any memory. @@ -254,7 +254,7 @@ static inline int32_t ompi_convertor_unpack( ompi_convertor_t* pConv, struct iovec* iov, uint32_t* out_size, uint32_t* max_data, int32_t* freeAfter ) { - dt_desc_t *pData = pConv->pDesc; + ompi_datatype_t *pData = pConv->pDesc; uint32_t length; /* protect against over unpacking data */ @@ -277,6 +277,7 @@ static inline int32_t ompi_convertor_unpack( ompi_convertor_t* pConv, return (pConv->bConverted == (pData->size * pConv->count)); } } + assert( pConv->bConverted < (pConv->pDesc->size * pConv->count) ); return pConv->fAdvance( pConv, iov, out_size, max_data, freeAfter ); } @@ -286,11 +287,11 @@ extern ompi_convertor_t* ompi_mpi_external32_convertor; /* and finally the convertor functions */ OMPI_DECLSPEC ompi_convertor_t* ompi_convertor_create( int32_t remote_arch, int32_t mode ); OMPI_DECLSPEC int32_t ompi_convertor_init_for_send( ompi_convertor_t* pConv, uint32_t flags, - const dt_desc_t* pData, int32_t count, + const ompi_datatype_t* pData, int32_t count, const void* pUserBuf, int32_t local_starting_point, memalloc_fct_t allocfn ); OMPI_DECLSPEC int32_t ompi_convertor_init_for_recv( ompi_convertor_t* pConv, uint32_t flags, - const dt_desc_t* pData, int32_t count, + const ompi_datatype_t* pData, int32_t count, const void* pUserBuf, int32_t remote_starting_point, memalloc_fct_t allocfn ); OMPI_DECLSPEC int32_t ompi_convertor_need_buffers( ompi_convertor_t* pConvertor ); @@ -321,11 +322,11 @@ static inline ompi_convertor_t* ompi_convertor_get_copy( const ompi_convertor_t* } /* temporary function prototypes. They should move in other place later. */ -OMPI_DECLSPEC int32_t ompi_ddt_get_args( const dt_desc_t* pData, int32_t which, +OMPI_DECLSPEC int32_t ompi_ddt_get_args( const ompi_datatype_t* pData, int32_t which, int32_t * ci, int32_t * i, int32_t * ca, long* a, int32_t * cd, ompi_datatype_t** d, int32_t * type); -OMPI_DECLSPEC int32_t ompi_ddt_set_args( dt_desc_t* pData, +OMPI_DECLSPEC int32_t ompi_ddt_set_args( ompi_datatype_t* pData, int32_t ci, int32_t ** i, int32_t ca, long* a, int32_t cd, ompi_datatype_t** d,int32_t type); diff --git a/src/datatype/dt_add.c b/src/datatype/dt_add.c index 7fe948e1c4..548c5d1395 100644 --- a/src/datatype/dt_add.c +++ b/src/datatype/dt_add.c @@ -33,7 +33,7 @@ * be sure that the pdtBase datatype is correctly initialized with all fields * set to ZERO if it's a empty datatype. */ -int32_t ompi_ddt_add( dt_desc_t* pdtBase, const dt_desc_t* pdtAdd, +int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, uint32_t count, long disp, long extent ) { uint32_t newLength, place_needed = 0, i; diff --git a/src/datatype/dt_create.c b/src/datatype/dt_create.c index 257b6c4930..c2dc78e674 100644 --- a/src/datatype/dt_create.c +++ b/src/datatype/dt_create.c @@ -21,7 +21,7 @@ #include "limits.h" #include "attribute/attribute.h" -static void __get_free_dt_struct( dt_desc_t* pData ) +static void __get_free_dt_struct( ompi_datatype_t* pData ) { int i; @@ -47,7 +47,7 @@ static void __get_free_dt_struct( dt_desc_t* pData ) pData->d_keyhash = NULL; } -static void __destroy_ddt_struct( dt_desc_t* pData ) +static void __destroy_ddt_struct( ompi_datatype_t* pData ) { if( pData->desc.desc != NULL ) free( pData->desc.desc ); pData->desc.desc = NULL; @@ -72,9 +72,9 @@ static void __destroy_ddt_struct( dt_desc_t* pData ) OBJ_CLASS_INSTANCE(ompi_datatype_t, ompi_object_t, __get_free_dt_struct, __destroy_ddt_struct ); -dt_desc_t* ompi_ddt_create( int32_t expectedSize ) +ompi_datatype_t* ompi_ddt_create( int32_t expectedSize ) { - dt_desc_t* pdt = (dt_desc_t*)OBJ_NEW(ompi_datatype_t); + ompi_datatype_t* pdt = (ompi_datatype_t*)OBJ_NEW(ompi_datatype_t); if( expectedSize == -1 ) expectedSize = DT_INCREASE_STACK; pdt->desc.length = expectedSize + 1; /* one for the fake elem at the end */ @@ -84,7 +84,7 @@ dt_desc_t* ompi_ddt_create( int32_t expectedSize ) return pdt; } -int32_t ompi_ddt_create_resized( const dt_desc_t* oldType, long lb, long extent, dt_desc_t** newType ) +int32_t ompi_ddt_create_resized( const ompi_datatype_t* oldType, long lb, long extent, ompi_datatype_t** newType ) { ompi_ddt_duplicate( oldType, newType ); (*newType)->lb = lb; diff --git a/src/datatype/dt_create_array.c b/src/datatype/dt_create_array.c index bc4c80693c..78de1b07c2 100644 --- a/src/datatype/dt_create_array.c +++ b/src/datatype/dt_create_array.c @@ -19,14 +19,14 @@ #include "datatype/datatype.h" int32_t ompi_ddt_create_subarray( int ndims, const int* pSizes, const int* pSubSizes, const int* pStarts, - int order, const dt_desc_t* oldType, dt_desc_t** newType ) + int order, const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { return OMPI_ERR_NOT_IMPLEMENTED; } int32_t ompi_ddt_create_darray( int size, int rank, int ndims, const int* pGSizes, const int *pDistrib, - const int* pDArgs, const int* pPSizes, int order, const dt_desc_t* oldType, - dt_desc_t** newType ) + const int* pDArgs, const int* pPSizes, int order, const ompi_datatype_t* oldType, + ompi_datatype_t** newType ) { return OMPI_ERR_NOT_IMPLEMENTED; } diff --git a/src/datatype/dt_create_indexed.c b/src/datatype/dt_create_indexed.c index 51be45ba60..547fdb430e 100644 --- a/src/datatype/dt_create_indexed.c +++ b/src/datatype/dt_create_indexed.c @@ -20,9 +20,9 @@ /* We try to merge together data that are contiguous */ int32_t ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ) + const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { - dt_desc_t* pdt; + ompi_datatype_t* pdt; int i, dLength, endat, disp; long extent = oldType->ub - oldType->lb; @@ -55,9 +55,9 @@ int32_t ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* } int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ) + const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { - dt_desc_t* pdt; + ompi_datatype_t* pdt; int i, dLength; long extent = oldType->ub - oldType->lb; long disp, endat; @@ -90,9 +90,9 @@ int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long } int32_t ompi_ddt_create_indexed_block( int count, int bLength, const int* pDisp, - const dt_desc_t* oldType, dt_desc_t** newType ) + const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { - dt_desc_t* pdt; + ompi_datatype_t* pdt; int i, dLength, endat, disp; long extent = oldType->ub - oldType->lb; diff --git a/src/datatype/dt_destroy.c b/src/datatype/dt_destroy.c index 12aac55b74..c959923339 100644 --- a/src/datatype/dt_destroy.c +++ b/src/datatype/dt_destroy.c @@ -19,9 +19,9 @@ #include "datatype/datatype.h" #include "datatype/datatype_internal.h" -int32_t ompi_ddt_destroy( dt_desc_t** dt ) +int32_t ompi_ddt_destroy( ompi_datatype_t** dt ) { - dt_desc_t* pData = *dt; + ompi_datatype_t* pData = *dt; if( pData->flags & DT_FLAG_FOREVER ) return OMPI_ERROR;