diff --git a/ompi/datatype/ompi_datatype.h b/ompi/datatype/ompi_datatype.h index 8286fae463..2dace3e5b7 100644 --- a/ompi/datatype/ompi_datatype.h +++ b/ompi/datatype/ompi_datatype.h @@ -7,7 +7,7 @@ * Copyright (c) 2010-2017 Cisco Systems, Inc. All rights reserved * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science + * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -44,6 +44,8 @@ BEGIN_C_DECLS /* These flags are on top of the flags in opal_datatype.h */ /* Is the datatype predefined as MPI type (not necessarily as OPAL type, e.g. struct/block types) */ #define OMPI_DATATYPE_FLAG_PREDEFINED 0x0200 +#define OMPI_DATATYPE_FLAG_ANALYZED 0x0400 +#define OMPI_DATATYPE_FLAG_MONOTONIC 0x0800 /* Keep trace of the type of the predefined datatypes */ #define OMPI_DATATYPE_FLAG_DATA_INT 0x1000 #define OMPI_DATATYPE_FLAG_DATA_FLOAT 0x2000 @@ -152,13 +154,23 @@ ompi_datatype_is_contiguous_memory_layout( const ompi_datatype_t* type, int32_t return opal_datatype_is_contiguous_memory_layout(&type->super, count); } +static inline int32_t +ompi_datatype_is_monotonic( ompi_datatype_t * type ) { + if (!(type->super.flags & OMPI_DATATYPE_FLAG_ANALYZED)) { + if (opal_datatype_is_monotonic(&type->super)) { + type->super.flags |= OMPI_DATATYPE_FLAG_MONOTONIC; + } + type->super.flags |= OMPI_DATATYPE_FLAG_ANALYZED; + } + return type->super.flags & OMPI_DATATYPE_FLAG_MONOTONIC; +} + static inline int32_t ompi_datatype_commit( ompi_datatype_t ** type ) { return opal_datatype_commit ( (opal_datatype_t*)*type ); } - OMPI_DECLSPEC int32_t ompi_datatype_destroy( ompi_datatype_t** type); diff --git a/ompi/datatype/ompi_datatype_internal.h b/ompi/datatype/ompi_datatype_internal.h index 4323f0c31e..0cbfb25a95 100644 --- a/ompi/datatype/ompi_datatype_internal.h +++ b/ompi/datatype/ompi_datatype_internal.h @@ -7,7 +7,7 @@ * Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science + * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 FUJITSU LIMITED. All rights reserved. * $COPYRIGHT$ @@ -416,6 +416,8 @@ extern const ompi_datatype_t* ompi_datatype_basicDatatypes[OMPI_DATATYPE_MPI_MAX { /*ompi_predefined_datatype_t*/ \ { /* ompi_datatype_t */ \ OMPI_DATATYPE_INITIALIZER_ ## TYPE (OMPI_DATATYPE_FLAG_PREDEFINED | \ + OMPI_DATATYPE_FLAG_ANALYZED | \ + OMPI_DATATYPE_FLAG_MONOTONIC | \ (FLAGS)) /*super*/, \ OMPI_DATATYPE_EMPTY_DATA(NAME) /*id,d_f_to_c_index,d_keyhash,args,packed_description,name*/ \ }, \ @@ -457,6 +459,8 @@ extern const ompi_datatype_t* ompi_datatype_basicDatatypes[OMPI_DATATYPE_MPI_MAX .super = OPAL_OBJ_STATIC_INIT(opal_datatype_t), \ .flags = OPAL_DATATYPE_FLAG_BASIC | \ OMPI_DATATYPE_FLAG_PREDEFINED | \ + OMPI_DATATYPE_FLAG_ANALYZED | \ + OMPI_DATATYPE_FLAG_MONOTONIC | \ OMPI_DATATYPE_FLAG_DATA_FORTRAN | (FLAGS), \ .id = OPAL_DATATYPE_ ## TYPE ## SIZE, \ .bdt_used = (((uint32_t)1)<<(OPAL_DATATYPE_ ## TYPE ## SIZE)), \ diff --git a/ompi/datatype/ompi_datatype_module.c b/ompi/datatype/ompi_datatype_module.c index b602d92d3e..3ee09173cd 100644 --- a/ompi/datatype/ompi_datatype_module.c +++ b/ompi/datatype/ompi_datatype_module.c @@ -15,7 +15,7 @@ * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science + * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 FUJITSU LIMITED. All rights reserved. * $COPYRIGHT$ @@ -414,7 +414,9 @@ opal_pointer_array_t ompi_datatype_f_to_c_table = {{0}}; ompi_datatype_commit( &ptype ); \ COPY_DATA_DESC( PDATA, ptype ); \ (PDATA)->super.flags &= ~OPAL_DATATYPE_FLAG_PREDEFINED; \ - (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; \ + (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED | \ + OMPI_DATATYPE_FLAG_ANALYZED | \ + OMPI_DATATYPE_FLAG_MONOTONIC; \ ptype->super.desc.desc = NULL; \ ptype->super.opt_desc.desc = NULL; \ OBJ_RELEASE( ptype ); \ @@ -430,7 +432,9 @@ opal_pointer_array_t ompi_datatype_f_to_c_table = {{0}}; ompi_datatype_commit( &ptype ); \ COPY_DATA_DESC( (PDATA), ptype ); \ (PDATA)->super.flags &= ~OPAL_DATATYPE_FLAG_PREDEFINED; \ - (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; \ + (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED | \ + OMPI_DATATYPE_FLAG_ANALYZED | \ + OMPI_DATATYPE_FLAG_MONOTONIC; \ ptype->super.desc.desc = NULL; \ ptype->super.opt_desc.desc = NULL; \ OBJ_RELEASE( ptype ); \ @@ -445,7 +449,9 @@ opal_pointer_array_t ompi_datatype_f_to_c_table = {{0}}; /* forget the language flag */ \ (PDATA)->super.flags &= ~OMPI_DATATYPE_FLAG_DATA_LANGUAGE; \ (PDATA)->super.flags &= ~OPAL_DATATYPE_FLAG_PREDEFINED; \ - (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED; \ + (PDATA)->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED | \ + OMPI_DATATYPE_FLAG_ANALYZED | \ + OMPI_DATATYPE_FLAG_MONOTONIC; \ } while(0) diff --git a/ompi/mpi/c/bindings.h b/ompi/mpi/c/bindings.h index 12e29cbfbd..46239d5a86 100644 --- a/ompi/mpi/c/bindings.h +++ b/ompi/mpi/c/bindings.h @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2018 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -71,6 +73,17 @@ BEGIN_C_DECLS else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \ } while(0) +#define OMPI_CHECK_DATATYPE_FOR_VIEW( RC, DDT, COUNT ) \ + do { \ + /* (RC) = MPI_SUCCESS; */ \ + if( NULL == (DDT) || MPI_DATATYPE_NULL == (DDT) ) (RC) = MPI_ERR_TYPE; \ + else if( (COUNT) < 0 ) (RC) = MPI_ERR_COUNT; \ + else if( !opal_datatype_is_committed(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \ + /* XXX Fix flags else if( ompi_datatype_is_overlapped((DDT)) ) (RC) = MPI_ERR_TYPE; */ \ + else if( !opal_datatype_is_valid(&((DDT)->super)) ) (RC) = MPI_ERR_TYPE; \ + else if( !ompi_datatype_is_monotonic((DDT)) ) (RC) = MPI_ERR_TYPE; \ + } while (0) + /* This macro has to be used to check the correctness of the user buffer depending on the datatype. * This macro expects that the DDT parameter is a valid pointer to an ompi datatype object. diff --git a/ompi/mpi/c/file_set_view.c b/ompi/mpi/c/file_set_view.c index ed0883650e..a49a80f29a 100644 --- a/ompi/mpi/c/file_set_view.c +++ b/ompi/mpi/c/file_set_view.c @@ -13,7 +13,7 @@ * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -59,9 +59,9 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, rc = MPI_ERR_FILE; fh = MPI_FILE_NULL; } else { - OMPI_CHECK_DATATYPE_FOR_RECV(rc, etype, 0); + OMPI_CHECK_DATATYPE_FOR_VIEW(rc, etype, 0); if (MPI_SUCCESS == rc) { - OMPI_CHECK_DATATYPE_FOR_RECV(rc, filetype, 0); + OMPI_CHECK_DATATYPE_FOR_VIEW(rc, filetype, 0); } } OMPI_ERRHANDLER_CHECK(rc, fh, rc, FUNC_NAME);