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)
16 MPI_Request *req=NULL;
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);
58 MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
59 MPI_Type_commit(&newtype);
62 req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request));
63 for (i = 0; i < NUM_LOOPS; i++)
64 MPI_Issend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
67 for (i = 0; i < NUM_LOOPS; i++)
68 MPI_Recv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
70 MPI_Type_free(&newtype);
72 MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
74 MPI_Barrier(MPI_COMM_WORLD);
78 MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
79 MPI_Type_commit(&newtype);
81 req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request));
83 MPI_Barrier(MPI_COMM_WORLD);
84 for (i = 0; i < NUM_LOOPS; i++)
85 MPI_Irsend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
88 for (i = 0; i < NUM_LOOPS; i++)
89 MPI_Irecv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]);
90 MPI_Barrier(MPI_COMM_WORLD);
92 MPI_Type_free(&newtype);
93 MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
95 MPI_Barrier(MPI_COMM_WORLD);
102 printf(" No Errors\n");