1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2012 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
15 int main(int argc, char **argv)
18 MPI_Info info_in, info_out;
19 int errors = 0, all_errors = 0;
22 char invalid_key[] = "invalid_test_key";
23 char buf[MPI_MAX_INFO_VAL];
26 MPI_Init(&argc, &argv);
28 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
29 MPI_Comm_size(MPI_COMM_WORLD, &nproc);
31 /* Test#1: setting a valid key at window-create time */
33 MPI_Info_create(&info_in);
34 MPI_Info_set(info_in, (char *)"no_locks", (char *)"true");
36 MPI_Win_allocate(sizeof(int), sizeof(int), info_in, MPI_COMM_WORLD, &base, &win);
38 MPI_Win_get_info(win, &info_out);
40 MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
41 if (!flag || strncmp(buf, "true", strlen("true")) != 0) {
43 printf("%d: no_locks is not defined\n", rank);
45 printf("%d: no_locks = %s, expected true\n", rank, buf);
49 MPI_Info_free(&info_in);
50 MPI_Info_free(&info_out);
52 /* We create a new window with no info argument for the next text to ensure that we have the
56 MPI_Win_allocate(sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &base, &win);
58 /* Test#2: setting and getting invalid key */
60 MPI_Info_create(&info_in);
61 MPI_Info_set(info_in, invalid_key, (char *)"true");
63 MPI_Win_set_info(win, info_in);
64 MPI_Win_get_info(win, &info_out);
66 MPI_Info_get(info_out, invalid_key, MPI_MAX_INFO_VAL, buf, &flag);
68 /* Check if our invalid key was ignored. Note, this check's MPICH's
69 * behavior, but this behavior may not be required for a standard
70 * conforming MPI implementation. */
72 printf("%d: %s was not ignored\n", rank, invalid_key);
77 MPI_Info_free(&info_in);
78 MPI_Info_free(&info_out);
80 /* Test#3: setting info key "no_lock" to false and getting the key */
82 MPI_Info_create(&info_in);
83 MPI_Info_set(info_in, (char *)"no_locks", (char *)"false");
85 MPI_Win_set_info(win, info_in);
86 MPI_Win_get_info(win, &info_out);
88 MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
89 if (!flag || strncmp(buf, "false", strlen("false")) != 0) {
91 printf("%d: no_locks is not defined\n", rank);
93 printf("%d: no_locks = %s, expected false\n", rank, buf);
97 printf("%d: no_locks = %s\n", rank, buf);
99 MPI_Info_free(&info_in);
100 MPI_Info_free(&info_out);
102 /* Test#4: setting info key "no_lock" to true and getting the key */
104 MPI_Info_create(&info_in);
105 MPI_Info_set(info_in, (char *)"no_locks", (char *)"true");
107 MPI_Win_set_info(win, info_in);
108 MPI_Win_get_info(win, &info_out);
110 MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
111 if (!flag || strncmp(buf, "true", strlen("true")) != 0) {
113 printf("%d: no_locks is not defined\n", rank);
115 printf("%d: no_locks = %s, expected true\n", rank, buf);
119 printf("%d: no_locks = %s\n", rank, buf);
121 MPI_Info_free(&info_in);
122 MPI_Info_free(&info_out);
124 /* Test#4: getting other info keys */
126 MPI_Win_get_info(win, &info_out);
128 MPI_Info_get(info_out, (char *)"accumulate_ordering", MPI_MAX_INFO_VAL, buf, &flag);
130 printf("%d: accumulate_ordering = %s\n", rank, buf);
132 MPI_Info_get(info_out, (char *)"accumulate_ops", MPI_MAX_INFO_VAL, buf, &flag);
134 printf("%d: accumulate_ops = %s\n", rank, buf);
136 MPI_Info_get(info_out, (char *)"same_size", MPI_MAX_INFO_VAL, buf, &flag);
138 printf("%d: same_size = %s\n", rank, buf);
140 MPI_Info_get(info_out, (char *)"alloc_shm", MPI_MAX_INFO_VAL, buf, &flag);
142 printf("%d: alloc_shm = %s\n", rank, buf);
144 MPI_Info_free(&info_out);
147 MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
149 if (rank == 0 && all_errors == 0)
150 printf(" No Errors\n");