/* given 'info', incorporate any hints in 'sysinfo' that are not already set * into 'new_info'. Caller must free 'new_info' later. */ void ADIOI_incorporate_system_hints(MPI_Info info, MPI_Info sysinfo, MPI_Info *new_info) { int i, nkeys_sysinfo, flag; char val[MPI_MAX_INFO_VAL], key[MPI_MAX_INFO_KEY]; if (sysinfo == MPI_INFO_NULL) nkeys_sysinfo = 0; else MPI_Info_get_nkeys(sysinfo, &nkeys_sysinfo); /* short-circuit: return immediately if no hints to process */ if (info == MPI_INFO_NULL && nkeys_sysinfo == 0) { *new_info = MPI_INFO_NULL; return; } if (info == MPI_INFO_NULL) MPI_Info_create(new_info); else MPI_Info_dup(info, new_info); for (i=0; i<nkeys_sysinfo; i++) { MPI_Info_get_nthkey(sysinfo, i, key); /* don't care about the value, just want to know if hint set already*/ if (info != MPI_INFO_NULL) ADIOI_Info_get(info, key, 1, val, &flag); if (flag == 1) continue; /* skip any hints already set by user */ ADIOI_Info_get(sysinfo, key, MPI_MAX_INFO_VAL-1, val, &flag); ADIOI_Info_set(*new_info, key, val); flag = 0; } return; }
static void dump_mpi_info( MPI_Info info, const char * prefix = NULL ) { int nkeys; std::stringstream ss; ss << "MPI Info"; if( prefix ) { ss << " for " << prefix; } ss << ":\n"; MPI_Info_get_nkeys(info, &nkeys); for( int i=0; i<nkeys; i++ ) { char key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; int valuelen, flag; MPI_Info_get_nthkey(info, i, key); MPI_Info_get_valuelen(info, key, &valuelen, &flag); CHECK( flag ) << "somehow key not defined?"; MPI_Info_get(info, key, valuelen+1, value, &flag); CHECK( flag ) << "somehow key not defined?"; ss << " key " << i << ": " << key << " => " << value; } LOG(INFO) << ss.str(); }
/* debug function: a routine I want in the library to make my life easier when * using a source debugger. please ignore any "defined but not used" warnings */ static void dump_keys(MPI_Info info) { int i, nkeys, flag; char key[MPI_MAX_INFO_KEY]; char value[MPI_MAX_INFO_VAL]; MPI_Info_get_nkeys(info, &nkeys); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info, i, key); MPI_Info_get(info, key, MPI_MAX_INFO_VAL-1, value, &flag); printf("key = %s, value = %s\n", key, value); } return; }
/*----< print_info() >------------------------------------------------------*/ static void print_info(MPI_Info *info_used) { int i, nkeys; MPI_Info_get_nkeys(*info_used, &nkeys); printf("MPI File Info: nkeys = %d\n",nkeys); for (i=0; i<nkeys; i++) { char key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; int valuelen, flag; MPI_Info_get_nthkey(*info_used, i, key); MPI_Info_get_valuelen(*info_used, key, &valuelen, &flag); MPI_Info_get(*info_used, key, valuelen+1, value, &flag); printf("MPI File Info: [%2d] key = %25s, value = %s\n",i,key,value); } }
void IMB_print_info() /* Prints MPI_Info selections (MPI-2 only) */ { int nkeys,ikey,vlen,exists; MPI_Info tmp_info; char key[MPI_MAX_INFO_KEY], *value; IMB_user_set_info(&tmp_info); /* July 2002 fix V2.2.1: handle NULL case */ if( tmp_info!=MPI_INFO_NULL ) { /* end change */ MPI_Info_get_nkeys(tmp_info, &nkeys); if( nkeys > 0) fprintf(unit,"# Got %d Info-keys:\n\n",nkeys); for( ikey=0; ikey<nkeys; ikey++ ) { MPI_Info_get_nthkey(tmp_info, ikey, key); MPI_Info_get_valuelen(tmp_info, key, &vlen, &exists); value = (char*)IMB_v_alloc((vlen+1)* sizeof(char), "Print_Info"); MPI_Info_get(tmp_info, key, vlen, value, &exists); printf("# %s = \"%s\"\n",key,value); IMB_v_free ((void**)&value); } MPI_Info_free(&tmp_info); /* July 2002 fix V2.2.1: end if */ } /* end change */ }
/* * Show all hints (key/value pairs) in an MPI_Info object. */ void ShowHints(MPI_Info * mpiHints) { char key[MPI_MAX_INFO_VAL]; char value[MPI_MAX_INFO_VAL]; int flag, i, nkeys; MPI_CHECK(MPI_Info_get_nkeys(*mpiHints, &nkeys), "cannot get info object keys"); for (i = 0; i < nkeys; i++) { MPI_CHECK(MPI_Info_get_nthkey(*mpiHints, i, key), "cannot get info object key"); MPI_CHECK(MPI_Info_get(*mpiHints, key, MPI_MAX_INFO_VAL - 1, value, &flag), "cannot get info object value"); fprintf(stdout, "\t%s = %s\n", key, value); } }
void ADIOI_GRIDFTP_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code) { if (!(fd->info)) { if ( users_info==MPI_INFO_NULL ) { /* This must be part of the open call. */ MPI_Info_create(&(fd->info)); } else { MPI_Info_dup(users_info,&(fd->info)); } } else { int i,nkeys,valuelen,flag; char key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; if ( users_info!=MPI_INFO_NULL ) { MPI_Info_get_nkeys(users_info,&nkeys); for (i=0;i<nkeys;i++) { MPI_Info_get_nthkey(users_info,i,key); MPI_Info_get_valuelen(users_info,key,&valuelen,&flag); if (flag) { ADIOI_Info_get(users_info,key,valuelen,value,&flag); if (flag) ADIOI_Info_set(fd->info,key,value); } } } } /* let the generic ROMIO and MPI-I/O stuff happen... */ ADIOI_GEN_SetInfo(fd, users_info, error_code); }
/** * Get the hint information from the MPI_Info variable stored in the * test_params and print it out. * * @param test_params_p Pointer to test_params. * @return 0 on success. */ static int print_hints(struct test_params_s *test_params_p) { int i, hint_key_len, hint_val_len, hint_nkeys, flag; char hint_key[MPI_MAX_INFO_KEY], *hint_val; MPI_Info_get_nkeys(*(test_params_p->info_p), &hint_nkeys); for (i = 0; i < hint_nkeys; i++) { MPI_Info_get_nthkey(*(test_params_p->info_p), i, hint_key); hint_key_len = strlen(hint_key); MPI_Info_get_valuelen(*(test_params_p->info_p), hint_key, &hint_val_len, &flag); assert(flag); hint_val = malloc((hint_val_len + 1)*sizeof(char)); if (!hint_val) { fprintf(stderr, "hint_val malloc of size %d failed.\n", hint_val_len); return -1; } MPI_Info_get(*(test_params_p->info_p), hint_key, hint_val_len + 1, hint_val, &flag); assert(flag); fprintf( stdout, "hint %d \"%30s\" = %s\n", i, hint_key, hint_val); free(hint_val); } if (!hint_nkeys) fprintf( stdout, "hints = N/A\n"); return 0; }
static void print_hints( int rank, MPI_File *mfh ) { MPI_Info info; int nkeys; int i, dummy_int; char key[1024]; char value[1024]; MPI_Barrier( MPI_COMM_WORLD ); if ( rank == 0 ) { MPI_File_get_info( *mfh, &info ); MPI_Info_get_nkeys( info, &nkeys ); printf( "HINTS:\n" ); for( i = 0; i < nkeys; i++ ) { MPI_Info_get_nthkey( info, i, key ); printf( "%35s -> ", key ); MPI_Info_get( info, key, 1024, value, &dummy_int ); printf( "%s\n", value ); } MPI_Info_free(&info); } MPI_Barrier( MPI_COMM_WORLD ); }
/* * Function: h5_dump_info_object * Purpose: Display content of an MPI Info object * Return: void * Programmer: Albert Cheng 2002/05/21 * Modifications: */ void h5_dump_info_object(MPI_Info info) { char key[MPI_MAX_INFO_KEY+1]; char value[MPI_MAX_INFO_VAL+1]; int flag; int i, nkeys; printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info, MPI_MAX_INFO_VAL); if (info==MPI_INFO_NULL){ printf("object is MPI_INFO_NULL\n"); } else { MPI_Info_get_nkeys(info, &nkeys); printf("object has %d items\n", nkeys); for (i=0; i<nkeys; i++){ MPI_Info_get_nthkey(info, i, key); MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag); printf("%s=%s\n", key, value); } } }
/*------------------------------------------------------------------------- * Function: test_fapl_mpio_dup * * Purpose: Test if fapl_mpio property list keeps a duplicate of the * communicator and INFO objects given when set; and returns * duplicates of its components when H5Pget_fapl_mpio is called. * * Return: Success: None * * Failure: Abort * * Programmer: Albert Cheng * January 9, 2003 * * Modifications: *------------------------------------------------------------------------- */ void test_fapl_mpio_dup(void) { int mpi_size, mpi_rank; MPI_Comm comm, comm_tmp; int mpi_size_old, mpi_rank_old; int mpi_size_tmp, mpi_rank_tmp; MPI_Info info = MPI_INFO_NULL; MPI_Info info_tmp = MPI_INFO_NULL; int mrc; /* MPI return value */ hid_t acc_pl; /* File access properties */ herr_t ret; /* hdf5 return value */ int nkeys, nkeys_tmp; if (VERBOSE_MED) printf("Verify fapl_mpio duplicates communicator and INFO objects\n"); /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); if (VERBOSE_MED) printf("rank/size of MPI_COMM_WORLD are %d/%d\n", mpi_rank, mpi_size); /* Create a new communicator that has the same processes as MPI_COMM_WORLD. * Use MPI_Comm_split because it is simplier than MPI_Comm_create */ mrc = MPI_Comm_split(MPI_COMM_WORLD, 0, 0, &comm); VRFY((mrc==MPI_SUCCESS), "MPI_Comm_split"); MPI_Comm_size(comm,&mpi_size_old); MPI_Comm_rank(comm,&mpi_rank_old); if (VERBOSE_MED) printf("rank/size of comm are %d/%d\n", mpi_rank_old, mpi_size_old); /* create a new INFO object with some trivial information. */ mrc = MPI_Info_create(&info); VRFY((mrc==MPI_SUCCESS), "MPI_Info_create"); mrc = MPI_Info_set(info, "hdf_info_name", "XYZ"); VRFY((mrc==MPI_SUCCESS), "MPI_Info_set"); if (MPI_INFO_NULL != info){ mrc=MPI_Info_get_nkeys(info, &nkeys); VRFY((mrc==MPI_SUCCESS), "MPI_Info_get_nkeys"); } if (VERBOSE_MED) h5_dump_info_object(info); acc_pl = H5Pcreate (H5P_FILE_ACCESS); VRFY((acc_pl >= 0), "H5P_FILE_ACCESS"); ret = H5Pset_fapl_mpio(acc_pl, comm, info); VRFY((ret >= 0), ""); /* Case 1: * Free the created communicator and INFO object. * Check if the access property list is still valid and can return * valid communicator and INFO object. */ mrc = MPI_Comm_free(&comm); VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); if (MPI_INFO_NULL!=info){ mrc = MPI_Info_free(&info); VRFY((mrc==MPI_SUCCESS), "MPI_Info_free"); } ret = H5Pget_fapl_mpio(acc_pl, &comm_tmp, &info_tmp); VRFY((ret >= 0), "H5Pget_fapl_mpio"); MPI_Comm_size(comm_tmp,&mpi_size_tmp); MPI_Comm_rank(comm_tmp,&mpi_rank_tmp); if (VERBOSE_MED) printf("After H5Pget_fapl_mpio: rank/size of comm are %d/%d\n", mpi_rank_tmp, mpi_size_tmp); VRFY((mpi_size_tmp==mpi_size), "MPI_Comm_size"); VRFY((mpi_rank_tmp==mpi_rank), "MPI_Comm_rank"); if (MPI_INFO_NULL != info_tmp){ mrc=MPI_Info_get_nkeys(info_tmp, &nkeys_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_get_nkeys"); VRFY((nkeys_tmp==nkeys), "new and old nkeys equal"); } if (VERBOSE_MED) h5_dump_info_object(info_tmp); /* Case 2: * Free the retrieved communicator and INFO object. * Check if the access property list is still valid and can return * valid communicator and INFO object. * Also verify the NULL argument option. */ mrc = MPI_Comm_free(&comm_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); if (MPI_INFO_NULL!=info_tmp){ mrc = MPI_Info_free(&info_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_free"); } /* check NULL argument options. */ ret = H5Pget_fapl_mpio(acc_pl, &comm_tmp, NULL); VRFY((ret >= 0), "H5Pget_fapl_mpio Comm only"); mrc = MPI_Comm_free(&comm_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); ret = H5Pget_fapl_mpio(acc_pl, NULL, &info_tmp); VRFY((ret >= 0), "H5Pget_fapl_mpio Info only"); if (MPI_INFO_NULL!=info_tmp){ mrc = MPI_Info_free(&info_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_free"); } ret = H5Pget_fapl_mpio(acc_pl, NULL, NULL); VRFY((ret >= 0), "H5Pget_fapl_mpio neither"); /* now get both and check validity too. */ /* Donot free the returned objects which are used in the next case. */ ret = H5Pget_fapl_mpio(acc_pl, &comm_tmp, &info_tmp); VRFY((ret >= 0), "H5Pget_fapl_mpio"); MPI_Comm_size(comm_tmp,&mpi_size_tmp); MPI_Comm_rank(comm_tmp,&mpi_rank_tmp); if (VERBOSE_MED) printf("After second H5Pget_fapl_mpio: rank/size of comm are %d/%d\n", mpi_rank_tmp, mpi_size_tmp); VRFY((mpi_size_tmp==mpi_size), "MPI_Comm_size"); VRFY((mpi_rank_tmp==mpi_rank), "MPI_Comm_rank"); if (MPI_INFO_NULL != info_tmp){ mrc=MPI_Info_get_nkeys(info_tmp, &nkeys_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_get_nkeys"); VRFY((nkeys_tmp==nkeys), "new and old nkeys equal"); } if (VERBOSE_MED) h5_dump_info_object(info_tmp); /* Case 3: * Close the property list and verify the retrieved communicator and INFO * object are still valid. */ H5Pclose(acc_pl); MPI_Comm_size(comm_tmp,&mpi_size_tmp); MPI_Comm_rank(comm_tmp,&mpi_rank_tmp); if (VERBOSE_MED) printf("After Property list closed: rank/size of comm are %d/%d\n", mpi_rank_tmp, mpi_size_tmp); if (MPI_INFO_NULL != info_tmp){ mrc=MPI_Info_get_nkeys(info_tmp, &nkeys_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_get_nkeys"); } if (VERBOSE_MED) h5_dump_info_object(info_tmp); /* clean up */ mrc = MPI_Comm_free(&comm_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free"); if (MPI_INFO_NULL!=info_tmp){ mrc = MPI_Info_free(&info_tmp); VRFY((mrc==MPI_SUCCESS), "MPI_Info_free"); } }
int main( int argc, char *argv[] ) { MPI_Info infos[MAX_INFOS]; char key[64], value[64]; int errs = 0; int i, j; MTest_Init( &argc, &argv ); /* We create max_info items, then delete the middle third of them, then recreate them, then check them, then delete them all. This checks that the MPICH algorithm for handling large numbers of items works correctly; other MPI implementations should also be able to handle this */ /* Create them all */ for (i=0; i<MAX_INFOS; i++) { MPI_Info_create( &infos[i] ); DBGPRINTF( ( "Info handle is %x\n", infos[i] ) ); for (j=0; j<info_list; j++) { sprintf( key, "key%d-%d", i, j ); sprintf( value, "value%d-%d", i, j ); DBGPRINTF( ( "Creating key/value %s=%s\n", key, value )); MPI_Info_set( infos[i], key, value ); } #ifdef DBG { int nkeys; MPI_Info_get_nkeys( infos[0], &nkeys ); if (nkeys != info_list) { printf( "infos[0] changed at %d info\n", i );} } #endif } /* Delete the middle set */ for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) { MPI_Info_free( &infos[i] ); } /* Recreate the middle set */ for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) { MPI_Info_create( &infos[i] ); DBGPRINTF( ( "Info handle is %x\n", infos[i] ) ); for (j=0; j<info_list; j++) { sprintf( key, "key%d-%d", i, j ); sprintf( value, "value%d-%d", i, j ); DBGPRINTF( ( "Creating key/value %s=%s\n", key, value )); MPI_Info_set( infos[i], key, value ); } } /* Now, check that they are still valid */ for (i=0; i<MAX_INFOS; i++) { int nkeys; /*printf( "info = %x\n", infos[i] ); print_handle( infos[i] ); printf( "\n" );*/ MPI_Info_get_nkeys( infos[i], &nkeys ); if (nkeys != info_list) { errs++; if (errs < MAX_ERRORS) { printf( "Wrong number of keys for info %d; got %d, should be %d\n", i, nkeys, info_list ); } } for (j=0; j<nkeys; j++) { char keystr[64]; char valstr[64]; int flag; MPI_Info_get_nthkey( infos[i], j, key ); sprintf( keystr, "key%d-%d", i, j ); if (strcmp( keystr, key ) != 0) { errs++; if (errs < MAX_ERRORS) { printf( "Wrong key for info %d; got %s expected %s\n", i, key, keystr ); } continue; } MPI_Info_get( infos[i], key, 64, value, &flag ); if (!flag) { errs++; if (errs < MAX_ERRORS) { printf( "Get failed to return value for info %d\n", i ); } continue; } sprintf( valstr, "value%d-%d", i, j ); if (strcmp( valstr, value ) != 0) { errs++; if (errs < MAX_ERRORS) { printf( "Wrong value for info %d; got %s expected %s\n", i, value, valstr ); } } } } for (i=0; i<MAX_INFOS; i++) { MPI_Info_free( &infos[i] ); } MTest_Finalize( errs ); MPI_Finalize( ); return 0; }
void SID_init(int *argc, char **argv[], SID_args args[], void *mpi_comm_as_void){ int status; int i_level; int i_char; int flag_continue; int flag_passed_comm; // MPI-specific things #if USE_MPI int n_keys; int i_key; char key[256]; char key_value[256]; int key_exists; char nodes_string[256]; SID_fp fp_tmp; FILE *fp_hack; int node_name_length; MPI_Comm mpi_comm; #if USE_MPI_IO MPI_Info info_disp; #endif if (mpi_comm_as_void == NULL) { flag_passed_comm = 0; MPI_Init(argc,argv); MPI_Comm_dup(MPI_COMM_WORLD, &mpi_comm); } else { mpi_comm = *((MPI_Comm *) mpi_comm_as_void); flag_passed_comm = 1; } MPI_Comm_size(mpi_comm, &(SID.n_proc)); MPI_Comm_rank(mpi_comm, &(SID.My_rank)); SID.My_node =(char *)SID_malloc(SID_MAXLENGTH_PROCESSOR_NAME * sizeof(char)); #if USE_MPI MPI_Get_processor_name(SID.My_node, &node_name_length); #else sprintf(SID.My_node,"localhost"); node_name_length=strlen(SID.My_node); #endif if (node_name_length >= SID_MAXLENGTH_PROCESSOR_NAME-1) SID_trap_error("SID_MAXLENGTH_PROCESSOR_NAME needs to be increased",ERROR_LOGIC); // Make my_rank=MASTER_RANK the master if(SID.My_rank==MASTER_RANK) SID.I_am_Master=TRUE; else SID.I_am_Master=FALSE; // Identify the last rank if(SID.My_rank==SID.n_proc-1) SID.I_am_last_rank=TRUE; else SID.I_am_last_rank=FALSE; #if USE_MPI_IO // Fetch collective buffering defaults MPI_Info_create(&(SID.file_info)); if(SID.I_am_Master){ fp_hack=fopen(".tmp.SID","w+"); fclose(fp_hack); } MPI_Barrier(mpi_comm); MPI_File_open(mpi_comm, ".tmp.SID", MPI_MODE_WRONLY, MPI_INFO_NULL, &(fp_tmp.fp)); MPI_File_get_info(fp_tmp.fp,&info_disp); MPI_Info_get_nkeys(info_disp,&n_keys); for(i_key=0;i_key<n_keys;i_key++){ MPI_Info_get_nthkey(info_disp,i_key,key); MPI_Info_get(info_disp,key,MPI_MAX_INFO_VAL,key_value,&key_exists); if(key_exists) MPI_Info_set((SID.file_info),key,key_value); } MPI_File_close(&(fp_tmp.fp)); if(SID.I_am_Master) remove(".tmp.SID"); // Set user-defined colective buffering optimizations sprintf(nodes_string,"%d",MIN(SID.n_proc,N_IO_FILES_MAX)); MPI_Info_set((SID.file_info),"cb_nodes", nodes_string); MPI_Info_set((SID.file_info),"cb_config_list", "*:1"); #endif #else SID.My_rank=MASTER_RANK; SID.n_proc =1; #endif /* #if !USE_MPI_IO SID.n_groups=SID.n_proc/N_IO_FILES_MAX; if(SID.n_proc%N_IO_FILES_MAX) SID.n_groups++; SID.My_group=SID.My_rank/N_IO_FILES_MAX; #endif */ // Set ranks to the left and right SID.rank_to_right =(SID.My_rank+1)%SID.n_proc; SID.rank_to_left = SID.My_rank-1; if(SID.rank_to_left<0) SID.rank_to_left = SID.n_proc-1; // Intitialize log timing information SID.time_start_level=(time_t *)SID_malloc(sizeof(time_t)*SID_LOG_MAX_LEVELS); SID.time_stop_level =(time_t *)SID_malloc(sizeof(time_t)*SID_LOG_MAX_LEVELS); SID.time_total_level=(int *)SID_malloc(sizeof(int) *SID_LOG_MAX_LEVELS); SID.IO_size =(double *)SID_malloc(sizeof(double)*SID_LOG_MAX_LEVELS); SID.flag_use_timer =(int *)SID_malloc(sizeof(int) *SID_LOG_MAX_LEVELS); for(i_level=0;i_level<SID_LOG_MAX_LEVELS;i_level++){ SID.time_start_level[i_level]=0; SID.time_stop_level[i_level] =0; SID.time_total_level[i_level]=0; SID.IO_size[i_level] =0.; SID.flag_use_timer[i_level] =FALSE; } // Initialize other log information #if USE_MPI if(*argc>1) SID.fp_in =fopen((*argv)[1],"r"); else SID.fp_in =NULL; #else SID.fp_in =stdin; #endif if (flag_passed_comm) SID.fp_log = NULL; else SID.fp_log = stderr; SID.level =0; SID.indent =TRUE; SID.awake =TRUE; SID.flag_results_on=FALSE; SID.verbosity =SID_LOG_MAX_LEVELS; // Store the name of the binary executable that brought us here strcpy(SID.My_binary,(*argv)[0]); strip_path(SID.My_binary); // Initialize argument information if(args!=NULL){ if((status=SID_parse_args(*argc,*argv,args))>0){ SID_print_syntax(*argc,*argv,args); SID_exit(status); } } else SID.args=NULL; #if USE_MPI_IO if(SID.I_am_Master){ fp_hack=fopen(".tmp.SID","w+"); fclose(fp_hack); } MPI_Barrier(mpi_comm); SID_fopen(".tmp.SID","w",&fp_tmp); MPI_File_get_info(fp_tmp.fp,&info_disp); if(SID.I_am_Master){ fprintf(stdout,"\n"); fprintf(stdout,"MPI-I/O Configuration:\n"); fprintf(stdout,"---------------------\n"); MPI_Info_get_nkeys(info_disp,&n_keys); for(i_key=0;i_key<n_keys;i_key++){ MPI_Info_get_nthkey(info_disp,i_key,key); MPI_Info_get(info_disp,key,MPI_MAX_INFO_VAL,key_value,&key_exists); if(key_exists) fprintf(stdout,"key %2d of %d: {%s}={%s}\n",i_key+1,n_keys,key,key_value); } fprintf(stdout,"\n"); } SID_fclose(&fp_tmp); if(SID.I_am_Master) remove(".tmp.SID"); #else #if USE_MPI if(SID.I_am_Master) fprintf(stdout,"MPI-I/O switched off.\n\n"); #endif #endif // Create private COMM_WORLD SID_Comm_init(&(SID.COMM_WORLD)); #if USE_MPI MPI_Comm_dup(mpi_comm, &((SID.COMM_WORLD)->comm)); MPI_Comm_group((SID.COMM_WORLD)->comm,&((SID.COMM_WORLD)->group)); MPI_Comm_size(SID.COMM_WORLD->comm, &((SID.COMM_WORLD)->n_proc)); MPI_Comm_rank(SID.COMM_WORLD->comm, &((SID.COMM_WORLD)->My_rank)); // We have duplicated our duplicate mpi communicator - now we can free the // original duplicate MPI_Comm_free(&mpi_comm); #else SID.COMM_WORLD->comm =NULL; SID.COMM_WORLD->group =NULL; SID.COMM_WORLD->n_proc =1; SID.COMM_WORLD->My_rank=MASTER_RANK; #endif // Start total-run-ime timer (void)time(&(SID.time_start)); // Default max wallclock SID.max_wallclock=DEFAULT_MAX_WALLCLOCK_TIME; }
int main(int argc, char **argv) { int i, len, nkeys, flag, mynod, default_striping_factor, nprocs; MPI_File fh; MPI_Info info, info_used; char *filename, key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &mynod); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* process 0 takes the file name as a command-line argument and broadcasts it to other processes */ if (!mynod) { i = 1; while ((i < argc) && strcmp("-fname", *argv)) { i++; argv++; } if (i >= argc) { printf("\n*# Usage: file_info -fname filename\n\n"); MPI_Abort(MPI_COMM_WORLD, 1); } argv++; len = strlen(*argv); filename = (char *) malloc(len+1); strcpy(filename, *argv); MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD); } else { MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); filename = (char *) malloc(len+1); MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD); } /* open the file with MPI_INFO_NULL */ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); /* check the default values set by ROMIO */ MPI_File_get_info(fh, &info_used); MPI_Info_get_nkeys(info_used, &nkeys); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info_used, i, key); MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL-1, value, &flag); if (!mynod) printf("Process %d, Default: key = %s, value = %s\n", mynod, key, value); if (!strcmp("striping_factor", key)) default_striping_factor = atoi(value); } MPI_File_close(&fh); /* delete the file */ if (!mynod) MPI_File_delete(filename, MPI_INFO_NULL); MPI_Barrier(MPI_COMM_WORLD); /* set new info values. */ MPI_Info_create(&info); /* The following four hints are accepted on all machines. They can be specified at file-open time or later (any number of times). */ /* buffer size for collective I/O */ MPI_Info_set(info, "cb_buffer_size", "8388608"); /* number of processes that actually perform I/O in collective I/O */ sprintf(value, "%d", nprocs/2); MPI_Info_set(info, "cb_nodes", value); /* buffer size for data sieving in independent reads */ MPI_Info_set(info, "ind_rd_buffer_size", "2097152"); /* buffer size for data sieving in independent writes */ MPI_Info_set(info, "ind_wr_buffer_size", "1048576"); /* The following three hints related to file striping are accepted only on Intel PFS and IBM PIOFS file systems and are ignored elsewhere. They can be specified only at file-creation time; if specified later they will be ignored. */ /* number of I/O devices across which the file will be striped. accepted only if 0 < value < default_striping_factor; ignored otherwise */ sprintf(value, "%d", default_striping_factor-1); MPI_Info_set(info, "striping_factor", value); /* the striping unit in bytes */ MPI_Info_set(info, "striping_unit", "131072"); /* the I/O device number from which to start striping the file. accepted only if 0 <= value < default_striping_factor; ignored otherwise */ sprintf(value, "%d", default_striping_factor-2); MPI_Info_set(info, "start_iodevice", value); /* The following hint about PFS server buffering is accepted only on Intel PFS. It can be specified anytime. */ MPI_Info_set(info, "pfs_svr_buf", "true"); /* open the file and set new info */ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); /* check the values set */ MPI_File_get_info(fh, &info_used); MPI_Info_get_nkeys(info_used, &nkeys); if (!mynod) printf("\n New values\n\n"); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info_used, i, key); MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL-1, value, &flag); if (!mynod) printf("Process %d, key = %s, value = %s\n", mynod, key, value); } MPI_File_close(&fh); free(filename); MPI_Info_free(&info_used); MPI_Info_free(&info); MPI_Finalize(); return 0; }
void phdf5writeAll(char *filename) { hid_t fid1; /* HDF5 file IDs */ hid_t acc_tpl1; /* File access templates */ hid_t xfer_plist; /* Dataset transfer properties list */ hid_t sid1; /* Dataspace ID */ hid_t file_dataspace; /* File dataspace ID */ hid_t mem_dataspace; /* memory dataspace ID */ hid_t dataset1, dataset2; /* Dataset ID */ hsize_t dims1[SPACE1_RANK] = {SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */ DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ herr_t ret; /* Generic return value */ MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; /* in support of H5Tuner Test */ MPI_Comm comm_test = MPI_COMM_WORLD; MPI_Info info_test ; int i_test, nkeys_test, flag_test; char key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL+1]; char *libtuner_file = getenv("LD_PRELOAD"); /* in support of H5Tuner Test */ if (verbose) printf("Collective write test on file %s\n", filename); /* ------------------- * START AN HDF5 FILE * -------------------*/ /* setup file access template with parallel IO access. */ acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS); assert(acc_tpl1 != FAIL); MESG("H5Pcreate access succeed"); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info); assert(ret != FAIL); MESG("H5Pset_fapl_mpio succeed"); /* create the file collectively */ fid1=H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl1); assert(fid1 != FAIL); MESG("H5Fcreate succeed"); // ------------------------------------------------ // H5Tuner tests // ------------------------------------------------ // Retrieve MPI parameters set via the H5Tuner printf("\n\n--------------------------------------------------\n"); if ( (libtuner_file != NULL) && (strlen(libtuner_file) > 1) ){ printf("Version of the H5Tuner loaded: \n%s\n", libtuner_file); } else { printf("No H5Tuner currently loaded.\n"); } printf("--------------------------------------------------\n"); // Retrieve HDF5 Threshold and Alignment hsize_t alignment[2]; size_t sieve_buf_size; alignment[0]= 0; // threshold value alignment[1]= 0; // alignment value int ierr = H5Pget_alignment(acc_tpl1, &alignment[0], &alignment[1]); printf("\n\n--------------------------------------------------\n"); printf("Testing values for Threshold and Alignment\n"); printf("--------------------------------------------------\n"); printf("Test value set to:88 \nRetrieved Threshold=%lu\n", alignment[0]); printf("Test value set to:44 \nRetrieved Alignment=%lu\n", alignment[1]); // Check Threshold if ( alignment[0] == 88 ) { printf("PASSED: Threshold Test\n"); } else { printf("FAILED: Threshold Test\n"); } // Check Alignment if ( alignment[1] == 44 ) { printf("PASSED: Alignment Test\n"); } else { printf("FAILED: Alignment Test\n"); } printf("--------------------------------------------------\n\n"); // Retrieve HDF5 sieve buffer size ierr = H5Pget_sieve_buf_size(acc_tpl1, &sieve_buf_size); printf("\n\n--------------------------------------------------\n"); printf("Testing values for Sieve Buffer Size\n"); printf("--------------------------------------------------\n"); printf("Test value set to:77 \nRetrieved Sieve Buffer Size=%lu\n", sieve_buf_size); // Check sieve buffer size if ( (int) sieve_buf_size == 77 ) { printf("PASSED: Sieve Buffer Size Test\n"); } else { printf("FAILED: Sieve Buffer Size Test\n"); } printf("--------------------------------------------------\n\n"); // Retrieve MPI parameters set via the H5Tuner MPI_Info_create(&info_test); ret = H5Pget_fapl_mpio(acc_tpl1, &comm_test, &info_test); assert(ret != FAIL); MESG("H5Pget_fapl_mpio succeed"); printf("-------------------------------------------------\n" ); printf("Testing parameters values via MPI_Info\n" ); printf("-------------------------------------------------\n" ); if(info_test == MPI_INFO_NULL) { printf("MPI info object is null. No keys are available.\n"); } else { MPI_Info_get_nkeys(info_test, &nkeys_test); //printf("MPI info has %d keys\n", nkeys_test); if (nkeys_test <= 0) { printf("MPI info has no keys\n"); } else { printf("MPI info has %d keys\n", nkeys_test); for ( i_test=0; i_test < nkeys_test; i_test++) { MPI_Info_get_nthkey( info_test, i_test, key ); MPI_Info_get( info_test, key, MPI_MAX_INFO_VAL, value, &flag_test ); printf( "Retrieved value for key %s is %s\n", key, value ); //fflush(stdout); } } printf("-------------------------------------------------\n" ); MPI_Info_free(&info_test); } // end of H5Tuner tests // --------------------------------------- /* Release file-access template */ ret=H5Pclose(acc_tpl1); assert(ret != FAIL); /* -------------------------- * Define the dimensions of the overall datasets * and create the dataset * ------------------------- */ /* setup dimensionality object */ sid1 = H5Screate_simple (SPACE1_RANK, dims1, NULL); assert (sid1 != FAIL); MESG("H5Screate_simple succeed"); /* create a dataset collectively */ dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dataset1 != FAIL); MESG("H5Dcreate2 succeed"); /* create another dataset collectively */ dataset2 = H5Dcreate2(fid1, DATASETNAME2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dataset2 != FAIL); MESG("H5Dcreate2 2 succeed"); /* * Set up dimensions of the slab this process accesses. */ /* Dataset1: each process takes a block of rows. */ slab_set(start, count, stride, BYROW); if (verbose) printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], (unsigned long)(count[0]*count[1])); /* create a file dataspace independently */ file_dataspace = H5Dget_space (dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); assert (mem_dataspace != FAIL); /* fill the local slab with some trivial data */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); if (verbose){ MESG("data_array created"); dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate (H5P_DATASET_XFER); assert(xfer_plist != FAIL); ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* write data collectively */ ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); /* release all temporary handles. */ /* Could have used them for dataset2 but it is cleaner */ /* to create them again.*/ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); /* Dataset2: each process takes a block of columns. */ slab_set(start, count, stride, BYCOL); if (verbose) printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], (unsigned long)(count[0]*count[1])); /* put some trivial data in the data_array */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); if (verbose){ MESG("data_array created"); dataset_print(start, count, stride, &data_array1[0][0]); } /* create a file dataspace independently */ file_dataspace = H5Dget_space (dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); assert (mem_dataspace != FAIL); /* fill the local slab with some trivial data */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); if (verbose){ MESG("data_array created"); dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate (H5P_DATASET_XFER); assert(xfer_plist != FAIL); ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* write data independently */ ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); /* * All writes completed. Close datasets collectively */ ret=H5Dclose(dataset1); assert(ret != FAIL); MESG("H5Dclose1 succeed"); ret=H5Dclose(dataset2); assert(ret != FAIL); MESG("H5Dclose2 succeed"); /* release all IDs created */ H5Sclose(sid1); /* close the file collectively */ H5Fclose(fid1); }
int main(int argc, char *argv[]) { MPI_Info infos[MAX_INFOS]; char key[64], value[64]; int errs = 0; int i, j; MTest_Init(&argc, &argv); for (i = 0; i < MAX_INFOS; i++) { MPI_Info_create(&infos[i]); #ifdef DBG printf("Info handle is %x\n", infos[i]); #endif for (j = 0; j < info_list; j++) { sprintf(key, "key%d-%d", i, j); sprintf(value, "value%d-%d", i, j); #ifdef DBG printf("Creating key/value %s=%s\n", key, value); #endif MPI_Info_set(infos[i], key, value); } #ifdef DBG { int nkeys; MPI_Info_get_nkeys(infos[0], &nkeys); if (nkeys != info_list) { printf("infos[0] changed at %d info\n", i); } } #endif } for (i = 0; i < MAX_INFOS; i++) { int nkeys; /*printf("info = %x\n", infos[i]); * print_handle(infos[i]); printf("\n"); */ MPI_Info_get_nkeys(infos[i], &nkeys); if (nkeys != info_list) { errs++; if (errs < MAX_ERRORS) { printf("Wrong number of keys for info %d; got %d, should be %d\n", i, nkeys, info_list); } } for (j = 0; j < nkeys; j++) { char keystr[64]; char valstr[64]; int flag; MPI_Info_get_nthkey(infos[i], j, key); sprintf(keystr, "key%d-%d", i, j); if (strcmp(keystr, key) != 0) { errs++; if (errs < MAX_ERRORS) { printf("Wrong key for info %d; got %s expected %s\n", i, key, keystr); } continue; } MPI_Info_get(infos[i], key, sizeof(value), value, &flag); if (!flag) { errs++; if (errs < MAX_ERRORS) { printf("Get failed to return value for info %d\n", i); } continue; } sprintf(valstr, "value%d-%d", i, j); if (strcmp(valstr, value) != 0) { errs++; if (errs < MAX_ERRORS) { printf("Wrong value for info %d; got %s expected %s\n", i, value, valstr); } } } } for (i = 0; i < MAX_INFOS; i++) { MPI_Info_free(&infos[i]); } MTest_Finalize(errs); return MTestReturnValue(errs); }
int main( int argc, char *argv[] ) { int errs = 0; MPI_Info info; char *keys[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" }; char *values[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7", (char*)"myhost.myorg.org" }; char value[MPI_MAX_INFO_VAL]; int i, flag, nkeys; MTest_Init( &argc, &argv ); MPI_Info_create( &info ); /* Use only named keys incase the info implementation only supports the predefined keys (e.g., IBM) */ for (i=0; i<NKEYS; i++) { MPI_Info_set( info, keys[i], values[i] ); } /* Check that all values are present */ for (i=0; i<NKEYS; i++) { MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag ); if (!flag) { errs++; printf( "No value for key %s\n", keys[i] ); } if (strcmp( value, values[i] )) { errs++; printf( "Incorrect value for key %s, got %s expected %s\n", keys[i], value, values[i] ); } } /* Now, change one value and remove another, then check again */ MPI_Info_delete( info, keys[NKEYS-1] ); MPI_Info_get_nkeys( info, &nkeys ); if (nkeys != NKEYS - 1) { errs++; printf( "Deleting a key did not change the number of keys\n" ); } values[0] = (char*)"backfile.txt"; MPI_Info_set( info, keys[0], values[0] ); for (i=0; i<NKEYS-1; i++) { MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag ); if (!flag) { errs++; printf( "(after reset) No value for key %s\n", keys[i] ); } if (strcmp( value, values[i] )) { errs++; printf( "(after reset) Incorrect value for key %s, got %s expected %s\n", keys[i], value, values[i] ); } } MPI_Info_free( &info ); if (info != MPI_INFO_NULL) { errs++; printf( "MPI_Info_free should set info to MPI_INFO_NULL\n" ); } MTest_Finalize( errs ); MPI_Finalize(); return 0; }
int main(int argc, char **argv) { int i, len, nkeys, flag, mynod, default_striping_factor=0, nprocs, errs = 0; MPI_File fh; MPI_Info info, info_used; char *filename, key[MPI_MAX_INFO_KEY], value[MPI_MAX_INFO_VAL]; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &mynod); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* process 0 takes the file name as a command-line argument and broadcasts it to other processes */ if (!mynod) { i = 1; while ((i < argc) && strcmp("-fname", *argv)) { if (!strcmp("-v", *argv)) verbose = 1; i++; argv++; } if (i >= argc) { fprintf(stderr, "\n*# Usage: file_info [-v] -fname filename\n\n"); MPI_Abort(MPI_COMM_WORLD, 1); } argv++; len = strlen(*argv); filename = (char *) malloc(len+1); strcpy(filename, *argv); MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD); MPI_Bcast(&verbose, 1, MPI_INT, 0, MPI_COMM_WORLD); } else { MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); filename = (char *) malloc(len+1); MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD); MPI_Bcast(&verbose, 1, MPI_INT, 0, MPI_COMM_WORLD); } /* open the file with MPI_INFO_NULL */ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); /* check the default values set by ROMIO */ MPI_File_get_info(fh, &info_used); MPI_Info_get_nkeys(info_used, &nkeys); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info_used, i, key); MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL-1, value, &flag); #ifdef INFO_DEBUG if (!mynod) fprintf(stderr, "Process %d, Default: key = %s, value = %s\n", mynod, key, value); #endif if (!strcmp("striping_factor", key)) { default_striping_factor = atoi(value); /* no check */ } else if (!strcmp("cb_buffer_size", key)) { if (atoi(value) != DFLT_CB_BUFFER_SIZE) { errs++; if (verbose) fprintf(stderr, "cb_buffer_size is %d; should be %d\n", atoi(value), DFLT_CB_BUFFER_SIZE); } } else if (!strcmp("romio_cb_read", key)) { if (strcmp(DFLT_ROMIO_CB_READ, value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_read is set to %s; should be %s\n", value, DFLT_ROMIO_CB_READ); } } else if (!strcmp("romio_cb_write", key)) { if (strcmp(DFLT_ROMIO_CB_WRITE, value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_write is set to %s; should be %s\n", value, DFLT_ROMIO_CB_WRITE); } } else if (!strcmp("cb_nodes", key)) { /* unreliable test -- just ignore value */ } else if (!strcmp("romio_no_indep_rw", key)) { if (strcmp("false", value)) { errs++; if (verbose) fprintf(stderr, "romio_no_indep_rw is set to %s; should be %s\n", value, "false"); } } else if (!strcmp("ind_rd_buffer_size", key)) { if (atoi(value) != DFLT_IND_RD_BUFFER_SIZE) { errs++; if (verbose) fprintf(stderr, "ind_rd_buffer_size is %d; should be %d\n", atoi(value), DFLT_IND_RD_BUFFER_SIZE); } } else if (!strcmp("ind_wr_buffer_size", key)) { if (atoi(value) != DFLT_IND_WR_BUFFER_SIZE) { errs++; if (verbose) fprintf(stderr, "ind_wr_buffer_size is %d; should be %d\n", atoi(value), DFLT_IND_WR_BUFFER_SIZE); } } else if (!strcmp("romio_ds_read", key)) { if (strcmp("automatic", value)) { errs++; if (verbose) fprintf(stderr, "romio_ds_read is set to %s; should be %s\n", value, "automatic"); } } else if (!strcmp("romio_ds_write", key)) { /* Unreliable test -- value is file system dependent. Ignore. */ } else if (!strcmp("cb_config_list", key)) { #ifndef SKIP_CB_CONFIG_LIST_TEST if (strcmp("*:1", value)) { errs++; if (verbose) fprintf(stderr, "cb_config_list is set to %s; should be %s\n", value, "*:1"); } #endif } /* don't care about the defaults for these keys */ else if (!strcmp("romio_cb_pfr", key)) { } else if (!strcmp("romio_cb_fr_types", key)) { } else if (!strcmp("romio_cb_fr_alignment", key)) { } else if (!strcmp("romio_cb_ds_threshold", key)) { } else if (!strcmp("romio_cb_alltoall", key)) { } else { if (verbose) fprintf(stderr, "unexpected key %s (not counted as an error)\n", key); } } MPI_Info_free(&info_used); MPI_File_close(&fh); /* delete the file */ if (!mynod) MPI_File_delete(filename, MPI_INFO_NULL); MPI_Barrier(MPI_COMM_WORLD); /* set new info values. */ MPI_Info_create(&info); /* The following four hints are accepted on all machines. They can be specified at file-open time or later (any number of times). */ /* buffer size for collective I/O */ MPI_Info_set(info, "cb_buffer_size", "8388608"); /* number of processes that actually perform I/O in collective I/O */ sprintf(value, "%d", nprocs/2); MPI_Info_set(info, "cb_nodes", value); /* buffer size for data sieving in independent reads */ MPI_Info_set(info, "ind_rd_buffer_size", "2097152"); /* buffer size for data sieving in independent writes */ MPI_Info_set(info, "ind_wr_buffer_size", "1048576"); /* The following three hints related to file striping are accepted only on Intel PFS and IBM PIOFS file systems and are ignored elsewhere. They can be specified only at file-creation time; if specified later they will be ignored. */ /* number of I/O devices across which the file will be striped. accepted only if 0 < value < default_striping_factor; ignored otherwise */ if (default_striping_factor - 1 > 0) { sprintf(value, "%d", default_striping_factor-1); MPI_Info_set(info, "striping_factor", value); } else { sprintf(value, "%d", default_striping_factor); MPI_Info_set(info, "striping_factor", value); } /* the striping unit in bytes */ MPI_Info_set(info, "striping_unit", "131072"); #ifndef SKIP_CB_CONFIG_LIST_TEST /* set the cb_config_list so we'll get deterministic cb_nodes output */ MPI_Info_set(info, "cb_config_list", "*:*"); #endif /* the I/O device number from which to start striping the file. accepted only if 0 <= value < default_striping_factor; ignored otherwise */ sprintf(value, "%d", default_striping_factor-2); MPI_Info_set(info, "start_iodevice", value); /* The following hint about PFS server buffering is accepted only on Intel PFS. It can be specified anytime. */ MPI_Info_set(info, "pfs_svr_buf", "true"); /* open the file and set new info */ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); /* check the values set */ MPI_File_get_info(fh, &info_used); MPI_Info_get_nkeys(info_used, &nkeys); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info_used, i, key); MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL-1, value, &flag); #ifdef INFO_DEBUG if (!mynod) fprintf(stderr, "Process %d, key = %s, value = %s\n", mynod, key, value); #endif if (!strcmp("striping_factor", key)) { if ((default_striping_factor - 1 > 0) && (atoi(value) != default_striping_factor-1)) { errs++; if (verbose) fprintf(stderr, "striping_factor is %d; should be %d\n", atoi(value), default_striping_factor-1); } else if (atoi(value) != default_striping_factor) { errs++; if (verbose) fprintf(stderr, "striping_factor is %d; should be %d\n", atoi(value), default_striping_factor); } } else if (!strcmp("cb_buffer_size", key)) { if (atoi(value) != 8388608) { errs++; if (verbose) fprintf(stderr, "cb_buffer_size is %d; should be %d\n", atoi(value), 8388608); } } else if (!strcmp("romio_cb_read", key)) { if (strcmp(DFLT_ROMIO_CB_READ, value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_read is set to %s; should be %s\n", value, DFLT_ROMIO_CB_READ); } } else if (!strcmp("romio_cb_write", key)) { if (strcmp(DFLT_ROMIO_CB_WRITE, value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_write is set to %s; should be %s\n", value, DFLT_ROMIO_CB_WRITE); } } else if (!strcmp("cb_nodes", key)) { if (atoi(value) != (nprocs/2)) { errs++; if (verbose) fprintf(stderr, "cb_nodes is %d; should be %d\n", atoi(value), nprocs/2); } } else if (!strcmp("romio_no_indep_rw", key)) { if (strcmp("false", value)) { errs++; if (verbose) fprintf(stderr, "romio_no_indep_rw is set to %s; should be %s\n", value, "false"); } } else if (!strcmp("ind_rd_buffer_size", key)) { if (atoi(value) != 2097152) { errs++; if (verbose) fprintf(stderr, "ind_rd_buffer_size is %d; should be %d\n", atoi(value), 2097152); } } else if (!strcmp("ind_wr_buffer_size", key)) { if (atoi(value) != 1048576) { errs++; if (verbose) fprintf(stderr, "ind_wr_buffer_size is %d; should be %d\n", atoi(value), 1048576); } } else if (!strcmp("romio_ds_read", key)) { if (strcmp("automatic", value)) { errs++; if (verbose) fprintf(stderr, "romio_ds_read is set to %s; should be %s\n", value, "automatic"); } } else if (!strcmp("romio_ds_write", key)) { /* Unreliable test -- value is file system dependent. Ignore. */ } else if (!strcmp("cb_config_list", key)) { #ifndef SKIP_CB_CONFIG_LIST_TEST if (strcmp("*:*", value)) { errs++; if (verbose) fprintf(stderr, "cb_config_list is set to %s; should be %s\n", value, "*:*"); } #endif } else if (!strcmp("romio_cb_pfr", key)) { if(strcmp("disable", value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_pfr is set to %s; should be %s\n", value, "automatic"); } } else if (!strcmp("romio_cb_fr_types", key)) { if(strcmp("aar", value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_fr_types is set to %s; should be %s\n", value, "aar"); } } else if (!strcmp("romio_cb_fr_alignment", key)) { if(strcmp("1", value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_fr_alignment is set to %s; should be %s\n", value, "1"); } } else if (!strcmp("romio_cb_ds_threshold", key)) { if(strcmp("0", value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_ds_threshold is set to %s; should be %s\n", value, "0"); } } else if (!strcmp("romio_cb_alltoall", key)) { if(strcmp("automatic", value)) { errs++; if (verbose) fprintf(stderr, "romio_cb_alltoall is set to %s; should be %s\n", value, "automatic"); } } else { if (verbose) fprintf(stderr, "unexpected key %s (not counted as an error)\n", key); } } /* Q: SHOULD WE BOTHER LOOKING AT THE OTHER PROCESSES? */ if (!mynod) { if (errs) fprintf(stderr, "Found %d errors.\n", errs); else printf(" No Errors\n"); } MPI_File_close(&fh); free(filename); MPI_Info_free(&info_used); MPI_Info_free(&info); MPI_Finalize(); return 0; }
void mpi_info_get_nkeys(int* info, int *nkeys, int* ierr){ *ierr = MPI_Info_get_nkeys(*info, nkeys); }
int main( int argc, char *argv[] ) { int errs = 0; MPI_Info info1, infodup; int nkeys, nkeysdup, i, vallen, flag, flagdup; char key[MPI_MAX_INFO_KEY], keydup[MPI_MAX_INFO_KEY]; char value[MPI_MAX_INFO_VAL], valdup[MPI_MAX_INFO_VAL]; MTest_Init( &argc, &argv ); MPI_Info_create( &info1 ); /* Use only named keys incase the info implementation only supports the predefined keys (e.g., IBM) */ MPI_Info_set( info1, (char*)"host", (char*)"myhost.myorg.org" ); MPI_Info_set( info1, (char*)"file", (char*)"runfile.txt" ); MPI_Info_set( info1, (char*)"soft", (char*)"2:1000:4,3:1000:7" ); MPI_Info_dup( info1, &infodup ); MPI_Info_get_nkeys( infodup, &nkeysdup ); MPI_Info_get_nkeys( info1, &nkeys ); if (nkeys != nkeysdup) { errs++; printf( "Dup'ed info has a different number of keys; is %d should be %d\n", nkeysdup, nkeys ); } vallen = MPI_MAX_INFO_VAL; for (i=0; i<nkeys; i++) { /* MPI requires that the keys are in the same order after the dup */ MPI_Info_get_nthkey( info1, i, key ); MPI_Info_get_nthkey( infodup, i, keydup ); if (strcmp(key, keydup)) { errs++; printf( "keys do not match: %s should be %s\n", keydup, key ); } vallen = MPI_MAX_INFO_VAL; MPI_Info_get( info1, key, vallen, value, &flag ); MPI_Info_get( infodup, keydup, vallen, valdup, &flagdup ); if (!flag || !flagdup) { errs++; printf( "Info get failed for key %s\n", key ); } else if (strcmp( value, valdup )) { errs++; printf( "Info values for key %s not the same after dup\n", key ); } } /* Change info and check that infodup does NOT have the new value (ensure that lazy dups are still duped) */ MPI_Info_set( info1, (char*)"path", (char*)"/a:/b:/c/d" ); MPI_Info_get( infodup, (char*)"path", vallen, value, &flag ); if (flag) { errs++; printf( "inserting path into info changed infodup\n" ); } MPI_Info_free( &info1 ); MPI_Info_free( &infodup ); MTest_Finalize( errs ); MPI_Finalize(); return 0; }