1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2017 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 /* This test checks request-based get with MPI_Testall. Both the return value of
13 * MPI_Testall and status.MPI_ERROR should be correctly set.
15 * Thanks for Joseph Schuchart reporting this bug in MPICH and contributing
16 * the prototype of this test program. */
18 int main(int argc, char **argv)
21 MPI_Win win = MPI_WIN_NULL;
23 int errs = 0, mpi_errno = MPI_SUCCESS;
24 int val1 = 0, val2 = 0, flag = 0;
28 MTest_Init(&argc, &argv);
29 MPI_Comm_size(MPI_COMM_WORLD, &size);
30 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
32 MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
34 MPI_Win_allocate(2 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &baseptr, &win);
36 /* Initialize window buffer */
37 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
40 MPI_Win_unlock(rank, win);
42 /* Issue request-based get with testall. */
43 MPI_Win_lock_all(0, win);
44 MPI_Rget(&val1, 1, MPI_INT, 0, 0, 1, MPI_INT, win, &reqs[0]);
45 MPI_Rget(&val2, 1, MPI_INT, 0, 1, 1, MPI_INT, win, &reqs[1]);
48 mpi_errno = MPI_Testall(2, reqs, &flag, stats);
51 /* Check get value. */
52 if (val1 != 1 || val2 != 2) {
53 printf("%d - Got val1 = %d, val2 = %d, expected 1, 2\n", rank, val1, val2);
58 /* Check return error code. */
59 if (mpi_errno != MPI_SUCCESS) {
60 printf("%d - Got return errno %d, expected MPI_SUCCESS(%d)\n",
61 rank, mpi_errno, MPI_SUCCESS);
66 MPI_Win_unlock_all(win);
67 MPI_Barrier(MPI_COMM_WORLD);