Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix+activate rma test
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / baseattrwin.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2001 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include <stdio.h>
8 #include "mpi.h"
9 #include "mpitest.h"
10
11 int main(int argc, char **argv)
12 {
13     int errs = 0;
14     void *v;
15     int flag;
16     int rank, size;
17     int base[1024];
18     MPI_Aint n;
19     int disp;
20     MPI_Win win;
21
22     MTest_Init(&argc, &argv);
23     MPI_Comm_size(MPI_COMM_WORLD, &size);
24     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25
26     /* Create a window; then extract the values */
27     n = 1024;
28     disp = 4;
29     MPI_Win_create(base, n, disp, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
30
31     MPI_Win_get_attr(win, MPI_WIN_BASE, &v, &flag);
32     if (!flag) {
33         errs++;
34         fprintf(stderr, "Could not get WIN_BASE\n");
35     }
36     else {
37         /* MPI 2.1, section 11.2.2.  v must be a pointer to the start of the
38          * window.  It is not a pointer to a pointer to the start of the window.
39          */
40         if ((int *) v != base) {
41             errs++;
42             fprintf(stderr, "Got incorrect value for WIN_BASE (%p, should be %p)", v, base);
43         }
44     }
45
46     MPI_Win_get_attr(win, MPI_WIN_SIZE, &v, &flag);
47     if (!flag) {
48         errs++;
49         fprintf(stderr, "Could not get WIN_SIZE\n");
50     }
51     else {
52         MPI_Aint vval = *(MPI_Aint *) v;
53         if (vval != n) {
54             errs++;
55             fprintf(stderr, "Got wrong value for WIN_SIZE (%ld, should be %ld)\n",
56                     (long) vval, (long) n);
57         }
58     }
59
60     MPI_Win_get_attr(win, MPI_WIN_DISP_UNIT, &v, &flag);
61     if (!flag) {
62         errs++;
63         fprintf(stderr, "Could not get WIN_DISP_UNIT\n");
64     }
65     else {
66         int vval = *(int *) v;
67         if (vval != disp) {
68             errs++;
69             fprintf(stderr, "Got wrong value for WIN_DISP_UNIT (%d, should be %d)\n", vval, disp);
70         }
71     }
72
73     MPI_Win_free(&win);
74     MTest_Finalize(errs);
75     MPI_Finalize();
76
77     return 0;
78 }