From 4d92b5fcd822ce6140d081533473c849a54734b0 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 28 Nov 2016 08:55:11 +0900 Subject: [PATCH] memchecker: fix memchecker_call - fix handling of contiguous datatypes with a non-zero true lower bound - fix handling of datatypes using block of non contiguous predefined datatypes Signed-off-by: Gilles Gouaillardet --- ompi/include/ompi/memchecker.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ompi/include/ompi/memchecker.h b/ompi/include/ompi/memchecker.h index a56f065c36..a250194906 100644 --- a/ompi/include/ompi/memchecker.h +++ b/ompi/include/ompi/memchecker.h @@ -6,11 +6,11 @@ * reserved. * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2012-2013 Inria. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science + * Copyright (c) 2014-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. * - * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -107,7 +107,7 @@ static inline int memchecker_call (int (*f)(void *, size_t), const void * addr, if( datatype->super.size == (size_t) (datatype->super.true_ub - datatype->super.true_lb) ) { /* We have a contiguous type. */ - f( (void*)addr , datatype->super.size * count ); + f( (void*)((char *)addr+datatype->super.true_lb), datatype->super.size * count ); } else { /* Now we got a noncontigous type. */ uint32_t elem_pos = 0, i; @@ -128,7 +128,18 @@ static inline int memchecker_call (int (*f)(void *, size_t), const void * addr, while( pElem->elem.common.flags & OPAL_DATATYPE_FLAG_DATA ) { /* now here we have a basic datatype */ - f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*pElem->elem.extent ); + size_t blength = opal_datatype_basicDatatypes[pElem->elem.common.type]->size; + if ((size_t)pElem->elem.extent == blength) { + /* block is made of contiguous basic datatype */ + f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*pElem->elem.extent ); + } else { + uint32_t j; + ptrdiff_t offset; + for (j = 0, offset=0; j < pElem->elem.count; j++) { + f( (void *)(source_base + pElem->elem.disp + offset), blength); + offset += pElem->elem.extent; + } + } elem_pos++; /* advance to the next data */ pElem = &(description[elem_pos]); continue;