Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / win_info.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2012 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7
8 #include <stdio.h>
9 #include <mpi.h>
10 #include "mpitest.h"
11
12 #define VERBOSE 0
13
14 int main(int argc, char **argv) {
15     int      i, j, rank, nproc;
16     MPI_Info info_in, info_out;
17     int      errors = 0, all_errors = 0;
18     MPI_Win  win;
19     void    *base;
20     char     invalid_key[] = "invalid_test_key";
21     char     buf[MPI_MAX_INFO_VAL];
22     int      flag;
23
24     MPI_Init(&argc, &argv);
25
26     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27     MPI_Comm_size(MPI_COMM_WORLD, &nproc);
28
29     MPI_Info_create(&info_in);
30     MPI_Info_set(info_in, invalid_key, "true");
31
32     MPI_Win_allocate(sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &base, &win);
33
34     MPI_Win_set_info(win, info_in);
35     MPI_Win_get_info(win, &info_out);
36
37     MPI_Info_get(info_out, invalid_key, MPI_MAX_INFO_VAL, buf, &flag);
38 #ifndef USE_STRICT_MPI
39     /* Check if our invalid key was ignored.  Note, this check's MPICH's
40      * behavior, but this behavior may not be required for a standard
41      * conforming MPI implementation. */
42     if (flag) {
43         printf("%d: %s was not ignored\n", rank, invalid_key);
44         errors++;
45     }
46 #endif
47
48     MPI_Info_get(info_out, "no_locks", MPI_MAX_INFO_VAL, buf, &flag);
49     if (flag && VERBOSE) printf("%d: no_locks = %s\n", rank, buf);
50
51     MPI_Info_get(info_out, "accumulate_ordering", MPI_MAX_INFO_VAL, buf, &flag);
52     if (flag && VERBOSE) printf("%d: accumulate_ordering = %s\n", rank, buf);
53
54     MPI_Info_get(info_out, "accumulate_ops", MPI_MAX_INFO_VAL, buf, &flag);
55     if (flag && VERBOSE) printf("%d: accumulate_ops = %s\n", rank, buf);
56
57     MPI_Info_get(info_out, "same_size", MPI_MAX_INFO_VAL, buf, &flag);
58     if (flag && VERBOSE) printf("%d: same_size = %s\n", rank, buf);
59
60     MPI_Info_get(info_out, "alloc_shm", MPI_MAX_INFO_VAL, buf, &flag);
61     if (flag && VERBOSE) printf("%d: alloc_shm = %s\n", rank, buf);
62
63     MPI_Info_free(&info_in);
64     MPI_Info_free(&info_out);
65     MPI_Win_free(&win);
66
67     MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
68
69     if (rank == 0 && all_errors == 0)
70         printf(" No Errors\n");
71
72     MPI_Finalize();
73
74     return 0;
75 }