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 puts, gets, and accumulate on 2 processes using fence */
15 int main(int argc, char *argv[])
17 int rank, nprocs, A[SIZE], B[SIZE], i;
22 MTest_Init(&argc,&argv);
23 MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
24 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
27 printf("Run this program with 2 or more processes\n");
28 MPI_Abort(MPI_COMM_WORLD, 1);
31 MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
35 for (i=0; i<SIZE; i++)
39 for (i=0; i<SIZE; i++) {
45 MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
47 MPI_Win_fence(0, win);
50 for (i=0; i<SIZE-1; i++)
51 MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
54 for (i=0; i<SIZE-1; i++)
55 MPI_Get(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, win);
57 MPI_Accumulate(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, MPI_SUM, win);
59 MPI_Win_fence(0, win);
62 for (i=0; i<SIZE-1; i++) {
64 SQUELCH( printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]); );
70 if (B[SIZE-1] != SIZE - 1 - 3*(SIZE-1)) {
71 SQUELCH( printf("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE-1], SIZE - 1 - 3*(SIZE-1)); );
77 MPI_Comm_free(&CommDeuce);