Skip to content

v3.x: revamp opal/datatype internals #3568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions config/ompi_find_mpi_aint_count_offset.m4
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
# reserved.
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
# Copyright (c) 2014 Research Organization for Information Science
# Copyright (c) 2014-2017 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2015 Intel, Inc. All rights reserved.
# $COPYRIGHT$
Expand All @@ -42,14 +42,13 @@ AC_DEFUN([OMPI_FIND_MPI_AINT_COUNT_OFFSET],[
dnl #########################################################################

AC_DEFUN([_OMPI_FIND_MPI_AINT_TYPE], [
# Find the type of MPI_Aint. We already did the work to figure
# out what opal_ptrdiff will be; just use that.
# MPI_Aint type is ptrdiff_t; just use that.
AC_MSG_CHECKING([for type of MPI_Aint])

MPI_AINT_TYPE=$opal_ptrdiff_t
MPI_AINT_TYPE=ptrdiff_t
# Get the size of this type; we'll need it to figure out Fortran's
# MPI_ADDRESS_KIND, later
MPI_AINT_SIZE=$opal_ptrdiff_size
MPI_AINT_SIZE=$ac_cv_sizeof_ptrdiff_t
AC_DEFINE_UNQUOTED(OMPI_MPI_AINT_TYPE, [$MPI_AINT_TYPE],
[Type of MPI_Aint])

Expand Down
25 changes: 3 additions & 22 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Copyright (c) 2013 Mellanox Technologies, Inc.
# All rights reserved.
# Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
# Copyright (c) 2014-2016 Research Organization for Information Science
# Copyright (c) 2014-2017 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2016 IBM Corporation. All rights reserved.
# $COPYRIGHT$
Expand Down Expand Up @@ -420,6 +420,8 @@ if test "$ac_cv_type_ssize_t" = yes ; then
fi
if test "$ac_cv_type_ptrdiff_t" = yes; then
AC_CHECK_SIZEOF(ptrdiff_t)
else
AC_MSG_ERROR([ptrdiff_t type is not available, this is required by C99 standard. Cannot continue])
fi
AC_CHECK_SIZEOF(wchar_t)

Expand Down Expand Up @@ -782,27 +784,6 @@ AC_INCLUDES_DEFAULT
#endif
])

#
# Check for ptrdiff type. Yes, there are platforms where
# sizeof(void*) != sizeof(long) (64 bit Windows, apparently).
#
AC_MSG_CHECKING([for pointer diff type])
if test $ac_cv_type_ptrdiff_t = yes ; then
opal_ptrdiff_t="ptrdiff_t"
opal_ptrdiff_size=$ac_cv_sizeof_ptrdiff_t
elif test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long ; then
opal_ptrdiff_t="long"
opal_ptrdiff_size=$ac_cv_sizeof_long
elif test $ac_cv_type_long_long = yes && test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long_long ; then
opal_ptrdiff_t="long long"
opal_ptrdiff_size=$ac_cv_sizeof_long_long
else
AC_MSG_ERROR([Could not find datatype to emulate ptrdiff_t. Cannot continue])
fi
AC_DEFINE_UNQUOTED([OPAL_PTRDIFF_TYPE], [$opal_ptrdiff_t],
[type to use for ptrdiff_t])
AC_MSG_RESULT([$opal_ptrdiff_t (size: $opal_ptrdiff_size)])

#
# Find corresponding types for MPI_Aint, MPI_Count, and MPI_Offset.
# And if relevant, find the corresponding MPI_ADDRESS_KIND,
Expand Down
32 changes: 16 additions & 16 deletions ompi/datatype/ompi_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -167,7 +167,7 @@ OMPI_DECLSPEC int32_t ompi_datatype_destroy( ompi_datatype_t** type);
*/
static inline int32_t
ompi_datatype_add( ompi_datatype_t* pdtBase, const ompi_datatype_t* pdtAdd, uint32_t count,
OPAL_PTRDIFF_TYPE disp, OPAL_PTRDIFF_TYPE extent )
ptrdiff_t disp, ptrdiff_t extent )
{
return opal_datatype_add( &pdtBase->super, &pdtAdd->super, count, disp, extent );
}
Expand All @@ -178,17 +178,17 @@ ompi_datatype_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** newTy
OMPI_DECLSPEC int32_t ompi_datatype_create_contiguous( int count, const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_vector( int count, int bLength, int stride,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_hvector( int count, int bLength, OPAL_PTRDIFF_TYPE stride,
OMPI_DECLSPEC int32_t ompi_datatype_create_hvector( int count, int bLength, ptrdiff_t stride,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const int* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const OPAL_PTRDIFF_TYPE* pDisp,
OMPI_DECLSPEC int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const ptrdiff_t* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const OPAL_PTRDIFF_TYPE* pDisp,
OMPI_DECLSPEC int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const ptrdiff_t* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const OPAL_PTRDIFF_TYPE* pDisp,
OMPI_DECLSPEC int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const ptrdiff_t* pDisp,
ompi_datatype_t* const* pTypes, ompi_datatype_t** newType );
OMPI_DECLSPEC int32_t ompi_datatype_create_darray( int size, int rank, int ndims, int const* gsize_array,
int const* distrib_array, int const* darg_array,
Expand All @@ -199,8 +199,8 @@ OMPI_DECLSPEC int32_t ompi_datatype_create_subarray(int ndims, int const* size_a
const ompi_datatype_t* oldtype, ompi_datatype_t** newtype);
static inline int32_t
ompi_datatype_create_resized( const ompi_datatype_t* oldType,
OPAL_PTRDIFF_TYPE lb,
OPAL_PTRDIFF_TYPE extent,
ptrdiff_t lb,
ptrdiff_t extent,
ompi_datatype_t** newType )
{
ompi_datatype_t * type;
Expand All @@ -214,13 +214,13 @@ ompi_datatype_create_resized( const ompi_datatype_t* oldType,
}

static inline int32_t
ompi_datatype_type_lb( const ompi_datatype_t* type, OPAL_PTRDIFF_TYPE* disp )
ompi_datatype_type_lb( const ompi_datatype_t* type, ptrdiff_t* disp )
{
return opal_datatype_type_lb(&type->super, disp);
}

static inline int32_t
ompi_datatype_type_ub( const ompi_datatype_t* type, OPAL_PTRDIFF_TYPE* disp )
ompi_datatype_type_ub( const ompi_datatype_t* type, ptrdiff_t* disp )
{
return opal_datatype_type_ub( &type->super, disp);
}
Expand All @@ -232,19 +232,19 @@ ompi_datatype_type_size ( const ompi_datatype_t* type, size_t *size )
}

static inline int32_t
ompi_datatype_type_extent( const ompi_datatype_t* type, OPAL_PTRDIFF_TYPE* extent )
ompi_datatype_type_extent( const ompi_datatype_t* type, ptrdiff_t* extent )
{
return opal_datatype_type_extent( &type->super, extent);
}

static inline int32_t
ompi_datatype_get_extent( const ompi_datatype_t* type, OPAL_PTRDIFF_TYPE* lb, OPAL_PTRDIFF_TYPE* extent)
ompi_datatype_get_extent( const ompi_datatype_t* type, ptrdiff_t* lb, ptrdiff_t* extent)
{
return opal_datatype_get_extent( &type->super, lb, extent);
}

static inline int32_t
ompi_datatype_get_true_extent( const ompi_datatype_t* type, OPAL_PTRDIFF_TYPE* true_lb, OPAL_PTRDIFF_TYPE* true_extent)
ompi_datatype_get_true_extent( const ompi_datatype_t* type, ptrdiff_t* true_lb, ptrdiff_t* true_extent)
{
return opal_datatype_get_true_extent( &type->super, true_lb, true_extent);
}
Expand All @@ -266,7 +266,7 @@ ompi_datatype_copy_content_same_ddt( const ompi_datatype_t* type, size_t count,
char* pDestBuf, char* pSrcBuf )
{
int32_t length, rc;
OPAL_PTRDIFF_TYPE extent;
ptrdiff_t extent;

ompi_datatype_type_extent( type, &extent );
while( 0 != count ) {
Expand Down Expand Up @@ -295,11 +295,11 @@ OMPI_DECLSPEC int32_t ompi_datatype_sndrcv( const void *sbuf, int32_t scount, co
*/
OMPI_DECLSPEC int32_t ompi_datatype_get_args( const ompi_datatype_t* pData, int32_t which,
int32_t * ci, int32_t * i,
int32_t * ca, OPAL_PTRDIFF_TYPE* a,
int32_t * ca, ptrdiff_t* a,
int32_t * cd, ompi_datatype_t** d, int32_t * type);
OMPI_DECLSPEC int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
int32_t ci, const int32_t ** i,
int32_t ca, const OPAL_PTRDIFF_TYPE* a,
int32_t ca, const ptrdiff_t* a,
int32_t cd, ompi_datatype_t* const * d,int32_t type);
OMPI_DECLSPEC int32_t ompi_datatype_copy_args( const ompi_datatype_t* source_data,
ompi_datatype_t* dest_data );
Expand Down
38 changes: 19 additions & 19 deletions ompi/datatype/ompi_datatype_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2013-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand All @@ -40,7 +40,7 @@ static inline int
__ompi_datatype_pack_description( ompi_datatype_t* datatype,
void** packed_buffer, int* next_index );
static ompi_datatype_t*
__ompi_datatype_create_from_args( int32_t* i, OPAL_PTRDIFF_TYPE * a,
__ompi_datatype_create_from_args( int32_t* i, ptrdiff_t * a,
ompi_datatype_t** d, int32_t type );

typedef struct __dt_args {
Expand All @@ -51,7 +51,7 @@ typedef struct __dt_args {
int32_t ca;
int32_t cd;
int* i;
OPAL_PTRDIFF_TYPE* a;
ptrdiff_t* a;
ompi_datatype_t** d;
} ompi_datatype_args_t;

Expand All @@ -65,7 +65,7 @@ typedef struct __dt_args {
*/
#if OPAL_ALIGN_WORD_SIZE_INTEGERS
#define OMPI_DATATYPE_ALIGN_PTR(PTR, TYPE) \
(PTR) = OPAL_ALIGN_PTR((PTR), sizeof(OPAL_PTRDIFF_TYPE), TYPE)
(PTR) = OPAL_ALIGN_PTR((PTR), sizeof(ptrdiff_t), TYPE)
#else
#define OMPI_DATATYPE_ALIGN_PTR(PTR, TYPE)
#endif /* OPAL_ALIGN_WORD_SIZE_INTEGERS */
Expand All @@ -80,7 +80,7 @@ typedef struct __dt_args {
#define ALLOC_ARGS(PDATA, IC, AC, DC) \
do { \
int length = sizeof(ompi_datatype_args_t) + (IC) * sizeof(int) + \
(AC) * sizeof(OPAL_PTRDIFF_TYPE) + (DC) * sizeof(MPI_Datatype); \
(AC) * sizeof(ptrdiff_t) + (DC) * sizeof(MPI_Datatype); \
char* buf = (char*)malloc( length ); \
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)buf; \
pArgs->ci = (IC); \
Expand All @@ -89,8 +89,8 @@ typedef struct __dt_args {
buf += sizeof(ompi_datatype_args_t); \
if( pArgs->ca == 0 ) pArgs->a = NULL; \
else { \
pArgs->a = (OPAL_PTRDIFF_TYPE*)buf; \
buf += pArgs->ca * sizeof(OPAL_PTRDIFF_TYPE); \
pArgs->a = (ptrdiff_t*)buf; \
buf += pArgs->ca * sizeof(ptrdiff_t); \
} \
if( pArgs->cd == 0 ) pArgs->d = NULL; \
else { \
Expand All @@ -101,15 +101,15 @@ typedef struct __dt_args {
else pArgs->i = (int*)buf; \
pArgs->ref_count = 1; \
pArgs->total_pack_size = (4 + (IC) + (DC)) * sizeof(int) + \
(AC) * sizeof(OPAL_PTRDIFF_TYPE); \
(AC) * sizeof(ptrdiff_t); \
(PDATA)->args = (void*)pArgs; \
(PDATA)->packed_description = NULL; \
} while(0)


int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
int32_t ci, const int32_t** i,
int32_t ca, const OPAL_PTRDIFF_TYPE* a,
int32_t ca, const ptrdiff_t* a,
int32_t cd, ompi_datatype_t* const * d, int32_t type)
{
int pos;
Expand Down Expand Up @@ -220,9 +220,9 @@ int32_t ompi_datatype_set_args( ompi_datatype_t* pData,
break;
}

/* copy the array of MPI_Aint, aka OPAL_PTRDIFF_TYPE */
/* copy the array of MPI_Aint, aka ptrdiff_t */
if( pArgs->a != NULL )
memcpy( pArgs->a, a, ca * sizeof(OPAL_PTRDIFF_TYPE) );
memcpy( pArgs->a, a, ca * sizeof(ptrdiff_t) );

for( pos = 0; pos < cd; pos++ ) {
pArgs->d[pos] = d[pos];
Expand Down Expand Up @@ -317,7 +317,7 @@ int32_t ompi_datatype_print_args( const ompi_datatype_t* pData )

int32_t ompi_datatype_get_args( const ompi_datatype_t* pData, int32_t which,
int32_t* ci, int32_t* i,
int32_t* ca, OPAL_PTRDIFF_TYPE* a,
int32_t* ca, ptrdiff_t* a,
int32_t* cd, ompi_datatype_t** d, int32_t* type)
{
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)pData->args;
Expand Down Expand Up @@ -354,7 +354,7 @@ int32_t ompi_datatype_get_args( const ompi_datatype_t* pData, int32_t which,
memcpy( i, pArgs->i, pArgs->ci * sizeof(int) );
}
if( (NULL != a) && (NULL != pArgs->a) ) {
memcpy( a, pArgs->a, pArgs->ca * sizeof(OPAL_PTRDIFF_TYPE) );
memcpy( a, pArgs->a, pArgs->ca * sizeof(ptrdiff_t) );
}
if( (NULL != d) && (NULL != pArgs->d) ) {
memcpy( d, pArgs->d, pArgs->cd * sizeof(MPI_Datatype) );
Expand Down Expand Up @@ -449,8 +449,8 @@ static inline int __ompi_datatype_pack_description( ompi_datatype_t* datatype,
/* description of the displacements must be 64 bits aligned */
OMPI_DATATYPE_ALIGN_PTR(next_packed, char*);

memcpy( next_packed, args->a, sizeof(OPAL_PTRDIFF_TYPE) * args->ca );
next_packed += sizeof(OPAL_PTRDIFF_TYPE) * args->ca;
memcpy( next_packed, args->a, sizeof(ptrdiff_t) * args->ca );
next_packed += sizeof(ptrdiff_t) * args->ca;
}
position = (int*)next_packed;
next_packed += sizeof(int) * args->cd;
Expand Down Expand Up @@ -557,7 +557,7 @@ static ompi_datatype_t* __ompi_datatype_create_from_packed_description( void** p
int* position;
ompi_datatype_t* datatype = NULL;
ompi_datatype_t** array_of_datatype;
OPAL_PTRDIFF_TYPE* array_of_disp;
ptrdiff_t* array_of_disp;
int* array_of_length;
int number_of_length, number_of_disp, number_of_datatype, data_id;
int create_type, i;
Expand Down Expand Up @@ -609,13 +609,13 @@ static ompi_datatype_t* __ompi_datatype_create_from_packed_description( void** p
next_buffer += (4 * sizeof(int)); /* move after the header */

/* description of the displacements (if ANY !) should always be aligned
on MPI_Aint, aka OPAL_PTRDIFF_TYPE */
on MPI_Aint, aka ptrdiff_t */
if (number_of_disp > 0) {
OMPI_DATATYPE_ALIGN_PTR(next_buffer, char*);
}

array_of_disp = (OPAL_PTRDIFF_TYPE*)next_buffer;
next_buffer += number_of_disp * sizeof(OPAL_PTRDIFF_TYPE);
array_of_disp = (ptrdiff_t*)next_buffer;
next_buffer += number_of_disp * sizeof(ptrdiff_t);
/* the other datatypes */
position = (int*)next_buffer;
next_buffer += number_of_datatype * sizeof(int);
Expand Down
14 changes: 7 additions & 7 deletions ompi/datatype/ompi_datatype_create_indexed.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand All @@ -35,7 +35,7 @@ int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const
{
ompi_datatype_t* pdt;
int i, dLength, endat, disp;
OPAL_PTRDIFF_TYPE extent;
ptrdiff_t extent;

if( 0 == count ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
Expand Down Expand Up @@ -66,12 +66,12 @@ int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const
}


int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const OPAL_PTRDIFF_TYPE* pDisp,
int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const ptrdiff_t* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{
ompi_datatype_t* pdt;
int i, dLength;
OPAL_PTRDIFF_TYPE extent, disp, endat;
ptrdiff_t extent, disp, endat;

if( 0 == count ) {
*newType = ompi_datatype_create( 0 );
Expand Down Expand Up @@ -109,7 +109,7 @@ int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* p
{
ompi_datatype_t* pdt;
int i, dLength, endat, disp;
OPAL_PTRDIFF_TYPE extent;
ptrdiff_t extent;

ompi_datatype_type_extent( oldType, &extent );
if( (count == 0) || (bLength == 0) ) {
Expand Down Expand Up @@ -143,12 +143,12 @@ int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* p
return OMPI_SUCCESS;
}

int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const OPAL_PTRDIFF_TYPE* pDisp,
int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const ptrdiff_t* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{
ompi_datatype_t* pdt;
int i, dLength;
OPAL_PTRDIFF_TYPE extent, disp, endat;
ptrdiff_t extent, disp, endat;

ompi_datatype_type_extent( oldType, &extent );
if( (count == 0) || (bLength == 0) ) {
Expand Down
Loading