Skip to content

Commit

Permalink
fix(h5dump): support subfiling
Browse files Browse the repository at this point in the history
close #125
  • Loading branch information
hyoklee committed Nov 28, 2023
1 parent ea94084 commit 76f7b3c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
7 changes: 7 additions & 0 deletions tools/lib/h5tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info)
*
* Currently, driver configuration strings are unsupported.
*/
#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
if (vfd_info->u.value == H5_VFD_SUBFILING) {
if (H5Pset_fapl_subfiling(fapl_id,
(const H5FD_subfiling_config_t *)vfd_info->info) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_subfiling() failed");
}
#endif
if (H5Pset_driver_by_value(fapl_id, vfd_info->u.value, (const char *)vfd_info->info) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver value '%ld'",
(long int)vfd_info->u.value);
Expand Down
50 changes: 46 additions & 4 deletions tools/src/h5dump/h5dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static struct h5_long_options l_opts[] = {{"attribute", require_arg, 'a'},
{"vfd-name", require_arg, '5'},
{"vfd-info", require_arg, '6'},
{NULL, 0, '\0'}};

static int mpi_code_g;
/*-------------------------------------------------------------------------
* Function: leave
*
Expand Down Expand Up @@ -886,7 +886,12 @@ parse_command_line(int argc, const char *const *argv)
if (!vfd_info_g.info)
vfd_info_g.info = &hdfs_fa_g;
#endif

#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
fprintf(stderr, "vfd_info_g.u.name=%s\n", vfd_info_g.u.name);
if (0 == strcmp(vfd_info_g.u.name, drivernames[SUBFILING_VFD_IDX])) {
set_mpi(argc, argv);
}
#endif
break;
case 'g':
dump_opts.display_all = 0;
Expand Down Expand Up @@ -1214,12 +1219,24 @@ parse_command_line(int argc, const char *const *argv)
case '4':
vfd_info_g.type = VFD_BY_VALUE;
vfd_info_g.u.value = (H5FD_class_value_t)atoi(H5_optarg);

#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
if (vfd_info_g.u.value == H5_VFD_SUBFILING) {
set_mpi(argc, argv);
}
#endif
use_custom_vfd_g = true;
break;

case '5':
vfd_info_g.type = VFD_BY_NAME;
vfd_info_g.u.name = H5_optarg;
#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
fprintf(stderr, "vfd_info_g.u.name=%s\n", vfd_info_g.u.name);
if (0 == strcmp(vfd_info_g.u.name, drivernames[SUBFILING_VFD_IDX])) {
set_mpi(argc, argv);
}
#endif
use_custom_vfd_g = true;
break;

Expand All @@ -1234,8 +1251,10 @@ parse_command_line(int argc, const char *const *argv)
}
}


/* If the file uses the onion VFD, get the revision number */
if (vfd_info_g.type == VFD_BY_NAME && vfd_info_g.u.name && !strcmp(vfd_info_g.u.name, "onion")) {
if (vfd_info_g.type == VFD_BY_NAME &&
vfd_info_g.u.name && !strcmp(vfd_info_g.u.name, "onion")) {

if (vfd_info_g.info) {
if (!strcmp(vfd_info_g.info, "revision_count"))
Expand All @@ -1257,6 +1276,7 @@ parse_command_line(int argc, const char *const *argv)
vfd_info_g.info = &onion_fa_g;
}


parse_end:
/* check for file name to be processed */
if (argc <= H5_optind) {
Expand All @@ -1277,6 +1297,24 @@ parse_command_line(int argc, const char *const *argv)
return hand;
}

#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
int
set_mpi(argc, argv)
{
int required = MPI_THREAD_MULTIPLE;
int provided = 0;

/* Initialize MPI */
mpi_code_g = MPI_Init_thread(&argc, &argv, required, &provided);
if (MPI_SUCCESS != mpi_code_g) {
printf("MPI_Init_thread failed with error code %d\n", mpi_code_g);
return 1;
}

return 0;
}
#endif

/*-------------------------------------------------------------------------
* Function: main
*
Expand Down Expand Up @@ -1358,13 +1396,14 @@ main(int argc, char *argv[])
goto done;
}

/* Enable error reporting if --enable-error-stack command line option is specified */
/* enable error reporting if command line option */
h5tools_error_report();

/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);

if (use_custom_vol_g || use_custom_vfd_g) {

if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, use_custom_vol_g ? &vol_info_g : NULL,
use_custom_vfd_g ? &vfd_info_g : NULL)) < 0) {
error_msg("unable to create FAPL for file access\n");
Expand Down Expand Up @@ -1602,6 +1641,9 @@ main(int argc, char *argv[])
/* To Do: clean up XML table */

leave(h5tools_getstatus());
#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
MPI_Finalize();
#endif
} /* main */

/*-------------------------------------------------------------------------
Expand Down

0 comments on commit 76f7b3c

Please sign in to comment.