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 /* tests a series of Gets. Run on 2 processes. */
13 /* same as test5.c but uses alloc_mem */
17 int main(int argc, char *argv[])
19 int rank, nprocs, i, *A, *B;
24 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);
37 i = MPI_Alloc_mem(SIZE * sizeof(int), MPI_INFO_NULL, &A);
39 printf("Can't allocate memory in test program\n");
40 MPI_Abort(MPI_COMM_WORLD, 1);
42 i = MPI_Alloc_mem(SIZE * sizeof(int), MPI_INFO_NULL, &B);
44 printf("Can't allocate memory in test program\n");
45 MPI_Abort(MPI_COMM_WORLD, 1);
49 for (i = 0; i < SIZE; i++)
51 MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
52 MPI_Win_fence(0, win);
53 for (i = 0; i < SIZE; i++) {
55 MPI_Get(&A[i], 1, MPI_INT, 1, i, 1, MPI_INT, win);
57 MPI_Win_fence(0, win);
58 for (i = 0; i < SIZE; i++)
59 if (A[i] != 1000 + i) {
60 SQUELCH(printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000 + i););
65 for (i = 0; i < SIZE; i++)
67 MPI_Win_create(A, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
68 MPI_Win_fence(0, win);
69 for (i = 0; i < SIZE; i++) {
71 MPI_Get(&B[i], 1, MPI_INT, 0, i, 1, MPI_INT, win);
73 MPI_Win_fence(0, win);
74 for (i = 0; i < SIZE; i++)
75 if (B[i] != 500 + i) {
76 SQUELCH(printf("Rank 1: B[%d] is %d, should be %d\n", i, B[i], 500 + i););
88 MPI_Comm_free(&CommDeuce);