summaryrefslogtreecommitdiffstats
path: root/src/H5CX.c
diff options
context:
space:
mode:
authorNeil Fortner <fortnern@gmail.com>2023-10-20 17:32:17 (GMT)
committerGitHub <noreply@github.com>2023-10-20 17:32:17 (GMT)
commit630d6e27c956859ff5c0d7a61df3c095fbd7c86b (patch)
tree7494b9edf2aa094304467eac23727b17dba6d9a6 /src/H5CX.c
parentb916ce2419da45f7a51503e3bf2774e71f7db815 (diff)
downloadhdf5-630d6e27c956859ff5c0d7a61df3c095fbd7c86b.zip
hdf5-630d6e27c956859ff5c0d7a61df3c095fbd7c86b.tar.gz
hdf5-630d6e27c956859ff5c0d7a61df3c095fbd7c86b.tar.bz2
Add new API function H5Pget_actual_select_io_mode() (#2974)
This function allows the user to determine if the library performed selection I/O, vector I/O, or scalar (legacy) I/O during the last HDF5 operation performed with the provided DXPL. Expanded existing tests to check this functionality.
Diffstat (limited to 'src/H5CX.c')
-rw-r--r--src/H5CX.c101
1 files changed, 98 insertions, 3 deletions
diff --git a/src/H5CX.c b/src/H5CX.c
index b3b2fca..c46c58a 100644
--- a/src/H5CX.c
+++ b/src/H5CX.c
@@ -299,6 +299,11 @@ typedef struct H5CX_t {
bool no_selection_io_cause_set; /* Whether reason for not performing selection I/O is set */
bool no_selection_io_cause_valid; /* Whether reason for not performing selection I/O is valid */
+ uint32_t
+ actual_selection_io_mode; /* Actual selection I/O mode used (H5D_ACTUAL_SELECTION_IO_MODE_NAME) */
+ hbool_t actual_selection_io_mode_set; /* Whether actual selection I/O mode is set */
+ hbool_t actual_selection_io_mode_valid; /* Whether actual selection I/O mode is valid */
+
/* Cached LCPL properties */
H5T_cset_t encoding; /* Link name character encoding */
bool encoding_valid; /* Whether link name character encoding is valid */
@@ -380,6 +385,8 @@ typedef struct H5CX_dxpl_cache_t {
H5D_selection_io_mode_t selection_io_mode; /* Selection I/O mode (H5D_XFER_SELECTION_IO_MODE_NAME) */
uint32_t no_selection_io_cause; /* Reasons for not performing selection I/O
(H5D_XFER_NO_SELECTION_IO_CAUSE_NAME) */
+ uint32_t actual_selection_io_mode; /* Actual selection I/O mode
+ (H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME) */
bool modify_write_buf; /* Whether the library can modify write buffers */
} H5CX_dxpl_cache_t;
@@ -571,13 +578,18 @@ H5CX_init(void)
/* Get the selection I/O mode */
if (H5P_get(dx_plist, H5D_XFER_SELECTION_IO_MODE_NAME, &H5CX_def_dxpl_cache.selection_io_mode) < 0)
- HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve parallel transfer method");
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve selection I/O mode");
/* Get the local & global reasons for breaking selection I/O values */
if (H5P_get(dx_plist, H5D_XFER_NO_SELECTION_IO_CAUSE_NAME, &H5CX_def_dxpl_cache.no_selection_io_cause) <
0)
HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve cause for no selection I/O");
+ /* Get the actual selection I/O mode */
+ if (H5P_get(dx_plist, H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME,
+ &H5CX_def_dxpl_cache.actual_selection_io_mode) < 0)
+ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve actual selection I/O mode");
+
/* Get the modify write buffer property */
if (H5P_get(dx_plist, H5D_XFER_MODIFY_WRITE_BUF_NAME, &H5CX_def_dxpl_cache.modify_write_buf) < 0)
HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve modify write buffer property");
@@ -2515,6 +2527,47 @@ done:
} /* end H5CX_get_no_selection_io_cause() */
/*-------------------------------------------------------------------------
+ * Function: H5CX_get_actual_selection_io_mode
+ *
+ * Purpose: Retrieves the actual I/O mode (scalar, vector, and/or selection) for the current API call
+ *context.
+ *
+ * Return: Non-negative on success / Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5CX_get_actual_selection_io_mode(uint32_t *actual_selection_io_mode)
+{
+ H5CX_node_t **head = NULL; /* Pointer to head of API context list */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ assert(actual_selection_io_mode);
+ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ assert(head && *head);
+ assert(H5P_DEFAULT != (*head)->ctx.dxpl_id);
+
+ /* This property is a special case - we want to wipe out any previous setting. Copy the default setting
+ * if it has not been set yet. */
+ if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT && !(*head)->ctx.actual_selection_io_mode_set &&
+ !(*head)->ctx.actual_selection_io_mode_valid) {
+ (*head)->ctx.actual_selection_io_mode = H5CX_def_dxpl_cache.actual_selection_io_mode;
+ (*head)->ctx.actual_selection_io_mode_set = true;
+ }
+ H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME,
+ actual_selection_io_mode)
+
+ /* Get the value */
+ *actual_selection_io_mode = (*head)->ctx.actual_selection_io_mode;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5CX_get_actual_selection_io_mode() */
+
+/*-------------------------------------------------------------------------
* Function: H5CX_get_modify_write_buf
*
* Purpose: Retrieves the modify write buffer property for the current API call context.
@@ -3443,7 +3496,7 @@ done:
#endif /* H5_HAVE_PARALLEL */
/*-------------------------------------------------------------------------
- * Function: H5CX_set_no_selecction_io_cause
+ * Function: H5CX_set_no_selection_io_cause
*
* Purpose: Sets the reason for not performing selection I/O for
* the current API call context.
@@ -3472,7 +3525,39 @@ H5CX_set_no_selection_io_cause(uint32_t no_selection_io_cause)
} /* end if */
FUNC_LEAVE_NOAPI_VOID
-} /* end H5CX_set_no_selectiion_io_cause() */
+} /* end H5CX_set_no_selection_io_cause() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5CX_set_actual_selection_io_mode
+ *
+ * Purpose: Sets the actual selection I/O mode for the current API
+ * call context.
+ *
+ * Return: <none>
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5CX_set_actual_selection_io_mode(uint32_t actual_selection_io_mode)
+{
+ H5CX_node_t **head = NULL; /* Pointer to head of API context list */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Sanity checks */
+ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */
+ assert(head && *head);
+ assert((*head)->ctx.dxpl_id != H5P_DEFAULT);
+
+ /* If we're using the default DXPL, don't modify it */
+ if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) {
+ /* Cache the value for later, marking it to set in DXPL when context popped */
+ (*head)->ctx.actual_selection_io_mode = actual_selection_io_mode;
+ (*head)->ctx.actual_selection_io_mode_set = true;
+ }
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5CX_set_actual_selection_io_mode() */
/*-------------------------------------------------------------------------
* Function: H5CX_get_ohdr_flags
@@ -3529,7 +3614,17 @@ H5CX__pop_common(bool update_dxpl_props)
/* Check for cached DXPL properties to return to application */
if (update_dxpl_props) {
+ /* actual_selection_io_mode is a special case - we always want to set it in the property list even if
+ * it was never set by the library, in that case it indicates no I/O was performed and we don't want
+ * to leave the (possibly incorrect) old value in the property list, so set from the default property
+ * list */
+ if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT && !(*head)->ctx.actual_selection_io_mode_set) {
+ (*head)->ctx.actual_selection_io_mode = H5CX_def_dxpl_cache.actual_selection_io_mode;
+ (*head)->ctx.actual_selection_io_mode_set = true;
+ }
+
H5CX_SET_PROP(H5D_XFER_NO_SELECTION_IO_CAUSE_NAME, no_selection_io_cause)
+ H5CX_SET_PROP(H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME, actual_selection_io_mode)
#ifdef H5_HAVE_PARALLEL
H5CX_SET_PROP(H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, mpio_actual_chunk_opt)
H5CX_SET_PROP(H5D_MPIO_ACTUAL_IO_MODE_NAME, mpio_actual_io_mode)