void BigArray<T>::loadNC(const std::string &fileName) { dataFileName = fileName; connection.disconnect(); connection = releaseSignal().connect(boost::bind(&gurls::BigArray<T>::close, this)); std::string errorString = "Error opening file " + fileName + ":"; // Set up file access property list with parallel I/O access plist_id = H5Pcreate(H5P_FILE_ACCESS); if(plist_id == -1) throw gException(errorString); herr_t status; #ifdef USE_MPIIO status = H5Pset_fapl_mpio(plist_id, MPI_COMM_WORLD, MPI_INFO_NULL); #else status = H5Pset_fapl_mpiposix(plist_id, MPI_COMM_WORLD, false); #endif CHECK_HDF5_ERR(status, errorString) // Create a new file collectively and release property list identifier. file_id = H5Fopen(fileName.c_str(), H5F_ACC_RDWR, plist_id); CHECK_HDF5_ERR(file_id, errorString) status = H5Pclose(plist_id); CHECK_HDF5_ERR(status, errorString) dset_id = H5Dopen(file_id, "mat", H5P_DEFAULT); CHECK_HDF5_ERR(dset_id, errorString) hid_t filespace = H5Dget_space( dset_id ); CHECK_HDF5_ERR(filespace, errorString) hsize_t dims[2], maxDims[2]; status = H5Sget_simple_extent_dims(filespace, dims, maxDims); CHECK_HDF5_ERR(status, errorString) status = H5Sclose(filespace); CHECK_HDF5_ERR(status, errorString) this->numrows = static_cast<unsigned long>(dims[1]); this->numcols = static_cast<unsigned long>(dims[0]); // Create property list for collective dataset write. plist_id = H5Pcreate(H5P_DATASET_XFER); if(plist_id == -1) throw gException(errorString); status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_INDEPENDENT); CHECK_HDF5_ERR(status, errorString) }
/* * Create the appropriate File access property list */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type, hbool_t use_gpfs) { hid_t ret_pl = -1; herr_t ret; /* generic return value */ int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); ret_pl = H5Pcreate (H5P_FILE_ACCESS); VRFY((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) return (ret_pl); if (l_facc_type == FACC_MPIO) { /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(ret_pl, comm, info); VRFY((ret >= 0), ""); return(ret_pl); } if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { hid_t mpio_pl; mpio_pl = H5Pcreate (H5P_FILE_ACCESS); VRFY((mpio_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(mpio_pl, comm, info); VRFY((ret >= 0), ""); /* setup file access template */ ret_pl = H5Pcreate (H5P_FILE_ACCESS); VRFY((ret_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); H5Pclose(mpio_pl); return(ret_pl); } if (l_facc_type == FACC_MPIPOSIX) { /* set Parallel access with communicator */ ret = H5Pset_fapl_mpiposix(ret_pl, comm, use_gpfs); VRFY((ret >= 0), "H5Pset_fapl_mpiposix succeeded"); return(ret_pl); } /* unknown file access types */ return (ret_pl); }
/*---------------------------------------------------------------------------- * Name: h5pset_fapl_mpiposix_c * Purpose: Call H5Pset_fapl_mpiposix to set mode for parallel I/O and the user * supplied communicator * Inputs: prp_id - property list identifier * comm - MPI communicator * flag - flag to use GPFS hints * Returns: 0 on success, -1 on failure * Programmer: Elena Pourmal * Tuesday, May 6, 2003 * Modifications: *---------------------------------------------------------------------------*/ int_f nh5pset_fapl_mpiposix_c(hid_t_f *prp_id, int_f* comm, int_f* flag) { int ret_value = -1; hid_t c_prp_id; herr_t ret; hbool_t c_flag; MPI_Comm c_comm; c_comm = MPI_Comm_f2c(*comm); c_flag = (hbool_t)*flag; /* * Call H5Pset_fapl_mpiposix function. */ c_prp_id = (hid_t) *prp_id; ret = H5Pset_fapl_mpiposix(c_prp_id, c_comm, c_flag); if (ret < 0) return ret_value; ret_value = 0; return ret_value; }
void BigArray<T>::init(std::string& fileName, unsigned long r, unsigned long c) { dataFileName = fileName; connection.disconnect(); connection = releaseSignal().connect(boost::bind(&gurls::BigArray<T>::close, this)); std::string errorString = "Error creating file " + fileName + ":"; // Set up file access property list with parallel I/O access plist_id = H5Pcreate(H5P_FILE_ACCESS); if(plist_id == -1) throw gException(errorString); herr_t status; #ifdef USE_MPIIO status = H5Pset_fapl_mpio(plist_id, MPI_COMM_WORLD, MPI_INFO_NULL); #else status = H5Pset_fapl_mpiposix(plist_id, MPI_COMM_WORLD, false); #endif CHECK_HDF5_ERR(status, errorString) // Create a new file collectively and release property list identifier. file_id = H5Fcreate(fileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id); CHECK_HDF5_ERR(file_id, errorString) status = H5Pclose(plist_id); CHECK_HDF5_ERR(status, errorString) // Create the dataspace for the dataset. hsize_t dims[2]; dims[0] = static_cast<hsize_t>(c); dims[1] = static_cast<hsize_t>(r); hid_t filespace = H5Screate_simple(2, dims, NULL); CHECK_HDF5_ERR(filespace, errorString) hid_t plist_dset_id = H5Pcreate(H5P_DATASET_CREATE); if(plist_dset_id == -1) throw gException(errorString); dset_id = H5Dcreate(file_id, "mat", getHdfType<T>(), filespace, H5P_DEFAULT, plist_dset_id, H5P_DEFAULT); CHECK_HDF5_ERR(dset_id, errorString) status = H5Pclose(plist_dset_id); CHECK_HDF5_ERR(status, errorString) status = H5Sclose(filespace); CHECK_HDF5_ERR(status, errorString) this->numrows = r; this->numcols = c; // Create property list for collective dataset write. plist_id = H5Pcreate(H5P_DATASET_XFER); if(plist_id == -1) throw gException(errorString); status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_INDEPENDENT); CHECK_HDF5_ERR(status, errorString) flush(); }