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.
12 /* Create an array with all of the MPI names in it */
14 typedef struct mpi_names_t { MPI_Datatype dtype; const char *name; } mpi_names_t;
16 /* The MPI standard specifies that the names must be the MPI names,
17 not the related language names (e.g., MPI_CHAR, not char) */
19 int main( int argc, char **argv )
22 mpi_names_t mpi_names[] = {
23 { MPI_CHAR, "MPI_CHAR" },
24 { MPI_SIGNED_CHAR, "MPI_SIGNED_CHAR" },
25 { MPI_UNSIGNED_CHAR, "MPI_UNSIGNED_CHAR" },
26 { MPI_BYTE, "MPI_BYTE" },
27 { MPI_WCHAR, "MPI_WCHAR" },
28 { MPI_SHORT, "MPI_SHORT" },
29 { MPI_UNSIGNED_SHORT, "MPI_UNSIGNED_SHORT" },
30 { MPI_INT, "MPI_INT" },
31 { MPI_UNSIGNED, "MPI_UNSIGNED" },
32 { MPI_LONG, "MPI_LONG" },
33 { MPI_UNSIGNED_LONG, "MPI_UNSIGNED_LONG" },
34 { MPI_FLOAT, "MPI_FLOAT" },
35 { MPI_DOUBLE, "MPI_DOUBLE" },
36 #if MTEST_HAVE_MIN_MPI_VERSION(2,2)
37 /* these two types were added in MPI-2.2 */
38 { MPI_AINT, "MPI_AINT" },
39 { MPI_OFFSET, "MPI_OFFSET" },
42 { MPI_PACKED, "MPI_PACKED" },
45 { MPI_FLOAT_INT, "MPI_FLOAT_INT" },
46 { MPI_DOUBLE_INT, "MPI_DOUBLE_INT" },
47 { MPI_LONG_INT, "MPI_LONG_INT" },
48 { MPI_SHORT_INT, "MPI_SHORT_INT" },
49 { MPI_2INT, "MPI_2INT" },
51 #ifdef HAVE_FORTRAN_BINDING
52 { MPI_COMPLEX, "MPI_COMPLEX" },
53 { MPI_DOUBLE_COMPLEX, "MPI_DOUBLE_COMPLEX" },
54 { MPI_LOGICAL, "MPI_LOGICAL" },
55 { MPI_REAL, "MPI_REAL" },
56 { MPI_DOUBLE_PRECISION, "MPI_DOUBLE_PRECISION" },
57 { MPI_INTEGER, "MPI_INTEGER" },
58 { MPI_2INTEGER, "MPI_2INTEGER" },
59 /* 2COMPLEX (and the 2DOUBLE_COMPLEX) were in MPI 1.0 but not later */
60 #ifdef HAVE_MPI_2COMPLEX
61 { MPI_2COMPLEX, "MPI_2COMPLEX" },
63 #ifdef HAVE_MPI_2DOUBLE_COMPLEX
64 /* MPI_2DOUBLE_COMPLEX is an extension - it is not part of MPI 2.1 */
65 { MPI_2DOUBLE_COMPLEX, "MPI_2DOUBLE_COMPLEX" },
67 { MPI_2REAL, "MPI_2REAL" },
68 { MPI_2DOUBLE_PRECISION, "MPI_2DOUBLE_PRECISION" },
69 { MPI_CHARACTER, "MPI_CHARACTER" },
71 #if MTEST_HAVE_MIN_MPI_VERSION(2,2)
72 /* these C99 types were added in MPI-2.2 */
73 { MPI_INT8_T, "MPI_INT8_T" },
74 { MPI_INT16_T, "MPI_INT16_T" },
75 { MPI_INT32_T, "MPI_INT32_T" },
76 { MPI_INT64_T, "MPI_INT64_T" },
77 { MPI_UINT8_T, "MPI_UINT8_T" },
78 { MPI_UINT16_T, "MPI_UINT16_T" },
79 { MPI_UINT32_T, "MPI_UINT32_T" },
80 { MPI_UINT64_T, "MPI_UINT64_T" },
81 { MPI_C_BOOL, "MPI_C_BOOL" },
82 { MPI_C_FLOAT_COMPLEX, "MPI_C_FLOAT_COMPLEX" },
83 { MPI_C_DOUBLE_COMPLEX, "MPI_C_DOUBLE_COMPLEX" },
84 { MPI_AINT, "MPI_AINT" },
85 { MPI_OFFSET, "MPI_OFFSET" },
87 /* Size-specific types */
88 /* Do not move MPI_REAL4 - this is used to indicate the very first
89 optional type. In addition, you must not add any required types
91 /* See MPI 2.1, Section 16.2. These are required, predefined types.
92 If the type is not available (e.g., *only* because the Fortran
93 compiler does not support it), the value may be MPI_DATATYPE_NULL */
94 { MPI_REAL4, "MPI_REAL4" },
95 { MPI_REAL8, "MPI_REAL8" },
96 { MPI_REAL16, "MPI_REAL16" },
97 { MPI_COMPLEX8, "MPI_COMPLEX8" },
98 { MPI_COMPLEX16, "MPI_COMPLEX16" },
99 { MPI_COMPLEX32, "MPI_COMPLEX32" },
100 { MPI_INTEGER1, "MPI_INTEGER1" },
101 { MPI_INTEGER2, "MPI_INTEGER2" },
102 { MPI_INTEGER4, "MPI_INTEGER4" },
103 { MPI_INTEGER8, "MPI_INTEGER8" },
104 #ifdef HAVE_MPI_INTEGER16
105 /* MPI_INTEGER16 is not included in most of the tables in MPI 2.1,
106 and some implementations omit it. An error will be reported, but
107 this ifdef allows the test to be built and run. */
108 { MPI_INTEGER16, "MPI_INTEGER16" },
110 /* Semi-optional types - if the compiler doesn't support long double
111 or long long, these might be MPI_DATATYPE_NULL */
112 { MPI_LONG_DOUBLE, "MPI_LONG_DOUBLE" },
113 { MPI_LONG_LONG_INT, "MPI_LONG_LONG_INT" },
114 { MPI_LONG_LONG, "MPI_LONG_LONG" },
115 { MPI_UNSIGNED_LONG_LONG, "MPI_UNSIGNED_LONG_LONG" },
116 { MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT" },
117 #if MTEST_HAVE_MIN_MPI_VERSION(2,2)
118 /* added in MPI-2.2 */
119 { MPI_C_LONG_DOUBLE_COMPLEX, "MPI_C_LONG_DOUBLE_COMPLEX" },
120 { MPI_AINT, "MPI_AINT" },
121 { MPI_OFFSET, "MPI_OFFSET" },
123 #if MTEST_HAVE_MIN_MPI_VERSION(3,0)
125 { MPI_COUNT, "MPI_COUNT" },
127 { 0, (char *)0 }, /* Sentinal used to indicate the last element */
130 char name[MPI_MAX_OBJECT_NAME];
131 int namelen, i, inOptional;
134 MTest_Init( &argc, &argv );
136 /* Sample some datatypes */
137 /* See 8.4, "Naming Objects" in MPI-2. The default name is the same
138 as the datatype name */
139 MPI_Type_get_name( MPI_DOUBLE, name, &namelen );
140 if (strncmp( name, "MPI_DOUBLE", MPI_MAX_OBJECT_NAME )) {
142 fprintf( stderr, "Expected MPI_DOUBLE but got :%s:\n", name );
145 MPI_Type_get_name( MPI_INT, name, &namelen );
146 if (strncmp( name, "MPI_INT", MPI_MAX_OBJECT_NAME )) {
148 fprintf( stderr, "Expected MPI_INT but got :%s:\n", name );
151 /* Now we try them ALL */
153 for (i=0; mpi_names[i].name != 0; i++) {
154 /* Are we in the optional types? */
155 if (strcmp( mpi_names[i].name, "MPI_REAL4" ) == 0)
157 /* If this optional type is not supported, skip it */
158 if (inOptional && mpi_names[i].dtype == MPI_DATATYPE_NULL) continue;
159 if (mpi_names[i].dtype == MPI_DATATYPE_NULL) {
160 /* Report an error because all of the standard types
163 fprintf( stderr, "MPI Datatype %s is MPI_DATATYPE_NULL\n",
167 MTestPrintfMsg( 10, "Checking type %s\n", mpi_names[i].name );
169 MPI_Type_get_name( mpi_names[i].dtype, name, &namelen );
170 if (strncmp( name, mpi_names[i].name, namelen )) {
172 fprintf( stderr, "Expected %s but got %s\n",
173 mpi_names[i].name, name );
177 /* Try resetting the name */
178 MPI_Type_set_name( MPI_INT, (char*)"int" );
180 MPI_Type_get_name( MPI_INT, name, &namelen );
181 if (strncmp( name, "int", MPI_MAX_OBJECT_NAME )) {
183 fprintf( stderr, "Expected int but got :%s:\n", name );
186 #ifndef HAVE_MPI_INTEGER16
188 fprintf( stderr, "MPI_INTEGER16 is not available\n" );
191 MTest_Finalize( errs );