Skip to content

Commit 4d92b5f

Browse files
ggouaillardetawlauria
authored andcommitted
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 <[email protected]>
1 parent 0db5a15 commit 4d92b5f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ompi/include/ompi/memchecker.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* reserved.
77
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
88
* Copyright (c) 2012-2013 Inria. All rights reserved.
9-
* Copyright (c) 2014-2017 Research Organization for Information Science
9+
* Copyright (c) 2014-2018 Research Organization for Information Science
1010
* and Technology (RIST). All rights reserved.
1111
* Copyright (c) 2014 Intel, Inc. All rights reserved.
1212
*
13-
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
1414
* $COPYRIGHT$
1515
*
1616
* Additional copyrights may follow
@@ -107,7 +107,7 @@ static inline int memchecker_call (int (*f)(void *, size_t), const void * addr,
107107

108108
if( datatype->super.size == (size_t) (datatype->super.true_ub - datatype->super.true_lb) ) {
109109
/* We have a contiguous type. */
110-
f( (void*)addr , datatype->super.size * count );
110+
f( (void*)((char *)addr+datatype->super.true_lb), datatype->super.size * count );
111111
} else {
112112
/* Now we got a noncontigous type. */
113113
uint32_t elem_pos = 0, i;
@@ -128,7 +128,18 @@ static inline int memchecker_call (int (*f)(void *, size_t), const void * addr,
128128

129129
while( pElem->elem.common.flags & OPAL_DATATYPE_FLAG_DATA ) {
130130
/* now here we have a basic datatype */
131-
f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*pElem->elem.extent );
131+
size_t blength = opal_datatype_basicDatatypes[pElem->elem.common.type]->size;
132+
if ((size_t)pElem->elem.extent == blength) {
133+
/* block is made of contiguous basic datatype */
134+
f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*pElem->elem.extent );
135+
} else {
136+
uint32_t j;
137+
ptrdiff_t offset;
138+
for (j = 0, offset=0; j < pElem->elem.count; j++) {
139+
f( (void *)(source_base + pElem->elem.disp + offset), blength);
140+
offset += pElem->elem.extent;
141+
}
142+
}
132143
elem_pos++; /* advance to the next data */
133144
pElem = &(description[elem_pos]);
134145
continue;

0 commit comments

Comments
 (0)