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.
6 /* Test of info that makes use of the extended handles, including
12 #include "mpitestconf.h"
18 #define MAX_INFOS 4000
25 #define DBGPRINTF(a) printf a; fflush(stdout)
30 int main(int argc, char *argv[])
32 MPI_Info infos[MAX_INFOS];
33 char key[64], value[64];
37 MTest_Init(&argc, &argv);
39 /* We create max_info items, then delete the middle third of them,
40 * then recreate them, then check them, then
41 * delete them all. This checks that the MPICH algorithm for
42 * handling large numbers of items works correctly; other MPI
43 * implementations should also be able to handle this */
46 for (i = 0; i < MAX_INFOS; i++) {
47 MPI_Info_create(&infos[i]);
48 DBGPRINTF(("Info handle is %x\n", infos[i]));
49 for (j = 0; j < info_list; j++) {
50 sprintf(key, "key%d-%d", i, j);
51 sprintf(value, "value%d-%d", i, j);
52 DBGPRINTF(("Creating key/value %s=%s\n", key, value));
53 MPI_Info_set(infos[i], key, value);
58 MPI_Info_get_nkeys(infos[0], &nkeys);
59 if (nkeys != info_list) {
60 printf("infos[0] changed at %d info\n", i);
66 /* Delete the middle set */
67 for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
68 MPI_Info_free(&infos[i]);
71 /* Recreate the middle set */
72 for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
73 MPI_Info_create(&infos[i]);
74 DBGPRINTF(("Info handle is %x\n", infos[i]));
75 for (j = 0; j < info_list; j++) {
76 sprintf(key, "key%d-%d", i, j);
77 sprintf(value, "value%d-%d", i, j);
78 DBGPRINTF(("Creating key/value %s=%s\n", key, value));
79 MPI_Info_set(infos[i], key, value);
83 /* Now, check that they are still valid */
84 for (i = 0; i < MAX_INFOS; i++) {
86 /*printf("info = %x\n", infos[i]);
87 * print_handle(infos[i]); printf("\n"); */
88 MPI_Info_get_nkeys(infos[i], &nkeys);
89 if (nkeys != info_list) {
91 if (errs < MAX_ERRORS) {
92 printf("Wrong number of keys for info %d; got %d, should be %d\n",
96 for (j = 0; j < nkeys; j++) {
100 MPI_Info_get_nthkey(infos[i], j, key);
101 sprintf(keystr, "key%d-%d", i, j);
102 if (strcmp(keystr, key) != 0) {
104 if (errs < MAX_ERRORS) {
105 printf("Wrong key for info %d; got %s expected %s\n", i, key, keystr);
109 MPI_Info_get(infos[i], key, 64, value, &flag);
112 if (errs < MAX_ERRORS) {
113 printf("Get failed to return value for info %d\n", i);
117 sprintf(valstr, "value%d-%d", i, j);
118 if (strcmp(valstr, value) != 0) {
120 if (errs < MAX_ERRORS) {
121 printf("Wrong value for info %d; got %s expected %s\n", i, value, valstr);
126 for (i = 0; i < MAX_INFOS; i++) {
127 MPI_Info_free(&infos[i]);
130 MTest_Finalize(errs);