2 * This is a test of Type_commit. This checks to see if Type_commit
3 * (or Type_struct) replaces a struct with a contiguous type, and
4 * that that type is constructed correctly.
10 #if defined(NEEDS_STDLIB_PROTOTYPES)
14 int main( int argc, char **argv )
17 MPI_Aint nlb, nub, n2lb, n2ub;
18 MPI_Datatype ntype, n2type;
20 MPI_Datatype types[2];
25 MPI_Init( &argc, &argv );
27 MPI_Address( &myarray[0], &displs[0] );
28 MPI_Address( &myarray[3], &displs[1] );
31 displs[1] = displs[1] - displs[0];
33 types[0] = MPI_DOUBLE;
34 types[1] = MPI_DOUBLE;
35 MPI_Type_struct( 2, blockcounts, displs, types, &ntype );
36 MPI_Type_commit( &ntype );
38 MPI_Type_size( ntype, &nsize );
39 MPI_Type_lb( ntype, &nlb );
40 MPI_Type_ub( ntype, &nub );
44 printf( "LB for struct is %d\n", (int)nlb );
46 if (nub != 4 * sizeof(double)) {
48 printf( "UB for struct is %d != %d\n", (int)nub,
49 4 * (int)sizeof(double) );
51 if (nsize != 4 * sizeof(double)) {
53 printf( "Size for struct %d != %d\n", nsize, 4 * (int)sizeof(double) );
56 MPI_Type_contiguous( 3, ntype, &n2type );
57 MPI_Type_commit( &n2type );
59 MPI_Type_size( n2type, &n2size );
60 MPI_Type_lb( n2type, &n2lb );
61 MPI_Type_ub( n2type, &n2ub );
63 if (n2size != 3 * nsize) {
65 printf( "Size of contig type %d != %d\n", n2size, 3*nsize );
69 printf( "LB for contig is %d\n", (int)n2lb );
71 if (n2ub != 3 * nub) {
73 printf( "UB for contig %d != %d\n", (int)n2ub, 3 * (int)nub );
77 printf( "Found %d errors\n", err );
80 printf( " No Errors\n" );
82 MPI_Type_free( &ntype );
83 MPI_Type_free( &n2type );