1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2016 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
11 #define NUM_LOOPS (128)
13 int main(int argc, char **argv)
18 int snd_buf[3], rcv_buf[3];
22 MPI_Init(&argc, &argv);
23 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
24 MPI_Comm_size(MPI_COMM_WORLD, &size);
27 fprintf(stderr, "Must run with at least 2 processes\n");
28 MPI_Abort(MPI_COMM_WORLD, 1);
31 displs = (int *) malloc(count * sizeof(int));
32 for (i = 0; i < count; i++)
35 MPI_Barrier(MPI_COMM_WORLD);
38 MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
39 MPI_Type_commit(&newtype);
42 req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request));
43 for (i = 0; i < NUM_LOOPS; i++)
44 MPI_Isend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
47 for (i = 0; i < NUM_LOOPS; i++)
48 MPI_Recv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
50 MPI_Type_free(&newtype);
52 MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
54 MPI_Barrier(MPI_COMM_WORLD);
57 MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
58 MPI_Type_commit(&newtype);
61 req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request));
62 for (i = 0; i < NUM_LOOPS; i++)
63 MPI_Issend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
66 for (i = 0; i < NUM_LOOPS; i++)
67 MPI_Recv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
69 MPI_Type_free(&newtype);
71 MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
73 MPI_Barrier(MPI_COMM_WORLD);
76 MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
77 MPI_Type_commit(&newtype);
79 req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request));
81 MPI_Barrier(MPI_COMM_WORLD);
82 for (i = 0; i < NUM_LOOPS; i++)
83 MPI_Irsend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
86 for (i = 0; i < NUM_LOOPS; i++)
87 MPI_Irecv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
88 MPI_Barrier(MPI_COMM_WORLD);
90 MPI_Type_free(&newtype);
91 MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
93 MPI_Barrier(MPI_COMM_WORLD);
98 printf(" No Errors\n");