1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
7 /* Tests that Type_get_extent of a couple of basic types succeeds. */
11 #include "mpitestconf.h"
16 static int verbose = 0;
18 int parse_args(int argc, char **argv);
20 int main(int argc, char **argv)
22 int mpi_err, errs = 0, size;
23 MPI_Aint lb, ub, extent;
31 MPI_Init(&argc, &argv);
32 parse_args(argc, argv);
34 /* To improve reporting of problems about operations, we
35 * change the error handler to errors return */
36 MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
39 mpi_err = MPI_Type_size(type, &size);
40 if (mpi_err != MPI_SUCCESS) {
42 fprintf(stderr, "MPI_Type_size of MPI_INT failed.\n");
46 if (size != sizeof(int)) {
48 fprintf(stderr, "MPI_Type_size of MPI_INT incorrect size (%d); should be %d.\n",
49 size, (int) sizeof(int));
54 mpi_err = MPI_Type_get_extent(type, &lb, &extent);
55 if (mpi_err != MPI_SUCCESS) {
57 fprintf(stderr, "MPI_Type_get_extent of MPI_INT failed.\n");
61 if (extent != sizeof(int)) {
64 "MPI_Type_get_extent of MPI_INT returned incorrect extent (%d); should be %d.\n",
65 (int) extent, (int) sizeof(int));
72 "MPI_Type_get_extent of MPI_INT returned incorrect lb (%d); should be 0.\n",
77 mpi_err = MPI_Type_ub(type, &ub);
78 if (mpi_err != MPI_SUCCESS) {
80 fprintf(stderr, "MPI_Type_ub of MPI_INT failed.\n");
84 if (ub != extent - lb) {
86 fprintf(stderr, "MPI_Type_ub of MPI_INT returned incorrect ub (%d); should be %d.\n",
87 (int) ub, (int) (extent - lb));
93 mpi_err = MPI_Type_size(type, &size);
94 if (mpi_err != MPI_SUCCESS) {
96 fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT failed.\n");
100 if (size != sizeof(float) + sizeof(int)) {
103 "MPI_Type_size of MPI_FLOAT_INT returned incorrect size (%d); should be %d.\n",
104 size, (int) (sizeof(float) + sizeof(int)));
109 mpi_err = MPI_Type_get_extent(type, &lb, &extent);
110 if (mpi_err != MPI_SUCCESS) {
112 fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT failed.\n");
116 if (extent != sizeof(foo)) {
119 "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect extent (%d); should be %d.\n",
120 (int) extent, (int) sizeof(foo));
127 "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect lb (%d); should be 0.\n",
132 mpi_err = MPI_Type_ub(type, &ub);
133 if (mpi_err != MPI_SUCCESS) {
135 fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT failed.\n");
139 if (ub != extent - lb) {
142 "MPI_Type_ub of MPI_FLOAT_INT returned incorrect ub (%d); should be %d.\n",
143 (int) ub, (int) (extent - lb));
148 /* print message and exit */
150 fprintf(stderr, "Found %d errors\n", errs);
153 printf(" No Errors\n");
159 int parse_args(int argc, char **argv)
164 * while ((ret = getopt(argc, argv, "v")) >= 0)
173 if (argc > 1 && strcmp(argv[1], "-v") == 0)