Skip to content

Commit

Permalink
Push ID->pointer lookups of LCPLs to API routines
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Feb 5, 2025
1 parent 86cc8f1 commit aa354fa
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 224 deletions.
56 changes: 34 additions & 22 deletions src/H5D.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

/* Helper routines for sync/async API calls */
static hid_t H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t lcpl_id, H5P_genplist_t *dcpl, H5P_genplist_t *dapl,
H5P_genplist_t *lcpl, H5P_genplist_t *dcpl, H5P_genplist_t *dapl,
void **token_ptr, H5VL_object_t **_vol_obj_ptr);
static hid_t H5D__open_api_common(hid_t loc_id, const char *name, H5P_genplist_t *dapl, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
Expand Down Expand Up @@ -91,7 +91,7 @@ H5FL_BLK_EXTERN(type_conv);
*-------------------------------------------------------------------------
*/
static hid_t
H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id,
H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5P_genplist_t *lcpl,
H5P_genplist_t *dcpl, H5P_genplist_t *dapl, void **token_ptr,
H5VL_object_t **_vol_obj_ptr)
{
Expand All @@ -116,18 +116,8 @@ H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t spac
if (H5VL_setup_acc_args(loc_id, H5P_CLS_DACC, true, &dapl_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments");

/* Get link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
else if (true != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Create the dataset */
if (NULL == (dset = H5VL_dataset_create(*vol_obj_ptr, &loc_params, name, lcpl_id, type_id, space_id, dcpl,
dapl, H5P_DATASET_XFER_DEFAULT, token_ptr)))
if (NULL == (dset = H5VL_dataset_create(*vol_obj_ptr, &loc_params, name, lcpl, type_id, space_id, dcpl, dapl, H5P_DATASET_XFER_DEFAULT, token_ptr)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create dataset");

/* Get an ID for the dataset */
Expand Down Expand Up @@ -172,12 +162,22 @@ hid_t
H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id,
hid_t dapl_id)
{
H5P_genplist_t *lcpl; /* Link creation property list */
H5P_genplist_t *dcpl; /* Dataset creation property list */
H5P_genplist_t *dapl; /* Dataset access property list */
hid_t ret_value = H5I_INVALID_HID; /* Return value */

FUNC_ENTER_API(H5I_INVALID_HID)

/* Get link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
if (NULL == (lcpl = H5P_object_verify(lcpl_id, H5P_TYPE_LINK_CREATE, true)))
HGOTO_ERROR(H5E_DATASET, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Get the pointer to the dataset create property list */
if (H5P_DEFAULT == dcpl_id)
dcpl_id = H5P_DATASET_CREATE_DEFAULT;
Expand All @@ -194,8 +194,7 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t
HGOTO_ERROR(H5E_DATASET, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Create the dataset synchronously */
if ((ret_value =
H5D__create_api_common(loc_id, name, type_id, space_id, lcpl_id, dcpl, dapl, NULL, NULL)) < 0)
if ((ret_value = H5D__create_api_common(loc_id, name, type_id, space_id, lcpl, dcpl, dapl, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5I_INVALID_HID, "unable to synchronously create dataset");

done:
Expand All @@ -217,6 +216,7 @@ H5Dcreate_async(const char *app_file, const char *app_func, unsigned app_line, h
hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
H5P_genplist_t *lcpl; /* Link creation property list */
H5P_genplist_t *dcpl; /* Dataset creation property list */
H5P_genplist_t *dapl; /* Dataset access property list */
void *token = NULL; /* Request token for async operation */
Expand All @@ -225,9 +225,14 @@ H5Dcreate_async(const char *app_file, const char *app_func, unsigned app_line, h

FUNC_ENTER_API(H5I_INVALID_HID)

/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Get link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
if (NULL == (lcpl = H5P_object_verify(lcpl_id, H5P_TYPE_LINK_CREATE, true)))
HGOTO_ERROR(H5E_DATASET, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Get the pointer to the dataset create property list */
if (H5P_DEFAULT == dcpl_id)
Expand All @@ -244,9 +249,12 @@ H5Dcreate_async(const char *app_file, const char *app_func, unsigned app_line, h
if (NULL == (dapl = H5P_object_verify(dapl_id, H5P_TYPE_DATASET_ACCESS, true)))
HGOTO_ERROR(H5E_DATASET, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */

/* Create the dataset asynchronously */
if ((ret_value = H5D__create_api_common(loc_id, name, type_id, space_id, lcpl_id, dcpl, dapl, token_ptr,
&vol_obj)) < 0)
if ((ret_value = H5D__create_api_common(loc_id, name, type_id, space_id, lcpl, dcpl, dapl, token_ptr, &vol_obj)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5I_INVALID_HID, "unable to asynchronously create dataset");

/* If a token was created, add the token to the event set */
Expand Down Expand Up @@ -300,6 +308,7 @@ hid_t
H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id)
{
void *dset = NULL; /* dset object from VOL connector */
H5P_genplist_t *def_lcpl; /* Default link creation property list */
H5P_genplist_t *dcpl; /* Dataset creation property list */
H5P_genplist_t *dapl; /* Dataset access property list */
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
Expand All @@ -308,6 +317,10 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t

FUNC_ENTER_API(H5I_INVALID_HID)

/* Get default link creation property list */
if (NULL == (def_lcpl = H5I_object(H5P_LINK_CREATE_DEFAULT)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "can't find object for ID");

/* Check arguments */
if (H5P_DEFAULT == dcpl_id)
dcpl_id = H5P_DATASET_CREATE_DEFAULT;
Expand Down Expand Up @@ -341,8 +354,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t
loc_params.obj_type = H5I_get_type(loc_id);

/* Create the dataset */
if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, type_id,
space_id, dcpl, dapl, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, def_lcpl, type_id, space_id, dcpl, dapl, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset");

/* Get an ID for the dataset */
Expand Down
9 changes: 6 additions & 3 deletions src/H5Ddeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ hid_t
H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id)
{
void *dset = NULL; /* dset object from VOL connector */
H5P_genplist_t *def_lcpl; /* Default link creation property list */
H5P_genplist_t *dcpl; /* Dataset creation property list */
H5P_genplist_t *def_dapl; /* Default dataset access property list */
H5VL_object_t *vol_obj = NULL; /* object of loc_id */
Expand All @@ -116,6 +117,10 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t
if (H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read");

/* Get default link creation property list */
if (NULL == (def_lcpl = H5I_object(H5P_LINK_CREATE_DEFAULT)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "can't find object for ID");

/* Get the pointer to the dataset create property list */
if (H5P_DEFAULT == dcpl_id)
dcpl_id = H5P_DATASET_CREATE_DEFAULT;
Expand All @@ -138,9 +143,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier");

/* Create the dataset */
if (NULL ==
(dset = H5VL_dataset_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, type_id, space_id,
dcpl, def_dapl, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, def_lcpl, type_id, space_id, dcpl, def_dapl, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset");

/* Register the new dataset to get an ID for it */
Expand Down
54 changes: 34 additions & 20 deletions src/H5G.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
/********************/

/* Helper routines for sync/async API calls */
static hid_t H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, H5P_genplist_t *gcpl,
static hid_t H5G__create_api_common(hid_t loc_id, const char *name, H5P_genplist_t *lcpl, H5P_genplist_t *gcpl,
H5P_genplist_t *gapl, void **token_ptr, H5VL_object_t **_vol_obj_ptr);
static hid_t H5G__open_api_common(hid_t loc_id, const char *name, H5P_genplist_t *gapl, void **token_ptr,
H5VL_object_t **_vol_obj_ptr);
Expand Down Expand Up @@ -141,7 +141,7 @@ static herr_t H5G__get_info_by_idx_api_common(hid_t loc_id, const char *group_na
*-------------------------------------------------------------------------
*/
static hid_t
H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, H5P_genplist_t *gcpl,
H5G__create_api_common(hid_t loc_id, const char *name, H5P_genplist_t *lcpl, H5P_genplist_t *gcpl,
H5P_genplist_t *gapl, void **token_ptr, H5VL_object_t **_vol_obj_ptr)
{
void *grp = NULL; /* Structure for new group */
Expand All @@ -165,18 +165,8 @@ H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, H5P_genpli
if (H5VL_setup_acc_args(loc_id, H5P_CLS_GACC, true, &gapl_id, vol_obj_ptr, &loc_params) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments");

/* Check link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
else if (true != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a link creation property list");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Create the group */
if (NULL == (grp = H5VL_group_create(*vol_obj_ptr, &loc_params, name, lcpl_id, gcpl, gapl,
H5P_DATASET_XFER_DEFAULT, token_ptr)))
if (NULL == (grp = H5VL_group_create(*vol_obj_ptr, &loc_params, name, lcpl, gcpl, gapl, H5P_DATASET_XFER_DEFAULT, token_ptr)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group");

/* Get an ID for the group */
Expand Down Expand Up @@ -217,12 +207,19 @@ H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, H5P_genpli
hid_t
H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id)
{
H5P_genplist_t *lcpl; /* Link creation property list */
H5P_genplist_t *gcpl; /* Group creation property list */
H5P_genplist_t *gapl; /* Group access property list */
hid_t ret_value = H5I_INVALID_HID; /* Return value */

FUNC_ENTER_API(H5I_INVALID_HID)

/* Check link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
if (NULL == (lcpl = H5P_object_verify(lcpl_id, H5P_TYPE_LINK_CREATE, true)))
HGOTO_ERROR(H5E_SYM, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Check group creation property list */
if (H5P_DEFAULT == gcpl_id)
gcpl_id = H5P_GROUP_CREATE_DEFAULT;
Expand All @@ -235,8 +232,11 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g
if (NULL == (gapl = H5P_object_verify(gapl_id, H5P_TYPE_GROUP_ACCESS, true)))
HGOTO_ERROR(H5E_SYM, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Create the group synchronously */
if ((ret_value = H5G__create_api_common(loc_id, name, lcpl_id, gcpl, gapl, NULL, NULL)) < 0)
if ((ret_value = H5G__create_api_common(loc_id, name, lcpl, gcpl, gapl, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to synchronously create group");

done:
Expand All @@ -258,6 +258,7 @@ H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, h
hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t es_id)
{
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
H5P_genplist_t *lcpl; /* Link creation property list */
H5P_genplist_t *gcpl; /* Group creation property list */
H5P_genplist_t *gapl; /* Group access property list */
void *token = NULL; /* Request token for async operation */
Expand All @@ -266,9 +267,11 @@ H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, h

FUNC_ENTER_API(H5I_INVALID_HID)

/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */
/* Check link creation property list */
if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
if (NULL == (lcpl = H5P_object_verify(lcpl_id, H5P_TYPE_LINK_CREATE, true)))
HGOTO_ERROR(H5E_SYM, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Check group creation property list */
if (H5P_DEFAULT == gcpl_id)
Expand All @@ -282,8 +285,15 @@ H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, h
if (NULL == (gapl = H5P_object_verify(gapl_id, H5P_TYPE_GROUP_ACCESS, true)))
HGOTO_ERROR(H5E_SYM, H5E_BADID, H5I_INVALID_HID, "can't find object for ID");

/* Set the LCPL for the API context */
H5CX_set_lcpl(lcpl_id);

/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
token_ptr = &token; /* Point at token for VOL connector to set up */

/* Create the group asynchronously */
if ((ret_value = H5G__create_api_common(loc_id, name, lcpl_id, gcpl, gapl, token_ptr, &vol_obj)) < 0)
if ((ret_value = H5G__create_api_common(loc_id, name, lcpl, gcpl, gapl, token_ptr, &vol_obj)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to asynchronously create group");

/* If a token was created, add the token to the event set */
Expand Down Expand Up @@ -337,6 +347,7 @@ hid_t
H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
{
void *grp = NULL; /* Structure for new group */
H5P_genplist_t *def_lcpl; /* Link creation property list */
H5P_genplist_t *gcpl; /* Group creation property list */
H5P_genplist_t *gapl; /* Group access property list */
H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
Expand All @@ -345,6 +356,10 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)

FUNC_ENTER_API(H5I_INVALID_HID)

/* Get default link creation property list */
if (NULL == (def_lcpl = H5I_object(H5P_LINK_CREATE_DEFAULT)))
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find object for ID");

/* Check group property list */
if (H5P_DEFAULT == gcpl_id)
gcpl_id = H5P_GROUP_CREATE_DEFAULT;
Expand All @@ -369,8 +384,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier");

/* Create the group */
if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl, gapl,
H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, def_lcpl, gcpl, gapl, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group");

/* Get an ID for the group */
Expand Down
Loading

0 comments on commit aa354fa

Please sign in to comment.