diff --git a/ompi/datatype/convertor.c b/ompi/datatype/convertor.c index 5b67ab8208..8f2183ba17 100644 --- a/ompi/datatype/convertor.c +++ b/ompi/datatype/convertor.c @@ -31,7 +31,7 @@ #include "ompi/datatype/convertor_internal.h" #include "ompi/datatype/dt_arch.h" -extern int ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; +extern size_t ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; extern int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* convertor, int starting_point, const int* sizes ); @@ -82,7 +82,7 @@ ompi_convertor_find_or_create_master( uint32_t remote_arch ) { ompi_convertor_master_t* master = ompi_convertor_master_list; int i; - int32_t* remote_sizes; + size_t* remote_sizes; while( NULL != master ) { if( master->remote_arch == remote_arch ) @@ -102,7 +102,7 @@ ompi_convertor_find_or_create_master( uint32_t remote_arch ) * the local ones. As master->remote_sizes is defined as being an array of * consts we have to manually cast it before using it for writing purposes. */ - remote_sizes = (int32_t*)master->remote_sizes; + remote_sizes = (size_t*)master->remote_sizes; for( i = DT_CHAR; i < DT_MAX_PREDEFINED; i++ ) { remote_sizes[i] = ompi_ddt_local_sizes[i]; } @@ -284,10 +284,6 @@ int32_t ompi_convertor_unpack( ompi_convertor_t* pConv, uint32_t i; char* base_pointer; - /*opal_output( 0, "ompi_convertor_unpack at %p max_data %ld bConverted %ld size %ld count %d\n", - pConv->pBaseBuf, (long)*max_data, (long)pConv->bConverted, - (long)pConv->local_size, pConv->count ); - ompi_ddt_dump( pConv->pDesc );*/ *max_data = pConv->bConverted; base_pointer = pConv->pBaseBuf + pConv->bConverted + pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; @@ -314,23 +310,19 @@ int32_t ompi_convertor_unpack( ompi_convertor_t* pConv, pConv->flags |= CONVERTOR_COMPLETED; return 1; } - /*opal_output( 0, "ompi_convertor_unpack generic at %p max_data %ld bConverted %ld size %ld count %d\n", - pConv->pBaseBuf, (long)*max_data, (long)pConv->bConverted, - (long)pConv->local_size, pConv->count ); - ompi_ddt_dump( pConv->pDesc );*/ return pConv->fAdvance( pConv, iov, out_size, max_data, freeAfter ); } static inline int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor, - int starting_point, const int* sizes ) + size_t starting_point, const size_t* sizes ) { dt_stack_t* pStack; /* pointer to the position on the stack */ const ompi_datatype_t* pData = pConvertor->pDesc; dt_elem_desc_t* pElems; uint32_t count; - long extent; + ptrdiff_t extent; pStack = pConvertor->pStack; /* The prepare function already make the selection on which data representation @@ -338,17 +330,16 @@ int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor, */ pElems = pConvertor->use_desc->desc; - count = starting_point / pData->size; + count = (uint32_t)(starting_point / pData->size); extent = pData->ub - pData->lb; pStack[0].type = DT_LOOP; /* the first one is always the loop */ pStack[0].count = pConvertor->count - count; pStack[0].index = -1; - pStack[0].end_loop = pConvertor->use_desc->used; pStack[0].disp = count * extent; /* now compute the number of pending bytes */ - count = starting_point - count * pData->size; + count = (uint32_t)(starting_point - count * pData->size); /* we save the current displacement starting from the begining * of this data. */ @@ -362,7 +353,6 @@ int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor, pStack[1].disp = pData->true_lb + count; } pStack[1].index = 0; /* useless */ - pStack[1].end_loop = 0; /* useless */ pConvertor->bConverted = starting_point; pConvertor->stack_pos = 1; @@ -372,7 +362,7 @@ int ompi_convertor_create_stack_with_pos_contig( ompi_convertor_t* pConvertor, static inline int ompi_convertor_create_stack_at_begining( ompi_convertor_t* convertor, - const int* sizes ) + const size_t* sizes ) { dt_stack_t* pStack = convertor->pStack; dt_elem_desc_t* pElems; @@ -387,7 +377,6 @@ int ompi_convertor_create_stack_at_begining( ompi_convertor_t* convertor, pStack[0].index = -1; pStack[0].count = convertor->count; pStack[0].disp = 0; - pStack[0].end_loop = convertor->use_desc->used; /* The prepare function already make the selection on which data representation * we have to use: normal one or the optimized version ? */ @@ -395,7 +384,6 @@ int ompi_convertor_create_stack_at_begining( ompi_convertor_t* convertor, pStack[1].index = 0; pStack[1].disp = 0; - pStack[1].end_loop = 0; if( pElems[0].elem.common.type == DT_LOOP ) { pStack[1].count = pElems[0].loop.loops; } else { @@ -555,7 +543,7 @@ ompi_convertor_prepare_for_send( ompi_convertor_t* convertor, if( convertor->flags & CONVERTOR_WITH_CHECKSUM ) { if( datatype->flags & DT_FLAG_CONTIGUOUS ) { - if( ((datatype->ub - datatype->lb) == (long)datatype->size) + if( ((datatype->ub - datatype->lb) == (ptrdiff_t)datatype->size) || (1 >= convertor->count) ) convertor->fAdvance = ompi_pack_homogeneous_contig_checksum; else @@ -565,7 +553,7 @@ ompi_convertor_prepare_for_send( ompi_convertor_t* convertor, } } else { if( datatype->flags & DT_FLAG_CONTIGUOUS ) { - if( ((datatype->ub - datatype->lb) == (long)datatype->size) + if( ((datatype->ub - datatype->lb) == (ptrdiff_t)datatype->size) || (1 >= convertor->count) ) convertor->fAdvance = ompi_pack_homogeneous_contig; else @@ -641,8 +629,8 @@ void ompi_ddt_dump_stack( const dt_stack_t* pStack, int stack_pos, { opal_output( 0, "\nStack %p stack_pos %d name %s\n", (void*)pStack, stack_pos, name ); for( ; stack_pos >= 0; stack_pos-- ) { - opal_output( 0, "%d: pos %d count %d disp %ld end_loop %d ", stack_pos, pStack[stack_pos].index, - pStack[stack_pos].count, pStack[stack_pos].disp, pStack[stack_pos].end_loop ); + opal_output( 0, "%d: pos %d count %d disp %ld ", stack_pos, pStack[stack_pos].index, + pStack[stack_pos].count, pStack[stack_pos].disp ); if( pStack->index != -1 ) opal_output( 0, "\t[desc count %d disp %ld extent %d]\n", pDesc[pStack[stack_pos].index].elem.count, diff --git a/ompi/datatype/convertor.h b/ompi/datatype/convertor.h index 6c42d90ad7..26224069dc 100644 --- a/ompi/datatype/convertor.h +++ b/ompi/datatype/convertor.h @@ -64,11 +64,10 @@ typedef void*(*memalloc_fct_t)( size_t* pLength, void* userdata ); struct ompi_convertor_master_t; typedef struct dt_stack { - int16_t index; /**< index in the element description */ - int16_t type; /**< the type used for the last pack/unpack (original or DT_BYTE) */ - int32_t count; /**< number of times we still have to do it */ - int32_t end_loop; /**< for loops the end of the loop, otherwise useless */ - long disp; /**< actual displacement depending on the count field */ + int16_t index; /**< index in the element description */ + int16_t type; /**< the type used for the last pack/unpack (original or DT_BYTE) */ + size_t count; /**< number of times we still have to do it */ + ptrdiff_t disp; /**< actual displacement depending on the count field */ } dt_stack_t; /** @@ -99,7 +98,7 @@ struct ompi_convertor_t { uint32_t partial_length; /**< amount of data left over from the last unpack */ uint32_t checksum; /**< checksum computed by pack/unpack operation */ uint32_t csum_ui1; /**< partial checksum computed by pack/unpack operation */ - uint32_t csum_ui2; /**< partial checksum computed by pack/unpack operation */ + size_t csum_ui2; /**< partial checksum computed by pack/unpack operation */ dt_stack_t static_stack[DT_STATIC_STACK_SIZE]; /**< local stack for small datatypes */ }; OMPI_DECLSPEC OBJ_CLASS_DECLARATION( ompi_convertor_t ); diff --git a/ompi/datatype/convertor_internal.h b/ompi/datatype/convertor_internal.h index dca5f2d903..f4e265b869 100644 --- a/ompi/datatype/convertor_internal.h +++ b/ompi/datatype/convertor_internal.h @@ -18,16 +18,16 @@ #include "ompi/datatype/convertor.h" typedef int32_t (*conversion_fct_t)( ompi_convertor_t* pConvertor, uint32_t count, - const void* from, uint32_t from_len, long from_extent, - void* to, uint32_t to_length, long to_extent, - uint32_t *advance ); + const void* from, size_t from_len, ptrdiff_t from_extent, + void* to, size_t to_length, ptrdiff_t to_extent, + ptrdiff_t *advance ); typedef struct ompi_convertor_master_t { struct ompi_convertor_master_t* next; uint32_t remote_arch; uint32_t flags; uint64_t hetero_mask; - const int32_t remote_sizes[DT_MAX_PREDEFINED]; + const size_t remote_sizes[DT_MAX_PREDEFINED]; conversion_fct_t* pFunctions; /**< the convertor functions pointer */ } ompi_convertor_master_t; diff --git a/ompi/datatype/copy_functions.c b/ompi/datatype/copy_functions.c index 22c296f501..67e9ced2c0 100644 --- a/ompi/datatype/copy_functions.c +++ b/ompi/datatype/copy_functions.c @@ -31,19 +31,19 @@ * * Return value: Number of elements of type TYPE copied */ -#define COPY_TYPE( TYPENAME, TYPE, COUNT ) \ -static int copy_##TYPENAME( ompi_convertor_t *pConvertor, uint32_t count, \ - char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_len, long to_extent, \ - uint32_t *advance) \ +#define COPY_TYPE( TYPENAME, TYPE, COUNT ) \ +static int copy_##TYPENAME( ompi_convertor_t *pConvertor, uint32_t count, \ + char* from, size_t from_len, ptrdiff_t from_extent, \ + char* to, size_t to_len, ptrdiff_t to_extent, \ + ptrdiff_t *advance) \ { \ uint32_t i; \ - uint32_t remote_TYPE_size = sizeof(TYPE) * (COUNT); /* TODO */ \ - uint32_t local_TYPE_size = (COUNT) * sizeof(TYPE); \ + size_t remote_TYPE_size = sizeof(TYPE) * (COUNT); /* TODO */ \ + size_t local_TYPE_size = (COUNT) * sizeof(TYPE); \ \ /* make sure the remote buffer is large enough to hold the data */ \ if( (remote_TYPE_size * count) > from_len ) { \ - count = from_len / remote_TYPE_size; \ + count = (uint32_t)(from_len / remote_TYPE_size); \ if( (count * remote_TYPE_size) != from_len ) { \ DUMP( "oops should I keep this data somewhere (excedent %d bytes)?\n", \ from_len - (count * remote_TYPE_size) ); \ @@ -54,8 +54,8 @@ static int copy_##TYPENAME( ompi_convertor_t *pConvertor, uint32_t count, \ DUMP( " copy %s count %d from buffer %p with length %d to %p space %d\n", \ #TYPE, count, from, from_len, to, to_len ); \ \ - if( (from_extent == (long)local_TYPE_size) && \ - (to_extent == (long)remote_TYPE_size) ) { \ + if( (from_extent == (ptrdiff_t)local_TYPE_size) && \ + (to_extent == (ptrdiff_t)remote_TYPE_size) ) { \ /* copy of contigous data at both source and destination */ \ MEMCPY( to, from, count * local_TYPE_size ); \ } else { \ @@ -84,18 +84,18 @@ static int copy_##TYPENAME( ompi_convertor_t *pConvertor, uint32_t count, \ * * Return value: Number of elements of type TYPE copied */ -#define COPY_CONTIGUOUS_BYTES( TYPENAME, COUNT ) \ -static int copy_##TYPENAME##_##COUNT( ompi_convertor_t *pConvertor, uint32_t count, \ - char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_len, long to_extent, \ - uint32_t *advance) \ +#define COPY_CONTIGUOUS_BYTES( TYPENAME, COUNT ) \ +static int copy_##TYPENAME##_##COUNT( ompi_convertor_t *pConvertor, uint32_t count, \ + char* from, size_t from_len, ptrdiff_t from_extent, \ + char* to, size_t to_len, ptrdiff_t to_extent, \ + ptrdiff_t *advance ) \ { \ uint32_t i; \ - uint32_t remote_TYPE_size = (COUNT); /* TODO */ \ - uint32_t local_TYPE_size = (COUNT); \ + size_t remote_TYPE_size = (size_t)(COUNT); /* TODO */ \ + size_t local_TYPE_size = (size_t)(COUNT); \ \ if( (remote_TYPE_size * count) > from_len ) { \ - count = from_len / remote_TYPE_size; \ + count = (uint32_t)(from_len / remote_TYPE_size); \ if( (count * remote_TYPE_size) != from_len ) { \ DUMP( "oops should I keep this data somewhere (excedent %d bytes)?\n", \ from_len - (count * remote_TYPE_size) ); \ @@ -106,8 +106,8 @@ static int copy_##TYPENAME##_##COUNT( ompi_convertor_t *pConvertor, uint32_t cou DUMP( " copy %s count %d from buffer %p with length %d to %p space %d\n", \ #TYPENAME, count, from, from_len, to, to_len ); \ \ - if( (from_extent == (long)local_TYPE_size) && \ - (to_extent == (long)remote_TYPE_size) ) { \ + if( (from_extent == (ptrdiff_t)local_TYPE_size) && \ + (to_extent == (ptrdiff_t)remote_TYPE_size) ) { \ MEMCPY( to, from, count * local_TYPE_size ); \ } else { \ for( i = 0; i < count; i++ ) { \ diff --git a/ompi/datatype/copy_functions_heterogeneous.c b/ompi/datatype/copy_functions_heterogeneous.c index 4f11ef2e04..4d85b6aa00 100644 --- a/ompi/datatype/copy_functions_heterogeneous.c +++ b/ompi/datatype/copy_functions_heterogeneous.c @@ -23,22 +23,23 @@ #include "ompi/datatype/convertor_internal.h" static inline void -ompi_dt_swap_bytes(void *to_p, const void *from_p, const long size) +ompi_dt_swap_bytes(void *to_p, const void *from_p, const size_t size) { - int i; + size_t i, back_i; uint8_t *to = (uint8_t*) to_p, *from = (uint8_t*) from_p; - for (i = 0 ; i < size ; i++) { - to[size - 1 - i] = from[i]; + back_i = size - 1; + for (i = 0 ; i < size ; i++, back_i--) { + to[back_i] = from[i]; } } -#define COPY_TYPE_HETEROGENEOUS( TYPENAME, TYPE ) \ -static int32_t \ -copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ - const char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_length, long to_extent, \ - uint32_t *advance) \ +#define COPY_TYPE_HETEROGENEOUS( TYPENAME, TYPE ) \ +static int32_t \ +copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ + const char* from, size_t from_len, ptrdiff_t from_extent, \ + char* to, size_t to_length, ptrdiff_t to_extent, \ + ptrdiff_t *advance) \ { \ uint32_t i; \ \ @@ -53,8 +54,8 @@ copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ to += to_extent; \ from += from_extent; \ } \ - } else if (sizeof(TYPE) == to_extent && \ - sizeof(TYPE) == from_extent) { \ + } else if ((ptrdiff_t)sizeof(TYPE) == to_extent && \ + (ptrdiff_t)sizeof(TYPE) == from_extent) { \ MEMCPY( to, from, count * sizeof(TYPE) ); \ } else { \ /* source or destination are non-contigous */ \ @@ -72,8 +73,8 @@ copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ #define COPY_2TYPE_HETEROGENEOUS( TYPENAME, TYPE1, TYPE2 ) \ static int32_t \ copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ - const char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_length, long to_extent, \ + const char* from, uint32_t from_len, ptrdiff_t from_extent, \ + char* to, uint32_t to_length, ptrdiff_t to_extent, \ uint32_t *advance) \ { \ uint32_t i; \ @@ -96,8 +97,8 @@ copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ to += to_extent; \ from += from_extent; \ } \ - } else if (sizeof(TYPE1) + sizeof(TYPE2) == to_extent && \ - sizeof(TYPE1) + sizeof(TYPE2) == from_extent) { \ + } else if ((ptrdiff_t)(sizeof(TYPE1) + sizeof(TYPE2)) == to_extent && \ + (ptrdiff_t)(sizeof(TYPE1) + sizeof(TYPE2)) == from_extent) { \ /* source and destination are contigous */ \ MEMCPY( to, from, count * (sizeof(TYPE1) + sizeof(TYPE2)) ); \ } else { \ @@ -120,8 +121,8 @@ copy_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ #define COPY_2COMPLEX_HETEROGENEOUS( TYPENAME, TYPE ) \ static int32_t \ copy_2complex_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, \ - const char* from, uint32_t from_len, long from_extent, \ - char* to, uint32_t to_length, long to_extent, \ + const char* from, uint32_t from_len, ptrdiff_t from_extent, \ + char* to, uint32_t to_length, ptrdiff_t to_extent, \ uint32_t *advance) \ { \ uint32_t i; \ @@ -161,13 +162,13 @@ copy_2complex_##TYPENAME##_heterogeneous(ompi_convertor_t *pConvertor, uint32_t static inline void -datatype_check(char *type, uint32_t local_size, uint32_t remote_size, uint32_t *count, - const char* from, uint32_t from_len, long from_extent, - char* to, uint32_t to_len, long to_extent) +datatype_check(char *type, size_t local_size, size_t remote_size, uint32_t *count, + const char* from, size_t from_len, ptrdiff_t from_extent, + char* to, size_t to_len, ptrdiff_t to_extent) { /* make sure the remote buffer is large enough to hold the data */ if( (remote_size * *count) > from_len ) { - *count = from_len / remote_size; + *count = (uint32_t)(from_len / remote_size); if( (*count * remote_size) != from_len ) { DUMP( "oops should I keep this data somewhere (excedent %d bytes)?\n", from_len - (*count * remote_size) ); @@ -184,8 +185,8 @@ datatype_check(char *type, uint32_t local_size, uint32_t remote_size, uint32_t * /* char has no endian issues, so don't really worry about it */ static int32_t copy_char_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, - const char* from, uint32_t from_len, long from_extent, - char* to, uint32_t to_length, long to_extent, + const char* from, uint32_t from_len, ptrdiff_t from_extent, + char* to, uint32_t to_length, ptrdiff_t to_extent, uint32_t *advance) { uint32_t i; @@ -220,8 +221,8 @@ copy_char_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, } static int32_t copy_cxx_bool_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, - const char* from, uint32_t from_len, long from_extent, - char* to, uint32_t to_length, long to_extent, + const char* from, uint32_t from_len, ptrdiff_t from_extent, + char* to, uint32_t to_length, ptrdiff_t to_extent, uint32_t *advance) { uint32_t i; @@ -277,8 +278,8 @@ copy_cxx_bool_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, } static int32_t copy_fortran_logical_heterogeneous(ompi_convertor_t *pConvertor, uint32_t count, - const char* from, uint32_t from_len, long from_extent, - char* to, uint32_t to_length, long to_extent, + const char* from, uint32_t from_len, ptrdiff_t from_extent, + char* to, uint32_t to_length, ptrdiff_t to_extent, uint32_t *advance) { uint32_t i; diff --git a/ompi/datatype/datatype.h b/ompi/datatype/datatype.h index e0c70ed377..4a90f40fd3 100644 --- a/ompi/datatype/datatype.h +++ b/ompi/datatype/datatype.h @@ -35,6 +35,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include #include "ompi/constants.h" #include "opal/class/opal_object.h" @@ -96,13 +97,13 @@ typedef struct dt_type_desc { */ typedef struct ompi_datatype_t { opal_object_t super; /**< basic superclass */ - unsigned long size; /**< total size in bytes of the memory used by the data if + size_t size; /**< total size in bytes of the memory used by the data if * the data is put on a contiguous buffer */ uint32_t align; /**< data should be aligned to */ - long true_lb; - long true_ub; /**< the true ub of the data without user defined lb and ub */ - long lb; /**< lower bound in memory */ - long ub; /**< upper bound in memory */ + ptrdiff_t true_lb; + ptrdiff_t true_ub; /**< the true ub of the data without user defined lb and ub */ + ptrdiff_t lb; /**< lower bound in memory */ + ptrdiff_t ub; /**< upper bound in memory */ uint16_t flags; /**< the flags */ uint16_t id; /**< data id, normally the index in the data array. */ uint32_t nbElems; /**< total number of elements inside the datatype */ @@ -146,19 +147,19 @@ void ompi_ddt_dump( const ompi_datatype_t* pData ); /* data creation functions */ 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, +OMPI_DECLSPEC int32_t ompi_ddt_create_vector( int count, int bLength, int stride, const ompi_datatype_t* oldType, ompi_datatype_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_create_hvector( int count, int bLength, long stride, +OMPI_DECLSPEC int32_t ompi_ddt_create_hvector( int count, int bLength, MPI_Aint stride, 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 ompi_datatype_t* oldType, ompi_datatype_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp, +OMPI_DECLSPEC int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const MPI_Aint* pDisp, 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 ompi_datatype_t* oldType, ompi_datatype_t** newType ); -OMPI_DECLSPEC int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp, +OMPI_DECLSPEC int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const MPI_Aint* pDisp, 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_resized( const ompi_datatype_t* oldType, MPI_Aint lb, MPI_Aint 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 ompi_datatype_t* oldType, ompi_datatype_t** newType ); @@ -169,22 +170,22 @@ OMPI_DECLSPEC int32_t ompi_ddt_create_darray( int size, int rank, int ndims, ompi_datatype_t** newType ); OMPI_DECLSPEC int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, uint32_t count, - long disp, long extent ); + ptrdiff_t disp, ptrdiff_t extent ); -static inline int32_t ompi_ddt_type_lb( const ompi_datatype_t* pData, long* disp ) +static inline int32_t ompi_ddt_type_lb( const ompi_datatype_t* pData, ptrdiff_t* disp ) { *disp = pData->lb; return 0; } -static inline int32_t ompi_ddt_type_ub( const ompi_datatype_t* pData, long* disp ) +static inline int32_t ompi_ddt_type_ub( const ompi_datatype_t* pData, ptrdiff_t* disp ) { *disp = pData->ub; return 0; } -static inline int32_t ompi_ddt_type_size ( const ompi_datatype_t* pData, int32_t *size ) +static inline int32_t ompi_ddt_type_size ( const ompi_datatype_t* pData, size_t *size ) { *size = pData->size; return 0; } -static inline int32_t ompi_ddt_type_extent( const ompi_datatype_t* pData, long* extent ) +static inline int32_t ompi_ddt_type_extent( const ompi_datatype_t* pData, ptrdiff_t* extent ) { *extent = pData->ub - pData->lb; return 0; } -static inline int32_t ompi_ddt_get_extent( const ompi_datatype_t* pData, long* lb, long* extent) +static inline int32_t ompi_ddt_get_extent( const ompi_datatype_t* pData, ptrdiff_t* lb, ptrdiff_t* extent) { *lb = pData->lb; *extent = pData->ub - pData->lb; return 0; } -static inline int32_t ompi_ddt_get_true_extent( const ompi_datatype_t* pData, long* true_lb, long* true_extent) +static inline int32_t ompi_ddt_get_true_extent( const ompi_datatype_t* pData, ptrdiff_t* true_lb, ptrdiff_t* true_extent) { *true_lb = pData->true_lb; *true_extent = (pData->true_ub - pData->true_lb); return 0; } -static inline int32_t ompi_ddt_get_size( const ompi_datatype_t* pData, unsigned long* size ) +static inline int32_t ompi_ddt_get_size( const ompi_datatype_t* pData, size_t* size ) { *size = pData->size; return 0; } /* * This function return true (1) if the datatype representation depending on the count @@ -194,11 +195,11 @@ static inline int32_t ompi_ddt_is_contiguous_memory_layout( const ompi_datatype_ { if( !(datatype->flags & DT_FLAG_CONTIGUOUS) ) return 0; if( (count == 1) || (datatype->flags & DT_FLAG_NO_GAPS) ) return 1; - assert( (long)datatype->size != (datatype->ub - datatype->lb) ); + assert( (ptrdiff_t)datatype->size != (datatype->ub - datatype->lb) ); return 0; } -OMPI_DECLSPEC int32_t ompi_ddt_get_element_count( const ompi_datatype_t* pData, int32_t iSize ); +OMPI_DECLSPEC int32_t ompi_ddt_get_element_count( const ompi_datatype_t* pData, size_t iSize ); OMPI_DECLSPEC int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* pData, int32_t count, char* pDestBuf, char* pSrcBuf ); @@ -215,11 +216,11 @@ OMPI_DECLSPEC int32_t ompi_ddt_sndrcv( void *sbuf, int32_t scount, const ompi_da */ 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 * ca, MPI_Aint* a, int32_t * cd, ompi_datatype_t** d, int32_t * type); 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 ca, MPI_Aint* a, int32_t cd, ompi_datatype_t** d,int32_t type); OMPI_DECLSPEC int32_t ompi_ddt_copy_args( const ompi_datatype_t* source_data, ompi_datatype_t* dest_data ); diff --git a/ompi/datatype/datatype_internal.h b/ompi/datatype/datatype_internal.h index f710220905..3711de2f10 100644 --- a/ompi/datatype/datatype_internal.h +++ b/ompi/datatype/datatype_internal.h @@ -153,17 +153,17 @@ struct ddt_elem_desc { ddt_elem_id_description common; /**< basic data description and flags */ uint32_t count; /**< number of blocks */ uint32_t blocklen; /**< number of elements on each block */ - int32_t extent; /**< extent of each block (in bytes) */ - long disp; /**< displacement of the first block */ + ptrdiff_t extent; /**< extent of each block (in bytes) */ + ptrdiff_t disp; /**< displacement of the first block */ }; typedef struct ddt_elem_desc ddt_elem_desc_t; struct ddt_loop_desc { ddt_elem_id_description common; /**< basic data description and flags */ uint32_t loops; /**< number of elements */ - uint32_t unused; /**< not used right now */ uint32_t items; /**< number of items in the loop */ - long extent; /**< extent of the whole loop */ + size_t unused; /**< not used right now */ + ptrdiff_t extent; /**< extent of the whole loop */ }; typedef struct ddt_loop_desc ddt_loop_desc_t; @@ -171,8 +171,8 @@ struct ddt_endloop_desc { ddt_elem_id_description common; /**< basic data description and flags */ uint32_t items; /**< number of elements */ uint32_t unused; /**< not used right now */ - uint32_t size; /**< real size of the data in the loop */ - long first_elem_disp; /**< the displacement of the first block in the loop */ + size_t size; /**< real size of the data in the loop */ + ptrdiff_t first_elem_disp; /**< the displacement of the first block in the loop */ }; typedef struct ddt_endloop_desc ddt_endloop_desc_t; @@ -234,19 +234,18 @@ extern const ompi_datatype_t* ompi_ddt_basicDatatypes[DT_MAX_PREDEFINED]; int32_t ompi_ddt_default_convertors_init( void ); int32_t ompi_ddt_default_convertors_fini( void ); -#define SAVE_STACK( PSTACK, INDEX, TYPE, COUNT, DISP, END_LOOP) \ +#define SAVE_STACK( PSTACK, INDEX, TYPE, COUNT, DISP) \ do { \ (PSTACK)->index = (INDEX); \ (PSTACK)->type = (TYPE); \ (PSTACK)->count = (COUNT); \ (PSTACK)->disp = (DISP); \ - (PSTACK)->end_loop = (END_LOOP); \ } while(0) -#define PUSH_STACK( PSTACK, STACK_POS, INDEX, TYPE, COUNT, DISP, END_LOOP) \ +#define PUSH_STACK( PSTACK, STACK_POS, INDEX, TYPE, COUNT, DISP) \ do { \ dt_stack_t* pTempStack = (PSTACK) + 1; \ - SAVE_STACK( pTempStack, (INDEX), (TYPE), (COUNT), (DISP), (END_LOOP) ); \ + SAVE_STACK( pTempStack, (INDEX), (TYPE), (COUNT), (DISP) ); \ (STACK_POS)++; \ (PSTACK) = pTempStack; \ } while(0) diff --git a/ompi/datatype/datatype_pack.c b/ompi/datatype/datatype_pack.c index 7befdf1104..d189de3ad6 100644 --- a/ompi/datatype/datatype_pack.c +++ b/ompi/datatype/datatype_pack.c @@ -58,9 +58,9 @@ ompi_pack_homogeneous_contig_function( ompi_convertor_t* pConv, { dt_stack_t* pStack = pConv->pStack; char *source_base = NULL; - size_t length = pConv->local_size - pConv->bConverted; - uint32_t iov_count, initial_amount = pConv->bConverted; - long initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; + uint32_t iov_count; + size_t length = pConv->local_size - pConv->bConverted, initial_amount = pConv->bConverted; + ptrdiff_t initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; *freeAfter = 0; source_base = (pConv->pBaseBuf + initial_displ + pStack[0].disp + pStack[1].disp); @@ -107,20 +107,20 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv, const ompi_datatype_t* pData = pConv->pDesc; dt_stack_t* pStack = pConv->pStack; char *user_memory, *packed_buffer; - long extent; - uint32_t max_allowed, i, index; - uint32_t iov_count, total_bytes_converted = 0; - long initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; + uint32_t i, index, iov_count; + size_t max_allowed, total_bytes_converted = 0; + ptrdiff_t extent; + ptrdiff_t initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; extent = pData->ub - pData->lb; - assert( (pData->flags & DT_FLAG_CONTIGUOUS) && ((long)pData->size != extent) ); + assert( (pData->flags & DT_FLAG_CONTIGUOUS) && ((ptrdiff_t)pData->size != extent) ); /* Limit the amount of packed data to the data left over on this convertor */ max_allowed = pConv->local_size - pConv->bConverted; if( max_allowed > (*max_data) ) max_allowed = (*max_data); - i = pConv->bConverted / pData->size; /* how many we already pack */ + i = (uint32_t)(pConv->bConverted / pData->size); /* how many we already pack */ *freeAfter = 0; /* There are some optimizations that can be done if the upper level @@ -169,7 +169,7 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv, iov[index].iov_base = user_memory; iov[index].iov_len = pData->size; user_memory += extent; - COMPUTE_CSUM( iov[index].iov_base, iov[index].iov_len, pConv ); + COMPUTE_CSUM( iov[index].iov_base, (size_t)iov[index].iov_len, pConv ); } max_allowed -= iov[index].iov_len; total_bytes_converted += iov[index].iov_len; @@ -186,7 +186,8 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv, } { - uint32_t done, counter; + uint32_t counter; + size_t done; if( iov[iov_count].iov_base == NULL ) { size_t length = iov[iov_count].iov_len; @@ -212,7 +213,7 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv, total_bytes_converted += done; } user_memory = pConv->pBaseBuf + initial_displ + i * extent; - counter = max_allowed / pData->size; + counter = (uint32_t)(max_allowed / pData->size); if( counter > pConv->count ) counter = pConv->count; for( i = 0; i < counter; i++ ) { OMPI_DDT_SAFEGUARD_POINTER( user_memory, pData->size, pConv->pBaseBuf, pData, pConv->count ); @@ -265,7 +266,8 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, dt_elem_desc_t* pElem; const ompi_datatype_t *pData = pConvertor->pDesc; char *source_base, *destination; - uint32_t iov_len_local, iov_count; + size_t iov_len_local; + uint32_t iov_count; DO_DEBUG( opal_output( 0, "ompi_convertor_generic_simple_pack( %p, {%p, %d}, %d )\n", (void*)pConvertor, iov[0].iov_base, iov[0].iov_len, *out_size ); ); @@ -279,7 +281,7 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; source_base = pConvertor->pBaseBuf + pStack->disp; - count_desc = pStack->count; + count_desc = (uint32_t)pStack->count; pStack--; pConvertor->stack_pos--; pElem = &(description[pos_desc]); @@ -350,7 +352,7 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, pStack->count, pConvertor->stack_pos, pos_desc, pStack->disp, iov_len_local ); ); } if( DT_LOOP == pElem->elem.common.type ) { - long local_disp = (long)source_base; + ptrdiff_t local_disp = (ptrdiff_t)source_base; if( pElem->loop.common.flags & DT_FLAG_CONTIGUOUS ) { PACK_CONTIGUOUS_LOOP( pConvertor, pElem, count_desc, source_base, destination, iov_len_local ); @@ -360,9 +362,9 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, } /* Save the stack with the correct last_count value. */ } - local_disp = (long)source_base - local_disp; + local_disp = (ptrdiff_t)source_base - local_disp; PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_LOOP, count_desc, - pStack->disp + local_disp, pos_desc + pElem->elem.disp + 1); + pStack->disp + local_disp); pos_desc++; update_loop_description: /* update the current state */ source_base = pConvertor->pBaseBuf + pStack->disp; @@ -402,7 +404,7 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, } /* I complete an element, next step I should go to the next one */ PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_BYTE, count_desc, - source_base - pStack->disp - pConvertor->pBaseBuf, pos_desc ); + source_base - pStack->disp - pConvertor->pBaseBuf ); DO_DEBUG( opal_output( 0, "pack save stack stack_pos %d pos_desc %d count_desc %d disp %ld\n", pConvertor->stack_pos, pStack->index, pStack->count, pStack->disp ); ); return 0; diff --git a/ompi/datatype/datatype_pack.h b/ompi/datatype/datatype_pack.h index 6c4ad24c0a..6b0963cd68 100644 --- a/ompi/datatype/datatype_pack.h +++ b/ompi/datatype/datatype_pack.h @@ -18,19 +18,20 @@ static inline void pack_predefined_data( ompi_convertor_t* CONVERTOR, uint32_t* COUNT, char** SOURCE, char** DESTINATION, - uint32_t* SPACE ) + size_t* SPACE ) { - uint32_t _copy_count = *(COUNT), _copy_blength; + uint32_t _copy_count = *(COUNT); + size_t _copy_blength; ddt_elem_desc_t* _elem = &((ELEM)->elem); char* _source = (*SOURCE) + _elem->disp; _copy_blength = ompi_ddt_basicDatatypes[_elem->common.type]->size; if( (_copy_count * _copy_blength) > *(SPACE) ) { - _copy_count = *(SPACE) / _copy_blength; + _copy_count = (uint32_t)(*(SPACE) / _copy_blength); if( 0 == _copy_count ) return; /* nothing to do */ } - if( _copy_blength == (uint32_t)_elem->extent ) { + if( (ptrdiff_t)_copy_blength == _elem->extent ) { _copy_blength *= _copy_count; /* the extent and the size of the basic datatype are equals */ OMPI_DDT_SAFEGUARD_POINTER( _source, _copy_blength, (CONVERTOR)->pBaseBuf, @@ -63,16 +64,16 @@ static inline void pack_contiguous_loop( ompi_convertor_t* CONVERTOR, uint32_t* COUNT, char** SOURCE, char** DESTINATION, - uint32_t* SPACE ) + size_t* SPACE ) { ddt_loop_desc_t *_loop = (ddt_loop_desc_t*)(ELEM); ddt_endloop_desc_t* _end_loop = (ddt_endloop_desc_t*)((ELEM) + _loop->items); char* _source = (*SOURCE) + _end_loop->first_elem_disp; - size_t _copy_loops = *(COUNT); + uint32_t _copy_loops = *(COUNT); uint32_t _i; if( (_copy_loops * _end_loop->size) > *(SPACE) ) - _copy_loops = *(SPACE) / _end_loop->size; + _copy_loops = (uint32_t)(*(SPACE) / _end_loop->size); for( _i = 0; _i < _copy_loops; _i++ ) { OMPI_DDT_SAFEGUARD_POINTER( _source, _end_loop->size, (CONVERTOR)->pBaseBuf, (CONVERTOR)->pDesc, (CONVERTOR)->count ); diff --git a/ompi/datatype/datatype_unpack.c b/ompi/datatype/datatype_unpack.c index 7511af8390..7896346980 100644 --- a/ompi/datatype/datatype_unpack.c +++ b/ompi/datatype/datatype_unpack.c @@ -61,27 +61,28 @@ ompi_unpack_general_function( ompi_convertor_t* pConvertor, size_t* max_data, int32_t* freeAfter ) { - dt_stack_t* pStack; /* pointer to the position on the stack */ - uint32_t pos_desc; /* actual position in the description of the derived datatype */ - int count_desc; /* the number of items already done in the actual pos_desc */ - int type = DT_CHAR; /* type at current position */ - uint32_t advance; /* number of bytes that we should advance the buffer */ - long disp_desc = 0; /* compute displacement for truncated data */ - int bConverted = 0; /* number of bytes converted this time */ + dt_stack_t* pStack; /* pointer to the position on the stack */ + uint32_t pos_desc; /* actual position in the description of the derived datatype */ + int32_t count_desc; /* the number of items already done in the actual pos_desc */ + int type = DT_CHAR; /* type at current position */ + ptrdiff_t advance; /* number of bytes that we should advance the buffer */ + ptrdiff_t disp_desc = 0; /* compute displacement for truncated data */ + size_t bConverted = 0; /* number of bytes converted this time */ const ompi_convertor_master_t* master = pConvertor->master; dt_elem_desc_t* description; - long extent = pConvertor->pDesc->ub - pConvertor->pDesc->lb; - int oCount = extent * pConvertor->count; + ptrdiff_t extent = pConvertor->pDesc->ub - pConvertor->pDesc->lb; + size_t oCount = extent * pConvertor->count; + size_t iCount, total_bytes_converted = 0; char* pInput; - int iCount, rc; - uint32_t iov_count, total_bytes_converted = 0; + int32_t rc; + uint32_t iov_count; /* For the general case always use the user data description */ description = pConvertor->use_desc->desc; pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; - count_desc = pStack->count; + count_desc = (int32_t)pStack->count; disp_desc = pStack->disp; pStack--; pConvertor->stack_pos--; @@ -116,8 +117,7 @@ ompi_unpack_general_function( ompi_convertor_t* pConvertor, if( DT_LOOP == description[pos_desc].elem.common.type ) { do { PUSH_STACK( pStack, pConvertor->stack_pos, - pos_desc, DT_LOOP, description[pos_desc].loop.loops, - pStack->disp, pos_desc + description[pos_desc].loop.items + 1 ); + pos_desc, DT_LOOP, description[pos_desc].loop.loops, pStack->disp ); pos_desc++; } while( DT_LOOP == description[pos_desc].loop.common.type ); /* let's start another loop */ DDT_DUMP_STACK( pConvertor->pStack, pConvertor->stack_pos, description, "advance loops" ); @@ -140,7 +140,7 @@ ompi_unpack_general_function( ompi_convertor_t* pConvertor, count_desc -= rc; disp_desc += rc * description[pos_desc].elem.extent; if( iCount != 0 ) - printf( "unpack there is still room in the input buffer %d bytes\n", iCount ); + printf( "unpack there is still room in the input buffer %ld bytes\n", (long)iCount ); goto save_and_return; } pos_desc++; /* advance to the next data */ @@ -166,7 +166,7 @@ ompi_unpack_general_function( ompi_convertor_t* pConvertor, /* I complete an element, next step I should go to the next one */ PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, type, - count_desc, disp_desc, pos_desc ); + count_desc, disp_desc ); return 0; } @@ -189,11 +189,11 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv, { const ompi_datatype_t *pData = pConv->pDesc; char *user_memory, *packed_buffer; - uint32_t iov_count, initial_bytes_converted = pConv->bConverted; - long extent = pData->ub - pData->lb; - uint32_t bConverted, length, remaining, i; + uint32_t iov_count, i; + size_t bConverted, remaining, length, initial_bytes_converted = pConv->bConverted; dt_stack_t* stack = &(pConv->pStack[1]); - long initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; + ptrdiff_t extent = pData->ub - pData->lb; + ptrdiff_t initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( pBaseBuf %p, iov_count %d )\n", pConv->pBaseBuf, *out_size ); ); @@ -208,7 +208,7 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv, DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %d\n", user_memory, packed_buffer, remaining ); ); - if( (long)pData->size == extent ) { + if( (ptrdiff_t)pData->size == extent ) { user_memory += pConv->bConverted; /* contiguous data or basic datatype with count */ @@ -284,14 +284,14 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv, static inline uint32_t ompi_unpack_partial_datatype( ompi_convertor_t* pConvertor, dt_elem_desc_t* pElem, char* partial_data, - uint32_t start_position, uint32_t end_position, + ptrdiff_t start_position, ptrdiff_t end_position, char** user_buffer ) { char unused_byte = 0x7F, saved_data[16]; char temporary[16], *temporary_buffer = temporary; char* real_data = *user_buffer + pElem->elem.disp; - uint32_t i, count_desc = 1; - uint32_t data_length = ompi_ddt_basicDatatypes[pElem->elem.common.type]->size; + uint32_t i, length, count_desc = 1; + size_t data_length = ompi_ddt_basicDatatypes[pElem->elem.common.type]->size; DO_DEBUG( opal_output( 0, "unpack partial data start %d end %d data_length %d user %p\n" "\tbConverted %d total_length %d count %d\n", @@ -300,7 +300,8 @@ ompi_unpack_partial_datatype( ompi_convertor_t* pConvertor, dt_elem_desc_t* pEle /* Find a byte that is not used in the partial buffer */ find_unused_byte: - for( i = 0; i < (end_position - start_position); i++ ) { + length = (uint32_t)(end_position - start_position); + for( i = 0; i < length; i++ ) { if( unused_byte == partial_data[i] ) { unused_byte--; goto find_unused_byte; @@ -356,7 +357,8 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, dt_elem_desc_t* pElem; const ompi_datatype_t *pData = pConvertor->pDesc; char *user_memory_base, *packed_buffer; - uint32_t iov_len_local, iov_count; + size_t iov_len_local; + uint32_t iov_count; DO_DEBUG( opal_output( 0, "ompi_convertor_generic_simple_unpack( %p, {%p, %lu}, %u )\n", (void*)pConvertor, iov[0].iov_base, (size_t)iov[0].iov_len, *out_size ); ); @@ -370,7 +372,7 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; user_memory_base = pConvertor->pBaseBuf + pStack->disp; - count_desc = pStack->count; + count_desc = (uint32_t)pStack->count; pStack--; pConvertor->stack_pos--; pElem = &(description[pos_desc]); @@ -386,8 +388,8 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, packed_buffer = iov[iov_count].iov_base; iov_len_local = iov[iov_count].iov_len; if( 0 != pConvertor->partial_length ) { - uint32_t element_length = ompi_ddt_basicDatatypes[pElem->elem.common.type]->size; - uint32_t missing_length = element_length - pConvertor->partial_length; + size_t element_length = ompi_ddt_basicDatatypes[pElem->elem.common.type]->size; + size_t missing_length = element_length - pConvertor->partial_length; assert( pElem->elem.common.flags & DT_FLAG_DATA ); COMPUTE_CSUM( packed_buffer, missing_length, pConvertor ); @@ -430,7 +432,7 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, packed_buffer, 0, iov_len_local, &temp ); - pConvertor->partial_length = iov_len_local; + pConvertor->partial_length = (uint32_t)iov_len_local; iov_len_local = 0; } goto complete_loop; @@ -462,7 +464,7 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, pStack->count, pConvertor->stack_pos, pos_desc, pStack->disp, iov_len_local ); ); } if( DT_LOOP == pElem->elem.common.type ) { - long local_disp = (long)user_memory_base; + ptrdiff_t local_disp = (ptrdiff_t)user_memory_base; if( pElem->loop.common.flags & DT_FLAG_CONTIGUOUS ) { UNPACK_CONTIGUOUS_LOOP( pConvertor, pElem, count_desc, packed_buffer, user_memory_base, iov_len_local ); @@ -472,9 +474,9 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, } /* Save the stack with the correct last_count value. */ } - local_disp = (long)user_memory_base - local_disp; + local_disp = (ptrdiff_t)user_memory_base - local_disp; PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_LOOP, count_desc, - pStack->disp + local_disp, pos_desc + pElem->elem.disp + 1); + pStack->disp + local_disp); pos_desc++; update_loop_description: /* update the current state */ user_memory_base = pConvertor->pBaseBuf + pStack->disp; @@ -496,7 +498,7 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, } /* I complete an element, next step I should go to the next one */ PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_BYTE, count_desc, - user_memory_base - pStack->disp - pConvertor->pBaseBuf, pos_desc ); + user_memory_base - pStack->disp - pConvertor->pBaseBuf ); DO_DEBUG( opal_output( 0, "unpack save stack stack_pos %d pos_desc %d count_desc %d disp %ld\n", pConvertor->stack_pos, pStack->index, pStack->count, pStack->disp ); ); return 0; diff --git a/ompi/datatype/datatype_unpack.h b/ompi/datatype/datatype_unpack.h index 3158ddc81b..f7bc80ba73 100644 --- a/ompi/datatype/datatype_unpack.h +++ b/ompi/datatype/datatype_unpack.h @@ -18,15 +18,16 @@ static inline void unpack_predefined_data( ompi_convertor_t* CONVERTOR, /* the c uint32_t* COUNT, /* the number of elements */ char** SOURCE, /* the source pointer */ char** DESTINATION, /* the destination pointer */ - uint32_t* SPACE ) /* the space in the destination buffer */ + size_t* SPACE ) /* the space in the destination buffer */ { - uint32_t _copy_count = *(COUNT), _copy_blength; + uint32_t _copy_count = *(COUNT); + size_t _copy_blength; ddt_elem_desc_t* _elem = &((ELEM)->elem); char* _destination = (*DESTINATION) + _elem->disp; _copy_blength = ompi_ddt_basicDatatypes[_elem->common.type]->size; if( (_copy_count * _copy_blength) > *(SPACE) ) { - _copy_count = *(SPACE) / _copy_blength; + _copy_count = (uint32_t)(*(SPACE) / _copy_blength); if( 0 == _copy_count ) return; /* nothing to do */ } @@ -63,16 +64,16 @@ static inline void unpack_contiguous_loop( ompi_convertor_t* CONVERTOR, uint32_t* COUNT, char** SOURCE, char** DESTINATION, - uint32_t* SPACE ) + size_t* SPACE ) { ddt_loop_desc_t *_loop = (ddt_loop_desc_t*)(ELEM); ddt_endloop_desc_t* _end_loop = (ddt_endloop_desc_t*)((ELEM) + _loop->items); char* _destination = (*DESTINATION) + _end_loop->first_elem_disp; - size_t _copy_loops = *(COUNT); + uint32_t _copy_loops = *(COUNT); uint32_t _i; if( (_copy_loops * _end_loop->size) > *(SPACE) ) - _copy_loops = *(SPACE) / _end_loop->size; + _copy_loops = (uint32_t)(*(SPACE) / _end_loop->size); for( _i = 0; _i < _copy_loops; _i++ ) { OMPI_DDT_SAFEGUARD_POINTER( _destination, _end_loop->size, (CONVERTOR)->pBaseBuf, (CONVERTOR)->pDesc, (CONVERTOR)->count ); diff --git a/ompi/datatype/dt_add.c b/ompi/datatype/dt_add.c index 0e9e02bab2..dfacec3b06 100644 --- a/ompi/datatype/dt_add.c +++ b/ompi/datatype/dt_add.c @@ -27,13 +27,13 @@ #define UNSET_CONTIGUOUS_FLAG( INT_VALUE ) (INT_VALUE) = (INT_VALUE) & (~(DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS)) #if defined(__GNUC__) && !defined(__STDC__) -#define LMAX(A,B) ({ long _a = (A), _b = (B); (_a < _b ? _b : _a) }) -#define LMIN(A,B) ({ long _a = (A), _b = (B); (_a < _b ? _a : _b); }) +#define LMAX(A,B) ({ ptrdiff_t _a = (A), _b = (B); (_a < _b ? _b : _a) }) +#define LMIN(A,B) ({ ptrdiff_t _a = (A), _b = (B); (_a < _b ? _a : _b); }) #define IMAX(A,B) ({ int _a = (A), _b = (B); (_a < _b ? _b : _a); }) #define IMIN(A,B) ({ int _a = (A), _b = (B); (_a < _b ? _a : _b); }) #else -static inline long LMAX( long a, long b ) { return ( a < b ? b : a ); } -static inline long LMIN( long a, long b ) { return ( a < b ? a : b ); } +static inline ptrdiff_t LMAX( ptrdiff_t a, ptrdiff_t b ) { return ( a < b ? b : a ); } +static inline ptrdiff_t LMIN( ptrdiff_t a, ptrdiff_t b ) { return ( a < b ? a : b ); } static inline int IMAX( int a, int b ) { return ( a < b ? b : a ); } static inline int IMIN( int a, int b ) { return ( a < b ? a : b ); } #endif /* __GNU__ */ @@ -44,7 +44,7 @@ static inline int IMIN( int a, int b ) { return ( a < b ? a : b ); } _new_lb = (_old_lb) + (_disp); \ _new_ub = (_old_ub) + (_disp); \ } else { \ - long lower, upper; \ + ptrdiff_t lower, upper; \ upper = (_disp) + (_old_extent) * ((_count) - 1); \ lower = (_disp); \ if( lower < upper ) { \ @@ -74,12 +74,12 @@ static inline int IMIN( int a, int b ) { return ( a < b ? a : b ); } * set to ZERO if it's a empty datatype. */ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, - uint32_t count, long disp, long extent ) + uint32_t count, ptrdiff_t disp, ptrdiff_t extent ) { uint32_t newLength, place_needed = 0, i; short localFlags = 0; /* no specific options yet */ dt_elem_desc_t *pLast, *pLoop = NULL; - long lb, ub, true_lb, true_ub, epsilon, old_true_ub; + ptrdiff_t lb, ub, true_lb, true_ub, epsilon, old_true_ub; /* the extent should always be positive. So a negative * value here have a special meaning ie. default extent as @@ -97,7 +97,7 @@ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, pdtBase->lb = disp; pdtBase->flags |= DT_FLAG_USER_LB; } - if( (pdtBase->ub - pdtBase->lb) != (long)pdtBase->size ) { + if( (pdtBase->ub - pdtBase->lb) != (ptrdiff_t)pdtBase->size ) { pdtBase->flags &= ~DT_FLAG_NO_GAPS; } return OMPI_SUCCESS; @@ -109,12 +109,12 @@ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, pdtBase->ub = disp; pdtBase->flags |= DT_FLAG_USER_UB; } - if( (pdtBase->ub - pdtBase->lb) != (long)pdtBase->size ) { + if( (pdtBase->ub - pdtBase->lb) != (ptrdiff_t)pdtBase->size ) { pdtBase->flags &= ~DT_FLAG_NO_GAPS; } return OMPI_SUCCESS; } - place_needed = (extent == (long)pdtAdd->size ? 1 : 3); + place_needed = (extent == (ptrdiff_t)pdtAdd->size ? 1 : 3); } else { place_needed = pdtAdd->desc.used; if( count != 1 ) place_needed += 2; /* for the loop markers */ @@ -222,7 +222,7 @@ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, */ if( (pdtAdd->flags & (DT_FLAG_PREDEFINED | DT_FLAG_DATA)) == (DT_FLAG_PREDEFINED | DT_FLAG_DATA) ) { pdtBase->btypes[pdtAdd->id] += count; - if( (extent != (long)pdtAdd->size) && (count > 1) ) { /* gaps around the datatype */ + if( (extent != (ptrdiff_t)pdtAdd->size) && (count > 1) ) { /* gaps around the datatype */ localFlags = pdtAdd->flags & ~(DT_FLAG_COMMITED | DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS); CREATE_LOOP_START( pLast, count, 2, extent, localFlags ); pLast++; @@ -265,7 +265,7 @@ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, */ if( count != 1 ) { pLoop = pLast; - CREATE_LOOP_START( pLast, count, (long)pdtAdd->desc.used + 1, extent, + CREATE_LOOP_START( pLast, count, pdtAdd->desc.used + 1, extent, (pdtAdd->flags & ~(DT_FLAG_COMMITED)) ); pdtBase->btypes[DT_LOOP] += 2; pdtBase->desc.used += 2; @@ -302,12 +302,12 @@ int32_t ompi_ddt_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, if( disp != old_true_ub ) { /* is there a gap between the 2 datatypes ? */ if( disp < old_true_ub ) pdtBase->flags |= DT_FLAG_OVERLAP; } else { - if( (localFlags & DT_FLAG_CONTIGUOUS) /* both have to be contiguous */ - && ( (((long)pdtAdd->size) == extent) /* the size and the extent of the added - * type have to match */ - || (count < 2)) ) { /* - if the count is bigger than 2 */ + if( (localFlags & DT_FLAG_CONTIGUOUS) /* both have to be contiguous */ + && ( ((ptrdiff_t)pdtAdd->size == extent) /* the size and the extent of the + * added type have to match */ + || (count < 2)) ) { /* if the count is bigger than 2 */ SET_CONTIGUOUS_FLAG(pdtBase->flags); - if( ((long)pdtBase->size) == (pdtBase->ub - pdtBase->lb) ) + if( (ptrdiff_t)pdtBase->size == (pdtBase->ub - pdtBase->lb) ) SET_NO_GAP_FLAG(pdtBase->flags); } } diff --git a/ompi/datatype/dt_copy.c b/ompi/datatype/dt_copy.c index 3ce4653f60..823972332f 100644 --- a/ompi/datatype/dt_copy.c +++ b/ompi/datatype/dt_copy.c @@ -45,9 +45,10 @@ static inline void copy_predefined_data( const dt_elem_desc_t* ELEM, uint32_t COUNT, char* SOURCE, char* DESTINATION, - uint32_t* SPACE ) + size_t* SPACE ) { - uint32_t _copy_count = (COUNT), _copy_blength; + uint32_t _copy_count = (COUNT); + size_t _copy_blength; const ddt_elem_desc_t* _elem = &((ELEM)->elem); char* _source = (SOURCE) + _elem->disp; char* _destination = (DESTINATION) + _elem->disp; @@ -87,7 +88,7 @@ static inline void copy_contiguous_loop( const dt_elem_desc_t* ELEM, uint32_t COUNT, char* SOURCE, char* DESTINATION, - uint32_t* SPACE ) + size_t* SPACE ) { ddt_loop_desc_t *_loop = (ddt_loop_desc_t*)(ELEM); ddt_endloop_desc_t* _end_loop = (ddt_endloop_desc_t*)((ELEM) + _loop->items); @@ -96,7 +97,7 @@ static inline void copy_contiguous_loop( const dt_elem_desc_t* ELEM, size_t _copy_loops = (COUNT); uint32_t _i; - if( _loop->extent == (long)_end_loop->size ) { /* the loop is contiguous */ + if( _loop->extent == (ptrdiff_t)_end_loop->size ) { /* the loop is contiguous */ _copy_loops *= _end_loop->size; OMPI_DDT_SAFEGUARD_POINTER( _source, _copy_loops, (SOURCE_BASE), (DATATYPE), (TOTAL_COUNT) ); @@ -133,7 +134,7 @@ int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* datatype, int32_t uint32_t count_desc; /* the number of items already done in the actual pos_desc */ dt_elem_desc_t* description; dt_elem_desc_t* pElem; - uint32_t iov_len_local; + size_t iov_len_local; char *source = source_base, *destination = destination_base; DO_DEBUG( opal_output( 0, "ompi_ddt_copy_content_same_ddt( %p, %d, dst %p, src %p )\n", @@ -149,13 +150,13 @@ int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* datatype, int32_t * do a memcpy. */ if( (datatype->flags & DT_FLAG_CONTIGUOUS) == DT_FLAG_CONTIGUOUS ) { - long extent = (datatype->ub - datatype->lb); + ptrdiff_t extent = (datatype->ub - datatype->lb); /* Now that we know the datatype is contiguous, we should move the 2 pointers * source and destination to the correct displacement. */ destination += datatype->lb; source += datatype->lb; - if( (long)datatype->size == extent ) { /* all contiguous == no gaps around */ + if( (ptrdiff_t)datatype->size == extent ) { /* all contiguous == no gaps around */ size_t total_length = datatype->size * count; size_t memcpy_chunk = ompi_datatype_memcpy_block_size; while( total_length > 0 ) { @@ -194,10 +195,8 @@ int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* datatype, int32_t if( datatype->opt_desc.desc != NULL ) { description = datatype->opt_desc.desc; - pStack->end_loop = datatype->opt_desc.used; } else { description = datatype->desc.desc; - pStack->end_loop = datatype->desc.used; } if( description[0].elem.common.type == DT_LOOP ) @@ -241,16 +240,16 @@ int32_t ompi_ddt_copy_content_same_ddt( const ompi_datatype_t* datatype, int32_t pStack->count, stack_pos, pos_desc, pStack->disp, iov_len_local ); ); } if( DT_LOOP == pElem->elem.common.type ) { - long local_disp = (long)source; + ptrdiff_t local_disp = (ptrdiff_t)source; if( pElem->loop.common.flags & DT_FLAG_CONTIGUOUS ) { COPY_CONTIGUOUS_LOOP( pElem, datatype, source_base, count, count_desc, source, destination, iov_len_local ); pos_desc += pElem->loop.items + 1; goto update_loop_description; } - local_disp = (long)source - local_disp; + local_disp = (ptrdiff_t)source - local_disp; PUSH_STACK( pStack, stack_pos, pos_desc, DT_LOOP, count_desc, - pStack->disp + local_disp, pos_desc + pElem->elem.disp + 1); + pStack->disp + local_disp); pos_desc++; update_loop_description: /* update the current state */ source = source_base + pStack->disp; diff --git a/ompi/datatype/dt_create.c b/ompi/datatype/dt_create.c index e5003ad3c8..32f6a5c8c3 100644 --- a/ompi/datatype/dt_create.c +++ b/ompi/datatype/dt_create.c @@ -106,14 +106,14 @@ ompi_datatype_t* ompi_ddt_create( int32_t expectedSize ) return datatype; } -int32_t ompi_ddt_create_resized( const ompi_datatype_t* oldType, long lb, long extent, ompi_datatype_t** newType ) +int32_t ompi_ddt_create_resized( const ompi_datatype_t* oldType, MPI_Aint lb, MPI_Aint extent, ompi_datatype_t** newType ) { ompi_ddt_duplicate( oldType, newType ); (*newType)->lb = lb; (*newType)->ub = lb + extent; (*newType)->flags &= ~DT_FLAG_NO_GAPS; - if( (extent == (long)oldType->size) && (oldType->flags & DT_FLAG_CONTIGUOUS) ) { + if( (extent == (ptrdiff_t)oldType->size) && (oldType->flags & DT_FLAG_CONTIGUOUS) ) { (*newType)->flags |= DT_FLAG_NO_GAPS; } return OMPI_SUCCESS; diff --git a/ompi/datatype/dt_create_indexed.c b/ompi/datatype/dt_create_indexed.c index bfa1525881..d220e83f53 100644 --- a/ompi/datatype/dt_create_indexed.c +++ b/ompi/datatype/dt_create_indexed.c @@ -26,7 +26,7 @@ int32_t ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* { ompi_datatype_t* pdt; int i, dLength, endat, disp; - long extent = oldType->ub - oldType->lb; + ptrdiff_t extent = oldType->ub - oldType->lb; if( 0 == count ) { *newType = ompi_ddt_create( 0 ); @@ -62,13 +62,13 @@ int32_t ompi_ddt_create_indexed( int count, const int* pBlockLength, const int* return OMPI_SUCCESS; } -int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const long* pDisp, +int32_t ompi_ddt_create_hindexed( int count, const int* pBlockLength, const MPI_Aint* pDisp, const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { ompi_datatype_t* pdt; int i, dLength; - long extent = oldType->ub - oldType->lb; - long disp, endat; + ptrdiff_t extent = oldType->ub - oldType->lb; + ptrdiff_t disp, endat; if( 0 == count ) { *newType = ompi_ddt_create( 0 ); @@ -108,7 +108,7 @@ int32_t ompi_ddt_create_indexed_block( int count, int bLength, const int* pDisp, { ompi_datatype_t* pdt; int i, dLength, endat, disp; - long extent = oldType->ub - oldType->lb; + ptrdiff_t extent = oldType->ub - oldType->lb; if( (count == 0) || (bLength == 0) ) { *newType = ompi_ddt_create(1); diff --git a/ompi/datatype/dt_create_struct.c b/ompi/datatype/dt_create_struct.c index b24e33bfb6..ed3b23096e 100644 --- a/ompi/datatype/dt_create_struct.c +++ b/ompi/datatype/dt_create_struct.c @@ -20,11 +20,11 @@ #include "ompi_config.h" #include "ompi/datatype/datatype.h" -int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* pDisp, +int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const MPI_Aint* pDisp, ompi_datatype_t* const * pTypes, ompi_datatype_t** newType ) { int i; - long disp = 0, endto, lastExtent, lastDisp; + ptrdiff_t disp = 0, endto, lastExtent, lastDisp; int lastBlock; ompi_datatype_t *pdt, *lastType; @@ -66,7 +66,7 @@ int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const long* lastDisp = pDisp[0]; endto = pDisp[0] + lastExtent * lastBlock; - pdt = ompi_ddt_create( disp ); + pdt = ompi_ddt_create( (int32_t)disp ); /* Do again the same loop but now add the elements */ for( i = 1; i < count; i++ ) { diff --git a/ompi/datatype/dt_create_vector.c b/ompi/datatype/dt_create_vector.c index 7dbbb7934f..8651f928e9 100644 --- a/ompi/datatype/dt_create_vector.c +++ b/ompi/datatype/dt_create_vector.c @@ -26,10 +26,10 @@ * */ -int32_t ompi_ddt_create_vector( int count, int bLength, long stride, +int32_t ompi_ddt_create_vector( int count, int bLength, int stride, const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { - long extent = oldType->ub - oldType->lb; + ptrdiff_t extent = oldType->ub - oldType->lb; ompi_datatype_t *pTempData, *pData; if( 0 == count ) { @@ -56,10 +56,10 @@ int32_t ompi_ddt_create_vector( int count, int bLength, long stride, return OMPI_SUCCESS; } -int32_t ompi_ddt_create_hvector( int count, int bLength, long stride, +int32_t ompi_ddt_create_hvector( int count, int bLength, MPI_Aint stride, const ompi_datatype_t* oldType, ompi_datatype_t** newType ) { - long extent = oldType->ub - oldType->lb; + ptrdiff_t extent = oldType->ub - oldType->lb; ompi_datatype_t *pTempData, *pData; if( 0 == count ) { diff --git a/ompi/datatype/dt_get_count.c b/ompi/datatype/dt_get_count.c index adc1b567de..41e3ecd9bc 100644 --- a/ompi/datatype/dt_get_count.c +++ b/ompi/datatype/dt_get_count.c @@ -27,12 +27,12 @@ * positive = number of basic elements inside * negative = some error occurs */ -int32_t ompi_ddt_get_element_count( const ompi_datatype_t* datatype, int32_t iSize ) +int32_t ompi_ddt_get_element_count( const ompi_datatype_t* datatype, size_t iSize ) { dt_stack_t* pStack; /* pointer to the position on the stack */ uint32_t pos_desc; /* actual position in the description of the derived datatype */ - int rc, nbElems = 0; - int stack_pos = 0; + int32_t nbElems = 0, stack_pos = 0; + size_t local_size; dt_elem_desc_t* pElems; /* Normally the size should be less or equal to the size of the datatype. @@ -45,7 +45,6 @@ int32_t ompi_ddt_get_element_count( const ompi_datatype_t* datatype, int32_t iSi pStack->index = -1; pStack->disp = 0; pElems = datatype->desc.desc; - pStack->end_loop = datatype->desc.used; pos_desc = 0; while( 1 ) { /* loop forever the exit condition is on the last DT_END_LOOP */ @@ -68,8 +67,7 @@ int32_t ompi_ddt_get_element_count( const ompi_datatype_t* datatype, int32_t iSi if( DT_LOOP == pElems[pos_desc].elem.common.type ) { ddt_loop_desc_t* loop = &(pElems[pos_desc].loop); do { - PUSH_STACK( pStack, stack_pos, pos_desc, DT_LOOP, loop->loops, - 0, pos_desc + loop->items ); + PUSH_STACK( pStack, stack_pos, pos_desc, DT_LOOP, loop->loops, 0 ); pos_desc++; } while( DT_LOOP == pElems[pos_desc].elem.common.type ); /* let's start another loop */ DDT_DUMP_STACK( pStack, stack_pos, pElems, "advance loops" ); @@ -78,15 +76,15 @@ int32_t ompi_ddt_get_element_count( const ompi_datatype_t* datatype, int32_t iSi while( pElems[pos_desc].elem.common.flags & DT_FLAG_DATA ) { /* now here we have a basic datatype */ const ompi_datatype_t* basic_type = BASIC_DDT_FROM_ELEM(pElems[pos_desc]); - rc = pElems[pos_desc].elem.count * basic_type->size; - if( rc >= iSize ) { - rc = iSize / basic_type->size; - nbElems += rc; - iSize -= rc * basic_type->size; + local_size = pElems[pos_desc].elem.count * basic_type->size; + if( local_size >= iSize ) { + local_size = iSize / basic_type->size; + nbElems += (int32_t)local_size; + iSize -= local_size * basic_type->size; return (iSize == 0 ? nbElems : -1); } nbElems += pElems[pos_desc].elem.count; - iSize -= rc; + iSize -= local_size; pos_desc++; /* advance to the next data */ } } diff --git a/ompi/datatype/dt_match_size.c b/ompi/datatype/dt_match_size.c index 59f859f5b1..efe6204998 100644 --- a/ompi/datatype/dt_match_size.c +++ b/ompi/datatype/dt_match_size.c @@ -43,7 +43,7 @@ ompi_ddt_match_size( int size, uint16_t datakind, uint16_t datalang ) continue; if( (datatype->flags & DT_FLAG_DATA_TYPE) != datakind ) continue; - if( (unsigned long)size == datatype->size ) { + if( (size_t)size == datatype->size ) { return datatype; } } diff --git a/ompi/datatype/dt_module.c b/ompi/datatype/dt_module.c index d75474c027..460150aeb4 100644 --- a/ompi/datatype/dt_module.c +++ b/ompi/datatype/dt_module.c @@ -279,7 +279,7 @@ const ompi_datatype_t* ompi_ddt_basicDatatypes[DT_MAX_PREDEFINED] = { ompi_pointer_array_t *ompi_datatype_f_to_c_table = NULL; -int ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; +size_t ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; #define COPY_DATA_DESC( PDST, PSRC ) \ do { \ @@ -316,20 +316,20 @@ int ompi_ddt_local_sizes[DT_MAX_PREDEFINED]; ompi_datatype_t* types[2]; \ ompi_datatype_t* ptype; \ int bLength[2] = {1, 1}; \ - long base, displ[2]; \ + MPI_Aint base, displ[2]; \ \ types[0] = (ompi_datatype_t*)ompi_ddt_basicDatatypes[MPIType1]; \ types[1] = (ompi_datatype_t*)ompi_ddt_basicDatatypes[MPIType2]; \ - base = (long)(&(s[0])); \ - displ[0] = (long)(&(s[0].v1)); \ + base = (ptrdiff_t)(&(s[0])); \ + displ[0] = (ptrdiff_t)(&(s[0].v1)); \ displ[0] -= base; \ - displ[1] = (long)(&(s[0].v2)); \ + displ[1] = (ptrdiff_t)(&(s[0].v2)); \ displ[1] -= base; \ \ ompi_ddt_create_struct( 2, bLength, displ, types, &ptype ); \ - displ[0] = (long)(&(s[1])); \ + displ[0] = (ptrdiff_t)(&(s[1])); \ displ[0] -= base; \ - if( displ[0] != (displ[1] + (long)sizeof(type2)) ) \ + if( displ[0] != (displ[1] + (ptrdiff_t)sizeof(type2)) ) \ ptype->ub = displ[0]; /* force a new extent for the datatype */ \ ptype->flags |= (FLAGS); \ ptype->id = MPIDDT; \ @@ -418,7 +418,7 @@ int32_t ompi_ddt_init( void ) datatype->btypes[i] = 1; /* Check if the data contain gaps */ - if( (datatype->ub - datatype->lb) == (long)datatype->size ) { + if( (datatype->ub - datatype->lb) == (ptrdiff_t)datatype->size ) { datatype->desc.desc[0].elem.common.flags |= DT_FLAG_NO_GAPS; } } @@ -594,7 +594,7 @@ int32_t ompi_ddt_init( void ) for( i = 0; i < ompi_mpi_cxx_ldblcplex.d_f_to_c_index; i++ ) { ompi_datatype_t* datatype = (ompi_datatype_t*)ompi_pointer_array_get_item( ompi_datatype_f_to_c_table, i ); - if( (datatype->ub - datatype->lb) == (long)datatype->size ) { + if( (datatype->ub - datatype->lb) == (ptrdiff_t)datatype->size ) { datatype->flags |= DT_FLAG_NO_GAPS; } else { datatype->flags &= ~DT_FLAG_NO_GAPS; @@ -714,11 +714,11 @@ static int __dump_data_desc( dt_elem_desc_t* pDesc, int nbElems, char* ptr, size (int)pDesc->loop.extent ); else if( DT_END_LOOP == pDesc->elem.common.type ) index += snprintf( ptr + index, length - index, "prev %d elements first elem displacement %ld size of data %d\n", - (int)pDesc->end_loop.items, pDesc->end_loop.first_elem_disp, + (int)pDesc->end_loop.items, (long)pDesc->end_loop.first_elem_disp, (int)pDesc->end_loop.size ); else index += snprintf( ptr + index, length - index, "count %d disp 0x%lx (%ld) extent %d (size %ld)\n", - (int)pDesc->elem.count, pDesc->elem.disp, pDesc->elem.disp, + (int)pDesc->elem.count, (long)pDesc->elem.disp, (long)pDesc->elem.disp, (int)pDesc->elem.extent, pDesc->elem.count * ompi_ddt_basicDatatypes[pDesc->elem.common.type]->size ); pDesc++; @@ -757,8 +757,8 @@ void ompi_ddt_dump( const ompi_datatype_t* pData ) "true_lb %ld true_ub %ld (true_extent %ld) lb %ld ub %ld (extent %ld)\n" "nbElems %d loops %d flags %X (", (void*)pData, pData->name, pData->size, (int)pData->align, pData->id, (int)pData->desc.length, (int)pData->desc.used, - pData->true_lb, pData->true_ub, pData->true_ub - pData->true_lb, - pData->lb, pData->ub, pData->ub - pData->lb, + (long)pData->true_lb, (long)pData->true_ub, (long)(pData->true_ub - pData->true_lb), + (long)pData->lb, (long)pData->ub, (long)(pData->ub - pData->lb), (int)pData->nbElems, (int)pData->btypes[DT_LOOP], (int)pData->flags ); /* dump the flags */ if( pData->flags == DT_FLAG_PREDEFINED ) diff --git a/ompi/datatype/dt_optimize.c b/ompi/datatype/dt_optimize.c index 22bd8bbe88..0bd75e03d8 100644 --- a/ompi/datatype/dt_optimize.c +++ b/ompi/datatype/dt_optimize.c @@ -49,7 +49,8 @@ static inline int SAVE_OPTIMIZED_ELEMENT( dt_elem_desc_t* pElemDesc, static inline int ADD_ELEMENT( dt_elem_desc_t* pElemDesc, ddt_elem_desc_t* opt_elem, - uint16_t type, uint32_t count, long disp, int32_t extent ) + uint16_t type, uint32_t count, + ptrdiff_t disp, int32_t extent ) { if( 0 == opt_elem->count ) { opt_elem->common.flags = DT_FLAG_BASIC; @@ -69,18 +70,19 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, { dt_elem_desc_t* pElemDesc; ddt_elem_desc_t opt_elem; - long last_disp = 0; + ptrdiff_t last_disp = 0; dt_stack_t* pStack; /* pointer to the position on the stack */ int32_t pos_desc = 0; /* actual position in the description of the derived datatype */ int32_t stack_pos = 0, last_type = DT_BYTE; - int32_t type = DT_LOOP, last_length = 0, nbElems = 0, changes = 0, last_extent = 1; - uint16_t last_flags = 0xFFFF; /* keep all for the first datatype */ - long total_disp = 0; + int32_t type = DT_LOOP, nbElems = 0, changes = 0; int32_t optimized = 0, continuity; + uint16_t last_flags = 0xFFFF; /* keep all for the first datatype */ + ptrdiff_t total_disp = 0, last_extent = 1; + int32_t last_length = 0; uint32_t i; pStack = (dt_stack_t*)alloca( sizeof(dt_stack_t) * (pData->btypes[DT_LOOP]+2) ); - SAVE_STACK( pStack, -1, 0, count, 0, pData->desc.used ); + SAVE_STACK( pStack, -1, 0, count, 0 ); pTypeDesc->length = 2 * pData->desc.used + 1 /* for the fake DT_END_LOOP at the end */; pTypeDesc->desc = pElemDesc = (dt_elem_desc_t*)malloc( sizeof(dt_elem_desc_t) * pTypeDesc->length ); @@ -119,13 +121,13 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, ddt_loop_desc_t* loop = (ddt_loop_desc_t*)&(pData->desc.desc[pos_desc]); ddt_endloop_desc_t* end_loop = (ddt_endloop_desc_t*)&(pData->desc.desc[pos_desc + loop->items]); int index = GET_FIRST_NON_LOOP( &(pData->desc.desc[pos_desc]) ); - long loop_disp = pData->desc.desc[pos_desc + index].elem.disp; + ptrdiff_t loop_disp = pData->desc.desc[pos_desc + index].elem.disp; - continuity = ((last_disp + last_length * (long)ompi_ddt_basicDatatypes[last_type]->size) + continuity = ((last_disp + last_length * (ptrdiff_t)ompi_ddt_basicDatatypes[last_type]->size) == (total_disp + loop_disp)); if( loop->common.flags & DT_FLAG_CONTIGUOUS ) { /* the loop is contiguous or composed by contiguous elements with a gap */ - if( loop->extent == (long)end_loop->size ) { + if( loop->extent == (ptrdiff_t)end_loop->size ) { /* the whole loop is contiguous */ if( !continuity ) { if( 0 != last_length ) { @@ -160,7 +162,7 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, /* we have a gap in the begining or the end of the loop but the whole * loop can be merged in just one memcpy. */ - CREATE_LOOP_START( pElemDesc, counter, (long)2, loop->extent, loop->common.flags ); + CREATE_LOOP_START( pElemDesc, counter, 2, loop->extent, loop->common.flags ); pElemDesc++; nbElems++; CREATE_ELEM( pElemDesc, DT_BYTE, DT_FLAG_BASIC, end_loop->size, loop_disp, 1); pElemDesc++; nbElems++; @@ -182,7 +184,7 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, } if( 2 == loop->items ) { /* small loop */ if( (1 == elem->count) - && (elem->extent == (long)ompi_ddt_basicDatatypes[elem->common.type]->size) ) { + && (elem->extent == (ptrdiff_t)ompi_ddt_basicDatatypes[elem->common.type]->size) ) { CREATE_ELEM( pElemDesc, elem->common.type, elem->common.flags & ~DT_FLAG_CONTIGUOUS, loop->loops, elem->disp, loop->extent ); pElemDesc++; nbElems++; @@ -190,7 +192,7 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, changes++; optimized++; goto complete_loop; } else if( loop->loops < 3 ) { - long elem_displ = elem->disp; + ptrdiff_t elem_displ = elem->disp; for( i = 0; i < loop->loops; i++ ) { CREATE_ELEM( pElemDesc, elem->common.type, elem->common.flags, elem->count, elem_displ, elem->extent ); @@ -204,7 +206,7 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, } CREATE_LOOP_START( pElemDesc, loop->loops, loop->items, loop->extent, loop->common.flags ); pElemDesc++; nbElems++; - PUSH_STACK( pStack, stack_pos, nbElems, DT_LOOP, loop->loops, total_disp, pos_desc + loop->extent ); + PUSH_STACK( pStack, stack_pos, nbElems, DT_LOOP, loop->loops, total_disp ); pos_desc++; DDT_DUMP_STACK( pStack, stack_pos, pData->desc.desc, "advance loops" ); } @@ -215,7 +217,7 @@ ompi_ddt_optimize_short( ompi_datatype_t* pData, while( pData->desc.desc[pos_desc].elem.common.flags & DT_FLAG_DATA ) { /* keep doing it until we reach a non datatype element */ /* now here we have a basic datatype */ type = pData->desc.desc[pos_desc].elem.common.type; - continuity = ((last_disp + last_length * (long)ompi_ddt_basicDatatypes[last_type]->size) + continuity = ((last_disp + last_length * (ptrdiff_t)ompi_ddt_basicDatatypes[last_type]->size) == (total_disp + pData->desc.desc[pos_desc].elem.disp)); if( (pData->desc.desc[pos_desc].elem.common.flags & DT_FLAG_CONTIGUOUS) && continuity && @@ -264,7 +266,7 @@ int32_t ompi_ddt_commit( ompi_datatype_t** data ) { ompi_datatype_t* pData = *data; ddt_endloop_desc_t* pLast = &(pData->desc.desc[pData->desc.used].end_loop); - long first_elem_disp = 0; + ptrdiff_t first_elem_disp = 0; if( pData->flags & DT_FLAG_COMMITED ) return OMPI_SUCCESS; pData->flags |= DT_FLAG_COMMITED; @@ -299,7 +301,7 @@ int32_t ompi_ddt_commit( ompi_datatype_t** data ) } /* If the data is contiguous is useless to generate an optimized version. */ - /*if( (long)pData->size == (pData->true_ub - pData->true_lb) ) return OMPI_SUCCESS; */ + /*if( pData->size == (pData->true_ub - pData->true_lb) ) return OMPI_SUCCESS; */ (void)ompi_ddt_optimize_short( pData, 1, &(pData->opt_desc) ); if( 0 != pData->opt_desc.used ) { diff --git a/ompi/datatype/dt_sndrcv.c b/ompi/datatype/dt_sndrcv.c index bc09aabbe9..0cb71dbd90 100644 --- a/ompi/datatype/dt_sndrcv.c +++ b/ompi/datatype/dt_sndrcv.c @@ -59,8 +59,8 @@ int32_t ompi_ddt_sndrcv( void *sbuf, int32_t scount, const ompi_datatype_t* sdty /* If same datatypes used, just copy. */ if (sdtype == rdtype) { - max_data = ( scount < rcount ? scount : rcount ); - ompi_ddt_copy_content_same_ddt(rdtype, max_data, (char*)rbuf, (char*)sbuf); + int32_t count = ( scount < rcount ? scount : rcount ); + ompi_ddt_copy_content_same_ddt(rdtype, count, (char*)rbuf, (char*)sbuf); return ((scount > rcount) ? MPI_ERR_TRUNCATE : MPI_SUCCESS); } diff --git a/ompi/datatype/fake_stack.c b/ompi/datatype/fake_stack.c index 546a5cc1c4..ecc4819906 100644 --- a/ompi/datatype/fake_stack.c +++ b/ompi/datatype/fake_stack.c @@ -29,11 +29,11 @@ #include int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, - int starting_point, - const int* sizes ); + size_t starting_point, + const size_t* sizes ); static inline size_t -ompi_convertor_compute_remote_size( const ompi_datatype_t* pData, const int* sizes ) +ompi_convertor_compute_remote_size( const ompi_datatype_t* pData, const size_t* sizes ) { uint32_t i; size_t length = 0; @@ -45,21 +45,20 @@ ompi_convertor_compute_remote_size( const ompi_datatype_t* pData, const int* siz } int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, - int starting_point, const int* sizes ) + size_t starting_point, const size_t* sizes ) { dt_stack_t* pStack; /* pointer to the position on the stack */ int pos_desc; /* actual position in the description of the derived datatype */ - int lastLength = 0, loop_length; + size_t lastLength = 0; const ompi_datatype_t* pData = pConvertor->pDesc; - int* remoteLength; - int resting_place = starting_point; + size_t loop_length, *remoteLength, remote_size; + size_t resting_place = starting_point; dt_elem_desc_t* pElems; - size_t remote_size; uint32_t count; assert( 0 != starting_point ); - assert( pConvertor->bConverted != (unsigned long)starting_point ); - assert( starting_point <= (int)(pConvertor->count * pData->size) ); + assert( pConvertor->bConverted != starting_point ); + assert( starting_point <=(pConvertor->count * pData->size) ); /*opal_output( 0, "Data extent %d size %d count %d total_size %d starting_point %d\n", pData->ub - pData->lb, pData->size, pConvertor->count, @@ -71,25 +70,23 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, * allow us to move quickly inside the datatype when we have a count. */ pElems = pConvertor->use_desc->desc; - pStack->end_loop = pConvertor->use_desc->used; if( (pConvertor->flags & CONVERTOR_HOMOGENEOUS) && (pData->flags & DT_FLAG_CONTIGUOUS) ) { /* Special case for contiguous datatypes */ - int cnt = starting_point / pData->size; - long extent = pData->ub - pData->lb; + int32_t cnt = (int32_t)(starting_point / pData->size); + ptrdiff_t extent = pData->ub - pData->lb; loop_length = GET_FIRST_NON_LOOP( pElems ); pStack[0].disp = pElems[loop_length].elem.disp; pStack[0].type = DT_LOOP; pStack[0].count = pConvertor->count - cnt; - cnt = starting_point - cnt * pData->size; /* number of bytes after the loop */ + cnt = (int32_t)(starting_point - cnt * pData->size); /* number of bytes after the loop */ pStack[1].index = 0; pStack[1].type = DT_BYTE; - pStack[1].end_loop = pStack->end_loop; pStack[1].disp = pStack[0].disp; pStack[1].count = pData->size - cnt; - if( (long)pData->size == extent ) { /* all elements are contiguous */ + if( (ptrdiff_t)pData->size == extent ) { /* all elements are contiguous */ pStack[1].disp += starting_point; } else { /* each is contiguous but there are gaps inbetween */ pStack[1].disp += (pConvertor->count - pStack[0].count) * extent + cnt; @@ -102,7 +99,7 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, /* remove from the main loop all the complete datatypes */ remote_size = ompi_convertor_compute_remote_size( pData, sizes ); - count = starting_point / remote_size; + count = (int32_t)(starting_point / remote_size); resting_place -= (remote_size * count); pStack->count = pConvertor->count - count; pStack->index = -1; @@ -111,17 +108,17 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, pStack->disp = count * (pData->ub - pData->lb) + pElems[loop_length].elem.disp; pos_desc = 0; - remoteLength = (int*)alloca( sizeof(int) * (pConvertor->pDesc->btypes[DT_LOOP] + 1)); + remoteLength = (size_t*)alloca( sizeof(size_t) * (pConvertor->pDesc->btypes[DT_LOOP] + 1)); remoteLength[0] = 0; /* initial value set to ZERO */ loop_length = 0; /* The only way to get out of this loop is when we reach the desired position or * when we finish the whole datatype. */ - while( pos_desc < pConvertor->pStack[0].end_loop ) { + while( pos_desc < (int32_t)pConvertor->use_desc->used ) { if( DT_END_LOOP == pElems->elem.common.type ) { /* end of the current loop */ ddt_endloop_desc_t* end_loop = (ddt_endloop_desc_t*)pElems; - long extent; + ptrdiff_t extent; if( (loop_length * pStack->count) > resting_place ) { /* We will stop somewhere on this loop. To avoid moving inside the loop @@ -129,7 +126,7 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, * stop. Once this index is computed we can then reparse the loop once * until we find the correct position. */ - int cnt = resting_place / loop_length; + int32_t cnt = (int32_t)(resting_place / loop_length); if( pStack->index == -1 ) { extent = pData->ub - pData->lb; } else { @@ -160,8 +157,8 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, } if( DT_LOOP == pElems->elem.common.type ) { remoteLength[pConvertor->stack_pos] += loop_length; - PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_LOOP, pElems->loop.loops, - pStack->disp, pos_desc + pElems->loop.items ); + PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_LOOP, + pElems->loop.loops, pStack->disp ); pos_desc++; pElems++; remoteLength[pConvertor->stack_pos] = 0; @@ -172,13 +169,12 @@ int ompi_convertor_create_stack_with_pos_general( ompi_convertor_t* pConvertor, const ompi_datatype_t* basic_type = BASIC_DDT_FROM_ELEM( (*pElems) ); lastLength = pElems->elem.count * basic_type->size; if( resting_place < lastLength ) { - int cnt = resting_place / basic_type->size; + int32_t cnt = (int32_t)(resting_place / basic_type->size); loop_length += (cnt * basic_type->size); resting_place -= (cnt * basic_type->size); PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, pElems->elem.common.type, pElems->elem.count - cnt, - pElems->elem.disp + cnt * pElems->elem.extent, - pos_desc ); + pElems->elem.disp + cnt * pElems->elem.extent ); pConvertor->bConverted = starting_point - resting_place; DDT_DUMP_STACK( pConvertor->pStack, pConvertor->stack_pos, pConvertor->pDesc->desc.desc, pConvertor->pDesc->name ); diff --git a/ompi/datatype/position.c b/ompi/datatype/position.c index d200a27d8a..dc07e242bc 100644 --- a/ompi/datatype/position.c +++ b/ompi/datatype/position.c @@ -50,14 +50,15 @@ static inline void position_predefined_data( ompi_convertor_t* CONVERTOR, dt_elem_desc_t* ELEM, uint32_t* COUNT, char** POINTER, - uint32_t* SPACE ) + size_t* SPACE ) { - uint32_t _copy_count = *(COUNT), _copy_blength; + uint32_t _copy_count = *(COUNT); + size_t _copy_blength; ddt_elem_desc_t* _elem = &((ELEM)->elem); _copy_blength = ompi_ddt_basicDatatypes[_elem->common.type]->size; if( (_copy_count * _copy_blength) > *(SPACE) ) { - _copy_count = *(SPACE) / _copy_blength; + _copy_count = (uint32_t)(*(SPACE) / _copy_blength); if( 0 == _copy_count ) return; /* nothing to do */ } _copy_blength *= _copy_count; @@ -73,14 +74,14 @@ static inline void position_contiguous_loop( ompi_convertor_t* CONVERTOR, dt_elem_desc_t* ELEM, uint32_t* COUNT, char** POINTER, - uint32_t* SPACE ) + size_t* SPACE ) { ddt_loop_desc_t *_loop = (ddt_loop_desc_t*)(ELEM); ddt_endloop_desc_t* _end_loop = (ddt_endloop_desc_t*)((ELEM) + (ELEM)->loop.items); - size_t _copy_loops = *(COUNT); + uint32_t _copy_loops = *(COUNT); if( (_copy_loops * _end_loop->size) > *(SPACE) ) - _copy_loops = *(SPACE) / _end_loop->size; + _copy_loops = (uint32_t)(*(SPACE) / _end_loop->size); OMPI_DDT_SAFEGUARD_POINTER( *(POINTER) + _end_loop->first_elem_disp, (_copy_loops - 1) * _loop->extent + _end_loop->size, (CONVERTOR)->pBaseBuf, (CONVERTOR)->pDesc, (CONVERTOR)->count ); @@ -105,8 +106,8 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, dt_elem_desc_t* description = pConvertor->use_desc->desc; dt_elem_desc_t* pElem; char *base_pointer = pConvertor->pBaseBuf; - uint32_t iov_len_local; - long extent = pConvertor->pDesc->ub - pConvertor->pDesc->lb; + size_t iov_len_local; + ptrdiff_t extent = pConvertor->pDesc->ub - pConvertor->pDesc->lb; DUMP( "ompi_convertor_generic_simple_pack( %p, &%ld )\n", (void*)pConvertor, (long)*position ); @@ -118,7 +119,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, iov_len_local = *position - pConvertor->bConverted; if( iov_len_local > pConvertor->pDesc->size ) { pStack = pConvertor->pStack; /* we're working with the full stack */ - count_desc = iov_len_local / pConvertor->pDesc->size; + count_desc = (uint32_t)(iov_len_local / pConvertor->pDesc->size); DO_DEBUG( opal_output( 0, "position before %ld asked %ld data size %d" " iov_len_local %d count_desc %d\n", pConvertor->bConverted, *position, pConvertor->pDesc->size, @@ -139,7 +140,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; base_pointer += pStack->disp; - count_desc = pStack->count; + count_desc = (uint32_t)pStack->count; pStack--; pConvertor->stack_pos--; pElem = &(description[pos_desc]); @@ -178,7 +179,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, pStack->count, pConvertor->stack_pos, pos_desc, pStack->disp, iov_len_local ); ); } if( DT_LOOP == pElem->elem.common.type ) { - long local_disp = (long)base_pointer; + ptrdiff_t local_disp = (ptrdiff_t)base_pointer; if( pElem->loop.common.flags & DT_FLAG_CONTIGUOUS ) { POSITION_CONTIGUOUS_LOOP( pConvertor, pElem, count_desc, base_pointer, iov_len_local ); @@ -188,9 +189,9 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, } /* Save the stack with the correct last_count value. */ } - local_disp = (long)base_pointer - local_disp; + local_disp = (ptrdiff_t)base_pointer - local_disp; PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_LOOP, count_desc, - pStack->disp + local_disp, pos_desc + pElem->elem.disp + 1); + pStack->disp + local_disp ); pos_desc++; update_loop_description: /* update the current state */ base_pointer = pConvertor->pBaseBuf + pStack->disp; @@ -204,7 +205,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, base_pointer, iov_len_local ); if( 0 != count_desc ) { /* completed */ type = pElem->elem.common.type; - pConvertor->partial_length = iov_len_local; + pConvertor->partial_length = (uint32_t)iov_len_local; goto complete_loop; } base_pointer = pConvertor->pBaseBuf + pStack->disp; @@ -218,7 +219,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor, if( !(pConvertor->flags & CONVERTOR_COMPLETED) ) { /* I complete an element, next step I should go to the next one */ PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_BYTE, count_desc, - base_pointer - pStack->disp - pConvertor->pBaseBuf, pos_desc ); + base_pointer - pStack->disp - pConvertor->pBaseBuf ); DO_DEBUG( opal_output( 0, "position save stack stack_pos %d pos_desc %d count_desc %d disp %ld\n", pConvertor->stack_pos, pStack->index, pStack->count, pStack->disp ); ); return 0; diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 4ec06a14a3..cd0a74c78d 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -148,7 +148,8 @@ extern "C" { /* * Typedefs */ -typedef long MPI_Aint; +#include +typedef ptrdiff_t MPI_Aint; typedef OMPI_MPI_OFFSET_TYPE MPI_Offset; typedef struct ompi_communicator_t *MPI_Comm; typedef struct ompi_datatype_t *MPI_Datatype; diff --git a/ompi/mca/coll/basic/coll_basic_allgather.c b/ompi/mca/coll/basic/coll_basic_allgather.c index f6198f9f97..be12293b94 100644 --- a/ompi/mca/coll/basic/coll_basic_allgather.c +++ b/ompi/mca/coll/basic/coll_basic_allgather.c @@ -45,7 +45,7 @@ mca_coll_basic_allgather_intra(void *sbuf, int scount, { int err; char *rbuf_original = NULL, *inplace_temp = NULL; - long true_lb, true_extent, lb, extent; + ptrdiff_t true_lb, true_extent, lb, extent; /* Handle MPI_IN_PLACE (see explanantion in reduce.c for how to allocate temp buffer) -- note that rank 0 can use IN_PLACE @@ -112,8 +112,8 @@ mca_coll_basic_allgather_inter(void *sbuf, int scount, int err; int i; char *tmpbuf = NULL, *ptmp; - long rlb, slb, rextent, sextent; - long incr; + ptrdiff_t rlb, slb, rextent, sextent; + ptrdiff_t incr; ompi_request_t *req; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; diff --git a/ompi/mca/coll/basic/coll_basic_allreduce.c b/ompi/mca/coll/basic/coll_basic_allreduce.c index 3706cf8a6c..3f72297523 100644 --- a/ompi/mca/coll/basic/coll_basic_allreduce.c +++ b/ompi/mca/coll/basic/coll_basic_allreduce.c @@ -80,7 +80,7 @@ mca_coll_basic_allreduce_inter(void *sbuf, void *rbuf, int count, int rank; int root = 0; int rsize; - long lb, extent; + ptrdiff_t lb, extent; char *tmpbuf = NULL, *pml_buffer = NULL; ompi_request_t *req[2]; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; diff --git a/ompi/mca/coll/basic/coll_basic_exscan.c b/ompi/mca/coll/basic/coll_basic_exscan.c index ea5f3c333a..c25311e76f 100644 --- a/ompi/mca/coll/basic/coll_basic_exscan.c +++ b/ompi/mca/coll/basic/coll_basic_exscan.c @@ -44,10 +44,8 @@ mca_coll_basic_exscan_intra(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, struct ompi_communicator_t *comm) { - int size; - int rank; - int err; - long true_lb, true_extent, lb, extent; + int size, rank, err; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *reduce_buffer = NULL; char *source; diff --git a/ompi/mca/coll/basic/coll_basic_gatherv.c b/ompi/mca/coll/basic/coll_basic_gatherv.c index d05ef53b01..4e3cd2fc8b 100644 --- a/ompi/mca/coll/basic/coll_basic_gatherv.c +++ b/ompi/mca/coll/basic/coll_basic_gatherv.c @@ -40,13 +40,9 @@ mca_coll_basic_gatherv_intra(void *sbuf, int scount, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long extent; + ptrdiff_t lb, extent; size = ompi_comm_size(comm); rank = ompi_comm_rank(comm); @@ -116,13 +112,9 @@ mca_coll_basic_gatherv_inter(void *sbuf, int scount, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long extent; + ptrdiff_t lb, extent; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; size = ompi_comm_remote_size(comm); diff --git a/ompi/mca/coll/basic/coll_basic_reduce.c b/ompi/mca/coll/basic/coll_basic_reduce.c index a121fdbd22..effccf57ca 100644 --- a/ompi/mca/coll/basic/coll_basic_reduce.c +++ b/ompi/mca/coll/basic/coll_basic_reduce.c @@ -40,11 +40,8 @@ mca_coll_basic_reduce_lin_intra(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int err; - int size; - long true_lb, true_extent, lb, extent; + int i, rank, err, size; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *pml_buffer = NULL; char *inplace_temp = NULL; @@ -276,15 +273,9 @@ mca_coll_basic_reduce_log_intra(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int i; - int size; - int rank; - int vrank; - int err; - int peer; - int dim; - int mask; - long true_lb, true_extent, lb, extent; + int i, size, rank, vrank; + int err, peer, dim, mask; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *free_rbuf = NULL; char *pml_buffer = NULL; @@ -490,11 +481,8 @@ mca_coll_basic_reduce_lin_inter(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int err; - int size; - long true_lb, true_extent, lb, extent; + int i, rank, err, size; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *pml_buffer = NULL; diff --git a/ompi/mca/coll/basic/coll_basic_reduce_scatter.c b/ompi/mca/coll/basic/coll_basic_reduce_scatter.c index b4160fcaea..df3bb9fed9 100644 --- a/ompi/mca/coll/basic/coll_basic_reduce_scatter.c +++ b/ompi/mca/coll/basic/coll_basic_reduce_scatter.c @@ -43,12 +43,8 @@ mca_coll_basic_reduce_scatter_intra(void *sbuf, void *rbuf, int *rcounts, struct ompi_op_t *op, struct ompi_communicator_t *comm) { - int i; - int err; - int rank; - int size; - int count; - long true_lb, true_extent, lb, extent; + int i, err, rank, size, count; + ptrdiff_t true_lb, true_extent, lb, extent; int *disps = NULL; char *free_buffer = NULL; char *pml_buffer = NULL; @@ -138,12 +134,9 @@ mca_coll_basic_reduce_scatter_inter(void *sbuf, void *rbuf, int *rcounts, struct ompi_op_t *op, struct ompi_communicator_t *comm) { - int err, i; - int rank; - int root = 0; - int rsize; + int err, i, rank, root = 0, rsize; int totalcounts, tcount; - long lb, extent; + ptrdiff_t lb, extent; char *tmpbuf = NULL, *tmpbuf2 = NULL, *tbuf = NULL; ompi_request_t *req; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; diff --git a/ompi/mca/coll/basic/coll_basic_scan.c b/ompi/mca/coll/basic/coll_basic_scan.c index 33eb6d82da..891d471980 100644 --- a/ompi/mca/coll/basic/coll_basic_scan.c +++ b/ompi/mca/coll/basic/coll_basic_scan.c @@ -42,10 +42,8 @@ mca_coll_basic_scan_intra(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, struct ompi_communicator_t *comm) { - int size; - int rank; - int err; - long true_lb, true_extent, lb, extent; + int size, rank, err; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *pml_buffer = NULL; diff --git a/ompi/mca/coll/basic/coll_basic_scatter.c b/ompi/mca/coll/basic/coll_basic_scatter.c index 14a00c8025..d2ed90a4e6 100644 --- a/ompi/mca/coll/basic/coll_basic_scatter.c +++ b/ompi/mca/coll/basic/coll_basic_scatter.c @@ -42,13 +42,9 @@ mca_coll_basic_scatter_intra(void *sbuf, int scount, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long incr; + ptrdiff_t lb, incr; /* Initialize */ @@ -112,13 +108,9 @@ mca_coll_basic_scatter_inter(void *sbuf, int scount, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long incr; + ptrdiff_t lb, incr; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; /* Initialize */ diff --git a/ompi/mca/coll/basic/coll_basic_scatterv.c b/ompi/mca/coll/basic/coll_basic_scatterv.c index 07912de264..e9e787b4c0 100644 --- a/ompi/mca/coll/basic/coll_basic_scatterv.c +++ b/ompi/mca/coll/basic/coll_basic_scatterv.c @@ -42,13 +42,9 @@ mca_coll_basic_scatterv_intra(void *sbuf, int *scounts, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long extent; + ptrdiff_t lb, extent; /* Initialize */ @@ -118,13 +114,9 @@ mca_coll_basic_scatterv_inter(void *sbuf, int *scounts, struct ompi_datatype_t *rdtype, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int size; - int err; + int i, rank, size, err; char *ptmp; - long lb; - long extent; + ptrdiff_t lb, extent; ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs; /* Initialize */ diff --git a/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c b/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c index fd56bc830a..646aabdf3b 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c @@ -46,7 +46,7 @@ int mca_coll_hierarch_allreduce_intra(void *sbuf, void *rbuf, int count, struct ompi_communicator_t *lcomm=NULL; int rank; int lroot, llroot; - long extent, true_extent, lb, true_lb; + ptrdiff_t extent, true_extent, lb, true_lb; char *tmpbuf=NULL, *tbuf=NULL; int ret=OMPI_SUCCESS; int root=0; diff --git a/ompi/mca/coll/hierarch/coll_hierarch_reduce.c b/ompi/mca/coll/hierarch/coll_hierarch_reduce.c index 9d3a2ee549..0dce5ffbc6 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_reduce.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_reduce.c @@ -46,7 +46,7 @@ int mca_coll_hierarch_reduce_intra(void *sbuf, void *rbuf, int count, struct ompi_communicator_t *lcomm=NULL; int rank; int lroot, llroot; - long extent, true_extent, lb, true_lb; + ptrdiff_t extent, true_extent, lb, true_lb; char *tmpbuf=NULL, *tbuf=NULL; int ret=OMPI_SUCCESS; diff --git a/ompi/mca/coll/hierarch/coll_hierarch_tmpcoll.c b/ompi/mca/coll/hierarch/coll_hierarch_tmpcoll.c index 8d051514ce..e687759165 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_tmpcoll.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_tmpcoll.c @@ -109,12 +109,10 @@ int mca_coll_hierarch_reduce_tmp(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int i; - int err; - int size; + int i, err, size; char *pml_buffer = NULL; - long extent, lb; - int rank=ompi_comm_rank(comm);; + ptrdiff_t extent, lb; + int rank = ompi_comm_rank(comm);; /* If not root, send data to the root. */ if (rank != root) { diff --git a/ompi/mca/coll/sm/coll_sm_reduce.c b/ompi/mca/coll/sm/coll_sm_reduce.c index 0bb83c7168..1c148e9b72 100644 --- a/ompi/mca/coll/sm/coll_sm_reduce.c +++ b/ompi/mca/coll/sm/coll_sm_reduce.c @@ -62,7 +62,7 @@ int mca_coll_sm_reduce_intra(void *sbuf, void* rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int32_t size; + size_t size; /* There are several possibilities: * @@ -77,7 +77,7 @@ int mca_coll_sm_reduce_intra(void *sbuf, void* rbuf, int count, */ ompi_ddt_type_size(dtype, &size); - if (size > mca_coll_sm_component.sm_control_size) { + if ((int)size > mca_coll_sm_component.sm_control_size) { return comm->c_coll_basic_module->coll_reduce(sbuf, rbuf, count, dtype, op, root, comm); } @@ -150,7 +150,7 @@ static int reduce_inorder(void *sbuf, void* rbuf, int count, mca_coll_sm_in_use_flag_t *flag; ompi_convertor_t convertor; mca_coll_base_mpool_index_t *index; - int32_t ddt_size; + size_t ddt_size; size_t segment_ddt_count, segment_ddt_bytes, zero = 0; /* Setup some identities */ @@ -182,7 +182,7 @@ static int reduce_inorder(void *sbuf, void* rbuf, int count, if (root == rank) { char *reduce_temp_buffer, *free_buffer, *reduce_target; - long true_lb, true_extent, lb, extent; + ptrdiff_t true_lb, true_extent, lb, extent; char *inplace_temp; int peer; size_t count_left = (size_t)count; diff --git a/ompi/mca/coll/tuned/coll_tuned_alltoall.c b/ompi/mca/coll/tuned/coll_tuned_alltoall.c index 9f74c7b292..f35147ee0d 100644 --- a/ompi/mca/coll/tuned/coll_tuned_alltoall.c +++ b/ompi/mca/coll/tuned/coll_tuned_alltoall.c @@ -40,16 +40,13 @@ int ompi_coll_tuned_alltoall_intra_pairwise(void *sbuf, int scount, int rank, size, step; int sendto, recvfrom; void * tmpsend, *tmprecv; - MPI_Aint sext, rext; - long lb; - + ptrdiff_t lb, sext, rext; size = ompi_comm_size(comm); rank = ompi_comm_rank(comm); OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:alltoall_intra_pairwise rank %d", rank)); - err = ompi_ddt_get_extent (sdtype, &lb, &sext); if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; } @@ -91,23 +88,19 @@ int ompi_coll_tuned_alltoall_intra_bruck(void *sbuf, int scount, { int i, k, line = -1; int rank, size; - MPI_Aint sext, rext; int sendto, recvfrom, distance, *displs=NULL, *blen=NULL; int maxpacksize, packsize, position; char * tmpbuf=NULL, *packbuf=NULL; - long lb; + ptrdiff_t lb, sext, rext; int err = 0; int weallocated = 0; MPI_Datatype iddt; - - size = ompi_comm_size(comm); rank = ompi_comm_rank(comm); OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:alltoall_intra_bruck rank %d", rank)); - err = ompi_ddt_get_extent (sdtype, &lb, &sext); if (err != MPI_SUCCESS) { line = __LINE__; goto err_hndl; } @@ -258,8 +251,7 @@ int ompi_coll_tuned_alltoall_intra_two_procs(void *sbuf, int scount, int rank; int sendto, recvfrom; void * tmpsend, *tmprecv; - MPI_Aint sext, rext; - long lb; + ptrdiff_t sext, rext, lb; rank = ompi_comm_rank(comm); diff --git a/ompi/mca/coll/tuned/coll_tuned_bcast.c b/ompi/mca/coll/tuned/coll_tuned_bcast.c index 81c1211eac..96aede37a5 100644 --- a/ompi/mca/coll/tuned/coll_tuned_bcast.c +++ b/ompi/mca/coll/tuned/coll_tuned_bcast.c @@ -43,8 +43,8 @@ ompi_coll_tuned_bcast_intra_chain ( void *buff, int count, int new_sendcount; /* used to mane the size for the next pipelined receive */ int realsegsize; char *tmpbuf = (char*)buff; - long type_extent, lb; - int typelng; + size_t typelng; + ptrdiff_t type_extent, lb; ompi_request_t *base_req, *new_req; ompi_coll_chain_t* chain; @@ -245,9 +245,8 @@ ompi_coll_tuned_bcast_intra_split_bintree ( void* buffer, int sendcount[2]; /* the same like segcount, except for the last segment */ int realsegsize[2]; char *tmpbuf[2]; - int type_size; - long type_extent; - long lb; + size_t type_size; + ptrdiff_t type_extent, lb; ompi_request_t *base_req, *new_req; ompi_coll_tree_t *tree; @@ -506,9 +505,8 @@ ompi_coll_tuned_bcast_intra_bintree ( void* buffer, int sendcount; /* the same like segcount, except for the last segment */ int realsegsize; char *tmpbuf; - int type_size; - long type_extent; - long lb; + size_t type_size; + ptrdiff_t type_extent, lb; ompi_request_t *base_req, *new_req, *send_reqs[2]; ompi_coll_tree_t *tree; diff --git a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c index 88d94865bf..3a528b95bb 100644 --- a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c +++ b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c @@ -66,7 +66,7 @@ ompi_coll_tuned_allreduce_intra_dec_dynamic (void *sbuf, void *rbuf, int count, /* we do, so calc the message size or what ever we need and use this for the evaluation */ int alg, faninout, segsize; - int dsize; + size_t dsize; ompi_ddt_type_size (dtype, &dsize); dsize *= count; @@ -111,7 +111,7 @@ int ompi_coll_tuned_alltoall_intra_dec_dynamic(void *sbuf, int scount, /* we do, so calc the message size or what ever we need and use this for the evaluation */ int comsize; int alg, faninout, segsize; - int dsize; + size_t dsize; ompi_ddt_type_size (sdtype, &dsize); comsize = ompi_comm_size(comm); @@ -190,7 +190,7 @@ int ompi_coll_tuned_bcast_intra_dec_dynamic(void *buff, int count, /* we do, so calc the message size or what ever we need and use this for the evaluation */ int alg, faninout, segsize; - int dsize; + size_t dsize; ompi_ddt_type_size (datatype, &dsize); dsize *= count; @@ -235,7 +235,7 @@ int ompi_coll_tuned_reduce_intra_dec_dynamic( void *sendbuf, void *recvbuf, /* we do, so calc the message size or what ever we need and use this for the evaluation */ int alg, faninout, segsize; - int dsize; + size_t dsize; ompi_ddt_type_size (datatype, &dsize); dsize *= count; diff --git a/ompi/mca/coll/tuned/coll_tuned_reduce.c b/ompi/mca/coll/tuned/coll_tuned_reduce.c index 7a74980f02..b1fddf7bf6 100644 --- a/ompi/mca/coll/tuned/coll_tuned_reduce.c +++ b/ompi/mca/coll/tuned/coll_tuned_reduce.c @@ -47,13 +47,12 @@ int ompi_coll_tuned_reduce_intra_chain( void *sendbuf, void *recvbuf, int count, char *inbuf[2] = {(char*)NULL, (char*)NULL}; char *accumbuf = (char*)NULL; char *sendtmpbuf = (char*)NULL; - long ext, lb; - unsigned long typelng; + ptrdiff_t ext, lb; + size_t typelng; int allocedaccumbuf = 0; ompi_request_t* reqs[2]; ompi_coll_chain_t* chain; - size = ompi_comm_size(comm); rank = ompi_comm_rank(comm); @@ -334,11 +333,8 @@ ompi_coll_tuned_reduce_intra_basic_linear(void *sbuf, void *rbuf, int count, struct ompi_op_t *op, int root, struct ompi_communicator_t *comm) { - int i; - int rank; - int err; - int size; - long true_lb, true_extent, lb, extent; + int i, rank, err, size; + ptrdiff_t true_lb, true_extent, lb, extent; char *free_buffer = NULL; char *pml_buffer = NULL; char *inplace_temp = NULL; diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_data_move.c b/ompi/mca/osc/pt2pt/osc_pt2pt_data_move.c index 79a184a441..5d7541351c 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_data_move.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_data_move.c @@ -636,7 +636,7 @@ ompi_osc_pt2pt_sendreq_recv_accum(ompi_osc_pt2pt_module_t *module, } else { ompi_osc_pt2pt_longreq_t *longreq; - long lb, extent, true_lb, true_extent; + ptrdiff_t lb, extent, true_lb, true_extent; size_t buflen; /* figure out how big a buffer we need */ diff --git a/ompi/mca/osc/rdma/osc_rdma_data_move.c b/ompi/mca/osc/rdma/osc_rdma_data_move.c index 00b2c69bf9..4c3deaf2c6 100644 --- a/ompi/mca/osc/rdma/osc_rdma_data_move.c +++ b/ompi/mca/osc/rdma/osc_rdma_data_move.c @@ -644,7 +644,7 @@ ompi_osc_rdma_sendreq_recv_accum(ompi_osc_rdma_module_t *module, } else { ompi_osc_rdma_longreq_t *longreq; - long lb, extent, true_lb, true_extent; + ptrdiff_t lb, extent, true_lb, true_extent; size_t buflen; /* figure out how big a buffer we need */ diff --git a/ompi/mca/pml/dr/pml_dr_recvfrag.h b/ompi/mca/pml/dr/pml_dr_recvfrag.h index 0ec3defd86..edc83ae6bb 100644 --- a/ompi/mca/pml/dr/pml_dr_recvfrag.h +++ b/ompi/mca/pml/dr/pml_dr_recvfrag.h @@ -67,7 +67,7 @@ do { \ do { \ size_t i, length = 0; \ uint32_t ui1 = 0; \ - uint32_t ui2 = 0; \ + size_t ui2 = 0; \ mca_pml_dr_buffer_t** buffers = frag->buffers; \ bool do_csum = mca_pml_dr.enable_csum && \ (btl->btl_flags & MCA_BTL_FLAGS_NEED_CSUM); \ diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 472d2b78a3..9eee286e86 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -270,7 +270,7 @@ static int mca_pml_ob1_recv_request_ack( mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma)) { char* base; char* align; - long lb; + ptrdiff_t lb; /* round this up/down to the next aligned address */ ompi_ddt_type_lb(recvreq->req_recv.req_convertor.pDesc, &lb); @@ -696,7 +696,7 @@ int mca_pml_ob1_recv_request_schedule_exclusive( if(0 == recvreq->req_rdma_cnt) { char* base; - long lb; + ptrdiff_t lb; if(mca_pml_ob1.leave_pinned_pipeline) { /* lookup and/or create a cached registration */ diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index f2493c973d..f918e1d88d 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -1071,7 +1071,7 @@ int mca_pml_ob1_send_request_put_frag( /* if registration doesnt exist - create one */ if (mca_pml_ob1.leave_pinned_pipeline && reg == NULL) { unsigned char* base; - long lb; + ptrdiff_t lb; ompi_ddt_type_lb(sendreq->req_send.req_convertor.pDesc, &lb); base = (unsigned char*)sendreq->req_send.req_convertor.pBaseBuf + lb + offset; reg = mca_pml_ob1_rdma_register(bml_btl, base, frag->rdma_length); diff --git a/ompi/mpi/c/bindings.h b/ompi/mpi/c/bindings.h index dbc19dca05..108af52527 100644 --- a/ompi/mpi/c/bindings.h +++ b/ompi/mpi/c/bindings.h @@ -80,9 +80,9 @@ extern "C" { if ( (DDT)->flags & DT_FLAG_PREDEFINED ) { \ (RC) = MPI_ERR_BUFFER; \ } else { \ - unsigned long size = 0; \ - long true_lb = 0; \ - long true_extended = 0; \ + size_t size = 0; \ + ptrdiff_t true_lb = 0; \ + ptrdiff_t true_extended = 0; \ ompi_ddt_get_size((DDT), &size); \ ompi_ddt_get_true_extent((DDT), &true_lb, &true_extended); \ if ( 0 < size && 0 == true_lb ) { \ diff --git a/ompi/mpi/c/get_elements.c b/ompi/mpi/c/get_elements.c index 0d81270fbc..61dbd52451 100644 --- a/ompi/mpi/c/get_elements.c +++ b/ompi/mpi/c/get_elements.c @@ -34,7 +34,8 @@ static const char FUNC_NAME[] = "MPI_Get_elements"; int MPI_Get_elements(MPI_Status *status, MPI_Datatype datatype, int *count) { - int size, i; + int i; + size_t size; if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/ompi/mpi/c/status_set_elements.c b/ompi/mpi/c/status_set_elements.c index 873c5e1195..a5537c5081 100644 --- a/ompi/mpi/c/status_set_elements.c +++ b/ompi/mpi/c/status_set_elements.c @@ -36,7 +36,7 @@ int MPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype, int count) { int rc = MPI_SUCCESS; - int32_t size; + size_t size; if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); @@ -50,7 +50,7 @@ int MPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype, if (status != MPI_STATUS_IGNORE) { ompi_ddt_type_size( datatype, &size ); - status->_count = count * size; + status->_count = (int)(count * size); } return MPI_SUCCESS; } diff --git a/ompi/mpi/c/type_create_darray.c b/ompi/mpi/c/type_create_darray.c index 2e90f5e4e3..b6ead16108 100644 --- a/ompi/mpi/c/type_create_darray.c +++ b/ompi/mpi/c/type_create_darray.c @@ -31,7 +31,7 @@ static const char FUNC_NAME[] = "MPI_Type_create_darray"; -static MPI_Datatype cyclic( int32_t darg, int32_t gsize, int32_t r, int32_t psize, MPI_Datatype oldtype ) +static ompi_datatype_t* cyclic( int32_t darg, int32_t gsize, int32_t r, int32_t psize, ompi_datatype_t* oldtype ) { int count, darg_last; @@ -74,7 +74,7 @@ int MPI_Type_create_darray(int size, { int32_t i, darg_i, step, end_loop, *r; - MPI_Datatype temptype; + ompi_datatype_t* temptype; if (MPI_PARAM_CHECK) { int prod_psize = 1; @@ -154,7 +154,6 @@ int MPI_Type_create_darray(int size, } while( i != end_loop ); free( r ); - /* This function is not yet implemented */ { int* a_i[8]; diff --git a/ompi/mpi/c/win_create.c b/ompi/mpi/c/win_create.c index e33c2bc0f7..85de304bf7 100644 --- a/ompi/mpi/c/win_create.c +++ b/ompi/mpi/c/win_create.c @@ -66,7 +66,7 @@ int MPI_Win_create(void *base, MPI_Aint size, int disp_unit, } /* create window and return */ - ret = ompi_win_create(base, size, disp_unit, comm, + ret = ompi_win_create(base, (size_t)size, disp_unit, comm, info, win); if (OMPI_SUCCESS != ret) { *win = MPI_WIN_NULL; diff --git a/ompi/win/win.c b/ompi/win/win.c index a7777b3615..4beb950638 100644 --- a/ompi/win/win.c +++ b/ompi/win/win.c @@ -72,7 +72,7 @@ ompi_win_finalize(void) int -ompi_win_create(void *base, long size, +ompi_win_create(void *base, size_t size, int disp_unit, ompi_communicator_t *comm, ompi_info_t *info, ompi_win_t** newwin) diff --git a/ompi/win/win.h b/ompi/win/win.h index 9055181bdf..c48e6e8ce1 100644 --- a/ompi/win/win.h +++ b/ompi/win/win.h @@ -79,7 +79,7 @@ struct ompi_win_t { int w_disp_unit; void *w_baseptr; - long w_size; + size_t w_size; /** Current epoch / mode (access, expose, lock, etc.). Checked by the argument checking code in the MPI layer, set by the OSC @@ -97,7 +97,7 @@ OMPI_DECLSPEC extern ompi_win_t ompi_mpi_win_null; int ompi_win_init(void); int ompi_win_finalize(void); -int ompi_win_create(void *base, long size, int disp_unit, +int ompi_win_create(void *base, size_t size, int disp_unit, ompi_communicator_t *comm, ompi_info_t *info, ompi_win_t **newwin); diff --git a/opal/util/crc.c b/opal/util/crc.c index 9457a4aff4..f1596641ae 100644 --- a/opal/util/crc.c +++ b/opal/util/crc.c @@ -66,16 +66,16 @@ unsigned long opal_bcopy_csum_partial ( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen, + size_t copylen, + size_t csumlen, unsigned long * lastPartialLong, - unsigned long * lastPartialLength + size_t* lastPartialLength ) { unsigned long * src = (unsigned long *) source; unsigned long * dest = (unsigned long *) destination; unsigned long csum = 0; - ssize_t csumlenresidue; + size_t csumlenresidue; unsigned long i, temp; csumlenresidue = (csumlen > copylen) ? (csumlen - copylen) : 0; @@ -116,18 +116,18 @@ opal_bcopy_csum_partial ( } } else { /* fast path... */ - unsigned long numLongs = copylen/sizeof(unsigned long); + size_t numLongs = copylen/sizeof(unsigned long); for(i = 0; i < numLongs; i++) { - csum += *src; - *dest++ = *src++; + csum += *src; + *dest++ = *src++; } *lastPartialLong = 0; *lastPartialLength = 0; if (WORDALIGNED(copylen) && (csumlenresidue == 0)) { - return(csum); + return(csum); } else { - copylen -= i * sizeof(unsigned long); + copylen -= i * sizeof(unsigned long); } } } else if (WORDALIGNED(source)) { @@ -144,36 +144,36 @@ opal_bcopy_csum_partial ( copylen -= sizeof(unsigned long) - *lastPartialLength; /* now we have an unaligned source and an unknown alignment for our destination */ if (WORDALIGNED(dest)) { - unsigned long numLongs = copylen/sizeof(unsigned long); + size_t numLongs = copylen/sizeof(unsigned long); for(i = 0; i < numLongs; i++) { - memcpy(&temp, src, sizeof(temp)); - src++; - csum += temp; - *dest++ = temp; + memcpy(&temp, src, sizeof(temp)); + src++; + csum += temp; + *dest++ = temp; } copylen -= i * sizeof(unsigned long); } else { for( ;copylen >= sizeof(*src); copylen -= sizeof(*src)) { - memcpy(&temp, src, sizeof(temp)); - src++; - csum += temp; - memcpy(dest, &temp, sizeof(temp)); - dest++; + memcpy(&temp, src, sizeof(temp)); + src++; + csum += temp; + memcpy(dest, &temp, sizeof(temp)); + dest++; } } *lastPartialLong = 0; *lastPartialLength = 0; } else { /* NO, we don't... */ - memcpy(((char *)&temp + *lastPartialLength), src, copylen); - memcpy(dest, ((char *)&temp + *lastPartialLength), copylen); - src = (unsigned long *)((char *)src + copylen); - dest = (unsigned long *)((char *)dest + copylen); - csum += (temp - *lastPartialLong); - *lastPartialLong = temp; - *lastPartialLength += copylen; - copylen = 0; + memcpy(((char *)&temp + *lastPartialLength), src, copylen); + memcpy(dest, ((char *)&temp + *lastPartialLength), copylen); + src = (unsigned long *)((char *)src + copylen); + dest = (unsigned long *)((char *)dest + copylen); + csum += (temp - *lastPartialLong); + *lastPartialLong = temp; + *lastPartialLength += copylen; + copylen = 0; } } else { @@ -256,20 +256,20 @@ opal_bcopy_csum_partial ( copylen -= sizeof(unsigned long) - *lastPartialLength; /* now we have an unknown alignment for our source and destination */ if (WORDALIGNED(src) && WORDALIGNED(dest)) { - unsigned long numLongs = copylen/sizeof(unsigned long); + size_t numLongs = copylen/sizeof(unsigned long); for(i = 0; i < numLongs; i++) { - csum += *src; - *dest++ = *src++; + csum += *src; + *dest++ = *src++; } copylen -= i * sizeof(unsigned long); } else { /* safe but slower for all other alignments */ for( ;copylen >= sizeof(*src); copylen -= sizeof(*src)) { - memcpy(&temp, src, sizeof(temp)); - src++; - csum += temp; - memcpy(dest, &temp, sizeof(temp)); - dest++; + memcpy(&temp, src, sizeof(temp)); + src++; + csum += temp; + memcpy(dest, &temp, sizeof(temp)); + dest++; } } *lastPartialLong = 0; @@ -359,7 +359,7 @@ opal_bcopy_csum_partial ( memcpy(&temp, src, copylen); memcpy(dest, &temp, copylen); } - if (csumlenresidue < (ssize_t)(sizeof(unsigned long) - copylen - *lastPartialLength)) { + if (csumlenresidue < (sizeof(unsigned long) - copylen - *lastPartialLength)) { temp = *lastPartialLong; memcpy(((char *)&temp + *lastPartialLength), src, (copylen + csumlenresidue)); /* avoid unsigned arithmetic overflow by subtracting the old partial */ @@ -413,16 +413,16 @@ unsigned int opal_bcopy_uicsum_partial ( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen, - unsigned int * lastPartialInt, - unsigned int * lastPartialLength + size_t copylen, + size_t csumlen, + unsigned int* lastPartialInt, + size_t* lastPartialLength ) { unsigned int * src = (unsigned int *) source; unsigned int * dest = (unsigned int *) destination; unsigned int csum = 0; - ssize_t csumlenresidue; + size_t csumlenresidue; unsigned long i; unsigned int temp; @@ -464,18 +464,18 @@ opal_bcopy_uicsum_partial ( } } else { /* fast path... */ - unsigned long numLongs = copylen/sizeof(unsigned int); + size_t numLongs = copylen/sizeof(unsigned int); for(i = 0; i < numLongs; i++) { - csum += *src; - *dest++ = *src++; + csum += *src; + *dest++ = *src++; } *lastPartialInt = 0; *lastPartialLength = 0; if (INTALIGNED(copylen) && (csumlenresidue == 0)) { - return(csum); + return(csum); } else { - copylen -= i * sizeof(unsigned int); + copylen -= i * sizeof(unsigned int); } } } else if (INTALIGNED(source)) { @@ -492,7 +492,7 @@ opal_bcopy_uicsum_partial ( copylen -= sizeof(unsigned int) - *lastPartialLength; /* now we have an unaligned source and an unknown alignment for our destination */ if (INTALIGNED(dest)) { - unsigned long numLongs = copylen/sizeof(unsigned int); + size_t numLongs = copylen/sizeof(unsigned int); for(i = 0; i < numLongs; i++) { memcpy(&temp, src, sizeof(temp)); src++; @@ -604,7 +604,7 @@ opal_bcopy_uicsum_partial ( copylen -= sizeof(unsigned int) - *lastPartialLength; /* now we have an unknown alignment for our source and destination */ if (INTALIGNED(src) && INTALIGNED(dest)) { - unsigned long numLongs = copylen/sizeof(unsigned int); + size_t numLongs = copylen/sizeof(unsigned int); for(i = 0; i < numLongs; i++) { csum += *src; *dest++ = *src++; @@ -707,7 +707,7 @@ opal_bcopy_uicsum_partial ( memcpy(&temp, src, copylen); memcpy(dest, &temp, copylen); } - if (csumlenresidue < (ssize_t)(sizeof(unsigned int) - copylen - *lastPartialLength)) { + if (csumlenresidue < (sizeof(unsigned int) - copylen - *lastPartialLength)) { temp = *lastPartialInt; memcpy(((char *)&temp + *lastPartialLength), src, (copylen + csumlenresidue)); /* avoid unsigned arithmetic overflow by subtracting the old partial @@ -769,9 +769,9 @@ opal_bcopy_uicsum_partial ( unsigned long opal_csum_partial ( const void * source, - unsigned long csumlen, - unsigned long * lastPartialLong, - unsigned long * lastPartialLength + size_t csumlen, + unsigned long* lastPartialLong, + size_t* lastPartialLength ) { unsigned long * src = (unsigned long *) source; @@ -811,17 +811,17 @@ opal_csum_partial ( } } else { /* fast path... */ - unsigned long numLongs = csumlen/sizeof(unsigned long); + size_t numLongs = csumlen/sizeof(unsigned long); for(i = 0; i < numLongs; i++) { - csum += *src++; + csum += *src++; } *lastPartialLong = 0; *lastPartialLength = 0; if (WORDALIGNED(csumlen)) { - return(csum); + return(csum); } else { - csumlen -= i * sizeof(unsigned long); + csumlen -= i * sizeof(unsigned long); } } } else { @@ -919,9 +919,9 @@ opal_csum_partial ( unsigned int opal_uicsum_partial ( const void * source, - unsigned long csumlen, - unsigned int * lastPartialInt, - unsigned int * lastPartialLength + size_t csumlen, + unsigned int* lastPartialInt, + size_t* lastPartialLength ) { unsigned int * src = (unsigned int *) source; @@ -961,17 +961,17 @@ opal_uicsum_partial ( } } else { /* fast path... */ - unsigned long numLongs = csumlen/sizeof(unsigned int); + size_t numLongs = csumlen/sizeof(unsigned int); for(i = 0; i < numLongs; i++) { - csum += *src++; + csum += *src++; } *lastPartialInt = 0; *lastPartialLength = 0; if (INTALIGNED(csumlen)) { - return(csum); + return(csum); } else { - csumlen -= i * sizeof(unsigned int); + csumlen -= i * sizeof(unsigned int); } } } else { @@ -1099,11 +1099,11 @@ void opal_initialize_crc_table(void) unsigned int opal_bcopy_uicrc_partial( const void * source, void * destination, - unsigned long copylen, - unsigned long crclen, + size_t copylen, + size_t crclen, unsigned int partial_crc) { - unsigned long crclenresidue = (crclen > copylen) ? (crclen - copylen) : 0; + size_t crclenresidue = (crclen > copylen) ? (crclen - copylen) : 0; register int i, j; register unsigned char t; unsigned int tmp; @@ -1162,7 +1162,7 @@ unsigned int opal_bcopy_uicrc_partial( unsigned int opal_uicrc_partial( - const void * source, unsigned long crclen, unsigned int partial_crc) + const void * source, size_t crclen, unsigned int partial_crc) { register int i, j; register unsigned char * t; diff --git a/opal/util/crc.h b/opal/util/crc.h index a8a9818ee6..2b77dc6445 100644 --- a/opal/util/crc.h +++ b/opal/util/crc.h @@ -39,22 +39,22 @@ OPAL_DECLSPEC unsigned long opal_bcopy_csum_partial( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen, - unsigned long * lastPartialLong, - unsigned long * lastPartialLength + size_t copylen, + size_t csumlen, + unsigned long* lastPartialLong, + size_t* lastPartialLength ); static inline unsigned long opal_bcopy_csum ( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen + size_t copylen, + size_t csumlen ) { unsigned long plong = 0; - unsigned long plength = 0; + size_t plength = 0; return opal_bcopy_csum_partial(source, destination, copylen, csumlen, &plong, &plength); } @@ -62,55 +62,55 @@ OPAL_DECLSPEC unsigned int opal_bcopy_uicsum_partial ( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen, - unsigned int * lastPartialInt, - unsigned int * lastPartialLength + size_t copylen, + size_t csumlen, + unsigned int* lastPartialInt, + size_t* lastPartialLength ); static inline unsigned int opal_bcopy_uicsum ( const void * source, void * destination, - unsigned long copylen, - unsigned long csumlen + size_t copylen, + size_t csumlen ) { unsigned int pint = 0; - unsigned int plength = 0; + size_t plength = 0; return opal_bcopy_uicsum_partial(source, destination, copylen, csumlen, &pint, &plength); } OPAL_DECLSPEC unsigned long opal_csum_partial ( const void * source, - unsigned long csumlen, - unsigned long * lastPartialLong, - unsigned long * lastPartialLength + size_t csumlen, + unsigned long* lastPartialLong, + size_t* lastPartialLength ); static inline unsigned long -opal_csum(const void * source, unsigned long csumlen) +opal_csum(const void * source, size_t csumlen) { unsigned long lastPartialLong = 0; - unsigned long lastPartialLength = 0; + size_t lastPartialLength = 0; return opal_csum_partial(source, csumlen, &lastPartialLong, &lastPartialLength); } OPAL_DECLSPEC unsigned int opal_uicsum_partial ( const void * source, - unsigned long csumlen, + size_t csumlen, unsigned int * lastPartialInt, - unsigned int * lastPartialLength + size_t* lastPartialLength ); static inline unsigned int -opal_uicsum(const void * source, unsigned long csumlen) +opal_uicsum(const void * source, size_t csumlen) { unsigned int lastPartialInt = 0; - unsigned int lastPartialLength = 0; + size_t lastPartialLength = 0; return opal_uicsum_partial(source, csumlen, &lastPartialInt, &lastPartialLength); } @@ -124,16 +124,16 @@ OPAL_DECLSPEC unsigned int opal_bcopy_uicrc_partial( const void * source, void * destination, - unsigned long copylen, - unsigned long crclen, + size_t copylen, + size_t crclen, unsigned int partial_crc); static inline unsigned int opal_bcopy_uicrc( const void * source, void * destination, - unsigned long copylen, - unsigned long crclen) + size_t copylen, + size_t crclen) { return opal_bcopy_uicrc_partial(source, destination, copylen, crclen, CRC_INITIAL_REGISTER); } @@ -141,12 +141,12 @@ opal_bcopy_uicrc( OPAL_DECLSPEC unsigned int opal_uicrc_partial( const void * source, - unsigned long crclen, + size_t crclen, unsigned int partial_crc); static inline unsigned int -opal_uicrc(const void * source, unsigned long crclen) +opal_uicrc(const void * source, size_t crclen) { return opal_uicrc_partial(source, crclen, CRC_INITIAL_REGISTER); }