1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2009 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
6 /* Regression test for MPICH trac ticket #972, originally written by
7 * Rob Latham <robl@mcs.anl.gov> as a simplification of a type
8 * encountered by the HDF5 library.
10 * Should be run with 1 process. */
15 /* uncomment to use debugging routine in MPICH
16 extern int MPIDU_Datatype_debug(MPI_Datatype type, int depth);
19 int makeHDF5type0(MPI_Datatype * type);
20 int makeHDF5type0(MPI_Datatype * type)
22 MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
28 MPI_Type_contiguous(4, MPI_BYTE, &ctg);
30 MPI_Type_vector(1, 5, 1, ctg, &vect);
32 b[0] = b[1] = b[2] = 1;
39 MPI_Type_create_struct(3, b, d, t, &structype);
41 MPI_Type_vector(1, 5, 1, structype, &vec2);
43 b[0] = b[1] = b[2] = 1;
50 MPI_Type_create_struct(3, b, d, t, &structype2);
52 MPI_Type_vector(1, 5, 1, structype2, &vec3);
54 b[0] = b[1] = b[2] = 1;
61 MPI_Type_create_struct(3, b, d, t, &structype3);
63 MPI_Type_vector(1, 5, 1, structype3, &vec4);
65 b[0] = b[1] = b[2] = 1;
72 MPI_Type_create_struct(3, b, d, t, &structype4);
74 MPI_Type_vector(1, 1, 1, structype4, &vec5);
76 b[0] = b[1] = b[2] = 1;
83 MPI_Type_create_struct(3, b, d, t, type);
87 MPI_Type_free(&structype);
89 MPI_Type_free(&structype2);
91 MPI_Type_free(&structype3);
93 MPI_Type_free(&structype4);
95 MPI_Type_commit(type);
100 int makeHDF5type1(MPI_Datatype * type);
101 int makeHDF5type1(MPI_Datatype * type)
103 MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
109 MPI_Type_contiguous(4, MPI_BYTE, &ctg);
111 MPI_Type_vector(1, 5, 1, ctg, &vect);
113 b[0] = b[1] = b[2] = 1;
120 MPI_Type_create_struct(3, b, d, t, &structype);
122 MPI_Type_vector(1, 5, 1, structype, &vec2);
124 b[0] = b[1] = b[2] = 1;
131 MPI_Type_create_struct(3, b, d, t, &structype2);
133 MPI_Type_vector(1, 5, 1, structype2, &vec3);
135 b[0] = b[1] = b[2] = 1;
142 MPI_Type_create_struct(3, b, d, t, &structype3);
144 MPI_Type_vector(1, 5, 1, structype3, &vec4);
146 b[0] = b[1] = b[2] = 1;
153 MPI_Type_create_struct(3, b, d, t, &structype4);
155 MPI_Type_vector(1, 1, 1, structype4, &vec5);
157 b[0] = b[1] = b[2] = 1;
164 MPI_Type_create_struct(3, b, d, t, type);
167 MPI_Type_free(&vect);
168 MPI_Type_free(&structype);
169 MPI_Type_free(&vec2);
170 MPI_Type_free(&structype2);
171 MPI_Type_free(&vec3);
172 MPI_Type_free(&structype3);
173 MPI_Type_free(&vec4);
174 MPI_Type_free(&structype4);
175 MPI_Type_free(&vec5);
176 MPI_Type_commit(type);
181 int makeHDF5type(MPI_Datatype * type);
182 int makeHDF5type(MPI_Datatype * type)
188 int blocklens[NTYPES];
189 MPI_Aint disps[NTYPES];
191 MPI_Datatype types[NTYPES];
192 makeHDF5type0(&(types[0]));
193 makeHDF5type1(&(types[1]));
195 for (i = 0; i < NTYPES; i++) {
200 MPI_Type_create_struct(NTYPES, blocklens, disps, types, type);
201 MPI_Type_commit(type);
203 for (i = 0; i < NTYPES; i++) {
204 MPI_Type_free(&(types[i]));
209 int main(int argc, char **argv)
211 MPI_Datatype hdf5type;
213 MPI_Init(&argc, &argv);
214 makeHDF5type(&hdf5type);
216 /*MPIDU_Datatype_debug(hdf5type, 32); */
218 MPI_Type_free(&hdf5type);
221 printf(" No Errors\n");