1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2015 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 int main(int argc, char *argv[])
18 float *in_buf, *out_buf;
22 MTest_Init(&argc, &argv);
24 comm = MPI_COMM_WORLD;
25 MPI_Comm_rank(comm, &rank);
26 MPI_Comm_size(comm, &nproc);
28 reqs = (MPI_Request *) malloc(2 * nproc * sizeof(MPI_Request));
29 in_buf = (float *) malloc(elems * nproc * sizeof(float));
30 out_buf = (float *) malloc(elems * nproc * sizeof(float));
31 MTEST_VG_MEM_INIT(out_buf, elems * nproc * sizeof(float));
33 for (i = 0; i < nproc; i++) {
34 MPI_Irecv(&in_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i]);
37 for (i = 0; i < nproc; i++) {
38 MPI_Isend(&out_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i + nproc]);
41 MPI_Waitall(nproc * 2, reqs, MPI_STATUSES_IGNORE);
46 MTest_Finalize(errors);