1
1

Merge pull request #4684 from ggouaillardet/topic/monotonic_datatype

MPI_File_set_view(): check datatypes are monotonic
Этот коммит содержится в:
Gilles Gouaillardet 2018-01-09 22:17:37 +09:00 коммит произвёл GitHub
родитель b6840ad769 02f8215b25
Коммит c1b1bfc6c4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 107 добавлений и 11 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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)), \

Просмотреть файл

@ -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)

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);

Просмотреть файл

@ -15,6 +15,8 @@
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved.
# Copyright (c) 2018 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -59,6 +61,7 @@ libdatatype_la_SOURCES = \
opal_datatype_fake_stack.c \
opal_datatype_get_count.c \
opal_datatype_module.c \
opal_datatype_monotonic.c \
opal_datatype_optimize.c \
opal_datatype_pack.c \
opal_datatype_position.c \

Просмотреть файл

@ -14,7 +14,7 @@
* reserved.
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* Copyright (c) 2017-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
@ -186,6 +186,7 @@ OPAL_DECLSPEC opal_datatype_t* opal_datatype_create( int32_t expectedSize );
OPAL_DECLSPEC int32_t opal_datatype_create_desc( opal_datatype_t * datatype, int32_t expectedSize );
OPAL_DECLSPEC int32_t opal_datatype_commit( opal_datatype_t * pData );
OPAL_DECLSPEC int32_t opal_datatype_destroy( opal_datatype_t** );
OPAL_DECLSPEC int32_t opal_datatype_is_monotonic( opal_datatype_t* type);
static inline int32_t
opal_datatype_is_committed( const opal_datatype_t* type )

57
opal/datatype/opal_datatype_monotonic.c Обычный файл
Просмотреть файл

@ -0,0 +1,57 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include <stddef.h>
#include "opal/constants.h"
#include "opal/datatype/opal_datatype.h"
#include "opal/datatype/opal_datatype_internal.h"
#include "opal/datatype/opal_convertor.h"
int32_t opal_datatype_is_monotonic(opal_datatype_t* type )
{
opal_convertor_t *pConv;
uint32_t iov_count;
struct iovec iov[5];
size_t max_data = 0;
long prev = -1;
int rc;
bool monotonic = true;
pConv = opal_convertor_create( opal_local_arch, 0 );
if (OPAL_UNLIKELY(NULL == pConv)) {
return 0;
}
rc = opal_convertor_prepare_for_send( pConv, type, 1, NULL );
if( OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
OBJ_RELEASE(pConv);
return 0;
}
do {
iov_count = 5;
rc = opal_convertor_raw( pConv, iov, &iov_count, &max_data);
for (uint32_t i=0; i<iov_count; i++) {
if ((long)iov[i].iov_base < prev) {
monotonic = false;
goto cleanup;
}
prev = (long)iov[i].iov_base;
}
} while (rc != 1);
cleanup:
OBJ_RELEASE( pConv );
return monotonic;
}