//-------------------------------------------------------------------------- // Function: FileAccPropList::getSieveBufSize ///\brief Returns the current settings for the data sieve buffer size /// property from this property list. ///\return Data sieve buffer size, in bytes ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t FileAccPropList::getSieveBufSize() const { size_t bufsize; herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); if( ret_value < 0 ) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } return(bufsize); }
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); }