summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c89
-rw-r--r--tools/lib/h5tools.h4
-rw-r--r--tools/lib/h5tools_dump.c4
3 files changed, 81 insertions, 16 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 55c69a7..e6df7c8 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -16,6 +16,8 @@
* amongst the various HDF5 tools.
*/
+#include <libgen.h>
+
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
@@ -81,19 +83,20 @@ const char *volnames[] = {
* somehow otherwise not enabled.
*
*/
-const char *drivernames[] = {
- "sec2",
- "direct",
- "log",
- "windows",
- "stdio",
- "core",
- "family",
- "split",
- "multi",
- "mpio",
- "ros3",
- "hdfs",
+const char *drivernames[]={
+ [SEC2_VFD_IDX] = "sec2",
+ [DIRECT_VFD_IDX] = "direct",
+ [LOG_VFD_IDX] = "log",
+ [WINDOWS_VFD_IDX] = "windows",
+ [STDIO_VFD_IDX] = "stdio",
+ [CORE_VFD_IDX] = "core",
+ [FAMILY_VFD_IDX] = "family",
+ [SPLIT_VFD_IDX] = "split",
+ [MULTI_VFD_IDX] = "multi",
+ [MPIO_VFD_IDX] = "mpio",
+ [ROS3_VFD_IDX] = "ros3",
+ [HDFS_VFD_IDX] = "hdfs",
+ [SWMR_VFD_IDX] = "swmr",
};
#define NUM_VOLS (sizeof(volnames) / sizeof(volnames[0]))
@@ -468,6 +471,52 @@ h5tools_set_error_file(const char *fname, int is_bin)
return retvalue;
}
+static hid_t
+swmr_fapl_augment(hid_t fapl, const char *fname)
+{
+ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
+ const char *dname;
+ char *tname;
+
+ /*
+ * Set up to open the file with VFD SWMR configured.
+ */
+ /* Enable page buffering */
+ if(H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) {
+ HDfprintf(rawerrorstream, "H5Pset_page_buffer_size failed\n");
+ return H5I_INVALID_HID;
+ }
+
+ /* Allocate memory for the configuration structure */
+ config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(*config));
+ if(config == NULL) {
+ HDfprintf(rawerrorstream, "VFD SWMR config allocation failed\n");
+ return H5I_INVALID_HID;
+ }
+
+ config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
+ config->tick_len = 4;
+ config->max_lag = 5;
+ config->writer = FALSE;
+ config->md_pages_reserved = 128;
+
+ if ((tname = strdup(fname)) == NULL) {
+ HDfprintf(rawerrorstream, "temporary string allocation failed\n");
+ return H5I_INVALID_HID;
+ }
+ dname = dirname(tname);
+ snprintf(config->md_file_path, sizeof(config->md_file_path),
+ "%s/my_md_file", dname);
+ free(tname);
+
+ /* Enable VFD SWMR configuration */
+ if(H5Pset_vfd_swmr_config(fapl, config) < 0) {
+ HDfprintf(rawerrorstream, "H5Pset_vrd_swmr_config failed\n");
+ return H5I_INVALID_HID;
+ }
+ return fapl;
+}
+
/*-------------------------------------------------------------------------
* Function: h5tools_set_fapl_vfd
*
@@ -484,7 +533,11 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info)
herr_t ret_value = SUCCEED;
/* Determine which driver the user wants to open the file with */
- if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) {
+ if (!HDstrcmp(vfd_info->name, drivernames[SWMR_VFD_IDX])) {
+ /* SWMR driver */
+ if (swmr_fapl_augment(fapl_id, vfd_info->fname) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "swmr_fapl_augment failed");
+ } else if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) {
/* SEC2 Driver */
if (H5Pset_fapl_sec2(fapl_id) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
@@ -948,7 +1001,15 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec
if (drivernum == LOG_VFD_IDX)
continue;
+ /* Skip the SWMR VFD, since it will start to wait to
+ * rendezvous with a writer, and that's not usually
+ * desired.
+ */
+ if (drivernum == SWMR_VFD_IDX)
+ continue;
+
vfd_info.info = NULL;
+ vfd_info.fname = fname;
vfd_info.name = drivernames[drivernum];
/* Get a fapl reflecting the selected VOL connector and VFD */
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 152ec1a..14a5361 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -568,6 +568,9 @@ typedef struct h5tools_vfd_info_t {
/* Name of the VFD */
const char *name;
+
+ /* Name of the file to open with the VFD */
+ const char *fname;
} h5tools_vfd_info_t;
/* This enum should match the entries in the above 'volnames'
@@ -592,6 +595,7 @@ typedef enum {
MPIO_VFD_IDX,
ROS3_VFD_IDX,
HDFS_VFD_IDX,
+ SWMR_VFD_IDX,
} driver_idx;
/* The following include, h5tools_str.h, must be after the
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index b1be577..4ba89fa 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -81,7 +81,7 @@ h5tool_format_t h5tools_dataformat = {
1, /*skip_first */
1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
+ " %" PRIuHADDR, /*obj_format */
1, /*dset_hidefileno */
"DATASET %s ", /*dset_format */
@@ -3292,7 +3292,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
if (HADDR_UNDEF == ioffset)
h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF");
else
- h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
+ h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
}
}