Skip to content

Commit

Permalink
Slightly better tests.
Browse files Browse the repository at this point in the history
Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
  • Loading branch information
bosilca committed Jun 19, 2019
1 parent 2324c63 commit de6a289
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion opal/datatype/opal_convertor.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ opal_convertor_create_stack_with_pos_contig( opal_convertor_t* pConvertor,
*/
if( OPAL_LIKELY(0 == count) ) {
pStack[1].type = pElems->elem.common.type;
pStack[1].count = pElems->elem.count;
pStack[1].count = pElems->elem.blocklen;
} else {
pStack[1].type = OPAL_DATATYPE_UINT1;
pStack[1].count = pData->size - count;
Expand Down
13 changes: 8 additions & 5 deletions opal/datatype/opal_datatype_optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,18 @@ opal_datatype_optimize_short( opal_datatype_t* pData,
if( ((last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size) ==
(current->blocklen * opal_datatype_basicDatatypes[current->common.type]->size)) &&
(current->disp == (last.disp + (ptrdiff_t)last.count * last.extent)) &&
((last.count == 1) || (current->count == 1) || (last.extent == current->extent)) ) {
((current->count == 1) || (last.extent == current->extent)) ) {
last.count += current->count;
if( last.count == 1 ) {
last.extent = current->extent;
} /* otherwise keep the last.extent */
/* find the lowest common denomitaor type */
if( last.common.type != current->common.type ) {
last.common.type = OPAL_DATATYPE_UINT1;
last.blocklen *= opal_datatype_basicDatatypes[last.common.type]->size;
last.common.type = OPAL_DATATYPE_UINT1;
}
/* maximize the contiguous pieces */
if( last.extent == (ptrdiff_t)(last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size) ) {
last.blocklen *= last.count;
last.count = 1;
last.extent = last.blocklen * opal_datatype_basicDatatypes[last.common.type]->size;
}
continue; /* next data */
}
Expand Down
29 changes: 11 additions & 18 deletions test/datatype/ddt_raw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
uint32_t *iovec_count,
int increment)
{



opal_convertor_t *convertor;
size_t remaining_length = 0;
uint32_t i;
uint32_t temp_count;
struct iovec *temp_iov=NULL;
size_t temp_data;


convertor = opal_convertor_create( opal_local_arch, 0 );

if (OMPI_SUCCESS != opal_convertor_prepare_for_send (convertor,
Expand All @@ -55,9 +51,9 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
}

if ( 0 == datatype->super.size ) {
*iovec_count = 0;
*iov = NULL;
return OMPI_SUCCESS;
*iovec_count = 0;
*iov = NULL;
return OMPI_SUCCESS;
}

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

while (0 == opal_convertor_raw(convertor,
temp_iov,
&temp_count,
&temp_data)) {
while (0 == opal_convertor_raw(convertor, temp_iov,
&temp_count, &temp_data)) {
*iovec_count = *iovec_count + temp_count;
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
if (NULL == *iov) {
opal_output(1, "OUT OF MEMORY\n");
free(temp_iov);
return OMPI_ERR_OUT_OF_RESOURCE;
}
for (i=0 ; i<temp_count ; i++) {
for (i = 0 ; i < temp_count ; i++) {
(*iov)[i+(*iovec_count-temp_count)].iov_base = temp_iov[i].iov_base;
(*iov)[i+(*iovec_count-temp_count)].iov_len = temp_iov[i].iov_len;
}
Expand All @@ -90,12 +84,12 @@ mca_common_ompio_decode_datatype ( ompi_datatype_t *datatype,
}
*iovec_count = *iovec_count + temp_count;
if ( temp_count > 0 ) {
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
if (NULL == *iov) {
opal_output(1, "OUT OF MEMORY\n");
*iov = (struct iovec *) realloc (*iov, *iovec_count * sizeof(struct iovec));
if (NULL == *iov) {
opal_output(1, "OUT OF MEMORY\n");
free(temp_iov);
return OMPI_ERR_OUT_OF_RESOURCE;
}
return OMPI_ERR_OUT_OF_RESOURCE;
}
}
for (i=0 ; i<temp_count ; i++) {
(*iov)[i+(*iovec_count-temp_count)].iov_base = temp_iov[i].iov_base;
Expand Down Expand Up @@ -342,7 +336,6 @@ int main (int argc, char *argv[]) {
struct iovec * iov_1 = NULL;
mca_common_ompio_decode_datatype ( datatype, 1, &iov_1, &iovec_count_1, 1);


assert(iovec_count_300 == iovec_count_10);
assert(iovec_count_300 == iovec_count_1);
// assert(iov[100].iov_base == iov2[100].iov_base);
Expand Down
3 changes: 1 addition & 2 deletions test/datatype/opal_datatype_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count )
osrc = (char*)malloc( malloced_size );

{
for( size_t i = 0; i < malloced_size; i++ )
osrc[i] = i % 128 + 32;
for( size_t i = 0; i < malloced_size; i++ ) osrc[i] = i % 128 + 32;
memcpy(odst, osrc, malloced_size);
}
pdst = odst - lb;
Expand Down
4 changes: 2 additions & 2 deletions test/datatype/opal_ddt_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static int32_t opal_datatype_create_vector( int count, int bLength, int stride,
}

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

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

0 comments on commit de6a289

Please sign in to comment.