1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test of type_match_size";
17 * type match size is part of the extended Fortran support, and may not
21 int main( int argc, char *argv[] )
27 MTest_Init( &argc, &argv );
29 /* Check the most likely cases. Note that it is an error to
30 free the type returned by MPI_Type_match_size. Also note
31 that it is an error to request a size not supported by the compiler,
32 so Type_match_size should generate an error in that case */
33 MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
35 err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(float), &newtype );
38 MTestPrintErrorMsg( "Float: ", err );
41 err = MPI_Type_size( newtype, &dsize );
44 MTestPrintErrorMsg( "Float type: ", err );
47 if (dsize != sizeof(float)) {
49 printf( "Unexpected size for float (%d != %d)\n",
50 dsize, (int) sizeof(float) );
55 err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(double), &newtype );
58 MTestPrintErrorMsg( "Double: ", err );
61 MPI_Type_size( newtype, &dsize );
62 if (dsize != sizeof(double)) {
64 printf( "Unexpected size for double\n" );
67 #ifdef HAVE_LONG_DOUBLE
68 err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(long double), &newtype );
71 MTestPrintErrorMsg( "Long double: ", err );
74 MPI_Type_size( newtype, &dsize );
75 if (dsize != sizeof(long double)) {
77 printf( "Unexpected size for long double\n" );
82 err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(short), &newtype );
85 MTestPrintErrorMsg( "Short: ", err );
88 MPI_Type_size( newtype, &dsize );
89 if (dsize != sizeof(short)) {
91 printf( "Unexpected size for short\n" );
95 err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(int), &newtype );
98 MTestPrintErrorMsg( "Int: ", err );
101 MPI_Type_size( newtype, &dsize );
102 if (dsize != sizeof(int)) {
104 printf( "Unexpected size for int\n" );
108 err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long), &newtype );
111 MTestPrintErrorMsg( "Long: ", err );
114 MPI_Type_size( newtype, &dsize );
115 if (dsize != sizeof(long)) {
117 printf( "Unexpected size for long\n" );
120 #ifdef HAVE_LONG_LONG
121 err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype );
124 MTestPrintErrorMsg( "Long long: ", err );
127 MPI_Type_size( newtype, &dsize );
128 if (dsize != sizeof(long long)) {
130 printf( "Unexpected size for long long\n" );
135 /* COMPLEX is a FORTRAN type. The MPICH Type_match_size attempts
136 to give a valid datatype, but if Fortran is not available,
137 MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.
138 Allow this case by testing for MPI_DATATYPE_NULL */
139 if (MPI_COMPLEX != MPI_DATATYPE_NULL) {
140 err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(float), &newtype );
143 MTestPrintErrorMsg( "Complex: ", err );
146 MPI_Type_size( newtype, &dsize );
147 if (dsize != 2*sizeof(float)) {
149 printf( "Unexpected size for complex\n" );
154 if (MPI_COMPLEX != MPI_DATATYPE_NULL &&
155 MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
156 err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(double), &newtype );
159 MTestPrintErrorMsg( "Double complex: ", err );
162 MPI_Type_size( newtype, &dsize );
163 if (dsize != 2*sizeof(double)) {
165 printf( "Unexpected size for double complex\n" );
170 MTest_Finalize( errs );