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 );
57 MPI_Info_get_nkeys( infos[0], &nkeys );
58 if (nkeys != info_list) {
59 printf( "infos[0] changed at %d info\n", i );}
64 /* Delete the middle set */
65 for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) {
66 MPI_Info_free( &infos[i] );
69 /* Recreate the middle set */
70 for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) {
71 MPI_Info_create( &infos[i] );
72 DBGPRINTF( ( "Info handle is %x\n", infos[i] ) );
73 for (j=0; j<info_list; j++) {
74 sprintf( key, "key%d-%d", i, j );
75 sprintf( value, "value%d-%d", i, j );
76 DBGPRINTF( ( "Creating key/value %s=%s\n", key, value ));
77 MPI_Info_set( infos[i], key, value );
81 /* Now, check that they are still valid */
82 for (i=0; i<MAX_INFOS; i++) {
84 /*printf( "info = %x\n", infos[i] );
85 print_handle( infos[i] ); printf( "\n" );*/
86 MPI_Info_get_nkeys( infos[i], &nkeys );
87 if (nkeys != info_list) {
89 if (errs < MAX_ERRORS) {
90 printf( "Wrong number of keys for info %d; got %d, should be %d\n",
91 i, nkeys, info_list );
94 for (j=0; j<nkeys; j++) {
98 MPI_Info_get_nthkey( infos[i], j, key );
99 sprintf( keystr, "key%d-%d", i, j );
100 if (strcmp( keystr, key ) != 0) {
102 if (errs < MAX_ERRORS) {
103 printf( "Wrong key for info %d; got %s expected %s\n",
108 MPI_Info_get( infos[i], key, 64, value, &flag );
111 if (errs < MAX_ERRORS) {
112 printf( "Get failed to return value for info %d\n", i );
116 sprintf( valstr, "value%d-%d", i, j );
117 if (strcmp( valstr, value ) != 0) {
119 if (errs < MAX_ERRORS) {
120 printf( "Wrong value for info %d; got %s expected %s\n",
126 for (i=0; i<MAX_INFOS; i++) {
127 MPI_Info_free( &infos[i] );
130 MTest_Finalize( errs );