Skip to content

Commit de6a289

Browse files
committed
Slightly better tests.
Signed-off-by: George Bosilca <[email protected]>
1 parent 2324c63 commit de6a289

File tree

5 files changed

+23
-28
lines changed

5 files changed

+23
-28
lines changed

opal/datatype/opal_convertor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ opal_convertor_create_stack_with_pos_contig( opal_convertor_t* pConvertor,
357357
*/
358358
if( OPAL_LIKELY(0 == count) ) {
359359
pStack[1].type = pElems->elem.common.type;
360-
pStack[1].count = pElems->elem.count;
360+
pStack[1].count = pElems->elem.blocklen;
361361
} else {
362362
pStack[1].type = OPAL_DATATYPE_UINT1;
363363
pStack[1].count = pData->size - count;

opal/datatype/opal_datatype_optimize.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,18 @@ opal_datatype_optimize_short( opal_datatype_t* pData,
167167
if( ((last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size) ==
168168
(current->blocklen * opal_datatype_basicDatatypes[current->common.type]->size)) &&
169169
(current->disp == (last.disp + (ptrdiff_t)last.count * last.extent)) &&
170-
((last.count == 1) || (current->count == 1) || (last.extent == current->extent)) ) {
170+
((current->count == 1) || (last.extent == current->extent)) ) {
171171
last.count += current->count;
172-
if( last.count == 1 ) {
173-
last.extent = current->extent;
174-
} /* otherwise keep the last.extent */
175172
/* find the lowest common denomitaor type */
176173
if( last.common.type != current->common.type ) {
177-
last.common.type = OPAL_DATATYPE_UINT1;
178174
last.blocklen *= opal_datatype_basicDatatypes[last.common.type]->size;
175+
last.common.type = OPAL_DATATYPE_UINT1;
176+
}
177+
/* maximize the contiguous pieces */
178+
if( last.extent == (ptrdiff_t)(last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size) ) {
179+
last.blocklen *= last.count;
180+
last.count = 1;
181+
last.extent = last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size;
179182
}
180183
continue; /* next data */
181184
}

test/datatype/ddt_raw2.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
3333
uint32_t *iovec_count,
3434
int increment)
3535
{
36-
37-
38-
3936
opal_convertor_t *convertor;
4037
size_t remaining_length = 0;
4138
uint32_t i;
4239
uint32_t temp_count;
4340
struct iovec *temp_iov=NULL;
4441
size_t temp_data;
4542

46-
4743
convertor = opal_convertor_create( opal_local_arch, 0 );
4844

4945
if (OMPI_SUCCESS != opal_convertor_prepare_for_send (convertor,
@@ -55,9 +51,9 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
5551
}
5652

5753
if ( 0 == datatype->super.size ) {
58-
*iovec_count = 0;
59-
*iov = NULL;
60-
return OMPI_SUCCESS;
54+
*iovec_count = 0;
55+
*iov = NULL;
56+
return OMPI_SUCCESS;
6157
}
6258

6359
remaining_length = count * datatype->super.size;
@@ -69,18 +65,16 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
6965
return OMPI_ERR_OUT_OF_RESOURCE;
7066
}
7167

72-
while (0 == opal_convertor_raw(convertor,
73-
temp_iov,
74-
&temp_count,
75-
&temp_data)) {
68+
while (0 == opal_convertor_raw(convertor, temp_iov,
69+
&temp_count, &temp_data)) {
7670
*iovec_count = *iovec_count + temp_count;
7771
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
7872
if (NULL == *iov) {
7973
opal_output(1, "OUT OF MEMORY\n");
8074
free(temp_iov);
8175
return OMPI_ERR_OUT_OF_RESOURCE;
8276
}
83-
for (i=0 ; i<temp_count ; i++) {
77+
for (i = 0 ; i < temp_count ; i++) {
8478
(*iov)[i+(*iovec_count-temp_count)].iov_base = temp_iov[i].iov_base;
8579
(*iov)[i+(*iovec_count-temp_count)].iov_len = temp_iov[i].iov_len;
8680
}
@@ -90,12 +84,12 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
9084
}
9185
*iovec_count = *iovec_count + temp_count;
9286
if ( temp_count > 0 ) {
93-
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
94-
if (NULL == *iov) {
95-
opal_output(1, "OUT OF MEMORY\n");
87+
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
88+
if (NULL == *iov) {
89+
opal_output(1, "OUT OF MEMORY\n");
9690
free(temp_iov);
97-
return OMPI_ERR_OUT_OF_RESOURCE;
98-
}
91+
return OMPI_ERR_OUT_OF_RESOURCE;
92+
}
9993
}
10094
for (i=0 ; i<temp_count ; i++) {
10195
(*iov)[i+(*iovec_count-temp_count)].iov_base = temp_iov[i].iov_base;
@@ -342,7 +336,6 @@ int main (int argc, char *argv[]) {
342336
struct iovec * iov_1 = NULL;
343337
mca_common_ompio_decode_datatype ( datatype, 1, &iov_1, &iovec_count_1, 1);
344338

345-
346339
assert(iovec_count_300 == iovec_count_10);
347340
assert(iovec_count_300 == iovec_count_1);
348341
// assert(iov[100].iov_base == iov2[100].iov_base);

test/datatype/opal_datatype_test.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count )
159159
osrc = (char*)malloc( malloced_size );
160160

161161
{
162-
for( size_t i = 0; i < malloced_size; i++ )
163-
osrc[i] = i % 128 + 32;
162+
for( size_t i = 0; i < malloced_size; i++ ) osrc[i] = i % 128 + 32;
164163
memcpy(odst, osrc, malloced_size);
165164
}
166165
pdst = odst - lb;

test/datatype/opal_ddt_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int32_t opal_datatype_create_vector( int count, int bLength, int stride,
445445
}
446446

447447
pData = opal_datatype_create( oldType->desc.used + 2 );
448-
if( (bLength == stride) || (1 >= count) ) { /* the elements are contiguous */
448+
if( (bLength == stride) || (1 == count) ) { /* the elements are contiguous */
449449
opal_datatype_add( pData, oldType, count * bLength, 0, extent );
450450
} else {
451451
if( 1 == bLength ) {
@@ -476,7 +476,7 @@ static int32_t opal_datatype_create_hvector( int count, int bLength, ptrdiff_t s
476476
}
477477

478478
pTempData = opal_datatype_create( oldType->desc.used + 2 );
479-
if( ((extent * bLength) == stride) || (1 >= count) ) { /* contiguous */
479+
if( ((extent * bLength) == stride) || (1 == count) ) { /* contiguous */
480480
pData = pTempData;
481481
opal_datatype_add( pData, oldType, count * bLength, 0, extent );
482482
} else {

0 commit comments

Comments
 (0)