5 #if defined(NEEDS_STDLIB_PROTOTYPES)
10 * Trying to manipulate the extent of a datatype with succesive
11 * calls to MPI_Type_struct. Tests that a MPI_UB buried within
12 * a structure is found. From kalns@canidae.cps.msu.edu (modified to
13 * fit test structure).
15 int main( int argc, char **argv )
17 int errs = 0, toterrs, rank;
21 MPI_Datatype types[2];
22 MPI_Datatype type1,type2,type3;
23 MPI_Aint extent1, extent2, extent3;
25 MPI_Init( &argc, &argv );
27 /* 2 blocks of 1 int each, stride of 4 ; expect extent to be 20
29 MPI_Type_vector( 2, 1, 4, MPI_INT, &type1 );
30 MPI_Type_commit( &type1 );
31 MPI_Type_extent( type1, &extent );
32 extent1 = 5 * sizeof(int);
33 if (extent != extent1) {
35 printf("extent(type1)=%ld\n",(long)extent);
41 displ[1]=sizeof(int)*4;
46 /* using MPI_UB and Type_struct, monkey with the extent, making it 16
48 MPI_Type_struct( 2, blens, displ, types, &type2 );
49 MPI_Type_commit( &type2 );
50 MPI_Type_extent( type2, &extent );
51 if (extent != extent2) {
53 printf("extent(type2)=%ld\n",(long)extent);
56 /* monkey with the extent again, making it 4
58 * ===> MPIF gives 16, the old extent
65 MPI_Type_struct( 2, blens, displ, types, &type3 );
66 MPI_Type_commit( &type3 );
68 MPI_Type_extent( type3, &extent );
69 if (extent != extent3 && extent != 4) {
71 printf("extent(type3)=%ld\n",(long)extent);
74 MPI_Type_free( &type1 );
75 MPI_Type_free( &type2 );
76 MPI_Type_free( &type3 );
78 MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
79 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
81 if (toterrs == 0) printf( " No Errors\n" );
82 else printf( "Found %d errors\n", toterrs );