From ee27c497f9f94612d0799613ceddef7a321486df Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Tue, 29 Aug 2006 20:19:58 +0000 Subject: [PATCH] Allow duplication of MPI_LB and MPI_UB. A very usefull feature :) This commit was SVN r11496. --- ompi/datatype/dt_create_dup.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ompi/datatype/dt_create_dup.c b/ompi/datatype/dt_create_dup.c index 1c6a82c11e..f613786fc7 100644 --- a/ompi/datatype/dt_create_dup.c +++ b/ompi/datatype/dt_create_dup.c @@ -42,20 +42,25 @@ int32_t ompi_ddt_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** ne the top level (specifically, MPI_TYPE_DUP). */ pdt->d_keyhash = NULL; - memcpy( pdt->desc.desc, oldType->desc.desc, sizeof(dt_elem_desc_t) * desc_length ); + /** + * Allow duplication of MPI_UB and MPI_LB. + */ + if( 0 != oldType->desc.used ) { + memcpy( pdt->desc.desc, oldType->desc.desc, sizeof(dt_elem_desc_t) * desc_length ); + /* TODO: if the data was commited update the opt_desc field */ + if( 0 != oldType->opt_desc.used ) { + desc_length = pdt->opt_desc.used + 1; + pdt->opt_desc.desc = (dt_elem_desc_t*)malloc( desc_length * sizeof(dt_elem_desc_t) ); + /* + * Yes, the pdt->opt_desc.length is just the opt_desc.used of the old Type. + */ + pdt->opt_desc.length = oldType->opt_desc.used; + pdt->opt_desc.used = oldType->opt_desc.used; + memcpy( pdt->opt_desc.desc, oldType->opt_desc.desc, desc_length * sizeof(dt_elem_desc_t) ); + } + } pdt->id = 0; pdt->args = NULL; - /* TODO: if the data was commited update the opt_desc field */ - if( 0 != oldType->opt_desc.used ) { - desc_length = pdt->opt_desc.used + 1; - pdt->opt_desc.desc = (dt_elem_desc_t*)malloc( desc_length * sizeof(dt_elem_desc_t) ); - /* - * Yes, the pdt->opt_desc.length is just the opt_desc.used of the old Type. - */ - pdt->opt_desc.length = oldType->opt_desc.used; - pdt->opt_desc.used = oldType->opt_desc.used; - memcpy( pdt->opt_desc.desc, oldType->opt_desc.desc, desc_length * sizeof(dt_elem_desc_t) ); - } *newType = pdt; return OMPI_SUCCESS; }