Skip to content

Cleanup the temporary memory allocation in collectives #1047

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 1 commit into from
Nov 2, 2015
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
40 changes: 18 additions & 22 deletions ompi/datatype/ompi_datatype_create_darray.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-2014 The University of Tennessee and The University
* Copyright (c) 2004-2015 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 @@ -247,32 +247,28 @@ int32_t ompi_datatype_create_darray(int size,
}


/* set displacement and UB correctly. Please read the comment in subarray */
/**
* We need to shift the content (useful data) of the datatype, so
* we need to force the displacement to be moved. Therefore, we
* cannot use resize as it will only set the soft lb and ub
* markers without moving the data. Instead, we have to create a
* new data, and insert the last_Type with the correct
* displacement.
*/
{
ptrdiff_t displs[3], tmp_size;
ompi_datatype_t *types[3];
int blength[3] = { 1, 1, 1};
ptrdiff_t displs[2], tmp_size = 1;

displs[1] = st_offsets[start_loop];
tmp_size = 1;
for (i = start_loop + step ; i != end_loop ; i += step) {
displs[0] = st_offsets[start_loop];
displs[1] = orig_extent;
for (i = start_loop + step; i != end_loop; i += step) {
tmp_size *= gsize_array[i - step];
displs[1] += tmp_size * st_offsets[i];
displs[0] += tmp_size * st_offsets[i];
displs[1] *= gsize_array[i];
}
displs[0] *= orig_extent;

displs[0] = 0;
displs[1] *= orig_extent;
displs[2] = orig_extent;
for (i = 0 ; i < ndims ; i++) {
displs[2] *= gsize_array[i];
}
if(oldtype->super.flags & (OPAL_DATATYPE_FLAG_USER_LB | OPAL_DATATYPE_FLAG_USER_UB) ) {
types[0] = MPI_LB; types[1] = lastType; types[2] = MPI_UB;

rc = ompi_datatype_create_struct(3, blength, displs, types, newtype);
} else {
ompi_datatype_create_resized(lastType, displs[1], displs[2], newtype);
}
*newtype = ompi_datatype_create(lastType->super.desc.used);
ompi_datatype_add(*newtype, lastType, 1, displs[0], displs[1]);
ompi_datatype_destroy(&lastType);
/* need to destroy the old type even in error condition, so
don't check return code from above until after cleanup. */
Expand Down
35 changes: 11 additions & 24 deletions ompi/datatype/ompi_datatype_create_subarray.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-2014 The University of Tennessee and The University
* Copyright (c) 2004-2015 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 @@ -91,29 +91,16 @@ int32_t ompi_datatype_create_subarray(int ndims,
}

replace_subarray_type:
/*
* Resized will only set the soft lb and ub markers without moving the real
* data inside. Thus, in case the original data contains the hard markers
* (MPI_LB or MPI_UB) we must force the displacement of the data upward to
* the right position AND set the hard markers LB and UB.
*
* NTH: ompi_datatype_create_resized() does not do enough for the general
* pack/unpack functions to work correctly. Until this is fixed always use
* ompi_datatype_create_struct(). Once this is fixed remove 1 || below. To
* verify that the regression is fixed run the subarray test in the Open MPI
* ibm testsuite.
*/
if(1 || oldtype->super.flags & (OPAL_DATATYPE_FLAG_USER_LB | OPAL_DATATYPE_FLAG_USER_UB) ) {
MPI_Aint displs[3];
MPI_Datatype types[3];
int blength[3] = { 1, 1, 1 };

displs[0] = 0; displs[1] = displ * extent; displs[2] = size * extent;
types[0] = MPI_LB; types[1] = last_type; types[2] = MPI_UB;
ompi_datatype_create_struct( 3, blength, displs, types, newtype );
} else {
ompi_datatype_create_resized(last_type, displ * extent, size * extent, newtype);
}
/**
* We need to shift the content (useful data) of the datatype, so
* we need to force the displacement to be moved. Therefore, we
* cannot use resize as it will only set the soft lb and ub
* markers without moving the data. Instead, we have to create a
* new data, and insert the last_Type with the correct
* displacement.
*/
*newtype = ompi_datatype_create( last_type->super.desc.used );
ompi_datatype_add( *newtype, last_type, 1, displ * extent, size * extent);
ompi_datatype_destroy( &last_type );

return OMPI_SUCCESS;
Expand Down
5 changes: 2 additions & 3 deletions opal/datatype/opal_datatype_resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -21,9 +23,6 @@ int32_t opal_datatype_resize( opal_datatype_t* type, OPAL_PTRDIFF_TYPE lb, OPAL_
type->lb = lb;
type->ub = lb + extent;

type->true_lb += lb;
type->true_ub += lb;

type->flags &= ~OPAL_DATATYPE_FLAG_NO_GAPS;
if( (extent == (OPAL_PTRDIFF_TYPE)type->size) &&
(type->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS) ) {
Expand Down