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.
11 /* This is a modified version of test4.c. Sent by Liwei Peng, Microsoft. */
13 /* tests passive target RMA on 3 processes. tests the lock-single_op-unlock
20 int main(int argc, char *argv[])
22 int rank, nprocs, A[SIZE2], B[SIZE2], i;
28 MTest_Init(&argc, &argv);
29 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
30 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
33 fprintf(stderr, "Run this program with 3 or more processes\n");
34 MPI_Abort(MPI_COMM_WORLD, 1);
37 MPI_Comm_split(MPI_COMM_WORLD, (rank < 3), rank, &CommThree);
41 for (i = 0; i < SIZE2; i++) {
46 for (i = 0; i < SIZE2; i++) {
51 for (i = 0; i < SIZE2; i++) {
56 MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommThree, &win);
59 for (i = 0; i < SIZE1; i++) {
60 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
61 MPI_Put(A + i, 1, MPI_INT, trank, i, 1, MPI_INT, win);
62 /* MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win);
63 * MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win); */
64 MPI_Win_unlock(trank, win);
70 for (i = 0; i < SIZE1; i++) {
71 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
72 MPI_Get(A + i, 1, MPI_INT, trank, SIZE1 + i, 1, MPI_INT, win);
73 MPI_Win_unlock(trank, win);
78 for (i = 0; i < SIZE1; i++)
79 if (A[i] != (-4) * (i + SIZE1)) {
80 printf("Get Error: A[%d] is %d, should be %d\n", i, A[i], (-4) * (i + SIZE1));
85 else if (rank == 1) { /*target */
88 for (i = 0; i < SIZE1; i++) {
90 printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i);
96 MPI_Comm_free(&CommThree);