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);
34 fprintf(stderr, "comm size must be > 1\n");
39 buf = malloc(64 * 129);
42 fprintf(stderr, "error allocating buffer\n");
47 for (i = 8; i < 64; i += 4) {
48 MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype);
50 MPI_Type_commit(&newtype);
51 memset(buf, 0, 64 * 129);
55 for (j = 0; j < i; j++) {
57 for (k = 0; k < 129; k++) {
58 buf[129 * j + k] = (char) j;
63 MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD);
67 MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
70 for (j = 0; j < i; j++) {
72 for (k = 0; k < 129; k++) {
73 if (k < 128 && buf[129 * j + k] != (char) j) {
76 "(i=%d, pos=%d) should be %d but is %d\n",
77 i, 129 * j + k, j, (int) buf[129 * j + k]);
80 else if (k == 128 && buf[129 * j + k] != (char) 0) {
83 "(i=%d, pos=%d) should be %d but is %d\n",
84 i, 129 * j + k, 0, (int) buf[129 * j + k]);
91 MPI_Type_free(&newtype);
97 MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
100 fprintf(stderr, "%d errors reported from receiver\n", recv_errs);
104 else if (rank == 1) {
105 MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
111 /* print message and exit */
114 fprintf(stderr, "Found %d errors\n", errs);
118 printf(" No Errors\n");
124 static int parse_args(int argc, char **argv)
129 * while ((ret = getopt(argc, argv, "v")) >= 0)
138 if (argc > 1 && strcmp(argv[1], "-v") == 0)