opal/datatype: add opal_datatype_is_monotonic()
return true if the datatype has non-negative displacements and monotonically nondecreasing, and false otherwise. Thanks George for the guidance. Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
родитель
b6840ad769
Коммит
1a17cb3b1c
@ -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
Обычный файл
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;
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user