Skip to content

Commit 8d50c81

Browse files
committed
Fixes at the OMPI datatype level.
Includes: - Fix the create_hindexed and vector creation. - Fix the handling of [get|set]_elements and _count. - Correctly compute the dispacement for block indexed types. Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
1 parent 0cb3361 commit 8d50c81

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

ompi/datatype/ompi_datatype_create_indexed.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ int32_t ompi_datatype_create_hindexed( int count, const int* pBlockLength, const
8787
return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
8888
}
8989

90+
ompi_datatype_type_extent( oldType, &extent );
9091
disp = pDisp[i];
9192
dLength = pBlockLength[i];
9293
endat = disp + dLength * extent;
93-
ompi_datatype_type_extent( oldType, &extent );
9494

9595
pdt = ompi_datatype_create( (count - i) * (2 + oldType->super.desc.used) );
9696
for( i += 1; i < count; i++ ) {
@@ -162,17 +162,17 @@ int32_t ompi_datatype_create_hindexed_block( int count, int bLength, const ptrdi
162162
pdt = ompi_datatype_create( count * (2 + oldType->super.desc.used) );
163163
disp = pDisp[0];
164164
dLength = bLength;
165-
endat = disp + dLength;
165+
endat = disp + dLength * extent;
166166
for( i = 1; i < count; i++ ) {
167167
if( endat == pDisp[i] ) {
168168
/* contiguous with the previsious */
169169
dLength += bLength;
170-
endat += bLength;
170+
endat += bLength * extent;
171171
} else {
172172
ompi_datatype_add( pdt, oldType, dLength, disp, extent );
173173
disp = pDisp[i];
174174
dLength = bLength;
175-
endat = disp + bLength;
175+
endat = disp + bLength * extent;
176176
}
177177
}
178178
ompi_datatype_add( pdt, oldType, dLength, disp, extent );

ompi/datatype/ompi_datatype_create_vector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int32_t ompi_datatype_create_vector( int count, int bLength, int stride,
4040

4141
pData = ompi_datatype_create( oldType->super.desc.used + 2 );
4242
if( (bLength == stride) || (1 >= count) ) { /* the elements are contiguous */
43-
ompi_datatype_add( pData, oldType, (size_t)count * bLength, 0, extent * count );
43+
ompi_datatype_add( pData, oldType, (size_t)count * bLength, 0, extent );
4444
} else {
4545
if( 1 == bLength ) {
4646
ompi_datatype_add( pData, oldType, count, 0, extent * stride );
@@ -70,7 +70,7 @@ int32_t ompi_datatype_create_hvector( int count, int bLength, ptrdiff_t stride,
7070
pTempData = ompi_datatype_create( oldType->super.desc.used + 2 );
7171
if( ((extent * bLength) == stride) || (1 >= count) ) { /* contiguous */
7272
pData = pTempData;
73-
ompi_datatype_add( pData, oldType, count * bLength, 0, extent * count );
73+
ompi_datatype_add( pData, oldType, count * bLength, 0, extent );
7474
} else {
7575
if( 1 == bLength ) {
7676
pData = pTempData;

opal/datatype/opal_datatype_get_count.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ ssize_t opal_datatype_get_element_count( const opal_datatype_t* datatype, size_t
6969
while( pElems[pos_desc].elem.common.flags & OPAL_DATATYPE_FLAG_DATA ) {
7070
/* now here we have a basic datatype */
7171
const opal_datatype_t* basic_type = BASIC_DDT_FROM_ELEM(pElems[pos_desc]);
72-
local_size = pElems[pos_desc].elem.count * basic_type->size;
72+
local_size = (pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen) * basic_type->size;
7373
if( local_size >= iSize ) {
7474
local_size = iSize / basic_type->size;
7575
nbElems += (int32_t)local_size;
7676
iSize -= local_size * basic_type->size;
7777
return (iSize == 0 ? nbElems : -1);
7878
}
79-
nbElems += pElems[pos_desc].elem.count;
79+
nbElems += (pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen);
8080
iSize -= local_size;
8181
pos_desc++; /* advance to the next data */
8282
}
@@ -131,7 +131,7 @@ int32_t opal_datatype_set_element_count( const opal_datatype_t* datatype, size_t
131131
while( pElems[pos_desc].elem.common.flags & OPAL_DATATYPE_FLAG_DATA ) {
132132
/* now here we have a basic datatype */
133133
const opal_datatype_t* basic_type = BASIC_DDT_FROM_ELEM(pElems[pos_desc]);
134-
local_length = pElems[pos_desc].elem.count;
134+
local_length = (pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen);
135135
if( local_length >= count ) {
136136
*length += count * basic_type->size;
137137
return 0;
@@ -188,8 +188,8 @@ int opal_datatype_compute_ptypes( opal_datatype_t* datatype )
188188
}
189189
while( pElems[pos_desc].elem.common.flags & OPAL_DATATYPE_FLAG_DATA ) {
190190
/* now here we have a basic datatype */
191-
datatype->ptypes[pElems[pos_desc].elem.common.type] += pElems[pos_desc].elem.count;
192-
nbElems += pElems[pos_desc].elem.count;
191+
datatype->ptypes[pElems[pos_desc].elem.common.type] += pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen;
192+
nbElems += pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen;
193193

194194
DUMP( " compute_ptypes-add: type %d count %"PRIsize_t" (total type %"PRIsize_t" total %lld)\n",
195195
pElems[pos_desc].elem.common.type, datatype->ptypes[pElems[pos_desc].elem.common.type],

0 commit comments

Comments
 (0)