1
1

Correctly initialize and finalize all the datatype classes. No memory leaks on the

datatype engine subsists.

This commit was SVN r30019.
Этот коммит содержится в:
George Bosilca 2013-12-20 15:57:10 +00:00
родитель a85194ae96
Коммит 7178492dd5
3 изменённых файлов: 21 добавлений и 18 удалений

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

@ -452,6 +452,8 @@ int32_t ompi_datatype_init( void )
{ {
int32_t i; int32_t i;
opal_datatype_init();
/* Create the f2c translation table */ /* Create the f2c translation table */
OBJ_CONSTRUCT(&ompi_datatype_f_to_c_table, opal_pointer_array_t); OBJ_CONSTRUCT(&ompi_datatype_f_to_c_table, opal_pointer_array_t);
if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_datatype_f_to_c_table, if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_datatype_f_to_c_table,
@ -623,7 +625,7 @@ int32_t ompi_datatype_init( void )
/** /**
* Now make sure all non-contiguous types are marked as such. * Now make sure all non-contiguous types are marked as such.
*/ */
for( i = 0; i < ompi_mpi_offset.dt.d_f_to_c_index; i++ ) { for( i = 0; i < ompi_mpi_count.dt.d_f_to_c_index; i++ ) {
opal_datatype_t* datatype = (opal_datatype_t*)opal_pointer_array_get_item(&ompi_datatype_f_to_c_table, i ); opal_datatype_t* datatype = (opal_datatype_t*)opal_pointer_array_get_item(&ompi_datatype_f_to_c_table, i );
if( (datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size ) { if( (datatype->ub - datatype->lb) == (OPAL_PTRDIFF_TYPE)datatype->size ) {
@ -632,7 +634,6 @@ int32_t ompi_datatype_init( void )
datatype->flags &= ~OPAL_DATATYPE_FLAG_NO_GAPS; datatype->flags &= ~OPAL_DATATYPE_FLAG_NO_GAPS;
} }
} }
ompi_datatype_default_convertors_init(); ompi_datatype_default_convertors_init();
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -645,15 +646,12 @@ int32_t ompi_datatype_finalize( void )
*/ */
/* As they are statically allocated they cannot be released. /* As they are statically allocated they cannot be released.
* XXX But we can call OBJ_DESTRUCT, just to free all internally allocated ressources. * But we can call OBJ_DESTRUCT, just to free all internally allocated ressources.
*/ */
#if 0 for( int i = 0; i < ompi_mpi_count.dt.d_f_to_c_index; i++ ) {
int i; opal_datatype_t* datatype = (opal_datatype_t*)opal_pointer_array_get_item(&ompi_datatype_f_to_c_table, i );
OBJ_DESTRUCT(datatype);
for( i = 0; i < OMPI_DATATYPE_MAX_PREDEFINED; i++ ) {
OBJ_DESTRUCT( ompi_datatype_basicDatatypes[i] );
} }
#endif /* 0 */
/* Get rid of the Fortran2C translation table */ /* Get rid of the Fortran2C translation table */
OBJ_DESTRUCT(&ompi_datatype_f_to_c_table); OBJ_DESTRUCT(&ompi_datatype_f_to_c_table);

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

@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2009 The University of Tennessee and The University * Copyright (c) 2004-2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@ -60,6 +60,7 @@ static void opal_datatype_destruct( opal_datatype_t* datatype )
datatype->desc.length = 0; datatype->desc.length = 0;
datatype->desc.used = 0; datatype->desc.used = 0;
} }
}
if( datatype->opt_desc.desc != NULL ) { if( datatype->opt_desc.desc != NULL ) {
if( datatype->opt_desc.desc != datatype->desc.desc ) if( datatype->opt_desc.desc != datatype->desc.desc )
free( datatype->opt_desc.desc ); free( datatype->opt_desc.desc );
@ -67,7 +68,6 @@ static void opal_datatype_destruct( opal_datatype_t* datatype )
datatype->opt_desc.used = 0; datatype->opt_desc.used = 0;
datatype->opt_desc.desc = NULL; datatype->opt_desc.desc = NULL;
} }
}
/** /**
* As the default description and the optimized description can point to the * As the default description and the optimized description can point to the
* same memory location we should keep the default location pointer until we * same memory location we should keep the default location pointer until we

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

@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2010 The University of Tennessee and The University * Copyright (c) 2004-2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@ -198,6 +198,11 @@ int32_t opal_datatype_init( void )
const opal_datatype_t* datatype; const opal_datatype_t* datatype;
int32_t i; int32_t i;
/**
* Force he initialization of the opal_datatype_t class. This will allow us to
* call OBJ_DESTRUCT without going too deep in the initialization process.
*/
opal_class_initialize(OBJ_CLASS(opal_datatype_t));
for( i = OPAL_DATATYPE_FIRST_TYPE; i < OPAL_DATATYPE_MAX_PREDEFINED; i++ ) { for( i = OPAL_DATATYPE_FIRST_TYPE; i < OPAL_DATATYPE_MAX_PREDEFINED; i++ ) {
datatype = opal_datatype_basicDatatypes[i]; datatype = opal_datatype_basicDatatypes[i];