48 #if H5_VERS_MAJOR > 1 && H5_VERS_MINOR > 6 49 #define HDF5_CHECK(HDF5_RETURN, MSG) do { \ 50 char resultString[1024]; \ 52 if (HDF5_RETURN < 0) { \ 53 fprintf(stdout, "** error **\n"); \ 54 fprintf(stdout, "ERROR in %s (line %d): %s.\n", \ 55 __FILE__, __LINE__, MSG); \ 56 strcpy(resultString, H5Eget_major((H5E_major_t)HDF5_RETURN)); \ 57 if (strcmp(resultString, "Invalid major error number") != 0) \ 58 fprintf(stdout, "HDF5 %s\n", resultString); \ 59 strcpy(resultString, H5Eget_minor((H5E_minor_t)HDF5_RETURN)); \ 60 if (strcmp(resultString, "Invalid minor error number") != 0) \ 61 fprintf(stdout, "%s\n", resultString); \ 62 fprintf(stdout, "** exiting **\n"); \ 67 #define HDF5_CHECK(HDF5_RETURN, MSG) do { \ 69 if (HDF5_RETURN < 0) { \ 70 fprintf(stdout, "** error **\n"); \ 71 fprintf(stdout, "ERROR in %s (line %d): %s.\n", \ 72 __FILE__, __LINE__, MSG); \ 77 fprintf(stdout, "** exiting **\n"); \ 113 if (init_values !=
NULL){
125 {0,
"hdf5.collectiveMetadata",
"Use collectiveMetadata (available since HDF5-1.10.0)",
OPTION_FLAG,
'd', & o->
collective_md},
130 {0,
"hdf5.noFill",
"No fill in HDF5 file creation",
OPTION_FLAG,
'd', & o->
noFill},
134 memcpy(help, h,
sizeof(h));
181 ERR(
"alignment must be non-negative integer");
183 ERR(
"individual data sets not implemented");
186 #if defined (H5_VERS_MAJOR) && defined (H5_VERS_MINOR) 188 #if (H5_VERS_MAJOR > 0 && H5_VERS_MINOR > 5) 190 ERRF(
"'no fill' option not available in HDF5");
193 WARN(
"unable to determine HDF5 version for 'no fill' usage");
204 return HDF5_Open(testFileName, flags, param);
213 hid_t accessPropList, createPropList;
219 unsigned fd_mode = (unsigned)0;
222 MPI_Info mpiHints = MPI_INFO_NULL;
224 fd = (hid_t *) malloc(
sizeof(hid_t));
226 ERR(
"malloc() failed");
233 fd_mode |= H5F_ACC_RDONLY;
236 fd_mode |= H5F_ACC_RDWR;
239 fprintf(stdout,
"File append not implemented in HDF5\n");
242 fd_mode |= H5F_ACC_CREAT;
245 fd_mode |= H5F_ACC_EXCL;
248 fd_mode |= H5F_ACC_TRUNC;
251 fprintf(stdout,
"O_DIRECT not implemented in HDF5\n");
255 createPropList = H5Pcreate(H5P_FILE_CREATE);
256 HDF5_CHECK(createPropList,
"cannot create file creation property list");
259 (createPropList,
sizeof(hsize_t),
sizeof(hsize_t)),
260 "cannot set property list properly");
263 accessPropList = H5Pcreate(H5P_FILE_ACCESS);
264 HDF5_CHECK(accessPropList,
"cannot create file access property list");
271 comm = MPI_COMM_SELF;
285 fprintf(stdout,
"\nhints passed to access property list {\n");
287 fprintf(stdout,
"}\n");
289 HDF5_CHECK(H5Pset_fapl_mpio(accessPropList, comm, mpiHints),
290 "cannot set file access property list");
294 "cannot set alignment");
296 #ifdef HAVE_H5PSET_ALL_COLL_METADATA_OPS 301 HDF5_CHECK(H5Pset_all_coll_metadata_ops(accessPropList, 1),
302 "cannot set collective md read");
303 HDF5_CHECK(H5Pset_coll_metadata_write(accessPropList, 1),
304 "cannot set collective md write");
310 if (flags & IOR_CREAT) {
311 *fd = H5Fcreate(testFileName, H5F_ACC_TRUNC, createPropList, accessPropList);
314 *fd = H5Fopen(testFileName, fd_mode, accessPropList);
322 WARN(
"showHints not working for HDF5");
325 MPI_Info mpiHintsCheck = MPI_INFO_NULL;
327 apl = H5Fget_access_plist(*fd);
328 HDF5_CHECK(H5Pget_fapl_mpio(apl, &comm, &mpiHintsCheck),
329 "cannot get info object through HDF5");
332 "\nhints returned from opened file (HDF5) {\n");
334 fprintf(stdout,
"}\n");
338 (*fd, apl, (
void **)&fd_mpiio),
339 "cannot get MPIIO file handle");
340 if (mpiHintsCheck != MPI_INFO_NULL)
341 MPI_Info_free(&mpiHintsCheck);
343 (*fd_mpiio, &mpiHintsCheck),
344 "cannot get info object through MPIIO");
346 "\nhints returned from opened file (MPIIO) {\n");
348 fprintf(stdout,
"}\n");
349 if (mpiHintsCheck != MPI_INFO_NULL)
350 MPI_Info_free(&mpiHintsCheck);
361 "cannot close creation property list");
363 "cannot close access property list");
372 "cannot set collective data transfer mode");
376 "cannot set independent data transfer mode");
380 memStart[0] = (hsize_t) 0;
381 memCount[0] = (hsize_t) 1;
390 memStart, memStride, memCount,
391 memBlock),
"cannot create hyperslab");
412 if (mpiHints != MPI_INFO_NULL)
413 MPI_Info_free(&mpiHints);
424 static int firstReadCheck =
FALSE, startNewDataSet;
433 if (firstReadCheck ==
TRUE) {
434 firstReadCheck =
FALSE;
436 firstReadCheck =
TRUE;
450 if ((
IOR_offset_t) ((offset - segmentPosition) % segmentSize) ==
456 startNewDataSet =
TRUE;
458 startNewDataSet =
FALSE;
466 if (startNewDataSet ==
TRUE) {
471 "cannot close file data space");
479 startNewDataSet =
FALSE;
483 if (access ==
WRITE) {
487 "cannot write to data set");
492 "cannot read from data set");
515 "cannot close file data space");
517 "cannot close memory data space");
519 " cannot close transfer property list");
521 HDF5_CHECK(H5Fclose(*(hid_t *) fd),
"cannot close file");
541 static char version[1024] = {0};
542 if(version[0])
return version;
544 unsigned major, minor, release;
545 if (H5get_libversion(&major, &minor, &release) < 0) {
546 WARN(
"cannot get HDF5 library version");
548 sprintf(version,
"%u.%u.%u", major, minor, release);
550 #ifndef H5_HAVE_PARALLEL 551 strcat(version,
" (Serial)");
553 strcat(version,
" (Parallel)");
579 hsStart[0] = (hsize_t) ((offset % hints->
blockSize)
584 (hsize_t) ((offset % segmentSize) /
sizeof(
IOR_size_t));
586 hsCount[0] = (hsize_t) 1;
594 hsStart, hsStride, hsCount, hsBlock),
595 "cannot select hyperslab");
606 hid_t dataSetPropList;
608 static int dataSetSuffix = 0;
624 sprintf(dataSetName,
"%s-%04d.%04d",
"Dataset", dataSetID,
629 dataSetPropList = H5Pcreate(H5P_DATASET_CREATE);
631 #if defined (H5_VERS_MAJOR) && defined (H5_VERS_MINOR) 633 #if (H5_VERS_MAJOR > 0 && H5_VERS_MINOR > 5) 636 fprintf(stdout,
"\nusing 'no fill' option\n");
639 H5D_FILL_TIME_NEVER),
640 "cannot set fill time for property list");
644 sprintf(errorString,
"'no fill' option not available in %s",
649 WARN(
"unable to determine HDF5 version for 'no fill' usage");
652 H5Dcreate(*(hid_t *) fd, dataSetName, H5T_NATIVE_LLONG,
656 dataSet = H5Dopen(*(hid_t *) fd, dataSetName);
static void SetupDataSet(void *, int flags, aiori_mod_opt_t *)
static aiori_fd_t * HDF5_Create(char *, int flags, aiori_mod_opt_t *)
static void HDF5_init_xfer_options(aiori_xfer_hint_t *params)
void ShowHints(MPI_Info *mpiHints)
static void HDF5_Close(aiori_fd_t *, aiori_mod_opt_t *)
struct benchmark_options o
#define HDF5_CHECK(HDF5_RETURN, MSG)
IOR_offset_t MPIIO_GetFileSize(aiori_mod_opt_t *module_options, char *testFileName)
IOR_offset_t setAlignment
#define MPI_CHECK(MPI_STATUS, MSG)
int aiori_posix_stat(const char *path, struct stat *buf, aiori_mod_opt_t *module_options)
static aiori_xfer_hint_t * hints
static option_help * HDF5_options(aiori_mod_opt_t **init_backend_options, aiori_mod_opt_t *init_values)
static int HDF5_Access(const char *, int, aiori_mod_opt_t *)
int MPIIO_Access(const char *path, int mode, aiori_mod_opt_t *module_options)
static option_help options[]
static hid_t xferPropList
static void HDF5_Fsync(aiori_fd_t *, aiori_mod_opt_t *)
static int HDF5_check_params(aiori_mod_opt_t *options)
void MPIIO_xfer_hints(aiori_xfer_hint_t *params)
IOR_offset_t transferSize
static void HDF5_Delete(char *, aiori_mod_opt_t *)
static char * HDF5_GetVersion()
int aiori_posix_rmdir(const char *path, aiori_mod_opt_t *module_options)
static aiori_fd_t * HDF5_Open(char *, int flags, aiori_mod_opt_t *)
int aiori_posix_mkdir(const char *path, mode_t mode, aiori_mod_opt_t *module_options)
static IOR_offset_t HDF5_Xfer(int, aiori_fd_t *, IOR_size_t *, IOR_offset_t, IOR_offset_t, aiori_mod_opt_t *)
int aiori_posix_statfs(const char *path, ior_aiori_statfs_t *stat_buf, aiori_mod_opt_t *module_options)
void SetHints(MPI_Info *mpiHints, char *hintsFileName)
void MPIIO_Delete(char *testFileName, aiori_mod_opt_t *module_options)
static IOR_offset_t HDF5_GetFileSize(aiori_mod_opt_t *, char *)
long long int IOR_offset_t
static IOR_offset_t SeekOffset(void *, IOR_offset_t, aiori_mod_opt_t *)