1
1

Add a resized datatype to the test. Implement generic

data corectness for most of the conversion functions.
Этот коммит содержится в:
George Bosilca 2014-11-29 19:47:25 -05:00
родитель 0b0c7ea28b
Коммит 59b739ee90
6 изменённых файлов: 156 добавлений и 41 удалений

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2009 The University of Tennessee and The University
* Copyright (c) 2004-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@ -36,8 +36,8 @@
#define DUMP_DATA_AFTER_COMMIT 0x00000001
#define CHECK_PACK_UNPACK 0x00000002
uint32_t outputFlags = CHECK_PACK_UNPACK;
#define VALIDATE_DATA 0x00000004
uint32_t outputFlags = CHECK_PACK_UNPACK | VALIDATE_DATA;
/**
* Cache cleanup.
@ -568,6 +568,38 @@ ompi_datatype_t* test_struct( void )
return pdt;
}
/* Create a non-contiguous resized datatype */
struct structure {
double not_transfered;
double transfered_1;
double transfered_2;
};
ompi_datatype_t* create_struct_constant_gap_resized_ddt( ompi_datatype_t* type )
{
struct structure *data;
ompi_datatype_t *struct_type, *temp_type;
ompi_datatype_t *types[2] = {type, type};
int blocklens[2] = {1, 1};
MPI_Aint disps[3];
MPI_Get_address(&data[0].transfered_1, &disps[0]);
MPI_Get_address(&data[0].transfered_2, &disps[1]);
MPI_Get_address(&data[0], &disps[2]);
disps[1] -= disps[2]; /* 8 */
disps[0] -= disps[2]; /* 16 */
ompi_datatype_create_struct(2, blocklens, disps, types, &temp_type);
ompi_datatype_create_resized(temp_type, 0, sizeof(data[0]), &struct_type);
ompi_datatype_commit(&struct_type);
OBJ_RELEASE(temp_type); assert( temp_type == NULL );
if( outputFlags & DUMP_DATA_AFTER_COMMIT ) {
ompi_datatype_dump( struct_type );
}
return struct_type;
}
typedef struct {
int i1;
int gap;

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2009 The University of Tennessee and The University
* Copyright (c) 2004-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@ -91,4 +91,5 @@ extern ompi_datatype_t* create_strange_dt( void );
extern ompi_datatype_t* create_contiguous_type( const ompi_datatype_t* data, int count );
extern ompi_datatype_t* create_vector_type( const ompi_datatype_t* data, int count,
int length, int stride );
extern ompi_datatype_t* create_struct_constant_gap_resized_ddt( ompi_datatype_t* type );

Просмотреть файл

@ -3,7 +3,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2009 The University of Tennessee and The University
* Copyright (c) 2004-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@ -130,6 +130,7 @@ static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count )
void *pdst, *psrc;
TIMER_DATA_TYPE start, end;
long total_time;
int errors = 0;
opal_datatype_type_extent( pdt, &extent );
@ -140,8 +141,8 @@ static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count )
int i;
for( i = 0; i < (count * extent); i++ )
((char*)psrc)[i] = i % 128 + 32;
memcpy(pdst, psrc, (count * extent));
}
memset( pdst, 0, count * extent );
cache_trash(); /* make sure the cache is useless */
@ -153,10 +154,26 @@ static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count )
GET_TIME( end );
total_time = ELAPSED_TIME( start, end );
printf( "direct local copy in %ld microsec\n", total_time );
if(outputFlags & VALIDATE_DATA) {
for( int i = 0; i < (count * extent); i++ ) {
if( ((char*)pdst)[i] != ((char*)psrc)[i] ) {
printf("error at position %d (%d != %d)\n",
i, (int)((char*)pdst)[i], (int)((char*)psrc)[i]);
errors++;
if(outputFlags & QUIT_ON_FIRST_ERROR) { assert(0); exit(-1); }
}
}
if( 0 == errors ) {
printf("Validation check succesfully passed\n");
} else {
printf("Found %d errors. Giving up!\n", errors);
exit(-1);
}
}
free( pdst );
free( psrc );
return OPAL_SUCCESS;
return (0 == errors ? OPAL_SUCCESS : errors);
}
static int
@ -228,6 +245,20 @@ local_copy_with_convertor_2datatypes( opal_datatype_t const * const send_type, i
}
length += max_data;
if( outputFlags & RESET_CONVERTORS ) {
size_t pos = 0;
opal_convertor_set_position(send_convertor, &pos);
pos = length;
opal_convertor_set_position(send_convertor, &pos);
assert(pos == length);
pos = 0;
opal_convertor_set_position(recv_convertor, &pos);
pos = length;
opal_convertor_set_position(recv_convertor, &pos);
assert(pos == length);
}
}
GET_TIME( end );
total_time = ELAPSED_TIME( start, end );
@ -247,7 +278,6 @@ local_copy_with_convertor_2datatypes( opal_datatype_t const * const send_type, i
return OPAL_SUCCESS;
}
static int local_copy_with_convertor( opal_datatype_t const * const pdt, int count, int chunk )
{
OPAL_PTRDIFF_TYPE extent;
@ -256,7 +286,7 @@ static int local_copy_with_convertor( opal_datatype_t const * const pdt, int cou
struct iovec iov;
uint32_t iov_count;
size_t max_data;
int32_t length = 0, done1 = 0, done2 = 0;
int32_t length = 0, done1 = 0, done2 = 0, errors = 0;
TIMER_DATA_TYPE start, end, unpack_start, unpack_end;
long total_time, unpack_time = 0;
@ -269,8 +299,8 @@ static int local_copy_with_convertor( opal_datatype_t const * const pdt, int cou
{
int i = 0;
for( ; i < (count * extent); ((char*)psrc)[i] = i % 128 + 32, i++ );
memcpy(pdst, psrc, (count * extent));
}
memset( pdst, 0, count * extent );
send_convertor = opal_convertor_create( remote_arch, 0 );
if( OPAL_SUCCESS != opal_convertor_prepare_for_send( send_convertor, pdt, count, psrc ) ) {
@ -312,12 +342,41 @@ static int local_copy_with_convertor( opal_datatype_t const * const pdt, int cou
}
length += max_data;
if( outputFlags & RESET_CONVERTORS ) {
size_t pos = 0;
opal_convertor_set_position(send_convertor, &pos);
pos = length;
opal_convertor_set_position(send_convertor, &pos);
assert(pos == length);
pos = 0;
opal_convertor_set_position(recv_convertor, &pos);
pos = length;
opal_convertor_set_position(recv_convertor, &pos);
assert(pos == length);
}
}
GET_TIME( end );
total_time = ELAPSED_TIME( start, end );
printf( "copying same data-type using convertors in %ld microsec\n", total_time );
printf( "\t unpack in %ld microsec [pack in %ld microsec]\n", unpack_time,
total_time - unpack_time );
if(outputFlags & VALIDATE_DATA) {
for( int i = 0; i < (count * extent); i++ ) {
if( ((char*)pdst)[i] != ((char*)psrc)[i] ) {
printf("error at position %d (%d != %d)\n",
i, (int)((char*)pdst)[i], (int)((char*)psrc)[i]);
errors++;
if(outputFlags & QUIT_ON_FIRST_ERROR) { assert(0); exit(-1); }
}
}
if( 0 == errors ) {
printf("Validation check succesfully passed\n");
} else {
printf("Found %d errors. Giving up!\n", errors);
exit(-1);
}
}
clean_and_return:
if( NULL != send_convertor ) OBJ_RELEASE( send_convertor );
if( NULL != recv_convertor ) OBJ_RELEASE( recv_convertor );
@ -325,7 +384,7 @@ static int local_copy_with_convertor( opal_datatype_t const * const pdt, int cou
if( NULL != pdst ) free( pdst );
if( NULL != psrc ) free( psrc );
if( NULL != ptemp ) free( ptemp );
return OPAL_SUCCESS;
return (0 == errors ? OPAL_SUCCESS : errors);
}
/**
@ -370,14 +429,6 @@ int main( int argc, char* argv[] )
}
OBJ_RELEASE( pdt ); assert( pdt == NULL );
printf( "\n\n#\n * TEST CREATE STRUCT CONSTANT GAP RESIZED\n#\n\n" );
pdt = create_struct_constant_gap_resized_ddt();
if( outputFlags & CHECK_PACK_UNPACK ) {
local_copy_ddt_count(pdt, 10000);
local_copy_with_convertor(pdt, 10000, 956);
}
OBJ_RELEASE( pdt ); assert( pdt == NULL );
mpich_typeub();
mpich_typeub2();
mpich_typeub3();
@ -501,7 +552,25 @@ int main( int argc, char* argv[] )
}
printf( ">>--------------------------------------------<<\n" );
OBJ_RELEASE( pdt ); assert( pdt == NULL );
printf( ">>--------------------------------------------<<\n" );
printf( "Struct data-type resized (double unused followed by 2 used doubles)\n" );
pdt = create_struct_constant_gap_resized_ddt( &opal_datatype_float8 );
opal_datatype_dump( pdt );
if( outputFlags & CHECK_PACK_UNPACK ) {
local_copy_ddt_count(pdt, 1);
local_copy_with_convertor( pdt, 100, 11 );
local_copy_with_convertor_2datatypes( pdt, 100, pdt, 100, 11 );
local_copy_with_convertor( pdt, 100, 82 );
local_copy_with_convertor_2datatypes( pdt, 100, pdt, 100, 81 );
local_copy_with_convertor( pdt, 1500, 6000 );
local_copy_with_convertor_2datatypes( pdt, 1500, pdt, 1500, 666 );
local_copy_with_convertor( pdt, 10000, 36000 );
local_copy_with_convertor_2datatypes( pdt, 10000, pdt, 10000, 1111 );
}
printf( ">>--------------------------------------------<<\n" );
OBJ_RELEASE( pdt ); assert( pdt == NULL );
printf( ">>--------------------------------------------<<\n" );
pdt = test_struct_char_double();
if( outputFlags & CHECK_PACK_UNPACK ) {

Просмотреть файл

@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2009 The University of Tennessee and The University
* Copyright (c) 2009-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
@ -26,7 +26,7 @@
#include "opal/datatype/opal_datatype.h"
uint32_t outputFlags = 0;
uint32_t outputFlags = VALIDATE_DATA | CHECK_PACK_UNPACK | RESET_CONVERTORS | QUIT_ON_FIRST_ERROR;
static int32_t opal_datatype_create_indexed( int count, const int* pBlockLength, const int* pDisp,
const opal_datatype_t* oldType, opal_datatype_t** newType );
@ -260,7 +260,7 @@ struct structure {
double transfered_2;
};
opal_datatype_t* create_struct_constant_gap_resized_ddt( void )
opal_datatype_t* create_struct_constant_gap_resized_ddt( const opal_datatype_t* type )
{
opal_datatype_t *struct_type;

Просмотреть файл

@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2009 The University of Tennessee and The University
* Copyright (c) 2009-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
@ -25,6 +25,9 @@
#define DUMP_DATA_AFTER_COMMIT 0x00000001
#define CHECK_PACK_UNPACK 0x00000002
#define VALIDATE_DATA 0x00000004
#define RESET_CONVERTORS 0x00000010
#define QUIT_ON_FIRST_ERROR 0x00000020
extern uint32_t outputFlags;
@ -49,6 +52,6 @@ extern int mpich_typeub( void );
extern int mpich_typeub2( void );
extern int mpich_typeub3( void );
extern opal_datatype_t* create_struct_constant_gap_resized_ddt( void );
extern opal_datatype_t* create_struct_constant_gap_resized_ddt( const opal_datatype_t* type );
#endif /* TEST_OPAL_DDT_LIB_H */

Просмотреть файл

@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2004-2006 The University of Tennessee and The University
* Copyright (c) 2004-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* $COPYRIGHT$
@ -31,7 +31,7 @@ struct structure {
};
static MPI_Datatype
create_struct_constant_gap_resized_ddt( int number, /* number of repetitions */
create_struct_constant_gap_resized_ddt( int number, /* IGNORED: number of repetitions */
int contig_size, /* IGNORED: number of elements in a contiguous chunk */
int gap_size ) /* IGNORED: number of elements in a gap */
{
@ -50,6 +50,8 @@ create_struct_constant_gap_resized_ddt( int number, /* number of repetitions */
MPI_Type_create_struct(2, blocklens, disps, types, &temp_type);
MPI_Type_create_resized(temp_type, 0, sizeof(data[0]), &struct_type);
MPI_Type_commit(&struct_type);
MPI_Type_free(&temp_type);
MPI_DDT_DUMP( struct_type );
return struct_type;
}
@ -338,19 +340,19 @@ static int do_test_for_ddt( MPI_Datatype sddt, MPI_Datatype rddt, int length )
MPI_Type_get_extent( sddt, &lb, &extent );
sbuf = (char*)malloc( length );
rbuf = (char*)malloc( length );
printf( "# Isend recv\n" );
printf( "# Isend recv (length %d)\n", length );
for( i = 1; i <= (length/extent); i *= 2 ) {
isend_recv( 10, sddt, i, sbuf, rddt, i, rbuf );
}
printf( "# Isend Irecv Wait\n" );
printf( "# Isend Irecv Wait (length %d)\n", length );
for( i = 1; i <= (length/extent); i *= 2 ) {
isend_irecv_wait( 10, sddt, i, sbuf, rddt, i, rbuf );
}
printf( "# Irecv send\n" );
printf( "# Irecv send (length %d)\n", length );
for( i = 1; i <= (length/extent); i *= 2 ) {
irecv_send( 10, sddt, i, sbuf, rddt, i, rbuf );
}
printf( "# Irecv Isend Wait\n" );
printf( "# Irecv Isend Wait (length %d)\n", length );
for( i = 1; i <= (length/extent); i *= 2 ) {
irecv_isend_wait( 10, sddt, i, sbuf, rddt, i, rbuf );
}
@ -365,12 +367,14 @@ static int do_test_for_ddt( MPI_Datatype sddt, MPI_Datatype rddt, int length )
#define DO_OPTIMIZED_INDEXED_GAP 0x08
#define DO_STRUCT_CONSTANT_GAP_RESIZED 0x10
#define MIN_LENGTH 1024
#define MAX_LENGTH (1024*1024)
int main( int argc, char* argv[] )
{
int length = 111;
int rank, size;
MPI_Datatype ddt;
int run_tests = 0xffffffff; /* do all tests by default */
int length, rank, size;
MPI_Datatype ddt;
/*int run_tests = DO_CONSTANT_GAP;*/
MPI_Init (&argc, &argv);
@ -385,14 +389,16 @@ int main( int argc, char* argv[] )
if( run_tests & DO_CONTIG ) {
printf( "\ncontiguous datatype\n\n" );
do_test_for_ddt( MPI_INT, MPI_INT, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( MPI_INT, MPI_INT, length );
}
if( run_tests & DO_INDEXED_GAP ) {
printf( "\nindexed gap\n\n" );
ddt = create_indexed_gap_ddt();
MPI_DDT_DUMP( ddt );
do_test_for_ddt( ddt, ddt, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( ddt, ddt, length );
MPI_Type_free( &ddt );
}
@ -400,7 +406,8 @@ int main( int argc, char* argv[] )
printf( "\noptimized indexed gap\n\n" );
ddt = create_indexed_gap_optimized_ddt();
MPI_DDT_DUMP( ddt );
do_test_for_ddt( ddt, ddt, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( ddt, ddt, length );
MPI_Type_free( &ddt );
}
@ -408,7 +415,8 @@ int main( int argc, char* argv[] )
printf( "\nconstant indexed gap\n\n" );
ddt = create_indexed_constant_gap_ddt( 80, 100, 1 );
MPI_DDT_DUMP( ddt );
do_test_for_ddt( ddt, ddt, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( ddt, ddt, length );
MPI_Type_free( &ddt );
}
@ -416,15 +424,17 @@ int main( int argc, char* argv[] )
printf( "\noptimized constant indexed gap\n\n" );
ddt = create_optimized_indexed_constant_gap_ddt( 80, 100, 1 );
MPI_DDT_DUMP( ddt );
do_test_for_ddt( ddt, ddt, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( ddt, ddt, length );
MPI_Type_free( &ddt );
}
if( run_tests & DO_STRUCT_CONSTANT_GAP_RESIZED ) {
printf( "\nstruct constant gap resized\n\n" );
ddt = create_struct_constant_gap_resized_ddt( 80, 0 /* unused */, 0 /* unused */ );
ddt = create_struct_constant_gap_resized_ddt( 0 /* unused */, 0 /* unused */, 0 /* unused */ );
MPI_DDT_DUMP( ddt );
do_test_for_ddt( ddt, ddt, length );
for( length = MIN_LENGTH; length < MAX_LENGTH; length <<=1 )
do_test_for_ddt( ddt, ddt, length );
MPI_Type_free( &ddt );
}