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", dsize, (int) sizeof(float));
54 err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(double), &newtype);
57 MTestPrintErrorMsg("Double: ", err);
60 MPI_Type_size(newtype, &dsize);
61 if (dsize != sizeof(double)) {
63 printf("Unexpected size for double\n");
66 #ifdef HAVE_LONG_DOUBLE
67 err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(long double), &newtype);
70 MTestPrintErrorMsg("Long double: ", err);
73 MPI_Type_size(newtype, &dsize);
74 if (dsize != sizeof(long double)) {
76 printf("Unexpected size for long double\n");
81 err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(short), &newtype);
84 MTestPrintErrorMsg("Short: ", err);
87 MPI_Type_size(newtype, &dsize);
88 if (dsize != sizeof(short)) {
90 printf("Unexpected size for short\n");
94 err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(int), &newtype);
97 MTestPrintErrorMsg("Int: ", err);
100 MPI_Type_size(newtype, &dsize);
101 if (dsize != sizeof(int)) {
103 printf("Unexpected size for int\n");
107 err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long), &newtype);
110 MTestPrintErrorMsg("Long: ", err);
113 MPI_Type_size(newtype, &dsize);
114 if (dsize != sizeof(long)) {
116 printf("Unexpected size for long\n");
119 #ifdef HAVE_LONG_LONG
120 err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype);
123 MTestPrintErrorMsg("Long long: ", err);
126 MPI_Type_size(newtype, &dsize);
127 if (dsize != sizeof(long long)) {
129 printf("Unexpected size for long long\n");
134 /* COMPLEX is a FORTRAN type. The MPICH Type_match_size attempts
135 * to give a valid datatype, but if Fortran is not available,
136 * MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.
137 * Allow this case by testing for MPI_DATATYPE_NULL */
138 if (MPI_COMPLEX != MPI_DATATYPE_NULL) {
139 err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(float), &newtype);
142 MTestPrintErrorMsg("Complex: ", err);
145 MPI_Type_size(newtype, &dsize);
146 if (dsize != 2 * sizeof(float)) {
148 printf("Unexpected size for complex\n");
153 if (MPI_COMPLEX != MPI_DATATYPE_NULL && MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
154 err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(double), &newtype);
157 MTestPrintErrorMsg("Double complex: ", err);
160 MPI_Type_size(newtype, &dsize);
161 if (dsize != 2 * sizeof(double)) {
163 printf("Unexpected size for double complex\n");
168 MTest_Finalize(errs);