1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 /* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
18 int main(int argc, char *argv[])
20 int rank, nprocs, A[SIZE2], B[SIZE2], i, j;
25 MTest_Init(&argc, &argv);
26 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
27 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30 printf("Run this program with 2 or more processes\n");
31 MPI_Abort(MPI_COMM_WORLD, 1);
34 MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
38 for (i = 0; i < SIZE2; i++)
40 MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, CommDeuce, &win);
42 for (j = 0; j < 2; j++) {
43 for (i = 0; i < SIZE1; i++) {
44 MPI_Win_lock(MPI_LOCK_SHARED, 1, j == 0 ? 0 : MPI_MODE_NOCHECK, win);
45 MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
46 MPI_Win_unlock(1, win);
49 for (i = 0; i < SIZE1; i++) {
50 MPI_Win_lock(MPI_LOCK_SHARED, 1, j == 0 ? 0 : MPI_MODE_NOCHECK, win);
51 MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
52 MPI_Win_unlock(1, win);
58 for (i = 0; i < SIZE1; i++)
59 if (B[i] != (-4) * (i + SIZE1)) {
61 ("Get Error: B[%d] is %d, should be %d\n", i, B[i],
62 (-4) * (i + SIZE1)););
67 for (i = 0; i < SIZE2; i++)
69 MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
73 for (i = 0; i < SIZE1; i++) {
75 SQUELCH(printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i););
81 MPI_Comm_free(&CommDeuce);