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.
8 #include "mpitestconf.h"
15 static int verbose = 0;
17 static int parse_args(int argc, char **argv);
19 int main( int argc, char *argv[] )
26 MPI_Init(&argc, &argv);
27 parse_args(argc, argv);
29 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30 MPI_Comm_size(MPI_COMM_WORLD, &size);
33 if (verbose) fprintf(stderr, "comm size must be > 1\n");
38 buf = malloc(64 * 129);
40 if (verbose) fprintf(stderr, "error allocating buffer\n");
45 for (i = 8; i < 64; i += 4) {
46 MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype);
48 MPI_Type_commit(&newtype);
49 memset(buf, 0, 64*129);
53 for (j=0; j < i; j++) {
55 for (k=0; k < 129; k++) {
56 buf[129*j + k] = (char) j;
61 MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD);
65 MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
68 for (j=0; j < i; j++) {
70 for (k=0; k < 129; k++) {
71 if (k < 128 && buf[129*j + k] != (char) j) {
72 if (verbose) fprintf(stderr,
73 "(i=%d, pos=%d) should be %d but is %d\n",
74 i, 129*j + k, j, (int) buf[129*j + k]);
77 else if (k == 128 && buf[129*j + k] != (char) 0) {
78 if (verbose) fprintf(stderr,
79 "(i=%d, pos=%d) should be %d but is %d\n",
80 i, 129*j + k, 0, (int) buf[129*j + k]);
87 MPI_Type_free(&newtype);
93 MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD,
96 if (verbose) fprintf(stderr, "%d errors reported from receiver\n",
101 else if (rank == 1) {
102 MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
108 /* print message and exit */
110 if (rank == 0) fprintf(stderr, "Found %d errors\n", errs);
113 if (rank == 0) printf(" No Errors\n");
119 static int parse_args(int argc, char **argv)
124 while ((ret = getopt(argc, argv, "v")) >= 0)
133 if (argc > 1 && strcmp(argv[1], "-v") == 0)