Skip to content

Refresh of the datatype engine from Topic/backport 6695 #6863

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 14 commits into from
Aug 21, 2019
2 changes: 1 addition & 1 deletion ompi/datatype/ompi_datatype.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2009-2013 The University of Tennessee and The University
* Copyright (c) 2009-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
Expand Down
13 changes: 6 additions & 7 deletions ompi/datatype/ompi_datatype_create_contiguous.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2013 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
Expand All @@ -29,13 +29,12 @@ int32_t ompi_datatype_create_contiguous( int count, const ompi_datatype_t* oldTy
{
ompi_datatype_t* pdt;

if( 0 == count ) {
pdt = ompi_datatype_create( 0 );
ompi_datatype_add( pdt, &ompi_mpi_datatype_null.dt, 0, 0, 0 );
} else {
pdt = ompi_datatype_create( oldType->super.desc.used + 2 );
opal_datatype_add( &(pdt->super), &(oldType->super), count, 0, (oldType->super.ub - oldType->super.lb) );
if( (0 == count) || (0 == oldType->super.size) ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

pdt = ompi_datatype_create( oldType->super.desc.used + 2 );
opal_datatype_add( &(pdt->super), &(oldType->super), count, 0, (oldType->super.ub - oldType->super.lb) );
*newType = pdt;
return OMPI_SUCCESS;
}
4 changes: 1 addition & 3 deletions ompi/datatype/ompi_datatype_create_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ int32_t ompi_datatype_create_darray(int size,
if (ndims < 1) {
/* Don't just return MPI_DATATYPE_NULL as that can't be
MPI_TYPE_FREE()ed, and that seems bad */
*newtype = ompi_datatype_create(0);
ompi_datatype_add(*newtype, &ompi_mpi_datatype_null.dt, 0, 0, 0);
return MPI_SUCCESS;
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newtype);
}

rc = ompi_datatype_type_extent(oldtype, &orig_extent);
Expand Down
83 changes: 39 additions & 44 deletions ompi/datatype/ompi_datatype_create_indexed.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2013 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -34,24 +34,28 @@
int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const int* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{
ompi_datatype_t* pdt;
int i;
ptrdiff_t extent, disp, endat;
ompi_datatype_t* pdt;
size_t dLength;
int i;

if( 0 == count ) {
/* ignore all cases that lead to an empty type */
ompi_datatype_type_size(oldType, &dLength);
for( i = 0; (i < count) && (0 == pBlockLength[i]); i++ ); /* find first non zero */
if( (i == count) || (0 == dLength) ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

disp = pDisp[0];
dLength = pBlockLength[0];
disp = pDisp[i];
dLength = pBlockLength[i];
endat = disp + dLength;
ompi_datatype_type_extent( oldType, &extent );

pdt = ompi_datatype_create( count * (2 + oldType->super.desc.used) );
for( i = 1; i < count; i++ ) {
if( endat == pDisp[i] ) {
/* contiguous with the previsious */
pdt = ompi_datatype_create( (count - i) * (2 + oldType->super.desc.used) );
for( i += 1; i < count; i++ ) {
if( 0 == pBlockLength[i] ) /* ignore empty length */
continue;
if( endat == pDisp[i] ) { /* contiguous with the previsious */
dLength += pBlockLength[i];
endat += pBlockLength[i];
} else {
Expand All @@ -71,26 +75,28 @@ int32_t ompi_datatype_create_indexed( int count, const int* pBlockLength, const
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;
ptrdiff_t extent, disp, endat;
ompi_datatype_t* pdt;
size_t dLength;
int i;

if( 0 == count ) {
*newType = ompi_datatype_create( 0 );
ompi_datatype_add( *newType, &ompi_mpi_datatype_null.dt, 0, 0, 0);
return OMPI_SUCCESS;
/* ignore all cases that lead to an empty type */
ompi_datatype_type_size(oldType, &dLength);
for( i = 0; (i < count) && (0 == pBlockLength[i]); i++ ); /* find first non zero */
if( (i == count) || (0 == dLength) ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

ompi_datatype_type_extent( oldType, &extent );
pdt = ompi_datatype_create( count * (2 + oldType->super.desc.used) );
disp = pDisp[0];
dLength = pBlockLength[0];
disp = pDisp[i];
dLength = pBlockLength[i];
endat = disp + dLength * extent;

for( i = 1; i < count; i++ ) {
if( endat == pDisp[i] ) {
/* contiguous with the previsious */
pdt = ompi_datatype_create( (count - i) * (2 + oldType->super.desc.used) );
for( i += 1; i < count; i++ ) {
if( 0 == pBlockLength[i] ) /* ignore empty length */
continue;
if( endat == pDisp[i] ) { /* contiguous with the previsious */
dLength += pBlockLength[i];
endat += pBlockLength[i] * extent;
} else {
Expand All @@ -110,21 +116,15 @@ int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const
int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* pDisp,
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{
ompi_datatype_t* pdt;
int i;
ptrdiff_t extent, disp, endat;
ompi_datatype_t* pdt;
size_t dLength;
int i;

ompi_datatype_type_extent( oldType, &extent );
if( (count == 0) || (bLength == 0) ) {
if( 0 == count ) {
return ompi_datatype_duplicate(&ompi_mpi_datatype_null.dt, newType);
} else {
*newType = ompi_datatype_create(1);
ompi_datatype_add( *newType, oldType, 0, pDisp[0] * extent, extent );
return OMPI_SUCCESS;
}
return ompi_datatype_duplicate(&ompi_mpi_datatype_null.dt, newType);
}
ompi_datatype_type_extent( oldType, &extent );
pdt = ompi_datatype_create( count * (2 + oldType->super.desc.used) );
disp = pDisp[0];
dLength = bLength;
Expand All @@ -150,34 +150,29 @@ int32_t ompi_datatype_create_indexed_block( int count, int bLength, const int* p
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;
ptrdiff_t extent, disp, endat;
ompi_datatype_t* pdt;
size_t dLength;
int i;

ompi_datatype_type_extent( oldType, &extent );
if( (count == 0) || (bLength == 0) ) {
*newType = ompi_datatype_create(1);
if( 0 == count )
ompi_datatype_add( *newType, &ompi_mpi_datatype_null.dt, 0, 0, 0 );
else
ompi_datatype_add( *newType, oldType, 0, pDisp[0] * extent, extent );
return OMPI_SUCCESS;
return ompi_datatype_duplicate(&ompi_mpi_datatype_null.dt, newType);
}
ompi_datatype_type_extent( oldType, &extent );
pdt = ompi_datatype_create( count * (2 + oldType->super.desc.used) );
disp = pDisp[0];
dLength = bLength;
endat = disp + dLength;
endat = disp + dLength * extent;
for( i = 1; i < count; i++ ) {
if( endat == pDisp[i] ) {
/* contiguous with the previsious */
dLength += bLength;
endat += bLength;
endat += bLength * extent;
} else {
ompi_datatype_add( pdt, oldType, dLength, disp, extent );
disp = pDisp[i];
dLength = bLength;
endat = disp + bLength;
endat = disp + bLength * extent;
}
}
ompi_datatype_add( pdt, oldType, dLength, disp, extent );
Expand Down
38 changes: 19 additions & 19 deletions ompi/datatype/ompi_datatype_create_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2013 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -31,27 +31,27 @@
int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const ptrdiff_t* pDisp,
ompi_datatype_t* const * pTypes, ompi_datatype_t** newType )
{
int i;
ptrdiff_t disp = 0, endto, lastExtent, lastDisp;
int lastBlock;
ompi_datatype_t *pdt, *lastType;
int lastBlock;
int i, start_from;

if( 0 == count ) {
*newType = ompi_datatype_create( 0 );
ompi_datatype_add( *newType, &ompi_mpi_datatype_null.dt, 0, 0, 0);
return OMPI_SUCCESS;
/* Find first non-zero length element */
for( i = 0; (i < count) && (0 == pBlockLength[i]); i++ );
if( i == count ) { /* either nothing or nothing relevant */
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

/* if we compute the total number of elements before we can
/* compute the total number of elements before we can
* avoid increasing the size of the desc array often.
*/
lastType = (ompi_datatype_t*)pTypes[0];
lastBlock = pBlockLength[0];
start_from = i;
lastType = (ompi_datatype_t*)pTypes[start_from];
lastBlock = pBlockLength[start_from];
lastExtent = lastType->super.ub - lastType->super.lb;
lastDisp = pDisp[0];
endto = pDisp[0] + lastExtent * lastBlock;
lastDisp = pDisp[start_from];
endto = pDisp[start_from] + lastExtent * lastBlock;

for( i = 1; i < count; i++ ) {
for( i = (start_from + 1); i < count; i++ ) {
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
lastBlock += pBlockLength[i];
endto = lastDisp + lastBlock * lastExtent;
Expand All @@ -68,16 +68,16 @@ int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const p
disp += lastType->super.desc.used;
if( lastBlock != 1 ) disp += 2;

lastType = (ompi_datatype_t*)pTypes[0];
lastBlock = pBlockLength[0];
lastType = (ompi_datatype_t*)pTypes[start_from];
lastBlock = pBlockLength[start_from];
lastExtent = lastType->super.ub - lastType->super.lb;
lastDisp = pDisp[0];
endto = pDisp[0] + lastExtent * lastBlock;
lastDisp = pDisp[start_from];
endto = pDisp[start_from] + lastExtent * lastBlock;

pdt = ompi_datatype_create( (int32_t)disp );

/* Do again the same loop but now add the elements */
for( i = 1; i < count; i++ ) {
for( i = (start_from + 1); i < count; i++ ) {
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
lastBlock += pBlockLength[i];
endto = lastDisp + lastBlock * lastExtent;
Expand Down
21 changes: 5 additions & 16 deletions ompi/datatype/ompi_datatype_create_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2013 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
Expand All @@ -28,23 +28,14 @@

#include "ompi/datatype/ompi_datatype.h"

/* Open questions ...
* - how to improuve the handling of these vectors (creating a temporary datatype
* can be ONLY a initial solution.
*
*/

int32_t ompi_datatype_create_vector( int count, int bLength, int stride,
const ompi_datatype_t* oldType, ompi_datatype_t** newType )
{
ompi_datatype_t *pTempData, *pData;
ptrdiff_t extent = oldType->super.ub - oldType->super.lb;


if( 0 == count ) {
*newType = ompi_datatype_create( 0 );
ompi_datatype_add( *newType, &ompi_mpi_datatype_null.dt, 0, 0, 0);
return OMPI_SUCCESS;
if( (0 == count) || (0 == bLength) ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

pData = ompi_datatype_create( oldType->super.desc.used + 2 );
Expand Down Expand Up @@ -72,10 +63,8 @@ int32_t ompi_datatype_create_hvector( int count, int bLength, ptrdiff_t stride,
ompi_datatype_t *pTempData, *pData;
ptrdiff_t extent = oldType->super.ub - oldType->super.lb;

if( 0 == count ) {
*newType = ompi_datatype_create( 0 );
ompi_datatype_add( *newType, &ompi_mpi_datatype_null.dt, 0, 0, 0);
return OMPI_SUCCESS;
if( (0 == count) || (0 == bLength) ) {
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
}

pTempData = ompi_datatype_create( oldType->super.desc.used + 2 );
Expand Down
3 changes: 1 addition & 2 deletions ompi/datatype/ompi_datatype_external.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2016 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
Expand All @@ -26,7 +26,6 @@
#include <stdio.h>

#include "ompi/runtime/params.h"
#include "ompi/communicator/communicator.h"
#include "ompi/datatype/ompi_datatype.h"
#include "opal/datatype/opal_convertor.h"

Expand Down
18 changes: 9 additions & 9 deletions ompi/datatype/ompi_datatype_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2017 The University of Tennessee and The University
* Copyright (c) 2004-2019 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -736,14 +736,14 @@ void ompi_datatype_dump( const ompi_datatype_t* pData )
length = length * 100 + 500;
buffer = (char*)malloc( length );
index += snprintf( buffer, length - index,
"Datatype %p[%s] id %d size %ld align %d opal_id %d length %d used %d\n"
"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->id,
(long)pData->super.size, (int)pData->super.align, pData->super.id, (int)pData->super.desc.length, (int)pData->super.desc.used,
(long)pData->super.true_lb, (long)pData->super.true_ub, (long)(pData->super.true_ub - pData->super.true_lb),
(long)pData->super.lb, (long)pData->super.ub, (long)(pData->super.ub - pData->super.lb),
(int)pData->super.nbElems, (int)pData->super.loops, (int)pData->super.flags );
"Datatype %p[%s] id %d size %" PRIsize_t " align %u opal_id %u length %" PRIsize_t " used %" PRIsize_t "\n"
"true_lb %td true_ub %td (true_extent %td) lb %td ub %td (extent %td)\n"
"nbElems %" PRIsize_t " loops %u flags %X (",
(void*)pData, pData->name, pData->id,
pData->super.size, pData->super.align, (uint32_t)pData->super.id, pData->super.desc.length, pData->super.desc.used,
pData->super.true_lb, pData->super.true_ub, pData->super.true_ub - pData->super.true_lb,
pData->super.lb, pData->super.ub, pData->super.ub - pData->super.lb,
pData->super.nbElems, pData->super.loops, (int)pData->super.flags );
/* dump the flags */
if( ompi_datatype_is_predefined(pData) ) {
index += snprintf( buffer + index, length - index, "predefined " );
Expand Down
6 changes: 3 additions & 3 deletions ompi/mca/common/monitoring/common_monitoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void mca_common_monitoring_register(void*pml_monitoring_component)
&mca_common_monitoring_enabled);

mca_common_monitoring_current_state = mca_common_monitoring_enabled;

(void)mca_base_var_register("ompi", "pml", "monitoring", "enable_output",
"Enable the PML monitoring textual output at MPI_Finalize "
"(it will be automatically turned off when MPIT is used to "
Expand All @@ -278,7 +278,7 @@ void mca_common_monitoring_register(void*pml_monitoring_component)
MCA_BASE_VAR_FLAG_DWG, OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_common_monitoring_output_enabled);

(void)mca_base_var_register("ompi", "pml", "monitoring", "filename",
/*&mca_common_monitoring_component.pmlm_version, "filename",*/
"The name of the file where the monitoring information "
Expand All @@ -292,7 +292,7 @@ void mca_common_monitoring_register(void*pml_monitoring_component)

/* Now that the MCA variables are automatically unregistered when
* their component close, we need to keep a safe copy of the
* filename.
* filename.
* Keep the copy completely separated in order to let the initial
* filename to be handled by the framework. It's easier to deal
* with the string lifetime.
Expand Down
Loading