Exemplo n.º 1
0
FORT_DLL_SPEC void FORT_CALL mpi_file_get_info_ ( MPI_Fint *v1, MPI_Fint *v2, MPI_Fint *ierr ){
#ifdef MPI_MODE_RDONLY
    *ierr = MPI_File_get_info( MPI_File_f2c(*v1), (MPI_Info *)(v2) );
#else
*ierr = MPI_ERR_INTERN;
#endif
}
Exemplo n.º 2
0
JNIEXPORT jlong JNICALL Java_mpi_File_getInfo(
        JNIEnv *env, jobject jthis, jlong fh)
{
    MPI_Info info;
    int rc = MPI_File_get_info((MPI_File)fh, &info);
    ompi_java_exceptionCheck(env, rc);
    return (jlong)info;
}
Exemplo n.º 3
0
static void dump_mpi_file_info( MPI_File f, const char * prefix = NULL ) {
  MPI_Info info;

  MPI_CHECK( MPI_File_get_info( f, &info ) );

  dump_mpi_info( info, prefix );

  MPI_CHECK( MPI_Info_free( &info ) );
}
Exemplo n.º 4
0
void f_numagg(hid_t *file_id, int *num)
{
#ifndef USE_HDF5
  *num = 0;
#else

  int             ierr;
  MPI_File       *pFH = NULL;
  MPI_Info        infoF = MPI_INFO_NULL;
  T3PIO_results_t results;

  ierr = MPI_Info_create(&infoF);
  ierr = H5Fget_vfd_handle(*file_id, H5P_DEFAULT, (void **) &pFH);
  ierr = MPI_File_get_info(*pFH, &infoF);
  t3pio_extract_key_values(infoF, &results);
  *num = results.numIO;

  ierr = MPI_Info_free(&infoF);
#endif
}
Exemplo n.º 5
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 );
}
Exemplo n.º 6
0
/*
 * Open a file through the HDF5 interface.
 */
static void *HDF5_Open(char *testFileName, IOR_param_t * param)
{
        hid_t accessPropList, createPropList;
        hsize_t memStart[NUM_DIMS],
            dataSetDims[NUM_DIMS],
            memStride[NUM_DIMS],
            memCount[NUM_DIMS], memBlock[NUM_DIMS], memDataSpaceDims[NUM_DIMS];
        int tasksPerDataSet;
        unsigned fd_mode = (unsigned)0;
        hid_t *fd;
        MPI_Comm comm;
        MPI_Info mpiHints = MPI_INFO_NULL;

        fd = (hid_t *) malloc(sizeof(hid_t));
        if (fd == NULL)
                ERR("malloc() failed");
        /*
         * HDF5 uses different flags than those for POSIX/MPIIO
         */
        if (param->open == WRITE) {     /* WRITE flags */
                param->openFlags = IOR_TRUNC;
        } else {                /* READ or check WRITE/READ flags */
                param->openFlags = IOR_RDONLY;
        }

        /* set IOR file flags to HDF5 flags */
        /* -- file open flags -- */
        if (param->openFlags & IOR_RDONLY) {
                fd_mode |= H5F_ACC_RDONLY;
        }
        if (param->openFlags & IOR_WRONLY) {
                fprintf(stdout, "File write only not implemented in HDF5\n");
        }
        if (param->openFlags & IOR_RDWR) {
                fd_mode |= H5F_ACC_RDWR;
        }
        if (param->openFlags & IOR_APPEND) {
                fprintf(stdout, "File append not implemented in HDF5\n");
        }
        if (param->openFlags & IOR_CREAT) {
                fd_mode |= H5F_ACC_CREAT;
        }
        if (param->openFlags & IOR_EXCL) {
                fd_mode |= H5F_ACC_EXCL;
        }
        if (param->openFlags & IOR_TRUNC) {
                fd_mode |= H5F_ACC_TRUNC;
        }
        if (param->openFlags & IOR_DIRECT) {
                fprintf(stdout, "O_DIRECT not implemented in HDF5\n");
        }

        /* set up file creation property list */
        createPropList = H5Pcreate(H5P_FILE_CREATE);
        HDF5_CHECK(createPropList, "cannot create file creation property list");
        /* set size of offset and length used to address HDF5 objects */
        HDF5_CHECK(H5Pset_sizes
                   (createPropList, sizeof(hsize_t), sizeof(hsize_t)),
                   "cannot set property list properly");

        /* set up file access property list */
        accessPropList = H5Pcreate(H5P_FILE_ACCESS);
        HDF5_CHECK(accessPropList, "cannot create file access property list");

        /*
         * someday HDF5 implementation will allow subsets of MPI_COMM_WORLD
         */
        /* store MPI communicator info for the file access property list */
        if (param->filePerProc) {
                comm = MPI_COMM_SELF;
        } else {
                comm = testComm;
        }

        SetHints(&mpiHints, param->hintsFileName);
        /*
         * note that with MP_HINTS_FILTERED=no, all key/value pairs will
         * be in the info object.  The info object that is attached to
         * the file during MPI_File_open() will only contain those pairs
         * deemed valid by the implementation.
         */
        /* show hints passed to file */
        if (rank == 0 && param->showHints) {
                fprintf(stdout, "\nhints passed to access property list {\n");
                ShowHints(&mpiHints);
                fprintf(stdout, "}\n");
        }
        HDF5_CHECK(H5Pset_fapl_mpio(accessPropList, comm, mpiHints),
                   "cannot set file access property list");

        /* set alignment */
        HDF5_CHECK(H5Pset_alignment(accessPropList, param->setAlignment,
                                    param->setAlignment),
                   "cannot set alignment");

        /* open file */
        if (param->open == WRITE) {     /* WRITE */
                *fd = H5Fcreate(testFileName, fd_mode,
                                createPropList, accessPropList);
                HDF5_CHECK(*fd, "cannot create file");
        } else {                /* READ or CHECK */
                *fd = H5Fopen(testFileName, fd_mode, accessPropList);
                HDF5_CHECK(*fd, "cannot open file");
        }

        /* show hints actually attached to file handle */
        if (param->showHints || (1) /* WEL - this needs fixing */ ) {
                if (rank == 0
                    && (param->showHints) /* WEL - this needs fixing */ ) {
                        WARN("showHints not working for HDF5");
                }
        } else {
                MPI_Info mpiHintsCheck = MPI_INFO_NULL;
                hid_t apl;
                apl = H5Fget_access_plist(*fd);
                HDF5_CHECK(H5Pget_fapl_mpio(apl, &comm, &mpiHintsCheck),
                           "cannot get info object through HDF5");
                if (rank == 0) {
                        fprintf(stdout,
                                "\nhints returned from opened file (HDF5) {\n");
                        ShowHints(&mpiHintsCheck);
                        fprintf(stdout, "}\n");
                        if (1 == 1) {   /* request the MPIIO file handle and its hints */
                                MPI_File *fd_mpiio;
                                HDF5_CHECK(H5Fget_vfd_handle
                                           (*fd, apl, (void **)&fd_mpiio),
                                           "cannot get MPIIO file handle");
                                MPI_CHECK(MPI_File_get_info
                                          (*fd_mpiio, &mpiHintsCheck),
                                          "cannot get info object through MPIIO");
                                fprintf(stdout,
                                        "\nhints returned from opened file (MPIIO) {\n");
                                ShowHints(&mpiHintsCheck);
                                fprintf(stdout, "}\n");
                        }
                }
                MPI_CHECK(MPI_Barrier(testComm), "barrier error");
        }

        /* this is necessary for resetting various parameters
           needed for reopening and checking the file */
        newlyOpenedFile = TRUE;

        HDF5_CHECK(H5Pclose(createPropList),
                   "cannot close creation property list");
        HDF5_CHECK(H5Pclose(accessPropList),
                   "cannot close access property list");

        /* create property list for serial/parallel access */
        xferPropList = H5Pcreate(H5P_DATASET_XFER);
        HDF5_CHECK(xferPropList, "cannot create transfer property list");

        /* set data transfer mode */
        if (param->collective) {
                HDF5_CHECK(H5Pset_dxpl_mpio(xferPropList, H5FD_MPIO_COLLECTIVE),
                           "cannot set collective data transfer mode");
        } else {
                HDF5_CHECK(H5Pset_dxpl_mpio
                           (xferPropList, H5FD_MPIO_INDEPENDENT),
                           "cannot set independent data transfer mode");
        }

        /* set up memory data space for transfer */
        memStart[0] = (hsize_t) 0;
        memCount[0] = (hsize_t) 1;
        memStride[0] = (hsize_t) (param->transferSize / sizeof(IOR_size_t));
        memBlock[0] = (hsize_t) (param->transferSize / sizeof(IOR_size_t));
        memDataSpaceDims[0] = (hsize_t) param->transferSize;
        memDataSpace = H5Screate_simple(NUM_DIMS, memDataSpaceDims, NULL);
        HDF5_CHECK(memDataSpace, "cannot create simple memory data space");

        /* define hyperslab for memory data space */
        HDF5_CHECK(H5Sselect_hyperslab(memDataSpace, H5S_SELECT_SET,
                                       memStart, memStride, memCount,
                                       memBlock), "cannot create hyperslab");

        /* set up parameters for fpp or different dataset count */
        if (param->filePerProc) {
                tasksPerDataSet = 1;
        } else {
                if (param->individualDataSets) {
                        /* each task in segment has single data set */
                        tasksPerDataSet = 1;
                } else {
                        /* share single data set across all tasks in segment */
                        tasksPerDataSet = param->numTasks;
                }
        }
        dataSetDims[0] = (hsize_t) ((param->blockSize / sizeof(IOR_size_t))
                                    * tasksPerDataSet);

        /* create a simple data space containing information on size
           and shape of data set, and open it for access */
        dataSpace = H5Screate_simple(NUM_DIMS, dataSetDims, NULL);
        HDF5_CHECK(dataSpace, "cannot create simple data space");

        return (fd);
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
/*
 * Open a file through the MPIIO interface.  Setup file view.
 */
static void *MPIIO_Open(char *testFileName, IOR_param_t * param)
{
        int fd_mode = (int)0,
            offsetFactor,
            tasksPerFile,
            transfersPerBlock = param->blockSize / param->transferSize;
        struct fileTypeStruct {
                int globalSizes[2], localSizes[2], startIndices[2];
        } fileTypeStruct;
        MPI_File *fd;
        MPI_Comm comm;
        MPI_Info mpiHints = MPI_INFO_NULL;

        fd = (MPI_File *) malloc(sizeof(MPI_File));
        if (fd == NULL)
                ERR("malloc failed()");

        *fd = 0;

        /* set IOR file flags to MPIIO flags */
        /* -- file open flags -- */
        if (param->openFlags & IOR_RDONLY) {
                fd_mode |= MPI_MODE_RDONLY;
        }
        if (param->openFlags & IOR_WRONLY) {
                fd_mode |= MPI_MODE_WRONLY;
        }
        if (param->openFlags & IOR_RDWR) {
                fd_mode |= MPI_MODE_RDWR;
        }
        if (param->openFlags & IOR_APPEND) {
                fd_mode |= MPI_MODE_APPEND;
        }
        if (param->openFlags & IOR_CREAT) {
                fd_mode |= MPI_MODE_CREATE;
        }
        if (param->openFlags & IOR_EXCL) {
                fd_mode |= MPI_MODE_EXCL;
        }
        if (param->openFlags & IOR_TRUNC) {
                fprintf(stdout, "File truncation not implemented in MPIIO\n");
        }
        if (param->openFlags & IOR_DIRECT) {
                fprintf(stdout, "O_DIRECT not implemented in MPIIO\n");
        }

        /*
         * MPI_MODE_UNIQUE_OPEN mode optimization eliminates the overhead of file
         * locking.  Only open a file in this mode when the file will not be con-
         * currently opened elsewhere, either inside or outside the MPI environment.
         */
        fd_mode |= MPI_MODE_UNIQUE_OPEN;

        if (param->filePerProc) {
                comm = MPI_COMM_SELF;
        } else {
                comm = testComm;
        }

        SetHints(&mpiHints, param->hintsFileName);
        /*
         * note that with MP_HINTS_FILTERED=no, all key/value pairs will
         * be in the info object.  The info object that is attached to
         * the file during MPI_File_open() will only contain those pairs
         * deemed valid by the implementation.
         */
        /* show hints passed to file */
        if (rank == 0 && param->showHints) {
                fprintf(stdout, "\nhints passed to MPI_File_open() {\n");
                ShowHints(&mpiHints);
                fprintf(stdout, "}\n");
        }
        MPI_CHECK(MPI_File_open(comm, testFileName, fd_mode, mpiHints, fd),
                  "cannot open file");

        /* show hints actually attached to file handle */
        if (rank == 0 && param->showHints) {
                MPI_CHECK(MPI_File_get_info(*fd, &mpiHints),
                          "cannot get file info");
                fprintf(stdout, "\nhints returned from opened file {\n");
                ShowHints(&mpiHints);
                fprintf(stdout, "}\n");
        }

        /* preallocate space for file */
        if (param->preallocate && param->open == WRITE) {
                MPI_CHECK(MPI_File_preallocate(*fd,
                                               (MPI_Offset) (param->segmentCount
                                                             *
                                                             param->blockSize *
                                                             param->numTasks)),
                          "cannot preallocate file");
        }
        /* create file view */
        if (param->useFileView) {
                /* create contiguous transfer datatype */
                MPI_CHECK(MPI_Type_contiguous
                          (param->transferSize / sizeof(IOR_size_t),
                           MPI_LONG_LONG_INT, &param->transferType),
                          "cannot create contiguous datatype");
                MPI_CHECK(MPI_Type_commit(&param->transferType),
                          "cannot commit datatype");
                if (param->filePerProc) {
                        offsetFactor = 0;
                        tasksPerFile = 1;
                } else {
                        offsetFactor = (rank + rankOffset) % param->numTasks;
                        tasksPerFile = param->numTasks;
                }

                /*
                 * create file type using subarray
                 */
                fileTypeStruct.globalSizes[0] = 1;
                fileTypeStruct.globalSizes[1] =
                    transfersPerBlock * tasksPerFile;
                fileTypeStruct.localSizes[0] = 1;
                fileTypeStruct.localSizes[1] = transfersPerBlock;
                fileTypeStruct.startIndices[0] = 0;
                fileTypeStruct.startIndices[1] =
                    transfersPerBlock * offsetFactor;

                MPI_CHECK(MPI_Type_create_subarray
                          (2, fileTypeStruct.globalSizes,
                           fileTypeStruct.localSizes,
                           fileTypeStruct.startIndices, MPI_ORDER_C,
                           param->transferType, &param->fileType),
                          "cannot create subarray");
                MPI_CHECK(MPI_Type_commit(&param->fileType),
                          "cannot commit datatype");

                MPI_CHECK(MPI_File_set_view(*fd, (MPI_Offset) 0,
                                            param->transferType,
                                            param->fileType, "native",
                                            (MPI_Info) MPI_INFO_NULL),
                          "cannot set file view");
        }
        return ((void *)fd);
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
/*
 * access style is explicitly described as modifiable.  values include
 * read_once, read_mostly, write_once, write_mostlye, random
 *
 *
 */
int main(int argc, char *argv[])
{
    int errs = 0, err;
    int buf[10];
    int rank;
    MPI_Comm comm;
    MPI_Status status;
    MPI_File fh;
    MPI_Info infoin, infoout;
    char value[1024];
    int flag, count;

    MTest_Init(&argc, &argv);
    comm = MPI_COMM_WORLD;

    MPI_Comm_rank(comm, &rank);
    MPI_Info_create(&infoin);
    MPI_Info_set(infoin, (char *) "access_style", (char *) "write_once,random");
    MPI_File_open(comm, (char *) "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE, infoin, &fh);
    buf[0] = rank;
    err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
    if (err) {
        errs++;
        MTestPrintError(err);
    }

    MPI_Info_set(infoin, (char *) "access_style", (char *) "read_once");
    err = MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
    if (err) {
        errs++;
        MTestPrintError(err);
    }

    err = MPI_File_set_info(fh, infoin);
    if (err) {
        errs++;
        MTestPrintError(err);
    }
    MPI_Info_free(&infoin);
    buf[0] = -1;

    err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
    if (err) {
        errs++;
        MTestPrintError(err);
    }
    MPI_Get_count(&status, MPI_INT, &count);
    if (count != 1) {
        errs++;
        printf("Expected to read one int, read %d\n", count);
    }
    if (buf[0] != rank) {
        errs++;
        printf("Did not read expected value (%d)\n", buf[0]);
    }

    err = MPI_File_get_info(fh, &infoout);
    if (err) {
        errs++;
        MTestPrintError(err);
    }
    MPI_Info_get(infoout, (char *) "access_style", 1024, value, &flag);
    /* Note that an implementation is allowed to ignore the set_info,
     * so we'll accept either the original or the updated version */
    if (!flag) {
        ;
        /*
         * errs++;
         * printf("Access style hint not saved\n");
         */
    } else {
        if (strcmp(value, "read_once") != 0 && strcmp(value, "write_once,random") != 0) {
            errs++;
            printf("value for access_style unexpected; is %s\n", value);
        }
    }
    MPI_Info_free(&infoout);
    err = MPI_File_close(&fh);
    if (err) {
        errs++;
        MTestPrintError(err);
    }
    MPI_Barrier(comm);
    MPI_Comm_rank(comm, &rank);
    if (rank == 0) {
        err = MPI_File_delete((char *) "testfile", MPI_INFO_NULL);
        if (err) {
            errs++;
            MTestPrintError(err);
        }
    }

    MTest_Finalize(errs);
    return MTestReturnValue(errs);
}