1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
3 * (C) 2015 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 #define BUF_COUNT (16*1024)
14 int main(int argc, char *argv[])
18 char recvbuf[BUF_COUNT], sendbuf[BUF_COUNT];
20 MPI_Status *sendstats = NULL;
21 MPI_Request *sendreqs = NULL;
23 MPI_Init(&argc, &argv);
25 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
28 sendreqs = (MPI_Request *) malloc(nprocs * sizeof(MPI_Request));
29 sendstats = (MPI_Status *) malloc(nprocs * sizeof(MPI_Status));
31 for (x = 0; x < ITER; x++) {
32 MPI_Barrier(MPI_COMM_WORLD);
35 for (i = 0; i < nprocs; i++) {
36 MPI_Isend(sendbuf, BUF_COUNT, MPI_CHAR, i, 0, MPI_COMM_WORLD, &sendreqs[i]);
39 /* receive one by one */
40 for (i = 0; i < nprocs; i++) {
41 MPI_Recv(recvbuf, BUF_COUNT, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
45 /* ensure all send request completed */
46 MPI_Waitall(nprocs, sendreqs, sendstats);
49 MPI_Barrier(MPI_COMM_WORLD);
51 printf(" No Errors\n");