Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add MPICH3 rma tests (15 out of 88 should be passing now)
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / get_acc_local.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <mpi.h>
10
11 #include "mpitest.h"
12
13 int       errors  = 0;
14 const int NITER   = 1000;
15 const int acc_val = 3;
16
17 int main(int argc, char **argv)
18 {
19     int         rank, nproc;
20     int         out_val, i, counter = 0;
21     MPI_Win     win;
22
23     MPI_Init(&argc, &argv);
24
25     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26     MPI_Comm_size(MPI_COMM_WORLD, &nproc);
27
28     MPI_Win_create(&counter, sizeof(int), sizeof(int), MPI_INFO_NULL,
29                    MPI_COMM_WORLD, &win);
30
31     for (i = 0; i < NITER; i++) {
32         MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
33         MPI_Get_accumulate(&acc_val, 1, MPI_INT, &out_val, 1, MPI_INT,
34                             rank, 0, 1, MPI_INT, MPI_SUM, win);
35         MPI_Win_unlock(rank, win);
36
37         if (out_val != acc_val*i) {
38             errors++;
39             printf("Error: got %d, expected %d at iter %d\n", out_val, acc_val*i, i);
40             break;
41         }
42     }
43
44     MPI_Win_free(&win);
45
46     if (errors == 0 && rank == 0)
47         printf(" No errors\n");
48
49     MPI_Finalize();
50
51     return 0;
52 }