From 594cd935435d36801bee3dbb7fc531df7d398bcc Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 13 Mar 2019 10:20:30 -0500 Subject: HDFFV-10658: setting and getting properties in API context: 1. external file prefix and VDS prefix. 2. the datatype, dataspace, and LCPL of the dataset for VOL connector. --- src/H5CX.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++- src/H5CXprivate.h | 12 ++ src/H5D.c | 21 +-- src/H5Ddeprec.c | 12 +- src/H5Dint.c | 36 ++--- src/H5VLnative_dataset.c | 10 +- 6 files changed, 391 insertions(+), 42 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index b56d66d..2bfe559 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -189,6 +189,10 @@ typedef struct H5CX_t { hid_t dcpl_id; /* DCPL ID for API operation */ H5P_genplist_t *dcpl; /* Dataset Creation Property List */ + /* DAPL */ + hid_t dapl_id; /* DAPL ID for API operation */ + H5P_genplist_t *dapl; /* Dataset Access Property List */ + /* Internal: Object tagging info */ haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ @@ -275,8 +279,20 @@ typedef struct H5CX_t { hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ /* Cached DCPL properties */ - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + hid_t vl_prop_dset_type_id; + hbool_t vl_prop_dset_type_id_valid; + hid_t vl_prop_dset_space_id; + hbool_t vl_prop_dset_space_id_valid; + hid_t vl_prop_dset_lcpl_id; + hbool_t vl_prop_dset_lcpl_id_valid; + + /* Cached DAPL properties */ + char *extfile_prefix; + hbool_t extfile_prefix_valid; + char *vds_prefix; + hbool_t vds_prefix_valid; /* Cached VOL settings */ H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ @@ -336,8 +352,17 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hid_t vl_prop_dset_type_id; + hid_t vl_prop_dset_space_id; + hid_t vl_prop_dset_lcpl_id; } H5CX_dcpl_cache_t; +/* Typedef for cached default dataset access property list information */ +/* (Same as the cached DXPL struct, above, except for the default DXPL) */ +typedef struct H5CX_dapl_cache_t { + char *extfile_prefix; + char *vds_prefix; +} H5CX_dapl_cache_t; /********************/ /* Local Prototypes */ @@ -374,6 +399,9 @@ static H5CX_lapl_cache_t H5CX_def_lapl_cache; /* Define a "default" dataset creation property list cache structure to use for default DCPLs */ static H5CX_dcpl_cache_t H5CX_def_dcpl_cache; +/* Define a "default" dataset access property list cache structure to use for default DAPLs */ +static H5CX_dapl_cache_t H5CX_def_dapl_cache; + /* Declare a static free list to manage H5CX_node_t structs */ H5FL_DEFINE_STATIC(H5CX_node_t); @@ -398,6 +426,7 @@ H5CX__init_package(void) H5P_genplist_t *dx_plist; /* Data transfer property list */ H5P_genplist_t *la_plist; /* Link access property list */ H5P_genplist_t *dc_plist; /* Dataset creation property list */ + H5P_genplist_t *da_plist; /* Dataset access property list */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -511,6 +540,32 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") + if(H5P_get(dc_plist, H5VL_PROP_DSET_TYPE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") + if(H5P_get(dc_plist, H5VL_PROP_DSET_SPACE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") + if(H5P_get(dc_plist, H5VL_PROP_DSET_LCPL_ID, &H5CX_def_dcpl_cache.vl_prop_dset_lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + + + + /* Reset the "default DAPL cache" information */ + HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); + + /* Get the default DAPL cache information */ + + /* Get the default dataset access property list */ + if(NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") + + /* Get the prefix for the external file */ + if(H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for external file") + + /* Get the prefix for the VDS file */ + if(H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for VDS") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__init_package() */ @@ -634,6 +689,8 @@ H5CX__push_common(H5CX_node_t *cnode) /* Set non-zero context info */ cnode->ctx.dxpl_id = H5P_DATASET_XFER_DEFAULT; + cnode->ctx.dcpl_id = H5P_DATASET_CREATE_DEFAULT; + cnode->ctx.dapl_id = H5P_DATASET_ACCESS_DEFAULT; cnode->ctx.lapl_id = H5P_LINK_ACCESS_DEFAULT; cnode->ctx.tag = H5AC__INVALID_TAG; cnode->ctx.ring = H5AC_RING_USER; @@ -1083,6 +1140,7 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, *acspl_id = *libclass->def_plist_id; else { htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property list */ + htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property list */ #ifdef H5CX_DEBUG /* Sanity check the access property list class */ @@ -1096,6 +1154,12 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, else if(is_lapl) (*head)->ctx.lapl_id = *acspl_id; + /* Check for dataset access property and set API context if so */ + if((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for dataset access class") + else if(is_dapl) + (*head)->ctx.dapl_id = *acspl_id; + #ifdef H5_HAVE_PARALLEL /* If this routine is not guaranteed to be collective (i.e. it doesn't * modify the structural metadata in a file), check if the application @@ -2324,6 +2388,180 @@ done: /*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_type_id + * + * Purpose: Retrieves the datatype ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_type_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_type_id); + + /* Get the value */ + *dset_type_id = (*head)->ctx.vl_prop_dset_type_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_type_id */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_space_id + * + * Purpose: Retrieves the space ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_space_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_SPACE_ID, vl_prop_dset_space_id); + + /* Get the value */ + *dset_space_id = (*head)->ctx.vl_prop_dset_space_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_space_id */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_space_id + * + * Purpose: Retrieves the LCPL ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_lcpl_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_lcpl_id); + + /* Get the value */ + *dset_lcpl_id = (*head)->ctx.vl_prop_dset_lcpl_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_lcpl_id */ + + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_ext_file_prefix + * + * Purpose: Retrieves the prefix for external file + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 6, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_ext_file_prefix(char **extfile_prefix) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(extfile_prefix); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); + + H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_EFILE_PREFIX_NAME, extfile_prefix); + + /* Get the value */ + *extfile_prefix = (*head)->ctx.extfile_prefix; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_ext_file_prefix */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vds_prefix + * + * Purpose: Retrieves the prefix for VDS + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 6, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vds_prefix(char **vds_prefix) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(vds_prefix); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); + + H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_VDS_PREFIX_NAME, vds_prefix); + + /* Get the value */ + *vds_prefix = (*head)->ctx.vds_prefix; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vds_prefix */ + + +/*------------------------------------------------------------------------- * Function: H5CX_set_tag * * Purpose: Sets the object tag for the current API call context. @@ -2639,6 +2877,106 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_type_id + * + * Purpose: Sets the datatype ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_type_id = dset_type_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_type_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vl_prop_dset_type_id */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_space_id + * + * Purpose: Sets the data space ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_space_id = dset_space_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_space_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vl_prop_dset_space_id */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_lcpl_id + * + * Purpose: Sets the LCPL ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_lcpl_id = dset_lcpl_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_lcpl_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 80f1ac4..f022d8e 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -126,6 +126,13 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); +H5_DLL herr_t H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id); +H5_DLL herr_t H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id); +H5_DLL herr_t H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id); + +/* "Getter" routines for DAPL properties cached in API context */ +H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile); +H5_DLL herr_t H5CX_get_vds_prefix(char **prefix_vds); /* "Setter" routines for API context info */ H5_DLL void H5CX_set_tag(haddr_t tag); @@ -145,6 +152,11 @@ H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); +/* "Setter" routines for DCPL properties cached in API context */ +H5_DLL herr_t H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id); +H5_DLL herr_t H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id); +H5_DLL herr_t H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id); + /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); diff --git a/src/H5D.c b/src/H5D.c index fc350f2..a50518d 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -135,6 +135,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "dcpl_id is not a dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -148,12 +151,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") - if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); + H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -228,6 +228,9 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -241,10 +244,8 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 76827b4..70e6f70 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -136,6 +136,9 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -145,12 +148,9 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") - if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); + H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Dint.c b/src/H5Dint.c index 384c66b..ae9a40e 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -488,9 +488,6 @@ H5D__new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) new_dset->dcpl_id = H5P_copy_plist(plist, FALSE); } /* end else */ - /* Set the DCPL for the API context */ - H5CX_set_dcpl(new_dset->dcpl_id); - /* Set return value */ ret_value = new_dset; @@ -1083,8 +1080,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, - char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1105,20 +1101,22 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) + if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) { prefix = HDgetenv("HDF5_VDS_PREFIX"); - else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) + + if(prefix == NULL || *prefix == '\0') { + if(H5CX_get_vds_prefix(&prefix) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") + } + } else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) { prefix = HDgetenv("HDF5_EXTFILE_PREFIX"); - else - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible") - if(prefix == NULL || *prefix == '\0') { - /* Set prefix to value of prefix_type property */ - if(NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, prefix_type, &prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file prefix") - } /* end if */ + if(prefix == NULL || *prefix == '\0') { + if(H5CX_get_ext_file_prefix(&prefix) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") + } + } else + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible") /* Prefix has to be checked for NULL / empty string again because the * code above might have updated it. @@ -1552,8 +1550,10 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - vds_prefix = (char *)H5MM_xfree(vds_prefix); + if(extfile_prefix) + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + if(vds_prefix) + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 8f7351c..ac25c55 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -18,6 +18,7 @@ #define H5D_FRIEND /* Suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ @@ -62,12 +63,9 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + H5CX_get_vl_prop_dset_type_id(&type_id); + H5CX_get_vl_prop_dset_space_id(&space_id); + H5CX_get_vl_prop_dset_lcpl_id(&lcpl_id); /* Check arguments */ if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) -- cgit v0.12 From 9622aac313d38196b7f879f87bd0a3920e4af103 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Fri, 22 Mar 2019 09:53:15 -0500 Subject: HDFFV-10658: 1. moving HDgetenv to dataset initialization stage to reduce the overhead; 2. restoring the retrieval of three vol properties to H5P_get instead of using API context to prepare for Quincey's upcoming refactoring work. --- src/H5CX.c | 223 ------------------------------------------------------ src/H5CXprivate.h | 8 -- src/H5D.c | 15 ++-- src/H5Ddeprec.c | 9 ++- src/H5Dint.c | 40 ++++++---- 5 files changed, 42 insertions(+), 253 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index 2bfe559..08e8c3f 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -281,12 +281,6 @@ typedef struct H5CX_t { /* Cached DCPL properties */ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - hid_t vl_prop_dset_type_id; - hbool_t vl_prop_dset_type_id_valid; - hid_t vl_prop_dset_space_id; - hbool_t vl_prop_dset_space_id_valid; - hid_t vl_prop_dset_lcpl_id; - hbool_t vl_prop_dset_lcpl_id_valid; /* Cached DAPL properties */ char *extfile_prefix; @@ -352,9 +346,6 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hid_t vl_prop_dset_type_id; - hid_t vl_prop_dset_space_id; - hid_t vl_prop_dset_lcpl_id; } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -540,14 +531,6 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - if(H5P_get(dc_plist, H5VL_PROP_DSET_TYPE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_SPACE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_LCPL_ID, &H5CX_def_dcpl_cache.vl_prop_dset_lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") - - /* Reset the "default DAPL cache" information */ HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); @@ -2388,112 +2371,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_type_id - * - * Purpose: Retrieves the datatype ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_type_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_type_id); - - /* Get the value */ - *dset_type_id = (*head)->ctx.vl_prop_dset_type_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_type_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the space ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_space_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_SPACE_ID, vl_prop_dset_space_id); - - /* Get the value */ - *dset_space_id = (*head)->ctx.vl_prop_dset_space_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_space_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the LCPL ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_lcpl_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_lcpl_id); - - /* Get the value */ - *dset_lcpl_id = (*head)->ctx.vl_prop_dset_lcpl_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_lcpl_id */ - - - -/*------------------------------------------------------------------------- * Function: H5CX_get_ext_file_prefix * * Purpose: Retrieves the prefix for external file @@ -2877,106 +2754,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_type_id - * - * Purpose: Sets the datatype ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_type_id = dset_type_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_type_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_type_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_space_id - * - * Purpose: Sets the data space ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_space_id = dset_space_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_space_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_space_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_lcpl_id - * - * Purpose: Sets the LCPL ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_lcpl_id = dset_lcpl_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_lcpl_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index f022d8e..2248ac9 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -126,9 +126,6 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); -H5_DLL herr_t H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id); /* "Getter" routines for DAPL properties cached in API context */ H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile); @@ -152,11 +149,6 @@ H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); -/* "Setter" routines for DCPL properties cached in API context */ -H5_DLL herr_t H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id); - /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); diff --git a/src/H5D.c b/src/H5D.c index a50518d..413be37 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -151,9 +151,12 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -244,8 +247,10 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 70e6f70..85371ae 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -148,9 +148,12 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Dint.c b/src/H5Dint.c index ae9a40e..7367613 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -43,6 +43,12 @@ /* Local Typedefs */ /******************/ +/* Type of prefix for file */ +typedef enum { + H5D_PREFIX_TYPE_UNKNOWN=0, + H5D_PREFIX_TYPE_EXT=1, + H5D_PREFIX_TYPE_VDS=2 +} H5D_prefix_type_t; /********************/ /* Local Prototypes */ @@ -54,7 +60,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); -static herr_t H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix); +static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); @@ -112,6 +118,10 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ /* Flag indicating "top" of interface has been initialized */ static hbool_t H5D_top_package_initialize_s = FALSE; +/* Prefixes of VDS and external file from the environment variables + * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ +static char *H5D_prefix_ext_env = NULL; +static char *H5D_prefix_vds_env = NULL; /*------------------------------------------------------------------------- @@ -188,6 +198,10 @@ H5D__init_package(void) /* Mark "top" of interface as initialized, too */ H5D_top_package_initialize_s = TRUE; + /* Retrieve the prefixes of VDS and external file from the environment variable */ + H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX"); + H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX"); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_package() */ @@ -1080,7 +1094,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1101,15 +1115,15 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_VDS_PREFIX"); + if(H5D_PREFIX_TYPE_VDS == prefix_type) { + prefix = H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } - } else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_EXTFILE_PREFIX"); + } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { + prefix = H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) @@ -1324,11 +1338,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &new_dset->shared->extfile_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &new_dset->shared->vds_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ @@ -1483,11 +1497,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &extfile_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &vds_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ @@ -1550,10 +1564,8 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - if(extfile_prefix) - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - if(vds_prefix) - vds_prefix = (char *)H5MM_xfree(vds_prefix); + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ -- cgit v0.12 From e09e2fc4ad7aadef1a99573ee6d3cec9bea3becb Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Fri, 22 Mar 2019 10:03:06 -0500 Subject: HDFFV-10658: I left out this file in my previous commit. --- src/H5VLnative_dataset.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index ac25c55..aa65e54 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -18,7 +18,6 @@ #define H5D_FRIEND /* Suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ @@ -62,10 +61,12 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - /* Get creation properties */ - H5CX_get_vl_prop_dset_type_id(&type_id); - H5CX_get_vl_prop_dset_space_id(&space_id); - H5CX_get_vl_prop_dset_lcpl_id(&lcpl_id); + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") /* Check arguments */ if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) -- cgit v0.12 From 50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 4 Apr 2019 11:03:05 -0500 Subject: This commit basically has the following changes: 1. restored the datatype, dataspace, and LCPL of the dataset for VOL connector back to the properties. 2. splitted external.c and vds.c because they called HDsetenv in the program, instead using shell scripts to set the environment variables. 3. changed H5CX_get_vds_prefix and H5CX_get_ext_file_prefix to use H5P_peek instead of H5P_get. --- configure.ac | 2 + src/H5CX.c | 54 +++++++- src/H5Dint.c | 8 +- test/Makefile.am | 18 ++- test/external.c | 231 +------------------------------ test/external.h | 144 +++++++++++++++++++ test/external_env.c | 219 +++++++++++++++++++++++++++++ test/testexternal_env.sh.in | 42 ++++++ test/testvds_env.sh.in | 44 ++++++ test/vds.c | 198 +-------------------------- test/vds_env.c | 326 ++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 848 insertions(+), 438 deletions(-) create mode 100644 test/external.h create mode 100644 test/external_env.c create mode 100644 test/testexternal_env.sh.in create mode 100644 test/testvds_env.sh.in create mode 100644 test/vds_env.c diff --git a/configure.ac b/configure.ac index 30fe725..6cc97e2 100644 --- a/configure.ac +++ b/configure.ac @@ -3477,10 +3477,12 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testabort_fail.sh test/testcheck_version.sh test/testerror.sh + test/testexternal_env.sh test/testflushrefresh.sh test/testlibinfo.sh test/testlinks_env.sh test/testswmr.sh + test/testvds_env.sh test/testvdsswmr.sh test/test_filter_plugin.sh test/test_usecases.sh diff --git a/src/H5CX.c b/src/H5CX.c index 08e8c3f..94d1f32 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -2390,18 +2390,41 @@ H5CX_get_ext_file_prefix(char **extfile_prefix) FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(extfile_prefix); HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); - H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_EFILE_PREFIX_NAME, extfile_prefix); + /* Check if the value has been retrieved already */ + if(!(*head)->ctx.extfile_prefix_valid) { + /* Check for default DAPL */ + if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + (*head)->ctx.extfile_prefix = H5CX_def_dapl_cache.extfile_prefix; + else { + /* Check if the property list is already available */ + if(NULL == (*head)->ctx.dapl) + /* Get the dataset access property list pointer */ + if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + + /* Get the prefix for the external file */ + /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need + * to copy it and free this in the H5CX pop routine. -QAK) + */ + if(H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve external file prefix") + } /* end else */ + + /* Mark the value as valid */ + (*head)->ctx.extfile_prefix_valid = TRUE; + } /* end if */ /* Get the value */ *extfile_prefix = (*head)->ctx.extfile_prefix; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_ext_file_prefix */ +} /* end H5CX_get_ext_file_prefix() */ /*------------------------------------------------------------------------- @@ -2424,18 +2447,41 @@ H5CX_get_vds_prefix(char **vds_prefix) FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(vds_prefix); HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); - H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_VDS_PREFIX_NAME, vds_prefix); + /* Check if the value has been retrieved already */ + if(!(*head)->ctx.vds_prefix_valid) { + /* Check for default DAPL */ + if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + (*head)->ctx.vds_prefix = H5CX_def_dapl_cache.vds_prefix; + else { + /* Check if the property list is already available */ + if(NULL == (*head)->ctx.dapl) + /* Get the dataset access property list pointer */ + if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + + /* Get the prefix for the VDS */ + /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need + * to copy it and free this in the H5CX pop routine. -QAK) + */ + if(H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VDS prefix") + } /* end else */ + + /* Mark the value as valid */ + (*head)->ctx.vds_prefix_valid = TRUE; + } /* end if */ /* Get the value */ *vds_prefix = (*head)->ctx.vds_prefix; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vds_prefix */ +} /* end H5CX_get_vds_prefix() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dint.c b/src/H5Dint.c index 7367613..bdd43cf 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -120,8 +120,8 @@ static hbool_t H5D_top_package_initialize_s = FALSE; /* Prefixes of VDS and external file from the environment variables * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ -static char *H5D_prefix_ext_env = NULL; -static char *H5D_prefix_vds_env = NULL; +const static char *H5D_prefix_ext_env = NULL; +const static char *H5D_prefix_vds_env = NULL; /*------------------------------------------------------------------------- @@ -1116,14 +1116,14 @@ H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char ** * to be reentrant. */ if(H5D_PREFIX_TYPE_VDS == prefix_type) { - prefix = H5D_prefix_vds_env; + prefix = (char *)H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { - prefix = H5D_prefix_ext_env; + prefix = (char *)H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) diff --git a/test/Makefile.am b/test/Makefile.am index 88dc542..68b9394 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,21 +26,23 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlibinfo.sh: # testcheck_version.sh: tcheck_version # testlinks_env.sh: links_env +# testexternal_env.sh: external_env # testflushrefresh.sh: flushrefresh +# testvds_env.sh: vds_env # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* # testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c # test_filter_plugin.sh: filter_plugin.c # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes -TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \ - testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ + testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ - filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ + external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) swmr_writer$(EXEEXT) \ swmr_remove_reader$(EXEEXT) swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) \ swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ - vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) + vds_env$(EXEEXT) vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) @@ -69,21 +71,23 @@ TEST_PROG= testhdf5 \ # accum_swmr_reader is used by accum.c. # atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh +# external_env is used by testexternal_env.sh # filenotclosed and del_many_dense_attrs are used by testabort_fail.sh # flushrefresh is used by testflushrefresh.sh. # use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # swmr_* files (besides swmr.c) are used by testswmr.sh. # vds_swmr_* files are used by testvdsswmr.sh +# vds_env is used by testvds_env.sh # 'make check' doesn't run them directly, so they are not included in TEST_PROG. # Also build testmeta, which is used for timings test. It builds quickly, # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ - testmeta accum_swmr_reader atomic_writer atomic_reader \ + testmeta accum_swmr_reader atomic_writer atomic_reader external_env \ links_env filenotclosed del_many_dense_attrs flushrefresh \ use_append_chunk use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ - swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer + swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vol_plugin endif @@ -223,7 +227,7 @@ use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ - testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ + testexternal_env.sh testswmr.sh testvds_env.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ test_vol_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/external.c b/test/external.c index 20a9ed8..5ff65e6 100644 --- a/test/external.c +++ b/test/external.c @@ -18,24 +18,7 @@ * Purpose: Tests datasets stored in external raw files. */ #include "h5test.h" - -const char *FILENAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; - -/* A similar collection of files is used for the tests that - * perform file I/O. - */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 +#include "external.h" /*------------------------------------------------------------------------- @@ -99,106 +82,6 @@ out: /*------------------------------------------------------------------------- - * Function: reset_raw_data_files - * - * Purpose: Resets the data in the raw data files for tests that - * perform dataset I/O on a set of files. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -reset_raw_data_files(void) -{ - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ - - /* Set up garbage buffer */ - garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) - goto error; - for(i = 0; i < garbage_count; i++) - garbage[i] = 0xFF; - - /* The *r files are pre-filled with data and are used to - * verify that read operations work correctly. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { - data[j] = (int)(i * 25 + j); - } /* end for */ - - /* Write raw data to the file. */ - n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - - /* The *w files are only pre-filled with the garbage data and are - * used to verify that write operations work correctly. The individual - * tests fill in the actual data. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - HDfree(garbage); - return SUCCEED; - -error: - if(fd) - HDclose(fd); - if(garbage) - HDfree(garbage); - return FAIL; -} /* end reset_raw_data_files() */ - - -/*------------------------------------------------------------------------- * Function: test_non_extendible * * Purpose: Tests a non-extendible dataset with a single external file. @@ -1297,116 +1180,6 @@ error: /*------------------------------------------------------------------------- - * Function: test_path_env - * - * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite - * the efile_prefix dataset access property. - * This will create an HDF5 file in a subdirectory which will - * refer to ../extern_*a.raw - * The files are then accessed by setting the HDF5_EXTFILE_PREFIX - * environment variable to "${ORIGIN}". - * The efile_prefix dataset access property is set to "someprefix", - * which will cause an error if the value is not overwritten by - * the environment variable. - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Steffen Kiess - * March 10, 2015 - * - *------------------------------------------------------------------------- - */ -static int -test_path_env(hid_t fapl) -{ - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ - - TESTING("prefix in HDF5_EXTFILE_PREFIX"); - - if(HDsetenv("HDF5_EXTFILE_PREFIX", "${ORIGIN}", 1)) - TEST_ERROR - - if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR; - - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR - - /* Reset the raw data files */ - if(reset_raw_data_files() < 0) - TEST_ERROR - - /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) - TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int) i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) - FAIL_STACK_ERROR - } /* end for */ - - cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) - FAIL_STACK_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if(H5Pset_efile_prefix(dapl, "someprefix") < 0) - FAIL_STACK_ERROR - if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) - FAIL_STACK_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("efile prefix not set correctly"); - - /* Create dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) - FAIL_STACK_ERROR - - /* Read the entire dataset and compare with the original */ - HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) - FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) - FAIL_PUTS_ERROR("Incorrect value(s) read."); - - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Dclose(dset); - H5Pclose(dcpl); - H5Sclose(space); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} /* end test_path_env() */ - - -/*------------------------------------------------------------------------- * Function: test_h5d_get_access_plist * * Purpose: Ensure that H5Dget_access_plist returns correct values. @@ -1585,7 +1358,6 @@ main(void) nerrors += test_path_absolute(current_fapl_id); nerrors += test_path_relative(current_fapl_id); nerrors += test_path_relative_cwd(current_fapl_id); - nerrors += test_path_env(current_fapl_id); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, current_fapl_id) < 0 ? 1 : 0); @@ -1630,4 +1402,3 @@ error: printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/external.h b/test/external.h new file mode 100644 index 0000000..1c660e1 --- /dev/null +++ b/test/external.h @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol + * Wednesday, March 17, 2010 + * + * Purpose: srcdir querying support. + */ +#ifndef _EXTERNAL_H +#define _EXTERNAL_H + +/* Include test header files */ +#include "h5test.h" + +const char *FILENAME[] = { + "extern_1", + "extern_2", + "extern_3", + "extern_4", + "extern_dir/file_1", + "extern_5", + NULL +}; + +/* A similar collection of files is used for the tests that + * perform file I/O. + */ +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 + + +/*------------------------------------------------------------------------- + * Function: reset_raw_data_files + * + * Purpose: Resets the data in the raw data files for tests that + * perform dataset I/O on a set of files. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * February 2016 + * + *------------------------------------------------------------------------- + */ +static herr_t +reset_raw_data_files(void) +{ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ + + /* Set up garbage buffer */ + garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; + if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + goto error; + for(i = 0; i < garbage_count; i++) + garbage[i] = 0xFF; + + /* The *r files are pre-filled with data and are used to + * verify that read operations work correctly. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Fill array with data */ + for(j = 0; j < PART_SIZE; j++) { + data[j] = (int)(i * 25 + j); + } /* end for */ + + /* Write raw data to the file. */ + n = HDwrite(fd, data, sizeof(data)); + if(n != sizeof(data)) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + + /* The *w files are only pre-filled with the garbage data and are + * used to verify that write operations work correctly. The individual + * tests fill in the actual data. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + HDfree(garbage); + return SUCCEED; + +error: + if(fd) + HDclose(fd); + if(garbage) + HDfree(garbage); + return FAIL; +} /* end reset_raw_data_files() */ +#endif /* _EXTERNAL_H */ + diff --git a/test/external_env.c b/test/external_env.c new file mode 100644 index 0000000..97daef2 --- /dev/null +++ b/test/external_env.c @@ -0,0 +1,219 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Purpose: Tests datasets stored in external raw files. + */ +#include "h5test.h" +#include "external.h" + + +/*------------------------------------------------------------------------- + * Function: test_path_env + * + * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite + * the efile_prefix dataset access property. + * This will create an HDF5 file in a subdirectory which will + * refer to ../extern_*a.raw + * The files are then accessed by setting the HDF5_EXTFILE_PREFIX + * environment variable to "${ORIGIN}". + * The efile_prefix dataset access property is set to "someprefix", + * which will cause an error if the value is not overwritten by + * the environment variable. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Steffen Kiess + * March 10, 2015 + * + *------------------------------------------------------------------------- + */ +static int +test_path_env(hid_t fapl) +{ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ + + TESTING("prefix in HDF5_EXTFILE_PREFIX"); + + if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR; + + h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Reset the raw data files */ + if(reset_raw_data_files() < 0) + TEST_ERROR + + /* Create the dataset */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + TEST_ERROR + for(i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int) i + 1); + if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + FAIL_STACK_ERROR + } /* end for */ + + cur_size = TOTAL_SIZE; + if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + FAIL_STACK_ERROR + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if(H5Pset_efile_prefix(dapl, "someprefix") < 0) + FAIL_STACK_ERROR + if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) + FAIL_STACK_ERROR + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("efile prefix not set correctly"); + + /* Create dataset */ + if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) + FAIL_STACK_ERROR + + /* Read the entire dataset and compare with the original */ + HDmemset(whole, 0, sizeof(whole)); + if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + FAIL_STACK_ERROR + for(i = 0; i < TOTAL_SIZE; i++) + if(whole[i] != (signed)i) + FAIL_PUTS_ERROR("Incorrect value(s) read."); + + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Sclose(space) < 0) FAIL_STACK_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dapl); + H5Dclose(dset); + H5Pclose(dcpl); + H5Sclose(space); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_path_env() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Runs external dataset tests. + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + char filename[1024]; /* file name for test_1* funcs */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ + + h5_reset(); + + /* Get a fapl for the old (default) file format */ + fapl_id_old = h5_fileaccess(); + h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + + /* Copy and set up a fapl for the latest file format */ + if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) + FAIL_STACK_ERROR + if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Test with old & new format groups */ + for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { + hid_t current_fapl_id = -1; + + /* Set the fapl for different file formats */ + if(latest_format) { + HDputs("\nTesting with the latest file format:"); + current_fapl_id = fapl_id_new; + } /* end if */ + else { + HDputs("Testing with the default file format:"); + current_fapl_id = fapl_id_old; + } /* end else */ + + nerrors += test_path_env(current_fapl_id); + } /* end for */ + + if(nerrors > 0) goto error; + + /* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */ + if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR + + HDputs("All external storage tests passed."); + + /* Clean up files used by file set tests */ + if(h5_cleanup(FILENAME, fapl_id_old)) { + HDremove("extern_1r.raw"); + HDremove("extern_2r.raw"); + HDremove("extern_3r.raw"); + HDremove("extern_4r.raw"); + + HDremove("extern_1w.raw"); + HDremove("extern_2w.raw"); + HDremove("extern_3w.raw"); + HDremove("extern_4w.raw"); + + HDrmdir("extern_dir"); + } /* end if */ + + return EXIT_SUCCESS; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fapl_id_old); + H5Pclose(fapl_id_new); + H5Gclose(gid); + } H5E_END_TRY; + nerrors = MAX(1, nerrors); + printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); + return EXIT_FAILURE; +} /* end main() */ + diff --git a/test/testexternal_env.sh.in b/test/testexternal_env.sh.in new file mode 100644 index 0000000..dff3851 --- /dev/null +++ b/test/testexternal_env.sh.in @@ -0,0 +1,42 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_EXTFILE_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for external file with HDF5_EXTFILE_PREFIX +echo "Testing external file with HDF5_EXTFILE_PREFIX" +TEST_NAME=external_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_EXTFILE_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_EXTFILE_PREFIX test***" +fi +exit $nerrors diff --git a/test/testvds_env.sh.in b/test/testvds_env.sh.in new file mode 100644 index 0000000..870f2eb --- /dev/null +++ b/test/testvds_env.sh.in @@ -0,0 +1,44 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_VDS_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for VDS with HDF5_VDS_PREFIX +echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" +TEST_NAME=vds_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp" # Set the environment variable & value +UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_VDS_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_VDS_PREFIX test***" +fi +$UNENVCMD +exit $nerrors diff --git a/test/vds.c b/test/vds.c index 67af8e3..ad77030 100644 --- a/test/vds.c +++ b/test/vds.c @@ -1119,7 +1119,7 @@ error: } /* end test_api() */ /*------------------------------------------------------------------------- - * Function: vds_link_prefix + * Function: test_vds_prefix_first * * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" * Should be able to access the target source files in tmp directory via the prefix set @@ -1130,18 +1130,16 @@ error: *------------------------------------------------------------------------- */ static int -test_vds_prefix(unsigned config, hid_t fapl) +test_vds_prefix_first(unsigned config, hid_t fapl) { char srcfilename[FILENAME_BUF_SIZE]; char srcfilename_map[FILENAME_BUF_SIZE]; char vfilename[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; char srcfilenamepct[FILENAME_BUF_SIZE]; char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ - hid_t vfile2 = -1; /* File with copied virtual dset */ hid_t dcpl = -1; /* Dataset creation property list */ hid_t dapl = -1; /* Dataset access property list */ hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ @@ -1156,10 +1154,9 @@ test_vds_prefix(unsigned config, hid_t fapl) int i, j; char buffer[1024]; /* buffer to read vds_prefix */ - TESTING("basic virtual dataset I/O via H5Pset_vds_prefix()") + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection") h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[7], fapl, vfilename2, sizeof vfilename2); h5_fixname(FILENAME[8], fapl, srcfilename, sizeof srcfilename); h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, sizeof srcfilename_map); h5_fixname(FILENAME[10], fapl, srcfilenamepct, sizeof srcfilenamepct); @@ -1189,9 +1186,6 @@ test_vds_prefix(unsigned config, hid_t fapl) if(HDstrcmp(buffer, TMPDIR) != 0) FAIL_PUTS_ERROR("vds prefix not set correctly"); - /* - * Test 1: All - all selection - */ /* Create source dataspace */ if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR @@ -1344,187 +1338,6 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR dcpl = -1; - /* - * Test 2: All - all selection with ENV prefix - */ - if(HDsetenv("HDF5_VDS_PREFIX", "${ORIGIN}/tmp", 1)) - TEST_ERROR - - /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR - - /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) - TEST_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - TEST_ERROR - - if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) - TEST_ERROR - if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) - TEST_ERROR - - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("vds prefix not set correctly"); - - /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) - TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) - TEST_ERROR - - /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) - TEST_ERROR - - /* Create virtual file */ - if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - else { - srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) - TEST_ERROR - } - - /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR - - /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR - - /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; - - /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - } - } - - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) - TEST_ERROR - } - - /* Read data through virtual dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) { - TEST_ERROR - } - } - - /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); - - /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) - TEST_ERROR - } - - /* Read data directly from source dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) - TEST_ERROR - - /* Close */ - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if(H5Sclose(srcspace[0]) < 0) - TEST_ERROR - srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) - TEST_ERROR - vspace[0] = -1; - if(H5Pclose(dapl) < 0) - TEST_ERROR - dapl = -1; - if(H5Pclose(dcpl) < 0) - TEST_ERROR - dcpl = -1; - - if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) - TEST_ERROR - PASSED(); return 0; @@ -1536,7 +1349,6 @@ test_vds_prefix(unsigned config, hid_t fapl) for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - H5Fclose(vfile2); for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) @@ -1550,7 +1362,7 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR return 1; -} /* end vds_link_prefix() */ +} /* end test_vds_prefix */ /*------------------------------------------------------------------------- @@ -11621,7 +11433,7 @@ main(void) for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); nerrors += test_basic_io(bit_config, fapl); - nerrors += test_vds_prefix(bit_config, fapl); + nerrors += test_vds_prefix_first(bit_config, fapl); nerrors += test_unlim(bit_config, fapl); nerrors += test_printf(bit_config, fapl); nerrors += test_all(bit_config, fapl); diff --git a/test/vds_env.c b/test/vds_env.c new file mode 100644 index 0000000..d73336d --- /dev/null +++ b/test/vds_env.c @@ -0,0 +1,326 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Neil Fortner + * Monday, February 16, 2015 + * + * Purpose: Tests datasets with virtual layout. + */ +#include "h5test.h" + +const char *FILENAME[] = { + "vds_virt_0", + "vds_virt_3", + "vds_src_2", + "vds%%_src2", + NULL +}; + +/* I/O test config flags */ +#define TEST_IO_CLOSE_SRC 0x01u +#define TEST_IO_DIFFERENT_FILE 0x02u +#define TEST_IO_REOPEN_VIRT 0x04u +#define TEST_IO_NTESTS 0x08u + +#define FILENAME_BUF_SIZE 1024 + +#define TMPDIR "tmp/" + +/*------------------------------------------------------------------------- + * Function: test_vds_prefix_second + * + * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" + * Should be able to access the target source files in tmp directory via the prefix set + * by H5Pset_virtual_prefix() + * + * Return: Success: 0 + * Failure: -1 + *------------------------------------------------------------------------- + */ +static int +test_vds_prefix_second(unsigned config, hid_t fapl) +{ + char srcfilename[FILENAME_BUF_SIZE]; + char srcfilename_map[FILENAME_BUF_SIZE]; + char vfilename[FILENAME_BUF_SIZE]; + char vfilename2[FILENAME_BUF_SIZE]; + char srcfilenamepct[FILENAME_BUF_SIZE]; + char srcfilenamepct_map[FILENAME_BUF_SIZE]; + const char *srcfilenamepct_map_orig = "vds%%%%_src"; + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int fill = -1; /* Fill value */ + int i, j; + char buffer[1024]; /* buffer to read vds_prefix */ + + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix") + + h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); + h5_fixname(FILENAME[1], fapl, vfilename2, sizeof vfilename2); + h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); + h5_fixname(FILENAME[3], fapl, srcfilenamepct, sizeof srcfilenamepct); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + + /* create tmp directory and get current working directory path */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* Create DCPL */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + TEST_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR + + if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) + TEST_ERROR + if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) + TEST_ERROR + + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("vds prefix not set correctly"); + + /* Create source dataspace */ + if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Select all (should not be necessary, but just to be sure) */ + if(H5Sselect_all(srcspace[0]) < 0) + TEST_ERROR + if(H5Sselect_all(vspace[0]) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + TEST_ERROR + + /* Create virtual file */ + if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create source file if requested */ + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + else { + srcfile[0] = vfile; + if(H5Iinc_ref(srcfile[0]) < 0) + TEST_ERROR + } + + /* Create source dataset */ + if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create virtual dataset */ + if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR + + /* Populate write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; + + /* Write data directly to source dataset */ + if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Close srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + + if(config & TEST_IO_DIFFERENT_FILE) { + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + } + } + + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } + + /* Read data through virtual dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) { + TEST_ERROR + } + } + + /* Adjust write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); + + /* Write data through virtual dataset */ + if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Reopen srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + } + + /* Read data directly from source dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) + TEST_ERROR + + /* Close */ + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if(H5Sclose(srcspace[0]) < 0) + TEST_ERROR + srcspace[0] = -1; + if(H5Sclose(vspace[0]) < 0) + TEST_ERROR + vspace[0] = -1; + if(H5Pclose(dapl) < 0) + TEST_ERROR + dapl = -1; + if(H5Pclose(dcpl) < 0) + TEST_ERROR + dcpl = -1; + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5Dclose(srcdset[i]); + H5Dclose(vdset); + for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + H5Fclose(srcfile[i]); + H5Fclose(vfile); + for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + H5Sclose(srcspace[i]); + for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + H5Sclose(vspace[i]); + H5Sclose(memspace); + H5Pclose(dapl); + H5Pclose(dcpl); + } H5E_END_TRY; + + return 1; +} /* end test_vds_prefix2 */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests datasets with virtual layout + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fapl; + int test_api_config; + unsigned bit_config; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + fapl = h5_fileaccess(); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + + if(nerrors) + goto error; + HDprintf("All virtual dataset tests passed.\n"); + h5_cleanup(FILENAME, fapl); + + return EXIT_SUCCESS; + +error: + nerrors = MAX(1, nerrors); + HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return EXIT_FAILURE; +} /* end main() */ -- cgit v0.12 From 2886cd9e45b7f809a543a564929118c6145eb332 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Sat, 6 Apr 2019 16:55:14 -0500 Subject: HDFFV-10365: Changes as described in the RFC: H5Sencode/H5Sdecode Format Change. This also addresses HDFFV-10255: H5Sencode/decode performance issue. --- MANIFEST | 1 + fortran/src/H5Sf.c | 6 +- fortran/src/H5Sff.F90 | 13 +- fortran/src/H5f90proto.h | 2 +- fortran/test/tH5MISC_1_8.F90 | 33 +- java/src/jni/h5sImp.c | 4 +- src/H5Dmpio.c | 3 + src/H5Dvirtual.c | 4 + src/H5P.c | 19 +- src/H5Pdeprec.c | 48 +++ src/H5Ppublic.h | 3 +- src/H5Rint.c | 3 + src/H5S.c | 22 +- src/H5Sall.c | 2 +- src/H5Sdeprec.c | 121 ++++++ src/H5Shyper.c | 880 +++++++++++++++++++++++++++++++++---------- src/H5Snone.c | 2 +- src/H5Spkg.h | 31 +- src/H5Spoint.c | 334 +++++++++++++--- src/H5Spublic.h | 12 +- src/H5vers.txt | 2 + src/Makefile.am | 2 +- test/enc_dec_plist.c | 878 +++++++++++++++++++++++------------------- test/gen_plist.c | 4 +- test/th5s.c | 708 +++++++++++++++++++++++++++++++--- test/trefer.c | 58 +-- test/vds.c | 84 ++++- testpar/t_prop.c | 4 +- 28 files changed, 2507 insertions(+), 776 deletions(-) create mode 100644 src/H5Sdeprec.c diff --git a/MANIFEST b/MANIFEST index 7cb2cfd..16f62b1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -847,6 +847,7 @@ ./src/H5S.c ./src/H5Sall.c ./src/H5Sdbg.c +./src/H5Sdeprec.c ./src/H5Shyper.c ./src/H5Smodule.h ./src/H5Smpio.c diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c index 96540f7..8abea25 100644 --- a/fortran/src/H5Sf.c +++ b/fortran/src/H5Sf.c @@ -1149,7 +1149,7 @@ h5sdecode_c ( _fcd buf, hid_t_f *obj_id ) */ int_f -h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ) +h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id ) /******/ { int ret_value = -1; @@ -1162,7 +1162,7 @@ h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ) if (*nalloc == 0) { - if(H5Sencode((hid_t)*obj_id, c_buf, &c_size) < 0) + if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0) return ret_value; *nalloc = (size_t_f)c_size; @@ -1180,7 +1180,7 @@ h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ) /* * Call H5Sencode function. */ - if(H5Sencode((hid_t)*obj_id, c_buf, &c_size) < 0){ + if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0){ return ret_value; } diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90 index 3af7755..bd3dcf4 100644 --- a/fortran/src/H5Sff.F90 +++ b/fortran/src/H5Sff.F90 @@ -1379,25 +1379,32 @@ CONTAINS ! M. Scot Breitenfeld ! March 26, 2008 ! SOURCE - SUBROUTINE h5sencode_f(obj_id, buf, nalloc, hdferr) + SUBROUTINE h5sencode_f(obj_id, buf, nalloc, hdferr, fapl_id) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: obj_id CHARACTER(LEN=*), INTENT(OUT) :: buf INTEGER(SIZE_T), INTENT(INOUT) :: nalloc INTEGER, INTENT(OUT) :: hdferr + INTEGER(HID_T), OPTIONAL, INTENT(IN) :: fapl_id ! File access property list !***** + INTEGER(HID_T) :: fapl_id_default INTERFACE - INTEGER FUNCTION h5sencode_c(buf, obj_id, nalloc) BIND(C,NAME='h5sencode_c') + INTEGER FUNCTION h5sencode_c(buf, obj_id, nalloc, fapl_id_default) BIND(C,NAME='h5sencode_c') IMPORT :: C_CHAR IMPORT :: HID_T, SIZE_T INTEGER(HID_T), INTENT(IN) :: obj_id CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: buf INTEGER(SIZE_T), INTENT(INOUT) :: nalloc + INTEGER(HID_T) :: fapl_id_default END FUNCTION h5sencode_c END INTERFACE - hdferr = h5sencode_c(buf, obj_id, nalloc) + fapl_id_default = H5P_DEFAULT_F + + IF(PRESENT(fapl_id)) fapl_id_default = fapl_id + + hdferr = h5sencode_c(buf, obj_id, nalloc, fapl_id_default) END SUBROUTINE h5sencode_f diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index fada004..554ad0f 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -121,7 +121,7 @@ H5_FCDLL int_f h5sselect_hyperslab_c( hid_t_f *space_id , int_f *op, hsize_t_f * H5_FCDLL int_f h5sget_select_type_c( hid_t_f *space_id , int_f *op); H5_FCDLL int_f h5sselect_elements_c( hid_t_f *space_id , int_f *op, size_t_f *nelements, hsize_t_f *coord); H5_FCDLL int_f h5sdecode_c( _fcd buf, hid_t_f *obj_id ); -H5_FCDLL int_f h5sencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ); +H5_FCDLL int_f h5sencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id ); H5_FCDLL int_f h5sextent_equal_c( hid_t_f * space1_id, hid_t_f *space2_id, hid_t_f *c_equal); /* diff --git a/fortran/test/tH5MISC_1_8.F90 b/fortran/test/tH5MISC_1_8.F90 index 79fbf3e..b8c777c 100644 --- a/fortran/test/tH5MISC_1_8.F90 +++ b/fortran/test/tH5MISC_1_8.F90 @@ -189,8 +189,9 @@ SUBROUTINE test_h5s_encode(total_error) INTEGER(hid_t) :: sid1, sid3! Dataspace ID INTEGER(hid_t) :: decoded_sid1, decoded_sid3 + INTEGER(hid_t) :: fapl ! File access property INTEGER :: rank ! LOGICAL rank of dataspace - INTEGER(size_t) :: sbuf_size=0, scalar_size=0 + INTEGER(size_t) :: new_size = 0, old_size = 0, orig_size=0, scalar_size=0 ! Make sure the size is large CHARACTER(LEN=288) :: sbuf @@ -228,18 +229,36 @@ SUBROUTINE test_h5s_encode(total_error) ! Encode simple data space in a buffer - ! First find the buffer size - CALL H5Sencode_f(sid1, sbuf, sbuf_size, error) - CALL check("H5Sencode", error, total_error) + ! Find the buffer size without fapl + CALL H5Sencode_f(sid1, sbuf, orig_size, error) + CALL check("H5Sencode_f", error, total_error) + CALL verify("H5Sencode_f", INT(orig_size), 279, total_error) + + ! Create file access property list + CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error) + CALL check("h5pcreate_f", error, total_error) + + ! Find the buffer size with fapl (default old format) + CALL H5Sencode_f(sid1, sbuf, old_size, error, fapl) + CALL check("H5Sencode_f", error, total_error) + CALL verify("H5Sencode_f", INT(old_size), 279, total_error) + ! Set fapl to latest file format + CALL H5Pset_libver_bounds_f(fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) + CALL check("H5Pset_libver_bounds_f",error, total_error) - ! Try decoding bogus buffer + ! Find the buffer size with fapl set to latest format + CALL H5Sencode_f(sid1, sbuf, new_size, error, fapl) + CALL check("H5Sencode_f", error, total_error) + CALL verify("H5Sencode_f", INT(new_size), 101, total_error) + ! Try decoding bogus buffer CALL H5Sdecode_f(sbuf, decoded_sid1, error) CALL verify("H5Sdecode", error, -1, total_error) - CALL H5Sencode_f(sid1, sbuf, sbuf_size, error) - CALL check("H5Sencode", error, total_error) + ! Encode according to the latest file format + CALL H5Sencode_f(sid1, sbuf, new_size, error, fapl) + CALL check("H5Sencode_f", error, total_error) ! Decode from the dataspace buffer and return an object handle CALL H5Sdecode_f(sbuf, decoded_sid1, error) diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index a91dab2..d8110a1 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -1141,7 +1141,7 @@ Java_hdf_hdf5lib_H5_H5Sencode if (obj_id < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: invalid object ID"); - if ((status = H5Sencode(obj_id, NULL, &buf_size)) < 0) + if ((status = H5Sencode2(obj_id, NULL, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (buf_size == 0) @@ -1150,7 +1150,7 @@ Java_hdf_hdf5lib_H5_H5Sencode if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); - if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0) + if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size))) diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index d23cb63..7019362 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -2742,6 +2742,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") + /* Set to latest format for encoding dataspace */ + H5CX_set_libver_bounds(NULL); + if (*local_chunk_array_num_entries) if (NULL == (send_requests = (MPI_Request *) H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests buffer") diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 6c0cfba..d38df1b 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -430,6 +430,10 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Create block if # of used entries > 0 */ if(layout->storage.u.virt.list_nused > 0) { + + /* Set the low/high bounds according to 'f' for the API context */ + H5CX_set_libver_bounds(f); + /* Allocate array for caching results of strlen */ if(NULL == (str_size = (size_t *)H5MM_malloc(2 * layout->storage.u.virt.list_nused * sizeof(size_t)))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array") diff --git a/src/H5P.c b/src/H5P.c index 72d7ae8..09ff7f0 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -817,14 +817,17 @@ done: /*-------------------------------------------------------------------------- NAME - H5Pencode + H5Pencode2 PURPOSE - Routine to convert the property values in a property list into a binary buffer + Routine to convert the property values in a property list into a binary buffer. + The encoding of property values will be done according to the file format + setting in fapl_id. USAGE - herr_t H5Pencode(plist_id, buf, nalloc) + herr_t H5Pencode(plist_id, buf, nalloc, fapl_id) hid_t plist_id; IN: Identifier to property list to encode void *buf: OUT: buffer to gold the encoded plist size_t *nalloc; IN/OUT: size of buffer needed to encode plist + hid_t fapl_id; IN: File access property list ID RETURNS Returns non-negative on success, negative on failure. DESCRIPTION @@ -837,25 +840,29 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pencode(hid_t plist_id, void *buf, size_t *nalloc) +H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id) { H5P_genplist_t *plist; /* Property list to query */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*x*z", plist_id, buf, nalloc); + H5TRACE4("e", "i*x*zi", plist_id, buf, nalloc, fapl_id); /* Check arguments. */ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Call the internal encode routine */ if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pencode() */ +} /* H5Pencode2() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index 4a63b36..f6c2a3c 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -486,6 +486,54 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_version() */ + +/*-------------------------------------------------------------------------- + NAME + H5Pencode1 + PURPOSE + Routine to convert the property values in a property list into a binary buffer + USAGE + herr_t H5Pencode1(plist_id, buf, nalloc) + hid_t plist_id; IN: Identifier to property list to encode + void *buf: OUT: buffer to gold the encoded plist + size_t *nalloc; IN/OUT: size of buffer needed to encode plist + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Encodes a property list into a binary buffer. If the buffer is NULL, then + the call will set the size needed to encode the plist in nalloc. Otherwise + the routine will encode the plist in buf. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc) +{ + H5P_genplist_t *plist; /* Property list to query */ + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*x*z", plist_id, buf, nalloc); + + /* Check arguments. */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Call the internal encode routine */ + if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pencode1() */ + /*------------------------------------------------------------------------- * Function: H5Pset_file_space * diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 078fe74..90e6618 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -236,7 +236,7 @@ H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); -H5_DLL herr_t H5Pencode(hid_t plist_id, void *buf, size_t *nalloc); +H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id); H5_DLL hid_t H5Pdecode(const void *buf); H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); @@ -536,6 +536,7 @@ H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc); H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter, unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]); diff --git a/src/H5Rint.c b/src/H5Rint.c index a4f76ce..9098a03 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -215,6 +215,9 @@ H5R__create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H obj_loc.path = &path; H5G_loc_reset(&obj_loc); + /* Set the FAPL for the API context */ + H5CX_set_libver_bounds(loc->oloc->file); + /* Find the object */ if(H5G_loc_find(loc, name, &obj_loc) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found") diff --git a/src/H5S.c b/src/H5S.c index 301060f..3926b5f 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -23,6 +23,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ @@ -1487,13 +1488,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5Sencode + * Function: H5Sencode2 * * Purpose: Given a dataspace ID, converts the object description * (including selection) into binary in a buffer. + * The selection will be encoded according to the file + * format setting in fapl. * * Return: Success: non-negative - * Failure: negative + * Failure: negative * * Programmer: Raymond Lu * slu@ncsa.uiuc.edu @@ -1502,24 +1505,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Sencode(hid_t obj_id, void *buf, size_t *nalloc) +H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl_id) { H5S_t *dspace; herr_t ret_value=SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); + H5TRACE4("e", "i*x*zi", obj_id, buf, nalloc, fapl_id); /* Check argument and retrieve object */ if(NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + if(H5S_encode(dspace, (unsigned char **)&buf, nalloc) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") done: FUNC_LEAVE_API(ret_value) -} /* end H5Sencode() */ +} /* H5Sencode2() */ /*------------------------------------------------------------------------- diff --git a/src/H5Sall.c b/src/H5Sall.c index 9823d36..7aa9644 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -629,7 +629,7 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c new file mode 100644 index 0000000..e4ec1b0 --- /dev/null +++ b/src/H5Sdeprec.c @@ -0,0 +1,121 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Sdeprec.c + * + * Purpose: Deprecated functions from the H5S interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Smodule.h" /* This source code file is part of the H5S module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/*------------------------------------------------------------------------- + * Function: H5Sencode1 + * + * Purpose: Given a dataspace ID, converts the object description + * (including selection) into binary in a buffer. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Raymond Lu + * slu@ncsa.uiuc.edu + * July 14, 2004 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc) +{ + H5S_t *dspace; + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value=SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); + + /* Check argument and retrieve object */ + if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Use (earliest, latest) i.e. not latest format */ + if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Sencode1() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 6d42ec1..a6494d9 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -28,13 +28,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -157,6 +158,13 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{ H5S__hyper_iter_init, }}; +/* Format version bounds for dataspace hyperslab selection */ +const unsigned H5O_sds_hyper_ver_bounds[] = { + H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */ + H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */ +}; /*******************/ /* Local Variables */ @@ -3204,8 +3212,9 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans) PURPOSE Get the number of hyperslab blocks in current hyperslab selection USAGE - hsize_t H5S__get_select_hyper_nblocks(space) + hsize_t H5S__get_select_hyper_nblocks(space, app_ref) H5S_t *space; IN: Dataspace ptr of selection to query + hbool_t app_ref; IN: Whether this is an appl. ref. call RETURNS The number of hyperslab blocks in selection on success, negative on failure DESCRIPTION @@ -3216,7 +3225,7 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans) REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__get_select_hyper_nblocks(const H5S_t *space) +H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) { hsize_t ret_value = 0; /* Return value */ @@ -3231,7 +3240,8 @@ H5S__get_select_hyper_nblocks(const H5S_t *space) /* Check each dimension */ for(ret_value = 1, u = 0; u < space->extent.rank; u++) - ret_value *= space->select.sel_info.hslab->app_diminfo[u].count; + ret_value *= (app_ref ? space->select.sel_info.hslab->app_diminfo[u].count : + space->select.sel_info.hslab->opt_diminfo[u].count); } /* end if */ else ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); @@ -3274,7 +3284,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) if(space->select.sel_info.hslab->unlim_dim >= 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get number of blocks for unlimited selection") - ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space); + ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space, TRUE); done: FUNC_LEAVE_API(ret_value) @@ -3283,6 +3293,210 @@ done: /*-------------------------------------------------------------------------- NAME + H5S__hyper_get_enc_size_real + PURPOSE + Determine the size to encode the hyperslab selection info + USAGE + hssize_t H5S__hyper_get_enc_size_real(max_size, enc_size) + hsize_t max_size: IN: The maximum size of the hyperslab selection info + unint8_t *enc_size: OUT:The encoding size + RETURNS + The size to encode hyperslab selection info + DESCRIPTION + Determine the size by comparing "max_size" with (2^32 - 1) and (2^16 - 1). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static uint8_t +H5S__hyper_get_enc_size_real(hsize_t max_size) +{ + uint8_t ret_value = H5S_SELECT_INFO_ENC_SIZE_2; + + FUNC_ENTER_STATIC_NOERR + + if(max_size > H5S_UINT32_MAX) + ret_value = H5S_SELECT_INFO_ENC_SIZE_8; + else if(max_size > H5S_UINT16_MAX) + ret_value = H5S_SELECT_INFO_ENC_SIZE_4; + else + ret_value = H5S_SELECT_INFO_ENC_SIZE_2; + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S__hyper_get_enc_size_real() */ + + +/*-------------------------------------------------------------------------- + NAME + H5S__hyper_get_version_enc_size + PURPOSE + Determine the version and encoded size to use for encoding hyperslab selection info + USAGE + hssize_t H5S__hyper_get_version_enc_size(space, block_count, version, enc_size) + const H5S_t *space: IN: The dataspace + hsize_t block_count: IN: The number of blocks in the selection + uint32_t *version: OUT: The version to use for encoding + uint8_t *enc_size: OUT: The encoded size to use + + RETURNS + The version and the size to encode hyperslab selection info + DESCRIPTION + Determine the version to use for encoding hyperslab selection info based + on the following: + (1) the file format setting in fapl + (2) whether the number of blocks or selection high bounds exceeds H5S_UINT32_MAX or not + + Determine the encoded size based on version: + For version 3, the encoded size is determined according to: + (a) regular hyperslab + (1) The maximum needed to store start/stride/count/block + (2) Special handling for count/block: need to provide room for H5S_UNLIMITED + (b) irregular hyperslab + The maximum size needed to store: + (1) the number of blocks + (2) the selection high bounds + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size) +{ + hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ + hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + htri_t is_regular; /* A regular hyperslab or not */ + uint32_t tmp_version; /* Local temporay version */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Get bounding box for the selection */ + HDmemset(bounds_end, 0, sizeof(bounds_end)); + + if(space->select.sel_info.hslab->unlim_dim < 0) { /* ! H5S_UNLIMITED */ + /* Get bounding box for the selection */ + if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") + } + + /* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */ + if(block_count > H5S_UINT32_MAX) + count_up_version = TRUE; + else { + for(u = 0; u < space->extent.rank; u++) + if(bounds_end[u] > H5S_UINT32_MAX) { + bound_up_version = TRUE; + break; + } + } + + /* Get the file's low_bound and high_bound */ + if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") + + /* Determine regular hyperslab */ + is_regular = H5S__hyper_is_regular(space); + + if(low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0) + tmp_version = MAX(H5S_HYPER_VERSION_2, H5O_sds_hyper_ver_bounds[low_bound]); + + else { + if(count_up_version || bound_up_version) + tmp_version = is_regular ? H5S_HYPER_VERSION_2 : H5S_HYPER_VERSION_3; + else + tmp_version = (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1; + + } + + /* Version bounds check */ + if(tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) { + /* Fail for irregular hyperslab if exceeds 32 bits */ + if(count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32") + else if(bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32") + else + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds") + } + + /* Set the message version */ + *version = tmp_version; + + /* Determine the encoded size based on version */ + switch(tmp_version) { + case H5S_HYPER_VERSION_1: + *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + break; + + case H5S_HYPER_VERSION_2: + *enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + break; + + case H5S_HYPER_VERSION_3: + if(is_regular) { + uint8_t enc1, enc2; + hsize_t max1 = 0; + hsize_t max2 = 0; + + /* Find max for count[] and block[] */ + for(u = 0; u < space->extent.rank; u++) { + if(space->select.sel_info.hslab->opt_diminfo[u].count != H5S_UNLIMITED && + space->select.sel_info.hslab->opt_diminfo[u].count > max1) + max1 = space->select.sel_info.hslab->opt_diminfo[u].count; + if(space->select.sel_info.hslab->opt_diminfo[u].block != H5S_UNLIMITED && + space->select.sel_info.hslab->opt_diminfo[u].block > max1) + max1 = space->select.sel_info.hslab->opt_diminfo[u].block; + } + + /* +1 to provide room for H5S_UNLIMITED */ + enc1 = H5S__hyper_get_enc_size_real(++max1); + + /* Find max for start[] and stride[] */ + for(u = 0; u < space->extent.rank; u++) { + if(space->select.sel_info.hslab->opt_diminfo[u].start > max2) + max2 = space->select.sel_info.hslab->opt_diminfo[u].start; + if(space->select.sel_info.hslab->opt_diminfo[u].stride > max2) + max2 = space->select.sel_info.hslab->opt_diminfo[u].stride; + } + + /* Determine the encoding size */ + enc2 = H5S__hyper_get_enc_size_real(max2); + + *enc_size = MAX(enc1, enc2); + } else { + hsize_t max_size = block_count; + HDassert(space->select.sel_info.hslab->unlim_dim < 0); + + /* Find max for block_count and bounds_end[] */ + for(u = 0; u < space->extent.rank; u++) + if(bounds_end[u] > max_size) + max_size = bounds_end[u]; + + /* Determine the encoding size */ + *enc_size = H5S__hyper_get_enc_size_real(max_size); + } + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown hyperslab selection version") + break; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S__hyper_get_version_enc_size() */ + + + +/*-------------------------------------------------------------------------- + NAME H5S__hyper_serial_size PURPOSE Determine the number of bytes needed to store the serialized hyperslab @@ -3303,49 +3517,73 @@ done: static hssize_t H5S__hyper_serial_size(const H5S_t *space) { - hsize_t block_count; /* block counter for regular hyperslabs */ - unsigned u; /* Counter */ - hssize_t ret_value = -1; /* return value */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of hyerslab selection info */ + hssize_t ret_value = -1; /* return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC HDassert(space); - /* Check for version (right now, an unlimited dimension is the only thing - * that would bump the version) */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + block_count = H5S__get_select_hyper_nblocks(space, FALSE); + + /* Determine the version and the encoded size */ + if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") + + if(version == H5S_HYPER_VERSION_3) { + /* Version 3: regular */ + /* Size required is always: + * + + + + * + + + * (4 (start/stride/count/block) * * ) = + * 14 + (4 * enc_size * rank) bytes + */ + if(H5S__hyper_is_regular(space)) + ret_value = (hssize_t)14 + + ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank); + else { + /* Version 3: irregular */ + /* Size required is always: + * + + + + * + + + * < # of blocks (depend on enc_size) > + + * (2 (starting/ending offset) * * * <# of blocks) = + * = 14 bytes + enc_size (block_count) + (2 * enc_size * rank * block_count) bytes + */ + ret_value = 14 + enc_size; + H5_CHECK_OVERFLOW(((unsigned)2 * enc_size * space->extent.rank * block_count), hsize_t, hssize_t); + ret_value += (hssize_t)((unsigned)2 * enc_size * space->extent.rank * block_count); + } + } else if(version == H5S_HYPER_VERSION_2) { /* Version 2 */ /* Size required is always: * + + + * + + - * (4 (start/stride/count/block) * * ) = - * 17 + (4 * rank * 8) bytes + * (4 (start/stride/count/block) * * ) = + * 17 + (4 * 8 * rank) bytes */ - ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)space->extent.rank - * (hssize_t)8); - else { + HDassert(enc_size == 8); + ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)8 * (hssize_t)space->extent.rank); + } else { + HDassert(version == H5S_HYPER_VERSION_1); + HDassert(enc_size == 4); /* Version 1 */ /* Basic number of bytes required to serialize hyperslab selection: * + + + - * + + <# of blocks (4 bytes)> - * = 24 bytes + * + + <# of blocks (4 bytes)> + + * (2 (starting/ending offset) * * * <# of blocks) = + * = 24 bytes + (2 * 4 * rank * block_count) */ ret_value = 24; - - /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab->diminfo_valid) { - /* Check each dimension */ - for(block_count = 1, u = 0; u < space->extent.rank; u++) - block_count *= space->select.sel_info.hslab->opt_diminfo[u].count; - } /* end if */ - else - /* Spin through hyperslab spans, adding 8 * rank bytes for each block */ - block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); - H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, hssize_t); - ret_value += (hssize_t)(8 * block_count * space->extent.rank); + ret_value += (hssize_t)(8 * space->extent.rank * block_count); } /* end else */ +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serial_size() */ @@ -3356,12 +3594,13 @@ H5S__hyper_serial_size(const H5S_t *space) PURPOSE Serialize the current selection into a user-provided buffer. USAGE - void H5S__hyper_serialize_helper(spans, start, end, rank, buf) + void H5S__hyper_serialize_helper(spans, start, end, rank, enc_size, buf) H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to serialize hssize_t start[]; IN/OUT: Accumulated start points hssize_t end[]; IN/OUT: Accumulated end points hsize_t rank; IN: Current rank looking at - uint8 *buf; OUT: Buffer to put serialized selection into + uint8_t enc_size IN: Encoded size of hyperslab selection info + uint8_t *buf; OUT: Buffer to put serialized selection into RETURNS None DESCRIPTION @@ -3374,7 +3613,7 @@ H5S__hyper_serial_size(const H5S_t *space) --------------------------------------------------------------------------*/ static void H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, - hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **p) + hsize_t *start, hsize_t *end, hsize_t rank, uint8_t enc_size, uint8_t **p) { H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ uint8_t *pp = (*p); /* Local pointer for decoding */ @@ -3398,26 +3637,65 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, end[rank] = curr->high; /* Recurse down to the next dimension */ - H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, &pp); + H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, enc_size, &pp); } /* end if */ else { hsize_t u; /* Index variable */ /* Encode all the previous dimensions starting & ending points */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + /* Encode previous starting points */ + for(u=0; ulow); + + /* Encode previous ending points */ + for(u=0; uhigh); + break; - /* Encode previous starting points */ - for(u = 0; u < rank; u++) - UINT32ENCODE(pp, (uint32_t)start[u]); + case H5S_SELECT_INFO_ENC_SIZE_4: + /* Encode previous starting points */ + for(u=0; ulow); + /* Encode starting point for this span */ + UINT32ENCODE(pp, (uint32_t)curr->low); - /* Encode previous ending points */ - for(u = 0; u < rank; u++) - UINT32ENCODE(pp, (uint32_t)end[u]); + /* Encode previous ending points */ + for(u=0; uhigh); + break; + + case H5S_SELECT_INFO_ENC_SIZE_8: + /* Encode previous starting points */ + for(u=0; ulow); + + /* Encode previous ending points */ + for(u=0; uhigh); + break; + + default: + HDassert(0 && "Unknown enc size?!?"); - /* Encode starting point for this span */ - UINT32ENCODE(pp, (uint32_t)curr->high); + } /* end switch */ } /* end else */ /* Advance to next node */ @@ -3455,14 +3733,26 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp; /* Local pointer for encoding */ - uint8_t *lenp; /* Pointer to length location for later storage */ - uint32_t len = 0; /* Number of bytes used */ + const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ + hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ + hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ + hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ + uint8_t *pp; /* Local pointer for decoding */ + uint8_t *lenp = NULL; /* pointer to length location for later storage */ + uint32_t len = 0; /* number of bytes used */ uint32_t version; /* Version number */ uint8_t flags = 0; /* Flags for message */ - hsize_t block_count; /* Block counter for regular hyperslabs */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + unsigned i, u; /* Local counting variable */ + hbool_t complete = FALSE; /* Whether we are done with the iteration */ + hbool_t is_regular; /* Whether selection is regular */ + uint8_t enc_size; + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(space); @@ -3470,163 +3760,243 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) pp = (*p); HDassert(pp); - /* Calculate version */ - if(space->select.sel_info.hslab->unlim_dim >= 0) { - version = 2; - flags |= H5S_SELECT_FLAG_UNLIM; - } /* end if */ - else - version = 1; + /* Set some convienence values */ + ndims = space->extent.rank; + diminfo = space->select.sel_info.hslab->opt_diminfo; + + if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + block_count = H5S__get_select_hyper_nblocks(space, FALSE); + + /* Determine the version and the encoded size */ + if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") + + is_regular = H5S__hyper_is_regular(space); + if(is_regular && + (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3)) + flags |= H5S_HYPER_REGULAR; /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, version); /* Store the version number */ - if(version >= 2) - *(pp)++ = flags; /* Store the flags */ - else - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* keep the pointer to the length location for later */ - pp += 4; /* skip over space for length */ + + if(version >= 3) { + *(pp)++ = flags; /* Store the flags */ + *(pp)++ = enc_size; /* Store size of offset info */ + + } else { + if(version == 2) + *(pp)++ = flags; /* Store the flags */ + else + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* keep the pointer to the length location for later */ + pp += 4; /* skip over space for length */ + + len += 4; /* ndims */ + } /* Encode number of dimensions */ - UINT32ENCODE(pp, (uint32_t)space->extent.rank); - len += 4; + UINT32ENCODE(pp, (uint32_t)ndims); - /* If there is an unlimited dimension, only encode opt_unlim_diminfo */ - if(flags & H5S_SELECT_FLAG_UNLIM) { - unsigned i; + if(is_regular) { - HDassert(H5S_UNLIMITED == HSIZE_UNDEF); + if(version >= H5S_HYPER_VERSION_2) { + + HDassert(H5S_UNLIMITED == HSIZE_UNDEF); - /* Iterate over dimensions */ - for(i = 0; i < space->extent.rank; i++) { + /* Iterate over dimensions */ /* Encode start/stride/block/count */ - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].start); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].stride); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].count); - UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].block); - } /* end for */ - len += (4 * space->extent.rank * 8); - } /* end if */ - /* Check for a "regular" hyperslab selection */ - else if(space->select.sel_info.hslab->diminfo_valid) { - const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Rank of the dataspace */ - unsigned u; /* Local counting variable */ - hbool_t done; /* Whether we are done with the iteration */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_HYPER_VERSION_3); + for(i = 0; i < space->extent.rank; i++) { + UINT16ENCODE(pp, diminfo[i].start); + UINT16ENCODE(pp, diminfo[i].stride); + if(diminfo[i].count == H5S_UNLIMITED) { + UINT16ENCODE(pp, H5S_UINT16_MAX); + } else { + UINT16ENCODE(pp, diminfo[i].count); + } + + if(diminfo[i].block == H5S_UNLIMITED) { + UINT16ENCODE(pp, H5S_UINT16_MAX); + } else { + UINT16ENCODE(pp, diminfo[i].block); + } + } /* end for */ + break; - /* Set some convenience values */ - ndims = space->extent.rank; - fast_dim = ndims - 1; - diminfo = space->select.sel_info.hslab->opt_diminfo; + case H5S_SELECT_INFO_ENC_SIZE_4: + HDassert(version == H5S_HYPER_VERSION_3); + for(i = 0; i < space->extent.rank; i++) { + UINT32ENCODE(pp, diminfo[i].start); + UINT32ENCODE(pp, diminfo[i].stride); + if(diminfo[i].count == H5S_UNLIMITED) { + UINT32ENCODE(pp, H5S_UINT32_MAX); + } else { + UINT32ENCODE(pp, diminfo[i].count); + } + if(diminfo[i].block == H5S_UNLIMITED) { + UINT32ENCODE(pp, H5S_UINT32_MAX); + } else { + UINT32ENCODE(pp, diminfo[i].block); + } + } /* end for */ + break; - /* Check each dimension */ - for(block_count = 1, u = 0; u < ndims; u++) - block_count *= diminfo[u].count; + case H5S_SELECT_INFO_ENC_SIZE_8: + HDassert(version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3); + for(i = 0; i < space->extent.rank; i++) { + UINT64ENCODE(pp, diminfo[i].start); + UINT64ENCODE(pp, diminfo[i].stride); + if(diminfo[i].count == H5S_UNLIMITED) { + UINT64ENCODE(pp, H5S_UINT64_MAX); + } else { + UINT64ENCODE(pp, diminfo[i].count); + } + if(diminfo[i].block == H5S_UNLIMITED) { + UINT64ENCODE(pp, H5S_UINT64_MAX); + } else { + UINT64ENCODE(pp, diminfo[i].block); + } + } /* end for */ + if(version == H5S_HYPER_VERSION_2) + len += (4 * space->extent.rank * 8); + break; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + break; + } /* end switch */ - /* Encode number of hyperslabs */ - H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); - UINT32ENCODE(pp, (uint32_t)block_count); - len += 4; + } else { - /* Now serialize the information for the regular hyperslab */ + HDassert(version == H5S_HYPER_VERSION_1); + + /* Set some convienence values */ + fast_dim = ndims - 1; - /* Build the tables of count sizes as well as the initial offset */ - for(u = 0; u < ndims; u++) { - tmp_count[u] = diminfo[u].count; - offset[u] = diminfo[u].start; - } /* end for */ + /* Encode number of hyperslabs */ + H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); + UINT32ENCODE(pp, (uint32_t)block_count); + len += 4; - /* We're not done with the iteration */ - done = FALSE; + /* Now serialize the information for the regular hyperslab */ - /* Go iterate over the hyperslabs */ - while(done == FALSE) { - /* Iterate over the blocks in the fastest dimension */ - while(tmp_count[fast_dim] > 0) { - /* Add 8 bytes times the rank for each hyperslab selected */ - len += 8 * ndims; + /* Build the tables of count sizes as well as the initial offset */ + for(u = 0; u < ndims; u++) { + tmp_count[u] = diminfo[u].count; + offset[u] = diminfo[u].start; + } /* end for */ - /* Encode hyperslab starting location */ - for(u = 0; u < ndims; u++) - UINT32ENCODE(pp, (uint32_t)offset[u]); + /* Go iterate over the hyperslabs */ + while(complete == FALSE) { + /* Iterate over the blocks in the fastest dimension */ + while(tmp_count[fast_dim] > 0) { + /* Add 8 bytes times the rank for each hyperslab selected */ + len += 8 * ndims; - /* Encode hyperslab ending location */ - for(u = 0; u < ndims; u++) - UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1))); + /* Encode hyperslab starting location */ + for(u = 0; u < ndims; u++) + UINT32ENCODE(pp, (uint32_t)offset[u]); - /* Move the offset to the next sequence to start */ - offset[fast_dim]+=diminfo[fast_dim].stride; + /* Encode hyperslab ending location */ + for(u = 0; u < ndims; u++) + UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1))); - /* Decrement the block count */ - tmp_count[fast_dim]--; - } /* end while */ + /* Move the offset to the next sequence to start */ + offset[fast_dim]+=diminfo[fast_dim].stride; + + /* Decrement the block count */ + tmp_count[fast_dim]--; + } /* end while */ - /* Work on other dimensions if necessary */ - if(fast_dim > 0) { - int temp_dim; /* Temporary rank holder */ + /* Work on other dimensions if necessary */ + if(fast_dim > 0) { + int temp_dim; /* Temporary rank holder */ - /* Reset the block counts */ - tmp_count[fast_dim] = diminfo[fast_dim].count; + /* Reset the block counts */ + tmp_count[fast_dim] = diminfo[fast_dim].count; - /* Bubble up the decrement to the slower changing dimensions */ - temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0 && done == FALSE) { - /* Decrement the block count */ - tmp_count[temp_dim]--; + /* Bubble up the decrement to the slower changing dimensions */ + temp_dim = (int)fast_dim - 1; + while(temp_dim >= 0 && complete == FALSE) { + /* Decrement the block count */ + tmp_count[temp_dim]--; - /* Check if we have more blocks left */ - if(tmp_count[temp_dim] > 0) - break; + /* Check if we have more blocks left */ + if(tmp_count[temp_dim] > 0) + break; - /* Check for getting out of iterator */ - if(temp_dim == 0) - done = TRUE; + /* Check for getting out of iterator */ + if(temp_dim == 0) + complete = TRUE; - /* Reset the block count in this dimension */ - tmp_count[temp_dim] = diminfo[temp_dim].count; + /* Reset the block count in this dimension */ + tmp_count[temp_dim] = diminfo[temp_dim].count; - /* Wrapped a dimension, go up to next dimension */ - temp_dim--; - } /* end while */ - } /* end if */ - else - break; /* Break out now, for 1-D selections */ + /* Wrapped a dimension, go up to next dimension */ + temp_dim--; + } /* end while */ + } /* end if */ + else + break; /* Break out now, for 1-D selections */ - /* Re-compute offset array */ - for(u = 0; u < ndims; u++) - offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); - } /* end while */ - } /* end if */ - else { - hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ - hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ + /* Re-compute offset array */ + for(u = 0; u < ndims; u++) + offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); + } /* end while */ + + } /* end else */ + + } else { /* irregular */ /* Encode number of hyperslabs */ - block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); - H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); - UINT32ENCODE(pp, (uint32_t)block_count); - len += 4; + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_HYPER_VERSION_3); + H5_CHECK_OVERFLOW(block_count, hsize_t, uint16_t); + UINT16ENCODE(pp, (uint16_t)block_count); + break; - /* Add 8 bytes times the rank for each hyperslab selected */ - H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, size_t); - len += (uint32_t)(8 * space->extent.rank * block_count); + case H5S_SELECT_INFO_ENC_SIZE_4: + HDassert(version == H5S_HYPER_VERSION_1 || version == H5S_HYPER_VERSION_3); + H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); + UINT32ENCODE(pp, (uint32_t)block_count); + break; - /* Encode each hyperslab in selection */ - H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &pp); - } /* end else */ + case H5S_SELECT_INFO_ENC_SIZE_8: + HDassert(version == H5S_HYPER_VERSION_3); + UINT64ENCODE(pp, block_count); + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + break; + } /* end switch */ + + if(version == H5S_HYPER_VERSION_1) { + len+=4; /* block_count */ + + /* Add 8 bytes times the rank for each hyperslab selected */ + H5_CHECK_OVERFLOW((8 * ndims * block_count), hsize_t, size_t); + len += (uint32_t)(8 * ndims * block_count); + } + + H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, &pp); + + } /* Encode length */ - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + if(version <= H5S_HYPER_VERSION_2) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S__hyper_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S__hyper_serialize() */ + /*-------------------------------------------------------------------------- @@ -3657,14 +4027,15 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either *space or a newly allocated one */ hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */ - hsize_t start[H5S_MAX_RANK]; /* Hyperslab start information */ - hsize_t block[H5S_MAX_RANK]; /* Hyperslab block information */ + hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */ + hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */ uint32_t version; /* Version number */ uint8_t flags = 0; /* Flags */ - unsigned rank; /* Rank of points */ + uint8_t enc_size = 0; /* Encoded size of selection info */ + unsigned rank; /* rank of points */ const uint8_t *pp; /* Local pointer for decoding */ - unsigned u; /* Local counting variable */ - herr_t ret_value = FAIL; /* Return value */ + unsigned u; /* Local counting variable */ + herr_t ret_value=FAIL; /* return value */ FUNC_ENTER_STATIC @@ -3688,15 +4059,31 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - if(version >= (uint32_t)2) { + if(version >= (uint32_t)H5S_HYPER_VERSION_2) { /* Decode flags */ flags = *(pp)++; - /* Skip over the remainder of the header */ - pp += 4; - } else + if(version >= (uint32_t)H5S_HYPER_VERSION_3) + /* decode size of offset info */ + enc_size = *(pp)++; + else { + /* Skip over the remainder of the header */ + pp += 4; + enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + } + + /* Check for unknown flags */ + if(flags & ~H5S_SELECT_FLAG_BITS) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection") + } else { /* Skip over the remainder of the header */ pp += 8; + enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + } + + /* Check encoded */ + if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ UINT32DECODE(pp,rank); @@ -3712,24 +4099,66 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) if(rank != tmp_space->extent.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") - /* If there is an unlimited dimension, only encode opt_unlim_diminfo */ - if(flags & H5S_SELECT_FLAG_UNLIM) { + if(flags & H5S_HYPER_REGULAR) { hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */ - hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ + hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ /* Sanity checks */ HDassert(H5S_UNLIMITED == HSIZE_UNDEF); HDassert(version >= 2); - /* Iterate over dimensions */ - for(u = 0; u < rank; u++) { - /* Decode start/stride/block/count */ - UINT64DECODE(pp, start[u]); - UINT64DECODE(pp, stride[u]); - UINT64DECODE(pp, count[u]); - UINT64DECODE(pp, block[u]); - } /* end for */ + /* Decode start/stride/block/count */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + for(u = 0; u < tmp_space->extent.rank; u++) { + UINT16DECODE(pp, start[u]); + UINT16DECODE(pp, stride[u]); + + UINT16DECODE(pp, count[u]); + if((uint16_t)count[u] == H5S_UINT16_MAX) + count[u] = H5S_UNLIMITED; + + UINT16DECODE(pp, block[u]); + if((uint16_t)block[u] == H5S_UINT16_MAX) + block[u] = H5S_UNLIMITED; + } /* end for */ + break; + + case H5S_SELECT_INFO_ENC_SIZE_4: + for(u = 0; u < tmp_space->extent.rank; u++) { + UINT32DECODE(pp, start[u]); + UINT32DECODE(pp, stride[u]); + + UINT32DECODE(pp, count[u]); + if((uint32_t)count[u] == H5S_UINT32_MAX) + count[u] = H5S_UNLIMITED; + + UINT32DECODE(pp, block[u]); + if((uint32_t)block[u] == H5S_UINT32_MAX) + block[u] = H5S_UNLIMITED; + } /* end for */ + break; + case H5S_SELECT_INFO_ENC_SIZE_8: + for(u = 0; u < tmp_space->extent.rank; u++) { + UINT64DECODE(pp, start[u]); + UINT64DECODE(pp, stride[u]); + + UINT64DECODE(pp, count[u]); + if((uint64_t)count[u] == H5S_UINT64_MAX) + count[u] = H5S_UNLIMITED; + + UINT64DECODE(pp, block[u]); + if((uint64_t)block[u] == H5S_UINT64_MAX) + block[u] = H5S_UNLIMITED; + } /* end for */ + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + break; + } /* end switch */ + /* Select the hyperslab to the current selection */ if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") @@ -3737,28 +4166,65 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) else { const hsize_t *stride; /* Hyperslab stride information */ const hsize_t *count; /* Hyperslab count information */ - hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */ - hsize_t *tstart; /* Temporary hyperslab pointers */ - hsize_t *tend; /* Temporary hyperslab pointers */ - hsize_t *tblock; /* Temporary hyperslab pointers */ - size_t block_count; /* Number of blocks in selection */ - unsigned v; /* Local counting variable */ + hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */ + hsize_t *tstart; /* Temporary hyperslab pointers */ + hsize_t *tend; /* Temporary hyperslab pointers */ + hsize_t *tblock; /* Temporary hyperslab pointers */ + size_t num_elem; /* Number of elements in selection */ + unsigned v; /* Local counting variable */ + + /* decode the number of blocks */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + UINT16DECODE(pp, num_elem); + break; + + case H5S_SELECT_INFO_ENC_SIZE_4: + UINT32DECODE(pp, num_elem); + break; + + case H5S_SELECT_INFO_ENC_SIZE_8: + UINT64DECODE(pp, num_elem); + break; - /* Decode the number of blocks */ - UINT32DECODE(pp, block_count); + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + break; + } /* Set the count & stride for all blocks */ stride = count = H5S_hyper_ones_g; /* Retrieve the coordinates from the buffer */ - for(u = 0; u < block_count; u++) { - /* Decode the starting points */ - for(tstart = start, v = 0; v < rank; v++, tstart++) - UINT32DECODE(pp, *tstart); - - /* Decode the ending points */ - for(tend = end, v = 0; v < rank; v++, tend++) - UINT32DECODE(pp, *tend); + for(u = 0; u < num_elem; u++) { + + /* Decode the starting and ending points */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + for(tstart = start, v = 0; v < rank; v++, tstart++) + UINT16DECODE(pp, *tstart); + for(tend = end, v = 0; v < rank; v++, tend++) + UINT16DECODE(pp, *tend); + break; + + case H5S_SELECT_INFO_ENC_SIZE_4: + for(tstart = start,v = 0; v < rank; v++, tstart++) + UINT32DECODE(pp, *tstart); + for(tend = end, v = 0; v < rank; v++, tend++) + UINT32DECODE(pp, *tend); + break; + + case H5S_SELECT_INFO_ENC_SIZE_8: + for(tstart = start, v = 0; v < rank; v++, tstart++) + UINT64DECODE(pp, *tstart); + for(tend = end, v = 0; v < rank; v++, tend++) + UINT64DECODE(pp, *tend); + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + break; + } /* Change the ending points into blocks */ for(tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++) diff --git a/src/H5Snone.c b/src/H5Snone.c index cae9a67..6219bb1 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -583,7 +583,7 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 2918648..56b1f30 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -37,8 +37,35 @@ #define H5S_VALID_PERM 0x02 /* Flags for serialization of selections */ -#define H5S_SELECT_FLAG_UNLIM 0x01 -#define H5S_SELECT_FLAG_BITS (H5S_SELECT_FLAG_UNLIM) +#define H5S_HYPER_REGULAR 0x01 +#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) + +/* Versions for H5S_SEL_HYPER selection info */ +#define H5S_HYPER_VERSION_1 1 +#define H5S_HYPER_VERSION_2 2 +#define H5S_HYPER_VERSION_3 3 + +/* Versions for H5S_SEL_POINTS selection info */ +#define H5S_POINT_VERSION_1 1 +#define H5S_POINT_VERSION_2 2 + +/* Versions for H5S_SEL_NONE selection info */ +#define H5S_NONE_VERSION_1 1 + +/* Versions for H5S_SEL_ALL selection info */ +#define H5S_ALL_VERSION_1 1 + +/* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */ +#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_BITS ( H5S_SELECT_INFO_ENC_SIZE_2 | \ + H5S_SELECT_INFO_ENC_SIZE_4 | \ + H5S_SELECT_INFO_ENC_SIZE_8 ) + +#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */ +#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */ +#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */ /* Length of stack-allocated sequences for "project intersect" routines */ #define H5S_PROJECT_INTERSECT_NSEQS 256 diff --git a/src/H5Spoint.c b/src/H5Spoint.c index ac9c983..a3f7df2 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -28,13 +28,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -72,6 +73,8 @@ static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); +static herr_t + H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); /* Selection iteration callbacks */ static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); @@ -118,6 +121,13 @@ const H5S_select_class_t H5S_sel_point[1] = {{ H5S__point_iter_init, }}; +/* Format version bounds for dataspace hyperslab selection */ +const unsigned H5O_sds_point_ver_bounds[] = { + H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */ + H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */ +}; /*******************/ /* Local Variables */ @@ -919,6 +929,124 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_npoints() */ +/*-------------------------------------------------------------------------- + NAME + H5S__point_get_version_enc_size + PURPOSE + Determine the version and the size (2, 4 or 8 bytes) to encode point selection info + USAGE + hssize_t H5S__point_set_enc_size(space, version, enc_size) + const H5S_t *space: IN: Dataspace ID of selection to query + uint32_t *version: OUT: The version to use for encoding + uint8_t *enc_size: OUT: The size to use for encoding + RETURNS + The version and the size to encode point selection info + DESCRIPTION + Determine the version to use for encoding points selection info based + on the following: + (1) the low/high bounds setting in fapl + (2) whether the number of points or selection high bounds exceeds H5S_UINT32_MAX or not + + Determine the encoded size based on version: + --For version 2, the encoded size of point selection info is determined + by the maximum size for: + (a) storing the number of points + (b) storing the selection high bounds + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size) +{ + hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + uint32_t tmp_version; /* Local temporary version */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ + hsize_t max_size = 0; /* Maximum selection size */ + unsigned u; /* Local index veriable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Get bounding box for the selection */ + HDmemset(bounds_end, 0, sizeof(bounds_end)); + if(H5S__point_bounds(space, bounds_start, bounds_end) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") + + /* Determine whether number of points or high bounds exceeds (2^32 - 1) */ + if(space->select.num_elem > H5S_UINT32_MAX) + count_up_version = TRUE; + else { + for(u = 0; u < space->extent.rank; u++) + if(bounds_end[u] > H5S_UINT32_MAX) { + bound_up_version = TRUE; + break; + } + } + + /* If exceed (2^32 -1) */ + if(count_up_version || bound_up_version) + tmp_version = H5S_POINT_VERSION_2; + else + tmp_version = H5S_POINT_VERSION_1; + + /* Get the file's low/high bounds */ + if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") + + /* Upgrade to the version indicated by the file's low bound if higher */ + tmp_version = MAX(tmp_version, H5O_sds_point_ver_bounds[low_bound]); + + /* Version bounds check */ + if(tmp_version > H5O_sds_point_ver_bounds[high_bound]) { + if(count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32") + else if(bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32") + else + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace point selection version out of bounds") + } + + /* Set the version to return */ + *version = tmp_version; + + /* Get the encoded size use based on version */ + switch(tmp_version) { + case H5S_POINT_VERSION_1: + *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + break; + + case H5S_POINT_VERSION_2: + /* Find max for num_elem and bounds_end[] */ + max_size = space->select.num_elem; + for(u = 0; u < space->extent.rank; u++) + if(bounds_end[u] > max_size) + max_size = bounds_end[u]; + + /* Determine the encoding size */ + if(max_size > H5S_UINT32_MAX) + *enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + else if(max_size > H5S_UINT16_MAX) + *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + else + *enc_size = H5S_SELECT_INFO_ENC_SIZE_2; + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S__point_get_version_enc_size() */ + /*-------------------------------------------------------------------------- NAME @@ -942,22 +1070,39 @@ done: static hssize_t H5S__point_serial_size(const H5S_t *space) { + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ hssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC HDassert(space); - /* Basic number of bytes required to serialize point selection: - * + + + - * + + <# of points (4 bytes)> = 24 bytes - */ - ret_value = 24; + /* Determine the version and encoded size for point selection */ + if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") + + /* Basic number of bytes required to serialize point selection: */ + if(version >= H5S_POINT_VERSION_2) + /* + * + + + * + rank (4 bytes)> + */ + ret_value=13; + else + /* + * + + + + * + + */ + ret_value = 20; + + /* */ + ret_value += enc_size; /* Count points in selection */ - /* (Add 4 bytes times the rank for each element selected) */ - ret_value += (4 * space->extent.rank) * (hssize_t)H5S_GET_SELECT_NPOINTS(space); + ret_value += (hssize_t) (enc_size * space->extent.rank * space->select.num_elem); +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_serial_size() */ @@ -987,12 +1132,15 @@ static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *pp; /* Local pointer for encoding */ - uint8_t *lenp; /* Pointer to length location for later storage */ - uint32_t len = 0; /* Number of bytes used */ - unsigned u; /* Local counting variable */ + uint8_t *pp; /* Local pointer for decoding */ + uint8_t *lenp = NULL; /* pointer to length location for later storage */ + uint32_t len=0; /* number of bytes used */ + unsigned u; /* local counting variable */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -1000,42 +1148,96 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) pp = (*p); HDassert(pp); + /* Determine the version and encoded size for point selection info */ + if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") + /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* Keep the pointer to the length location for later */ - pp += 4; /* Skip over space for length */ + + UINT32ENCODE(pp, version); /* Store the version number */ + if(version >= 2) { + *(pp)++ = enc_size; /* Store size of point info */ + } else { + HDassert(version == H5S_POINT_VERSION_1); + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* Keep the pointer to the length location for later */ + pp += 4; /* Skip over space for length */ + len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ + } /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)space->extent.rank); - len += 4; - /* Encode number of elements */ - UINT32ENCODE(pp, (uint32_t)space->select.num_elem); - len += 4; + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_POINT_VERSION_2); + + /* Encode number of elements */ + UINT16ENCODE(pp, (uint16_t)space->select.num_elem); + + /* Encode each point in selection */ + curr=space->select.sel_info.pnt_lst->head; + while(curr!=NULL) { + /* Encode each point */ + for(u=0; uextent.rank; u++) + UINT16ENCODE(pp, (uint16_t)curr->pnt[u]); + curr=curr->next; + } /* end while */ + break; - /* Encode each point in selection */ - curr = space->select.sel_info.pnt_lst->head; - while(curr != NULL) { - /* Add 4 bytes times the rank for each element selected */ - len += 4 * space->extent.rank; + case H5S_SELECT_INFO_ENC_SIZE_4: + HDassert(version == H5S_POINT_VERSION_1 || version == H5S_POINT_VERSION_2); - /* Encode each point */ - for(u = 0; u < space->extent.rank; u++) - UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); + /* Encode number of elements */ + UINT32ENCODE(pp, (uint32_t)space->select.num_elem); - curr = curr->next; - } /* end while */ + /* Encode each point in selection */ + curr=space->select.sel_info.pnt_lst->head; + while(curr!=NULL) { + /* Encode each point */ + for(u=0; uextent.rank; u++) + UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); + curr=curr->next; + } /* end while */ + + /* Add 4 bytes times the rank for each element selected */ + if(version == H5S_POINT_VERSION_1) + len += (uint32_t)space->select.num_elem * 4 * space->extent.rank; + break; + + case H5S_SELECT_INFO_ENC_SIZE_8: + HDassert(version == H5S_POINT_VERSION_2); + + /* Encode number of elements */ + UINT64ENCODE(pp, space->select.num_elem); + + /* Encode each point in selection */ + curr=space->select.sel_info.pnt_lst->head; + while(curr!=NULL) { + /* Encode each point */ + for(u=0; uextent.rank; u++) + UINT64ENCODE(pp, curr->pnt[u]); + curr=curr->next; + } /* end while */ + break; - /* Encode length */ - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + + } /* end switch */ + + if(version == H5S_POINT_VERSION_1) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S__point_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S__point_serialize() */ + /*-------------------------------------------------------------------------- @@ -1067,9 +1269,10 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) either *space or a newly allocated one */ hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ uint32_t version; /* Version number */ + uint8_t enc_size = 0; /* Encoded size of selection info */ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ const uint8_t *pp; /* Local pointer for decoding */ - size_t num_elem = 0; /* Number of elements in selection */ + hsize_t num_elem = 0; /* Number of elements in selection */ unsigned rank; /* Rank of points */ unsigned i, j; /* local counting variables */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1096,8 +1299,18 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - /* Skip over the remainder of the header */ - pp += 8; + if(version >= (uint32_t)H5S_POINT_VERSION_2) + /* Decode size of point info */ + enc_size = *(pp)++; + else { + /* Skip over the remainder of the header */ + pp += 8; + enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + } + + /* Check encoded size */ + if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ UINT32DECODE(pp,rank); @@ -1113,8 +1326,22 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) if(rank != tmp_space->extent.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") - /* Deserialize points to select */ - UINT32DECODE(pp, num_elem); /* decode the number of points */ + /* decode the number of points */ + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + UINT16DECODE(pp, num_elem); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: + UINT32DECODE(pp, num_elem); + break; + case H5S_SELECT_INFO_ENC_SIZE_8: + UINT64DECODE(pp, num_elem); + break; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ + /* Allocate space for the coordinates */ if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) @@ -1123,7 +1350,22 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) /* Retrieve the coordinates from the buffer */ for(tcoord = coord, i = 0; i < num_elem; i++) for(j = 0; j < (unsigned)rank; j++, tcoord++) - UINT32DECODE(pp, *tcoord); + switch(enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + UINT16DECODE(pp, *tcoord); + break; + + case H5S_SELECT_INFO_ENC_SIZE_4: + UINT32DECODE(pp, *tcoord); + break; + + case H5S_SELECT_INFO_ENC_SIZE_8: + UINT64DECODE(pp, *tcoord); + break; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ /* Select points */ if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 561875a..c01beca 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -97,7 +97,7 @@ H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[], const hsize_t max[]); H5_DLL hid_t H5Scopy(hid_t space_id); H5_DLL herr_t H5Sclose(hid_t space_id); -H5_DLL herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc); +H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl); H5_DLL hid_t H5Sdecode(const void *buf); H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id); @@ -134,6 +134,16 @@ H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid); H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t buf[/*numblocks*/]); +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +/* Function prototypes */ +H5_DLL herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + #ifdef __cplusplus } #endif diff --git a/src/H5vers.txt b/src/H5vers.txt index 914c30e..22117c3 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -61,12 +61,14 @@ FUNCTION: H5Oget_info_by_name; ; v18, v112 FUNCTION: H5Oget_info_by_idx; ; v18, v112 FUNCTION: H5Ovisit; ; v18, v112 FUNCTION: H5Ovisit_by_name; ; v18, v112 +FUNCTION: H5Pencode; ; v110, v112 FUNCTION: H5Pget_filter; ; v10, v18 FUNCTION: H5Pget_filter_by_id; ; v16, v18 FUNCTION: H5Pinsert; ; v14, v18 FUNCTION: H5Pregister; ; v14, v18 FUNCTION: H5Rdereference; ; v10, v110 FUNCTION: H5Rget_obj_type; ; v16, v18 +FUNCTION: H5Sencode; ; v18, v112 FUNCTION: H5Tarray_create; ; v14, v18 FUNCTION: H5Tcommit; ; v10, v18 FUNCTION: H5Tget_array_dims; ; v14, v18 diff --git a/src/Makefile.am b/src/Makefile.am index 5532655..378e390 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -102,7 +102,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5R.c H5Rint.c H5Rdeprec.c \ H5UC.c \ H5RS.c \ - H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Snone.c H5Spoint.c \ + H5S.c H5Sall.c H5Sdbg.c H5Sdeprec.c H5Shyper.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c \ H5SL.c \ H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 33d23dc..2c8f691 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -15,75 +15,139 @@ * Serial tests for encoding/decoding plists */ -#include "h5test.h" +#include "testhdf5.h" #include "H5ACprivate.h" #include "H5Pprivate.h" +#define SRC_FNAME "source_file.h5" +#define SRC_DSET "src_dset" + static int -test_encode_decode(hid_t orig_pl) +test_encode_decode(hid_t orig_pl, H5F_libver_t low, H5F_libver_t high, hbool_t support_virtual) { - hid_t pl = (-1); /* Decoded property list */ + hid_t pl = (-1); /* Decoded property list */ + hid_t fapl = -1; /* File access property list */ void *temp_buf = NULL; /* Pointer to encoding buffer */ size_t temp_size = 0; /* Size of encoding buffer */ + herr_t ret; /* Return value */ - /* first call to encode returns only the size of the buffer needed */ - if(H5Pencode(orig_pl, NULL, &temp_size) < 0) - STACK_ERROR + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR - if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + /* Set library version bounds */ + if(H5Pset_libver_bounds(fapl, low, high) < 0) TEST_ERROR - if(H5Pencode(orig_pl, temp_buf, &temp_size) < 0) - STACK_ERROR + H5E_BEGIN_TRY { + ret = H5Pencode2(orig_pl, NULL, &temp_size, fapl); + } H5E_END_TRY; + + if(support_virtual && high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Pencode2"); + else { + + VERIFY(ret, SUCCEED, "H5Pencode2"); + + /* Allocate the buffer for encoding */ + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + /* Encode the property list to the buffer */ + if(H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0) + TEST_ERROR + + /* Decode the buffer */ + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR + + /* Check if the original and the decoded property lists are equal */ + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") + + /* Close the decoded property list */ + if((H5Pclose(pl)) < 0) + TEST_ERROR + + /* Free the buffer */ + if(temp_buf) + HDfree(temp_buf); + +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Test H5Pencode1() */ + + /* first call to encode returns only the size of the buffer needed */ + if(H5Pencode1(orig_pl, NULL, &temp_size) < 0) + STACK_ERROR + + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + if(H5Pencode1(orig_pl, temp_buf, &temp_size) < 0) + STACK_ERROR - if((pl = H5Pdecode(temp_buf)) < 0) - STACK_ERROR + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR - if(!H5Pequal(orig_pl, pl)) - PUTS_ERROR("encoding-decoding cycle failed\n") + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") - if((H5Pclose(pl)) < 0) - STACK_ERROR + if((H5Pclose(pl)) < 0) + STACK_ERROR - HDfree(temp_buf); + if(temp_buf) + HDfree(temp_buf); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + } + + if((H5Pclose(fapl)) < 0) + TEST_ERROR /* Success */ return(0); error: - if(pl > 0) - H5Pclose(pl); if(temp_buf) HDfree(temp_buf); + H5E_BEGIN_TRY { + H5Pclose(pl); + H5Pclose(fapl); + } H5E_END_TRY; + return(-1); } /* end test_encode_decode() */ int main(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset xfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ - + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset xfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hsize_t dims[1] = {3}; /* Data space current size */ hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ - double fill = 2.7f; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ + double fill = 2.7f; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ size_t nslots = 521 * 2; size_t nbytes = 1048576 * 10; double w0 = 0.5f; unsigned max_compact; unsigned min_dense; const char* c_to_f = "x+32"; + H5F_libver_t low, high; /* Low and high bounds */ + H5AC_cache_config_t my_cache_config = { H5AC__CURR_CACHE_CONFIG_VERSION, TRUE, @@ -115,467 +179,511 @@ main(void) 0.2f, (256 * 2048), H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_image_config_t my_cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, + TRUE, FALSE, - -1}; - - if(VERBOSE_MED) - printf("Encode/Decode DCPLs\n"); + -1 }; + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char* low_string; /* The low bound string */ + char* high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + + if(VERBOSE_MED) + printf("Encode/Decode DCPLs\n"); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("Default DCPL Encoding/Decoding"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DCPL Encoding/Decoding"); + + if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) + FAIL_STACK_ERROR + + max_size[0] = 100; + if((H5Pset_external(dcpl, "ext1.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext2.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext3.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext4.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + PASSED(); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("DCPL Encoding/Decoding for virtual layout"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set virtual layout */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR + + /* Create source dataspace */ + if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0) + TEST_ERROR + + if(test_encode_decode(dcpl, low, high, TRUE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + /******* ENCODE/DECODE DAPLS *****/ + TESTING("Default DAPL Encoding/Decoding"); + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DAPL Encoding/Decoding"); + + if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dapl)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DCPLS *****/ - TESTING("Default DCPL Encoding/Decoding"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + /******* ENCODE/DECODE OCPLS *****/ + TESTING("Default OCPL Encoding/Decoding"); + if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("DCPL Encoding/Decoding"); + TESTING("OCPL Encoding/Decoding"); - if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) + FAIL_STACK_ERROR - if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) - FAIL_STACK_ERROR + if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) + FAIL_STACK_ERROR - if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") - max_size[0] = 100; - if((H5Pset_external(dcpl, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(ocpl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + /******* ENCODE/DECODE DXPLS *****/ + TESTING("Default DXPL Encoding/Decoding"); + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") - /******* ENCODE/DECODE DAPLS *****/ - TESTING("Default DAPL Encoding/Decoding"); - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + TESTING("DXPL Encoding/Decoding"); - PASSED(); + if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) + FAIL_STACK_ERROR - TESTING("DAPL Encoding/Decoding"); +#ifdef H5_HAVE_PARALLEL + if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) + FAIL_STACK_ERROR +#endif/* H5_HAVE_PARALLEL */ + if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) + FAIL_STACK_ERROR + if((H5Pset_data_transform(dxpl, c_to_f)) < 0) + FAIL_STACK_ERROR - if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(dxpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE GCPLS *****/ + TESTING("Default GCPL Encoding/Decoding"); + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") - /******* ENCODE/DECODE OCPLS *****/ - TESTING("Default OCPL Encoding/Decoding"); - if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") + TESTING("GCPL Encoding/Decoding"); - PASSED(); + if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) + FAIL_STACK_ERROR - TESTING("OCPL Encoding/Decoding"); + if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR + /* Query the group creation properties */ + if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) - FAIL_STACK_ERROR + if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) + FAIL_STACK_ERROR - if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) - FAIL_STACK_ERROR + if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(ocpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(gcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE LCPLS *****/ + TESTING("Default LCPL Encoding/Decoding"); + if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DXPLS *****/ - TESTING("Default DXPL Encoding/Decoding"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") - /* Test encoding & decoding default property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") + PASSED(); - PASSED(); + TESTING("LCPL Encoding/Decoding"); - TESTING("DXPL Encoding/Decoding"); + if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) + FAIL_STACK_ERROR - if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) - FAIL_STACK_ERROR -#ifdef H5_HAVE_PARALLEL - if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) - FAIL_STACK_ERROR -#endif/* H5_HAVE_PARALLEL */ - if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) - FAIL_STACK_ERROR - if((H5Pset_data_transform(dxpl, c_to_f)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(dxpl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(lcpl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE GCPLS *****/ - TESTING("Default GCPL Encoding/Decoding"); - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) - FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") + /******* ENCODE/DECODE LAPLS *****/ + TESTING("Default LAPL Encoding/Decoding"); + if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Test encoding & decoding default property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") - TESTING("GCPL Encoding/Decoding"); - - if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) - FAIL_STACK_ERROR - - /* Query the group creation properties */ - if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(gcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + TESTING("LAPL Encoding/Decoding"); + if((H5Pset_nlinks(lapl, (size_t)134)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE LCPLS *****/ - TESTING("Default LCPL Encoding/Decoding"); - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") + if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Create FAPL for the elink FAPL */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR - TESTING("LCPL Encoding/Decoding"); + if((H5Pset_elink_fapl(lapl, fapl)) < 0) + FAIL_STACK_ERROR - if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) - FAIL_STACK_ERROR + /* Close the elink's FAPL */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(lapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE LAPLS *****/ - TESTING("Default LAPL Encoding/Decoding"); - if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE OCPYPLS *****/ + TESTING("Default OCPYPL Encoding/Decoding"); + if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("LAPL Encoding/Decoding"); + TESTING("OCPYPL Encoding/Decoding"); - if((H5Pset_nlinks(lapl, (size_t)134)) < 0) - FAIL_STACK_ERROR + if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) - FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) + FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) - FAIL_STACK_ERROR - - /* Create FAPL for the elink FAPL */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_elink_fapl(lapl, fapl)) < 0) - FAIL_STACK_ERROR - - /* Close the elink's FAPL */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lapl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(ocpypl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE OCPYPLS *****/ - TESTING("Default OCPYPL Encoding/Decoding"); - if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE FAPLS *****/ + TESTING("Default FAPL Encoding/Decoding"); + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("OCPYPL Encoding/Decoding"); + TESTING("FAPL Encoding/Decoding"); - if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) - FAIL_STACK_ERROR + if((H5Pset_family_offset(fapl, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_meta_block_size(fapl, 2098452)) < 0) + FAIL_STACK_ERROR + if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) + FAIL_STACK_ERROR + if((H5Pset_gc_references(fapl, 1)) < 0) + FAIL_STACK_ERROR + if((H5Pset_small_data_block_size(fapl, 2048)) < 0) + FAIL_STACK_ERROR + if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + FAIL_STACK_ERROR + if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) + FAIL_STACK_ERROR + if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) + FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) - FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(ocpypl)) < 0) - FAIL_STACK_ERROR - - PASSED(); - - - /******* ENCODE/DECODE FAPLS *****/ - TESTING("Default FAPL Encoding/Decoding"); - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding default property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - - PASSED(); - - TESTING("FAPL Encoding/Decoding"); - - if((H5Pset_family_offset(fapl, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_meta_block_size(fapl, 2098452)) < 0) - FAIL_STACK_ERROR - if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) - FAIL_STACK_ERROR - if((H5Pset_gc_references(fapl, 1)) < 0) - FAIL_STACK_ERROR - if((H5Pset_small_data_block_size(fapl, 2048)) < 0) - FAIL_STACK_ERROR - if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) - FAIL_STACK_ERROR - if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) - FAIL_STACK_ERROR - if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE FCPLS *****/ - TESTING("Default FCPL Encoding/Decoding"); + /******* ENCODE/DECODE FCPLS *****/ + TESTING("Default FCPL Encoding/Decoding"); - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("FCPL Encoding/Decoding"); + TESTING("FCPL Encoding/Decoding"); - if((H5Pset_userblock(fcpl, 1024) < 0)) - FAIL_STACK_ERROR + if((H5Pset_userblock(fcpl, 1024) < 0)) + FAIL_STACK_ERROR - if((H5Pset_istore_k(fcpl, 3) < 0)) - FAIL_STACK_ERROR + if((H5Pset_istore_k(fcpl, 3) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sym_k(fcpl, 4, 5) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sym_k(fcpl, 4, 5) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sizes(fcpl, 8, 4) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sizes(fcpl, 8, 4) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(fcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE STRCPLS *****/ - TESTING("Default STRCPL Encoding/Decoding"); + /******* ENCODE/DECODE STRCPLS *****/ + TESTING("Default STRCPL Encoding/Decoding"); - if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) - FAIL_STACK_ERROR + if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("STRCPL Encoding/Decoding"); + TESTING("STRCPL Encoding/Decoding"); - if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(strcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(strcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE ACPLS *****/ - TESTING("Default ACPL Encoding/Decoding"); + /******* ENCODE/DECODE ACPLS *****/ + TESTING("Default ACPL Encoding/Decoding"); - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) - FAIL_STACK_ERROR + if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("ACPL Encoding/Decoding"); + TESTING("ACPL Encoding/Decoding"); - if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(acpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(acpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + } /* end high */ + } /* end low */ return 0; diff --git a/test/gen_plist.c b/test/gen_plist.c index 68da6cc..8f38b1a 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -466,13 +466,13 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ - if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); HDassert(temp_buf); - if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); diff --git a/test/th5s.c b/test/th5s.c index 07d31ed..3e340e8 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -90,7 +90,21 @@ struct space4_struct { unsigned u; float f; char c2; - } space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ +} space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ + +/* + * Testing configuration defines used by: + * test_h5s_encode_regular_hyper() + * test_h5s_encode_irregular_hyper() + * test_h5s_encode_points() + */ +#define CONFIG_8 1 +#define CONFIG_16 2 +#define CONFIG_32 3 +#define POWER8 256 /* 2^8 */ +#define POWER16 65536 /* 2^16 */ +#define POWER32 4294967296 /* 2^32 */ + /**************************************************************** ** @@ -1163,27 +1177,30 @@ test_h5s_zero_dim(void) ** ** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. ** +** Note: See "RFC: H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void -test_h5s_encode(void) +test_h5s_encode(H5F_libver_t low, H5F_libver_t high) { - hid_t sid1, sid2, sid3; /* Dataspace ID */ - hid_t decoded_sid1, decoded_sid2, decoded_sid3; - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - size_t sbuf_size=0, null_size=0, scalar_size=0; - unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - hsize_t start[] = {0, 0, 0}; - hsize_t stride[] = {2, 5, 3}; - hsize_t count[] = {2, 2, 2}; - hsize_t block[] = {1, 3, 1}; - H5S_sel_type sel_type; - H5S_class_t space_type; - hssize_t nblocks; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hid_t fapl = -1; /* File access property list ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace Encoding and Decoding\n")); @@ -1192,26 +1209,40 @@ test_h5s_encode(void) * Test encoding and decoding of simple dataspace and hyperslab selection. *------------------------------------------------------------------------- */ + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Set the hyperslab selection */ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer */ - ret = H5Sencode(sid1, NULL, &sbuf_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, NULL, &sbuf_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); - if(sbuf_size>0) + if(sbuf_size>0) { sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } /* Try decoding bogus buffer */ H5E_BEGIN_TRY { - ret_id = H5Sdecode(sbuf); + ret_id = H5Sdecode(sbuf); } H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); - ret = H5Sencode(sid1, sbuf, &sbuf_size); + /* Encode the simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, sbuf, &sbuf_size, fapl); CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ @@ -1224,22 +1255,26 @@ test_h5s_encode(void) VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + /* Retrieve and verify the dataspace dimensions */ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); - /* Verify hyperslabe selection */ + /* Verify the type of dataspace selection */ sel_type = H5Sget_select_type(decoded_sid1); VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + /* Verify the number of hyperslab blocks */ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + /* Close the dataspaces */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -1254,23 +1289,27 @@ test_h5s_encode(void) CHECK(sid2, FAIL, "H5Screate"); /* Encode null data space in a buffer */ - ret = H5Sencode(sid2, NULL, &null_size); + ret = H5Sencode2(sid2, NULL, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(null_size>0) + if(null_size>0) { null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } - ret = H5Sencode(sid2, null_sbuf, &null_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode the null data space in the buffer */ + ret = H5Sencode2(sid2, null_sbuf, &null_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ decoded_sid2=H5Sdecode(null_sbuf); CHECK(decoded_sid2, FAIL, "H5Sdecode"); - /* Verify decoded dataspace */ + /* Verify the decoded dataspace type */ space_type = H5Sget_simple_extent_type(decoded_sid2); VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + /* Close the dataspaces */ ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); @@ -1286,14 +1325,17 @@ test_h5s_encode(void) CHECK(sid3, FAIL, "H5Screate_simple"); /* Encode scalar data space in a buffer */ - ret = H5Sencode(sid3, NULL, &scalar_size); + ret = H5Sencode2(sid3, NULL, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(scalar_size>0) + if(scalar_size>0) { scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } - ret = H5Sencode(sid3, scalar_buf, &scalar_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode the scalar data space in the buffer */ + ret = H5Sencode2(sid3, scalar_buf, &scalar_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ decoded_sid3=H5Sdecode(scalar_buf); @@ -1308,20 +1350,553 @@ test_h5s_encode(void) CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid3); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); + /* Close the dataspaces */ ret = H5Sclose(sid3); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(decoded_sid3); CHECK(ret, FAIL, "H5Sclose"); - HDfree(sbuf); - HDfree(null_sbuf); - HDfree(scalar_buf); -} /* test_h5s_encode() */ + /* Close the file access property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode() */ + + +/**************************************************************** +** +** test_h5s_check_encoding(): +** This is the helper routine to verify that H5Sencode2() +** works as specified in the RFC for the library format setting +** in the file access property list. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +** This routine is used by: +** test_h5s_encode_regular_hyper() +** test_h5s_encode_irregular_hyper() +** test_h5s_encode_points() +** +****************************************************************/ +static herr_t +test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, + uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail) +{ + char *buf = NULL; /* Pointer to the encoded buffer */ + size_t buf_size; /* Size of the encoded buffer */ + hid_t d_sid = -1; /* The decoded dataspace ID */ + htri_t check; + hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */ + hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */ + hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */ + hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */ + herr_t ret; /* Return value */ + + /* Get buffer size for encoding with the format setting in in_fapl */ + H5E_BEGIN_TRY { + ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl); + } H5E_END_TRY + + if(expected_to_fail) { + VERIFY(ret, FAIL, "H5Screate_simple"); + } else { + + CHECK(ret, FAIL, "H5Sencode2"); + + /* Allocate the buffer for encoding */ + buf = (char *)HDmalloc(buf_size); + CHECK(buf, NULL, "H5Dmalloc"); + + /* Encode according to the setting in in_fapl */ + ret = H5Sencode2(in_sid, buf, &buf_size, in_fapl); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode the buffer */ + d_sid = H5Sdecode(buf); + CHECK(d_sid, FAIL, "H5Sdecode"); + + /* Verify the number of selected points for in_sid and d_sid */ + VERIFY(H5Sget_select_npoints(in_sid), H5Sget_select_npoints(d_sid), "Compare npoints"); + + /* Verify if the two dataspace selections (in_sid, d_sid) are the same shape */ + check = H5S__select_shape_same_test(in_sid, d_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); + + /* Compare the starting/ending coordinates of the bounding box for in_sid and d_sid */ + ret = H5Sget_select_bounds(in_sid, in_low_bounds, in_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + ret = H5Sget_select_bounds(d_sid, d_low_bounds, d_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(in_low_bounds[0], d_low_bounds[0], "Compare selection low bounds"); + VERIFY(in_high_bounds[0], d_high_bounds[0], "Compare selection high bounds"); + + /* + * See "RFC: H5Sencode/H5Sdeocde Format Change" for the verification of: + * H5S_SEL_POINTS: + * --the expected version for point selection info + * --the expected encoded size (version 2 points selection info) + * H5S_SEL_HYPERSLABS: + * --the expected version for hyperslab selection info + * --the expected encoded size (version 3 hyperslab selection info) + */ + + if(H5Sget_select_type(in_sid) == H5S_SEL_POINTS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for point selection"); + + /* Verify the encoded size for version 2 */ + if(expected_version == 2) + VERIFY((uint8_t)buf[39], expected_enc_size, "Encoded size of point selection info"); + } + + if(H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for hyperslab selection info"); + + /* Verify the encoded size for version 3 */ + if(expected_version == 3) + VERIFY((uint8_t)buf[40], expected_enc_size, "Encoded size of selection info"); + + } /* hyperslab selection */ + + ret = H5Sclose(d_sid); + CHECK(ret, FAIL, "H5Sclose"); + if(buf) + HDfree(buf); + + } + + return(0); + +} /* test_h5s_check_encoding */ + +/**************************************************************** +** +** test_h5s_encode_regular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for regular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + unsigned config; /* Testing configuration */ + unsigned unlim; /* H5S_UNLIMITED setting or not */ + herr_t ret; /* Generic return value */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_16; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; + + /* Testing with unlimited or not */ + for(unlim = 0; unlim <= 1; unlim++) { + start = 0; + count = unlim? H5S_UNLIMITED : 2; + + if((high <= H5F_LIBVER_V18) && + (unlim || config == CONFIG_32)) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112) + expected_version = 3; + else if(config == CONFIG_16 && !unlim) + expected_version = 1; + else + expected_version = 2; + + /* test 1 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 4 : 8; + + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 2; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 2; + expected_enc_size = expected_version == 3 ? 4 : 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 4 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = POWER16 - 2; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = POWER32 - 2; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 5 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for unlim */ + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* test_h5s_encode_regular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_irregular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for irregular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + htri_t is_regular; /* Is this a regular hyperslab */ + unsigned config; /* Testing configuration */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of irregular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_8; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + start = 0; + count = 2; + block = 4; + + /* H5Sencode2 is expected to fail for library v110 and below + when the selection exceeds the 32 bits integer limit */ + if(high <= H5F_LIBVER_V110 && config == CONFIG_32) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112 || config == CONFIG_32) + expected_version = 3; + else + expected_version = 1; + + switch(config) { + case CONFIG_8: + stride = POWER8 - 2; + break; + + case CONFIG_16: + stride = POWER16 - 2; + break; + + case CONFIG_32: + stride = POWER32 - 2; + break; + + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + start = 8; + count = 5; + block = 2; + + switch(config) { + case CONFIG_8: + stride = POWER8; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + + case CONFIG_16: + stride = POWER16; + expected_enc_size = 4; + break; + + case CONFIG_32: + stride = POWER32; + expected_enc_size = 8; + break; + + default: + assert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Should be irregular hyperslab */ + is_regular = H5Sis_regular_hyperslab(sid); + VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_irregular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_points(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for point selection. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimenion size */ + unsigned num_dsets = 513; /* used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t coord[4]; /* The point coordinates */ + herr_t ret; /* Generic return value */ + hbool_t expected_to_fail = FALSE; /* Expected to fail or not */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of points selection\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* test 1 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER16; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + expected_to_fail = FALSE; + expected_enc_size = 4; + expected_version = 1; + + if(low >= H5F_LIBVER_V112) + expected_version = 2; + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 - 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Expected result same as test 1 */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + if(high <= H5F_LIBVER_V110) + expected_to_fail = TRUE; + + if(high >= H5F_LIBVER_V112) { + expected_version = 2; + expected_enc_size = 8; + } + + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 + 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_points() */ /**************************************************************** ** @@ -1362,7 +1937,7 @@ test_h5s_encode_length(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Encode simple data space in a buffer */ - ret = H5Sencode(sid, NULL, &sbuf_size); + ret = H5Sencode2(sid, NULL, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Allocate the buffer */ @@ -1372,7 +1947,7 @@ test_h5s_encode_length(void) } /* Encode the dataspace */ - ret = H5Sencode(sid, sbuf, &sbuf_size); + ret = H5Sencode2(sid, sbuf, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Verify that length stored at this location in the buffer is correct */ @@ -1400,7 +1975,6 @@ test_h5s_encode_length(void) } /* test_h5s_encode_length() */ - /**************************************************************** ** ** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code. @@ -1409,14 +1983,14 @@ test_h5s_encode_length(void) static void test_h5s_scalar_write(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - H5S_class_t ext_type; /* Extent type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + H5S_class_t ext_type; /* Extent type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Writing\n")); @@ -1435,14 +2009,17 @@ test_h5s_scalar_write(void) sid1 = H5Screate_simple(SPACE3_RANK, NULL, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Retrieve the number of elements in the dataspace selection */ n = H5Sget_simple_extent_npoints(sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Get the dataspace rank */ rank = H5Sget_simple_extent_ndims(sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE3_RANK, "H5Sget_simple_extent_ndims"); + /* Get the dataspace dimension sizes */ rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); VERIFY(rank, 0, "H5Sget_simple_extent_dims"); @@ -1454,6 +2031,7 @@ test_h5s_scalar_write(void) dataset = H5Dcreate2(fid1, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); + /* Write to the dataset */ ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &space3_data); CHECK(ret, FAIL, "H5Dwrite"); @@ -1468,7 +2046,7 @@ test_h5s_scalar_write(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_scalar_write() */ +} /* test_h5s_scalar_write() */ /**************************************************************** ** @@ -2587,16 +3165,34 @@ test_versionbounds(void) void test_h5s(void) { + H5F_libver_t low, high; /* Low and high bounds */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); /* Test basic H5S code */ - test_h5s_null(); /* Test Null dataspace H5S code */ + test_h5s_basic(); /* Test basic H5S code */ + test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ - test_h5s_encode(); /* Test encoding and decoding */ - test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + test_h5s_encode(low, high); /* Test encoding and decoding */ + test_h5s_encode_regular_hyper(low, high); /* Test encoding regular hyperslabs */ + test_h5s_encode_irregular_hyper(low, high); /* Test encoding irregular hyperslabs */ + test_h5s_encode_points(low, high); /* Test encoding points */ + + } /* end high bound */ + } /* end low bound */ + + test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ test_h5s_scalar_write(); /* Test scalar H5S writing code */ - test_h5s_scalar_read(); /* Test scalar H5S reading code */ + test_h5s_scalar_read(); /* Test scalar H5S reading code */ test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */ diff --git a/test/trefer.c b/test/trefer.c index 938f040..4bf9caf 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -490,16 +490,20 @@ test_reference_obj(void) ** test_reference_region(): Test basic H5R (reference) object reference code. ** Tests references to various kinds of objects ** +** Note: The libver_low/libver_high parameters are added to create the file +** with the low and high bounds setting in fapl. +** Please see the RFC for "H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ + hid_t fid1; /* HDF5 File IDs */ hid_t fapl = -1; /* File access property list */ - hid_t dset1, /* Dataset ID */ + hid_t dset1, /* Dataset ID */ dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; @@ -508,24 +512,24 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE2_RANK]; /* Selection bounds */ - hsize_t high[SPACE2_RANK]; /* Selection bounds */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Type of object */ - int i, j; /* counting variables */ - hssize_t hssize_ret; /* hssize_t return value */ - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* Generic return value */ - haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ - hid_t dset_NA; /* Dataset id for undefined reference */ - hid_t space_NA; /* Dataspace id for undefined reference */ - hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE2_RANK]; /* Selection bounds */ + hsize_t high[SPACE2_RANK]; /* Selection bounds */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Type of object */ + int i, j; /* counting variables */ + hssize_t hssize_ret; /* hssize_t return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* Generic return value */ + haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ + hid_t dset_NA; /* Dataset id for undefined reference */ + hid_t space_NA; /* Dataspace id for undefined reference */ + hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ hdset_reg_ref_t wdata_NA[1], /* Write buffer */ rdata_NA[1]; /* Read buffer */ @@ -634,8 +638,14 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); /* Store third dataset region */ - ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - CHECK(ret, FAIL, "H5Rcreate"); + H5E_BEGIN_TRY { + ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); + } H5E_END_TRY; + + if(libver_high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Rcreate"); + else + CHECK(ret, FAIL, "H5Rcreate"); ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf[0], &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type2"); diff --git a/test/vds.c b/test/vds.c index 67af8e3..db01b2b 100644 --- a/test/vds.c +++ b/test/vds.c @@ -420,11 +420,11 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, size_t plist_buf_size; /* Encode property list to plist_buf */ - if(H5Pencode(dcpl, NULL, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0) TEST_ERROR if(NULL == (plist_buf = HDmalloc(plist_buf_size))) TEST_ERROR - if(H5Pencode(dcpl, plist_buf, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0) TEST_ERROR /* Decode serialized property list to *ex_dcpl */ @@ -469,7 +469,7 @@ error: /* Main test function */ static int -test_api(test_api_config_t config, hid_t fapl) +test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) { char filename[FILENAME_BUF_SIZE]; hid_t dcpl = -1; /* Dataset creation property list */ @@ -618,7 +618,8 @@ test_api(test_api_config_t config, hid_t fapl) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)213) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)99:(low >= H5F_LIBVER_V110?174:213)) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -1025,7 +1026,8 @@ test_api(test_api_config_t config, hid_t fapl) } /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)697) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)607:(hsize_t)697) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -11598,6 +11600,11 @@ test_dapl_values(hid_t fapl_id) * * Purpose: Tests datasets with virtual layout * + * Note: + * Tests are modified to test with the low/high bounds combination + * set in fapl. + * Please see RFC for "H5Sencode/H5Sdecode Format Change". + * * Return: EXIT_SUCCESS/EXIT_FAILURE *------------------------------------------------------------------------- */ @@ -11606,8 +11613,11 @@ main(void) { char filename[FILENAME_BUF_SIZE]; hid_t fapl; + hid_t my_fapl = -1; /* File access property list */ int test_api_config; unsigned bit_config; + unsigned latest = FALSE; /* Using the latest library version bound */ + H5F_libver_t low, high; /* Low and high bounds */ int nerrors = 0; /* Testing setup */ @@ -11616,21 +11626,59 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) - nerrors += test_api((test_api_config_t)test_api_config, fapl); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_basic_io(bit_config, fapl); - nerrors += test_vds_prefix(bit_config, fapl); - nerrors += test_unlim(bit_config, fapl); - nerrors += test_printf(bit_config, fapl); - nerrors += test_all(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) + nerrors += test_api((test_api_config_t)test_api_config, my_fapl, low); + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_basic_io(bit_config, my_fapl); + nerrors += test_vds_prefix(bit_config, my_fapl); + nerrors += test_unlim(bit_config, my_fapl); + nerrors += test_printf(bit_config, my_fapl); + nerrors += test_all(bit_config, my_fapl); + } - nerrors += test_dapl_values(fapl); + nerrors += test_dapl_values(my_fapl); - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; diff --git a/testpar/t_prop.c b/testpar/t_prop.c index d5efa94..2eb3914 100644 --- a/testpar/t_prop.c +++ b/testpar/t_prop.c @@ -33,12 +33,12 @@ test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc) int send_size = 0; /* first call to encode returns only the size of the buffer needed */ - ret = H5Pencode(orig_pl, NULL, &buf_size); + ret = H5Pencode2(orig_pl, NULL, &buf_size, H5P_DEFAULT); VRFY((ret >= 0), "H5Pencode succeeded"); sbuf = (uint8_t *)HDmalloc(buf_size); - ret = H5Pencode(orig_pl, sbuf, &buf_size); + ret = H5Pencode2(orig_pl, sbuf, &buf_size, H5P_DEFAULT); VRFY((ret >= 0), "H5Pencode succeeded"); /* this is a temp fix to send this size_t */ -- cgit v0.12 From c57ae996124f708a4d1878e70ff5fb68c312cea7 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Mon, 8 Apr 2019 11:09:11 -0500 Subject: Modification for num_elem based on PR feedback. --- src/H5Spoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Spoint.c b/src/H5Spoint.c index a3f7df2..0bdabb4 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -1272,7 +1272,7 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) uint8_t enc_size = 0; /* Encoded size of selection info */ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ const uint8_t *pp; /* Local pointer for decoding */ - hsize_t num_elem = 0; /* Number of elements in selection */ + uint64_t num_elem = 0; /* Number of elements in selection */ unsigned rank; /* Rank of points */ unsigned i, j; /* local counting variables */ herr_t ret_value = SUCCEED; /* Return value */ -- cgit v0.12 From 3ccc98e256587c43f6ba5a31a2cf9d922f4e1773 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Mon, 8 Apr 2019 12:33:45 -0500 Subject: Modifications based on PR feedback: (1) Add H5Sdeprec.c to src/CMakeLists.txt (2) Add test for H5Sencode1. --- src/CMakeLists.txt | 1 + test/th5s.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f7bd48..9730436 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -533,6 +533,7 @@ set (H5S_SOURCES ${HDF5_SRC_DIR}/H5S.c ${HDF5_SRC_DIR}/H5Sall.c ${HDF5_SRC_DIR}/H5Sdbg.c + ${HDF5_SRC_DIR}/H5Sdeprec.c ${HDF5_SRC_DIR}/H5Shyper.c ${HDF5_SRC_DIR}/H5Smpio.c ${HDF5_SRC_DIR}/H5Snone.c diff --git a/test/th5s.c b/test/th5s.c index 3e340e8..6632a4c 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1375,6 +1375,196 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) HDfree(scalar_buf); } /* test_h5s_encode() */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/**************************************************************** +** +** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. +** +****************************************************************/ +static void +test_h5s_encode1(void) +{ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace Encoding (H5Sencode1) and Decoding\n")); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of simple dataspace and hyperslab selection. + *------------------------------------------------------------------------- + */ + /* Create the dataspace */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode1(sid1, NULL, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode2"); + + if(sbuf_size>0) { + sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } + + /* Try decoding bogus buffer */ + H5E_BEGIN_TRY { + ret_id = H5Sdecode(sbuf); + } H5E_END_TRY; + VERIFY(ret_id, FAIL, "H5Sdecode"); + + /* Encode the simple data space in a buffer */ + ret = H5Sencode1(sid1, sbuf, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid1=H5Sdecode(sbuf); + CHECK(decoded_sid1, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid1); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, + "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid1); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + + /* Retrieve and verify the dataspace dimensions */ + rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); + CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, + "H5Sget_simple_extent_dims"); + + /* Verify the type of dataspace selection */ + sel_type = H5Sget_select_type(decoded_sid1); + VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + + /* Verify the number of hyperslab blocks */ + nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); + VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + + /* Close the dataspaces */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of null dataspace. + *------------------------------------------------------------------------- + */ + sid2 = H5Screate(H5S_NULL); + CHECK(sid2, FAIL, "H5Screate"); + + /* Encode null data space in a buffer */ + ret = H5Sencode1(sid2, NULL, &null_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(null_size>0) { + null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } + + /* Encode the null data space in the buffer */ + ret = H5Sencode1(sid2, null_sbuf, &null_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid2=H5Sdecode(null_sbuf); + CHECK(decoded_sid2, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace type */ + space_type = H5Sget_simple_extent_type(decoded_sid2); + VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Close the dataspaces */ + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid2); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of scalar dataspace. + *------------------------------------------------------------------------- + */ + /* Create scalar dataspace */ + sid3 = H5Screate(H5S_SCALAR); + CHECK(sid3, FAIL, "H5Screate_simple"); + + /* Encode scalar data space in a buffer */ + ret = H5Sencode1(sid3, NULL, &scalar_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(scalar_size>0) { + scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } + + /* Encode the scalar data space in the buffer */ + ret = H5Sencode1(sid3, scalar_buf, &scalar_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid3=H5Sdecode(scalar_buf); + CHECK(decoded_sid3, FAIL, "H5Sdecode"); + + /* Verify extent type */ + space_type = H5Sget_simple_extent_type(decoded_sid3); + VERIFY(space_type, H5S_SCALAR, "H5Sget_simple_extent_type"); + + /* Verify decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid3); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid3); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); + + /* Close the dataspaces */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + /**************************************************************** ** @@ -3191,6 +3381,10 @@ test_h5s(void) } /* end low bound */ test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_h5s_scalar_write(); /* Test scalar H5S writing code */ test_h5s_scalar_read(); /* Test scalar H5S reading code */ -- cgit v0.12 From 477dda3c0daea39cdf409684e7dad0fd9367dd45 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 9 Apr 2019 16:20:19 -0500 Subject: HDFFV-10658 - setting and getting properties in API context: 1. switched to use the existing H5F_prefix_open_t for enum type; 2. put the common private function used by external.c and external_env.c into external_common.c --- MANIFEST | 4 ++ src/H5Dint.c | 22 +++----- src/H5Fprivate.h | 7 ++- src/H5VLnative_dataset.c | 1 + test/Makefile.am | 4 +- test/external.h | 144 ----------------------------------------------- test/external_common.c | 121 +++++++++++++++++++++++++++++++++++++++ test/external_common.h | 45 +++++++++++++++ test/external_env.c | 9 ++- 9 files changed, 190 insertions(+), 167 deletions(-) delete mode 100644 test/external.h create mode 100644 test/external_common.c create mode 100644 test/external_common.h diff --git a/MANIFEST b/MANIFEST index 7cb2cfd..0a389a1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -991,6 +991,9 @@ ./test/evict_on_close.c ./test/extend.c ./test/external.c +./test/external_common.c +./test/external_common.h +./test/external_env.c ./test/error_test.c ./test/err_compat.c ./test/filter_error.h5 @@ -1115,6 +1118,7 @@ ./test/tcoords.c ./test/testabort_fail.sh.in ./test/testcheck_version.sh.in +./test/testexternal_env.sh.in ./test/testerror.sh.in ./test/testlinks_env.sh.in ./test/test_filter_plugin.sh.in diff --git a/src/H5Dint.c b/src/H5Dint.c index 6ace085..208d879 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -43,12 +43,6 @@ /* Local Typedefs */ /******************/ -/* Type of prefix for file */ -typedef enum { - H5D_PREFIX_TYPE_UNKNOWN=0, - H5D_PREFIX_TYPE_EXT=1, - H5D_PREFIX_TYPE_VDS=2 -} H5D_prefix_type_t; /********************/ /* Local Prototypes */ @@ -60,7 +54,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); -static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix); +static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); @@ -1094,7 +1088,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1115,14 +1109,14 @@ H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char ** /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(H5D_PREFIX_TYPE_VDS == prefix_type) { + if(H5F_PREFIX_VDS == prefix_type) { prefix = (char *)H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } - } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { + } else if(H5F_PREFIX_EFILE == prefix_type) { prefix = (char *)H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { @@ -1338,11 +1332,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ @@ -1497,11 +1491,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e3860a0..553e16b 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,8 +702,11 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_VDS, /* Virtual dataset prefix */ - H5F_PREFIX_ELINK /* External link prefix */ + H5D_PREFIX_ERROR = -1, /* Error */ + H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ + H5F_PREFIX_ELINK = 1, /* External link prefix */ + H5F_PREFIX_EFILE = 2, /* External file prefix */ + H5F_PREFIX_NONE = 3 /* Must be the last */ } H5F_prefix_open_t; diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index aa65e54..8f7351c 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -61,6 +61,7 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + /* Get creation properties */ if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) diff --git a/test/Makefile.am b/test/Makefile.am index 68b9394..55b5a88 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -63,7 +63,7 @@ TEST_PROG= testhdf5 \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ enc_dec_plist_cross_platform getname vfd ntypes dangle dtransform \ reserved cross_read freespace mf vds file_image unregister \ - cache_logging cork swmr vol + cache_logging cork swmr vol_tst # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. @@ -135,7 +135,7 @@ else noinst_LTLIBRARIES=libh5test.la endif -libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c +libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c # Use libhd5test.la to compile all of the tests LDADD=libh5test.la $(LIBHDF5) diff --git a/test/external.h b/test/external.h deleted file mode 100644 index 1c660e1..0000000 --- a/test/external.h +++ /dev/null @@ -1,144 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Wednesday, March 17, 2010 - * - * Purpose: srcdir querying support. - */ -#ifndef _EXTERNAL_H -#define _EXTERNAL_H - -/* Include test header files */ -#include "h5test.h" - -const char *FILENAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; - -/* A similar collection of files is used for the tests that - * perform file I/O. - */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 - - -/*------------------------------------------------------------------------- - * Function: reset_raw_data_files - * - * Purpose: Resets the data in the raw data files for tests that - * perform dataset I/O on a set of files. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -reset_raw_data_files(void) -{ - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ - - /* Set up garbage buffer */ - garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) - goto error; - for(i = 0; i < garbage_count; i++) - garbage[i] = 0xFF; - - /* The *r files are pre-filled with data and are used to - * verify that read operations work correctly. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { - data[j] = (int)(i * 25 + j); - } /* end for */ - - /* Write raw data to the file. */ - n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - - /* The *w files are only pre-filled with the garbage data and are - * used to verify that write operations work correctly. The individual - * tests fill in the actual data. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - HDfree(garbage); - return SUCCEED; - -error: - if(fd) - HDclose(fd); - if(garbage) - HDfree(garbage); - return FAIL; -} /* end reset_raw_data_files() */ -#endif /* _EXTERNAL_H */ - diff --git a/test/external_common.c b/test/external_common.c new file mode 100644 index 0000000..e43a713 --- /dev/null +++ b/test/external_common.c @@ -0,0 +1,121 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ + +#include "external_common.h" + + +/*------------------------------------------------------------------------- + * Function: reset_raw_data_files + * + * Purpose: Resets the data in the raw data files for tests that + * perform dataset I/O on a set of files. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * February 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +reset_raw_data_files(void) +{ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ + + /* Set up garbage buffer */ + garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; + if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + goto error; + for(i = 0; i < garbage_count; i++) + garbage[i] = 0xFF; + + /* The *r files are pre-filled with data and are used to + * verify that read operations work correctly. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Fill array with data */ + for(j = 0; j < PART_SIZE; j++) { + data[j] = (int)(i * 25 + j); + } /* end for */ + + /* Write raw data to the file. */ + n = HDwrite(fd, data, sizeof(data)); + if(n != sizeof(data)) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + + /* The *w files are only pre-filled with the garbage data and are + * used to verify that write operations work correctly. The individual + * tests fill in the actual data. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + HDfree(garbage); + return SUCCEED; + +error: + if(fd) + HDclose(fd); + if(garbage) + HDfree(garbage); + return FAIL; +} diff --git a/test/external_common.h b/test/external_common.h new file mode 100644 index 0000000..f1a15b5 --- /dev/null +++ b/test/external_common.h @@ -0,0 +1,45 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ +#ifndef _EXTERNAL_COMMON_H +#define _EXTERNAL_COMMON_H + +/* Include test header files */ +#include "h5test.h" + +static const char *EXT_FNAME[] = { + "extern_1", + "extern_2", + "extern_3", + "extern_4", + "extern_dir/file_1", + "extern_5", + NULL +}; + +/* A similar collection of files is used for the tests that + * perform file I/O. + */ +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 + +herr_t reset_raw_data_files(void); +#endif /* _EXTERNAL_COMMON_H */ diff --git a/test/external_env.c b/test/external_env.c index 97daef2..2f5f838 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -17,8 +17,7 @@ * * Purpose: Tests datasets stored in external raw files. */ -#include "h5test.h" -#include "external.h" +#include "external_common.h" /*------------------------------------------------------------------------- @@ -63,7 +62,7 @@ test_path_env(hid_t fapl) if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -156,7 +155,7 @@ main(void) /* Get a fapl for the old (default) file format */ fapl_id_old = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) @@ -189,7 +188,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(FILENAME, fapl_id_old)) { + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); -- cgit v0.12 From 04d07d967a12f6aeeb4fa5bee99526ab328b509a Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 9 Apr 2019 17:40:24 -0500 Subject: Left out this file in previous commit. --- test/external.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/external.c b/test/external.c index 5ff65e6..af45445 100644 --- a/test/external.c +++ b/test/external.c @@ -17,8 +17,7 @@ * * Purpose: Tests datasets stored in external raw files. */ -#include "h5test.h" -#include "external.h" +#include "external_common.h" /*------------------------------------------------------------------------- @@ -643,7 +642,7 @@ test_read_file_set(hid_t fapl) * debugging to be emitted before we start playing games with what the * output looks like. */ - h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[1], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -754,7 +753,7 @@ test_write_file_set(hid_t fapl) TEST_ERROR /* Create another file */ - h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[2], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -872,7 +871,7 @@ test_path_absolute(hid_t fapl) TESTING("absolute filenames for external file"); - h5_fixname(FILENAME[3], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[3], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -968,7 +967,7 @@ test_path_relative(hid_t fapl) if (HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; @@ -1063,7 +1062,7 @@ test_path_relative_cwd(hid_t fapl) if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; @@ -1214,7 +1213,7 @@ test_h5d_get_access_plist(hid_t fapl_id) TEST_ERROR /* Create the file */ - h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[5], fapl_id, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR @@ -1305,7 +1304,7 @@ main(void) /* Get a fapl for the old (default) file format */ fapl_id_old = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) @@ -1360,7 +1359,7 @@ main(void) nerrors += test_path_relative_cwd(current_fapl_id); /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, current_fapl_id) < 0 ? 1 : 0); + nerrors += (h5_verify_cached_stabs(EXT_FNAME, current_fapl_id) < 0 ? 1 : 0); /* Close the common file */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR @@ -1375,7 +1374,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(FILENAME, fapl_id_old)) { + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); -- cgit v0.12 From 06002f8c22b46d69cf4951eba0bbca946955c0d0 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 10:21:38 -0500 Subject: Minor fixes: updating the test vds_env.c according to the set up of vds.c. --- src/H5Fprivate.h | 2 +- test/vds_env.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 553e16b..80d7229 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,7 +702,7 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5D_PREFIX_ERROR = -1, /* Error */ + H5F_PREFIX_ERROR = -1, /* Error */ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ H5F_PREFIX_ELINK = 1, /* External link prefix */ H5F_PREFIX_EFILE = 2, /* External file prefix */ diff --git a/test/vds_env.c b/test/vds_env.c index d73336d..b42bb00 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -294,22 +294,62 @@ int main(void) { char filename[FILENAME_BUF_SIZE]; - hid_t fapl; + hid_t fapl, my_fapl; int test_api_config; unsigned bit_config; + H5F_libver_t low, high; /* Low and high bounds */ + unsigned latest = FALSE; /* Using the latest library version bound */ int nerrors = 0; /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_vds_prefix_second(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; -- cgit v0.12 From bf6479fcee4cb05302f5733d6e81667b0c3d4273 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 11:22:24 -0500 Subject: Minor fix: removal of unnecessary enum values. --- src/H5Fprivate.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 80d7229..0fa2214 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,11 +702,9 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_ERROR = -1, /* Error */ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ H5F_PREFIX_ELINK = 1, /* External link prefix */ - H5F_PREFIX_EFILE = 2, /* External file prefix */ - H5F_PREFIX_NONE = 3 /* Must be the last */ + H5F_PREFIX_EFILE = 2 /* External file prefix */ } H5F_prefix_open_t; -- cgit v0.12 From 417cd9da87a7854148c1db1755531af6818a613e Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 16:02:28 -0500 Subject: Updated CMake for the splitting of external.c and vds.c. --- test/CMakeLists.txt | 2 + test/CMakeTests.cmake | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 772f790..f335fa2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -236,6 +236,7 @@ set (H5_TESTS extend direct_chunk # compression lib link external + external_env efc objcopy links @@ -255,6 +256,7 @@ set (H5_TESTS enc_dec_plist_cross_platform getname vfd + vfd_env ntypes dangle dtransform diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index c606eb1..40984b5 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -542,8 +542,10 @@ set (H5TEST_SEPARATE_TESTS testhdf5 cache cache_image + external_env flush1 flush2 + vds_env ) foreach (h5_test ${H5_TESTS}) if (NOT h5_test IN_LIST H5TEST_SEPARATE_TESTS) @@ -679,6 +681,49 @@ set_tests_properties (H5TEST-cache_image PROPERTIES ) endif () +#-- Adding test for external_env +add_test ( + NAME H5TEST-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETUP external_env_clear_objects) +add_test (NAME H5TEST-external_env COMMAND $) +set_tests_properties (H5TEST-external_env PROPERTIES + FIXTURES_REQUIRED external_env_clear_objects + ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + +#-- Adding test for vds_env +add_test ( + NAME H5TEST-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds_env_clear_objects) +add_test (NAME H5TEST-vds_env COMMAND $) +set_tests_properties (H5TEST-vds_env PROPERTIES + FIXTURES_REQUIRED vds_env_clear_objects + ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + if (BUILD_SHARED_LIBS) #-- Adding test for cache if (NOT CYGWIN AND NOT WIN32) @@ -1041,6 +1086,67 @@ if (BUILD_SHARED_LIBS) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) + #-- Adding test for external_env + add_test (NAME H5TEST-shared-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-external_env-objects PROPERTIES FIXTURES_SETUP shared_external_env_clear_objects) + add_test (NAME H5TEST-shared-external_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=external_env.txt" + -D "TEST_REFERENCE=external_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-external_env PROPERTIES + FIXTURES_REQUIRED shared_external_env_clear_objects + ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for vds_env + add_test (NAME H5TEST-shared-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-vds_env-objects PROPERTIES FIXTURES_SETUP shared_vds_env_clear_objects) + add_test (NAME H5TEST-shared-vds_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}/tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=vds_env.txt" + -D "TEST_REFERENCE=vds_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-vds_env PROPERTIES + FIXTURES_REQUIRED shared_vds_env_clear_objects + ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + #-- Adding test for libinfo add_test (NAME H5TEST-shared-testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$" -P "${GREP_RUNNER}" -- cgit v0.12 From c0e05f07470df35b5ceeebdf242cb830058713ab Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 16:48:42 -0500 Subject: Forgot to add external_common.c and external_common.h. --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f335fa2..8437e72 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,12 +14,14 @@ set (TEST_LIB_SOURCES ${HDF5_TEST_SOURCE_DIR}/h5test.c ${HDF5_TEST_SOURCE_DIR}/testframe.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c + ${HDF5_TEST_SOURCE_DIR}/external_common.c ${HDF5_TEST_SOURCE_DIR}/swmr_common.c ) set (TEST_LIB_HEADERS ${HDF5_TEST_SOURCE_DIR}/h5test.h ${HDF5_TEST_SOURCE_DIR}/cache_common.h + ${HDF5_TEST_SOURCE_DIR}/external_common.h ${HDF5_TEST_SOURCE_DIR}/swmr_common.h ) -- cgit v0.12 From a58c01aac18bc68be22296c51c3d327d1220ce28 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 10:19:45 -0500 Subject: Small correction for my previous commit. --- test/CMakeTests.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 40984b5..b5120d8 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1115,7 +1115,7 @@ if (BUILD_SHARED_LIBS) ) set_tests_properties (H5TEST-shared-external_env PROPERTIES FIXTURES_REQUIRED shared_external_env_clear_objects - ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) @@ -1143,7 +1143,7 @@ if (BUILD_SHARED_LIBS) ) set_tests_properties (H5TEST-shared-vds_env PROPERTIES FIXTURES_REQUIRED shared_vds_env_clear_objects - ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) -- cgit v0.12 From ff51724bdbd1afcc494d9720e2f1192bda4810df Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 11 Apr 2019 10:46:22 -0700 Subject: Renamed the autotools check-vol target to check-passthrough-vol. --- Makefile.am | 6 ++++-- bin/snapshot | 25 ++++++++++++++----------- config/commence.am | 4 ++-- config/conclude.am | 6 ++++-- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Makefile.am b/Makefile.am index b48bb30..7f872b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -186,8 +186,10 @@ check-vfd: fi; \ done -# Run tests with different Virtual Object Layer Connectors. -check-vol: +# Run tests with different passthrough Virtual Object Layer Connectors. +# NOTE: Will only succeed with passthrough VOL connectors that use +# the native VOL connector as the terminal connector. +check-passthrough-vol: for d in $(SUBDIRS); do \ if test $$d != .; then \ (cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ diff --git a/bin/snapshot b/bin/snapshot index 5900728..1218caa 100755 --- a/bin/snapshot +++ b/bin/snapshot @@ -130,10 +130,10 @@ DISPLAYUSAGE() set - cat < [diff] [test] [srcdir] [release] [help] - [clean] [distclean] [echo] [deploy ] [deploydir ] - [zlib ] [releasedir ] [srcdirname ] [check-vfd] - [check-vol] - [exec ] [module-load ] [op-configure