From 861a849530df32d9f1a495eb8b82877198dab7de Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 3 Mar 2017 08:45:57 -0600 Subject: Description: Only format changes: mostly tabs vs. spaces Platforms tested: Linux/64 (jelly) - very minor --- c++/src/H5AbstractDs.cpp | 436 +++++----- c++/src/H5AbstractDs.h | 68 +- c++/src/H5ArrayType.cpp | 142 ++-- c++/src/H5ArrayType.h | 48 +- c++/src/H5AtomType.cpp | 360 ++++---- c++/src/H5AtomType.h | 60 +- c++/src/H5Attribute.cpp | 500 +++++------ c++/src/H5Attribute.h | 94 +-- c++/src/H5Classes.h | 52 +- c++/src/H5CommonFG.cpp | 413 +++++---- c++/src/H5CommonFG.h | 68 +- c++/src/H5CompType.cpp | 582 ++++++------- c++/src/H5CompType.h | 126 +-- c++/src/H5CppDoc.h | 18 +- c++/src/H5DataSet.cpp | 820 +++++++++--------- c++/src/H5DataSet.h | 120 +-- c++/src/H5DataSpace.cpp | 793 +++++++++-------- c++/src/H5DataSpace.h | 152 ++-- c++/src/H5DataType.cpp | 928 ++++++++++---------- c++/src/H5DataType.h | 156 ++-- c++/src/H5DcreatProp.cpp | 902 ++++++++++---------- c++/src/H5DcreatProp.h | 138 +-- c++/src/H5DxferProp.cpp | 578 ++++++------- c++/src/H5DxferProp.h | 126 +-- c++/src/H5EnumType.cpp | 354 ++++---- c++/src/H5EnumType.h | 72 +- c++/src/H5Exception.cpp | 650 +++++++------- c++/src/H5Exception.h | 154 ++-- c++/src/H5FaccProp.cpp | 862 +++++++++---------- c++/src/H5FaccProp.h | 164 ++-- c++/src/H5FcreatProp.cpp | 396 ++++----- c++/src/H5FcreatProp.h | 94 +-- c++/src/H5File.cpp | 662 +++++++-------- c++/src/H5File.h | 126 +-- c++/src/H5FloatType.cpp | 402 ++++----- c++/src/H5FloatType.h | 66 +- c++/src/H5Group.cpp | 146 ++-- c++/src/H5Group.h | 58 +- c++/src/H5IdComponent.cpp | 408 ++++----- c++/src/H5IdComponent.h | 112 +-- c++/src/H5Include.h | 4 +- c++/src/H5IntType.cpp | 168 ++-- c++/src/H5IntType.h | 42 +- c++/src/H5LaccProp.cpp | 34 +- c++/src/H5LaccProp.h | 26 +- c++/src/H5Library.cpp | 200 ++--- c++/src/H5Library.h | 36 +- c++/src/H5Location.cpp | 1921 +++++++++++++++++++++-------------------- c++/src/H5Location.h | 298 +++---- c++/src/H5Object.cpp | 419 +++++---- c++/src/H5Object.h | 136 +-- c++/src/H5OcreatProp.cpp | 124 +-- c++/src/H5OcreatProp.h | 42 +- c++/src/H5PredType.cpp | 453 +++++----- c++/src/H5PredType.h | 328 +++---- c++/src/H5PropList.cpp | 769 +++++++++-------- c++/src/H5PropList.h | 142 ++-- c++/src/H5StrType.cpp | 326 ++++--- c++/src/H5StrType.h | 56 +- c++/src/H5VarLenType.cpp | 96 +-- c++/src/H5VarLenType.h | 32 +- c++/test/dsets.cpp | 1668 ++++++++++++++++++------------------ c++/test/h5cpputil.cpp | 142 ++-- c++/test/h5cpputil.h | 70 +- c++/test/tarray.cpp | 486 +++++------ c++/test/tattr.cpp | 2062 ++++++++++++++++++++++----------------------- c++/test/tcompound.cpp | 958 ++++++++++----------- c++/test/tdspl.cpp | 124 +-- c++/test/testhdf5.cpp | 88 +- c++/test/tfile.cpp | 846 +++++++++---------- c++/test/tfilter.cpp | 90 +- c++/test/th5s.cpp | 575 +++++++------ c++/test/titerate.cpp | 370 ++++---- c++/test/tlinks.cpp | 312 +++---- c++/test/tobject.cpp | 500 +++++------ c++/test/trefer.cpp | 1062 +++++++++++------------ c++/test/ttypes.cpp | 622 +++++++------- c++/test/tvlstr.cpp | 1022 +++++++++++----------- 78 files changed, 14522 insertions(+), 14533 deletions(-) diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 9e76b55..621578e 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -34,16 +34,16 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: AbstractDs default constructor -///\brief Default constructor -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs default constructor +///\brief Default constructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AbstractDs::AbstractDs(){} //-------------------------------------------------------------------------- -// Function: AbstractDs default constructor -///\brief Creates an AbstractDs instance using an existing id. -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs default constructor +///\brief Creates an AbstractDs instance using an existing id. +// Programmer Binh-Minh Ribler - 2000 // // *** Deprecation warning *** // This constructor is no longer appropriate because the data member "id" had @@ -54,275 +54,275 @@ AbstractDs::AbstractDs(){} // Mar 2016 -BMR, AbstractDs::AbstractDs(const hid_t ds_id){} //-------------------------------------------------------------------------- -// Function: AbstractDs::getTypeClass -///\brief Returns the class of the datatype that is used by this -/// object, which can be a dataset or an attribute. -///\return Datatype class identifier -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getTypeClass +///\brief Returns the class of the datatype that is used by this +/// object, which can be a dataset or an attribute. +///\return Datatype class identifier +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5T_class_t AbstractDs::getTypeClass() const { - // Gets the datatype used by this dataset or attribute. - // p_get_type calls either H5Dget_type or H5Aget_type depending on - // which object invokes getTypeClass - hid_t datatype_id; - try { - datatype_id = p_get_type(); // returned value is already validated - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); - } + // Gets the datatype used by this dataset or attribute. + // p_get_type calls either H5Dget_type or H5Aget_type depending on + // which object invokes getTypeClass + hid_t datatype_id; + try { + datatype_id = p_get_type(); // returned value is already validated + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); + } - // Gets the class of the datatype and validate it before returning - H5T_class_t type_class = H5Tget_class(datatype_id); + // Gets the class of the datatype and validate it before returning + H5T_class_t type_class = H5Tget_class(datatype_id); - // Close temporary datatype_id - herr_t ret_value = H5Tclose(datatype_id); - if (ret_value < 0) - { - if (fromClass() == "DataSet") - throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed"); - else if (fromClass() == "Attribute") - throw DataTypeIException("Attribute::getTypeClass", "H5Tclose failed"); - } + // Close temporary datatype_id + herr_t ret_value = H5Tclose(datatype_id); + if (ret_value < 0) + { + if (fromClass() == "DataSet") + throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed"); + else if (fromClass() == "Attribute") + throw DataTypeIException("Attribute::getTypeClass", "H5Tclose failed"); + } - // Check on the returned type_class - if (type_class == H5T_NO_CLASS) - { - if (fromClass() == "DataSet") - throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); - else if (fromClass() == "Attribute") - throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); - } - return(type_class); + // Check on the returned type_class + if (type_class == H5T_NO_CLASS) + { + if (fromClass() == "DataSet") + throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); + else if (fromClass() == "Attribute") + throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); + } + return(type_class); } //-------------------------------------------------------------------------- -// Function: AbstractDs::getDataType -///\brief Returns the generic datatype of this abstract dataset, which -/// can be a dataset or an attribute. -///\return DataType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getDataType +///\brief Returns the generic datatype of this abstract dataset, which +/// can be a dataset or an attribute. +///\return DataType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataType AbstractDs::getDataType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getDataType. Then, create and - // return the DataType object - try { - DataType datatype; - f_DataType_setId(&datatype, p_get_type()); - return(datatype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getDataType. Then, create and + // return the DataType object + try { + DataType datatype; + f_DataType_setId(&datatype, p_get_type()); + return(datatype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getArrayType -///\brief Returns the array datatype of this abstract dataset which -/// can be a dataset or an attribute. -///\return ArrayType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: AbstractDs::getArrayType +///\brief Returns the array datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return ArrayType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- ArrayType AbstractDs::getArrayType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getArrayType. Then, create and - // return the ArrayType object - try { - // Create ArrayType and set values this way to work around the - // problem described in the JIRA issue HDFFV-7947 - ArrayType arraytype; - f_DataType_setId(&arraytype, p_get_type()); - return(arraytype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getArrayType. Then, create and + // return the ArrayType object + try { + // Create ArrayType and set values this way to work around the + // problem described in the JIRA issue HDFFV-7947 + ArrayType arraytype; + f_DataType_setId(&arraytype, p_get_type()); + return(arraytype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getCompType -///\brief Returns the compound datatype of this abstract dataset which -/// can be a dataset or an attribute. -///\return CompType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getCompType +///\brief Returns the compound datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return CompType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- CompType AbstractDs::getCompType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getCompType. Then, create and - // return the CompType object - try { - CompType comptype; - f_DataType_setId(&comptype, p_get_type()); - return(comptype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getCompType. Then, create and + // return the CompType object + try { + CompType comptype; + f_DataType_setId(&comptype, p_get_type()); + return(comptype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getEnumType -///\brief Returns the enumeration datatype of this abstract dataset which -/// can be a dataset or an attribute. -///\return EnumType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getEnumType +///\brief Returns the enumeration datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return EnumType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- EnumType AbstractDs::getEnumType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getEnumType. Then, create and - // return the EnumType object - try { - EnumType enumtype; - f_DataType_setId(&enumtype, p_get_type()); - return(enumtype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getEnumType. Then, create and + // return the EnumType object + try { + EnumType enumtype; + f_DataType_setId(&enumtype, p_get_type()); + return(enumtype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getIntType -///\brief Returns the integer datatype of this abstract dataset which -/// can be a dataset or an attribute. -///\return IntType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getIntType +///\brief Returns the integer datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return IntType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- IntType AbstractDs::getIntType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getIntType. Then, create and - // return the IntType object - try { - IntType inttype; - f_DataType_setId(&inttype, p_get_type()); - return(inttype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getIntType. Then, create and + // return the IntType object + try { + IntType inttype; + f_DataType_setId(&inttype, p_get_type()); + return(inttype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getFloatType -///\brief Returns the floating-point datatype of this abstract dataset, -/// which can be a dataset or an attribute. -///\return FloatType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getFloatType +///\brief Returns the floating-point datatype of this abstract dataset, +/// which can be a dataset or an attribute. +///\return FloatType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FloatType AbstractDs::getFloatType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getFloatType. Then, create and - // return the FloatType object - try { - FloatType floatype; - f_DataType_setId(&floatype, p_get_type()); - return(floatype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getFloatType. Then, create and + // return the FloatType object + try { + FloatType floatype; + f_DataType_setId(&floatype, p_get_type()); + return(floatype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getStrType -///\brief Returns the string datatype of this abstract dataset which -/// can be a dataset or an attribute. -///\return StrType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs::getStrType +///\brief Returns the string datatype of this abstract dataset which +/// can be a dataset or an attribute. +///\return StrType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- StrType AbstractDs::getStrType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getStrType. Then, create and - // return the StrType object - try { - StrType strtype; - f_DataType_setId(&strtype, p_get_type()); - return(strtype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getStrType. Then, create and + // return the StrType object + try { + StrType strtype; + f_DataType_setId(&strtype, p_get_type()); + return(strtype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs::getVarLenType -///\brief Returns the floating-point datatype of this abstract dataset, -/// which can be a dataset or an attribute. -///\return VarLenType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: AbstractDs::getVarLenType +///\brief Returns the floating-point datatype of this abstract dataset, +/// which can be a dataset or an attribute. +///\return VarLenType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- VarLenType AbstractDs::getVarLenType() const { - // Gets the id of the datatype used by this dataset or attribute using - // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type - // depending on which object invokes getVarLenType. Then, create and - // return the VarLenType object - try { - VarLenType varlentype; - f_DataType_setId(&varlentype, p_get_type()); - return(varlentype); - } - catch (DataSetIException& E) { - throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); - } - catch (AttributeIException& E) { - throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); - } + // Gets the id of the datatype used by this dataset or attribute using + // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type + // depending on which object invokes getVarLenType. Then, create and + // return the VarLenType object + try { + VarLenType varlentype; + f_DataType_setId(&varlentype, p_get_type()); + return(varlentype); + } + catch (DataSetIException& E) { + throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); + } + catch (AttributeIException& E) { + throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: AbstractDs destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: AbstractDs destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AbstractDs::~AbstractDs() {} diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 1b4775c..eaa9d14 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -37,44 +37,44 @@ class DataSpace; */ class H5_DLLCPP AbstractDs { public: - // Gets a copy the datatype of that this abstract dataset uses. - // Note that this datatype is a generic one and can only be accessed - // via generic member functions, i.e., member functions belong - // to DataType. To get specific datatype, i.e. EnumType, FloatType, - // etc..., use the specific functions, that follow, instead. - DataType getDataType() const; + // Gets a copy the datatype of that this abstract dataset uses. + // Note that this datatype is a generic one and can only be accessed + // via generic member functions, i.e., member functions belong + // to DataType. To get specific datatype, i.e. EnumType, FloatType, + // etc..., use the specific functions, that follow, instead. + DataType getDataType() const; - // Gets a copy of the specific datatype of this abstract dataset. - ArrayType getArrayType() const; - CompType getCompType() const; - EnumType getEnumType() const; - IntType getIntType() const; - FloatType getFloatType() const; - StrType getStrType() const; - VarLenType getVarLenType() const; + // Gets a copy of the specific datatype of this abstract dataset. + ArrayType getArrayType() const; + CompType getCompType() const; + EnumType getEnumType() const; + IntType getIntType() const; + FloatType getFloatType() const; + StrType getStrType() const; + VarLenType getVarLenType() const; - ///\brief Gets the size in memory of this abstract dataset. - virtual size_t getInMemDataSize() const = 0; + ///\brief Gets the size in memory of this abstract dataset. + virtual size_t getInMemDataSize() const = 0; - ///\brief Gets the dataspace of this abstract dataset - pure virtual. - virtual DataSpace getSpace() const = 0; + ///\brief Gets the dataspace of this abstract dataset - pure virtual. + virtual DataSpace getSpace() const = 0; - // Gets the class of the datatype that is used by this abstract - // dataset. - H5T_class_t getTypeClass() const; + // Gets the class of the datatype that is used by this abstract + // dataset. + H5T_class_t getTypeClass() const; - ///\brief Returns the amount of storage size required - pure virtual. - virtual hsize_t getStorageSize() const = 0; + ///\brief Returns the amount of storage size required - pure virtual. + virtual hsize_t getStorageSize() const = 0; - // Returns this class name - pure virtual. - virtual H5std_string fromClass() const = 0; + // Returns this class name - pure virtual. + virtual H5std_string fromClass() const = 0; - // Destructor - virtual ~AbstractDs(); + // Destructor + virtual ~AbstractDs(); protected: - // Default constructor - AbstractDs(); + // Default constructor + AbstractDs(); // *** Deprecation warning *** // The following two constructors are no longer appropriate after the @@ -83,14 +83,14 @@ class H5_DLLCPP AbstractDs { // other will be removed from 1.10 release, and then from 1.8 if its // removal does not raise any problems in two 1.10 releases. - // Mar 2016 -BMR, AbstractDs(const hid_t h5_id); + // Mar 2016 -BMR, AbstractDs(const hid_t h5_id); - // Copy constructor - // AbstractDs( const AbstractDs& original ); + // Copy constructor + // AbstractDs( const AbstractDs& original ); private: - // This member function is implemented by DataSet and Attribute - pure virtual. - virtual hid_t p_get_type() const = 0; + // This member function is implemented by DataSet and Attribute - pure virtual. + virtual hid_t p_get_type() const = 0; }; } #endif // __AbstractDs_H diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index ecce591..3cdcc0a 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -30,95 +30,95 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: ArrayType default constructor -///\brief Default constructor: Creates a stub ArrayType -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType default constructor +///\brief Default constructor: Creates a stub ArrayType +// Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- ArrayType::ArrayType() : DataType() {} //-------------------------------------------------------------------------- -// Function: ArrayType overloaded constructor -///\brief Creates an ArrayType object using an existing id. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType overloaded constructor +///\brief Creates an ArrayType object using an existing id. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) {} +ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) {} //-------------------------------------------------------------------------- -// Function: ArrayType copy constructor -///\brief Copy constructor: makes a copy of the original ArrayType object. -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType copy constructor +///\brief Copy constructor: makes a copy of the original ArrayType object. +// Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} //-------------------------------------------------------------------------- -// Function: ArrayType overloaded constructor -///\brief Creates a new array data type based on the specified -/// \a base_type. -///\param base_type - IN: Existing datatype -///\param ndims - IN: Rank of the array, [0..H5S_MAX_RANK] -///\param dims - IN: Size of each array dimension -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType overloaded constructor +///\brief Creates a new array data type based on the specified +/// \a base_type. +///\param base_type - IN: Existing datatype +///\param ndims - IN: Rank of the array, [0..H5S_MAX_RANK] +///\param dims - IN: Size of each array dimension +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() { // Call C API to create an array data type hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); if (new_type_id < 0) - throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed"); + throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed"); // Set the id for this object id = new_type_id; } //-------------------------------------------------------------------------- -// Function: ArrayType overloaded constructor -///\brief Creates an ArrayType instance by opening an HDF5 array datatype -/// given its name, provided as a C character string. -///\param dtype_name - IN: Array type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: ArrayType overloaded constructor +///\brief Creates an ArrayType instance by opening an HDF5 array datatype +/// given its name, provided as a C character string. +///\param dtype_name - IN: Array type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openArrayType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openArrayType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() { - id = p_opentype(loc, dtype_name); + id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- -// Function: ArrayType overloaded constructor -///\brief Creates an ArrayType instance by opening an HDF5 array datatype -/// given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Array type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: ArrayType overloaded constructor +///\brief Creates an ArrayType instance by opening an HDF5 array datatype +/// given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Array type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openArrayType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openArrayType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : DataType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: ArrayType::operator= -///\brief Assignment operator -///\param rhs - IN: Reference to the existing array datatype -///\return Reference to ArrayType instance -///\exception H5::DataTypeIException +// Function: ArrayType::operator= +///\brief Assignment operator +///\param rhs - IN: Reference to the existing array datatype +///\return Reference to ArrayType instance +///\exception H5::DataTypeIException // Description -// Closes the id on the lhs object first with setId, then copies -// each data member from the rhs object. (Issue HDFFV-9562) -// Programmer Binh-Minh Ribler - Mar 2016 +// Closes the id on the lhs object first with setId, then copies +// each data member from the rhs object. (Issue HDFFV-9562) +// Programmer Binh-Minh Ribler - Mar 2016 // Modification //-------------------------------------------------------------------------- ArrayType& ArrayType::operator=(const ArrayType& rhs) @@ -139,14 +139,14 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) } //-------------------------------------------------------------------------- -// Function: ArrayType::getArrayNDims -///\brief Returns the number of dimensions for an array datatype. -///\return Number of dimensions -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType::getArrayNDims +///\brief Returns the number of dimensions for an array datatype. +///\return Number of dimensions +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May 2004 // Modification -// Apr, 2016 -// Became const. +// Apr, 2016 +// Became const. //-------------------------------------------------------------------------- int ArrayType::getArrayNDims() const { @@ -154,38 +154,38 @@ int ArrayType::getArrayNDims() const int ndims = H5Tget_array_ndims(id); if (ndims < 0) { - throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); + throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); } return(ndims); } //-------------------------------------------------------------------------- -// Function: ArrayType::getArrayDims -///\brief Retrieves the size of all dimensions of an array datatype. -///\param dims - OUT: Sizes of dimensions -///\return Number of dimensions -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType::getArrayDims +///\brief Retrieves the size of all dimensions of an array datatype. +///\param dims - OUT: Sizes of dimensions +///\return Number of dimensions +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May 2004 // Modification -// Apr, 2016 -// Became const. +// Apr, 2016 +// Became const. //-------------------------------------------------------------------------- int ArrayType::getArrayDims(hsize_t* dims) const { // Get the dimensions int ndims = H5Tget_array_dims2(id, dims); if (ndims < 0) - throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); + throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); // Return the number of dimensions return(ndims); } //-------------------------------------------------------------------------- -// Function: ArrayType destructor -///\brief Properly terminates access to this array datatype. -// Programmer Binh-Minh Ribler - May 2004 +// Function: ArrayType destructor +///\brief Properly terminates access to this array datatype. +// Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- ArrayType::~ArrayType() {} diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 65917ae..15b6bb3 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -27,39 +27,39 @@ namespace H5 { */ class H5_DLLCPP ArrayType : public DataType { public: - // Constructor that creates a new array data type based on the - // specified base type. - ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); + // Constructor that creates a new array data type based on the + // specified base type. + ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); - // Assignment operator - ArrayType& operator=(const ArrayType& rhs); + // Assignment operator + ArrayType& operator=(const ArrayType& rhs); - // Constructors that open an array datatype, given a location. - ArrayType(const H5Location& loc, const char* name); - ArrayType(const H5Location& loc, const H5std_string& name); + // Constructors that open an array datatype, given a location. + ArrayType(const H5Location& loc, const char* name); + ArrayType(const H5Location& loc, const H5std_string& name); - // Returns the number of dimensions of this array datatype. - int getArrayNDims() const; - //int getArrayNDims(); // removed 1.8.18 and 1.10.1 + // Returns the number of dimensions of this array datatype. + int getArrayNDims() const; + //int getArrayNDims(); // removed 1.8.18 and 1.10.1 - // Returns the sizes of dimensions of this array datatype. - int getArrayDims(hsize_t* dims) const; - //int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 + // Returns the sizes of dimensions of this array datatype. + int getArrayDims(hsize_t* dims) const; + //int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ArrayType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("ArrayType"); } - // Copy constructor: makes copy of the original object. - ArrayType( const ArrayType& original ); + // Copy constructor: makes copy of the original object. + ArrayType(const ArrayType& original); - // Constructor that takes an existing id - ArrayType( const hid_t existing_id ); + // Constructor that takes an existing id + ArrayType(const hid_t existing_id); - // Noop destructor - virtual ~ArrayType(); + // Noop destructor + virtual ~ArrayType(); - // Default constructor - ArrayType(); + // Default constructor + ArrayType(); }; } #endif // __H5ArrayType_H diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 22b163a..0dc2b1e 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -31,265 +31,265 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: AtomType default constructor [protected] -// Purpose Default constructor: creates a stub atomic datatype. -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType default constructor [protected] +// Purpose Default constructor: creates a stub atomic datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AtomType::AtomType() : DataType() {} //-------------------------------------------------------------------------- -// Function: AtomType overloaded constructor [protected] -// Purpose Creates an AtomType object using an existing id. -// Parameter existing_id - IN: Id of an existing datatype -// Exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType overloaded constructor [protected] +// Purpose Creates an AtomType object using an existing id. +// Parameter existing_id - IN: Id of an existing datatype +// Exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {} +AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) {} //-------------------------------------------------------------------------- -// Function: AtomType copy constructor -///\brief Copy constructor: makes a copy of the original AtomType object. -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType copy constructor +///\brief Copy constructor: makes a copy of the original AtomType object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType( const AtomType& original ) : DataType( original ) {} +AtomType::AtomType(const AtomType& original) : DataType(original) {} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: AtomType::setSize -///\brief Sets the total size for an atomic datatype. -///\param size - IN: Size to set -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType::setSize +///\brief Sets the total size for an atomic datatype. +///\param size - IN: Size to set +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setSize( size_t size ) const +void AtomType::setSize(size_t size) const { - // Call C routine H5Tset_size to set the total size - herr_t ret_value = H5Tset_size( id, size ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); - } + // Call C routine H5Tset_size to set the total size + herr_t ret_value = H5Tset_size(id, size); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); + } } //-------------------------------------------------------------------------- -// Function: AtomType::getOrder -///\brief Returns the byte order of an atomic datatype. -///\return Byte order, which can be: -/// \li \c H5T_ORDER_LE -/// \li \c H5T_ORDER_BE -/// \li \c H5T_ORDER_VAX -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Mar, 2005 +// Function: AtomType::getOrder +///\brief Returns the byte order of an atomic datatype. +///\return Byte order, which can be: +/// \li \c H5T_ORDER_LE +/// \li \c H5T_ORDER_BE +/// \li \c H5T_ORDER_VAX +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- H5T_order_t AtomType::getOrder() const { - // Call C routine to get the byte ordering - H5T_order_t type_order = H5Tget_order( id ); + // Call C routine to get the byte ordering + H5T_order_t type_order = H5Tget_order(id); - // return a byte order constant if successful - if( type_order == H5T_ORDER_ERROR ) - { - throw DataTypeIException(inMemFunc("getOrder"), - "H5Tget_order returns H5T_ORDER_ERROR"); - } - return( type_order ); + // return a byte order constant if successful + if (type_order == H5T_ORDER_ERROR) + { + throw DataTypeIException(inMemFunc("getOrder"), + "H5Tget_order returns H5T_ORDER_ERROR"); + } + return(type_order); } //-------------------------------------------------------------------------- -// Function: AtomType::getOrder -///\brief This is an overloaded member function, provided for convenience. -/// It takes a reference to a \c H5std_string for the buffer that -/// provide the text description of the returned byte order. -/// The text description can be either of the following: -/// "Little endian byte ordering (0)"; -/// "Big endian byte ordering (1)"; -/// "VAX mixed byte ordering (2)"; -///\param order_string - OUT: Text description of the returned byte order -///\return Byte order, which can be: -/// \li \c H5T_ORDER_LE -/// \li \c H5T_ORDER_BE -/// \li \c H5T_ORDER_VAX -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType::getOrder +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the buffer that +/// provide the text description of the returned byte order. +/// The text description can be either of the following: +/// "Little endian byte ordering (0)"; +/// "Big endian byte ordering (1)"; +/// "VAX mixed byte ordering (2)"; +///\param order_string - OUT: Text description of the returned byte order +///\return Byte order, which can be: +/// \li \c H5T_ORDER_LE +/// \li \c H5T_ORDER_BE +/// \li \c H5T_ORDER_VAX +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder( H5std_string& order_string ) const +H5T_order_t AtomType::getOrder(H5std_string& order_string) const { - // Call the overloaded to get the type order without text - H5T_order_t type_order = getOrder(); + // Call the overloaded to get the type order without text + H5T_order_t type_order = getOrder(); - // Then provide the text and return the type order - if( type_order == H5T_ORDER_LE ) - order_string = "Little endian byte ordering (0)"; - else if( type_order == H5T_ORDER_BE ) - order_string = "Big endian byte ordering (1)"; - else if( type_order == H5T_ORDER_VAX ) - order_string = "VAX mixed byte ordering (2)"; - return( type_order ); + // Then provide the text and return the type order + if (type_order == H5T_ORDER_LE) + order_string = "Little endian byte ordering (0)"; + else if (type_order == H5T_ORDER_BE) + order_string = "Big endian byte ordering (1)"; + else if (type_order == H5T_ORDER_VAX) + order_string = "VAX mixed byte ordering (2)"; + return(type_order); } //-------------------------------------------------------------------------- -// Function: AtomType::setOrder -///\brief Sets the byte ordering of an atomic datatype. -///\param order - IN: Byte ordering constant, which can be: -/// \li \c H5T_ORDER_LE -/// \li \c H5T_ORDER_BE -/// \li \c H5T_ORDER_VAX -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType::setOrder +///\brief Sets the byte ordering of an atomic datatype. +///\param order - IN: Byte ordering constant, which can be: +/// \li \c H5T_ORDER_LE +/// \li \c H5T_ORDER_BE +/// \li \c H5T_ORDER_VAX +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOrder( H5T_order_t order ) const +void AtomType::setOrder(H5T_order_t order) const { - // Call C routine to set the byte ordering - herr_t ret_value = H5Tset_order( id, order ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); - } + // Call C routine to set the byte ordering + herr_t ret_value = H5Tset_order(id, order); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); + } } //-------------------------------------------------------------------------- -// Function: AtomType::getPrecision -///\brief Returns the precision of an atomic datatype. -///\return Number of significant bits -///\exception H5::DataTypeIException +// Function: AtomType::getPrecision +///\brief Returns the precision of an atomic datatype. +///\return Number of significant bits +///\exception H5::DataTypeIException ///\par Description -/// The precision is the number of significant bits which, -/// unless padding is present, is 8 times larger than the -/// value returned by \c DataType::getSize(). -// Programmer Binh-Minh Ribler - 2000 +/// The precision is the number of significant bits which, +/// unless padding is present, is 8 times larger than the +/// value returned by \c DataType::getSize(). +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- size_t AtomType::getPrecision() const { - size_t num_signi_bits = H5Tget_precision( id ); // C routine + size_t num_signi_bits = H5Tget_precision(id); // C routine - // returns number of significant bits if successful - if( num_signi_bits == 0 ) - { - throw DataTypeIException(inMemFunc("getPrecision"), - "H5Tget_precision returns invalid number of significant bits"); - } - return( num_signi_bits ); + // returns number of significant bits if successful + if (num_signi_bits == 0) + { + throw DataTypeIException(inMemFunc("getPrecision"), + "H5Tget_precision returns invalid number of significant bits"); + } + return(num_signi_bits); } //-------------------------------------------------------------------------- -// Function: AtomType::setPrecision -///\brief Sets the precision of an atomic datatype. -///\param precision - IN: Number of bits of precision -///\exception H5::DataTypeIException +// Function: AtomType::setPrecision +///\brief Sets the precision of an atomic datatype. +///\param precision - IN: Number of bits of precision +///\exception H5::DataTypeIException ///\par Description -/// For information, please see C layer Reference Manuat at: +/// For information, please see C layer Reference Manuat at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-SetPrecision -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPrecision( size_t precision ) const +void AtomType::setPrecision(size_t precision) const { - // Call C routine to set the datatype precision - herr_t ret_value = H5Tset_precision( id, precision ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); - } + // Call C routine to set the datatype precision + herr_t ret_value = H5Tset_precision(id, precision); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); + } } //-------------------------------------------------------------------------- -// Function: AtomType::getOffset -///\brief Retrieves the bit offset of the first significant bit. -///\return Offset value -///\exception H5::DataTypeIException +// Function: AtomType::getOffset +///\brief Retrieves the bit offset of the first significant bit. +///\return Offset value +///\exception H5::DataTypeIException ///\par Description -/// For information, please see C layer Reference Manuat at: +/// For information, please see C layer Reference Manuat at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-GetOffset -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 // Modification -// 12/05/00: due to C API change -// - return type changed from size_t to int -// - offset = -1 when failure occurs vs. 0 +// 12/05/00: due to C API change +// - return type changed from size_t to int +// - offset = -1 when failure occurs vs. 0 //-------------------------------------------------------------------------- int AtomType::getOffset() const { - int offset = H5Tget_offset( id ); // C routine + int offset = H5Tget_offset(id); // C routine - // returns a non-negative offset value if successful - if( offset == -1 ) - { - throw DataTypeIException(inMemFunc("getOffset"), - "H5Tget_offset returns a negative offset value"); - } - return( offset ); + // returns a non-negative offset value if successful + if (offset == -1) + { + throw DataTypeIException(inMemFunc("getOffset"), + "H5Tget_offset returns a negative offset value"); + } + return(offset); } //-------------------------------------------------------------------------- -// Function: AtomType::setOffset -///\brief Sets the bit offset of the first significant bit. -///\param offset - IN: Offset of first significant bit -///\exception H5::DataTypeIException +// Function: AtomType::setOffset +///\brief Sets the bit offset of the first significant bit. +///\param offset - IN: Offset of first significant bit +///\exception H5::DataTypeIException ///\par Description -/// For information, please see C layer Reference Manuat at: +/// For information, please see C layer Reference Manuat at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-SetOffset -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOffset( size_t offset ) const +void AtomType::setOffset(size_t offset) const { - // Call C routine to set the bit offset - herr_t ret_value = H5Tset_offset( id, offset ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); - } + // Call C routine to set the bit offset + herr_t ret_value = H5Tset_offset(id, offset); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); + } } //-------------------------------------------------------------------------- -// Function: AtomType::getPad -///\brief Retrieves the padding type of the least and most-significant -/// bit padding. -///\param lsb - OUT: Least-significant bit padding type -///\param msb - OUT: Most-significant bit padding type -///\exception H5::DataTypeIException +// Function: AtomType::getPad +///\brief Retrieves the padding type of the least and most-significant +/// bit padding. +///\param lsb - OUT: Least-significant bit padding type +///\param msb - OUT: Most-significant bit padding type +///\exception H5::DataTypeIException ///\par Description -/// Possible values for \a lsb and \a msb include: -/// \li \c H5T_PAD_ZERO (0) - Set background to zeros. -/// \li \c H5T_PAD_ONE (1) - Set background to ones. -/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. -// Programmer Binh-Minh Ribler - 2000 +/// Possible values for \a lsb and \a msb include: +/// \li \c H5T_PAD_ZERO (0) - Set background to zeros. +/// \li \c H5T_PAD_ONE (1) - Set background to ones. +/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const +void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const { - // Call C routine to get the padding type - herr_t ret_value = H5Tget_pad( id, &lsb, &msb ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); - } + // Call C routine to get the padding type + herr_t ret_value = H5Tget_pad(id, &lsb, &msb); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); + } } //-------------------------------------------------------------------------- -// Function: AtomType::setPad -///\brief Sets the least and most-significant bits padding types. -///\param lsb - IN: Least-significant bit padding type -///\param msb - IN: Most-significant bit padding type -///\exception H5::DataTypeIException +// Function: AtomType::setPad +///\brief Sets the least and most-significant bits padding types. +///\param lsb - IN: Least-significant bit padding type +///\param msb - IN: Most-significant bit padding type +///\exception H5::DataTypeIException ///\par Description -/// Valid values for \a lsb and \a msb include: -/// \li \c H5T_PAD_ZERO (0) - Set background to zeros. -/// \li \c H5T_PAD_ONE (1) - Set background to ones. -/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for \a lsb and \a msb include: +/// \li \c H5T_PAD_ZERO (0) - Set background to zeros. +/// \li \c H5T_PAD_ONE (1) - Set background to ones. +/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const +void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const { - // Call C routine to set the padding type - herr_t ret_value = H5Tset_pad( id, lsb, msb ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); - } + // Call C routine to set the padding type + herr_t ret_value = H5Tset_pad(id, lsb, msb); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); + } } #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: AtomType destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AtomType::~AtomType() {} #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index d84b53f..a1e0262 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -30,53 +30,53 @@ namespace H5 { */ class H5_DLLCPP AtomType : public DataType { public: - // Returns the byte order of an atomic datatype. - H5T_order_t getOrder() const; - H5T_order_t getOrder( H5std_string& order_string ) const; + // Returns the byte order of an atomic datatype. + H5T_order_t getOrder() const; + H5T_order_t getOrder(H5std_string& order_string) const; - // Sets the byte ordering of an atomic datatype. - void setOrder( H5T_order_t order ) const; + // Sets the byte ordering of an atomic datatype. + void setOrder(H5T_order_t order) const; - // Retrieves the bit offset of the first significant bit. - // 12/05/00 - changed return type to int from size_t - C API - int getOffset() const; + // Retrieves the bit offset of the first significant bit. + // 12/05/00 - changed return type to int from size_t - C API + int getOffset() const; - // Sets the bit offset of the first significant bit. - void setOffset( size_t offset ) const; + // Sets the bit offset of the first significant bit. + void setOffset(size_t offset) const; - // Retrieves the padding type of the least and most-significant bit padding. - void getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const; + // Retrieves the padding type of the least and most-significant bit padding. + void getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const; - // Sets the least and most-significant bits padding types - void setPad( H5T_pad_t lsb, H5T_pad_t msb ) const; + // Sets the least and most-significant bits padding types + void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; - // Returns the precision of an atomic datatype. - size_t getPrecision() const; + // Returns the precision of an atomic datatype. + size_t getPrecision() const; - // Sets the precision of an atomic datatype. - void setPrecision( size_t precision ) const; + // Sets the precision of an atomic datatype. + void setPrecision(size_t precision) const; - // Sets the total size for an atomic datatype. - void setSize( size_t size ) const; + // Sets the total size for an atomic datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("AtomType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("AtomType"); } #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Copy constructor - makes copy of the original object - AtomType( const AtomType& original ); + // Copy constructor - makes copy of the original object + AtomType(const AtomType& original); - // Noop destructor - virtual ~AtomType(); + // Noop destructor + virtual ~AtomType(); #endif // DOXYGEN_SHOULD_SKIP_THIS protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Default constructor - AtomType(); + // Default constructor + AtomType(); - // Constructor that takes an existing id - AtomType( const hid_t existing_id ); + // Constructor that takes an existing id + AtomType(const hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; } diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index dfd2b28..6701f6e 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * +/* All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * @@ -20,7 +20,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -44,17 +44,17 @@ using std::endl; class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- -// Function: Attribute default constructor -///\brief Default constructor: Creates a stub attribute -// Programmer Binh-Minh Ribler - May, 2004 +// Function: Attribute default constructor +///\brief Default constructor: Creates a stub attribute +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- -// Function: Attribute copy constructor -///\brief Copy constructor: makes a copy of the original Attribute object. -///\param original - IN: Original Attribute object to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute copy constructor +///\brief Copy constructor: makes a copy of the original Attribute object. +///\param original - IN: Original Attribute object to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Attribute::Attribute(const Attribute& original) : AbstractDs(), H5Location(), id(original.id) { @@ -62,12 +62,12 @@ Attribute::Attribute(const Attribute& original) : AbstractDs(), H5Location(), id } //-------------------------------------------------------------------------- -// Function: Attribute overloaded constructor -///\brief Creates an Attribute object using the id of an existing -/// attribute. -///\param existing_id - IN: Id of an existing attribute -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute overloaded constructor +///\brief Creates an Attribute object using the id of an existing +/// attribute. +///\param existing_id - IN: Id of an existing attribute +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Attribute::Attribute(const hid_t existing_id) : AbstractDs(), H5Location(), id(existing_id) { @@ -75,30 +75,30 @@ Attribute::Attribute(const hid_t existing_id) : AbstractDs(), H5Location(), id(e } //-------------------------------------------------------------------------- -// Function: Attribute::write -///\brief Writes data to this attribute. -///\param mem_type - IN: Attribute datatype (in memory) -///\param buf - IN: Data to be written -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute::write +///\brief Writes data to this attribute. +///\param mem_type - IN: Attribute datatype (in memory) +///\param buf - IN: Data to be written +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::write( const DataType& mem_type, const void *buf ) const +void Attribute::write(const DataType& mem_type, const void *buf) const { - herr_t ret_value = H5Awrite( id, mem_type.getId(), buf ); - if( ret_value < 0 ) - { - throw AttributeIException("Attribute::write", "H5Awrite failed"); - } + herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); + if (ret_value < 0) + { + throw AttributeIException("Attribute::write", "H5Awrite failed"); + } } //-------------------------------------------------------------------------- -// Function: Attribute::write -///\brief This is an overloaded member function, provided for convenience. -/// It writes a \a H5std_string to this attribute. -///\param mem_type - IN: Attribute datatype (in memory) -///\param strg - IN: Data to be written -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Apr, 2003 +// Function: Attribute::write +///\brief This is an overloaded member function, provided for convenience. +/// It writes a \a H5std_string to this attribute. +///\param mem_type - IN: Attribute datatype (in memory) +///\param strg - IN: Data to be written +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Apr, 2003 //-------------------------------------------------------------------------- void Attribute::write(const DataType& mem_type, const H5std_string& strg) const { @@ -107,7 +107,7 @@ void Attribute::write(const DataType& mem_type, const H5std_string& strg) const htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); if (is_variable_len < 0) { - throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); + throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); } // Convert string to C-string const char* strg_C; @@ -117,55 +117,55 @@ void Attribute::write(const DataType& mem_type, const H5std_string& strg) const // Pass string in differently depends on variable or fixed length if (!is_variable_len) { - ret_value = H5Awrite(id, mem_type.getId(), strg_C); + ret_value = H5Awrite(id, mem_type.getId(), strg_C); } else { - // passing third argument by address - ret_value = H5Awrite(id, mem_type.getId(), &strg_C); + // passing third argument by address + ret_value = H5Awrite(id, mem_type.getId(), &strg_C); } if (ret_value < 0) { - throw AttributeIException("Attribute::write", "H5Awrite failed"); + throw AttributeIException("Attribute::write", "H5Awrite failed"); } } //-------------------------------------------------------------------------- -// Function: Attribute::read -///\brief Reads data from this attribute. -///\param mem_type - IN: Attribute datatype (in memory) -///\param buf - OUT: Buffer for read data -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute::read +///\brief Reads data from this attribute. +///\param mem_type - IN: Attribute datatype (in memory) +///\param buf - OUT: Buffer for read data +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::read( const DataType& mem_type, void *buf ) const +void Attribute::read(const DataType& mem_type, void *buf) const { - herr_t ret_value = H5Aread( id, mem_type.getId(), buf ); - if( ret_value < 0 ) - { - throw AttributeIException("Attribute::read", "H5Aread failed"); - } + herr_t ret_value = H5Aread(id, mem_type.getId(), buf); + if (ret_value < 0) + { + throw AttributeIException("Attribute::read", "H5Aread failed"); + } } //-------------------------------------------------------------------------- -// Function: Attribute::read -///\brief This is an overloaded member function, provided for convenience. -/// It reads a \a H5std_string from this attribute. -///\param mem_type - IN: Attribute datatype (in memory) -///\param strg - IN: Buffer for read string -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Apr, 2003 +// Function: Attribute::read +///\brief This is an overloaded member function, provided for convenience. +/// It reads a \a H5std_string from this attribute. +///\param mem_type - IN: Attribute datatype (in memory) +///\param strg - IN: Buffer for read string +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Apr, 2003 // Modification -// Mar 2008 -// Corrected a misunderstanding that H5Aread would allocate -// space for the buffer. Obtained the attribute size and -// allocated memory properly. -BMR -// Apr 2009 -// Used getInMemDataSize to get attribute data size. -BMR -// Jul 2009 -// Divided into specific private functions for fixed- and -// variable-len string data: p_read_fixed_len and -// p_read_variable_len. This should improve readability. -BMR +// Mar 2008 +// Corrected a misunderstanding that H5Aread would allocate +// space for the buffer. Obtained the attribute size and +// allocated memory properly. -BMR +// Apr 2009 +// Used getInMemDataSize to get attribute data size. -BMR +// Jul 2009 +// Divided into specific private functions for fixed- and +// variable-len string data: p_read_fixed_len and +// p_read_variable_len. This should improve readability. -BMR //-------------------------------------------------------------------------- void Attribute::read(const DataType& mem_type, H5std_string& strg) const { @@ -188,11 +188,11 @@ void Attribute::read(const DataType& mem_type, H5std_string& strg) const } //-------------------------------------------------------------------------- -// Function: Attribute::getInMemDataSize -///\brief Gets the size in memory of the attribute's data. -///\return Size of data (in memory) -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Apr 2009 +// Function: Attribute::getInMemDataSize +///\brief Gets the size in memory of the attribute's data. +///\return Size of data (in memory) +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- size_t Attribute::getInMemDataSize() const { @@ -200,9 +200,9 @@ size_t Attribute::getInMemDataSize() const // Get the data type of this attribute hid_t mem_type_id = H5Aget_type(id); - if( mem_type_id < 0 ) + if (mem_type_id < 0) { - throw AttributeIException(func, "H5Aget_type failed"); + throw AttributeIException(func, "H5Aget_type failed"); } // Get the data type's size by first getting its native type then getting @@ -210,22 +210,22 @@ size_t Attribute::getInMemDataSize() const hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); if (native_type < 0) { - throw AttributeIException(func, "H5Tget_native_type failed"); + throw AttributeIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); if (type_size == 0) { - throw AttributeIException(func, "H5Tget_size failed"); + throw AttributeIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this attribute. if (H5Tclose(native_type) < 0) { - throw DataSetIException(func, "H5Tclose(native_type) failed"); + throw DataSetIException(func, "H5Tclose(native_type) failed"); } if (H5Tclose(mem_type_id) < 0) { - throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); + throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the attribute by first getting its dataspace @@ -233,18 +233,18 @@ size_t Attribute::getInMemDataSize() const hid_t space_id = H5Aget_space(id); if (space_id < 0) { - throw AttributeIException(func, "H5Aget_space failed"); + throw AttributeIException(func, "H5Aget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); if (num_elements < 0) { - throw AttributeIException(func, "H5Sget_simple_extent_npoints failed"); + throw AttributeIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace if (H5Sclose(space_id) < 0) { - throw DataSetIException(func, "H5Sclose failed"); + throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data @@ -253,46 +253,46 @@ size_t Attribute::getInMemDataSize() const } //-------------------------------------------------------------------------- -// Function: Attribute::getSpace -///\brief Gets a copy of the dataspace for this attribute. -///\return Dataspace instance -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute::getSpace +///\brief Gets a copy of the dataspace for this attribute. +///\return Dataspace instance +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSpace Attribute::getSpace() const { // Calls C function H5Aget_space to get the id of the dataspace - hid_t dataspace_id = H5Aget_space( id ); + hid_t dataspace_id = H5Aget_space(id); // If the dataspace id is valid, create and return the DataSpace object - if( dataspace_id > 0 ) - { - DataSpace dataspace; - f_DataSpace_setId(&dataspace, dataspace_id); - return(dataspace); - } + if (dataspace_id > 0) + { + DataSpace dataspace; + f_DataSpace_setId(&dataspace, dataspace_id); + return(dataspace); + } else - { - throw AttributeIException("Attribute::getSpace", "H5Aget_space failed"); - } + { + throw AttributeIException("Attribute::getSpace", "H5Aget_space failed"); + } } //-------------------------------------------------------------------------- -// Function: Attribute::getName -///\brief Gets the name of this attribute, returning its length. -///\param attr_name - OUT: Buffer for the name string as char* -///\param buf_size - IN: Length of the buffer, default to 0 -///\return Actual length of the attribute name -///\exception H5::AttributeIException +// Function: Attribute::getName +///\brief Gets the name of this attribute, returning its length. +///\param attr_name - OUT: Buffer for the name string as char* +///\param buf_size - IN: Length of the buffer, default to 0 +///\return Actual length of the attribute name +///\exception H5::AttributeIException ///\par Description -/// This function retrieves \a buf_size chars of the attribute's -/// name including null termination. Thus, if the actual length -/// of the name is more than buf_size-1, the retrieved name will -/// be truncated to accommodate the null terminator. -/// To get length of the attribute's name for buffer allocation, -/// an application can call this function passing in NULL for the -/// first argument and ignore the second argument. -// Programmer Binh-Minh Ribler - Mar, 2014 +/// This function retrieves \a buf_size chars of the attribute's +/// name including null termination. Thus, if the actual length +/// of the name is more than buf_size-1, the retrieved name will +/// be truncated to accommodate the null terminator. +/// To get length of the attribute's name for buffer allocation, +/// an application can call this function passing in NULL for the +/// first argument and ignore the second argument. +// Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- ssize_t Attribute::getName(char* attr_name, size_t buf_size) const { @@ -302,25 +302,25 @@ ssize_t Attribute::getName(char* attr_name, size_t buf_size) const // If H5Aget_name returns a negative value, raise an exception if (name_size < 0) { - throw AttributeIException("Attribute::getName", "H5Aget_name failed"); + throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } else if (name_size == 0) { - throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); + throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Return length of the name return(name_size); } //-------------------------------------------------------------------------- -// Function: Attribute::getName -///\brief Returns the name of this attribute as an \a H5std_string. -///\return Name of the attribute -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: Attribute::getName +///\brief Returns the name of this attribute as an \a H5std_string. +///\return Name of the attribute +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - May, 2004 // Modification -// Mar 2014 - BMR -// Revised to use the modified getName() above +// Mar 2014 - BMR +// Revised to use the modified getName() above //-------------------------------------------------------------------------- H5std_string Attribute::getName() const { @@ -332,11 +332,11 @@ H5std_string Attribute::getName() const // If H5Aget_name failed, throw exception if (name_size < 0) { - throw AttributeIException("Attribute::getName", "H5Aget_name failed"); + throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } else if (name_size == 0) { - throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); + throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Attribute's name exists, retrieve it else if (name_size > 0) @@ -359,44 +359,44 @@ H5std_string Attribute::getName() const } //-------------------------------------------------------------------------- -// Function: Attribute::getName -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an integer -/// specifying a desired length to be retrieved of the name. -///\return Name (or part of name) of the attribute -///\param len - IN: Desired length of the name -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute::getName +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an integer +/// specifying a desired length to be retrieved of the name. +///\return Name (or part of name) of the attribute +///\param len - IN: Desired length of the name +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Mar 2014 - BMR -// Revised to use the new getName() below +// Mar 2014 - BMR +// Revised to use the new getName() below //-------------------------------------------------------------------------- H5std_string Attribute::getName(size_t len) const { H5std_string attr_name; ssize_t name_size = getName(attr_name, len); if (name_size < 0) - return(""); + return(""); else - return(attr_name); + return(attr_name); } //-------------------------------------------------------------------------- -// Function: Attribute::getName -///\brief Gets the name of this attribute, returning its length. -///\param attr_name - OUT: Buffer for the name string as \a H5std_string -///\param len - IN: Desired length of the name, default to 0 -///\return Actual length of the attribute name -///\exception H5::AttributeIException +// Function: Attribute::getName +///\brief Gets the name of this attribute, returning its length. +///\param attr_name - OUT: Buffer for the name string as \a H5std_string +///\param len - IN: Desired length of the name, default to 0 +///\return Actual length of the attribute name +///\exception H5::AttributeIException ///\par Description -/// This function retrieves the attribute's name as a string. The -/// buf_size can specify a specific length or default to 0, in -/// which case the entire name will be retrieved. -// Programmer Binh-Minh Ribler - Nov, 2001 +/// This function retrieves the attribute's name as a string. The +/// buf_size can specify a specific length or default to 0, in +/// which case the entire name will be retrieved. +// Programmer Binh-Minh Ribler - Nov, 2001 // Modification -// Mar 2014 - BMR -// Added to replace getName(size_t, H5std_string&) so that it'll -// allow the argument "len" to be skipped. +// Mar 2014 - BMR +// Added to replace getName(size_t, H5std_string&) so that it'll +// allow the argument "len" to be skipped. //-------------------------------------------------------------------------- ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const { @@ -406,7 +406,7 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const if (len == 0) { attr_name = getName(); - name_size = attr_name.length(); + name_size = attr_name.length(); } // If length is provided, get that number of characters in name else @@ -430,33 +430,33 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const } //-------------------------------------------------------------------------- -// Function: Attribute::getName -// Purpose This function is replaced by the previous function, which -// provides more convenient prototype. It will be removed -// in future release. -// Param len - IN: Desired length of the name -// Param attr_name - OUT: Buffer for the name string -// Return Actual length of the attribute name -// Exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Nov, 2001 +// Function: Attribute::getName +// Purpose This function is replaced by the previous function, which +// provides more convenient prototype. It will be removed +// in future release. +// Param len - IN: Desired length of the name +// Param attr_name - OUT: Buffer for the name string +// Return Actual length of the attribute name +// Exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Nov, 2001 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//ssize_t Attribute::getName( size_t len, H5std_string& attr_name ) const +//ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const //{ // return (getName(attr_name, len)); //} //-------------------------------------------------------------------------- -// Function: Attribute::getStorageSize -///\brief Returns the amount of storage size required for this attribute. -///\return Size of the storage or 0, for no data -///\exception H5::AttributeIException -// Note: H5Dget_storage_size returns 0 when there is no data. This -// function should have no failure. (from SLU) -// Programmer Binh-Minh Ribler - Mar, 2005 +// Function: Attribute::getStorageSize +///\brief Returns the amount of storage size required for this attribute. +///\return Size of the storage or 0, for no data +///\exception H5::AttributeIException +// Note: H5Dget_storage_size returns 0 when there is no data. This +// function should have no failure. (from SLU) +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- hsize_t Attribute::getStorageSize() const { @@ -466,19 +466,19 @@ hsize_t Attribute::getStorageSize() const //-------------------------------------------------------------------------- // Function: Attribute::getId -///\brief Get the id of this attribute -///\return Attribute identifier +///\brief Get the id of this attribute +///\return Attribute identifier // Description: -// Class hierarchy is revised to address bugzilla 1068. Class -// AbstractDS and Attribute are moved out of H5Object. In -// addition, member IdComponent::id is moved into subclasses, and -// IdComponent::getId now becomes pure virtual function. +// Class hierarchy is revised to address bugzilla 1068. Class +// AbstractDS and Attribute are moved out of H5Object. In +// addition, member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 // Modification -// Aug 2016 - BMR -// Note that Attribute is now inheriting from H5Location, because -// an attribute id can be used to specify a location in HDF5 -// library. +// Aug 2016 - BMR +// Note that Attribute is now inheriting from H5Location, because +// an attribute id can be used to specify a location in HDF5 +// library. //-------------------------------------------------------------------------- hid_t Attribute::getId() const { @@ -486,36 +486,36 @@ hid_t Attribute::getId() const } //-------------------------------------------------------------------------- -// Function: Attribute::p_get_type (private) -// Purpose Gets the datatype of this attribute. -// Return Id of the datatype -// Exception H5::AttributeIException +// Function: Attribute::p_get_type (private) +// Purpose Gets the datatype of this attribute. +// Return Id of the datatype +// Exception H5::AttributeIException // Description -// This private function is used in AbstractDs. -// Programmer Binh-Minh Ribler - 2000 +// This private function is used in AbstractDs. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hid_t Attribute::p_get_type() const { - hid_t type_id = H5Aget_type( id ); - if( type_id > 0 ) - return( type_id ); - else - { - throw AttributeIException("", "H5Aget_type failed"); - } + hid_t type_id = H5Aget_type(id); + if (type_id > 0) + return(type_id); + else + { + throw AttributeIException("", "H5Aget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: Attribute::p_read_fixed_len (private) -// brief Reads a fixed length \a H5std_string from an attribute. -// param mem_type - IN: Attribute datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// Function: Attribute::p_read_fixed_len (private) +// brief Reads a fixed length \a H5std_string from an attribute. +// param mem_type - IN: Attribute datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Jul, 2009 // Modification -// Jul 2009 -// Separated the fixed length case from the original -// Attribute::read +// Jul 2009 +// Separated the fixed length case from the original +// Attribute::read //-------------------------------------------------------------------------- void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const { @@ -527,31 +527,31 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // If there is data, allocate buffer and read it. if (attr_size > 0) { - char *strg_C = new char[attr_size+1]; - herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); - if( ret_value < 0 ) - { - delete []strg_C; // de-allocate for fixed-len string - throw AttributeIException("Attribute::read", "H5Aread failed"); - } - // Get string from the C char* and release resource allocated locally - strg_C[attr_size] = '\0'; - strg = strg_C; - delete []strg_C; + char *strg_C = new char[attr_size+1]; + herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); + if (ret_value < 0) + { + delete []strg_C; // de-allocate for fixed-len string + throw AttributeIException("Attribute::read", "H5Aread failed"); + } + // Get string from the C char* and release resource allocated locally + strg_C[attr_size] = '\0'; + strg = strg_C; + delete []strg_C; } } //-------------------------------------------------------------------------- -// Function: Attribute::p_read_variable_len (private) -// brief Reads a variable length \a H5std_string from an attribute. -// param mem_type - IN: Attribute datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// Function: Attribute::p_read_variable_len (private) +// brief Reads a variable length \a H5std_string from an attribute. +// param mem_type - IN: Attribute datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Jul, 2009 // Modification -// Jul 2009 -// Separated the variable length case from the original -// Attribute::read. -BMR +// Jul 2009 +// Separated the variable length case from the original +// Attribute::read. -BMR //-------------------------------------------------------------------------- void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg) const { @@ -561,9 +561,9 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Read attribute, no allocation for variable-len string; C library will herr_t ret_value = H5Aread(id, mem_type.getId(), &strg_C); - if( ret_value < 0 ) + if (ret_value < 0) { - throw AttributeIException("Attribute::read", "H5Aread failed"); + throw AttributeIException("Attribute::read", "H5Aread failed"); } // Get string from the C char* and release resource allocated by C API @@ -577,65 +577,65 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg ///\brief Sets the identifier of this object to a new value. /// ///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails +/// object fails // Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Attribute::p_setId(const hid_t new_id) { // handling references to this old id try { - close(); + close(); } catch (Exception& close_error) { - throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); + throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Attribute::close -///\brief Closes this attribute. +// Function: Attribute::close +///\brief Closes this attribute. /// -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void Attribute::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Aclose(id); - if( ret_value < 0 ) - { - throw AttributeIException("Attribute::close", "H5Aclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Aclose(id); + if (ret_value < 0) + { + throw AttributeIException("Attribute::close", "H5Aclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } //-------------------------------------------------------------------------- -// Function: Attribute destructor -///\brief Properly terminates access to this attribute. -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute destructor +///\brief Properly terminates access to this attribute. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- Attribute::~Attribute() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; + cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index c27bbdf..0243cd9 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -32,74 +32,74 @@ namespace H5 { class H5_DLLCPP Attribute : public AbstractDs, public H5Location { public: - // Copy constructor: makes a copy of an existing Attribute object. - Attribute( const Attribute& original ); + // Copy constructor: makes a copy of an existing Attribute object. + Attribute(const Attribute& original); - // Default constructor - Attribute(); + // Default constructor + Attribute(); - // Creates a copy of an existing attribute using the attribute id - Attribute( const hid_t attr_id ); + // Creates a copy of an existing attribute using the attribute id + Attribute(const hid_t attr_id); - // Closes this attribute. - virtual void close(); + // Closes this attribute. + virtual void close(); - // Gets the name of this attribute. - ssize_t getName(char* attr_name, size_t buf_size = 0) const; - H5std_string getName(size_t len) const; - H5std_string getName() const; - ssize_t getName(H5std_string& attr_name, size_t len = 0) const; - // The overloaded function below is replaced by the one above and it - // is kept for backward compatibility purpose. - ssize_t getName( size_t buf_size, H5std_string& attr_name ) const; + // Gets the name of this attribute. + ssize_t getName(char* attr_name, size_t buf_size = 0) const; + H5std_string getName(size_t len) const; + H5std_string getName() const; + ssize_t getName(H5std_string& attr_name, size_t len = 0) const; + // The overloaded function below is replaced by the one above and it + // is kept for backward compatibility purpose. + ssize_t getName(size_t buf_size, H5std_string& attr_name) const; - // Gets a copy of the dataspace for this attribute. - virtual DataSpace getSpace() const; + // Gets a copy of the dataspace for this attribute. + virtual DataSpace getSpace() const; - // Returns the amount of storage size required for this attribute. - virtual hsize_t getStorageSize() const; + // Returns the amount of storage size required for this attribute. + virtual hsize_t getStorageSize() const; - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; - // Reads data from this attribute. - void read( const DataType& mem_type, void *buf ) const; - void read( const DataType& mem_type, H5std_string& strg ) const; + // Reads data from this attribute. + void read(const DataType& mem_type, void *buf) const; + void read(const DataType& mem_type, H5std_string& strg) const; - // Writes data to this attribute. - void write(const DataType& mem_type, const void *buf ) const; - void write(const DataType& mem_type, const H5std_string& strg ) const; + // Writes data to this attribute. + void write(const DataType& mem_type, const void *buf) const; + void write(const DataType& mem_type, const H5std_string& strg) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Attribute"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("Attribute"); } - // Gets the attribute id. - virtual hid_t getId() const; + // Gets the attribute id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this attribute. - virtual ~Attribute(); + // Destructor: properly terminates access to this attribute. + virtual ~Attribute(); #ifndef DOXYGEN_SHOULD_SKIP_THIS protected: - // Sets the attribute id. - virtual void p_setId(const hid_t new_id); + // Sets the attribute id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS private: - hid_t id; // HDF5 attribute id + hid_t id; // HDF5 attribute id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this attribute. - void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const; - void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const; + // Reads variable or fixed len strings from this attribute. + void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const; + void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const; - // Friend function to set Attribute id. For library use only. - friend void f_Attribute_setId(Attribute* attr, hid_t new_id); + // Friend function to set Attribute id. For library use only. + friend void f_Attribute_setId(Attribute* attr, hid_t new_id); }; } diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 03faa1a..00066fe 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -18,31 +18,31 @@ #define __H5Classes_H namespace H5 { - class Exception; - class IdComponent; - class H5Location; - class H5Object; - class PropList; - class FileCreatPropList; - class FileAccPropList; - class LinkAccPropList; - class DSetCreatPropList; - class DSetMemXferPropList; - class DTypePropList; - class DataType; - class DataSpace; - class AtomType; - class PredType; - class EnumType; - class IntType; - class FloatType; - class StrType; - class CompType; - class AbstractDs; - class DataSet; - class Group; - class H5File; - class Attribute; - class H5Library; + class Exception; + class IdComponent; + class H5Location; + class H5Object; + class PropList; + class FileCreatPropList; + class FileAccPropList; + class LinkAccPropList; + class DSetCreatPropList; + class DSetMemXferPropList; + class DTypePropList; + class DataType; + class DataSpace; + class AtomType; + class PredType; + class EnumType; + class IntType; + class FloatType; + class StrType; + class CompType; + class AbstractDs; + class DataSet; + class Group; + class H5File; + class Attribute; + class H5Library; } #endif // __H5Classes_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 5f7971f..5c01055 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -16,7 +16,7 @@ #include #include "H5Include.h" -#include "H5private.h" // for HDstrcpy +#include "H5private.h" // for HDstrcpy #include "H5Exception.h" #include "H5IdComponent.h" #include "H5DataSpace.h" @@ -46,293 +46,292 @@ // December 2000 namespace H5 { -using namespace std; //-------------------------------------------------------------------------- -// Function: CommonFG::openDataType -///\brief Opens the named generic datatype at this location. -///\param name - IN: Name of the datatype to open -///\return DataType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openDataType +///\brief Opens the named generic datatype at this location. +///\param name - IN: Name of the datatype to open +///\return DataType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType( const char* name ) const +DataType CommonFG::openDataType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openDataType", "H5Topen2 failed"); + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openDataType", "H5Topen2 failed"); - // No failure, create and return the DataType object - DataType data_type(type_id); - return(data_type); + // No failure, create and return the DataType object + DataType data_type(type_id); + return(data_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openDataType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openDataType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType( const H5std_string& name ) const +DataType CommonFG::openDataType(const H5std_string& name) const { - return( openDataType( name.c_str()) ); + return(openDataType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openArrayType -///\brief Opens the named array datatype at this location. -///\param name - IN: Name of the array datatype to open -///\return ArrayType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CommonFG::openArrayType +///\brief Opens the named array datatype at this location. +///\param name - IN: Name of the array datatype to open +///\return ArrayType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType( const char* name ) const +ArrayType CommonFG::openArrayType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openArrayType", "H5Topen2 failed"); - - // No failure, create and return the ArrayType object - ArrayType array_type; - f_DataType_setId(&array_type, type_id); - return(array_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openArrayType", "H5Topen2 failed"); + + // No failure, create and return the ArrayType object + ArrayType array_type; + f_DataType_setId(&array_type, type_id); + return(array_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openArrayType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CommonFG::openArrayType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType( const H5std_string& name ) const +ArrayType CommonFG::openArrayType(const H5std_string& name) const { - return( openArrayType( name.c_str()) ); + return(openArrayType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openCompType -///\brief Opens the named compound datatype at this location. -///\param name - IN: Name of the compound datatype to open -///\return CompType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openCompType +///\brief Opens the named compound datatype at this location. +///\param name - IN: Name of the compound datatype to open +///\return CompType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType( const char* name ) const +CompType CommonFG::openCompType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openCompType", "H5Topen2 failed"); - - // No failure, create and return the CompType object - CompType comp_type; - f_DataType_setId(&comp_type, type_id); - return(comp_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openCompType", "H5Topen2 failed"); + + // No failure, create and return the CompType object + CompType comp_type; + f_DataType_setId(&comp_type, type_id); + return(comp_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openCompType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openCompType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType( const H5std_string& name ) const +CompType CommonFG::openCompType(const H5std_string& name) const { - return( openCompType( name.c_str()) ); + return(openCompType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openEnumType -///\brief Opens the named enumeration datatype at this location. -///\param name - IN: Name of the enumeration datatype to open -///\return EnumType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openEnumType +///\brief Opens the named enumeration datatype at this location. +///\param name - IN: Name of the enumeration datatype to open +///\return EnumType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType( const char* name ) const +EnumType CommonFG::openEnumType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openEnumType", "H5Topen2 failed"); - - // No failure, create and return the EnumType object - EnumType enum_type; - f_DataType_setId(&enum_type, type_id); - return(enum_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openEnumType", "H5Topen2 failed"); + + // No failure, create and return the EnumType object + EnumType enum_type; + f_DataType_setId(&enum_type, type_id); + return(enum_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openEnumType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openEnumType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType( const H5std_string& name ) const +EnumType CommonFG::openEnumType(const H5std_string& name) const { - return( openEnumType( name.c_str()) ); + return(openEnumType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openIntType -///\brief Opens the named integer datatype at this location. -///\param name - IN: Name of the integer datatype to open -///\return IntType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openIntType +///\brief Opens the named integer datatype at this location. +///\param name - IN: Name of the integer datatype to open +///\return IntType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType( const char* name ) const +IntType CommonFG::openIntType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openIntType", "H5Topen2 failed"); - - // No failure, create and return the IntType object - IntType int_type; - f_DataType_setId(&int_type, type_id); - return(int_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openIntType", "H5Topen2 failed"); + + // No failure, create and return the IntType object + IntType int_type; + f_DataType_setId(&int_type, type_id); + return(int_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openIntType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openIntType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType( const H5std_string& name ) const +IntType CommonFG::openIntType(const H5std_string& name) const { - return( openIntType( name.c_str()) ); + return(openIntType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openFloatType -///\brief Opens the named floating-point datatype at this location. -///\param name - IN: Name of the floating-point datatype to open -///\return FloatType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openFloatType +///\brief Opens the named floating-point datatype at this location. +///\param name - IN: Name of the floating-point datatype to open +///\return FloatType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType( const char* name ) const +FloatType CommonFG::openFloatType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openFloatType", "H5Topen2 failed"); - - // No failure, create and return the FloatType object - FloatType float_type; - f_DataType_setId(&float_type, type_id); - return(float_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openFloatType", "H5Topen2 failed"); + + // No failure, create and return the FloatType object + FloatType float_type; + f_DataType_setId(&float_type, type_id); + return(float_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openFloatType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openFloatType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType( const H5std_string& name ) const +FloatType CommonFG::openFloatType(const H5std_string& name) const { - return( openFloatType( name.c_str()) ); + return(openFloatType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openStrType -///\brief Opens the named string datatype at this location. -///\param name - IN: Name of the string datatype to open -///\return StrType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openStrType +///\brief Opens the named string datatype at this location. +///\param name - IN: Name of the string datatype to open +///\return StrType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType( const char* name ) const +StrType CommonFG::openStrType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openStrType", "H5Topen2 failed"); - - // No failure, create and return the StrType object - StrType str_type; - f_DataType_setId(&str_type, type_id); - return(str_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openStrType", "H5Topen2 failed"); + + // No failure, create and return the StrType object + StrType str_type; + f_DataType_setId(&str_type, type_id); + return(str_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openStrType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: CommonFG::openStrType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType( const H5std_string& name ) const +StrType CommonFG::openStrType(const H5std_string& name) const { - return( openStrType( name.c_str()) ); + return(openStrType(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CommonFG::openVarLenType -///\brief Opens the named variable length datatype at this location. -///\param name - IN: Name of the variable length datatype to open -///\return VarLenType instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CommonFG::openVarLenType +///\brief Opens the named variable length datatype at this location. +///\param name - IN: Name of the variable length datatype to open +///\return VarLenType instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType( const char* name ) const +VarLenType CommonFG::openVarLenType(const char* name) const { - // Call C function H5Topen2 to open the named datatype in this group, - // given either the file or group id - hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); - - // If the datatype's opening failed, throw an exception - if( type_id < 0 ) - throwException("openVarLenType", "H5Topen2 failed"); - - // No failure, create and return the VarLenType object - VarLenType varlen_type; - f_DataType_setId(&varlen_type, type_id); - return(varlen_type); + // Call C function H5Topen2 to open the named datatype in this group, + // given either the file or group id + hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT); + + // If the datatype's opening failed, throw an exception + if (type_id < 0) + throwException("openVarLenType", "H5Topen2 failed"); + + // No failure, create and return the VarLenType object + VarLenType varlen_type; + f_DataType_setId(&varlen_type, type_id); + return(varlen_type); } //-------------------------------------------------------------------------- -// Function: CommonFG::openVarLenType -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CommonFG::openVarLenType +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType( const H5std_string& name ) const +VarLenType CommonFG::openVarLenType(const H5std_string& name) const { - return( openVarLenType( name.c_str()) ); + return(openVarLenType(name.c_str())); } #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 59f425c..588d49a 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -32,55 +32,55 @@ class VarLenType; */ class H5_DLLCPP CommonFG { public: - // Opens a generic named datatype in this location. - DataType openDataType(const char* name) const; - DataType openDataType(const H5std_string& name) const; + // Opens a generic named datatype in this location. + DataType openDataType(const char* name) const; + DataType openDataType(const H5std_string& name) const; - // Opens a named array datatype in this location. - ArrayType openArrayType(const char* name) const; - ArrayType openArrayType(const H5std_string& name) const; + // Opens a named array datatype in this location. + ArrayType openArrayType(const char* name) const; + ArrayType openArrayType(const H5std_string& name) const; - // Opens a named compound datatype in this location. - CompType openCompType(const char* name) const; - CompType openCompType(const H5std_string& name) const; + // Opens a named compound datatype in this location. + CompType openCompType(const char* name) const; + CompType openCompType(const H5std_string& name) const; - // Opens a named enumeration datatype in this location. - EnumType openEnumType(const char* name) const; - EnumType openEnumType(const H5std_string& name) const; + // Opens a named enumeration datatype in this location. + EnumType openEnumType(const char* name) const; + EnumType openEnumType(const H5std_string& name) const; - // Opens a named integer datatype in this location. - IntType openIntType(const char* name) const; - IntType openIntType(const H5std_string& name) const; + // Opens a named integer datatype in this location. + IntType openIntType(const char* name) const; + IntType openIntType(const H5std_string& name) const; - // Opens a named floating-point datatype in this location. - FloatType openFloatType(const char* name) const; - FloatType openFloatType(const H5std_string& name) const; + // Opens a named floating-point datatype in this location. + FloatType openFloatType(const char* name) const; + FloatType openFloatType(const H5std_string& name) const; - // Opens a named string datatype in this location. - StrType openStrType(const char* name) const; - StrType openStrType(const H5std_string& name) const; + // Opens a named string datatype in this location. + StrType openStrType(const char* name) const; + StrType openStrType(const H5std_string& name) const; - // Opens a named variable length datatype in this location. - VarLenType openVarLenType(const char* name) const; - VarLenType openVarLenType(const H5std_string& name) const; + // Opens a named variable length datatype in this location. + VarLenType openVarLenType(const char* name) const; + VarLenType openVarLenType(const H5std_string& name) const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - /// For subclasses, H5File and Group, to return the correct - /// object id, i.e. file or group id. - virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to return the correct + /// object id, i.e. file or group id. + virtual hid_t getLocId() const = 0; - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; - // Default constructor. - CommonFG(); + // Default constructor. + CommonFG(); - // Noop destructor. - virtual ~CommonFG(); + // Noop destructor. + virtual ~CommonFG(); protected: - virtual void p_setId(const hid_t new_id) = 0; + virtual void p_setId(const hid_t new_id) = 0; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index babda34..037527f 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -33,203 +33,203 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: CompType default constructor -///\brief Default constructor: Creates a stub compound datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType default constructor +///\brief Default constructor: Creates a stub compound datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- CompType::CompType() : DataType() {} //-------------------------------------------------------------------------- -// Function: CompType copy constructor -///\brief Copy constructor: makes copy of the original CompType object -///\param original - IN: Original CompType instance -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType copy constructor +///\brief Copy constructor: makes copy of the original CompType object +///\param original - IN: Original CompType instance +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType( const CompType& original ) : DataType( original ) {} +CompType::CompType(const CompType& original) : DataType(original) {} //-------------------------------------------------------------------------- -// Function: CompType overloaded constructor -///\brief Creates a CompType object using the id of an existing datatype. -///\param existing_id - IN: Id of an existing compound datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType overloaded constructor +///\brief Creates a CompType object using the id of an existing datatype. +///\param existing_id - IN: Id of an existing compound datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType( const hid_t existing_id ) : DataType( existing_id ) {} +CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} //-------------------------------------------------------------------------- -// Function: CompType overloaded constructor -///\brief Creates an empty compound datatype given a size, in bytes. -///\param size - IN: Number of bytes in the datatype to create -///\exception H5::DataTypeIException +// Function: CompType overloaded constructor +///\brief Creates an empty compound datatype given a size, in bytes. +///\param size - IN: Number of bytes in the datatype to create +///\exception H5::DataTypeIException // Description -// The DataType constructor calls the C API H5Tcreate to create -// the compound datatype. -// Programmer Binh-Minh Ribler - 2000 +// The DataType constructor calls the C API H5Tcreate to create +// the compound datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType( size_t size ) : DataType( H5T_COMPOUND, size ) {} +CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} //-------------------------------------------------------------------------- -// Function: CompType overloaded constructor -///\brief Gets the compound datatype of the specified dataset. -///\param dataset - IN: Dataset that this enum datatype associates with -///\return CompType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType overloaded constructor +///\brief Gets the compound datatype of the specified dataset. +///\param dataset - IN: Dataset that this enum datatype associates with +///\return CompType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType( const DataSet& dataset ) : DataType() +CompType::CompType(const DataSet& dataset) : DataType() { - // Calls C function H5Dget_type to get the id of the datatype - id = H5Dget_type( dataset.getId() ); - - // If the datatype id is invalid, throw exception - if( id < 0 ) - { - throw DataSetIException("CompType constructor", "H5Dget_type failed"); - } + // Calls C function H5Dget_type to get the id of the datatype + id = H5Dget_type(dataset.getId()); + + // If the datatype id is invalid, throw exception + if (id < 0) + { + throw DataSetIException("CompType constructor", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: CompType overloaded constructor -///\brief Creates an CompType instance by opening an HDF5 compound -/// given its name, provided as a C character string. -///\param dtype_name - IN: Compound type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: CompType overloaded constructor +///\brief Creates an CompType instance by opening an HDF5 compound +/// given its name, provided as a C character string. +///\param dtype_name - IN: Compound type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openCompType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openCompType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() { - id = p_opentype(loc, dtype_name); + id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- -// Function: CompType overloaded constructor -///\brief Creates an CompType instance by opening an HDF5 compound -/// datatype given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Compound type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: CompType overloaded constructor +///\brief Creates an CompType instance by opening an HDF5 compound +/// datatype given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Compound type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openCompType(const H5Location&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openCompType(const H5Location&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : DataType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: CompType::getNmembers -///\brief Returns the number of members in this compound datatype. -///\return Number of members -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getNmembers +///\brief Returns the number of members in this compound datatype. +///\return Number of members +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int CompType::getNmembers() const { - int num_members = H5Tget_nmembers( id ); - if( num_members < 0 ) - { - throw DataTypeIException("CompType::getNmembers", - "H5Tget_nmembers returns negative number of members"); - } - return( num_members ); + int num_members = H5Tget_nmembers(id); + if (num_members < 0) + { + throw DataTypeIException("CompType::getNmembers", + "H5Tget_nmembers returns negative number of members"); + } + return(num_members); } //-------------------------------------------------------------------------- -// Function: CompType::getMemberName -///\brief Returns the name of a member in this compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return Name of member -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberName +///\brief Returns the name of a member in this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return Name of member +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string CompType::getMemberName( unsigned member_num ) const +H5std_string CompType::getMemberName(unsigned member_num) const { - char* member_name_C = H5Tget_member_name( id, member_num ); - if( member_name_C == NULL ) // NULL means failure + char* member_name_C = H5Tget_member_name(id, member_num); + if (member_name_C == NULL) // NULL means failure { - throw DataTypeIException("CompType::getMemberName", - "H5Tget_member_name returns NULL for member name"); + throw DataTypeIException("CompType::getMemberName", + "H5Tget_member_name returns NULL for member name"); } H5std_string member_name = H5std_string(member_name_C); // convert C string to string H5free_memory(member_name_C); // free the C string - return( member_name ); // return the member name string + return(member_name); // return the member name string } //-------------------------------------------------------------------------- -// Function: CompType::getMemberIndex -///\brief Returns the index of a member in this compound datatype. -///\param name - IN: Name of the member -///\return Index of member -///\exception H5::DataTypeIException +// Function: CompType::getMemberIndex +///\brief Returns the index of a member in this compound datatype. +///\param name - IN: Name of the member +///\return Index of member +///\exception H5::DataTypeIException ///\par Description -/// Members are stored in no particular order with numbers 0 -/// through N-1, where N is the value returned by the member -/// function \c CompType::getNmembers. -// Programmer Binh-Minh Ribler - May 16, 2002 +/// Members are stored in no particular order with numbers 0 +/// through N-1, where N is the value returned by the member +/// function \c CompType::getNmembers. +// Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- int CompType::getMemberIndex(const char* name) const { - int member_index = H5Tget_member_index(id, name); - if( member_index < 0 ) - { - throw DataTypeIException("CompType::getMemberIndex", - "H5Tget_member_index returns negative value"); - } - return( member_index ); + int member_index = H5Tget_member_index(id, name); + if (member_index < 0) + { + throw DataTypeIException("CompType::getMemberIndex", + "H5Tget_member_index returns negative value"); + } + return(member_index); } int CompType::getMemberIndex(const H5std_string& name) const { - return(getMemberIndex(name.c_str())); + return(getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- -// Function: CompType::getMemberOffset -///\brief Returns the byte offset of the beginning of a member with -/// respect to the beginning of the compound data type datum. -///\param member_num - IN: Zero-based index of the member -///\return Byte offset -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberOffset +///\brief Returns the byte offset of the beginning of a member with +/// respect to the beginning of the compound data type datum. +///\param member_num - IN: Zero-based index of the member +///\return Byte offset +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 // Description -/// Members are stored in no particular order with numbers 0 -/// through N-1, where N is the value returned by the member -/// function \c CompType::getNmembers. +/// Members are stored in no particular order with numbers 0 +/// through N-1, where N is the value returned by the member +/// function \c CompType::getNmembers. // -// Note that byte offset being returned as 0 doesn't indicate -// a failure. (According to Quincey) +// Note that byte offset being returned as 0 doesn't indicate +// a failure. (According to Quincey) //-------------------------------------------------------------------------- -size_t CompType::getMemberOffset( unsigned member_num ) const +size_t CompType::getMemberOffset(unsigned member_num) const { - size_t offset = H5Tget_member_offset( id, member_num ); - return( offset ); + size_t offset = H5Tget_member_offset(id, member_num); + return(offset); } //-------------------------------------------------------------------------- -// Function: CompType::getMemberClass -///\brief Gets the type class of the specified member. -///\param member_num - IN: Zero-based index of the member -///\return Type class of the member -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberClass +///\brief Gets the type class of the specified member. +///\param member_num - IN: Zero-based index of the member +///\return Type class of the member +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to use H5Tget_member_class instead. - Jul, 2005 +// Modified to use H5Tget_member_class instead. - Jul, 2005 //-------------------------------------------------------------------------- -H5T_class_t CompType::getMemberClass( unsigned member_num ) const +H5T_class_t CompType::getMemberClass(unsigned member_num) const { - H5T_class_t member_class = H5Tget_member_class(id, member_num); - if( member_class == H5T_NO_CLASS ) - { - throw DataTypeIException("CompType::getMemberClass", - "H5Tget_member_class returns H5T_NO_CLASS"); - } - return(member_class); + H5T_class_t member_class = H5Tget_member_class(id, member_num); + if (member_class == H5T_NO_CLASS) + { + throw DataTypeIException("CompType::getMemberClass", + "H5Tget_member_class returns H5T_NO_CLASS"); + } + return(member_class); } // This private member function calls the C API to get the identifier @@ -238,184 +238,184 @@ H5T_class_t CompType::getMemberClass( unsigned member_num ) const // the sub-types. hid_t CompType::p_get_member_type(unsigned member_num) const { - // get the id of the specified member first - hid_t member_type_id = H5Tget_member_type( id, member_num ); - if( member_type_id > 0 ) - return( member_type_id ); - else - { - // p_get_member_type is private, caller will catch this exception - // then throw another with appropriate API name - throw DataTypeIException("", "H5Tget_member_type failed"); - } + // get the id of the specified member first + hid_t member_type_id = H5Tget_member_type(id, member_num); + if (member_type_id > 0) + return(member_type_id); + else + { + // p_get_member_type is private, caller will catch this exception + // then throw another with appropriate API name + throw DataTypeIException("", "H5Tget_member_type failed"); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberDataType -///\brief Returns the generic datatype of the specified member in this -/// compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return DataType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberDataType +///\brief Returns the generic datatype of the specified member in this +/// compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return DataType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CompType::getMemberDataType( unsigned member_num ) const +DataType CompType::getMemberDataType(unsigned member_num) const { - try { - DataType datatype; - f_DataType_setId(&datatype, p_get_member_type(member_num)); - return(datatype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); - } + try { + DataType datatype; + f_DataType_setId(&datatype, p_get_member_type(member_num)); + return(datatype); + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberArrayType -///\brief Returns the array datatype of the specified member in this -/// compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return ArrayType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CompType::getMemberArrayType +///\brief Returns the array datatype of the specified member in this +/// compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return ArrayType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CompType::getMemberArrayType( unsigned member_num ) const +ArrayType CompType::getMemberArrayType(unsigned member_num) const { - try { - ArrayType arraytype(p_get_member_type(member_num)); - f_DataType_setId(&arraytype, p_get_member_type(member_num)); - return(arraytype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); - } + try { + ArrayType arraytype(p_get_member_type(member_num)); + f_DataType_setId(&arraytype, p_get_member_type(member_num)); + return(arraytype); + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberCompType -///\brief Returns the compound datatype of the specified member in this -/// compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return CompType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberCompType +///\brief Returns the compound datatype of the specified member in this +/// compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return CompType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CompType::getMemberCompType( unsigned member_num ) const +CompType CompType::getMemberCompType(unsigned member_num) const { try { CompType comptype(p_get_member_type(member_num)); - f_DataType_setId(&comptype, p_get_member_type(member_num)); + f_DataType_setId(&comptype, p_get_member_type(member_num)); return(comptype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberEnumType -///\brief Returns the enumeration datatype of the specified member in -/// this compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return EnumType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberEnumType +///\brief Returns the enumeration datatype of the specified member in +/// this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return EnumType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CompType::getMemberEnumType( unsigned member_num ) const +EnumType CompType::getMemberEnumType(unsigned member_num) const { try { EnumType enumtype(p_get_member_type(member_num)); - f_DataType_setId(&enumtype, p_get_member_type(member_num)); + f_DataType_setId(&enumtype, p_get_member_type(member_num)); return(enumtype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberIntType -///\brief Returns the integer datatype of the specified member in this -/// compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return IntType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberIntType +///\brief Returns the integer datatype of the specified member in this +/// compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return IntType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CompType::getMemberIntType( unsigned member_num ) const +IntType CompType::getMemberIntType(unsigned member_num) const { try { IntType inttype(p_get_member_type(member_num)); - f_DataType_setId(&inttype, p_get_member_type(member_num)); + f_DataType_setId(&inttype, p_get_member_type(member_num)); return(inttype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberFloatType -///\brief Returns the floating-point datatype of the specified member -/// in this compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return FloatType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberFloatType +///\brief Returns the floating-point datatype of the specified member +/// in this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return FloatType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CompType::getMemberFloatType( unsigned member_num ) const +FloatType CompType::getMemberFloatType(unsigned member_num) const { try { FloatType floatype(p_get_member_type(member_num)); - f_DataType_setId(&floatype, p_get_member_type(member_num)); + f_DataType_setId(&floatype, p_get_member_type(member_num)); return(floatype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberStrType -///\brief Returns the string datatype of the specified member in this -/// compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return StrType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::getMemberStrType +///\brief Returns the string datatype of the specified member in this +/// compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return StrType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CompType::getMemberStrType( unsigned member_num ) const +StrType CompType::getMemberStrType(unsigned member_num) const { try { StrType strtype(p_get_member_type(member_num)); - f_DataType_setId(&strtype, p_get_member_type(member_num)); + f_DataType_setId(&strtype, p_get_member_type(member_num)); return(strtype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: CompType::getMemberVarLenType -///\brief Returns the variable length datatype of the specified member -/// in this compound datatype. -///\param member_num - IN: Zero-based index of the member -///\return VarLenType instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: CompType::getMemberVarLenType +///\brief Returns the variable length datatype of the specified member +/// in this compound datatype. +///\param member_num - IN: Zero-based index of the member +///\return VarLenType instance +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CompType::getMemberVarLenType( unsigned member_num ) const +VarLenType CompType::getMemberVarLenType(unsigned member_num) const { try { VarLenType varlentype(p_get_member_type(member_num)); - f_DataType_setId(&varlentype, p_get_member_type(member_num)); + f_DataType_setId(&varlentype, p_get_member_type(member_num)); return(varlentype); - } - catch (DataTypeIException& E) { - throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); - } + } + catch (DataTypeIException& E) { + throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); + } } /* old style of getMemberType - using overloads; new style above @@ -424,27 +424,27 @@ VarLenType CompType::getMemberVarLenType( unsigned member_num ) const May, 2004: These should be reconsidered to provide more convenience. // Returns the datatype of the specified member in this compound datatype. // Several overloading of getMemberType are for different datatypes -void CompType::getMemberType( unsigned member_num, EnumType& enumtype ) const +void CompType::getMemberType(unsigned member_num, EnumType& enumtype) const { p_get_member_type(member_num, enumtype); } -void CompType::getMemberType( unsigned member_num, CompType& comptype ) const +void CompType::getMemberType(unsigned member_num, CompType& comptype) const { p_get_member_type(member_num, comptype); } -void CompType::getMemberType( unsigned member_num, IntType& inttype ) const +void CompType::getMemberType(unsigned member_num, IntType& inttype) const { p_get_member_type(member_num, inttype); } -void CompType::getMemberType( unsigned member_num, FloatType& floatype ) const +void CompType::getMemberType(unsigned member_num, FloatType& floatype) const { p_get_member_type(member_num, floatype); } -void CompType::getMemberType( unsigned member_num, StrType& strtype ) const +void CompType::getMemberType(unsigned member_num, StrType& strtype) const { p_get_member_type(member_num, strtype); } @@ -452,55 +452,55 @@ void CompType::getMemberType( unsigned member_num, StrType& strtype ) const */ //-------------------------------------------------------------------------- -// Function: CompType::insertMember -///\brief Inserts a new member to this compound datatype. -///\param name - IN: Name of the new member -///\param offset - IN: Offset in memory structure of the field to insert -///\param new_member - IN: New member to be inserted -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: CompType::insertMember +///\brief Inserts a new member to this compound datatype. +///\param name - IN: Name of the new member +///\param offset - IN: Offset in memory structure of the field to insert +///\param new_member - IN: New member to be inserted +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::insertMember( const H5std_string& name, size_t offset, const DataType& new_member ) const +void CompType::insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const { - // Convert string to C-string - const char* name_C; - name_C = name.c_str(); // name_C refers to the contents of name as a C-str - - hid_t new_member_id = new_member.getId(); // get new_member id for C API - - // Call C routine H5Tinsert to add the new member - herr_t ret_value = H5Tinsert( id, name_C, offset, new_member_id ); - if( ret_value < 0 ) - { - throw DataTypeIException("CompType::insertMember", "H5Tinsert failed"); - } + // Convert string to C-string + const char* name_C; + name_C = name.c_str(); // name_C refers to the contents of name as a C-str + + hid_t new_member_id = new_member.getId(); // get new_member id for C API + + // Call C routine H5Tinsert to add the new member + herr_t ret_value = H5Tinsert(id, name_C, offset, new_member_id); + if (ret_value < 0) + { + throw DataTypeIException("CompType::insertMember", "H5Tinsert failed"); + } } //-------------------------------------------------------------------------- -// Function: CompType::pack -///\brief Recursively removes padding from within a compound datatype. +// Function: CompType::pack +///\brief Recursively removes padding from within a compound datatype. /// -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void CompType::pack() const { - // Calls C routine H5Tpack to remove padding - herr_t ret_value = H5Tpack( id ); - if( ret_value < 0 ) - { - throw DataTypeIException("CompType::pack", "H5Tpack failed"); - } + // Calls C routine H5Tpack to remove padding + herr_t ret_value = H5Tpack(id); + if (ret_value < 0) + { + throw DataTypeIException("CompType::pack", "H5Tpack failed"); + } } //-------------------------------------------------------------------------- -// Function: CompType::setSize -///\brief Sets the total size for this compound datatype. -///\param size - IN: Size to set -///\exception H5::DataTypeIException +// Function: CompType::setSize +///\brief Sets the total size for this compound datatype. +///\param size - IN: Size to set +///\exception H5::DataTypeIException // Note -// H5Tset_size works on atom datatypes and compound datatypes only -// Programmer Binh-Minh Ribler - 2014 +// H5Tset_size works on atom datatypes and compound datatypes only +// Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- void CompType::setSize(size_t size) const { @@ -508,7 +508,7 @@ void CompType::setSize(size_t size) const herr_t ret_value = H5Tset_size(id, size); if (ret_value < 0) { - throw DataTypeIException("CompType::setSize", "H5Tset_size failed"); + throw DataTypeIException("CompType::setSize", "H5Tset_size failed"); } } diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 3337df7..222044d 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -27,94 +27,94 @@ namespace H5 { */ class H5_DLLCPP CompType : public DataType { public: - // Default constructor - CompType(); + // Default constructor + CompType(); - // Creates a compound datatype using an existing id - CompType( const hid_t existing_id ); + // Creates a compound datatype using an existing id + CompType(const hid_t existing_id); - // Creates a new compound datatype, given the type's size - CompType( size_t size ); // H5Tcreate + // Creates a new compound datatype, given the type's size + CompType(size_t size); // H5Tcreate - // Gets the compound datatype of the specified dataset - CompType( const DataSet& dataset ); // H5Dget_type + // Gets the compound datatype of the specified dataset + CompType(const DataSet& dataset); // H5Dget_type - // Copy constructor - makes a copy of original object - CompType( const CompType& original ); + // Copy constructor - makes a copy of original object + CompType(const CompType& original); - // Constructors that open a compound datatype, given a location. - CompType(const H5Location& loc, const char* name); - CompType(const H5Location& loc, const H5std_string& name); + // Constructors that open a compound datatype, given a location. + CompType(const H5Location& loc, const char* name); + CompType(const H5Location& loc, const H5std_string& name); - // Returns the type class of the specified member of this compound - // datatype. It provides to the user a way of knowing what type - // to create another datatype of the same class - H5T_class_t getMemberClass( unsigned member_num ) const; + // Returns the type class of the specified member of this compound + // datatype. It provides to the user a way of knowing what type + // to create another datatype of the same class + H5T_class_t getMemberClass(unsigned member_num) const; - // Returns the index of a member in this compound data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this compound data type. + int getMemberIndex(const char* name) const; + int getMemberIndex(const H5std_string& name) const; - // Returns the offset of a member of this compound datatype. - size_t getMemberOffset( unsigned memb_no ) const; + // Returns the offset of a member of this compound datatype. + size_t getMemberOffset(unsigned memb_no) const; - // Returns the name of a member of this compound datatype. - H5std_string getMemberName( unsigned member_num ) const; + // Returns the name of a member of this compound datatype. + H5std_string getMemberName(unsigned member_num) const; - // Returns the generic datatype of the specified member in - // this compound datatype. - DataType getMemberDataType( unsigned member_num ) const; + // Returns the generic datatype of the specified member in + // this compound datatype. + DataType getMemberDataType(unsigned member_num) const; - // Returns the array datatype of the specified member in - // this compound datatype. - ArrayType getMemberArrayType( unsigned member_num ) const; + // Returns the array datatype of the specified member in + // this compound datatype. + ArrayType getMemberArrayType(unsigned member_num) const; - // Returns the compound datatype of the specified member in - // this compound datatype. - CompType getMemberCompType( unsigned member_num ) const; + // Returns the compound datatype of the specified member in + // this compound datatype. + CompType getMemberCompType(unsigned member_num) const; - // Returns the enumeration datatype of the specified member in - // this compound datatype. - EnumType getMemberEnumType( unsigned member_num ) const; + // Returns the enumeration datatype of the specified member in + // this compound datatype. + EnumType getMemberEnumType(unsigned member_num) const; - // Returns the integer datatype of the specified member in - // this compound datatype. - IntType getMemberIntType( unsigned member_num ) const; + // Returns the integer datatype of the specified member in + // this compound datatype. + IntType getMemberIntType(unsigned member_num) const; - // Returns the floating-point datatype of the specified member in - // this compound datatype. - FloatType getMemberFloatType( unsigned member_num ) const; + // Returns the floating-point datatype of the specified member in + // this compound datatype. + FloatType getMemberFloatType(unsigned member_num) const; - // Returns the string datatype of the specified member in - // this compound datatype. - StrType getMemberStrType( unsigned member_num ) const; + // Returns the string datatype of the specified member in + // this compound datatype. + StrType getMemberStrType(unsigned member_num) const; - // Returns the variable length datatype of the specified member in - // this compound datatype. - VarLenType getMemberVarLenType( unsigned member_num ) const; + // Returns the variable length datatype of the specified member in + // this compound datatype. + VarLenType getMemberVarLenType(unsigned member_num) const; - // Returns the number of members in this compound datatype. - int getNmembers() const; + // Returns the number of members in this compound datatype. + int getNmembers() const; - // Adds a new member to this compound datatype. - void insertMember( const H5std_string& name, size_t offset, const DataType& new_member ) const; + // Adds a new member to this compound datatype. + void insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const; - // Recursively removes padding from within this compound datatype. - void pack() const; + // Recursively removes padding from within this compound datatype. + void pack() const; - // Sets the total size for this compound datatype. - void setSize(size_t size) const; + // Sets the total size for this compound datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("CompType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("CompType"); } - // Noop destructor. - virtual ~CompType(); + // Noop destructor. + virtual ~CompType(); private: - // Contains common code that is used by the member functions - // getMemberXxxType - hid_t p_get_member_type(unsigned member_num) const; + // Contains common code that is used by the member functions + // getMemberXxxType + hid_t p_get_member_type(unsigned member_num) const; }; } #endif // __H5CompType_H diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index 2420586..afc6ebf 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -67,34 +67,34 @@ *
*/ -/// This example shows how to create datasets. +/// This example shows how to create datasets. ///\par ///\example create.cpp ///\par -/// This example shows how to write datasets. +/// This example shows how to write datasets. ///\example writedata.cpp ///\par -/// This example shows how to read datasets. +/// This example shows how to read datasets. ///\example readdata.cpp ///\par -/// This example shows how to create a compound datatype, -/// write an array which has the compound datatype to the file, -/// and read back fields' subsets. +/// This example shows how to create a compound datatype, +/// write an array which has the compound datatype to the file, +/// and read back fields' subsets. ///\example compound.cpp ///\par -/// This example shows how to work with extendible datasets. +/// This example shows how to work with extendible datasets. ///\example extend_ds.cpp ///\par -/// This example shows how to read data from a chunked dataset. +/// This example shows how to read data from a chunked dataset. ///\example chunks.cpp ///\par -/// This example shows how to work with groups. +/// This example shows how to work with groups. ///\example h5group.cpp #endif // __H5CppDoc_H diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 7c5b994..a0db328 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -20,7 +20,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -44,23 +44,23 @@ using std::cerr; using std::endl; //-------------------------------------------------------------------------- -// Function: DataSet default constructor -///\brief Default constructor: creates a stub DataSet. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet default constructor +///\brief Default constructor: creates a stub DataSet. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- -// Function: DataSet overloaded constructor -///\brief Creates an DataSet object using the id of an existing dataset. -///\param existing_id - IN: Id of an existing dataset -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet overloaded constructor +///\brief Creates an DataSet object using the id of an existing dataset. +///\param existing_id - IN: Id of an existing dataset +// Programmer Binh-Minh Ribler - 2000 // Description -// incRefCount() is needed here to prevent the id from being closed -// prematurely. That is, when application uses the id of an -// existing DataSet object to create another DataSet object. So, -// when one of those objects is deleted, the id will be closed if -// the reference counter is only 1. +// incRefCount() is needed here to prevent the id from being closed +// prematurely. That is, when application uses the id of an +// existing DataSet object to create another DataSet object. So, +// when one of those objects is deleted, the id will be closed if +// the reference counter is only 1. //-------------------------------------------------------------------------- DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existing_id) { @@ -68,10 +68,10 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existin } //-------------------------------------------------------------------------- -// Function: DataSet copy constructor -///\brief Copy constructor: makes a copy of the original DataSet object. -///\param original - IN: DataSet instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet copy constructor +///\brief Copy constructor: makes a copy of the original DataSet object. +///\param original - IN: DataSet instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id) { @@ -79,22 +79,22 @@ DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(origina } //-------------------------------------------------------------------------- -// Function: DataSet overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 location, creates a -/// DataSet object -///\param loc - IN: Dataset reference object is in or location of -/// object that the dataset is located within. -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::DataSetIException +// Function: DataSet overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 location, creates a +/// DataSet object +///\param loc - IN: Dataset reference object is in or location of +/// object that the dataset is located within. +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::DataSetIException ///\par Description -/// \c loc can be DataSet, Group, H5File, or named DataType, that -/// is a datatype that has been named by DataType::commit. -// Programmer Binh-Minh Ribler - Oct, 2006 +/// \c loc can be DataSet, Group, H5File, or named DataType, that +/// is a datatype that has been named by DataType::commit. +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// Jul, 2008 -// Added for application convenience. +// Jul, 2008 +// Added for application convenience. //-------------------------------------------------------------------------- DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { @@ -102,18 +102,18 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co } //-------------------------------------------------------------------------- -// Function: DataSet overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 attribute, creates a -/// DataSet object -///\param attr - IN: Specifying location where the referenced object is in -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// Function: DataSet overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 attribute, creates a +/// DataSet object +///\param attr - IN: Specifying location where the referenced object is in +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// Jul, 2008 -// Added for application convenience. +// Jul, 2008 +// Added for application convenience. //-------------------------------------------------------------------------- DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { @@ -121,26 +121,26 @@ DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, co } //-------------------------------------------------------------------------- -// Function: DataSet::getSpace -///\brief Gets a copy of the dataspace of this dataset. -///\return DataSpace instance -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getSpace +///\brief Gets a copy of the dataspace of this dataset. +///\return DataSpace instance +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSpace DataSet::getSpace() const { - // Calls C function H5Dget_space to get the id of the dataspace - hid_t dataspace_id = H5Dget_space( id ); - - // If the dataspace id is invalid, throw an exception - if( dataspace_id < 0 ) - { - throw DataSetIException("DataSet::getSpace", "H5Dget_space failed"); - } - //create dataspace object using the existing id then return the object - DataSpace data_space; - f_DataSpace_setId(&data_space, dataspace_id); - return( data_space ); + // Calls C function H5Dget_space to get the id of the dataspace + hid_t dataspace_id = H5Dget_space(id); + + // If the dataspace id is invalid, throw an exception + if (dataspace_id < 0) + { + throw DataSetIException("DataSet::getSpace", "H5Dget_space failed"); + } + //create dataspace object using the existing id then return the object + DataSpace data_space; + f_DataSpace_setId(&data_space, dataspace_id); + return(data_space); } // This private member function calls the C API to get the identifier @@ -148,57 +148,57 @@ DataSpace DataSet::getSpace() const // by the various AbstractDs functions to get the specific datatype. hid_t DataSet::p_get_type() const { - hid_t type_id = H5Dget_type( id ); - if( type_id > 0 ) - return( type_id ); - else - { - throw DataSetIException("", "H5Dget_type failed"); - } + hid_t type_id = H5Dget_type(id); + if (type_id > 0) + return(type_id); + else + { + throw DataSetIException("", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::getCreatePlist -///\brief Gets the dataset creation property list. -///\return DSetCreatPropList instance -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getCreatePlist +///\brief Gets the dataset creation property list. +///\return DSetCreatPropList instance +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetCreatPropList DataSet::getCreatePlist() const { - hid_t create_plist_id = H5Dget_create_plist( id ); - if( create_plist_id < 0 ) - { - throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); - } - - // create and return the DSetCreatPropList object - DSetCreatPropList create_plist; - f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + hid_t create_plist_id = H5Dget_create_plist(id); + if (create_plist_id < 0) + { + throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); + } + + // create and return the DSetCreatPropList object + DSetCreatPropList create_plist; + f_PropList_setId(&create_plist, create_plist_id); + return(create_plist); } //-------------------------------------------------------------------------- -// Function: DataSet::getStorageSize -///\brief Returns the amount of storage required for a dataset. -///\return Size of the storage or 0, for no data -///\exception H5::DataSetIException -// Note: H5Dget_storage_size returns 0 when there is no data. This -// function should have no failure. (from SLU) -// Programmer Binh-Minh Ribler - Mar, 2005 +// Function: DataSet::getStorageSize +///\brief Returns the amount of storage required for a dataset. +///\return Size of the storage or 0, for no data +///\exception H5::DataSetIException +// Note: H5Dget_storage_size returns 0 when there is no data. This +// function should have no failure. (from SLU) +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- hsize_t DataSet::getStorageSize() const { - hsize_t storage_size = H5Dget_storage_size(id); - return(storage_size); + hsize_t storage_size = H5Dget_storage_size(id); + return(storage_size); } //-------------------------------------------------------------------------- -// Function: DataSet::getInMemDataSize -///\brief Gets the size in memory of the dataset's data. -///\return Size of data (in memory) -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Apr 2009 +// Function: DataSet::getInMemDataSize +///\brief Gets the size in memory of the dataset's data. +///\return Size of data (in memory) +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- size_t DataSet::getInMemDataSize() const { @@ -206,9 +206,9 @@ size_t DataSet::getInMemDataSize() const // Get the data type of this dataset hid_t mem_type_id = H5Dget_type(id); - if( mem_type_id < 0 ) + if (mem_type_id < 0) { - throw DataSetIException(func, "H5Dget_type failed"); + throw DataSetIException(func, "H5Dget_type failed"); } // Get the data type's size by first getting its native type then getting @@ -216,22 +216,22 @@ size_t DataSet::getInMemDataSize() const hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); if (native_type < 0) { - throw DataSetIException(func, "H5Tget_native_type failed"); + throw DataSetIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); if (type_size == 0) { - throw DataSetIException(func, "H5Tget_size failed"); + throw DataSetIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this dataset. if (H5Tclose(native_type) < 0) { - throw DataSetIException(func, "H5Tclose(native_type) failed"); + throw DataSetIException(func, "H5Tclose(native_type) failed"); } if (H5Tclose(mem_type_id) < 0) { - throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); + throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the dataset by first getting its dataspace, @@ -239,18 +239,18 @@ size_t DataSet::getInMemDataSize() const hid_t space_id = H5Dget_space(id); if (space_id < 0) { - throw DataSetIException(func, "H5Dget_space failed"); + throw DataSetIException(func, "H5Dget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); if (num_elements < 0) { - throw DataSetIException(func, "H5Sget_simple_extent_npoints failed"); + throw DataSetIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace if (H5Sclose(space_id) < 0) { - throw DataSetIException(func, "H5Sclose failed"); + throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data @@ -259,184 +259,184 @@ size_t DataSet::getInMemDataSize() const } //-------------------------------------------------------------------------- -// Function: DataSet::getOffset -///\brief Returns the address of this dataset in the file. -///\return Address of dataset -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getOffset +///\brief Returns the address of this dataset in the file. +///\return Address of dataset +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- haddr_t DataSet::getOffset() const { - haddr_t ds_addr; // for address of dataset - - ds_addr = H5Dget_offset(id); - if( ds_addr == HADDR_UNDEF ) - { - throw DataSetIException("DataSet::getOffset", "H5Dget_offset returned HADDR_UNDEF"); - } - return(ds_addr); + haddr_t ds_addr; // for address of dataset + + ds_addr = H5Dget_offset(id); + if (ds_addr == HADDR_UNDEF) + { + throw DataSetIException("DataSet::getOffset", "H5Dget_offset returned HADDR_UNDEF"); + } + return(ds_addr); } //-------------------------------------------------------------------------- -// Function: DataSet::getSpaceStatus -///\brief Determines whether space has been allocated for a dataset. -///\param status - OUT: Space allocation status -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getSpaceStatus +///\brief Determines whether space has been allocated for a dataset. +///\param status - OUT: Space allocation status +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSet::getSpaceStatus(H5D_space_status_t& status) const { - herr_t ret_value = H5Dget_space_status(id, &status); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::getSpaceStatus", "H5Dget_space_status failed"); - } + herr_t ret_value = H5Dget_space_status(id, &status); + if (ret_value < 0) + { + throw DataSetIException("DataSet::getSpaceStatus", "H5Dget_space_status failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::getVlenBufSize -///\brief Returns the number of bytes required to store VL data. -///\param type - IN: Datatype, which is the datatype for the buffer -///\param space - IN: Selection for the memory buffer -///\return Amount of storage -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getVlenBufSize +///\brief Returns the number of bytes required to store VL data. +///\param type - IN: Datatype, which is the datatype for the buffer +///\param space - IN: Selection for the memory buffer +///\return Amount of storage +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space ) const +hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) const { - // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); - - hsize_t size; // for amount of storage - - herr_t ret_value = H5Dvlen_get_buf_size( id, type_id, space_id, &size ); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::getVlenBufSize", "H5Dvlen_get_buf_size failed"); - } - return( size ); + // Obtain identifiers for C API + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); + + hsize_t size; // for amount of storage + + herr_t ret_value = H5Dvlen_get_buf_size(id, type_id, space_id, &size); + if (ret_value < 0) + { + throw DataSetIException("DataSet::getVlenBufSize", "H5Dvlen_get_buf_size failed"); + } + return(size); } //-------------------------------------------------------------------------- -// Function: DataSet::getVlenBufSize -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Return Amount of storage -// Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getVlenBufSize +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Return Amount of storage +// Exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//hsize_t DataSet::getVlenBufSize( DataType& type, DataSpace& space ) const +//hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const //{ // return(getVlenBufSize(type, space)); //} //-------------------------------------------------------------------------- -// Function: DataSet::vlenReclaim -///\brief Reclaims VL datatype memory buffers. -///\param type - IN: Datatype, which is the datatype stored in the buffer -///\param space - IN: Selection for the memory buffer to free the -/// VL datatypes within -///\param xfer_plist - IN: Property list used to create the buffer -///\param buf - IN: Pointer to the buffer to be reclaimed -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::vlenReclaim +///\brief Reclaims VL datatype memory buffers. +///\param type - IN: Datatype, which is the datatype stored in the buffer +///\param space - IN: Selection for the memory buffer to free the +/// VL datatypes within +///\param xfer_plist - IN: Property list used to create the buffer +///\param buf - IN: Pointer to the buffer to be reclaimed +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf ) +void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf) { - // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); - hid_t xfer_plist_id = xfer_plist.getId(); - - herr_t ret_value = H5Dvlen_reclaim( type_id, space_id, xfer_plist_id, buf ); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); - } + // Obtain identifiers for C API + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); + hid_t xfer_plist_id = xfer_plist.getId(); + + herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); + if (ret_value < 0) + { + throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::vlenReclaim -///\brief Reclaims VL datatype memory buffers. -///\param type - IN: Datatype, which is the datatype stored in the buffer -///\param space - IN: Selection for the memory buffer to free the -/// VL datatypes within -///\param xfer_plist - IN: Property list used to create the buffer -///\param buf - IN: Pointer to the buffer to be reclaimed -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::vlenReclaim +///\brief Reclaims VL datatype memory buffers. +///\param type - IN: Datatype, which is the datatype stored in the buffer +///\param space - IN: Selection for the memory buffer to free the +/// VL datatypes within +///\param xfer_plist - IN: Property list used to create the buffer +///\param buf - IN: Pointer to the buffer to be reclaimed +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //\parDescription -// This function has better prototype for the users than the -// other, which might be removed at some point. BMR - 2006/12/20 +// This function has better prototype for the users than the +// other, which might be removed at some point. BMR - 2006/12/20 //-------------------------------------------------------------------------- void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist) { - // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); - hid_t xfer_plist_id = xfer_plist.getId(); - - herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { - throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); - } + // Obtain identifiers for C API + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); + hid_t xfer_plist_id = xfer_plist.getId(); + + herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); + if (ret_value < 0) + { + throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::read -///\brief Reads raw data from the specified dataset. -///\param buf - IN: Buffer for read data -///\param mem_type - IN: Memory datatype -///\param mem_space - IN: Memory dataspace -///\param file_space - IN: Dataset's dataspace in the file -///\param xfer_plist - IN: Transfer property list for this I/O operation -///\exception H5::DataSetIException +// Function: DataSet::read +///\brief Reads raw data from the specified dataset. +///\param buf - IN: Buffer for read data +///\param mem_type - IN: Memory datatype +///\param mem_space - IN: Memory dataspace +///\param file_space - IN: Dataset's dataspace in the file +///\param xfer_plist - IN: Transfer property list for this I/O operation +///\exception H5::DataSetIException ///\par Description -/// This function reads raw data from this dataset into the -/// buffer \a buf, converting from file datatype and dataspace -/// to memory datatype \a mem_type and dataspace \a mem_space. -// Programmer Binh-Minh Ribler - 2000 +/// This function reads raw data from this dataset into the +/// buffer \a buf, converting from file datatype and dataspace +/// to memory datatype \a mem_type and dataspace \a mem_space. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::read( void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist ) const +void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const { - // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); - hid_t file_space_id = file_space.getId(); - hid_t xfer_plist_id = xfer_plist.getId(); - - herr_t ret_value = H5Dread( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf ); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::read", "H5Dread failed"); - } + // Obtain identifiers for C API + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); + hid_t file_space_id = file_space.getId(); + hid_t xfer_plist_id = xfer_plist.getId(); + + herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); + if (ret_value < 0) + { + throw DataSetIException("DataSet::read", "H5Dread failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::read -///\brief This is an overloaded member function, provided for convenience. -/// It takes a reference to a \c H5std_string for the buffer. -///\param strg - IN: Buffer for read data string -///\param mem_type - IN: Memory datatype -///\param mem_space - IN: Memory dataspace -///\param file_space - IN: Dataset's dataspace in the file -///\param xfer_plist - IN: Transfer property list for this I/O operation -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::read +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the buffer. +///\param strg - IN: Buffer for read data string +///\param mem_type - IN: Memory datatype +///\param mem_space - IN: Memory dataspace +///\param file_space - IN: Dataset's dataspace in the file +///\param xfer_plist - IN: Transfer property list for this I/O operation +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Jul 2009 -// Follow the change to Attribute::read and use the following -// private functions to read datasets with fixed- and -// variable-length string: -// DataSet::p_read_fixed_len and -// DataSet::p_read_variable_len +// Jul 2009 +// Follow the change to Attribute::read and use the following +// private functions to read datasets with fixed- and +// variable-length string: +// DataSet::p_read_fixed_len and +// DataSet::p_read_variable_len //-------------------------------------------------------------------------- void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const { @@ -465,47 +465,47 @@ void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace } //-------------------------------------------------------------------------- -// Function: DataSet::write -///\brief Writes raw data from an application buffer to a dataset. -///\param buf - IN: Buffer containing data to be written -///\param mem_type - IN: Memory datatype -///\param mem_space - IN: Memory dataspace -///\param file_space - IN: Dataset's dataspace in the file -///\param xfer_plist - IN: Transfer property list for this I/O operation -///\exception H5::DataSetIException +// Function: DataSet::write +///\brief Writes raw data from an application buffer to a dataset. +///\param buf - IN: Buffer containing data to be written +///\param mem_type - IN: Memory datatype +///\param mem_space - IN: Memory dataspace +///\param file_space - IN: Dataset's dataspace in the file +///\param xfer_plist - IN: Transfer property list for this I/O operation +///\exception H5::DataSetIException ///\par Description -/// This function writes raw data from an application buffer -/// \a buf to a dataset, converting from memory datatype -/// \a mem_type and dataspace \a mem_space to file datatype -/// and dataspace. -// Programmer Binh-Minh Ribler - 2000 +/// This function writes raw data from an application buffer +/// \a buf to a dataset, converting from memory datatype +/// \a mem_type and dataspace \a mem_space to file datatype +/// and dataspace. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::write( const void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist ) const +void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const { - // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); - hid_t file_space_id = file_space.getId(); - hid_t xfer_plist_id = xfer_plist.getId(); - - herr_t ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf ); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::write", "H5Dwrite failed"); - } + // Obtain identifiers for C API + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); + hid_t file_space_id = file_space.getId(); + hid_t xfer_plist_id = xfer_plist.getId(); + + herr_t ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); + if (ret_value < 0) + { + throw DataSetIException("DataSet::write", "H5Dwrite failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::write -///\brief This is an overloaded member function, provided for convenience. -/// It takes a reference to a \c H5std_string for the buffer. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::write +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the buffer. +// Programmer Binh-Minh Ribler - 2000 // Modification -// Jul 2009 -// Modified to pass the buffer into H5Dwrite properly depending -// whether the dataset has variable- or fixed-length string. +// Jul 2009 +// Modified to pass the buffer into H5Dwrite properly depending +// whether the dataset has variable- or fixed-length string. //-------------------------------------------------------------------------- -void DataSet::write( const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist ) const +void DataSet::write(const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. @@ -515,11 +515,11 @@ void DataSet::write( const H5std_string& strg, const DataType& mem_type, const D throw DataSetIException("DataSet::write", "H5Tis_variable_str failed"); } - // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); - hid_t file_space_id = file_space.getId(); - hid_t xfer_plist_id = xfer_plist.getId(); + // Obtain identifiers for C API + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); + hid_t file_space_id = file_space.getId(); + hid_t xfer_plist_id = xfer_plist.getId(); // Convert string to C-string const char* strg_C; @@ -529,12 +529,12 @@ void DataSet::write( const H5std_string& strg, const DataType& mem_type, const D // Pass string in differently depends on variable or fixed length if (!is_variable_len) { - ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C ); + ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); } else { // passing string argument by address - ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C ); + ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); } if (ret_value < 0) { @@ -543,65 +543,65 @@ void DataSet::write( const H5std_string& strg, const DataType& mem_type, const D } //-------------------------------------------------------------------------- -// Function: DataSet::iterateElems -///\brief Iterates over all selected elements in a dataspace. -///\param buf - IN/OUT: Pointer to the buffer in memory containing the -/// elements to iterate over -///\param type - IN: Datatype for the elements stored in \a buf -///\param space - IN: Dataspace for \a buf. Also contains the selection -/// to iterate over. -///\param op - IN: Function pointer to the routine to be called for -/// each element in \a buf iterated over -///\param op_data - IN/OUT: Pointer to any user-defined data associated -/// with the operation -///\exception H5::DataSetIException -///\note This function may not work correctly yet - it's still -/// under development. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -int DataSet::iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data ) +// Function: DataSet::iterateElems +///\brief Iterates over all selected elements in a dataspace. +///\param buf - IN/OUT: Pointer to the buffer in memory containing the +/// elements to iterate over +///\param type - IN: Datatype for the elements stored in \a buf +///\param space - IN: Dataspace for \a buf. Also contains the selection +/// to iterate over. +///\param op - IN: Function pointer to the routine to be called for +/// each element in \a buf iterated over +///\param op_data - IN/OUT: Pointer to any user-defined data associated +/// with the operation +///\exception H5::DataSetIException +///\note This function may not work correctly yet - it's still +/// under development. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data) { - // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Diterate( buf, type_id, space_id, op, op_data ); - if( ret_value >= 0 ) - return( ret_value ); - else // raise exception when H5Diterate returns a negative value - { - throw DataSetIException("DataSet::iterateElems", "H5Diterate failed"); - } + // Obtain identifiers for C API + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Diterate(buf, type_id, space_id, op, op_data); + if (ret_value >= 0) + return(ret_value); + else // raise exception when H5Diterate returns a negative value + { + throw DataSetIException("DataSet::iterateElems", "H5Diterate failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSet::extend -///\brief Extends a dataset with unlimited dimension. -///\param size - IN: Array containing the new magnitude of each dimension -///\exception H5::DataSetIException +// Function: DataSet::extend +///\brief Extends a dataset with unlimited dimension. +///\param size - IN: Array containing the new magnitude of each dimension +///\exception H5::DataSetIException ///\par Description -/// For more information, please see the Description section in -/// C layer Reference Manual at: +/// For more information, please see the Description section in +/// C layer Reference Manual at: ///\par /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5D.html#Dataset-Extend -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::extend( const hsize_t* size ) const +void DataSet::extend(const hsize_t* size) const { - herr_t ret_value = H5Dset_extent( id, size ); - if( ret_value < 0 ) // raise exception when H5Dset_extent returns a neg value - throw DataSetIException("DataSet::extend", "H5Dset_extent failed"); + herr_t ret_value = H5Dset_extent(id, size); + if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value + throw DataSetIException("DataSet::extend", "H5Dset_extent failed"); } //-------------------------------------------------------------------------- -// Function: DataSet::fillMemBuf -///\brief Fills a selection in memory with a value. -///\param fill - IN: Pointer to fill value to use - default NULL -///\param fill_type - IN: Datatype of the fill value -///\param buf - IN/OUT: Memory buffer to fill selection within -///\param buf_type - IN: Datatype of the elements in buffer -///\param space - IN: Dataspace describing memory buffer & containing selection to use -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2014 +// Function: DataSet::fillMemBuf +///\brief Fills a selection in memory with a value. +///\param fill - IN: Pointer to fill value to use - default NULL +///\param fill_type - IN: Datatype of the fill value +///\param buf - IN/OUT: Memory buffer to fill selection within +///\param buf_type - IN: Datatype of the elements in buffer +///\param space - IN: Dataspace describing memory buffer & containing selection to use +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2014 // Modification //-------------------------------------------------------------------------- void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const @@ -610,28 +610,28 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, hid_t buf_type_id = buf_type.getId(); hid_t space_id = space.getId(); herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); - if( ret_value < 0 ) + if (ret_value < 0) { - throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); + throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } //-------------------------------------------------------------------------- -// Function: DataSet::fillMemBuf -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param fill - IN: Pointer to fill value to use - default NULL -// Param fill_type - IN: Datatype of the fill value -// Param buf - IN/OUT: Memory buffer to fill selection within -// Param buf_type - IN: Datatype of the elements in buffer -// Param space - IN: Dataspace describing memory buffer & containing selection to use -// Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::fillMemBuf +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Param fill - IN: Pointer to fill value to use - default NULL +// Param fill_type - IN: Datatype of the fill value +// Param buf - IN/OUT: Memory buffer to fill selection within +// Param buf_type - IN: Datatype of the elements in buffer +// Param space - IN: Dataspace describing memory buffer & containing selection to use +// Exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space) //{ @@ -639,39 +639,39 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, //} //-------------------------------------------------------------------------- -// Function: DataSet::fillMemBuf -///\brief Fills a selection in memory with 0. -///\param buf - IN/OUT: Memory buffer to fill selection within -///\param buf_type - IN: Datatype of the elements in buffer -///\param space - IN: Dataspace describing memory buffer & containing selection to use -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::fillMemBuf +///\brief Fills a selection in memory with 0. +///\param buf - IN/OUT: Memory buffer to fill selection within +///\param buf_type - IN: Datatype of the elements in buffer +///\param space - IN: Dataspace describing memory buffer & containing selection to use +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const { hid_t buf_type_id = buf_type.getId(); hid_t space_id = space.getId(); herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); - if( ret_value < 0 ) + if (ret_value < 0) { - throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); + throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } //-------------------------------------------------------------------------- // Function: DataSet::fillMemBuf -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. // Param buf - IN/OUT: Memory buffer to fill selection within // Param buf_type - IN: Datatype of the elements in buffer // Param space - IN: Dataspace describing memory buffer & containing selection to use -// Exception H5::DataSetIException +// Exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) //{ @@ -680,8 +680,8 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s //-------------------------------------------------------------------------- // Function: DataSet::getId -///\brief Get the id of this dataset. -///\return DataSet identifier +///\brief Get the id of this dataset. +///\return DataSet identifier // Description: // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDs and Attribute are moved out of H5Object. In @@ -691,19 +691,19 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s //-------------------------------------------------------------------------- hid_t DataSet::getId() const { - return(id); + return(id); } //-------------------------------------------------------------------------- -// Function: DataSet::p_read_fixed_len (private) -// brief Reads a fixed length \a H5std_string from a dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// Function: DataSet::p_read_fixed_len (private) +// brief Reads a fixed length \a H5std_string from a dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::DataSetIException +// Programmer Binh-Minh Ribler - Jul, 2009 // Modification -// Jul 2009 -// Added in follow to the change in Attribute::read +// Jul 2009 +// Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const { @@ -715,33 +715,33 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id // If there is data, allocate buffer and read it. if (data_size > 0) { - char *strg_C = new char [data_size+1]; - HDmemset(strg_C, 0, data_size+1); // clear buffer + char *strg_C = new char [data_size+1]; + HDmemset(strg_C, 0, data_size+1); // clear buffer - herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); + herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); - if( ret_value < 0 ) - { - delete []strg_C; // de-allocate for fixed-len string - throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string"); - } + if (ret_value < 0) + { + delete []strg_C; // de-allocate for fixed-len string + throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string"); + } - // Get string from the C char* and release resource allocated locally - strg = strg_C; - delete []strg_C; + // Get string from the C char* and release resource allocated locally + strg = strg_C; + delete []strg_C; } } //-------------------------------------------------------------------------- -// Function: DataSet::p_read_variable_len (private) -// brief Reads a variable length \a H5std_string from an dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// Function: DataSet::p_read_variable_len (private) +// brief Reads a variable length \a H5std_string from an dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::DataSetIException +// Programmer Binh-Minh Ribler - Jul, 2009 // Modification -// Jul 2009 -// Added in follow to the change in Attribute::read +// Jul 2009 +// Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const { @@ -751,9 +751,9 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // Read dataset, no allocation for variable-len string; C library will herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); - if( ret_value < 0 ) + if (ret_value < 0) { - throw DataSetIException("DataSet::read", "H5Dread failed for variable length string"); + throw DataSetIException("DataSet::read", "H5Dread failed for variable length string"); } // Get string from the C char* and release resource allocated by C API @@ -805,43 +805,43 @@ void f_PropList_setId(PropList* plist, hid_t new_id) #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSet::close -///\brief Closes this dataset. +// Function: DataSet::close +///\brief Closes this dataset. /// -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void DataSet::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Dclose( id ); - if( ret_value < 0 ) - { - throw DataSetIException("DataSet::close", "H5Dclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Dclose(id); + if (ret_value < 0) + { + throw DataSetIException("DataSet::close", "H5Dclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } //-------------------------------------------------------------------------- -// Function: DataSet destructor -///\brief Properly terminates access to this dataset. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet destructor +///\brief Properly terminates access to this dataset. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- DataSet::~DataSet() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; + cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index ee9ef28..93f9782 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -31,82 +31,82 @@ namespace H5 { class H5_DLLCPP DataSet : public H5Object, public AbstractDs { public: - // Close this dataset. - virtual void close(); + // Close this dataset. + virtual void close(); - // Extends the dataset with unlimited dimension. - void extend( const hsize_t* size ) const; + // Extends the dataset with unlimited dimension. + void extend(const hsize_t* size) const; - // Fills a selection in memory with a value - void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 + // Fills a selection in memory with a value + void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; + //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - // Fills a selection in memory with zero - void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 + // Fills a selection in memory with zero + void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; + //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - // Gets the creation property list of this dataset. - DSetCreatPropList getCreatePlist() const; + // Gets the creation property list of this dataset. + DSetCreatPropList getCreatePlist() const; - // Returns the address of this dataset in the file. - haddr_t getOffset() const; + // Returns the address of this dataset in the file. + haddr_t getOffset() const; - // Gets the dataspace of this dataset. - virtual DataSpace getSpace() const; + // Gets the dataspace of this dataset. + virtual DataSpace getSpace() const; - // Determines whether space has been allocated for a dataset. - void getSpaceStatus(H5D_space_status_t& status) const; + // Determines whether space has been allocated for a dataset. + void getSpaceStatus(H5D_space_status_t& status) const; - // Returns the amount of storage size required for this dataset. - virtual hsize_t getStorageSize() const; + // Returns the amount of storage size required for this dataset. + virtual hsize_t getStorageSize() const; - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; - // Returns the number of bytes required to store VL data. - hsize_t getVlenBufSize(const DataType& type, const DataSpace& space ) const; - //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 + // Returns the number of bytes required to store VL data. + hsize_t getVlenBufSize(const DataType& type, const DataSpace& space) const; + //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 - // Reclaims VL datatype memory buffers. - static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf ); - static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT); + // Reclaims VL datatype memory buffers. + static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf); + static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT); - // Reads the data of this dataset and stores it in the provided buffer. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void read( void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT ) const; - void read( H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT ) const; + // Reads the data of this dataset and stores it in the provided buffer. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void read(void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; + void read(H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - // Writes the buffered data to this dataset. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void write( const void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT ) const; - void write( const H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT ) const; + // Writes the buffered data to this dataset. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void write(const void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; + void write(const H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet - int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL ); + // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet + int iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSet"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DataSet"); } - // Creates a dataset by way of dereference. - DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a dataset by way of dereference. + DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Default constructor. - DataSet(); + // Default constructor. + DataSet(); - // Copy constructor. - DataSet( const DataSet& original ); + // Copy constructor. + DataSet(const DataSet& original); - // Creates a copy of an existing DataSet using its id. - DataSet(const hid_t existing_id); + // Creates a copy of an existing DataSet using its id. + DataSet(const hid_t existing_id); // Gets the dataset id. virtual hid_t getId() const; - // Destructor: properly terminates access to this dataset. - virtual ~DataSet(); + // Destructor: properly terminates access to this dataset. + virtual ~DataSet(); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -115,20 +115,20 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { #endif // DOXYGEN_SHOULD_SKIP_THIS private: - hid_t id; // HDF5 dataset id + hid_t id; // HDF5 dataset id // This function contains the common code that is used by // getTypeClass and various API functions getXxxType // defined in AbstractDs for generic datatype and specific // sub-types - virtual hid_t p_get_type() const; + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this dataset. - void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; - void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; + // Reads variable or fixed len strings from this dataset. + void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; + void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; - // Friend function to set DataSet id. For library use only. - friend void f_DataSet_setId(DataSet* dset, hid_t new_id); + // Friend function to set DataSet id. For library use only. + friend void f_DataSet_setId(DataSet* dset, hid_t new_id); }; } diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index cb479e1..2587a72 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -38,14 +38,14 @@ using std::endl; DataSpace* DataSpace::ALL_ = 0; //-------------------------------------------------------------------------- -// Function: DataSpace::getConstant -// Creates a DataSpace object representing the HDF5 constant -// H5S_ALL, pointed to by DataSpace::ALL_ -// Exception H5::DataSpaceIException +// Function: DataSpace::getConstant +// Creates a DataSpace object representing the HDF5 constant +// H5S_ALL, pointed to by DataSpace::ALL_ +// Exception H5::DataSpaceIException // Description -// If DataSpace::ALL_ already points to an allocated object, throw -// a DataSpaceIException. This scenario should not happen. -// Programmer Binh-Minh Ribler - 2015 +// If DataSpace::ALL_ already points to an allocated object, throw +// a DataSpaceIException. This scenario should not happen. +// Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- DataSpace* DataSpace::getConstant() { @@ -78,55 +78,55 @@ void DataSpace::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose Constant for default dataspace. +// Purpose Constant for default dataspace. //-------------------------------------------------------------------------- const DataSpace& DataSpace::ALL = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSpace constructor -///\brief Creates a new dataspace given a dataspace type. -///\param type - IN: Type of the dataspace to be created, which -/// currently can be either \c H5S_SCALAR or \c H5S_SIMPLE; -/// default to \c H5S_SCALAR. -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace constructor +///\brief Creates a new dataspace given a dataspace type. +///\param type - IN: Type of the dataspace to be created, which +/// currently can be either \c H5S_SCALAR or \c H5S_SIMPLE; +/// default to \c H5S_SCALAR. +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSpace::DataSpace(H5S_class_t type) : IdComponent() { - id = H5Screate( type ); - if( id < 0 ) - { - throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); - } + id = H5Screate(type); + if (id < 0) + { + throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace overloaded constructor -///\brief Creates a new simple dataspace. -///\param rank - IN: Number of dimensions of dataspace. -///\param dims - IN: An array of the size of each dimension. -///\param maxdims - IN: An array of the maximum size of each dimension. -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace overloaded constructor +///\brief Creates a new simple dataspace. +///\param rank - IN: Number of dimensions of dataspace. +///\param dims - IN: An array of the size of each dimension. +///\param maxdims - IN: An array of the maximum size of each dimension. +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent() { - id = H5Screate_simple( rank, dims, maxdims ); - if( id < 0 ) - { - throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); - } + id = H5Screate_simple(rank, dims, maxdims); + if (id < 0) + { + throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace overloaded constructor -///\brief Creates a DataSpace object using the id of an existing -/// dataspace. -///\param existing_id - IN: Id of an existing dataspace -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace overloaded constructor +///\brief Creates a DataSpace object using the id of an existing +/// dataspace. +///\param existing_id - IN: Id of an existing dataspace +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id) { @@ -134,10 +134,10 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id) } //-------------------------------------------------------------------------- -// Function: DataSpace copy constructor -///\brief Copy constructor: makes a copy of the original DataSpace object. -///\param original - IN: DataSpace object to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace copy constructor +///\brief Copy constructor: makes a copy of the original DataSpace object. +///\param original - IN: DataSpace object to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) { @@ -145,48 +145,48 @@ DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) } //-------------------------------------------------------------------------- -// Function: DataSpace::copy -///\brief Makes a copy of an existing dataspace. -///\param like_space - IN: Dataspace to be copied -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::copy +///\brief Makes a copy of an existing dataspace. +///\param like_space - IN: Dataspace to be copied +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 -//-------------------------------------------------------------------------- -void DataSpace::copy( const DataSpace& like_space ) -{ - // If this object has an hdf5 valid id, close it - if( id != H5S_ALL ) { - try { - close(); - } - catch (Exception& close_error) { +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 +//-------------------------------------------------------------------------- +void DataSpace::copy(const DataSpace& like_space) +{ + // If this object has an hdf5 valid id, close it + if (id != H5S_ALL) { + try { + close(); + } + catch (Exception& close_error) { throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); - } - } // end if + } + } // end if - // call C routine to copy the dataspace - id = H5Scopy( like_space.getId() ); + // call C routine to copy the dataspace + id = H5Scopy(like_space.getId()); - if( id < 0 ) - throw DataSpaceIException("DataSpace::copy", "H5Scopy failed"); + if (id < 0) + throw DataSpaceIException("DataSpace::copy", "H5Scopy failed"); } //-------------------------------------------------------------------------- -// Function: DataSpace::operator= -///\brief Assignment operator. -///\param rhs - IN: Reference to the existing dataspace -///\return Reference to DataSpace instance -///\exception H5::DataSpaceIException +// Function: DataSpace::operator= +///\brief Assignment operator. +///\param rhs - IN: Reference to the existing dataspace +///\return Reference to DataSpace instance +///\exception H5::DataSpaceIException // Description -// Makes a copy of the type on the right hand side and stores -// the new id in the left hand side object. -// Programmer Binh-Minh Ribler - 2000 +// Makes a copy of the type on the right hand side and stores +// the new id in the left hand side object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace& DataSpace::operator=( const DataSpace& rhs ) +DataSpace& DataSpace::operator=(const DataSpace& rhs) { if (this != &rhs) copy(rhs); @@ -194,435 +194,434 @@ DataSpace& DataSpace::operator=( const DataSpace& rhs ) } //-------------------------------------------------------------------------- -// Function: DataSpace::isSimple -///\brief Determines whether this dataspace is a simple dataspace. -///\return \c true if the dataspace is a simple dataspace, and \c false, -/// otherwise -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::isSimple +///\brief Determines whether this dataspace is a simple dataspace. +///\return \c true if the dataspace is a simple dataspace, and \c false, +/// otherwise +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool DataSpace::isSimple () const { - htri_t simple = H5Sis_simple( id ); - if( simple > 0 ) - return true; - else if( simple == 0 ) - return false; - else - { - throw DataSpaceIException("DataSpace::isSimple", - "H5Sis_simple returns negative value"); - } + htri_t simple = H5Sis_simple(id); + if (simple > 0) + return true; + else if (simple == 0) + return false; + else + { + throw DataSpaceIException("DataSpace::isSimple", + "H5Sis_simple returns negative value"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::offsetSimple -///\brief Sets the offset of this simple dataspace. -///\param offset - IN: Offset to position the selection at -///\exception H5::DataSpaceIException +// Function: DataSpace::offsetSimple +///\brief Sets the offset of this simple dataspace. +///\param offset - IN: Offset to position the selection at +///\exception H5::DataSpaceIException ///\par Description -/// This function creates an offset for the selection within -/// an extent, allowing the same shaped selection to be moved -/// to different locations within a dataspace without requiring -/// it to be re-defined. -// Programmer Binh-Minh Ribler - 2000 +/// This function creates an offset for the selection within +/// an extent, allowing the same shaped selection to be moved +/// to different locations within a dataspace without requiring +/// it to be re-defined. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::offsetSimple ( const hssize_t* offset ) const +void DataSpace::offsetSimple (const hssize_t* offset) const { - herr_t ret_value = H5Soffset_simple( id, offset ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed"); - } + herr_t ret_value = H5Soffset_simple(id, offset); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::getSimpleExtentDims -///\brief Retrieves dataspace dimension size and maximum size. -///\param dims - IN: Name of the new member -///\param maxdims - IN: Pointer to the value of the new member -///\return Number of dimensions, the same value as returned by -/// \c DataSpace::getSimpleExtentNdims() -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSimpleExtentDims +///\brief Retrieves dataspace dimension size and maximum size. +///\param dims - IN: Name of the new member +///\param maxdims - IN: Pointer to the value of the new member +///\return Number of dimensions, the same value as returned by +/// \c DataSpace::getSimpleExtentNdims() +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentDims ( hsize_t *dims, hsize_t *maxdims ) const +int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const { - int ndims = H5Sget_simple_extent_dims( id, dims, maxdims ); - if( ndims < 0 ) - { - throw DataSpaceIException("DataSpace::getSimpleExtentDims", - "H5Sget_simple_extent_dims returns negative number of dimensions"); - } - return( ndims ); + int ndims = H5Sget_simple_extent_dims(id, dims, maxdims); + if (ndims < 0) + { + throw DataSpaceIException("DataSpace::getSimpleExtentDims", + "H5Sget_simple_extent_dims returns negative number of dimensions"); + } + return(ndims); } //-------------------------------------------------------------------------- -// Function: DataSpace::getSimpleExtentNdims -///\brief Returns the dimensionality of a dataspace. -///\return Number of dimensions -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSimpleExtentNdims +///\brief Returns the dimensionality of a dataspace. +///\return Number of dimensions +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int DataSpace::getSimpleExtentNdims () const { - int ndims = H5Sget_simple_extent_ndims( id ); - if( ndims < 0 ) - { - throw DataSpaceIException("DataSpace::getSimpleExtentNdims", - "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace"); - } - return( ndims ); + int ndims = H5Sget_simple_extent_ndims(id); + if (ndims < 0) + { + throw DataSpaceIException("DataSpace::getSimpleExtentNdims", + "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace"); + } + return(ndims); } //-------------------------------------------------------------------------- -// Function: DataSpace::getSimpleExtentNpoints -///\brief Returns the number of elements in a dataspace. -///\return Number of elements -///\exception H5::DataSpaceIException +// Function: DataSpace::getSimpleExtentNpoints +///\brief Returns the number of elements in a dataspace. +///\return Number of elements +///\exception H5::DataSpaceIException // Modification -// 12/05/00: due to C API change -// return type hssize_t vs. hsize_t -// num_elements = -1 when failure occurs vs. 0 -// Programmer Binh-Minh Ribler - 2000 +// 12/05/00: due to C API change +// return type hssize_t vs. hsize_t +// num_elements = -1 when failure occurs vs. 0 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hssize_t DataSpace::getSimpleExtentNpoints () const { - hssize_t num_elements = H5Sget_simple_extent_npoints( id ); - - if( num_elements > -1 ) - return( num_elements ); - else - { - throw DataSpaceIException("DataSpace::getSimpleExtentNpoints", - "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace"); - } + hssize_t num_elements = H5Sget_simple_extent_npoints(id); + if (num_elements > -1) + return(num_elements); + else + { + throw DataSpaceIException("DataSpace::getSimpleExtentNpoints", + "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::getSimpleExtentType -///\brief Returns the current class of a dataspace. -///\return Class of the dataspace -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSimpleExtentType +///\brief Returns the current class of a dataspace. +///\return Class of the dataspace +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5S_class_t DataSpace::getSimpleExtentType () const { - H5S_class_t class_name = H5Sget_simple_extent_type( id ); - if( class_name == H5S_NO_CLASS ) - { - throw DataSpaceIException("DataSpace::getSimpleExtentType", - "H5Sget_simple_extent_type returns H5S_NO_CLASS"); - } - return( class_name ); + H5S_class_t class_name = H5Sget_simple_extent_type(id); + if (class_name == H5S_NO_CLASS) + { + throw DataSpaceIException("DataSpace::getSimpleExtentType", + "H5Sget_simple_extent_type returns H5S_NO_CLASS"); + } + return(class_name); } //-------------------------------------------------------------------------- -// Function: DataSpace::extentCopy -///\brief Copies the extent of a dataspace. -///\param dest_space - IN: Dataspace to copy from -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::extentCopy +///\brief Copies the extent of a dataspace. +///\param dest_space - IN: Dataspace to copy from +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSpace::extentCopy (const DataSpace& dest_space) const { - hid_t dest_space_id = dest_space.getId(); - herr_t ret_value = H5Sextent_copy( dest_space_id, id ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed"); - } + hid_t dest_space_id = dest_space.getId(); + herr_t ret_value = H5Sextent_copy(dest_space_id, id); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::extentCopy -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const. This wrapper will be removed in future release. -// Param dest_space - IN: Dataspace to copy from -// Exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::extentCopy +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const. This wrapper will be removed in future release. +// Param dest_space - IN: Dataspace to copy from +// Exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSpace::extentCopy( DataSpace& dest_space ) const +//void DataSpace::extentCopy(DataSpace& dest_space) const //{ // extentCopy(dest_space); //} //-------------------------------------------------------------------------- -// Function: DataSpace::setExtentSimple -///\brief Sets or resets the size of an existing dataspace. -///\param rank - IN: Rank of the dataspace -///\param current_size - IN: Array containing current size of dataspace -///\param maximum_size - IN: Array containing maximum size of dataspace -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::setExtentSimple +///\brief Sets or resets the size of an existing dataspace. +///\param rank - IN: Rank of the dataspace +///\param current_size - IN: Array containing current size of dataspace +///\param maximum_size - IN: Array containing maximum size of dataspace +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentSimple( int rank, const hsize_t *current_size, const hsize_t *maximum_size ) const +void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const { - herr_t ret_value; - ret_value = H5Sset_extent_simple( id, rank, current_size, maximum_size ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed"); - } + herr_t ret_value; + ret_value = H5Sset_extent_simple(id, rank, current_size, maximum_size); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::setExtentNone -///\brief Removes the extent from a dataspace. +// Function: DataSpace::setExtentNone +///\brief Removes the extent from a dataspace. /// -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSpace::setExtentNone () const { - herr_t ret_value = H5Sset_extent_none( id ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed"); - } + herr_t ret_value = H5Sset_extent_none(id); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectNpoints -///\brief Returns the number of elements in a dataspace selection. -///\return Number of elements -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSelectNpoints +///\brief Returns the number of elements in a dataspace selection. +///\return Number of elements +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hssize_t DataSpace::getSelectNpoints () const { - hssize_t num_elements = H5Sget_select_npoints( id ); - if( num_elements < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectNpoints", - "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection"); - } - return( num_elements ); + hssize_t num_elements = H5Sget_select_npoints(id); + if (num_elements < 0) + { + throw DataSpaceIException("DataSpace::getSelectNpoints", + "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection"); + } + return(num_elements); } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectHyperNblocks -///\brief Returns number of hyperslab blocks. -///\return Number of hyperslab blocks -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSelectHyperNblocks +///\brief Returns number of hyperslab blocks. +///\return Number of hyperslab blocks +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hssize_t DataSpace::getSelectHyperNblocks () const { - hssize_t num_blocks = H5Sget_select_hyper_nblocks( id ); - if( num_blocks < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectHyperNblocks", - "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks"); - } - return( num_blocks ); + hssize_t num_blocks = H5Sget_select_hyper_nblocks(id); + if (num_blocks < 0) + { + throw DataSpaceIException("DataSpace::getSelectHyperNblocks", + "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks"); + } + return(num_blocks); } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectHyperBlocklist -///\brief Gets the list of hyperslab blocks currently selected -///\param startblock - IN: Hyperslab block to start with -///\param numblocks - IN: Number of hyperslab blocks to get -///\param buf - IN: List of hyperslab blocks selected -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSelectHyperBlocklist +///\brief Gets the list of hyperslab blocks currently selected +///\param startblock - IN: Hyperslab block to start with +///\param numblocks - IN: Number of hyperslab blocks to get +///\param buf - IN: List of hyperslab blocks selected +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectHyperBlocklist( hsize_t startblock, hsize_t numblocks, hsize_t *buf ) const +void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const { - herr_t ret_value; - ret_value = H5Sget_select_hyper_blocklist( id, startblock, numblocks, buf ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectHyperBlocklist", - "H5Sget_select_hyper_blocklist failed"); - } + herr_t ret_value; + ret_value = H5Sget_select_hyper_blocklist(id, startblock, numblocks, buf); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::getSelectHyperBlocklist", + "H5Sget_select_hyper_blocklist failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectElemNpoints -///\brief Returns the number of element points in the current selection. -///\return Number of element points -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::getSelectElemNpoints +///\brief Returns the number of element points in the current selection. +///\return Number of element points +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hssize_t DataSpace::getSelectElemNpoints () const { - hssize_t num_points = H5Sget_select_elem_npoints( id ); - if( num_points < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectElemNpoints", - "H5Sget_select_elem_npoints failed"); - } - return( num_points ); + hssize_t num_points = H5Sget_select_elem_npoints(id); + if (num_points < 0) + { + throw DataSpaceIException("DataSpace::getSelectElemNpoints", + "H5Sget_select_elem_npoints failed"); + } + return(num_points); } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectElemPointlist -///\brief Gets the list of element points currently selected -///\param startpoint - IN: Element point to start with -///\param numpoints - IN: Number of element points to get -///\param buf - IN: List of element points selected -///\exception H5::DataSpaceIException +// Function: DataSpace::getSelectElemPointlist +///\brief Gets the list of element points currently selected +///\param startpoint - IN: Element point to start with +///\param numpoints - IN: Number of element points to get +///\param buf - IN: List of element points selected +///\exception H5::DataSpaceIException ///\par Description -/// For more information, please refer to the C layer Reference -/// Manual at: +/// For more information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectElemPointList -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectElemPointlist ( hsize_t startpoint, hsize_t numpoints, hsize_t *buf ) const +void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const { - herr_t ret_value; - ret_value = H5Sget_select_elem_pointlist( id, startpoint, numpoints, buf ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectElemPointlist", - "H5Sget_select_elem_pointlist failed"); - } + herr_t ret_value; + ret_value = H5Sget_select_elem_pointlist(id, startpoint, numpoints, buf); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::getSelectElemPointlist", + "H5Sget_select_elem_pointlist failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::getSelectBounds -///\brief Gets the bounding box containing the current selection. -///\param start - IN: Starting coordinates of the bounding box -///\param end - IN: Ending coordinates of the bounding box, i.e., -/// the coordinates of the diagonally opposite corner -///\exception H5::DataSpaceIException +// Function: DataSpace::getSelectBounds +///\brief Gets the bounding box containing the current selection. +///\param start - IN: Starting coordinates of the bounding box +///\param end - IN: Ending coordinates of the bounding box, i.e., +/// the coordinates of the diagonally opposite corner +///\exception H5::DataSpaceIException ///\par Description -/// For more information, please refer to the C layer Reference -/// Manual at: +/// For more information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectBounds -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectBounds ( hsize_t* start, hsize_t* end ) const +void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const { - herr_t ret_value = H5Sget_select_bounds( id, start, end ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::getSelectBounds", - "H5Sget_select_bounds failed"); - } + herr_t ret_value = H5Sget_select_bounds(id, start, end); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::getSelectBounds", + "H5Sget_select_bounds failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::selectElements -///\brief Selects array elements to be included in the selection for -/// this dataspace. -///\param op - IN: Operator specifying how the new selection is to be -/// combined with the existing selection for the dataspace -///\param num_elements - IN: Number of elements to be selected -///\param coord - IN: A 2-dimensional array of 0-based values -/// specifying the coordinates of the elements being selected -///\exception H5::DataSpaceIException +// Function: DataSpace::selectElements +///\brief Selects array elements to be included in the selection for +/// this dataspace. +///\param op - IN: Operator specifying how the new selection is to be +/// combined with the existing selection for the dataspace +///\param num_elements - IN: Number of elements to be selected +///\param coord - IN: A 2-dimensional array of 0-based values +/// specifying the coordinates of the elements being selected +///\exception H5::DataSpaceIException ///\par Description -/// For more information, please refer to the C layer Reference -/// Manual at: +/// For more information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectElements -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectElements ( H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const +void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const { - herr_t ret_value; - ret_value = H5Sselect_elements( id, op, num_elements, coord ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::selectElements", - "H5Sselect_elements failed"); - } + herr_t ret_value; + ret_value = H5Sselect_elements(id, op, num_elements, coord); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::selectElements", + "H5Sselect_elements failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::selectAll -///\brief Selects the entire dataspace. +// Function: DataSpace::selectAll +///\brief Selects the entire dataspace. /// -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSpace::selectAll () const { - herr_t ret_value = H5Sselect_all( id ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed"); - } + herr_t ret_value = H5Sselect_all(id); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::selectNone -///\brief Resets the selection region to include no elements. +// Function: DataSpace::selectNone +///\brief Resets the selection region to include no elements. /// -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataSpace::selectNone () const { - herr_t ret_value = H5Sselect_none( id ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::selectNone", - "H5Sselect_none failed"); - } + herr_t ret_value = H5Sselect_none(id); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::selectNone", + "H5Sselect_none failed"); + } } //-------------------------------------------------------------------------- -// Function: DataSpace::selectValid -///\brief Verifies that the selection is within the extent of the -/// dataspace. -///\return \c true if the selection is within the extent of the -/// dataspace, and \c false, otherwise -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::selectValid +///\brief Verifies that the selection is within the extent of the +/// dataspace. +///\return \c true if the selection is within the extent of the +/// dataspace, and \c false, otherwise +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool DataSpace::selectValid () const { - htri_t ret_value = H5Sselect_valid( id ); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw DataSpaceIException("DataSpace::selectValid", - "H5Sselect_valid returns negative value"); - } -} - -//-------------------------------------------------------------------------- -// Function: DataSpace::selectHyperslab -///\brief Selects a hyperslab region to add to the current selected region. -///\param op - IN: Operation to perform on current selection -///\param count - IN: Number of blocks included in the hyperslab -///\param start - IN: Offset of the start of hyperslab -///\param stride - IN: Hyperslab stride - default to \c NULL -///\param block - IN: Size of block in the hyperslab - default to \c NULL -///\exception H5::DataSpaceIException + htri_t ret_value = H5Sselect_valid(id); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else + { + throw DataSpaceIException("DataSpace::selectValid", + "H5Sselect_valid returns negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataSpace::selectHyperslab +///\brief Selects a hyperslab region to add to the current selected region. +///\param op - IN: Operation to perform on current selection +///\param count - IN: Number of blocks included in the hyperslab +///\param start - IN: Offset of the start of hyperslab +///\param stride - IN: Hyperslab stride - default to \c NULL +///\param block - IN: Size of block in the hyperslab - default to \c NULL +///\exception H5::DataSpaceIException ///\par Description -/// For more information, please refer to the C layer Reference -/// Manual at: +/// For more information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html#Dataspace-SelectHyperslab -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride, const hsize_t *block ) const +void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride, const hsize_t *block) const { - herr_t ret_value; - ret_value = H5Sselect_hyperslab( id, op, start, stride, count, block ); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::selectHyperslab", - "H5Sselect_hyperslab failed"); - } + herr_t ret_value; + ret_value = H5Sselect_hyperslab(id, op, start, stride, count, block); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::selectHyperslab", + "H5Sselect_hyperslab failed"); + } } //-------------------------------------------------------------------------- // Function: DataSpace::getId -///\brief Get the id of this dataspace -///\return Dataspace identifier +///\brief Get the id of this dataspace +///\return Dataspace identifier // Modification: -// May 2008 - BMR +// May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDS and Attribute are moved out of H5Object. In // addition, member IdComponent::id is moved into subclasses, and @@ -631,7 +630,7 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h //-------------------------------------------------------------------------- hid_t DataSpace::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -656,49 +655,49 @@ void DataSpace::p_setId(const hid_t new_id) catch (Exception& close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSpace::close -///\brief Closes this dataspace. +// Function: DataSpace::close +///\brief Closes this dataspace. /// -///\exception H5::DataSpaceIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void DataSpace::close() { // check if id is a valid hdf5 object id before trying to close it if (p_valid_id(id)) { - herr_t ret_value = H5Sclose(id); - if( ret_value < 0 ) - { - throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Sclose(id); + if (ret_value < 0) + { + throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } //-------------------------------------------------------------------------- -// Function: DataSpace destructor -///\brief Properly terminates access to this dataspace. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace destructor +///\brief Properly terminates access to this dataspace. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- DataSpace::~DataSpace() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; + cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index e76bc72..969e146 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -27,126 +27,126 @@ namespace H5 { */ class H5_DLLCPP DataSpace : public IdComponent { public: - ///\brief Default DataSpace objects - static const DataSpace& ALL; + ///\brief Default DataSpace objects + static const DataSpace& ALL; - // Creates a dataspace object given the space type - DataSpace(H5S_class_t type = H5S_SCALAR); + // Creates a dataspace object given the space type + DataSpace(H5S_class_t type = H5S_SCALAR); - // Creates a simple dataspace - DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); + // Creates a simple dataspace + DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); - // Creates a DataSpace object using an existing dataspace id. - DataSpace(const hid_t space_id); + // Creates a DataSpace object using an existing dataspace id. + DataSpace(const hid_t space_id); - // Copy constructor: makes a copy of the original DataSpace object. - DataSpace(const DataSpace& original); + // Copy constructor: makes a copy of the original DataSpace object. + DataSpace(const DataSpace& original); - // Assignment operator - DataSpace& operator=( const DataSpace& rhs ); + // Assignment operator + DataSpace& operator=(const DataSpace& rhs); - // Closes this dataspace. - virtual void close(); + // Closes this dataspace. + virtual void close(); - // Makes copy of an existing dataspace. - void copy(const DataSpace& like_space); + // Makes copy of an existing dataspace. + void copy(const DataSpace& like_space); - // Copies the extent of this dataspace. - void extentCopy(const DataSpace& dest_space) const; - // removed from 1.8.18 and 1.10.1 - //void extentCopy(DataSpace& dest_space) const; + // Copies the extent of this dataspace. + void extentCopy(const DataSpace& dest_space) const; + // removed from 1.8.18 and 1.10.1 + //void extentCopy(DataSpace& dest_space) const; - // Gets the bounding box containing the current selection. - void getSelectBounds( hsize_t* start, hsize_t* end ) const; + // Gets the bounding box containing the current selection. + void getSelectBounds(hsize_t* start, hsize_t* end) const; - // Gets the number of element points in the current selection. - hssize_t getSelectElemNpoints() const; + // Gets the number of element points in the current selection. + hssize_t getSelectElemNpoints() const; - // Retrieves the list of element points currently selected. - void getSelectElemPointlist( hsize_t startpoint, hsize_t numpoints, hsize_t *buf ) const; + // Retrieves the list of element points currently selected. + void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; - // Gets the list of hyperslab blocks currently selected. - void getSelectHyperBlocklist( hsize_t startblock, hsize_t numblocks, hsize_t *buf ) const; + // Gets the list of hyperslab blocks currently selected. + void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; - // Get number of hyperslab blocks. - hssize_t getSelectHyperNblocks() const; + // Get number of hyperslab blocks. + hssize_t getSelectHyperNblocks() const; - // Gets the number of elements in this dataspace selection. - hssize_t getSelectNpoints() const; + // Gets the number of elements in this dataspace selection. + hssize_t getSelectNpoints() const; - // Retrieves dataspace dimension size and maximum size. - int getSimpleExtentDims( hsize_t *dims, hsize_t *maxdims = NULL ) const; + // Retrieves dataspace dimension size and maximum size. + int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; - // Gets the dimensionality of this dataspace. - int getSimpleExtentNdims() const; + // Gets the dimensionality of this dataspace. + int getSimpleExtentNdims() const; - // Gets the number of elements in this dataspace. - // 12/05/00 - changed return type to hssize_t from hsize_t - C API - hssize_t getSimpleExtentNpoints() const; + // Gets the number of elements in this dataspace. + // 12/05/00 - changed return type to hssize_t from hsize_t - C API + hssize_t getSimpleExtentNpoints() const; - // Gets the current class of this dataspace. - H5S_class_t getSimpleExtentType() const; + // Gets the current class of this dataspace. + H5S_class_t getSimpleExtentType() const; - // Determines if this dataspace is a simple one. - bool isSimple() const; + // Determines if this dataspace is a simple one. + bool isSimple() const; - // Sets the offset of this simple dataspace. - void offsetSimple( const hssize_t* offset ) const; + // Sets the offset of this simple dataspace. + void offsetSimple(const hssize_t* offset) const; - // Selects the entire dataspace. - void selectAll() const; + // Selects the entire dataspace. + void selectAll() const; - // Selects array elements to be included in the selection for - // this dataspace. - void selectElements( H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; + // Selects array elements to be included in the selection for + // this dataspace. + void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; - // Selects a hyperslab region to add to the current selected region. - void selectHyperslab( H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride = NULL, const hsize_t *block = NULL ) const; + // Selects a hyperslab region to add to the current selected region. + void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride = NULL, const hsize_t *block = NULL) const; - // Resets the selection region to include no elements. - void selectNone() const; + // Resets the selection region to include no elements. + void selectNone() const; - // Verifies that the selection is within the extent of the dataspace. - bool selectValid() const; + // Verifies that the selection is within the extent of the dataspace. + bool selectValid() const; - // Removes the extent from this dataspace. - void setExtentNone() const; + // Removes the extent from this dataspace. + void setExtentNone() const; - // Sets or resets the size of this dataspace. - void setExtentSimple( int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL ) const; + // Sets or resets the size of this dataspace. + void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSpace"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DataSpace"); } - // Gets the dataspace id. - virtual hid_t getId() const; + // Gets the dataspace id. + virtual hid_t getId() const; - // Deletes the global constant - static void deleteConstants(); + // Deletes the global constant + static void deleteConstants(); - // Destructor: properly terminates access to this dataspace. - virtual ~DataSpace(); + // Destructor: properly terminates access to this dataspace. + virtual ~DataSpace(); #ifndef DOXYGEN_SHOULD_SKIP_THIS protected: - // Sets the dataspace id. - virtual void p_setId(const hid_t new_id); + // Sets the dataspace id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS private: - hid_t id; // HDF5 dataspace id + hid_t id; // HDF5 dataspace id #ifndef DOXYGEN_SHOULD_SKIP_THIS - static DataSpace* ALL_; + static DataSpace* ALL_; - // Creates the global constant - static DataSpace* getConstant(); + // Creates the global constant + static DataSpace* getConstant(); - // Friend function to set DataSpace id. For library use only. - friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); + // Friend function to set DataSpace id. For library use only. + friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 372b2c9..ae48d16 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -46,24 +46,24 @@ using std::cerr; using std::endl; //-------------------------------------------------------------------------- -// Function: DataType default constructor -///\brief Default constructor: Creates a stub datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType default constructor +///\brief Default constructor: Creates a stub datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataType::DataType() : H5Object(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- -// Function: DataType overloaded constructor -///\brief Creates a datatype using an existing datatype's id -///\param existing_id - IN: Id of the existing datatype +// Function: DataType overloaded constructor +///\brief Creates a datatype using an existing datatype's id +///\param existing_id - IN: Id of the existing datatype // Description -// Constructor creates a copy of an existing DataType using -// its id. -// Programmer Binh-Minh Ribler - 2000 +// Constructor creates a copy of an existing DataType using +// its id. +// Programmer Binh-Minh Ribler - 2000 // Modification -// Dec, 2005 -// Removed second argument, "predefined", after changing to the -// new ref counting mechanism that relies on C's ref counting. +// Dec, 2005 +// Removed second argument, "predefined", after changing to the +// new ref counting mechanism that relies on C's ref counting. //-------------------------------------------------------------------------- DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id) { @@ -71,36 +71,36 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id) } //-------------------------------------------------------------------------- -// Function: DataType overloaded constructor -///\brief Creates a object given its class and size -///\param type_class - IN: Class of datatype to create -///\param size - IN: Number of bytes in the datatype to create -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType overloaded constructor +///\brief Creates a object given its class and size +///\param type_class - IN: Class of datatype to create +///\param size - IN: Number of bytes in the datatype to create +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object() +DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object() { - // Call C routine to create the new datatype - id = H5Tcreate( type_class, size ); - if( id < 0 ) - { - throw DataTypeIException("DataType constructor", "H5Tcreate failed"); - } + // Call C routine to create the new datatype + id = H5Tcreate(type_class, size); + if (id < 0) + { + throw DataTypeIException("DataType constructor", "H5Tcreate failed"); + } } //-------------------------------------------------------------------------- -// Function: DataType overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 group, creates a -/// DataType object +// Function: DataType overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 group, creates a +/// DataType object ///\param loc - IN: Location referenced object is in -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// Jul, 2008 -// Added for application convenience. +// Jul, 2008 +// Added for application convenience. //-------------------------------------------------------------------------- DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object() { @@ -108,18 +108,18 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, } //-------------------------------------------------------------------------- -// Function: DataType overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 group, creates a -/// DataType object +// Function: DataType overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 group, creates a +/// DataType object ///\param attr - IN: Specifying location where the referenced object is in -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// Jul, 2008 -// Added for application convenience. +// Jul, 2008 +// Added for application convenience. //-------------------------------------------------------------------------- /* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { @@ -128,9 +128,9 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, */ //-------------------------------------------------------------------------- -// Function: DataType copy constructor -///\brief Copy constructor: makes a copy of the original DataType object -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType copy constructor +///\brief Copy constructor: makes a copy of the original DataType object +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataType::DataType(const DataType& original) : H5Object(), id(original.id) { @@ -144,32 +144,32 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2015 // Description -// Copying the type so that when a predefined type is passed in, -// a copy of it is made, not just a duplicate of the HDF5 id. -// Note: calling DataType::copy will invoke DataType::close() -// unnecessarily and will produce undefined behavior. -// -BMR, Apr 2015 +// Copying the type so that when a predefined type is passed in, +// a copy of it is made, not just a duplicate of the HDF5 id. +// Note: calling DataType::copy will invoke DataType::close() +// unnecessarily and will produce undefined behavior. +// -BMR, Apr 2015 //-------------------------------------------------------------------------- DataType::DataType(const PredType& pred_type) : H5Object() { // Call C routine to copy the datatype - id = H5Tcopy( pred_type.getId() ); + id = H5Tcopy(pred_type.getId()); if (id < 0) - throw DataTypeIException("DataType constructor", "H5Tcopy failed"); + throw DataTypeIException("DataType constructor", "H5Tcopy failed"); } //-------------------------------------------------------------------------- // Function: DataType overloaded constructor ///\brief Creates a DataType instance by opening an HDF5 datatype given -/// its name as a char*. +/// its name as a char*. ///\param dtype_name - IN: Datatype name ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openDataType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openDataType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object() { @@ -178,16 +178,16 @@ DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object() //-------------------------------------------------------------------------- // Function: DataType overloaded constructor -///\brief Creates a DataType instance by opening an HDF5 datatype given -/// its name as an \c H5std_string. +///\brief Creates a DataType instance by opening an HDF5 datatype given +/// its name as an \c H5std_string. ///\param dtype_name - IN: Datatype name ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openDataType(const H5std_string&) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openDataType(const H5std_string&) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Object() { @@ -195,108 +195,108 @@ DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Ob } //-------------------------------------------------------------------------- -// Function: DataType::copy -///\brief Copies an existing datatype to this datatype object -///\param like_type - IN: Datatype to be copied -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::copy +///\brief Copies an existing datatype to this datatype object +///\param like_type - IN: Datatype to be copied +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataType::copy( const DataType& like_type ) +void DataType::copy(const DataType& like_type) { // close the current data type before copying like_type to this object try { - close(); + close(); } catch (Exception& close_error) { - throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); + throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } // call C routine to copy the datatype - id = H5Tcopy( like_type.getId() ); - if( id < 0 ) - throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); + id = H5Tcopy(like_type.getId()); + if (id < 0) + throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); } //-------------------------------------------------------------------------- -// Function: DataType::copy -///\brief Copies the datatype of the given dataset to this datatype object -///\param dset - IN: Dataset -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jan, 2007 +// Function: DataType::copy +///\brief Copies the datatype of the given dataset to this datatype object +///\param dset - IN: Dataset +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jan, 2007 ///\par Description -/// The resulted dataset will be transient and modifiable. +/// The resulted dataset will be transient and modifiable. //-------------------------------------------------------------------------- void DataType::copy(const DataSet& dset) { // close the current data type before copying dset's datatype to this object try { - close(); + close(); } catch (Exception& close_error) { - throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); + throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } // call C routine to copy the datatype - id = H5Tcopy( dset.getId() ); - if( id < 0 ) - throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); + id = H5Tcopy(dset.getId()); + if (id < 0) + throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); } //-------------------------------------------------------------------------- -// Function: DataType::operator= -///\brief Assignment operator -///\param rhs - IN: Reference to the existing datatype -///\return Reference to DataType instance -///\exception H5::DataTypeIException +// Function: DataType::operator= +///\brief Assignment operator +///\param rhs - IN: Reference to the existing datatype +///\return Reference to DataType instance +///\exception H5::DataTypeIException // Description -// Makes a copy of the type on the right hand side and stores -// the new id in the left hand side object. -// Programmer Binh-Minh Ribler - 2000 +// Makes a copy of the type on the right hand side and stores +// the new id in the left hand side object. +// Programmer Binh-Minh Ribler - 2000 // Modification -// Changed operator= to simply copy the id of rhs instead of -// calling H5Tcopy because, when the operator= is invoked, a -// different datatype id is created and it won't have the same -// characteristics as the original one, specifically, if the -// rhs represents a named datatype, "this" would still be a -// transient datatype. -// BMR - Mar, 2015 +// Changed operator= to simply copy the id of rhs instead of +// calling H5Tcopy because, when the operator= is invoked, a +// different datatype id is created and it won't have the same +// characteristics as the original one, specifically, if the +// rhs represents a named datatype, "this" would still be a +// transient datatype. +// BMR - Mar, 2015 //-------------------------------------------------------------------------- -DataType& DataType::operator=( const DataType& rhs ) +DataType& DataType::operator=(const DataType& rhs) { if (this != &rhs) { - setId(rhs.id); + setId(rhs.id); } return(*this); } //-------------------------------------------------------------------------- -// Function: DataType::operator== -///\brief Compares this DataType against the given one to determines -/// whether the two objects refer to the same actual datatype. -///\param compared_type - IN: Reference to the datatype to compare -///\return true if the datatypes are equal, and false, otherwise. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::operator== +///\brief Compares this DataType against the given one to determines +/// whether the two objects refer to the same actual datatype. +///\param compared_type - IN: Reference to the datatype to compare +///\return true if the datatypes are equal, and false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::operator==(const DataType& compared_type ) const +bool DataType::operator==(const DataType& compared_type) const { - // Call C routine H5Tequal to determines whether two datatype - // identifiers refer to the same datatype - htri_t ret_value = H5Tequal( id, compared_type.getId() ); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); - } + // Call C routine H5Tequal to determines whether two datatype + // identifiers refer to the same datatype + htri_t ret_value = H5Tequal(id, compared_type.getId()); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); + } } //-------------------------------------------------------------------------- @@ -306,69 +306,69 @@ bool DataType::operator==(const DataType& compared_type ) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Dec 2016 // Description -// This function was introduced in 1.10.1 to be used by the new -// XxxType constructors that were introduced to replace the -// existing functions CommonFG::openXxxType(), which is awkward -// to use. -BMR, Dec 2016 +// This function was introduced in 1.10.1 to be used by the new +// XxxType constructors that were introduced to replace the +// existing functions CommonFG::openXxxType(), which is awkward +// to use. -BMR, Dec 2016 //-------------------------------------------------------------------------- hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const { // Call C function to open the named datatype at this location hid_t ret_value = H5Topen2(loc.getId(), dtype_name, H5P_DEFAULT); if (ret_value < 0) - throw DataTypeIException("DataType constructor", "H5Topen2 failed"); + throw DataTypeIException("DataType constructor", "H5Topen2 failed"); return(ret_value); } //-------------------------------------------------------------------------- -// Function: DataType::p_commit (private) -//\brief Commits a transient datatype to a file, creating a new -// named datatype -//\param loc_id - IN: The id of either a file, group, dataset, named -// datatype, or attribute. -//\param name - IN: Name of the datatype -//\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::p_commit (private) +//\brief Commits a transient datatype to a file, creating a new +// named datatype +//\param loc_id - IN: The id of either a file, group, dataset, named +// datatype, or attribute. +//\param name - IN: Name of the datatype +//\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 // Modification: -// Copied from DataType::commit and made into private function -// to be commonly used by several overloads of DataType::commit. -// BMR - Jan, 2007 +// Copied from DataType::commit and made into private function +// to be commonly used by several overloads of DataType::commit. +// BMR - Jan, 2007 //-------------------------------------------------------------------------- void DataType::p_commit(hid_t loc_id, const char* name) { - // Call C routine to commit the transient datatype - herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if( ret_value < 0 ) - throw DataTypeIException(inMemFunc("p_commit"), "H5Tcommit2 failed"); + // Call C routine to commit the transient datatype + herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (ret_value < 0) + throw DataTypeIException(inMemFunc("p_commit"), "H5Tcommit2 failed"); } //-------------------------------------------------------------------------- -// Function: DataType::commit -///\brief Commits a transient datatype to a file, creating a new -/// named datatype -///\param loc - IN: A location (file, dataset, datatype, or group) -///\param name - IN: Name of the datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jan, 2007 +// Function: DataType::commit +///\brief Commits a transient datatype to a file, creating a new +/// named datatype +///\param loc - IN: A location (file, dataset, datatype, or group) +///\param name - IN: Name of the datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- void DataType::commit(const H5Location& loc, const char* name) { - p_commit(loc.getId(), name); + p_commit(loc.getId(), name); } //-------------------------------------------------------------------------- -// Function: DataType::commit -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param loc - IN: A location (file, dataset, datatype, or group) -// Param name - IN: Name of the datatype -// Exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jan, 2007 +// Function: DataType::commit +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Param loc - IN: A location (file, dataset, datatype, or group) +// Param name - IN: Name of the datatype +// Exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jan, 2007 // Modification -// Planned for removal. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Planned for removal. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void DataType::commit(H5Location& loc, const char* name) //{ @@ -376,30 +376,30 @@ void DataType::commit(const H5Location& loc, const char* name) //} //-------------------------------------------------------------------------- -// Function: DataType::commit -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of the -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::commit +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataType::commit(const H5Location& loc, const H5std_string& name) { - p_commit(loc.getId(), name.c_str()); + p_commit(loc.getId(), name.c_str()); } //-------------------------------------------------------------------------- -// Function: DataType::commit -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param loc - IN: A location (file, dataset, datatype, or group) -// Param name - IN: Name of the datatype -// Exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Jan, 2007 +// Function: DataType::commit +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Param loc - IN: A location (file, dataset, datatype, or group) +// Param name - IN: Name of the datatype +// Exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Jan, 2007 // Modification -// Planned for removal. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Planned for removal. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void DataType::commit(H5Location& loc, const H5std_string& name) //{ @@ -407,340 +407,340 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) //} //-------------------------------------------------------------------------- -// Function: DataType::committed -///\brief Determines whether a datatype is a named type or a -/// transient type. -///\return \c true if the datatype is a named type, and \c false, -/// otherwise. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::committed +///\brief Determines whether a datatype is a named type or a +/// transient type. +///\return \c true if the datatype is a named type, and \c false, +/// otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool DataType::committed() const { - // Call C function to determine if a datatype is a named one - htri_t is_committed = H5Tcommitted( id ); - if (is_committed > 0) - return true; - else if (is_committed == 0) - return false; - else - { - throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); - } -} - -//-------------------------------------------------------------------------- -// Function: DataType::find -///\brief Finds a conversion function that can handle a conversion -/// from this datatype to the specified datatype, \a dest. -///\param dest - IN: Destination datatype -///\param pcdata - IN: Pointer to type conversion data -///\return Pointer to a suitable conversion function -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const -{ - // Call C routine to find the conversion function - H5T_conv_t func = H5Tfind( id, dest.getId(), pcdata ); - if( func == NULL ) - { - throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); - } - return( func ); -} - -//-------------------------------------------------------------------------- -// Function: DataType::convert -///\brief Converts data from this datatype to the specified datatypes. -///\param dest - IN: Destination datatype -///\param nelmts - IN: Size of array \a buf -///\param buf - IN/OUT: Array containing pre- and post-conversion -/// values -///\param background - IN: Optional backgroud buffer -///\param plist - IN: Property list - default to PropList::DEFAULT -///\return Pointer to a suitable conversion function -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist ) const -{ - // Get identifiers for C API - hid_t dest_id = dest.getId(); - hid_t plist_id = plist.getId(); - - // Call C routine H5Tconvert to convert the data - herr_t ret_value; - ret_value = H5Tconvert( id, dest_id, nelmts, buf, background, plist_id ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); - } -} - -//-------------------------------------------------------------------------- -// Function: DataType::lock -///\brief Locks a datatype, making it read-only and non-destructible. + // Call C function to determine if a datatype is a named one + htri_t is_committed = H5Tcommitted(id); + if (is_committed > 0) + return true; + else if (is_committed == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::find +///\brief Finds a conversion function that can handle a conversion +/// from this datatype to the specified datatype, \a dest. +///\param dest - IN: Destination datatype +///\param pcdata - IN: Pointer to type conversion data +///\return Pointer to a suitable conversion function +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const +{ + // Call C routine to find the conversion function + H5T_conv_t func = H5Tfind(id, dest.getId(), pcdata); + if (func == NULL) + { + throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); + } + return(func); +} + +//-------------------------------------------------------------------------- +// Function: DataType::convert +///\brief Converts data from this datatype to the specified datatypes. +///\param dest - IN: Destination datatype +///\param nelmts - IN: Size of array \a buf +///\param buf - IN/OUT: Array containing pre- and post-conversion +/// values +///\param background - IN: Optional backgroud buffer +///\param plist - IN: Property list - default to PropList::DEFAULT +///\return Pointer to a suitable conversion function +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist) const +{ + // Get identifiers for C API + hid_t dest_id = dest.getId(); + hid_t plist_id = plist.getId(); + + // Call C routine H5Tconvert to convert the data + herr_t ret_value; + ret_value = H5Tconvert(id, dest_id, nelmts, buf, background, plist_id); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::lock +///\brief Locks a datatype, making it read-only and non-destructible. /// -///\exception H5::DataTypeIException +///\exception H5::DataTypeIException ///\par Descrition -/// This is normally done by the library for predefined data -/// types so the application doesn't inadvertently change or -/// delete a predefined type. +/// This is normally done by the library for predefined data +/// types so the application doesn't inadvertently change or +/// delete a predefined type. /// -/// Once a data type is locked it can never be unlocked unless -/// the entire library is closed. -// Programmer Binh-Minh Ribler - 2000 +/// Once a data type is locked it can never be unlocked unless +/// the entire library is closed. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DataType::lock() const { - // Call C routine to lock the datatype - herr_t ret_value = H5Tlock( id ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); - } + // Call C routine to lock the datatype + herr_t ret_value = H5Tlock(id); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); + } } //-------------------------------------------------------------------------- -// Function: DataType::getClass -///\brief Returns the datatype class identifier. -///\return Datatype class identifier -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::getClass +///\brief Returns the datatype class identifier. +///\return Datatype class identifier +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5T_class_t DataType::getClass() const { - H5T_class_t type_class = H5Tget_class( id ); + H5T_class_t type_class = H5Tget_class(id); - // Return datatype class identifier if successful - if( type_class == H5T_NO_CLASS ) - { - throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); - } - return( type_class ); + // Return datatype class identifier if successful + if (type_class == H5T_NO_CLASS) + { + throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); + } + return(type_class); } //-------------------------------------------------------------------------- -// Function: DataType::getSize -///\brief Returns the size of a datatype. -///\return Datatype size in bytes -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::getSize +///\brief Returns the size of a datatype. +///\return Datatype size in bytes +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- size_t DataType::getSize() const { - // Call C routine to get the datatype size - size_t type_size = H5Tget_size( id ); - if( type_size <= 0 ) // valid data types are never zero size - { - throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); - } - return( type_size ); + // Call C routine to get the datatype size + size_t type_size = H5Tget_size(id); + if (type_size <= 0) // valid data types are never zero size + { + throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); + } + return(type_size); } //-------------------------------------------------------------------------- -// Function: DataType::getSuper -///\brief Returns the base datatype from which a datatype is derived. -///\return DataType object -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::getSuper +///\brief Returns the base datatype from which a datatype is derived. +///\return DataType object +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DataType DataType::getSuper() const { - // Call C routine to get the base datatype from which the specified - // datatype is derived. - hid_t base_type_id = H5Tget_super( id ); - - // If H5Tget_super returns a valid datatype id, create and return - // the base type, otherwise, raise exception - if( base_type_id > 0 ) - { - DataType base_type; - base_type.p_setId(base_type_id); - return(base_type); - } - else - { - throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); - } -} - -//-------------------------------------------------------------------------- -// Function: DataType::registerFunc -///\brief Registers the specified conversion function. -///\param pers - IN: Conversion option -/// \li \c H5T_PERS_HARD for hard conversion functions -/// \li \c H5T_PERS_SOFT for soft conversion functions. -///\param name - IN: Name displayed in diagnostic output. -///\param dest - IN: Destination datatype. -///\param func - IN: Function to convert between source and -/// destination datatypes. -///\exception H5::DataTypeIException + // Call C routine to get the base datatype from which the specified + // datatype is derived. + hid_t base_type_id = H5Tget_super(id); + + // If H5Tget_super returns a valid datatype id, create and return + // the base type, otherwise, raise exception + if (base_type_id > 0) + { + DataType base_type; + base_type.p_setId(base_type_id); + return(base_type); + } + else + { + throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::registerFunc +///\brief Registers the specified conversion function. +///\param pers - IN: Conversion option +/// \li \c H5T_PERS_HARD for hard conversion functions +/// \li \c H5T_PERS_SOFT for soft conversion functions. +///\param name - IN: Name displayed in diagnostic output. +///\param dest - IN: Destination datatype. +///\param func - IN: Function to convert between source and +/// destination datatypes. +///\exception H5::DataTypeIException ///\par Description -/// For more information, please see: +/// For more information, please see: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-Register -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const +void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the destination datatype + hid_t dest_id = dest.getId(); // get id of the destination datatype - // Call C routine H5Tregister to register the conversion function - herr_t ret_value = H5Tregister( pers, name, id, dest_id, func ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); - } + // Call C routine H5Tregister to register the conversion function + herr_t ret_value = H5Tregister(pers, name, id, dest_id, func); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); + } } //-------------------------------------------------------------------------- -// Function: DataType::registerFunc -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of the -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::registerFunc +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const +void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const { - registerFunc( pers, name.c_str(), dest, func ); + registerFunc(pers, name.c_str(), dest, func); } //-------------------------------------------------------------------------- -// Function: DataType::unregister -///\brief Removes a conversion function from all conversion paths. -///\param pers - IN: Conversion option -/// \li \c H5T_PERS_HARD for hard conversion functions -/// \li \c H5T_PERS_SOFT for soft conversion functions. -///\param name - IN: Name displayed in diagnostic output. -///\param dest - IN: Destination datatype. -///\param func - IN: Function to convert between source and -/// destination datatypes. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::unregister +///\brief Removes a conversion function from all conversion paths. +///\param pers - IN: Conversion option +/// \li \c H5T_PERS_HARD for hard conversion functions +/// \li \c H5T_PERS_SOFT for soft conversion functions. +///\param name - IN: Name displayed in diagnostic output. +///\param dest - IN: Destination datatype. +///\param func - IN: Function to convert between source and +/// destination datatypes. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const +void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the dest datatype for C API + hid_t dest_id = dest.getId(); // get id of the dest datatype for C API - // Call C routine H5Tunregister to remove the conversion function - herr_t ret_value = H5Tunregister( pers, name, id, dest_id, func ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); - } + // Call C routine H5Tunregister to remove the conversion function + herr_t ret_value = H5Tunregister(pers, name, id, dest_id, func); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); + } } //-------------------------------------------------------------------------- -// Function: DataType::unregister -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of the -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::unregister +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const +void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const { - unregister( pers, name.c_str(), dest, func ); + unregister(pers, name.c_str(), dest, func); } //-------------------------------------------------------------------------- -// Function: DataType::setTag -///\brief Tags an opaque datatype. -///\param tag - IN: Descriptive ASCII string with which the opaque -/// datatype is to be tagged. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::setTag +///\brief Tags an opaque datatype. +///\param tag - IN: Descriptive ASCII string with which the opaque +/// datatype is to be tagged. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag( const char* tag ) const +void DataType::setTag(const char* tag) const { - // Call C routine H5Tset_tag to tag an opaque datatype. - herr_t ret_value = H5Tset_tag( id, tag ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); - } + // Call C routine H5Tset_tag to tag an opaque datatype. + herr_t ret_value = H5Tset_tag(id, tag); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); + } } //-------------------------------------------------------------------------- -// Function: DataType::setTag -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of the -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::setTag +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag( const H5std_string& tag ) const +void DataType::setTag(const H5std_string& tag) const { - setTag( tag.c_str()); + setTag(tag.c_str()); } //-------------------------------------------------------------------------- -// Function: DataType::getTag -///\brief Gets the tag associated with an opaque datatype. -///\return Tag associated with the opaque datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::getTag +///\brief Gets the tag associated with an opaque datatype. +///\return Tag associated with the opaque datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5std_string DataType::getTag() const { - char* tag_Cstr = H5Tget_tag( id ); + char* tag_Cstr = H5Tget_tag(id); // if the tag C-string returned is not NULL, convert it to C++ string // and return it, otherwise, raise an exception - if( tag_Cstr != NULL ) + if (tag_Cstr != NULL) { - H5std_string tag = H5std_string(tag_Cstr); // C string to string object - H5free_memory(tag_Cstr); // free the C string - return (tag); // return the tag + H5std_string tag = H5std_string(tag_Cstr); // C string to string object + H5free_memory(tag_Cstr); // free the C string + return (tag); // return the tag } else { - throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); + throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); } } //-------------------------------------------------------------------------- -// Function: DataType::detectClass -///\brief Checks whether a datatype contains (or is) a certain type of -/// datatype. -///\return true if this datatype contains or is the specified type, -/// and false, otherwise. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: DataType::detectClass +///\brief Checks whether a datatype contains (or is) a certain type of +/// datatype. +///\return true if this datatype contains or is the specified type, +/// and false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- bool DataType::detectClass(H5T_class_t cls) const { - htri_t ret_value = H5Tdetect_class(id, cls); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("detectClass"), - "H5Tdetect_class returns negative value"); - } + htri_t ret_value = H5Tdetect_class(id, cls); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("detectClass"), + "H5Tdetect_class returns negative value"); + } } //-------------------------------------------------------------------------- -// Function: DataType::isVariableStr -///\brief Check whether this datatype is a variable-length string. -///\return true if this datatype is a variable-length string, and -/// false, otherwise. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: DataType::isVariableStr +///\brief Check whether this datatype is a variable-length string. +///\return true if this datatype is a variable-length string, and +/// false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- bool DataType::isVariableStr() const { - htri_t is_varlen_str = H5Tis_variable_str(id); - if( is_varlen_str == 1 ) - return true; - else if( is_varlen_str == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("isVariableStr"), - "H5Tis_variable_str returns negative value"); - } + htri_t is_varlen_str = H5Tis_variable_str(id); + if (is_varlen_str == 1) + return true; + else if (is_varlen_str == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("isVariableStr"), + "H5Tis_variable_str returns negative value"); + } } //-------------------------------------------------------------------------- @@ -757,7 +757,7 @@ bool DataType::isVariableStr() const //-------------------------------------------------------------------------- hid_t DataType::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -782,58 +782,58 @@ void DataType::p_setId(const hid_t new_id) catch (Exception& close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataType::close -///\brief Closes the datatype if it is not a predefined type. +// Function: DataType::close +///\brief Closes the datatype if it is not a predefined type. /// -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void DataType::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Tclose(id); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Tclose(id); + if (ret_value < 0) + { + throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } //-------------------------------------------------------------------------- -// Function: DataType destructor -///\brief Properly terminates access to this datatype. -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType destructor +///\brief Properly terminates access to this datatype. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 -// - Added the use of H5CPP_EXITED to terminate the HDF5 library -// and elimiate previous memory leaks. See comments in the -// header file "H5PredType.h" for details. - BMR, Mar 30, 2012 -// - Major re-implementation of the global constants was done -// to avoid relying on the order of the creation and deletion -// of the global constants. Hence, H5CPP_EXITED was removed. -// See Design Notes in "H5PredType.cpp" for details. -// - BMR, Sep 30, 2015 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 +// - Added the use of H5CPP_EXITED to terminate the HDF5 library +// and elimiate previous memory leaks. See comments in the +// header file "H5PredType.h" for details. - BMR, Mar 30, 2012 +// - Major re-implementation of the global constants was done +// to avoid relying on the order of the creation and deletion +// of the global constants. Hence, H5CPP_EXITED was removed. +// See Design Notes in "H5PredType.cpp" for details. +// - BMR, Sep 30, 2015 //-------------------------------------------------------------------------- DataType::~DataType() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; + cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } } // end namespace diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 4e904a6..fd9c17d 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -30,128 +30,128 @@ namespace H5 { */ class H5_DLLCPP DataType : public H5Object { public: - // Creates a datatype given its class and size - DataType( const H5T_class_t type_class, size_t size ); + // Creates a datatype given its class and size + DataType(const H5T_class_t type_class, size_t size); - // Copy constructor: makes a copy of the original object - DataType( const DataType& original ); + // Copy constructor: makes a copy of the original object + DataType(const DataType& original); - // Creates a copy of a predefined type - DataType(const PredType& pred_type); + // Creates a copy of a predefined type + DataType(const PredType& pred_type); - // Creates a datatype by way of dereference. - DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); -// DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a datatype by way of dereference. + DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); +// DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Closes this datatype. - virtual void close(); + // Closes this datatype. + virtual void close(); - // Copies an existing datatype to this datatype object. - void copy(const DataType& like_type); + // Copies an existing datatype to this datatype object. + void copy(const DataType& like_type); - // Copies the datatype of dset to this datatype object. - void copy(const DataSet& dset); + // Copies the datatype of dset to this datatype object. + void copy(const DataSet& dset); - // Returns the datatype class identifier. - H5T_class_t getClass() const; + // Returns the datatype class identifier. + H5T_class_t getClass() const; - // Commits a transient datatype to a file; this datatype becomes - // a named datatype which can be accessed from the location. - void commit(const H5Location& loc, const char* name); - void commit(const H5Location& loc, const H5std_string& name); + // Commits a transient datatype to a file; this datatype becomes + // a named datatype which can be accessed from the location. + void commit(const H5Location& loc, const char* name); + void commit(const H5Location& loc, const H5std_string& name); - // These two overloaded functions are kept for backward compatibility - // only; they missed the const - removed from 1.8.18 and 1.10.1 - //void commit(H5Location& loc, const char* name); - //void commit(H5Location& loc, const H5std_string& name); + // These two overloaded functions are kept for backward compatibility + // only; they missed the const - removed from 1.8.18 and 1.10.1 + //void commit(H5Location& loc, const char* name); + //void commit(H5Location& loc, const H5std_string& name); - // Determines whether this datatype is a named datatype or - // a transient datatype. - bool committed() const; + // Determines whether this datatype is a named datatype or + // a transient datatype. + bool committed() const; // Finds a conversion function that can handle the conversion // this datatype to the given datatype, dest. - H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const; + H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const; - // Converts data from between specified datatypes. - void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const; + // Converts data from between specified datatypes. + void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const; - // Assignment operator - DataType& operator=( const DataType& rhs ); + // Assignment operator + DataType& operator=(const DataType& rhs); - // Determines whether two datatypes are the same. - bool operator==(const DataType& compared_type ) const; + // Determines whether two datatypes are the same. + bool operator==(const DataType& compared_type) const; - // Locks a datatype. - void lock() const; + // Locks a datatype. + void lock() const; - // Returns the size of a datatype. - size_t getSize() const; + // Returns the size of a datatype. + size_t getSize() const; - // Returns the base datatype from which a datatype is derived. - // Note: not quite right for specific types yet??? - DataType getSuper() const; + // Returns the base datatype from which a datatype is derived. + // Note: not quite right for specific types yet??? + DataType getSuper() const; - // Registers a conversion function. - void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const; - void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const; + // Registers a conversion function. + void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; + void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; - // Removes a conversion function from all conversion paths. - void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const; - void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const; + // Removes a conversion function from all conversion paths. + void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; + void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; - // Tags an opaque datatype. - void setTag( const char* tag ) const; - void setTag( const H5std_string& tag ) const; + // Tags an opaque datatype. + void setTag(const char* tag) const; + void setTag(const H5std_string& tag) const; - // Gets the tag associated with an opaque datatype. - H5std_string getTag() const; + // Gets the tag associated with an opaque datatype. + H5std_string getTag() const; - // Checks whether this datatype contains (or is) a certain type class. - bool detectClass(H5T_class_t cls) const; + // Checks whether this datatype contains (or is) a certain type class. + bool detectClass(H5T_class_t cls) const; - // Checks whether this datatype is a variable-length string. - bool isVariableStr() const; + // Checks whether this datatype is a variable-length string. + bool isVariableStr() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DataType"); } // From CommonFG then H5Location - // Constructors to open a generic named datatype at a given location. - DataType(const H5Location& loc, const char* name); - DataType(const H5Location& loc, const H5std_string& name); + // Constructors to open a generic named datatype at a given location. + DataType(const H5Location& loc, const char* name); + DataType(const H5Location& loc, const H5std_string& name); // End of From CommonFG then H5Location - // Creates a copy of an existing DataType using its id - DataType( const hid_t type_id ); + // Creates a copy of an existing DataType using its id + DataType(const hid_t type_id); - // Default constructor - DataType(); + // Default constructor + DataType(); - // Gets the datatype id. - virtual hid_t getId() const; + // Gets the datatype id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this datatype. - virtual ~DataType(); + // Destructor: properly terminates access to this datatype. + virtual ~DataType(); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - hid_t id; // HDF5 datatype id + hid_t id; // HDF5 datatype id - // Sets the datatype id. - virtual void p_setId(const hid_t new_id); + // Sets the datatype id. + virtual void p_setId(const hid_t new_id); - // Opens a datatype and returns the id. - hid_t p_opentype(const H5Location& loc, const char* dtype_name) const; + // Opens a datatype and returns the id. + hid_t p_opentype(const H5Location& loc, const char* dtype_name) const; #endif // DOXYGEN_SHOULD_SKIP_THIS private: - // Friend function to set DataType id. For library use only. - friend void f_DataType_setId(DataType* dtype, hid_t new_id); + // Friend function to set DataType id. For library use only. + friend void f_DataType_setId(DataType* dtype, hid_t new_id); - void p_commit(hid_t loc_id, const char* name); + void p_commit(hid_t loc_id, const char* name); }; } #endif // __H5DataType_H diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 8ab38dc..86d4d9c 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -40,7 +40,7 @@ DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; // Function: DSetCreatPropList::getConstant // Purpose: Creates a DSetCreatPropList object representing the HDF5 // constant H5P_DATASET_CREATE, pointed to by -// DSetCreatPropList::DEFAULT_ +// DSetCreatPropList::DEFAULT_ // exception H5::PropListIException // Description // If DSetCreatPropList::DEFAULT_ already points to an allocated @@ -80,670 +80,670 @@ void DSetCreatPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose Constant for dataset creation default property +// Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DSetCreatPropList default constructor -///\brief Default constructor: creates a stub dataset creation property list -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList default constructor +///\brief Default constructor: creates a stub dataset creation property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} //-------------------------------------------------------------------------- -// Function: DSetCreatPropList copy constructor -///\brief Copy constructor: makes a copy of the original -/// DSetCreatPropList object -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList copy constructor +///\brief Copy constructor: makes a copy of the original +/// DSetCreatPropList object +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : ObjCreatPropList(orig) {} +DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPropList(orig) {} //-------------------------------------------------------------------------- -// Function: DSetCreatPropList overloaded constructor -///\brief Creates a DSetCreatPropList object using the id of an -/// existing dataset creation property list. -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList overloaded constructor +///\brief Creates a DSetCreatPropList object using the id of an +/// existing dataset creation property list. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) {} //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setChunk -///\brief Sets the size of the chunks used to store a chunked layout -/// dataset. -///\param ndims - IN: Number of dimensions of each chunk -///\param dim - IN: Array containing the size of each chunk -///\exception H5::PropListIException +// Function: DSetCreatPropList::setChunk +///\brief Sets the size of the chunks used to store a chunked layout +/// dataset. +///\param ndims - IN: Number of dimensions of each chunk +///\param dim - IN: Array containing the size of each chunk +///\exception H5::PropListIException ///\par Description -/// The \a ndims parameter currently must have the same value as -/// the rank of the dataset. The values of the \a dim array -/// define the size of the chunks to store the dataset's raw -/// data. As a side-effect, the layout of the dataset will be -/// changed to \c H5D_CHUNKED, if it is not so already. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DSetCreatPropList::setChunk( int ndims, const hsize_t* dim ) const +/// The \a ndims parameter currently must have the same value as +/// the rank of the dataset. The values of the \a dim array +/// define the size of the chunks to store the dataset's raw +/// data. As a side-effect, the layout of the dataset will be +/// changed to \c H5D_CHUNKED, if it is not so already. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const { - herr_t ret_value = H5Pset_chunk( id, ndims, dim ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed"); - } + herr_t ret_value = H5Pset_chunk(id, ndims, dim); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getChunk -///\brief Retrieves the size of the chunks used to store a chunked -/// layout dataset. -///\param max_ndims - IN: Size of \a dim array -///\param dim - OUT: Array to store the chunk dimensions -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList::getChunk +///\brief Retrieves the size of the chunks used to store a chunked +/// layout dataset. +///\param max_ndims - IN: Size of \a dim array +///\param dim - OUT: Array to store the chunk dimensions +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getChunk( int max_ndims, hsize_t* dim ) const +int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const { - int chunk_size = H5Pget_chunk( id, max_ndims, dim ); - if( chunk_size < 0 ) - { - throw PropListIException("DSetCreatPropList::getChunk", - "H5Pget_chunk returns negative chunk size"); - } - return( chunk_size ); + int chunk_size = H5Pget_chunk(id, max_ndims, dim); + if (chunk_size < 0) + { + throw PropListIException("DSetCreatPropList::getChunk", + "H5Pget_chunk returns negative chunk size"); + } + return(chunk_size); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setLayout -///\brief Sets the type of storage used store the raw data for a dataset. -///\param layout - IN: Type of storage layout for raw data -///\exception H5::PropListIException +// Function: DSetCreatPropList::setLayout +///\brief Sets the type of storage used store the raw data for a dataset. +///\param layout - IN: Type of storage layout for raw data +///\exception H5::PropListIException ///\par Description -/// For information on valid layout types, please refer to +/// For information on valid layout types, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetLayout -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::setLayout(H5D_layout_t layout) const { - herr_t ret_value = H5Pset_layout( id, layout ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setLayout", - "H5Pset_layout failed"); - } + herr_t ret_value = H5Pset_layout(id, layout); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setLayout", + "H5Pset_layout failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getLayout -///\brief Retrieves the layout type of this property list -///\return Layout type, which can be: -/// \li \c H5D_COMPACT - raw data is stored in the object -/// header in the file. -/// \li \c H5D_CONTIGUOUS - raw data is stored separately from the -/// object header in one contiguous chunk in -/// the file. -/// \li \c H5D_CHUNKED - raw data is stored separately from the -/// object header in chunks in separate locations -/// in the file. -///\exception H5::PropListIException +// Function: DSetCreatPropList::getLayout +///\brief Retrieves the layout type of this property list +///\return Layout type, which can be: +/// \li \c H5D_COMPACT - raw data is stored in the object +/// header in the file. +/// \li \c H5D_CONTIGUOUS - raw data is stored separately from the +/// object header in one contiguous chunk in +/// the file. +/// \li \c H5D_CHUNKED - raw data is stored separately from the +/// object header in chunks in separate locations +/// in the file. +///\exception H5::PropListIException ///\par Description -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5D_layout_t DSetCreatPropList::getLayout() const { - H5D_layout_t layout = H5Pget_layout( id ); - if( layout == H5D_LAYOUT_ERROR ) - { - throw PropListIException("DSetCreatPropList::getLayout", - "H5Pget_layout returns H5D_LAYOUT_ERROR"); - } - return( layout ); + H5D_layout_t layout = H5Pget_layout(id); + if (layout == H5D_LAYOUT_ERROR) + { + throw PropListIException("DSetCreatPropList::getLayout", + "H5Pget_layout returns H5D_LAYOUT_ERROR"); + } + return(layout); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setDeflate -///\brief Sets compression method and compression level -///\param level - IN: Compression level, should [0..9], inclusive -///\exception H5::PropListIException +// Function: DSetCreatPropList::setDeflate +///\brief Sets compression method and compression level +///\param level - IN: Compression level, should [0..9], inclusive +///\exception H5::PropListIException ///\par Description -/// The function sets the compression method for this property -/// list to \c H5D_COMPRESS_DEFLATE and the compression level to -/// \a level. Lower compression levels are faster but result in -/// less compression. -// Programmer Binh-Minh Ribler - 2000 +/// The function sets the compression method for this property +/// list to \c H5D_COMPRESS_DEFLATE and the compression level to +/// \a level. Lower compression levels are faster but result in +/// less compression. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setDeflate( int level ) const +void DSetCreatPropList::setDeflate(int level) const { - herr_t ret_value = H5Pset_deflate( id, level ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setDeflate", - "H5Pset_deflate failed"); - } + herr_t ret_value = H5Pset_deflate(id, level); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setDeflate", + "H5Pset_deflate failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setSzip -///\brief Sets up for the use of the SZIP compression filter. -///\param options_mask - IN: A bit-mask conveying the desired SZIP -/// options. Valid values are H5_SZIP_EC_OPTION_MASK -/// and H5_SZIP_NN_OPTION_MASK. -///\param pixels_per_block - IN: Number of pixels or data elements in -/// each data block. -///\exception H5::PropListIException +// Function: DSetCreatPropList::setSzip +///\brief Sets up for the use of the SZIP compression filter. +///\param options_mask - IN: A bit-mask conveying the desired SZIP +/// options. Valid values are H5_SZIP_EC_OPTION_MASK +/// and H5_SZIP_NN_OPTION_MASK. +///\param pixels_per_block - IN: Number of pixels or data elements in +/// each data block. +///\exception H5::PropListIException ///\par Description -/// The associate C function sets an SZIP compression filter, -/// H5Z_FILTER_SZIP, for a dataset. For more information about -/// SZIP and usage, please refer to the C layer Reference -/// Manual at: +/// The associate C function sets an SZIP compression filter, +/// H5Z_FILTER_SZIP, for a dataset. For more information about +/// SZIP and usage, please refer to the C layer Reference +/// Manual at: /// http://hdfgroup.org/HDF5/doc/RM_H5P.html#Property-SetSzip -// Programmer Binh-Minh Ribler - Jan, 2007 +// Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const { herr_t ret_value = H5Pset_szip(id, options_mask, pixels_per_block); - if( ret_value < 0 ) + if (ret_value < 0) { - throw PropListIException("DSetCreatPropList::setSzip", - "H5Pset_szip failed"); + throw PropListIException("DSetCreatPropList::setSzip", + "H5Pset_szip failed"); } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setNbit -///\brief Sets up for the use of the Nbit compression filter. -///\exception H5::PropListIException +// Function: DSetCreatPropList::setNbit +///\brief Sets up for the use of the Nbit compression filter. +///\exception H5::PropListIException ///\par Description -/// The associate C function sets an Nbit compression filter, -/// H5Z_FILTER_NBIT, for a dataset. For more information about -/// Nbit compression, please refer to the C layer Reference -/// Manual at: +/// The associate C function sets an Nbit compression filter, +/// H5Z_FILTER_NBIT, for a dataset. For more information about +/// Nbit compression, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-setNbit -// Programmer Binh-Minh Ribler - Apr, 2016 +// Programmer Binh-Minh Ribler - Apr, 2016 //-------------------------------------------------------------------------- void DSetCreatPropList::setNbit() const { herr_t ret_value = H5Pset_nbit(id); - if( ret_value < 0 ) + if (ret_value < 0) { - throw PropListIException("DSetCreatPropList::setNbit", - "H5Pset_nbit failed"); + throw PropListIException("DSetCreatPropList::setNbit", + "H5Pset_nbit failed"); } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setFillValue -///\brief Sets a dataset fill value -///\param fvalue_type - IN: Data type for the value passed via \a value -///\param value - IN: Pointer to buffer containing the fill value -///\exception H5::PropListIException +// Function: DSetCreatPropList::setFillValue +///\brief Sets a dataset fill value +///\param fvalue_type - IN: Data type for the value passed via \a value +///\param value - IN: Pointer to buffer containing the fill value +///\exception H5::PropListIException ///\par Description -/// The datatype may differ from that of the dataset, but it must -/// be one that the HDF5 library is able to convert \a value to -/// the dataset datatype when the dataset is created. -/// The default fill value is 0 (zero,) which is interpreted -/// according to the actual dataset datatype. +/// The datatype may differ from that of the dataset, but it must +/// be one that the HDF5 library is able to convert \a value to +/// the dataset datatype when the dataset is created. +/// The default fill value is 0 (zero,) which is interpreted +/// according to the actual dataset datatype. ///\par -/// For information on setting fill value, please refer to the -/// C layer Reference Manual at: +/// For information on setting fill value, please refer to the +/// C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFillValue -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillValue( const DataType& fvalue_type, const void* value ) const +void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* value) const { - herr_t ret_value = H5Pset_fill_value( id, fvalue_type.getId(), value ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setFillValue", + herr_t ret_value = H5Pset_fill_value(id, fvalue_type.getId(), value); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setFillValue", "H5Pset_fill_value failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getFillValue -///\brief Retrieves a dataset fill value -///\param fvalue_type - IN: Data type for the value passed via \a value -///\param value - OUT: Pointer to buffer to hold the retrieved fill value -///\exception H5::PropListIException +// Function: DSetCreatPropList::getFillValue +///\brief Retrieves a dataset fill value +///\param fvalue_type - IN: Data type for the value passed via \a value +///\param value - OUT: Pointer to buffer to hold the retrieved fill value +///\exception H5::PropListIException ///\par Description -/// The fill value is returned through \a value pointer -/// and the memory is allocated by the caller. The fill -/// value will be converted from its current data type to the -/// specified by \a fvalue_type. -// Programmer Binh-Minh Ribler - 2000 +/// The fill value is returned through \a value pointer +/// and the memory is allocated by the caller. The fill +/// value will be converted from its current data type to the +/// specified by \a fvalue_type. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFillValue( const DataType& fvalue_type, void* value ) const +void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) const { - herr_t ret_value = H5Pget_fill_value( id, fvalue_type.getId(), value ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::getFillValue", + herr_t ret_value = H5Pget_fill_value(id, fvalue_type.getId(), value); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::getFillValue", "H5Pget_fill_value failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::isFillValueDefined -///\brief Check if fill value has been defined for this property +// Function: DSetCreatPropList::isFillValueDefined +///\brief Check if fill value has been defined for this property ///\return -/// \li \c H5D_FILL_VALUE_UNDEFINED =0, -/// \li \c H5D_FILL_VALUE_DEFAULT =1, -/// \li \c H5D_FILL_VALUE_USER_DEFINED =2 -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +/// \li \c H5D_FILL_VALUE_UNDEFINED =0, +/// \li \c H5D_FILL_VALUE_DEFAULT =1, +/// \li \c H5D_FILL_VALUE_USER_DEFINED =2 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const { - H5D_fill_value_t status; - herr_t ret_value = H5Pfill_value_defined(id, &status); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::isFillValueDefined", + H5D_fill_value_t status; + herr_t ret_value = H5Pfill_value_defined(id, &status); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::isFillValueDefined", "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); - } - else - return (status); + } + else + return (status); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setFilter -///\brief Adds a filter to the filter pipeline -///\param filter_id - IN: Filter to add -///\param flags - IN: Specifies general properties of the filter -///\param cd_nelmts - IN: Number of elements in cd_values -///\param cd_values - IN: Auxiliary data for the filter -///\exception H5::PropListIException +// Function: DSetCreatPropList::setFilter +///\brief Adds a filter to the filter pipeline +///\param filter_id - IN: Filter to add +///\param flags - IN: Specifies general properties of the filter +///\param cd_nelmts - IN: Number of elements in cd_values +///\param cd_values - IN: Auxiliary data for the filter +///\exception H5::PropListIException ///\par Description -/// The \a flags argument is a bit vector of the field: -/// \c H5Z_FLAG_OPTIONAL(0x0001) +/// The \a flags argument is a bit vector of the field: +/// \c H5Z_FLAG_OPTIONAL(0x0001) ///\par -/// If this bit is set then the filter is optional. If the filter -/// fails during a \c DataSet::write() operation then the filter -/// is just excluded from the pipeline for the chunk for which it -/// failed; the filter will not participate in the pipeline -/// during a \c DataSet::read() of the chunk. If this bit is clear -/// and the filter fails then the entire I/O operation fails. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DSetCreatPropList::setFilter( H5Z_filter_t filter_id, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[] ) const +/// If this bit is set then the filter is optional. If the filter +/// fails during a \c DataSet::write() operation then the filter +/// is just excluded from the pipeline for the chunk for which it +/// failed; the filter will not participate in the pipeline +/// during a \c DataSet::read() of the chunk. If this bit is clear +/// and the filter fails then the entire I/O operation fails. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, + size_t cd_nelmts, const unsigned int cd_values[]) const { - herr_t ret_value = H5Pset_filter( id, filter_id, flags, cd_nelmts, cd_values ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setFilter", + herr_t ret_value = H5Pset_filter(id, filter_id, flags, cd_nelmts, cd_values); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setFilter", "H5Pset_filter failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::removeFilter -///\brief Removes one or more filters -///\param filter_id - IN: Filter to remove -///\exception H5::PropListIException +// Function: DSetCreatPropList::removeFilter +///\brief Removes one or more filters +///\param filter_id - IN: Filter to remove +///\exception H5::PropListIException ///\par Description -/// Deletes a filter from the dataset creation property list; -/// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. -// Programmer Binh-Minh Ribler - 2000 +/// Deletes a filter from the dataset creation property list; +/// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const { - herr_t ret_value = H5Premove_filter( id, filter_id); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::removeFilter", + herr_t ret_value = H5Premove_filter(id, filter_id); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::removeFilter", "H5Premove_filter failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getNfilters -///\brief Returns the number of filters in the pipeline -///\return Number of filters -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList::getNfilters +///\brief Returns the number of filters in the pipeline +///\return Number of filters +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int DSetCreatPropList::getNfilters() const { - int num_filters = H5Pget_nfilters( id ); - if( num_filters < 0 ) - { - throw PropListIException("DSetCreatPropList::getNfilters", + int num_filters = H5Pget_nfilters(id); + if (num_filters < 0) + { + throw PropListIException("DSetCreatPropList::getNfilters", "H5Pget_nfilters returned negative number of filters"); - } - else - return( num_filters ); + } + else + return(num_filters); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getFilter -///\brief Returns information about a filter in a pipeline -///\param filter_number - IN: Filter to get, range [0..N-1], where -/// N is returned by H5Pget_nfilters() -///\param flags - OUT: General properties of the filter -///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number -/// of values defined by the filter -///\param cd_values - OUT: Array to hold the data; allocated by the user -///\param namelen - IN: Length of \a name -///\param name - OUT: Name of the filter -///\param filter_config - OUT: Flags indicating whether filter can encode/decode -///\return Filter id -///\exception H5::PropListIException +// Function: DSetCreatPropList::getFilter +///\brief Returns information about a filter in a pipeline +///\param filter_number - IN: Filter to get, range [0..N-1], where +/// N is returned by H5Pget_nfilters() +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number +/// of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\param namelen - IN: Length of \a name +///\param name - OUT: Name of the filter +///\param filter_config - OUT: Flags indicating whether filter can encode/decode +///\return Filter id +///\exception H5::PropListIException ///\par Description -/// Failure occurs when \a filter_number is out of range. -// Note: the first argument was mistakenly typed as int instead -// of unsigned int, but for backward compatibility, it cannot be -// changed. -BMR (2014/04/15) +/// Failure occurs when \a filter_number is out of range. +// Note: the first argument was mistakenly typed as int instead +// of unsigned int, but for backward compatibility, it cannot be +// changed. -BMR (2014/04/15) //-------------------------------------------------------------------------- H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int& filter_config) const + unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, + size_t namelen, char name[], unsigned int& filter_config) const { - H5Z_filter_t filter_id; - filter_id = H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); - if( filter_id == H5Z_FILTER_ERROR ) - throw PropListIException("DSetCreatPropList::getFilter", + H5Z_filter_t filter_id; + filter_id = H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, + cd_values, namelen, name, &filter_config); + if (filter_id == H5Z_FILTER_ERROR) + throw PropListIException("DSetCreatPropList::getFilter", "H5Pget_filter2 returned H5Z_FILTER_ERROR"); - else - return(filter_id); + else + return(filter_id); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getFilterById -///\brief Returns information about a filter in a pipeline given the -/// filter id -///\param filter_id - IN: Filter to get -///\param flags - OUT: General properties of the filter -///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number -/// of values defined by the filter -///\param cd_values - OUT: Array to hold the data; allocated by the user -///\param namelen - IN: Length of \a name -///\param name - OUT: Name of the filter -///\param filter_config - OUT: Flags indicating whether filter can encode/decode -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList::getFilterById +///\brief Returns information about a filter in a pipeline given the +/// filter id +///\param filter_id - IN: Filter to get +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number +/// of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\param namelen - IN: Length of \a name +///\param name - OUT: Name of the filter +///\param filter_config - OUT: Flags indicating whether filter can encode/decode +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int &filter_config) const + unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, + size_t namelen, char name[], unsigned int &filter_config) const { - herr_t ret_value = H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); - if (ret_value < 0) - throw PropListIException("DSetCreatPropList::getFilterById", + herr_t ret_value = H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, + cd_values, namelen, name, &filter_config); + if (ret_value < 0) + throw PropListIException("DSetCreatPropList::getFilterById", "H5Pget_filter_by_id2 failed"); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::modifyFilter -///\brief Modifies the specified filter -///\param filter_id - IN: Filter to get -///\param flags - OUT: General properties of the filter -///\param cd_nelmts - IN: Number of elements in \a cd_values -/// \n OUT: Number of values defined by the filter -///\param cd_values - OUT: Array to hold the data; allocated by the user -///\exception H5::PropListIException +// Function: DSetCreatPropList::modifyFilter +///\brief Modifies the specified filter +///\param filter_id - IN: Filter to get +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN: Number of elements in \a cd_values +/// \n OUT: Number of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\exception H5::PropListIException ///\par Description -/// The \a flags argument is a bit vector of the field: -/// \c H5Z_FLAG_OPTIONAL(0x0001) +/// The \a flags argument is a bit vector of the field: +/// \c H5Z_FLAG_OPTIONAL(0x0001) ///\par -/// If this bit is set then the filter is optional. If the filter -/// fails during a DataSet::write() operation then the filter -/// is just excluded from the pipeline for the chunk for which it -/// failed; the filter will not participate in the pipeline -/// during a DataSet::read() of the chunk. If this bit is clear -/// and the filter fails then the entire I/O operation fails. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DSetCreatPropList::modifyFilter( H5Z_filter_t filter_id, unsigned int - flags, size_t cd_nelmts, const unsigned int cd_values[] ) const +/// If this bit is set then the filter is optional. If the filter +/// fails during a DataSet::write() operation then the filter +/// is just excluded from the pipeline for the chunk for which it +/// failed; the filter will not participate in the pipeline +/// during a DataSet::read() of the chunk. If this bit is clear +/// and the filter fails then the entire I/O operation fails. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int + flags, size_t cd_nelmts, const unsigned int cd_values[]) const { - herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::modifyFilter", + herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::modifyFilter", "H5Pmodify_filter failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::allFiltersAvail -///\brief Queries whether all the filters set in this property list -/// are available currently. -///\return true if all filters available, and false if one or more -/// filters not currently available -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList::allFiltersAvail +///\brief Queries whether all the filters set in this property list +/// are available currently. +///\return true if all filters available, and false if one or more +/// filters not currently available +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool DSetCreatPropList::allFiltersAvail() const { - htri_t ret_value = H5Pall_filters_avail(id); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else // Raise exception when H5Pall_filters_avail returns a negative value - { - throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); - } + htri_t ret_value = H5Pall_filters_avail(id); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Pall_filters_avail returns a negative value + { + throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setShuffle -///\brief Sets method of the shuffle filter +// Function: DSetCreatPropList::setShuffle +///\brief Sets method of the shuffle filter /// -///\exception H5::PropListIException +///\exception H5::PropListIException ///\par Description -/// Please refer to the Reference Manual of \c H5Pset_shuffle for -/// details. +/// Please refer to the Reference Manual of \c H5Pset_shuffle for +/// details. /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetShuffle -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::setShuffle() const { - herr_t ret_value = H5Pset_shuffle(id); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setShuffle", + herr_t ret_value = H5Pset_shuffle(id); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setShuffle", "H5Pset_shuffle failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getAllocTime -///\brief Get space allocation time for this property. -///\return Space allocation time. -///\exception H5::PropListIException +// Function: DSetCreatPropList::getAllocTime +///\brief Get space allocation time for this property. +///\return Space allocation time. +///\exception H5::PropListIException ///\par Description -/// The values of space allocation time can be one of the -/// followings: -/// \li \c H5D_ALLOC_TIME_DEFAULT -/// \li \c H5D_ALLOC_TIME_EARLY -/// \li \c H5D_ALLOC_TIME_LATE -/// \li \c H5D_ALLOC_TIME_INCR -// Programmer Binh-Minh Ribler - 2000 +/// The values of space allocation time can be one of the +/// followings: +/// \li \c H5D_ALLOC_TIME_DEFAULT +/// \li \c H5D_ALLOC_TIME_EARLY +/// \li \c H5D_ALLOC_TIME_LATE +/// \li \c H5D_ALLOC_TIME_INCR +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5D_alloc_time_t DSetCreatPropList::getAllocTime() const { - H5D_alloc_time_t alloc_time; - herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::getAllocTime", + H5D_alloc_time_t alloc_time; + herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::getAllocTime", "H5Pget_alloc_time failed"); - } - else - return (alloc_time); + } + else + return (alloc_time); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getFillTime -///\brief Gets fill value writing time. -///\return Fill value writing time -///\exception H5::PropListIException +// Function: DSetCreatPropList::getFillTime +///\brief Gets fill value writing time. +///\return Fill value writing time +///\exception H5::PropListIException ///\par Description -/// Valid values for fill value writing time include -/// \li \c H5D_FILL_TIME_NEVER -/// \li \c H5D_FILL_TIME_ALLOC. -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for fill value writing time include +/// \li \c H5D_FILL_TIME_NEVER +/// \li \c H5D_FILL_TIME_ALLOC. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5D_fill_time_t DSetCreatPropList::getFillTime() const { - H5D_fill_time_t fill_time; - herr_t ret_value = H5Pget_fill_time(id, &fill_time); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::getFillTime", + H5D_fill_time_t fill_time; + herr_t ret_value = H5Pget_fill_time(id, &fill_time); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::getFillTime", "H5Pget_fill_time failed"); - } - else - return (fill_time); + } + else + return (fill_time); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setAllocTime -///\brief Sets space allocation time for dataset during creation. -///\param alloc_time - IN: Allocation time -///\exception H5::PropListIException +// Function: DSetCreatPropList::setAllocTime +///\brief Sets space allocation time for dataset during creation. +///\param alloc_time - IN: Allocation time +///\exception H5::PropListIException ///\par Description -/// Valid values for space allocation time include: -/// \li \c H5D_ALLOC_TIME_DEFAULT -/// \li \c H5D_ALLOC_TIME_EARLY -/// \li \c H5D_ALLOC_TIME_LATE -/// \li \c H5D_ALLOC_TIME_INCR -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for space allocation time include: +/// \li \c H5D_ALLOC_TIME_DEFAULT +/// \li \c H5D_ALLOC_TIME_EARLY +/// \li \c H5D_ALLOC_TIME_LATE +/// \li \c H5D_ALLOC_TIME_INCR +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const { - herr_t ret_value = H5Pset_alloc_time(id, alloc_time); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setAllocTime", + herr_t ret_value = H5Pset_alloc_time(id, alloc_time); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setAllocTime", "H5Pset_alloc_time failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setFillTime -///\brief Sets fill value writing time for dataset. -///\return Fill value writing time -///\exception H5::PropListIException +// Function: DSetCreatPropList::setFillTime +///\brief Sets fill value writing time for dataset. +///\return Fill value writing time +///\exception H5::PropListIException ///\par Description -/// Valid values for fill value writing time include -/// \li \c H5D_FILL_TIME_NEVER -/// \li \c H5D_FILL_TIME_ALLOC. -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for fill value writing time include +/// \li \c H5D_FILL_TIME_NEVER +/// \li \c H5D_FILL_TIME_ALLOC. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const { - herr_t ret_value = H5Pset_fill_time(id, fill_time); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setFillTime", + herr_t ret_value = H5Pset_fill_time(id, fill_time); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setFillTime", "H5Pset_fill_time failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setFletcher32 -///\brief Sets Fletcher32 checksum of EDC for this property list. +// Function: DSetCreatPropList::setFletcher32 +///\brief Sets Fletcher32 checksum of EDC for this property list. /// -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::setFletcher32() const { - herr_t ret_value = H5Pset_fletcher32(id); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setFletcher32", + herr_t ret_value = H5Pset_fletcher32(id); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setFletcher32", "H5Pset_fletcher32 failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::setExternal -///\brief Adds an external file to the list of external files -///\param name - IN: Name of the external file -///\param offset - IN: Location where the data starts in the file -///\param size - IN: Number of bytes reserved in the file for the data -///\exception H5::PropListIException +// Function: DSetCreatPropList::setExternal +///\brief Adds an external file to the list of external files +///\param name - IN: Name of the external file +///\param offset - IN: Location where the data starts in the file +///\param size - IN: Number of bytes reserved in the file for the data +///\exception H5::PropListIException ///\par Description -/// If a dataset is splitted across multiple files then the files -/// should be defined in order. The total size of the dataset is -/// the sum of the \a size arguments for all the external files. If -/// the total size is larger than the size of a dataset then the -/// dataset can be extended (provided the data space also allows -/// the extending). -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DSetCreatPropList::setExternal( const char* name, off_t offset, hsize_t size ) const +/// If a dataset is splitted across multiple files then the files +/// should be defined in order. The total size of the dataset is +/// the sum of the \a size arguments for all the external files. If +/// the total size is larger than the size of a dataset then the +/// dataset can be extended (provided the data space also allows +/// the extending). +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size) const { - herr_t ret_value = H5Pset_external( id, name, offset, size ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::setExternal", + herr_t ret_value = H5Pset_external(id, name, offset, size); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setExternal", "H5Pset_external failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getExternalCount -///\brief Returns the number of external files for a dataset -///\return Number of external files -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetCreatPropList::getExternalCount +///\brief Returns the number of external files for a dataset +///\return Number of external files +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int DSetCreatPropList::getExternalCount() const { - int num_ext_files = H5Pget_external_count( id ); - if( num_ext_files < 0 ) - { - throw PropListIException("DSetCreatPropList::getExternalCount", + int num_ext_files = H5Pget_external_count(id); + if (num_ext_files < 0) + { + throw PropListIException("DSetCreatPropList::getExternalCount", "H5Pget_external_count returns negative number of external files"); - } - else - return( num_ext_files ); + } + else + return(num_ext_files); } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList::getExternal -///\brief Returns information about an external file -///\param idx - IN: Index of the external file, ranges [0-(N-1)] and -/// returned by getExternalCount() -///\param name_size - IN: Maximum length of \a name -///\param name - OUT: Name of the external file -///\param offset - OUT: Location to return an offset value -///\param size - OUT: Location to return the size of the external file data -///\exception H5::PropListIException +// Function: DSetCreatPropList::getExternal +///\brief Returns information about an external file +///\param idx - IN: Index of the external file, ranges [0-(N-1)] and +/// returned by getExternalCount() +///\param name_size - IN: Maximum length of \a name +///\param name - OUT: Name of the external file +///\param offset - OUT: Location to return an offset value +///\param size - OUT: Location to return the size of the external file data +///\exception H5::PropListIException ///\par Description -/// The parameter \a idx ranges [0..N-1] where N is returned by -/// getExternalCount(). At most \a name_size characters are copied -/// into the name array. If the external file name is longer than -/// name_size with the null terminator, the return value is not -/// null terminated (similar to strncpy()). -/// If \a name_size is zero or \a name is a null pointer, the -/// external file name will not be returned. If \a offset or -/// \a size are null pointers then the corresponding information -/// will not be returned. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void DSetCreatPropList::getExternal( unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size ) const +/// The parameter \a idx ranges [0..N-1] where N is returned by +/// getExternalCount(). At most \a name_size characters are copied +/// into the name array. If the external file name is longer than +/// name_size with the null terminator, the return value is not +/// null terminated (similar to strncpy()). +/// If \a name_size is zero or \a name is a null pointer, the +/// external file name will not be returned. If \a offset or +/// \a size are null pointers then the corresponding information +/// will not be returned. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const { - herr_t ret_value = H5Pget_external( id, idx, name_size, name, &offset, &size ); - if( ret_value < 0 ) - { - throw PropListIException("DSetCreatPropList::getExternal", + herr_t ret_value = H5Pget_external(id, idx, name_size, name, &offset, &size); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::getExternal", "H5Pget_external failed"); - } + } } //-------------------------------------------------------------------------- -// Function: DSetCreatPropList destructor -///\brief Noop destructor. +// Function: DSetCreatPropList destructor +///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::~DSetCreatPropList () {} +DSetCreatPropList::~DSetCreatPropList() {} } // end namespace diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 60ce1d5..b536709 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -29,105 +29,105 @@ class DataType; */ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { public: - ///\brief Default dataset creation property list. - static const DSetCreatPropList& DEFAULT; + ///\brief Default dataset creation property list. + static const DSetCreatPropList& DEFAULT; - // Creates a dataset creation property list. - DSetCreatPropList(); + // Creates a dataset creation property list. + DSetCreatPropList(); - // Queries whether all the filters set in this property list are - // available currently. - bool allFiltersAvail() const; + // Queries whether all the filters set in this property list are + // available currently. + bool allFiltersAvail() const; - // Get space allocation time for this property. - H5D_alloc_time_t getAllocTime() const; + // Get space allocation time for this property. + H5D_alloc_time_t getAllocTime() const; - // Set space allocation time for dataset during creation. - void setAllocTime(H5D_alloc_time_t alloc_time) const; + // Set space allocation time for dataset during creation. + void setAllocTime(H5D_alloc_time_t alloc_time) const; - // Retrieves the size of the chunks used to store a chunked layout dataset. - int getChunk( int max_ndims, hsize_t* dim ) const; + // Retrieves the size of the chunks used to store a chunked layout dataset. + int getChunk(int max_ndims, hsize_t* dim) const; - // Sets the size of the chunks used to store a chunked layout dataset. - void setChunk( int ndims, const hsize_t* dim ) const; + // Sets the size of the chunks used to store a chunked layout dataset. + void setChunk(int ndims, const hsize_t* dim) const; - // Returns information about an external file. - void getExternal( unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size ) const; + // Returns information about an external file. + void getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const; - // Returns the number of external files for a dataset. - int getExternalCount() const; + // Returns the number of external files for a dataset. + int getExternalCount() const; - // Gets fill value writing time. - H5D_fill_time_t getFillTime() const; + // Gets fill value writing time. + H5D_fill_time_t getFillTime() const; - // Sets fill value writing time for dataset. - void setFillTime(H5D_fill_time_t fill_time) const; + // Sets fill value writing time for dataset. + void setFillTime(H5D_fill_time_t fill_time) const; - // Retrieves a dataset fill value. - void getFillValue( const DataType& fvalue_type, void* value ) const; + // Retrieves a dataset fill value. + void getFillValue(const DataType& fvalue_type, void* value) const; - // Sets a dataset fill value. - void setFillValue( const DataType& fvalue_type, const void* value ) const; + // Sets a dataset fill value. + void setFillValue(const DataType& fvalue_type, const void* value) const; - // Returns information about a filter in a pipeline. - H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline. + H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; - // Returns information about a filter in a pipeline given the filter id. - void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline given the filter id. + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; - // Gets the layout of the raw data storage of the data that uses this - // property list. - H5D_layout_t getLayout() const; + // Gets the layout of the raw data storage of the data that uses this + // property list. + H5D_layout_t getLayout() const; - // Sets the type of storage used to store the raw data for the - // dataset that uses this property list. - void setLayout(H5D_layout_t layout) const; + // Sets the type of storage used to store the raw data for the + // dataset that uses this property list. + void setLayout(H5D_layout_t layout) const; - // Returns the number of filters in the pipeline. - int getNfilters() const; + // Returns the number of filters in the pipeline. + int getNfilters() const; - // Checks if fill value has been defined for this property. - H5D_fill_value_t isFillValueDefined() const; + // Checks if fill value has been defined for this property. + H5D_fill_value_t isFillValueDefined() const; - // Modifies the specified filter. - void modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const; + // Modifies the specified filter. + void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[]) const; - // Remove one or all filters from the filter pipeline. - void removeFilter( H5Z_filter_t filter_id) const; + // Remove one or all filters from the filter pipeline. + void removeFilter(H5Z_filter_t filter_id) const; - // Sets compression method and compression level. - void setDeflate( int level ) const; + // Sets compression method and compression level. + void setDeflate(int level) const; - // Adds an external file to the list of external files. - void setExternal( const char* name, off_t offset, hsize_t size ) const; + // Adds an external file to the list of external files. + void setExternal(const char* name, off_t offset, hsize_t size) const; - // Adds a filter to the filter pipeline. - void setFilter( H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, const unsigned int cd_values[] = NULL) const; + // Adds a filter to the filter pipeline. + void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, const unsigned int cd_values[] = NULL) const; - // Sets Fletcher32 checksum of EDC for this property list. - void setFletcher32() const; + // Sets Fletcher32 checksum of EDC for this property list. + void setFletcher32() const; - // Sets method of the shuffle filter. - void setShuffle() const; + // Sets method of the shuffle filter. + void setShuffle() const; - // Sets SZIP compression method. - void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; + // Sets SZIP compression method. + void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; - // Sets N-bit compression method. - void setNbit() const; + // Sets N-bit compression method. + void setNbit() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DSetCreatPropList"); } - // Copy constructor: creates a copy of a DSetCreatPropList object. - DSetCreatPropList(const DSetCreatPropList& orig); + // Copy constructor: creates a copy of a DSetCreatPropList object. + DSetCreatPropList(const DSetCreatPropList& orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetCreatPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetCreatPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetCreatPropList(); + // Noop destructor. + virtual ~DSetCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -135,7 +135,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { static void deleteConstants(); private: - static DSetCreatPropList* DEFAULT_; + static DSetCreatPropList* DEFAULT_; // Creates the global constant, should only be used by the library static DSetCreatPropList* getConstant(); diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 8746d35..e018ff2 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -15,7 +15,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -36,7 +36,7 @@ DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; // Function: DSetMemXferPropList::getConstant // Creates a DSetMemXferPropList object representing the HDF5 // constant H5P_DATASET_XFER, pointed to by -// DSetMemXferPropList::DEFAULT_ +// DSetMemXferPropList::DEFAULT_ // exception H5::PropListIException // Description // If DSetMemXferPropList::DEFAULT_ already points to an allocated @@ -76,25 +76,25 @@ void DSetMemXferPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose Constant for default dataset memory and transfer property list. +// Purpose Constant for default dataset memory and transfer property list. //-------------------------------------------------------------------------- const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function DSetMemXferPropList default constructor -///\brief Default constructor: creates a stub dataset memory and -/// transfer property list object. -// Programmer: Binh-Minh Ribler - 2000 +// Function DSetMemXferPropList default constructor +///\brief Default constructor: creates a stub dataset memory and +/// transfer property list object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} //-------------------------------------------------------------------------- -// Function DSetMemXferPropList constructor -///\brief Creates a dataset transfer property list with transform -/// expression. -// Programmer: Binh-Minh Ribler - 2000 +// Function DSetMemXferPropList constructor +///\brief Creates a dataset transfer property list with transform +/// expression. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET_XFER) { @@ -102,164 +102,164 @@ DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET } //-------------------------------------------------------------------------- -// Function DSetMemXferPropList copy constructor -///\brief Copy constructor: makes a copy of the original -/// DSetMemXferPropList object -///\param original - IN: Original dataset memory and transfer property -/// list object to copy -// Programmer: Binh-Minh Ribler - 2000 +// Function DSetMemXferPropList copy constructor +///\brief Copy constructor: makes a copy of the original +/// DSetMemXferPropList object +///\param original - IN: Original dataset memory and transfer property +/// list object to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original ) : PropList( original ) {} +DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : PropList(original ) {} //-------------------------------------------------------------------------- -// Function DSetMemXferPropList overloaded constructor -///\brief Creates a DSetMemXferPropList object using the id of an -/// existing DSetMemXferPropList. -///\param plist_id - IN: Id of an existing dataset memory and transfer -/// property list -// Programmer: Binh-Minh Ribler - 2000 +// Function DSetMemXferPropList overloaded constructor +///\brief Creates a DSetMemXferPropList object using the id of an +/// existing DSetMemXferPropList. +///\param plist_id - IN: Id of an existing dataset memory and transfer +/// property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) {} //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setBuffer -///\brief Sets type conversion and background buffers. -///\param size - IN: Size, in bytes, of the type conversion and background buffers -///\param tconv - IN: Pointer to application-allocated type conversion buffer -///\param bkg - IN: Pointer to application-allocated background buffer -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::setBuffer +///\brief Sets type conversion and background buffers. +///\param size - IN: Size, in bytes, of the type conversion and background buffers +///\param tconv - IN: Pointer to application-allocated type conversion buffer +///\param bkg - IN: Pointer to application-allocated background buffer +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const +void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const { - herr_t ret_value = H5Pset_buffer( id, size, tconv, bkg ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setBuffer", - "H5Pset_buffer failed"); - } + herr_t ret_value = H5Pset_buffer(id, size, tconv, bkg); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setBuffer", + "H5Pset_buffer failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getBuffer -///\brief Reads buffer settings. -///\param tconv - OUT: Pointer to application-allocated type conversion buf -///\param bkg - OUT: Pointer to application-allocated background buffer -///\return Buffer size, in bytes -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::getBuffer +///\brief Reads buffer settings. +///\param tconv - OUT: Pointer to application-allocated type conversion buf +///\param bkg - OUT: Pointer to application-allocated background buffer +///\return Buffer size, in bytes +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const +size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const { - size_t buffer_size = H5Pget_buffer( id, tconv, bkg ); - if( buffer_size == 0 ) - { - throw PropListIException("DSetMemXferPropList::getBuffer", - "H5Pget_buffer returned 0 for buffer size - failure"); - } - return( buffer_size ); + size_t buffer_size = H5Pget_buffer(id, tconv, bkg); + if(buffer_size == 0) + { + throw PropListIException("DSetMemXferPropList::getBuffer", + "H5Pget_buffer returned 0 for buffer size - failure"); + } + return(buffer_size); } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setPreserve -///\brief Sets the dataset transfer property list status to true or false. -///\param status - IN: Status to set, true or false -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::setPreserve +///\brief Sets the dataset transfer property list status to true or false. +///\param status - IN: Status to set, true or false +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setPreserve( bool status ) const +void DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve( id, (hbool_t) status ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setPreserve", - "H5Pset_preserve failed"); - } + herr_t ret_value = H5Pset_preserve(id, (hbool_t) status); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setPreserve", + "H5Pset_preserve failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getPreserve -///\brief Checks status of the dataset transfer property list. -///\return Status of the dataset transfer property list -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::getPreserve +///\brief Checks status of the dataset transfer property list. +///\return Status of the dataset transfer property list +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool DSetMemXferPropList::getPreserve() const { - int ret_value = H5Pget_preserve( id ); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw PropListIException("DSetMemXferPropList::getPreserve", - "H5Pget_preserve returned negative value for status"); - } + int ret_value = H5Pget_preserve(id); + if(ret_value > 0) + return true; + else if(ret_value == 0) + return false; + else + { + throw PropListIException("DSetMemXferPropList::getPreserve", + "H5Pget_preserve returned negative value for status"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setBtreeRatios -///\brief Sets B-tree split ratios for a dataset transfer property list. -///\param left - IN: B-tree split ratio for left-most nodes -///\param middle - IN: B-tree split ratio for right-most nodes and lone nodes -///\param right - IN: B-tree split ratio for all other nodes -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::setBtreeRatios +///\brief Sets B-tree split ratios for a dataset transfer property list. +///\param left - IN: B-tree split ratio for left-most nodes +///\param middle - IN: B-tree split ratio for right-most nodes and lone nodes +///\param right - IN: B-tree split ratio for all other nodes +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBtreeRatios( double left, double middle, double right ) const +void DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const { - herr_t ret_value = H5Pset_btree_ratios( id, left, middle, right ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setBtreeRatios", - "H5Pset_btree_ratios failed"); - } + herr_t ret_value = H5Pset_btree_ratios(id, left, middle, right); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setBtreeRatios", + "H5Pset_btree_ratios failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getBtreeRatios -///\brief Gets B-tree split ratios for a dataset transfer property list. -///\param left - OUT: B-tree split ratio for left-most nodes -///\param middle - OUT: B-tree split ratio for right-most nodes and lone nodes -///\param right - OUT: B-tree split ratio for all other nodes -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::getBtreeRatios +///\brief Gets B-tree split ratios for a dataset transfer property list. +///\param left - OUT: B-tree split ratio for left-most nodes +///\param middle - OUT: B-tree split ratio for right-most nodes and lone nodes +///\param right - OUT: B-tree split ratio for all other nodes +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getBtreeRatios( double& left, double& middle, double& right ) const +void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& right) const { - herr_t ret_value = H5Pget_btree_ratios( id, &left, &middle, &right ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::getBtreeRatios", - "H5Pget_btree_ratios failed"); - } + herr_t ret_value = H5Pget_btree_ratios(id, &left, &middle, &right); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getBtreeRatios", + "H5Pget_btree_ratios failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setDataTransform -///\brief Sets data transform expression. -///\param expression - IN: null-terminated data transform expression (char*) -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - Mar, 2014 +// Function: DSetMemXferPropList::setDataTransform +///\brief Sets data transform expression. +///\param expression - IN: null-terminated data transform expression (char*) +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- void DSetMemXferPropList::setDataTransform(const char* expression) const { - herr_t ret_value = H5Pset_data_transform( id, expression); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setDataTransform", - "H5Pset_data_transform failed"); - } + herr_t ret_value = H5Pset_data_transform(id, expression); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setDataTransform", + "H5Pset_data_transform failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setDataTransform -///\brief This is an overloaded member function, provided for convenience. -/// It takes a reference to a \c H5std_string for the expression. -///\param expression - IN: H5std_string data transform expression -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - Mar, 2014 +// Function: DSetMemXferPropList::setDataTransform +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the expression. +///\param expression - IN: H5std_string data transform expression +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const { @@ -267,13 +267,13 @@ void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getDataTransform -///\brief Sets data transform expression. -///\param exp - OUT: buffer for data transform expression (char*) -///\param buf_size - IN: size of buffer for expression, including the -/// null terminator -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - Mar, 2014 +// Function: DSetMemXferPropList::getDataTransform +///\brief Sets data transform expression. +///\param exp - OUT: buffer for data transform expression (char*) +///\param buf_size - IN: size of buffer for expression, including the +/// null terminator +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const { @@ -285,8 +285,8 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const // H5Pget_data_transform returns a negative value, raise an exception if (exp_len < 0) { - throw PropListIException("DSetMemXferPropList::getDataTransform", - "H5Pget_data_transform failed"); + throw PropListIException("DSetMemXferPropList::getDataTransform", + "H5Pget_data_transform failed"); } // H5Pget_data_transform will put a null terminator at the end of the @@ -298,11 +298,11 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getDataTransform -///\brief This is an overloaded member function, provided for convenience. -/// It takes no parameter and returns a \c H5std_string for the expression. -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - Mar, 2014 +// Function: DSetMemXferPropList::getDataTransform +///\brief This is an overloaded member function, provided for convenience. +/// It takes no parameter and returns a \c H5std_string for the expression. +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- H5std_string DSetMemXferPropList::getDataTransform() const { @@ -340,226 +340,226 @@ H5std_string DSetMemXferPropList::getDataTransform() const } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getTypeConvCB -///\brief Sets an exception handling callback for datatype conversion -/// for a dataset transfer property list. -///\param op - IN: User's function -///\param user_data - IN: User's data -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: DSetMemXferPropList::getTypeConvCB +///\brief Sets an exception handling callback for datatype conversion +/// for a dataset transfer property list. +///\param op - IN: User's function +///\param user_data - IN: User's data +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setTypeConvCB( H5T_conv_except_func_t op, void *user_data) const +void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const { - herr_t ret_value = H5Pset_type_conv_cb( id, op, user_data); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setTypeConvCB", - "H5Pset_type_conv_cb failed"); - } + herr_t ret_value = H5Pset_type_conv_cb(id, op, user_data); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setTypeConvCB", + "H5Pset_type_conv_cb failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getTypeConvCB -///\brief Gets the exception handling callback function and data. -///\param op - IN: Retrieved user function -///\param user_data - IN: Retrieved user data -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: DSetMemXferPropList::getTypeConvCB +///\brief Gets the exception handling callback function and data. +///\param op - IN: Retrieved user function +///\param user_data - IN: Retrieved user data +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getTypeConvCB( H5T_conv_except_func_t *op, void **user_data) const +void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const { - herr_t ret_value = H5Pget_type_conv_cb( id, op, user_data); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::getTypeConvCB", - "H5Pget_type_conv_cb failed"); - } + herr_t ret_value = H5Pget_type_conv_cb(id, op, user_data); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getTypeConvCB", + "H5Pget_type_conv_cb failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setVlenMemManager -///\brief Sets the memory manager for variable-length datatype allocation. -///\param alloc_func - IN: User's allocate routine -///\param alloc_info - IN: User's allocation parameters -///\param free_func - IN: User's free routine -///\param free_info - IN: User's free parameters -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::setVlenMemManager +///\brief Sets the memory manager for variable-length datatype allocation. +///\param alloc_func - IN: User's allocate routine +///\param alloc_info - IN: User's allocation parameters +///\param free_func - IN: User's free routine +///\param free_info - IN: User's free parameters +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager( H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info ) const +void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info) const { - herr_t ret_value = H5Pset_vlen_mem_manager( id, alloc_func, alloc_info, - free_func, free_info ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::setVlenMemManager", - "H5Pset_vlen_mem_manager failed"); - } + herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, + free_func, free_info); + if(ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setVlenMemManager", + "H5Pset_vlen_mem_manager failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setVlenMemManager -///\brief Sets the memory manager for variable-length datatype -/// allocation - system \c malloc and \c free will be used. +// Function: DSetMemXferPropList::setVlenMemManager +///\brief Sets the memory manager for variable-length datatype +/// allocation - system \c malloc and \c free will be used. /// -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetMemXferPropList::setVlenMemManager() const { - setVlenMemManager( NULL, NULL, NULL, NULL ); + setVlenMemManager(NULL, NULL, NULL, NULL); } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getVlenMemManager -///\brief Gets the memory manager for variable-length datatype allocation -///\param alloc_func - OUT: User's allocate routine -///\param alloc_info - OUT: User's allocation parameters -///\param free_func - OUT: User's free routine -///\param free_info - OUT: User's free parameters -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList::getVlenMemManager +///\brief Gets the memory manager for variable-length datatype allocation +///\param alloc_func - OUT: User's allocate routine +///\param alloc_info - OUT: User's allocation parameters +///\param free_func - OUT: User's free routine +///\param free_info - OUT: User's free parameters +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info ) const +void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info) const { - herr_t ret_value = H5Pget_vlen_mem_manager( id, &alloc_func, alloc_info, &free_func, free_info ); - if( ret_value < 0 ) - { - throw PropListIException("DSetMemXferPropList::getVlenMemManager", - "H5Pget_vlen_mem_manager failed"); - } + herr_t ret_value = H5Pget_vlen_mem_manager(id, &alloc_func, alloc_info, &free_func, free_info); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getVlenMemManager", + "H5Pget_vlen_mem_manager failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setSmallDataBlockSize -///\brief Sets the size of a contiguous block reserved for small data. -///\param size - IN: Maximum size, in bytes, of the small data block. -///\exception H5::PropListIException +// Function: DSetMemXferPropList::setSmallDataBlockSize +///\brief Sets the size of a contiguous block reserved for small data. +///\param size - IN: Maximum size, in bytes, of the small data block. +///\exception H5::PropListIException ///\par Description -/// For detail, please refer to the C layer Reference Manual at: +/// For detail, please refer to the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSmallData -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const { - herr_t ret_value = H5Pset_small_data_block_size(id, size); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", - "H5Pset_small_data_block_size failed"); - } + herr_t ret_value = H5Pset_small_data_block_size(id, size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", + "H5Pset_small_data_block_size failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getSmallDataBlockSize -///\brief Returns the current small data block size setting. -///\return Size of the small data block, in bytes -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: DSetMemXferPropList::getSmallDataBlockSize +///\brief Returns the current small data block size setting. +///\return Size of the small data block, in bytes +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- hsize_t DSetMemXferPropList::getSmallDataBlockSize() const { - hsize_t size; - herr_t ret_value = H5Pget_small_data_block_size(id, &size); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", - "H5Pget_small_data_block_size failed"); - } - return(size); + hsize_t size; + herr_t ret_value = H5Pget_small_data_block_size(id, &size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", + "H5Pget_small_data_block_size failed"); + } + return(size); } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setHyperVectorSize -///\brief Sets number of I/O vectors to be read/written in hyperslab I/O. +// Function: DSetMemXferPropList::setHyperVectorSize +///\brief Sets number of I/O vectors to be read/written in hyperslab I/O. /// -///\exception H5::PropListIException +///\exception H5::PropListIException ///\par Description -/// For information, please refer to the C layer Reference -/// Manual at: +/// For information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetHyperVectorSize -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const { - herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setHyperVectorSize", - "H5Pset_hyper_vector_size failed"); - } + herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setHyperVectorSize", + "H5Pset_hyper_vector_size failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getHyperVectorSize -///\brief Returns the number of I/O vectors to be read/written in -/// hyperslab I/O. -///\return Number of I/O vectors -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: DSetMemXferPropList::getHyperVectorSize +///\brief Returns the number of I/O vectors to be read/written in +/// hyperslab I/O. +///\return Number of I/O vectors +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t DSetMemXferPropList::getHyperVectorSize() const { - size_t vector_size; - herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getHyperVectorSize", - "H5Pget_hyper_vector_size failed"); - } - return(vector_size); + size_t vector_size; + herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getHyperVectorSize", + "H5Pget_hyper_vector_size failed"); + } + return(vector_size); } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::setEDCCheck -///\brief Enables or disables error-detecting for a dataset reading -/// process. -///\param check - IN: Specifies whether error detection is enabled or -/// disabled -///\exception H5::PropListIException +// Function: DSetMemXferPropList::setEDCCheck +///\brief Enables or disables error-detecting for a dataset reading +/// process. +///\param check - IN: Specifies whether error detection is enabled or +/// disabled +///\exception H5::PropListIException ///\par Description -/// The error detection algorithm used is the algorithm previously -/// specified in the corresponding dataset creation property -/// list. This function does not affect the use of error -/// detection in the writing process. +/// The error detection algorithm used is the algorithm previously +/// specified in the corresponding dataset creation property +/// list. This function does not affect the use of error +/// detection in the writing process. ///\par -/// Valid values are as follows: -/// \li \c H5Z_ENABLE_EDC (default) -/// \li \c H5Z_DISABLE_EDC -// Programmer: Binh-Minh Ribler - April, 2004 +/// Valid values are as follows: +/// \li \c H5Z_ENABLE_EDC (default) +/// \li \c H5Z_DISABLE_EDC +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const { - herr_t ret_value = H5Pset_edc_check(id, check); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setEDCCheck", - "H5Pset_edc_check failed"); - } + herr_t ret_value = H5Pset_edc_check(id, check); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setEDCCheck", + "H5Pset_edc_check failed"); + } } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList::getEDCCheck -///\brief Determines whether error-detection is enabled for dataset reads. -///\return \c H5Z_ENABLE_EDC or \c H5Z_DISABLE_EDC -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: DSetMemXferPropList::getEDCCheck +///\brief Determines whether error-detection is enabled for dataset reads. +///\return \c H5Z_ENABLE_EDC or \c H5Z_DISABLE_EDC +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const { - H5Z_EDC_t check = H5Pget_edc_check(id); - if (check < 0) - { - throw PropListIException("DSetMemXferPropList::getEDCCheck", - "H5Pget_edc_check failed"); - } - return(check); + H5Z_EDC_t check = H5Pget_edc_check(id); + if (check < 0) + { + throw PropListIException("DSetMemXferPropList::getEDCCheck", + "H5Pget_edc_check failed"); + } + return(check); } //-------------------------------------------------------------------------- -// Function: DSetMemXferPropList destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: DSetMemXferPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- DSetMemXferPropList::~DSetMemXferPropList() {} diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 42194fb..f1c363f 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -27,93 +27,93 @@ namespace H5 { */ class H5_DLLCPP DSetMemXferPropList : public PropList { public: - ///\brief Default dataset memory and transfer property list. - static const DSetMemXferPropList& DEFAULT; + ///\brief Default dataset memory and transfer property list. + static const DSetMemXferPropList& DEFAULT; - // Creates a dataset memory and transfer property list. - DSetMemXferPropList(); + // Creates a dataset memory and transfer property list. + DSetMemXferPropList(); - // Creates a dataset transform property list. - DSetMemXferPropList(const char* expression); + // Creates a dataset transform property list. + DSetMemXferPropList(const char* expression); - // Sets type conversion and background buffers. - void setBuffer( size_t size, void* tconv, void* bkg ) const; + // Sets type conversion and background buffers. + void setBuffer(size_t size, void* tconv, void* bkg) const; - // Reads buffer settings. - size_t getBuffer( void** tconv, void** bkg ) const; + // Reads buffer settings. + size_t getBuffer(void** tconv, void** bkg) const; - // Sets B-tree split ratios for a dataset transfer property list. - void setBtreeRatios( double left, double middle, double right ) const; + // Sets B-tree split ratios for a dataset transfer property list. + void setBtreeRatios(double left, double middle, double right) const; - // Gets B-tree split ratios for a dataset transfer property list. - void getBtreeRatios( double& left, double& middle, double& right ) const; + // Gets B-tree split ratios for a dataset transfer property list. + void getBtreeRatios(double& left, double& middle, double& right) const; - // Sets data transform expression. - void setDataTransform(const char* expression) const; - void setDataTransform(const H5std_string& expression) const; + // Sets data transform expression. + void setDataTransform(const char* expression) const; + void setDataTransform(const H5std_string& expression) const; - // Gets data transform expression. - ssize_t getDataTransform(char* exp, size_t buf_size=0) const; - H5std_string getDataTransform() const; + // Gets data transform expression. + ssize_t getDataTransform(char* exp, size_t buf_size=0) const; + H5std_string getDataTransform() const; - // Sets the dataset transfer property list status to TRUE or FALSE. - void setPreserve( bool status ) const; + // Sets the dataset transfer property list status to TRUE or FALSE. + void setPreserve(bool status) const; - // Checks status of the dataset transfer property list. - bool getPreserve() const; + // Checks status of the dataset transfer property list. + bool getPreserve() const; - // Sets an exception handling callback for datatype conversion. - void setTypeConvCB( H5T_conv_except_func_t op, void *user_data) const; + // Sets an exception handling callback for datatype conversion. + void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; - // Gets the exception handling callback for datatype conversion. - void getTypeConvCB( H5T_conv_except_func_t *op, void **user_data) const; + // Gets the exception handling callback for datatype conversion. + void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; - // Sets the memory manager for variable-length datatype - // allocation in H5Dread and H5Dvlen_reclaim. - void setVlenMemManager( H5MM_allocate_t alloc, void* alloc_info, - H5MM_free_t free, void* free_info ) const; + // Sets the memory manager for variable-length datatype + // allocation in H5Dread and H5Dvlen_reclaim. + void setVlenMemManager(H5MM_allocate_t alloc, void* alloc_info, + H5MM_free_t free, void* free_info) const; - // alloc and free are set to NULL, indicating that system - // malloc and free are to be used. - void setVlenMemManager() const; + // alloc and free are set to NULL, indicating that system + // malloc and free are to be used. + void setVlenMemManager() const; - // Gets the memory manager for variable-length datatype - // allocation in H5Dread and H5Tvlen_reclaim. - void getVlenMemManager( H5MM_allocate_t& alloc, void** alloc_info, - H5MM_free_t& free, void** free_info ) const; + // Gets the memory manager for variable-length datatype + // allocation in H5Dread and H5Tvlen_reclaim. + void getVlenMemManager(H5MM_allocate_t& alloc, void** alloc_info, + H5MM_free_t& free, void** free_info) const; - // Sets the size of a contiguous block reserved for small data. - void setSmallDataBlockSize(hsize_t size) const; + // Sets the size of a contiguous block reserved for small data. + void setSmallDataBlockSize(hsize_t size) const; - // Returns the current small data block size setting. - hsize_t getSmallDataBlockSize() const; + // Returns the current small data block size setting. + hsize_t getSmallDataBlockSize() const; - // Sets number of I/O vectors to be read/written in hyperslab I/O. - void setHyperVectorSize(size_t vector_size) const; + // Sets number of I/O vectors to be read/written in hyperslab I/O. + void setHyperVectorSize(size_t vector_size) const; - // Returns the number of I/O vectors to be read/written in - // hyperslab I/O. - size_t getHyperVectorSize() const; + // Returns the number of I/O vectors to be read/written in + // hyperslab I/O. + size_t getHyperVectorSize() const; - // Enables or disables error-detecting for a dataset reading - // process. - void setEDCCheck(H5Z_EDC_t check) const; + // Enables or disables error-detecting for a dataset reading + // process. + void setEDCCheck(H5Z_EDC_t check) const; - // Determines whether error-detection is enabled for dataset reads. - H5Z_EDC_t getEDCCheck() const; + // Determines whether error-detection is enabled for dataset reads. + H5Z_EDC_t getEDCCheck() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } - // Copy constructor: makes a copy of a DSetMemXferPropList object. - DSetMemXferPropList(const DSetMemXferPropList& orig); + // Copy constructor: makes a copy of a DSetMemXferPropList object. + DSetMemXferPropList(const DSetMemXferPropList& orig); - // Creates a copy of an existing dataset memory and transfer - // property list using the property list id. - DSetMemXferPropList(const hid_t plist_id); + // Creates a copy of an existing dataset memory and transfer + // property list using the property list id. + DSetMemXferPropList(const hid_t plist_id); - // Noop destructor - virtual ~DSetMemXferPropList(); + // Noop destructor + virtual ~DSetMemXferPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -121,7 +121,7 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { static void deleteConstants(); private: - static DSetMemXferPropList* DEFAULT_; + static DSetMemXferPropList* DEFAULT_; // Creates the global constant, should only be used by the library static DSetMemXferPropList* getConstant(); diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 5e1f0bd..49f60e6 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -15,7 +15,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -37,230 +37,230 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: EnumType default constructor -///\brief Default constructor: Creates a stub datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType default constructor +///\brief Default constructor: Creates a stub datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- EnumType::EnumType() : DataType() {} //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Creates an EnumType object using the id of an existing datatype. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType overloaded constructor +///\brief Creates an EnumType object using the id of an existing datatype. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType( const hid_t existing_id ) : DataType( existing_id ) {} +EnumType::EnumType(const hid_t existing_id) : DataType( existing_id ) {} //-------------------------------------------------------------------------- -// Function: EnumType copy constructor -///\brief Copy constructor: makes a copy of the original EnumType object. -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType copy constructor +///\brief Copy constructor: makes a copy of the original EnumType object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType( const EnumType& original ) : DataType( original ) {} +EnumType::EnumType(const EnumType& original) : DataType( original ) {} //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Creates an empty enumeration datatype given a size, in bytes. -///\param size - IN: Number of bytes in the datatype to create -///\exception H5::DataTypeIException +// Function: EnumType overloaded constructor +///\brief Creates an empty enumeration datatype given a size, in bytes. +///\param size - IN: Number of bytes in the datatype to create +///\exception H5::DataTypeIException // Description -// The DataType constructor calls the C API H5Tcreate to create -// the enum datatype. -// Programmer Binh-Minh Ribler - 2000 +// The DataType constructor calls the C API H5Tcreate to create +// the enum datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType( size_t size ) : DataType( H5T_ENUM, size ) {} +EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Gets the enum datatype of the specified dataset. -///\param dataset - IN: Dataset that this enum datatype associates with -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType overloaded constructor +///\brief Gets the enum datatype of the specified dataset. +///\param dataset - IN: Dataset that this enum datatype associates with +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType( const DataSet& dataset ) : DataType() +EnumType::EnumType(const DataSet& dataset) : DataType() { - // Calls C function H5Dget_type to get the id of the datatype - id = H5Dget_type( dataset.getId() ); + // Calls C function H5Dget_type to get the id of the datatype + id = H5Dget_type(dataset.getId()); - // If the datatype id is not valid, throw an exception - if( id < 0 ) - { - throw DataSetIException("EnumType constructor", "H5Dget_type failed"); - } + // If the datatype id is not valid, throw an exception + if (id < 0) + { + throw DataSetIException("EnumType constructor", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Creates a new enum datatype based on an integer datatype. -///\param data_type - IN: Base datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType overloaded constructor +///\brief Creates a new enum datatype based on an integer datatype. +///\param data_type - IN: Base datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType( const IntType& data_type ) : DataType() +EnumType::EnumType(const IntType& data_type) : DataType() { - // Calls C function H5Tenum_create to get the id of the datatype - id = H5Tenum_create( data_type.getId() ); + // Calls C function H5Tenum_create to get the id of the datatype + id = H5Tenum_create(data_type.getId()); - // If the datatype id is not valid, throw an exception - if( id < 0 ) - { - throw DataSetIException("EnumType constructor", "H5Tenum_create failed"); - } + // If the datatype id is not valid, throw an exception + if (id < 0) + { + throw DataSetIException("EnumType constructor", "H5Tenum_create failed"); + } } //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Creates an EnumType instance by opening an HDF5 enum datatype -/// given its name, provided as a C character string. -///\param dtype_name - IN: Enum datatype name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: EnumType overloaded constructor +///\brief Creates an EnumType instance by opening an HDF5 enum datatype +/// given its name, provided as a C character string. +///\param dtype_name - IN: Enum datatype name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openEnumType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openEnumType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() { - id = p_opentype(loc, dtype_name); + id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Creates an EnumType instance by opening an HDF5 enum datatype -/// given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Enum datatype name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: EnumType overloaded constructor +///\brief Creates an EnumType instance by opening an HDF5 enum datatype +/// given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Enum datatype name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openEnumType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openEnumType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : DataType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: EnumType::insert -///\brief Inserts a new member to this enumeration datatype. -///\param name - IN: Name of the new member -///\param value - IN: Pointer to the value of the new member -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::insert +///\brief Inserts a new member to this enumeration datatype. +///\param name - IN: Name of the new member +///\param value - IN: Pointer to the value of the new member +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert( const char* name, void *value ) const +void EnumType::insert(const char* name, void *value) const { - // Calls C routine H5Tenum_insert to insert the new enum datatype member. - herr_t ret_value = H5Tenum_insert( id, name, value ); - if( ret_value < 0 ) - { - throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed"); - } + // Calls C routine H5Tenum_insert to insert the new enum datatype member. + herr_t ret_value = H5Tenum_insert(id, name, value); + if (ret_value < 0) + { + throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed"); + } } //-------------------------------------------------------------------------- -// Function: EnumType::insert -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::insert +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert( const H5std_string& name, void *value ) const +void EnumType::insert(const H5std_string& name, void *value) const { - insert( name.c_str(), value ); + insert(name.c_str(), value); } //-------------------------------------------------------------------------- -// Function: EnumType::nameOf -///\brief Returns the symbol name corresponding to a specified member -/// of this enumeration datatype. -///\param value - IN: Pointer to the value of the enum datatype -///\param size - IN: Size for the name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::nameOf +///\brief Returns the symbol name corresponding to a specified member +/// of this enumeration datatype. +///\param value - IN: Pointer to the value of the enum datatype +///\param size - IN: Size for the name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string EnumType::nameOf( void *value, size_t size ) const +H5std_string EnumType::nameOf(void *value, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for C API - HDmemset(name_C, 0, size+1); // clear buffer + char* name_C = new char[size+1]; // temporary C-string for C API + HDmemset(name_C, 0, size+1); // clear buffer - // Calls C routine H5Tenum_nameof to get the name of the specified enum type - herr_t ret_value = H5Tenum_nameof( id, value, name_C, size ); + // Calls C routine H5Tenum_nameof to get the name of the specified enum type + herr_t ret_value = H5Tenum_nameof(id, value, name_C, size); - // If H5Tenum_nameof returns a negative value, raise an exception, - if( ret_value < 0 ) - { + // If H5Tenum_nameof returns a negative value, raise an exception, + if (ret_value < 0) + { delete []name_C; - throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); - } - // otherwise, create the string to hold the datatype name and return it - H5std_string name(name_C); - delete []name_C; - return( name ); + throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); + } + // otherwise, create the string to hold the datatype name and return it + H5std_string name(name_C); + delete []name_C; + return(name); } //-------------------------------------------------------------------------- -// Function: EnumType::valueOf -///\brief Retrieves the value corresponding to a member of this -/// enumeration datatype, given the member's name. -///\param name - IN: Name of the queried member -///\param value - OUT: Pointer to the retrieved value -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::valueOf +///\brief Retrieves the value corresponding to a member of this +/// enumeration datatype, given the member's name. +///\param name - IN: Name of the queried member +///\param value - OUT: Pointer to the retrieved value +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf( const char* name, void *value ) const +void EnumType::valueOf(const char* name, void *value) const { - // Calls C routine H5Tenum_valueof to get the enum datatype value - herr_t ret_value = H5Tenum_valueof( id, name, value ); - if( ret_value < 0 ) - { - throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed"); - } + // Calls C routine H5Tenum_valueof to get the enum datatype value + herr_t ret_value = H5Tenum_valueof(id, name, value); + if (ret_value < 0) + { + throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed"); + } } //-------------------------------------------------------------------------- -// Function: EnumType::valueOf -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of -/// argument \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::valueOf +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf( const H5std_string& name, void *value ) const +void EnumType::valueOf(const H5std_string& name, void *value) const { - valueOf( name.c_str(), value ); + valueOf(name.c_str(), value); } //-------------------------------------------------------------------------- -// Function: EnumType::getMemberIndex -///\brief Returns the index of a member in this enumeration datatype. -///\param name - IN: Name of the queried member -///\return Index of the member if it exists. Index will have the value -/// between 0 and \c N-1, where \c N is the value returned by the -/// member function \c EnumType::getNmembers. -///\exception H5::DataTypeIException +// Function: EnumType::getMemberIndex +///\brief Returns the index of a member in this enumeration datatype. +///\param name - IN: Name of the queried member +///\return Index of the member if it exists. Index will have the value +/// between 0 and \c N-1, where \c N is the value returned by the +/// member function \c EnumType::getNmembers. +///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- int EnumType::getMemberIndex(const char *name) const { - int member_index = H5Tget_member_index(id, name); - if( member_index < 0 ) - { - throw DataTypeIException("EnumType::getMemberIndex", + int member_index = H5Tget_member_index(id, name); + if (member_index < 0) + { + throw DataTypeIException("EnumType::getMemberIndex", "H5Tget_member_index returns negative value"); - } - return( member_index ); + } + return(member_index); } //-------------------------------------------------------------------------- -// Function: EnumType::getMemberIndex -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in the type of -/// argument \a name. +// Function: EnumType::getMemberIndex +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of +/// argument \a name. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- int EnumType::getMemberIndex(const H5std_string& name) const @@ -269,46 +269,46 @@ int EnumType::getMemberIndex(const H5std_string& name) const } //-------------------------------------------------------------------------- -// Function: EnumType::getNmembers -///\brief Returns the number of members in this enumeration datatype. -///\return Number of members -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: EnumType::getNmembers +///\brief Returns the number of members in this enumeration datatype. +///\return Number of members +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- int EnumType::getNmembers() const { - int num_members = H5Tget_nmembers( id ); - if( num_members < 0 ) - { - throw DataTypeIException("EnumType::getNmembers", + int num_members = H5Tget_nmembers(id); + if (num_members < 0) + { + throw DataTypeIException("EnumType::getNmembers", "H5Tget_nmembers returns negative number of members"); - } - return( num_members ); + } + return(num_members); } //-------------------------------------------------------------------------- -// Function: EnumType::getMemberValue -///\brief Retrieves the value of a member in this enumeration datatype, -/// given the member's index. -///\param memb_no - IN: Index of the queried member -///\param value - OUT: Pointer to the retrieved value -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType::getMemberValue +///\brief Retrieves the value of a member in this enumeration datatype, +/// given the member's index. +///\param memb_no - IN: Index of the queried member +///\param value - OUT: Pointer to the retrieved value +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::getMemberValue( unsigned memb_no, void *value ) const +void EnumType::getMemberValue(unsigned memb_no, void *value) const { - // Call C routine H5Tget_member_value to get the datatype member's value - hid_t ret_value = H5Tget_member_value( id, memb_no, value ); - if( ret_value < 0 ) - { - throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed"); - } + // Call C routine H5Tget_member_value to get the datatype member's value + hid_t ret_value = H5Tget_member_value(id, memb_no, value); + if (ret_value < 0) + { + throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed"); + } } //-------------------------------------------------------------------------- -// Function: EnumType destructor -///\brief Properly terminates access to this enum datatype. -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType destructor +///\brief Properly terminates access to this enum datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- EnumType::~EnumType() {} diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 054811b..2fbe2cd 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -28,56 +28,56 @@ namespace H5 { class H5_DLLCPP EnumType : public DataType { public: - // Creates an empty enumeration datatype based on a native signed - // integer type, whose size is given by size. - EnumType( size_t size ); + // Creates an empty enumeration datatype based on a native signed + // integer type, whose size is given by size. + EnumType(size_t size); - // Gets the enum datatype of the specified dataset - EnumType( const DataSet& dataset ); // H5Dget_type + // Gets the enum datatype of the specified dataset + EnumType(const DataSet& dataset); // H5Dget_type - // Creates a new enum datatype based on an integer datatype - EnumType( const IntType& data_type ); // H5Tenum_create + // Creates a new enum datatype based on an integer datatype + EnumType(const IntType& data_type); // H5Tenum_create - // Constructors that open an enum datatype, given a location. - EnumType(const H5Location& loc, const char* name); - EnumType(const H5Location& loc, const H5std_string& name); + // Constructors that open an enum datatype, given a location. + EnumType(const H5Location& loc, const char* name); + EnumType(const H5Location& loc, const H5std_string& name); - // Returns the number of members in this enumeration datatype. - int getNmembers () const; + // Returns the number of members in this enumeration datatype. + int getNmembers () const; - // Returns the index of a member in this enumeration data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this enumeration data type. + int getMemberIndex(const char* name) const; + int getMemberIndex(const H5std_string& name) const; - // Returns the value of an enumeration datatype member - void getMemberValue( unsigned memb_no, void *value ) const; + // Returns the value of an enumeration datatype member + void getMemberValue(unsigned memb_no, void *value) const; - // Inserts a new member to this enumeration type. - void insert( const char* name, void *value ) const; - void insert( const H5std_string& name, void *value ) const; + // Inserts a new member to this enumeration type. + void insert(const char* name, void *value) const; + void insert(const H5std_string& name, void *value) const; - // Returns the symbol name corresponding to a specified member - // of this enumeration datatype. - H5std_string nameOf( void *value, size_t size ) const; + // Returns the symbol name corresponding to a specified member + // of this enumeration datatype. + H5std_string nameOf(void *value, size_t size) const; - // Returns the value corresponding to a specified member of this - // enumeration datatype. - void valueOf( const char* name, void *value ) const; - void valueOf( const H5std_string& name, void *value ) const; + // Returns the value corresponding to a specified member of this + // enumeration datatype. + void valueOf(const char* name, void *value) const; + void valueOf(const H5std_string& name, void *value) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("EnumType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("EnumType"); } - // Default constructor - EnumType(); + // Default constructor + EnumType(); - // Creates an enumeration datatype using an existing id - EnumType( const hid_t existing_id ); + // Creates an enumeration datatype using an existing id + EnumType(const hid_t existing_id); - // Copy constructor: makes a copy of the original EnumType object. - EnumType( const EnumType& original ); + // Copy constructor: makes a copy of the original EnumType object. + EnumType(const EnumType& original); - virtual ~EnumType(); + virtual ~EnumType(); }; } #endif // __H5EnumType_H diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 335bb20..0316f64 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -23,207 +23,207 @@ namespace H5 { const char Exception::DEFAULT_MSG[] = "No detailed information provided"; //-------------------------------------------------------------------------- -// Function: Exception default constructor -///\brief Default constructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception default constructor +///\brief Default constructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Exception::Exception() : detail_message(""), func_name("") {} //-------------------------------------------------------------------------- -// Function: Exception overloaded constructor -///\brief Creates an exception with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception overloaded constructor +///\brief Creates an exception with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Exception::Exception(const H5std_string& func, const H5std_string& message) : detail_message(message), func_name(func) {} //-------------------------------------------------------------------------- -// Function: Exception copy constructor -///\brief Copy constructor: makes a copy of the original Exception object. -///\param orig - IN: Exception instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception copy constructor +///\brief Copy constructor: makes a copy of the original Exception object. +///\param orig - IN: Exception instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception( const Exception& orig ) : detail_message(orig.detail_message), func_name(orig.func_name) {} +Exception::Exception(const Exception& orig) : detail_message(orig.detail_message), func_name(orig.func_name) {} //-------------------------------------------------------------------------- -// Function: Exception::getMajorString -///\brief Returns a text string that describes the error -/// specified by a major error number. -///\param err_major - IN: Major error number -///\return Major error string +// Function: Exception::getMajorString +///\brief Returns a text string that describes the error +/// specified by a major error number. +///\param err_major - IN: Major error number +///\return Major error string ///\par Description -/// In the failure case, the string "Invalid major error number" -/// will be returned. -// Programmer Binh-Minh Ribler - 2000 +/// In the failure case, the string "Invalid major error number" +/// will be returned. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMajorString( hid_t err_major ) const +H5std_string Exception::getMajorString(hid_t err_major) const { - // Preliminary call to H5Eget_msg() to get the length of the message - ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0); - - // If H5Eget_msg() returns a negative value, raise an exception, - if( mesg_size < 0 ) - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); - - // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1); - - // Check for failure again - if( mesg_size < 0 ) - { - delete []mesg_C; - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); - } - - // Convert the C error description and return - H5std_string major_str(mesg_C); - delete []mesg_C; - return( major_str ); + // Preliminary call to H5Eget_msg() to get the length of the message + ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0); + + // If H5Eget_msg() returns a negative value, raise an exception, + if (mesg_size < 0) + throw IdComponentException("Exception::getMajorString", + "H5Eget_msg failed"); + + // Call H5Eget_msg again to get the actual message + char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1); + + // Check for failure again + if (mesg_size < 0) + { + delete []mesg_C; + throw IdComponentException("Exception::getMajorString", + "H5Eget_msg failed"); + } + + // Convert the C error description and return + H5std_string major_str(mesg_C); + delete []mesg_C; + return(major_str); } //-------------------------------------------------------------------------- -// Function: Exception::getMinorString -///\brief Returns a text string that describes the error -/// specified by a minor error number. -///\param err_minor - IN: Minor error number -///\return Minor error string +// Function: Exception::getMinorString +///\brief Returns a text string that describes the error +/// specified by a minor error number. +///\param err_minor - IN: Minor error number +///\return Minor error string ///\par Description -/// In the failure case, the string "Invalid minor error number" -/// will be returned. -// Programmer Binh-Minh Ribler - 2000 +/// In the failure case, the string "Invalid minor error number" +/// will be returned. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMinorString( hid_t err_minor ) const +H5std_string Exception::getMinorString(hid_t err_minor) const { - // Preliminary call to H5Eget_msg() to get the length of the message - ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0); - - // If H5Eget_msg() returns a negative value, raise an exception, - if( mesg_size < 0 ) - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); - - // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1); - - // Check for failure again - if( mesg_size < 0 ) - { - delete []mesg_C; - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); - } - - // Convert the C error description and return - H5std_string minor_str(mesg_C); - delete []mesg_C; - return( minor_str ); + // Preliminary call to H5Eget_msg() to get the length of the message + ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0); + + // If H5Eget_msg() returns a negative value, raise an exception, + if (mesg_size < 0) + throw IdComponentException("Exception::getMinorString", + "H5Eget_msg failed"); + + // Call H5Eget_msg again to get the actual message + char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1); + + // Check for failure again + if (mesg_size < 0) + { + delete []mesg_C; + throw IdComponentException("Exception::getMinorString", + "H5Eget_msg failed"); + } + + // Convert the C error description and return + H5std_string minor_str(mesg_C); + delete []mesg_C; + return(minor_str); } //-------------------------------------------------------------------------- -// Function: Exception::setAutoPrint -///\brief Turns on the automatic error printing. -///\param func - IN: Function to be called upon an error condition -///\param client_data - IN: Data passed to the error function +// Function: Exception::setAutoPrint +///\brief Turns on the automatic error printing. +///\param func - IN: Function to be called upon an error condition +///\param client_data - IN: Data passed to the error function ///\par Description -/// When the library is first initialized the auto printing -/// function, \a func, is set to the C API \c H5Eprint and -/// \a client_data is the standard error stream pointer, \c stderr. -/// Automatic stack traversal is always in the \c H5E_WALK_DOWNWARD -/// direction. +/// When the library is first initialized the auto printing +/// function, \a func, is set to the C API \c H5Eprint and +/// \a client_data is the standard error stream pointer, \c stderr. +/// Automatic stack traversal is always in the \c H5E_WALK_DOWNWARD +/// direction. ///\par -/// Users are encouraged to write their own more specific error -/// handlers -// Programmer Binh-Minh Ribler - 2000 +/// Users are encouraged to write their own more specific error +/// handlers +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint( H5E_auto2_t& func, void* client_data ) +void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) { - // calls the C API routine H5Eset_auto to set the auto printing to - // the specified function. - herr_t ret_value = H5Eset_auto2( H5E_DEFAULT, func, client_data ); - if( ret_value < 0 ) - throw Exception( "Exception::setAutoPrint", "H5Eset_auto failed" ); + // calls the C API routine H5Eset_auto to set the auto printing to + // the specified function. + herr_t ret_value = H5Eset_auto2(H5E_DEFAULT, func, client_data); + if (ret_value < 0) + throw Exception("Exception::setAutoPrint", "H5Eset_auto failed"); } //-------------------------------------------------------------------------- -// Function: Exception::dontPrint -///\brief Turns off the automatic error printing from the C library. -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::dontPrint +///\brief Turns off the automatic error printing from the C library. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::dontPrint() { - // calls the C API routine H5Eset_auto with NULL parameters to turn - // off the automatic error printing. - herr_t ret_value = H5Eset_auto2( H5E_DEFAULT, NULL, NULL ); - if( ret_value < 0 ) - throw Exception( "Exception::dontPrint", "H5Eset_auto failed" ); + // calls the C API routine H5Eset_auto with NULL parameters to turn + // off the automatic error printing. + herr_t ret_value = H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + if (ret_value < 0) + throw Exception("Exception::dontPrint", "H5Eset_auto failed"); } //-------------------------------------------------------------------------- -// Function: Exception::getAutoPrint -///\brief Retrieves the current settings for the automatic error -/// stack traversal function and its data. -///\param func - OUT: Current setting for the function to be -/// called upon an error condition -///\param client_data - OUT: Current setting for the data passed to -/// the error function -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::getAutoPrint +///\brief Retrieves the current settings for the automatic error +/// stack traversal function and its data. +///\param func - OUT: Current setting for the function to be +/// called upon an error condition +///\param client_data - OUT: Current setting for the data passed to +/// the error function +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint( H5E_auto2_t& func, void** client_data ) +void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) { - // calls the C API routine H5Eget_auto to get the current setting of - // the automatic error printing - herr_t ret_value = H5Eget_auto2( H5E_DEFAULT, &func, client_data ); - if( ret_value < 0 ) - throw Exception( "Exception::getAutoPrint", "H5Eget_auto failed" ); + // calls the C API routine H5Eget_auto to get the current setting of + // the automatic error printing + herr_t ret_value = H5Eget_auto2(H5E_DEFAULT, &func, client_data); + if (ret_value < 0) + throw Exception("Exception::getAutoPrint", "H5Eget_auto failed"); } //-------------------------------------------------------------------------- -// Function: Exception::clearErrorStack -///\brief Clears the error stack for the current thread. +// Function: Exception::clearErrorStack +///\brief Clears the error stack for the current thread. ///\par Description -/// The stack is also cleared whenever a C API function is -/// called, with certain exceptions (for instance, \c H5Eprint). -// Programmer Binh-Minh Ribler - 2000 +/// The stack is also cleared whenever a C API function is +/// called, with certain exceptions (for instance, \c H5Eprint). +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::clearErrorStack() { - // calls the C API routine H5Eclear to clear the error stack - herr_t ret_value = H5Eclear2(H5E_DEFAULT); - if( ret_value < 0 ) - throw Exception( "Exception::clearErrorStack", "H5Eclear failed" ); + // calls the C API routine H5Eclear to clear the error stack + herr_t ret_value = H5Eclear2(H5E_DEFAULT); + if (ret_value < 0) + throw Exception("Exception::clearErrorStack", "H5Eclear failed"); } //-------------------------------------------------------------------------- -// Function: Exception::walkErrorStack -///\brief Walks the error stack for the current thread, calling the -/// specified function. -///\param direction - IN: Direction in which the error stack is to be walked -///\param func - IN: Function to be called for each error encountered -///\param client_data - IN: Data passed to the error function +// Function: Exception::walkErrorStack +///\brief Walks the error stack for the current thread, calling the +/// specified function. +///\param direction - IN: Direction in which the error stack is to be walked +///\param func - IN: Function to be called for each error encountered +///\param client_data - IN: Data passed to the error function ///\par Description -/// Valid values for \a direction include: -/// \li \c H5E_WALK_UPWARD - begin with the most specific error -/// and end at the API -/// \li \c H5E_WALK_DOWNWARD - begin at the API and end at the -/// inner-most function where the error was first detected +/// Valid values for \a direction include: +/// \li \c H5E_WALK_UPWARD - begin with the most specific error +/// and end at the API +/// \li \c H5E_WALK_DOWNWARD - begin at the API and end at the +/// inner-most function where the error was first detected ///\par -/// The function specified by \a func will be called for each -/// error in the error stack. The \c H5E_walk_t prototype is as -/// follows: +/// The function specified by \a func will be called for each +/// error in the error stack. The \c H5E_walk_t prototype is as +/// follows: ///\code /// typedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void *client_data) /// int n - Indexed position of the error in the stack; it begins at zero -/// regardless of stack traversal direction +/// regardless of stack traversal direction /// H5E_error_t *err_desc - Pointer to a data structure describing the -/// error. This structure is listed below. +/// error. This structure is listed below. /// void *client_data - Pointer to client data in the format expected by -/// the user-defined function. +/// the user-defined function. ///\endcode ///\par /// Data structure to describe the error: @@ -238,87 +238,87 @@ void Exception::clearErrorStack() /// const char *desc; //optional supplied description /// } H5E_error2_t; ///\endcode -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk2_t func, void* client_data ) +void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void* client_data) { - // calls the C API routine H5Ewalk to walk the error stack - herr_t ret_value = H5Ewalk2( H5E_DEFAULT, direction, func, client_data ); - if( ret_value < 0 ) - throw Exception( "Exception::walkErrorStack", "H5Ewalk failed" ); + // calls the C API routine H5Ewalk to walk the error stack + herr_t ret_value = H5Ewalk2(H5E_DEFAULT, direction, func, client_data); + if (ret_value < 0) + throw Exception("Exception::walkErrorStack", "H5Ewalk failed"); } //-------------------------------------------------------------------------- -// Function: Exception::getDetailMsg -///\brief Returns the detailed message set at the time the exception -/// is thrown. -///\return Text message - \c H5std_string -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::getDetailMsg +///\brief Returns the detailed message set at the time the exception +/// is thrown. +///\return Text message - \c H5std_string +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5std_string Exception::getDetailMsg() const { - return(detail_message); + return(detail_message); } //-------------------------------------------------------------------------- -// Function: Exception::getCDetailMsg -///\brief Returns the detailed message set at the time the exception -/// is thrown. -///\return Text message - \c char pointer -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::getCDetailMsg +///\brief Returns the detailed message set at the time the exception +/// is thrown. +///\return Text message - \c char pointer +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- const char* Exception::getCDetailMsg() const { - return(detail_message.c_str()); + return(detail_message.c_str()); } //-------------------------------------------------------------------------- -// Function: Exception::getFuncName -///\brief Returns the name of the function, where the exception is thrown. -///\return Text message - \c H5std_string -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::getFuncName +///\brief Returns the name of the function, where the exception is thrown. +///\return Text message - \c H5std_string +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5std_string Exception::getFuncName() const { - return(func_name); + return(func_name); } //-------------------------------------------------------------------------- -// Function: Exception::getCFuncName -///\brief Returns the name of the function, where the exception is thrown. -///\return Text message - \c char pointer -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::getCFuncName +///\brief Returns the name of the function, where the exception is thrown. +///\return Text message - \c char pointer +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- const char* Exception::getCFuncName() const { - return(func_name.c_str()); + return(func_name.c_str()); } //-------------------------------------------------------------------------- -// Function: Exception::printErrorStack (static) -///\brief Prints the error stack in a default manner. -///\param stream - IN: File pointer, default to stderr -///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::printErrorStack (static) +///\brief Prints the error stack in a default manner. +///\param stream - IN: File pointer, default to stderr +///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::printErrorStack(FILE* stream, hid_t err_stack) { herr_t ret_value = H5Eprint2(err_stack, stream); - if( ret_value < 0 ) - throw Exception( "Printing error stack", "H5Eprint2 failed" ); + if (ret_value < 0) + throw Exception("Printing error stack", "H5Eprint2 failed"); } //-------------------------------------------------------------------------- -// Function: Exception::printError -// Purpose: Prints the error stack in a default manner. This member -// function is replaced by the static function printErrorStack -// and will be removed from the next major release. -// Parameter stream - IN: File pointer -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception::printError +// Purpose: Prints the error stack in a default manner. This member +// function is replaced by the static function printErrorStack +// and will be removed from the next major release. +// Parameter stream - IN: File pointer +// Programmer Binh-Minh Ribler - 2000 // Description: -// This function can be removed in next major release. -// -BMR, 2014/04/24 -// Removed from documentation. -BMR, 2016/03/23 +// This function can be removed in next major release. +// -BMR, 2014/04/24 +// Removed from documentation. -BMR, 2016/03/23 //-------------------------------------------------------------------------- void Exception::printError(FILE* stream) const { @@ -326,285 +326,285 @@ void Exception::printError(FILE* stream) const } //-------------------------------------------------------------------------- -// Function: Exception destructor -///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Function: Exception destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Exception::~Exception() throw() {} //-------------------------------------------------------------------------- -// Subclass: FileIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: FileIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: FileIException default constructor -///\brief Default constructor. +// Function: FileIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- FileIException::FileIException():Exception(){} //-------------------------------------------------------------------------- -// Function: FileIException overloaded constructor -///\brief Creates a FileIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: FileIException overloaded constructor +///\brief Creates a FileIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- FileIException::FileIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: FileIException destructor -///\brief Noop destructor. +// Function: FileIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- FileIException::~FileIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: GroupIException default constructor -///\brief Default constructor. +// Function: GroupIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- GroupIException::GroupIException():Exception(){} //-------------------------------------------------------------------------- -// Function: GroupIException overloaded constructor -///\brief Creates a GroupIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: GroupIException overloaded constructor +///\brief Creates a GroupIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- GroupIException::GroupIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: GroupIException destructor -///\brief Noop destructor. +// Function: GroupIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- GroupIException::~GroupIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: DataSpaceIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: DataSpaceIException default constructor -///\brief Default constructor. +// Function: DataSpaceIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- DataSpaceIException::DataSpaceIException():Exception(){} //-------------------------------------------------------------------------- -// Function: DataSpaceIException overloaded constructor -///\brief Creates a DataSpaceIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: DataSpaceIException overloaded constructor +///\brief Creates a DataSpaceIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- DataSpaceIException::DataSpaceIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: DataSpaceIException destructor -///\brief Noop destructor. +// Function: DataSpaceIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- DataSpaceIException::~DataSpaceIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: DataTypeIException default constructor -///\brief Default constructor. +// Function: DataTypeIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- DataTypeIException::DataTypeIException():Exception(){} //-------------------------------------------------------------------------- -// Function: DataTypeIException overloaded constructor -///\brief Creates a DataTypeIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: DataTypeIException overloaded constructor +///\brief Creates a DataTypeIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- DataTypeIException::DataTypeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: DataTypeIException destructor -///\brief Noop destructor. +// Function: DataTypeIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- DataTypeIException::~DataTypeIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: ObjHeaderIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: ObjHeaderIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: ObjHeaderIException default constructor -///\brief Default constructor. +// Function: ObjHeaderIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- ObjHeaderIException::ObjHeaderIException():Exception(){} //-------------------------------------------------------------------------- -// Function: ObjHeaderIException overloaded constructor -///\brief Creates an ObjHeaderIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: ObjHeaderIException overloaded constructor +///\brief Creates an ObjHeaderIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- ObjHeaderIException::ObjHeaderIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: ObjHeaderIException destructor -///\brief Noop destructor. +// Function: ObjHeaderIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- ObjHeaderIException::~ObjHeaderIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: PropListIException default constructor -///\brief Default constructor. +// Function: PropListIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- PropListIException::PropListIException():Exception(){} //-------------------------------------------------------------------------- -// Function: PropListIException overloaded constructor -///\brief Creates a PropListIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: PropListIException overloaded constructor +///\brief Creates a PropListIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- PropListIException::PropListIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: PropListIException destructor -///\brief Noop destructor. +// Function: PropListIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- PropListIException::~PropListIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: DataSetIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: DataSetIException default constructor -///\brief Default constructor. +// Function: DataSetIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- DataSetIException::DataSetIException():Exception(){} //-------------------------------------------------------------------------- -// Function: DataSetIException overloaded constructor -///\brief Creates a DataSetIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: DataSetIException overloaded constructor +///\brief Creates a DataSetIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- DataSetIException::DataSetIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: DataSetIException destructor -///\brief Noop destructor. +// Function: DataSetIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- DataSetIException::~DataSetIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: AttributeIException default constructor -///\brief Default constructor. +// Function: AttributeIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- AttributeIException::AttributeIException():Exception(){} //-------------------------------------------------------------------------- -// Function: AttributeIException overloaded constructor -///\brief Creates an AttributeIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: AttributeIException overloaded constructor +///\brief Creates an AttributeIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- AttributeIException::AttributeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: AttributeIException destructor -///\brief Noop destructor. +// Function: AttributeIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- AttributeIException::~AttributeIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: ReferenceException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: ReferenceException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: ReferenceException default constructor -///\brief Default constructor. +// Function: ReferenceException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- ReferenceException::ReferenceException():Exception(){} //-------------------------------------------------------------------------- -// Function: ReferenceException overloaded constructor -///\brief Creates a ReferenceException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: ReferenceException overloaded constructor +///\brief Creates a ReferenceException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- ReferenceException::ReferenceException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: ReferenceException destructor -///\brief Noop destructor. +// Function: ReferenceException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- ReferenceException::~ReferenceException() throw() {} //-------------------------------------------------------------------------- -// Subclass: LibraryIException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: LibraryIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: LibraryIException default constructor -///\brief Default constructor. +// Function: LibraryIException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- LibraryIException::LibraryIException():Exception(){} //-------------------------------------------------------------------------- -// Function: LibraryIException overloaded constructor -///\brief Creates a LibraryIException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: LibraryIException overloaded constructor +///\brief Creates a LibraryIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- LibraryIException::LibraryIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: LibraryIException destructor -///\brief Noop destructor. +// Function: LibraryIException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- LibraryIException::~LibraryIException() throw() {} //-------------------------------------------------------------------------- -// Subclass: LocationException -// Programmer Binh-Minh Ribler - 2014 +// Subclass: LocationException +// Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: LocationException default constructor -///\brief Default constructor. +// Function: LocationException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- LocationException::LocationException():Exception(){} //-------------------------------------------------------------------------- -// Function: LocationException overloaded constructor -///\brief Creates a LocationException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: LocationException overloaded constructor +///\brief Creates a LocationException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- LocationException::LocationException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: LocationException destructor -///\brief Noop destructor. +// Function: LocationException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- LocationException::~LocationException() throw() {} //-------------------------------------------------------------------------- -// Subclass: IdComponentException -// Programmer Binh-Minh Ribler - 2000 +// Subclass: IdComponentException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: IdComponentException default constructor -///\brief Default constructor. +// Function: IdComponentException default constructor +///\brief Default constructor. //-------------------------------------------------------------------------- IdComponentException::IdComponentException(): Exception() {} //-------------------------------------------------------------------------- -// Function: IdComponentException overloaded constructor -///\brief Creates a IdComponentException with the name of the function, -/// in which the failure occurs, and an optional detailed message. -///\param func - IN: Name of the function where failure occurs -///\param message - IN: Message on the failure +// Function: IdComponentException overloaded constructor +///\brief Creates a IdComponentException with the name of the function, +/// in which the failure occurs, and an optional detailed message. +///\param func - IN: Name of the function where failure occurs +///\param message - IN: Message on the failure //-------------------------------------------------------------------------- IdComponentException::IdComponentException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} //-------------------------------------------------------------------------- -// Function: IdComponentException destructor -///\brief Noop destructor. +// Function: IdComponentException destructor +///\brief Noop destructor. //-------------------------------------------------------------------------- IdComponentException::~IdComponentException() throw() {} diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 7112995..1f85711 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -33,147 +33,147 @@ namespace H5 { */ class H5_DLLCPP Exception { public: - // Creates an exception with a function name where the failure occurs - // and an optional detailed message - Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + // Creates an exception with a function name where the failure occurs + // and an optional detailed message + Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - // Returns a character string that describes the error specified by - // a major error number. - H5std_string getMajorString( hid_t err_major_id ) const; + // Returns a character string that describes the error specified by + // a major error number. + H5std_string getMajorString(hid_t err_major_id) const; - // Returns a character string that describes the error specified by - // a minor error number. - H5std_string getMinorString( hid_t err_minor_id ) const; + // Returns a character string that describes the error specified by + // a minor error number. + H5std_string getMinorString(hid_t err_minor_id) const; - // Returns the detailed message set at the time the exception is thrown - H5std_string getDetailMsg() const; - const char* getCDetailMsg() const; // C string of detailed message - H5std_string getFuncName() const; // function name as a string object - const char* getCFuncName() const; // function name as a char string + // Returns the detailed message set at the time the exception is thrown + H5std_string getDetailMsg() const; + const char* getCDetailMsg() const; // C string of detailed message + H5std_string getFuncName() const; // function name as a string object + const char* getCFuncName() const; // function name as a char string - // Turns on the automatic error printing. - static void setAutoPrint( H5E_auto2_t& func, void* client_data); + // Turns on the automatic error printing. + static void setAutoPrint(H5E_auto2_t& func, void* client_data); - // Turns off the automatic error printing. - static void dontPrint(); + // Turns off the automatic error printing. + static void dontPrint(); - // Retrieves the current settings for the automatic error stack - // traversal function and its data. - static void getAutoPrint( H5E_auto2_t& func, void** client_data); + // Retrieves the current settings for the automatic error stack + // traversal function and its data. + static void getAutoPrint(H5E_auto2_t& func, void** client_data); - // Clears the error stack for the current thread. - static void clearErrorStack(); + // Clears the error stack for the current thread. + static void clearErrorStack(); - // Walks the error stack for the current thread, calling the - // specified function. - static void walkErrorStack( H5E_direction_t direction, - H5E_walk2_t func, void* client_data); + // Walks the error stack for the current thread, calling the + // specified function. + static void walkErrorStack(H5E_direction_t direction, + H5E_walk2_t func, void* client_data); - // Prints the error stack in a default manner. - static void printErrorStack(FILE* stream = stderr, - hid_t err_stack = H5E_DEFAULT); // Static - virtual void printError(FILE* stream = NULL) const; + // Prints the error stack in a default manner. + static void printErrorStack(FILE* stream = stderr, + hid_t err_stack = H5E_DEFAULT); + virtual void printError(FILE* stream = NULL) const; - // Default constructor - Exception(); + // Default constructor + Exception(); - // copy constructor - Exception( const Exception& orig); + // copy constructor + Exception(const Exception& orig); - // virtual Destructor - virtual ~Exception() throw(); + // virtual Destructor + virtual ~Exception() throw(); protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; + // Default value for detail_message + static const char DEFAULT_MSG[]; private: - H5std_string detail_message; - H5std_string func_name; + H5std_string detail_message; + H5std_string func_name; }; class H5_DLLCPP FileIException : public Exception { public: - FileIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - FileIException(); - virtual ~FileIException() throw(); + FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + FileIException(); + virtual ~FileIException() throw(); }; class H5_DLLCPP GroupIException : public Exception { public: - GroupIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - GroupIException(); - virtual ~GroupIException() throw(); + GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + GroupIException(); + virtual ~GroupIException() throw(); }; class H5_DLLCPP DataSpaceIException : public Exception { public: - DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSpaceIException(); - virtual ~DataSpaceIException() throw(); + DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + DataSpaceIException(); + virtual ~DataSpaceIException() throw(); }; class H5_DLLCPP DataTypeIException : public Exception { public: - DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataTypeIException(); - virtual ~DataTypeIException() throw(); + DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + DataTypeIException(); + virtual ~DataTypeIException() throw(); }; class H5_DLLCPP ObjHeaderIException : public Exception { public: - ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ObjHeaderIException(); - virtual ~ObjHeaderIException() throw(); + ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + ObjHeaderIException(); + virtual ~ObjHeaderIException() throw(); }; class H5_DLLCPP PropListIException : public Exception { public: - PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - PropListIException(); - virtual ~PropListIException() throw(); + PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + PropListIException(); + virtual ~PropListIException() throw(); }; class H5_DLLCPP DataSetIException : public Exception { public: - DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSetIException(); - virtual ~DataSetIException() throw(); + DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + DataSetIException(); + virtual ~DataSetIException() throw(); }; class H5_DLLCPP AttributeIException : public Exception { public: - AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - AttributeIException(); - virtual ~AttributeIException() throw(); + AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + AttributeIException(); + virtual ~AttributeIException() throw(); }; class H5_DLLCPP ReferenceException : public Exception { public: - ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ReferenceException(); - virtual ~ReferenceException() throw(); + ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + ReferenceException(); + virtual ~ReferenceException() throw(); }; class H5_DLLCPP LibraryIException : public Exception { public: - LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LibraryIException(); - virtual ~LibraryIException() throw(); + LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + LibraryIException(); + virtual ~LibraryIException() throw(); }; class H5_DLLCPP LocationException : public Exception { public: - LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LocationException(); - virtual ~LocationException() throw(); + LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + LocationException(); + virtual ~LocationException() throw(); }; class H5_DLLCPP IdComponentException : public Exception { public: - IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - IdComponentException(); - virtual ~IdComponentException() throw(); + IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); + IdComponentException(); + virtual ~IdComponentException() throw(); }; } diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index c3919da..1ab812c 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -63,7 +63,7 @@ FileAccPropList* FileAccPropList::getConstant() //-------------------------------------------------------------------------- // Function: FileAccPropList::deleteConstants -// Purpose: Deletes the constant object that FileAccPropList::DEFAULT_ +// Purpose Deletes the constant object that FileAccPropList::DEFAULT_ // points to. // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 @@ -75,271 +75,271 @@ void FileAccPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose: Constant for default property +// Purpose Constant for default property //-------------------------------------------------------------------------- const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Default Constructor -///\brief Creates a file access property list -// Programmer: Binh-Minh Ribler - 2000 +// Function: Default Constructor +///\brief Creates a file access property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList() : PropList( H5P_FILE_ACCESS ) {} +FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} //-------------------------------------------------------------------------- -// Function: FileAccPropList copy constructor -///\brief Copy Constructor: makes a copy of the original -///\param original - IN: FileAccPropList instance to copy -// Programmer: Binh-Minh Ribler - 2000 +// Function: FileAccPropList copy constructor +///\brief Copy Constructor: makes a copy of the original +///\param original - IN: FileAccPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(original) {} //-------------------------------------------------------------------------- -// Function: FileAccPropList overloaded constructor -///\brief Creates a file access property list using the id of an -/// existing one. -// Programmer: Binh-Minh Ribler - 2000 +// Function: FileAccPropList overloaded constructor +///\brief Creates a file access property list using the id of an +/// existing one. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} //-------------------------------------------------------------------------- -// Function: FileAccPropList::setStdio -///\brief Modifies this property list to use the \c H5FD_STDIO driver. +// Function: FileAccPropList::setStdio +///\brief Modifies this property list to use the \c H5FD_STDIO driver. /// -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setStdio() const { - herr_t ret_value = H5Pset_fapl_stdio(id); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); - } + herr_t ret_value = H5Pset_fapl_stdio(id); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getDriver -///\brief Return the ID of the low-level file driver. -///\return A low-level driver ID which is the same ID used when the -/// driver was set for the property list. The driver ID is -/// only valid as long as the file driver remains registered. -/// Valid driver identifiers can be found at: +// Function: FileAccPropList::getDriver +///\brief Return the ID of the low-level file driver. +///\return A low-level driver ID which is the same ID used when the +/// driver was set for the property list. The driver ID is +/// only valid as long as the file driver remains registered. +/// Valid driver identifiers can be found at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetDriver -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- hid_t FileAccPropList::getDriver() const { - hid_t driver = H5Pget_driver(id); - if (driver < 0) - { - throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); - } + hid_t driver = H5Pget_driver(id); + if (driver < 0) + { + throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); + } return(driver); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setDriver -///\brief Set file driver for this property list. -///\param new_driver_id - IN: File driver -///\param new_driver_info - IN: Struct containing the driver-specific properites -///\exception H5::PropListIException +// Function: FileAccPropList::setDriver +///\brief Set file driver for this property list. +///\param new_driver_id - IN: File driver +///\param new_driver_info - IN: Struct containing the driver-specific properites +///\exception H5::PropListIException ///\par Description -/// For a list of valid driver identifiers, please see the C -/// layer Reference Manual at: +/// For a list of valid driver identifiers, please see the C +/// layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetDriver -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const { - herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); - if (ret_value < 0) - { - throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); - } + herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setFamilyOffset -///\brief Sets offset for family driver. -///\param offset - IN: offset value -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::setFamilyOffset +///\brief Sets offset for family driver. +///\param offset - IN: offset value +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setFamilyOffset(hsize_t offset) const { - herr_t ret_value = H5Pset_family_offset(id, offset); - if (ret_value < 0) - { - throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); - } + herr_t ret_value = H5Pset_family_offset(id, offset); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getFamilyOffset -///\brief Get offset for family driver. -///\return Offset for family driver -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getFamilyOffset +///\brief Get offset for family driver. +///\return Offset for family driver +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- hsize_t FileAccPropList::getFamilyOffset() const { - hsize_t offset; - herr_t ret_value = H5Pget_family_offset(id, &offset); - if (ret_value < 0) - { - throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); - } + hsize_t offset; + herr_t ret_value = H5Pget_family_offset(id, &offset); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); + } return(offset); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setCore -///\brief Modifies this file access property list to use the \c H5FD_CORE -/// driver. -///\param increment - IN: Specifies how much memory to increase each -/// time more memory is needed, in bytes -///\param backing_store - IN: Indicating whether to write the file -/// contents to disk when the file is closed -///\exception H5::PropListIException +// Function: FileAccPropList::setCore +///\brief Modifies this file access property list to use the \c H5FD_CORE +/// driver. +///\param increment - IN: Specifies how much memory to increase each +/// time more memory is needed, in bytes +///\param backing_store - IN: Indicating whether to write the file +/// contents to disk when the file is closed +///\exception H5::PropListIException ///\par Description -/// For more details on the use of \c H5FD_CORE driver, please -/// refer to +/// For more details on the use of \c H5FD_CORE driver, please +/// refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFaplCore -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const { - herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); - if (ret_value < 0) - { - throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); - } + herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); + if (ret_value < 0) + { + throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getCore -///\brief Queries core file driver properties. -///\param increment - OUT: Size of memory increment, in bytes -///\param backing_store - OUT: Indicating whether to write the file -/// contents to disk when the file is closed -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getCore +///\brief Queries core file driver properties. +///\param increment - OUT: Size of memory increment, in bytes +///\param backing_store - OUT: Indicating whether to write the file +/// contents to disk when the file is closed +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const { - herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); - } + herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setFamily -///\brief Sets this file access property list to use the family driver. -///\param memb_size - IN: Size in bytes of each file member -///\param memb_plist - IN: File access property list to be used for -/// each family member -///\exception H5::PropListIException +// Function: FileAccPropList::setFamily +///\brief Sets this file access property list to use the family driver. +///\param memb_size - IN: Size in bytes of each file member +///\param memb_plist - IN: File access property list to be used for +/// each family member +///\exception H5::PropListIException ///\par Description -/// Note that \a memb_size is used only when creating a new file. -// Programmer: Binh-Minh Ribler - April, 2004 +/// Note that \a memb_size is used only when creating a new file. +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const +void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const { - herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId() ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); - } + herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId()); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getFamily -///\brief Returns information about the family file access property -/// list. -///\param memb_size - OUT: Size in bytes of each file member -///\param memb_plist - OUT: Retrieved file access property list for each -/// file member -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getFamily +///\brief Returns information about the family file access property +/// list. +///\param memb_size - OUT: Size in bytes of each file member +///\param memb_plist - OUT: Retrieved file access property list for each +/// file member +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const { - hid_t memb_plist_id; - herr_t ret_value = H5Pget_fapl_family( id, &memb_size, &memb_plist_id ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); - } - memb_plist.p_setId(memb_plist_id); + hid_t memb_plist_id; + herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); + } + memb_plist.p_setId(memb_plist_id); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getFamily -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts and its return value. -///\param memb_size - OUT: Size in bytes of each file member -///\return The file access property list for each file member -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getFamily +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts and its return value. +///\param memb_size - OUT: Size in bytes of each file member +///\return The file access property list for each file member +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const { - hid_t memb_plist_id; - herr_t ret_value = H5Pget_fapl_family( id, &memb_size, &memb_plist_id ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); - } - FileAccPropList memb_plist(memb_plist_id); - return(memb_plist); -} - -//-------------------------------------------------------------------------- -// Function: FileAccPropList::setSplit -///\brief Emulates the old split file driver, which stored meta data -/// in one file and raw data in another file. -///\param meta_plist - IN: File access plist for the metadata file -///\param raw_plist - IN: File access plist for the raw data file -///\param meta_ext - IN: Metadata filename extension as \c char* -///\param raw_ext - IN: Raw data filename extension as \c char* -///\exception H5::PropListIException + hid_t memb_plist_id; + herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); + } + FileAccPropList memb_plist(memb_plist_id); + return(memb_plist); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSplit +///\brief Emulates the old split file driver, which stored meta data +/// in one file and raw data in another file. +///\param meta_plist - IN: File access plist for the metadata file +///\param raw_plist - IN: File access plist for the raw data file +///\param meta_ext - IN: Metadata filename extension as \c char* +///\param raw_ext - IN: Raw data filename extension as \c char* +///\exception H5::PropListIException ///\par Description -/// Temporary - For information, please refer to: +/// Temporary - For information, please refer to: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFaplSplit -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext ) const -{ - hid_t meta_pid = meta_plist.getId(); - hid_t raw_pid = raw_plist.getId(); - herr_t ret_value = H5Pset_fapl_split( id, meta_ext, meta_pid, raw_ext, raw_pid ); - if( ret_value < 0 ) +void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext) const { - throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); - } + hid_t meta_pid = meta_plist.getId(); + hid_t raw_pid = raw_plist.getId(); + herr_t ret_value = H5Pset_fapl_split(id, meta_ext, meta_pid, raw_ext, raw_pid); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setSplit -///\brief This is an overloaded member function, provided for convenience. -/// It takes character arguments as \c H5std_string. -///\param meta_plist - IN: File access plist for the metadata file -///\param raw_plist - IN: File access plist for the raw data file -///\param meta_ext - IN: Metadata filename extension as \c H5std_string -///\param raw_ext - IN: Raw data filename extension as \c H5std_string -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::setSplit +///\brief This is an overloaded member function, provided for convenience. +/// It takes character arguments as \c H5std_string. +///\param meta_plist - IN: File access plist for the metadata file +///\param raw_plist - IN: File access plist for the raw data file +///\param meta_ext - IN: Metadata filename extension as \c H5std_string +///\param raw_ext - IN: Raw data filename extension as \c H5std_string +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext ) const +void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext) const { - setSplit( meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() ); + setSplit(meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str()); } // Stream Virtual File Driver had been removed from the main library. @@ -347,402 +347,402 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP // -BMR, March, 2012 //-------------------------------------------------------------------------- -// Function: FileAccPropList::getSieveBufSize -///\brief Returns the current settings for the data sieve buffer size -/// property from this property list. -///\return Data sieve buffer size, in bytes -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getSieveBufSize +///\brief Returns the current settings for the data sieve buffer size +/// property from this property list. +///\return Data sieve buffer size, in bytes +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t FileAccPropList::getSieveBufSize() const { - size_t bufsize; - herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); - } - return(bufsize); + size_t bufsize; + herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); + } + return(bufsize); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setSieveBufSize -///\brief Sets the maximum size of the data sieve buffer. -///\param bufsize - IN: Maximum size, in bytes, of data sieve buffer -///\exception H5::PropListIException +// Function: FileAccPropList::setSieveBufSize +///\brief Sets the maximum size of the data sieve buffer. +///\param bufsize - IN: Maximum size, in bytes, of data sieve buffer +///\exception H5::PropListIException ///\par Description -/// For detail on data sieving, please refer to +/// For detail on data sieving, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSieveBufSize -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setSieveBufSize(size_t bufsize) const { - herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); - } + herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setMetaBlockSize -///\brief Sets the minimum size of metadata block allocations. -///\param block_size - IN: Minimum size, in bytes, of metadata -/// block allocations -///\exception H5::PropListIException +// Function: FileAccPropList::setMetaBlockSize +///\brief Sets the minimum size of metadata block allocations. +///\param block_size - IN: Minimum size, in bytes, of metadata +/// block allocations +///\exception H5::PropListIException ///\par Description -/// For more detail, please see the C layer Reference Manual at: +/// For more detail, please see the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetMetaBlockSize -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const { - herr_t ret_value = H5Pset_meta_block_size(id, block_size); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); - } + herr_t ret_value = H5Pset_meta_block_size(id, block_size); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getMetaBlockSize -///\brief Returns the current metadata block size setting. -///\return Metadata block size -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getMetaBlockSize +///\brief Returns the current metadata block size setting. +///\return Metadata block size +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- hsize_t FileAccPropList::getMetaBlockSize() const { - hsize_t block_size; - herr_t ret_value = H5Pget_meta_block_size(id, &block_size); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); - } - return(block_size); + hsize_t block_size; + herr_t ret_value = H5Pget_meta_block_size(id, &block_size); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); + } + return(block_size); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setLog -///\brief Modifies this file access property list to use the logging -/// driver. -///\param logfile - IN: Name of the log file -///\param flags - IN: Flags specifying the types of logging activity -///\param buf_size - IN: Size of the logging buffer -///\exception H5::PropListIException +// Function: FileAccPropList::setLog +///\brief Modifies this file access property list to use the logging +/// driver. +///\param logfile - IN: Name of the log file +///\param flags - IN: Flags specifying the types of logging activity +///\param buf_size - IN: Size of the logging buffer +///\exception H5::PropListIException ///\par Description -/// For detail on \a flags, please refer to +/// For detail on \a flags, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFaplLog -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const { - herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); - } + herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setLog -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param logfile - IN: Name of the log file - string -///\param flags - IN: Flags specifying the types of logging activity -///\param buf_size - IN: Size of the logging buffer -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::setLog +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param logfile - IN: Name of the log file - string +///\param flags - IN: Flags specifying the types of logging activity +///\param buf_size - IN: Size of the logging buffer +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const { - setLog(logfile.c_str(), flags, buf_size); + setLog(logfile.c_str(), flags, buf_size); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setSec2 -///\brief Modifies this file access property list to use the sec2 -/// driver. +// Function: FileAccPropList::setSec2 +///\brief Modifies this file access property list to use the sec2 +/// driver. /// -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setSec2() const { - herr_t ret_value = H5Pset_fapl_sec2(id); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); - } + herr_t ret_value = H5Pset_fapl_sec2(id); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setAlignment -///\brief Sets the alignment properties of this property list. -///\param threshold - IN: Threshold value for file object size -///\param alignment - IN: Alignment value -///\exception H5::PropListIException +// Function: FileAccPropList::setAlignment +///\brief Sets the alignment properties of this property list. +///\param threshold - IN: Threshold value for file object size +///\param alignment - IN: Alignment value +///\exception H5::PropListIException ///\par Description -/// The parameter \a threshold must have a non-negative value. -/// Note that setting the threshold value to 0 (zero) has the -/// effect of a special case, forcing everything to be aligned. -/// The parameter \a alignment must have a positive value. +/// The parameter \a threshold must have a non-negative value. +/// Note that setting the threshold value to 0 (zero) has the +/// effect of a special case, forcing everything to be aligned. +/// The parameter \a alignment must have a positive value. /// -/// For detail on \a setting alignment, please refer to +/// For detail on \a setting alignment, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAlignment -// Programmer: Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setAlignment( hsize_t threshold, hsize_t alignment ) const +void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const { - herr_t ret_value = H5Pset_alignment( id, threshold, alignment ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed"); - } + herr_t ret_value = H5Pset_alignment(id, threshold, alignment); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getAlignment -///\brief Returns the current settings for alignment properties from -/// this property list. -///\param threshold - OUT: Retrieved threshold value for file object size -///\param alignment - OUT: Retrieved alignment value -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: FileAccPropList::getAlignment +///\brief Returns the current settings for alignment properties from +/// this property list. +///\param threshold - OUT: Retrieved threshold value for file object size +///\param alignment - OUT: Retrieved alignment value +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getAlignment( hsize_t &threshold, hsize_t &alignment ) const +void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const { - herr_t ret_value = H5Pget_alignment( id, &threshold, &alignment ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed"); - } + herr_t ret_value = H5Pget_alignment(id, &threshold, &alignment); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setMultiType -///\brief Sets data type for \c MULTI driver. -///\param dtype - IN: Type of data -///\exception H5::PropListIException +// Function: FileAccPropList::setMultiType +///\brief Sets data type for \c MULTI driver. +///\param dtype - IN: Type of data +///\exception H5::PropListIException ///\par Description -/// More details and valid values for \a dtype can be found at: +/// More details and valid values for \a dtype can be found at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetMultiType -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setMultiType(H5FD_mem_t dtype) const { - herr_t ret_value = H5Pset_multi_type(id, dtype); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); - } + herr_t ret_value = H5Pset_multi_type(id, dtype); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getMultiType -///\brief Returns the data type property for \c MULTI driver. -///\return The data type property -///\exception H5::PropListIException +// Function: FileAccPropList::getMultiType +///\brief Returns the data type property for \c MULTI driver. +///\return The data type property +///\exception H5::PropListIException ///\par Description -/// More details and possible returned values can be found at: +/// More details and possible returned values can be found at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetMultiType -// Programmer: Binh-Minh Ribler - April, 2004 +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5FD_mem_t FileAccPropList::getMultiType() const { - H5FD_mem_t dtype; - herr_t ret_value = H5Pget_multi_type(id, &dtype); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); - } - return(dtype); + H5FD_mem_t dtype; + herr_t ret_value = H5Pget_multi_type(id, &dtype); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); + } + return(dtype); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setCache -///\brief Sets the meta data cache and raw data chunk cache parameters. -///\param mdc_nelmts - IN: Number of elements in the meta data cache -///\param rdcc_nelmts - IN: Number of elements in the raw data chunk cache -///\param rdcc_nbytes - IN: Total size of the raw data chunk cache, in bytes -///\param rdcc_w0 - IN: Preemption policy -///\exception H5::PropListIException +// Function: FileAccPropList::setCache +///\brief Sets the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - IN: Number of elements in the meta data cache +///\param rdcc_nelmts - IN: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - IN: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - IN: Preemption policy +///\exception H5::PropListIException ///\par Description -/// The argument \a rdcc_w0 should hold a value between 0 and 1 -/// inclusive. This value indicates how much chunks that have -/// been fully read are favored for preemption. A value of zero -/// means fully read chunks are treated no differently than other -/// chunks (the preemption is strictly LRU) while a value of one -/// means fully read chunks are always preempted before other chunks. -// Programmer: Binh-Minh Ribler - 2000 +/// The argument \a rdcc_w0 should hold a value between 0 and 1 +/// inclusive. This value indicates how much chunks that have +/// been fully read are favored for preemption. A value of zero +/// means fully read chunks are treated no differently than other +/// chunks (the preemption is strictly LRU) while a value of one +/// means fully read chunks are always preempted before other chunks. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setCache( int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const +void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const { - herr_t ret_value = H5Pset_cache( id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0 ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed"); - } + herr_t ret_value = H5Pset_cache(id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getCache -///\brief Queries the meta data cache and raw data chunk cache parameters. -///\param mdc_nelmts - OUT: Number of elements in the meta data cache -///\param rdcc_nelmts - OUT: Number of elements in the raw data chunk cache -///\param rdcc_nbytes - OUT: Total size of the raw data chunk cache, in bytes -///\param rdcc_w0 - OUT: Preemption policy -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: FileAccPropList::getCache +///\brief Queries the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - OUT: Number of elements in the meta data cache +///\param rdcc_nelmts - OUT: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - OUT: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - OUT: Preemption policy +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const +void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const { - herr_t ret_value = H5Pget_cache( id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0 ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed"); - } + herr_t ret_value = H5Pget_cache(id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setFcloseDegree -///\brief Sets the degree for the file close behavior. -///\param degree - IN: -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::setFcloseDegree +///\brief Sets the degree for the file close behavior. +///\param degree - IN: +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const { - herr_t ret_value = H5Pset_fclose_degree(id, degree); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); - } + herr_t ret_value = H5Pset_fclose_degree(id, degree); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getFcloseDegree -///\brief Returns the degree for the file close behavior. -///\return The degree for the file close behavior -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - April, 2004 +// Function: FileAccPropList::getFcloseDegree +///\brief Returns the degree for the file close behavior. +///\return The degree for the file close behavior +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5F_close_degree_t FileAccPropList::getFcloseDegree() const { - H5F_close_degree_t degree; - herr_t ret_value = H5Pget_fclose_degree(id, °ree); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); - } - return(degree); + H5F_close_degree_t degree; + herr_t ret_value = H5Pget_fclose_degree(id, °ree); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); + } + return(degree); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setGcReferences -///\brief Sets garbage collecting references flag. -///\param gc_ref - IN: Flag setting reference garbage collection to -/// on (1) or off (0). -///\exception H5::PropListIException +// Function: FileAccPropList::setGcReferences +///\brief Sets garbage collecting references flag. +///\param gc_ref - IN: Flag setting reference garbage collection to +/// on (1) or off (0). +///\exception H5::PropListIException ///\par Description -/// For detail on \a fapl, please refer to +/// For detail on \a fapl, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetGCReferences -// Programmer: Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setGcReferences( unsigned gc_ref ) const +void FileAccPropList::setGcReferences(unsigned gc_ref) const { - herr_t ret_value = H5Pset_gc_references( id, gc_ref ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed"); - } + herr_t ret_value = H5Pset_gc_references(id, gc_ref); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed"); + } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getGcReferences -///\brief Returns the garbage collecting references setting. -///\return Garbage collecting references setting, 0 (off) or 1 (on) -///\exception H5::PropListIException -// Programmer: Binh-Minh Ribler - 2000 +// Function: FileAccPropList::getGcReferences +///\brief Returns the garbage collecting references setting. +///\return Garbage collecting references setting, 0 (off) or 1 (on) +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- unsigned FileAccPropList::getGcReferences() const { - unsigned gc_ref; + unsigned gc_ref; - // the name of this routine will be changed to H5Pget_gc_references??? - herr_t ret_value = H5Pget_gc_references( id, &gc_ref ); - if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed"); - } - return( gc_ref ); + // the name of this routine will be changed to H5Pget_gc_references??? + herr_t ret_value = H5Pget_gc_references(id, &gc_ref); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed"); + } + return(gc_ref); } //-------------------------------------------------------------------------- -// Function: FileAccPropList::setLibverBounds -///\brief Sets bounds on versions of library format to be used when creating -/// or writing objects. -///\param libver_low - IN: Earliest version of the library that will be -/// used for creating or writing objects -///\param libver_high - IN: Latest version of the library that will be -///\exception H5::PropListIException +// Function: FileAccPropList::setLibverBounds +///\brief Sets bounds on versions of library format to be used when creating +/// or writing objects. +///\param libver_low - IN: Earliest version of the library that will be +/// used for creating or writing objects +///\param libver_high - IN: Latest version of the library that will be +///\exception H5::PropListIException ///\par Description -/// Valid values of \a libver_low are as follows: -/// \li \c H5F_LIBVER_EARLIEST (Default) -/// \li \c H5F_LIBVER_18 -/// \li \c H5F_LIBVER_LATEST +/// Valid values of \a libver_low are as follows: +/// \li \c H5F_LIBVER_EARLIEST (Default) +/// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_LATEST /// -/// Valid values of \a libver_high are as follows: -/// \li \c H5F_LIBVER_18 -/// \li \c H5F_LIBVER_LATEST (Default) +/// Valid values of \a libver_high are as follows: +/// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_LATEST (Default) /// -/// For more details, please refer to +/// For more details, please refer to /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetLibverBounds -// Programmer: Binh-Minh Ribler - March, 2015 +// Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const { herr_t ret_value = H5Pset_libver_bounds(id, libver_low, libver_high); if (ret_value < 0) { - throw PropListIException("FileAccPropList::setLibverBounds", "H5Pset_libver_bounds failed"); + throw PropListIException("FileAccPropList::setLibverBounds", "H5Pset_libver_bounds failed"); } } //-------------------------------------------------------------------------- -// Function: FileAccPropList::getLibverBounds -///\brief Gets the current settings for the library version format bounds -/// from a file access property list. -///\param libver_low - OUT: Earliest version of the library that will be -/// used for creating or writing objects -///\param libver_high - OUT: Latest version of the library that will be -/// used for creating or writing objects -///\exception H5::PropListIException +// Function: FileAccPropList::getLibverBounds +///\brief Gets the current settings for the library version format bounds +/// from a file access property list. +///\param libver_low - OUT: Earliest version of the library that will be +/// used for creating or writing objects +///\param libver_high - OUT: Latest version of the library that will be +/// used for creating or writing objects +///\exception H5::PropListIException ///\par Description -/// On success, the argument \a libver_low can have the following -/// values: -/// \li \c H5F_LIBVER_EARLIEST -/// \li \c H5F_LIBVER_18 -/// \li \c H5F_LIBVER_LATEST +/// On success, the argument \a libver_low can have the following +/// values: +/// \li \c H5F_LIBVER_EARLIEST +/// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_LATEST /// -/// and \a libver_high: -/// \li \c H5F_LIBVER_18 -/// \li \c H5F_LIBVER_LATEST -// Programmer: Binh-Minh Ribler - March, 2015 +/// and \a libver_high: +/// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_LATEST +// Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const { herr_t ret_value = H5Pget_libver_bounds(id, &libver_low, &libver_high); - if( ret_value < 0 ) + if (ret_value < 0) { - throw PropListIException("FileAccPropList::getLibverBounds", "H5Pget_libver_bounds failed"); + throw PropListIException("FileAccPropList::getLibverBounds", "H5Pget_libver_bounds failed"); } } //-------------------------------------------------------------------------- -// Function: FileAccPropList destructor -///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Function: FileAccPropList destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileAccPropList::~FileAccPropList() {} diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index aec5fcc..ae7c7f9 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -27,121 +27,121 @@ namespace H5 { */ class H5_DLLCPP FileAccPropList : public PropList { public: - ///\brief Default file access property list. - static const FileAccPropList& DEFAULT; + ///\brief Default file access property list. + static const FileAccPropList& DEFAULT; - // Creates a file access property list. - FileAccPropList(); + // Creates a file access property list. + FileAccPropList(); - // Modifies this property list to use the H5FD_STDIO driver - void setStdio() const; + // Modifies this property list to use the H5FD_STDIO driver + void setStdio() const; - // Set file driver for this property list - void setDriver(hid_t new_driver_id, const void *new_driver_info) const; + // Set file driver for this property list + void setDriver(hid_t new_driver_id, const void *new_driver_info) const; - // Returns a low-level file driver identifier. - hid_t getDriver() const; + // Returns a low-level file driver identifier. + hid_t getDriver() const; - // Sets offset for family driver. - void setFamilyOffset(hsize_t offset) const; + // Sets offset for family driver. + void setFamilyOffset(hsize_t offset) const; - // Gets offset for family driver. - hsize_t getFamilyOffset() const; + // Gets offset for family driver. + hsize_t getFamilyOffset() const; - // Modifies this file access property list to use the sec2 driver. - void setSec2() const; + // Modifies this file access property list to use the sec2 driver. + void setSec2() const; - // Modifies this file access property list to use the H5FD_CORE - // driver. - void setCore (size_t increment, hbool_t backing_store) const; + // Modifies this file access property list to use the H5FD_CORE + // driver. + void setCore (size_t increment, hbool_t backing_store) const; - // Queries H5FD_CORE driver properties. - void getCore (size_t& increment, hbool_t& backing_store) const; + // Queries H5FD_CORE driver properties. + void getCore (size_t& increment, hbool_t& backing_store) const; - // Sets this file access properties list to the family driver. - void setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const; + // Sets this file access properties list to the family driver. + void setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const; - // Returns information about the family file access property list. - void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; - FileAccPropList getFamily(hsize_t& memb_size) const; + // Returns information about the family file access property list. + void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; + FileAccPropList getFamily(hsize_t& memb_size) const; - // Emulates the old split file driver, - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const char* meta_ext = ".meta", - const char* raw_ext = ".raw" ) const; - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const H5std_string& meta_ext = ".meta", - const H5std_string& raw_ext = ".raw") const; + // Emulates the old split file driver, + void setSplit(const FileAccPropList& meta_plist, + const FileAccPropList& raw_plist, + const char* meta_ext = ".meta", + const char* raw_ext = ".raw") const; + void setSplit(const FileAccPropList& meta_plist, + const FileAccPropList& raw_plist, + const H5std_string& meta_ext = ".meta", + const H5std_string& raw_ext = ".raw") const; - // Sets the maximum size of the data sieve buffer. - void setSieveBufSize(size_t bufsize) const; + // Sets the maximum size of the data sieve buffer. + void setSieveBufSize(size_t bufsize) const; - // Returns the current settings for the data sieve buffer size - // property - size_t getSieveBufSize() const; + // Returns the current settings for the data sieve buffer size + // property + size_t getSieveBufSize() const; - // Sets the minimum size of metadata block allocations. - void setMetaBlockSize(hsize_t &block_size) const; + // Sets the minimum size of metadata block allocations. + void setMetaBlockSize(hsize_t &block_size) const; - // Returns the current metadata block size setting. - hsize_t getMetaBlockSize() const; + // Returns the current metadata block size setting. + hsize_t getMetaBlockSize() const; - // Modifies this file access property list to use the logging driver. - void setLog(const char *logfile, unsigned flags, size_t buf_size) const; - void setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const; + // Modifies this file access property list to use the logging driver. + void setLog(const char *logfile, unsigned flags, size_t buf_size) const; + void setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const; - // Sets alignment properties of this file access property list - void setAlignment( hsize_t threshold = 1, hsize_t alignment = 1 ) const; + // Sets alignment properties of this file access property list + void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; - // Retrieves the current settings for alignment properties from - // this property list. - void getAlignment( hsize_t& threshold, hsize_t& alignment ) const; + // Retrieves the current settings for alignment properties from + // this property list. + void getAlignment(hsize_t& threshold, hsize_t& alignment) const; - // Sets data type for multi driver. - void setMultiType(H5FD_mem_t dtype) const; + // Sets data type for multi driver. + void setMultiType(H5FD_mem_t dtype) const; - // Returns the data type property for MULTI driver. - H5FD_mem_t getMultiType() const; + // Returns the data type property for MULTI driver. + H5FD_mem_t getMultiType() const; - // Sets the meta data cache and raw data chunk cache parameters. - void setCache( int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const; + // Sets the meta data cache and raw data chunk cache parameters. + void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; - // Queries the meta data cache and raw data chunk cache parameters. - void getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const; + // Queries the meta data cache and raw data chunk cache parameters. + void getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const; - // Sets the degree for the file close behavior. - void setFcloseDegree(H5F_close_degree_t degree) const; + // Sets the degree for the file close behavior. + void setFcloseDegree(H5F_close_degree_t degree) const; - // Returns the degree for the file close behavior. - H5F_close_degree_t getFcloseDegree() const; + // Returns the degree for the file close behavior. + H5F_close_degree_t getFcloseDegree() const; - // Sets garbage collecting references flag. - void setGcReferences( unsigned gc_ref = 0 ) const; + // Sets garbage collecting references flag. + void setGcReferences(unsigned gc_ref = 0) const; - // Returns garbage collecting references setting. - unsigned getGcReferences() const; + // Returns garbage collecting references setting. + unsigned getGcReferences() const; - // Sets bounds on versions of library format to be used when creating - // or writing objects. - void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; + // Sets bounds on versions of library format to be used when creating + // or writing objects. + void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; - // Gets the current settings for the library version format bounds. - void getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const; + // Gets the current settings for the library version format bounds. + void getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FileAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("FileAccPropList"); } - // Copy constructor: creates a copy of a FileAccPropList object. - FileAccPropList( const FileAccPropList& original ); + // Copy constructor: creates a copy of a FileAccPropList object. + FileAccPropList(const FileAccPropList& original); - // Creates a copy of an existing file access property list - // using the property list id. - FileAccPropList (const hid_t plist_id); + // Creates a copy of an existing file access property list + // using the property list id. + FileAccPropList (const hid_t plist_id); - // Noop destructor - virtual ~FileAccPropList(); + // Noop destructor + virtual ~FileAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index ed6064f..c490f26 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -33,7 +33,7 @@ FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileCreatPropList::getConstant -// Purpose: Creates a FileCreatPropList object representing the HDF5 +// Purpose Creates a FileCreatPropList object representing the HDF5 // constant H5P_FILE_ACCESS, pointed to by FileCreatPropList::DEFAULT_ // exception H5::PropListIException // Description @@ -62,7 +62,7 @@ FileCreatPropList* FileCreatPropList::getConstant() //-------------------------------------------------------------------------- // Function: FileCreatPropList::deleteConstants -// Purpose: Deletes the constant object that FileCreatPropList::DEFAULT_ +// Purpose Deletes the constant object that FileCreatPropList::DEFAULT_ // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- @@ -73,302 +73,302 @@ void FileCreatPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose Constant for default property +// Purpose Constant for default property //-------------------------------------------------------------------------- const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: FileCreatPropList default constructor -///\brief Default constructor: Creates a file create property list -// Programmer Binh-Minh Ribler - 2000 +// Function: FileCreatPropList default constructor +///\brief Default constructor: Creates a file create property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList() : PropList( H5P_FILE_CREATE ) {} +FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} //-------------------------------------------------------------------------- -// Function: FileCreatPropList copy constructor -///\brief Copy constructor: makes a copy of the original -/// FileCreatPropList object. -///\param original - IN: FileCreatPropList instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: FileCreatPropList copy constructor +///\brief Copy constructor: makes a copy of the original +/// FileCreatPropList object. +///\param original - IN: FileCreatPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList( const FileCreatPropList& original ) : PropList( original ) {} +FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropList( original ) {} //-------------------------------------------------------------------------- -// Function: FileCreatPropList overloaded constructor -///\brief Creates a file creation property list using the id of an -/// existing one. -///\param plist_id - IN: FileCreatPropList id to use -// Programmer Binh-Minh Ribler - 2000 +// Function: FileCreatPropList overloaded constructor +///\brief Creates a file creation property list using the id of an +/// existing one. +///\param plist_id - IN: FileCreatPropList id to use +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) {} #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getVersion -///\brief Retrieves version information for various parts of a file. -///\param super - OUT: The file super block. -///\param freelist - OUT: The global free list. -///\param stab - OUT: The root symbol table entry. -///\param shhdr - OUT: Shared object headers. -///\exception H5::PropListIException +// Function: FileCreatPropList::getVersion +///\brief Retrieves version information for various parts of a file. +///\param super - OUT: The file super block. +///\param freelist - OUT: The global free list. +///\param stab - OUT: The root symbol table entry. +///\param shhdr - OUT: Shared object headers. +///\exception H5::PropListIException ///\par Description -/// Any (or even all) of the output arguments can be null pointers. -// Programmer Binh-Minh Ribler - 2000 +/// Any (or even all) of the output arguments can be null pointers. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const { - herr_t ret_value = H5Pget_version( id, &super, &freelist, &stab, &shhdr ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::getVersion", - "H5Pget_version failed"); - } + herr_t ret_value = H5Pget_version(id, &super, &freelist, &stab, &shhdr); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getVersion", + "H5Pget_version failed"); + } } #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setUserblock -///\brief Sets the user block size field of this file creation property list. -///\param size - IN: User block size to be set, in bytes -///\exception H5::PropListIException +// Function: FileCreatPropList::setUserblock +///\brief Sets the user block size field of this file creation property list. +///\param size - IN: User block size to be set, in bytes +///\exception H5::PropListIException ///\par Description -/// The default user block size is 0; it may be set to any power -/// of 2 equal to 512 or greater (512, 1024, 2048, etc.) -// Programmer Binh-Minh Ribler - 2000 +/// The default user block size is 0; it may be set to any power +/// of 2 equal to 512 or greater (512, 1024, 2048, etc.) +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setUserblock( hsize_t size ) const +void FileCreatPropList::setUserblock(hsize_t size) const { - herr_t ret_value = H5Pset_userblock( id, size); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::setUserblock", - "H5Pset_userblock failed"); - } + herr_t ret_value = H5Pset_userblock(id, size); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::setUserblock", + "H5Pset_userblock failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getUserblock -///\brief Returns the user block size of this file creation property list. -///\return User block size -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: FileCreatPropList::getUserblock +///\brief Returns the user block size of this file creation property list. +///\return User block size +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- hsize_t FileCreatPropList::getUserblock() const { - hsize_t userblock_size; - herr_t ret_value = H5Pget_userblock( id, &userblock_size ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::getUserblock", - "H5Pget_userblock failed"); - } - return( userblock_size ); + hsize_t userblock_size; + herr_t ret_value = H5Pget_userblock(id, &userblock_size); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getUserblock", + "H5Pget_userblock failed"); + } + return(userblock_size); } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setSizes -///\brief Sets the byte size of the offsets and lengths used to -/// address objects in an HDF5 file. -///\param sizeof_addr - IN: Size of an object offset in bytes -///\param sizeof_size - IN: Size of an object length in bytes. -///\exception H5::PropListIException +// Function: FileCreatPropList::setSizes +///\brief Sets the byte size of the offsets and lengths used to +/// address objects in an HDF5 file. +///\param sizeof_addr - IN: Size of an object offset in bytes +///\param sizeof_size - IN: Size of an object length in bytes. +///\exception H5::PropListIException ///\par Description -/// For information on setting sizes, please refer to the -/// C layer Reference Manual at: +/// For information on setting sizes, please refer to the +/// C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSizes -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSizes( size_t sizeof_addr, size_t sizeof_size ) const +void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const { - herr_t ret_value = H5Pset_sizes( id, sizeof_addr, sizeof_size ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::setSizes", - "H5Pset_sizes failed"); - } + herr_t ret_value = H5Pset_sizes(id, sizeof_addr, sizeof_size); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::setSizes", + "H5Pset_sizes failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getSizes -///\brief Retrieves the size of the offsets and lengths used in an -/// HDF5 file. +// Function: FileCreatPropList::getSizes +///\brief Retrieves the size of the offsets and lengths used in an +/// HDF5 file. /// -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSizes( size_t& sizeof_addr, size_t& sizeof_size ) const +void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const { - herr_t ret_value = H5Pget_sizes( id, &sizeof_addr, &sizeof_size ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::getSizes", - "H5Pget_sizes failed"); - } + herr_t ret_value = H5Pget_sizes(id, &sizeof_addr, &sizeof_size); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getSizes", + "H5Pget_sizes failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setSymk -///\brief Sets the size of parameters used to control the symbol table -/// nodes. -///\param ik - IN: Symbol table tree rank -///\param lk - IN: Symbol table node size -///\exception H5::PropListIException +// Function: FileCreatPropList::setSymk +///\brief Sets the size of parameters used to control the symbol table +/// nodes. +///\param ik - IN: Symbol table tree rank +///\param lk - IN: Symbol table node size +///\exception H5::PropListIException ///\par Description -/// For information, please see the C layer Reference Manual at: +/// For information, please see the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSymK -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSymk( unsigned ik, unsigned lk ) const +void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const { - herr_t ret_value = H5Pset_sym_k( id, ik, lk ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::setSymk", - "H5Pset_sym_k failed"); - } + herr_t ret_value = H5Pset_sym_k(id, ik, lk); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::setSymk", + "H5Pset_sym_k failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getSymk -///\brief Retrieves the size of the symbol table B-tree 1/2 rank and -/// the symbol table leaf node 1/2 size. +// Function: FileCreatPropList::getSymk +///\brief Retrieves the size of the symbol table B-tree 1/2 rank and +/// the symbol table leaf node 1/2 size. /// -///\exception H5::PropListIException +///\exception H5::PropListIException ///\par Description -/// For information, please see +/// For information, please see /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetSymK -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSymk( unsigned& ik, unsigned& lk ) const +void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const { - herr_t ret_value = H5Pget_sym_k( id, &ik, &lk ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::getSymk", - "H5Pget_sym_k failed"); - } + herr_t ret_value = H5Pget_sym_k(id, &ik, &lk); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getSymk", + "H5Pget_sym_k failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setIstorek -///\brief Sets the size of the parameter used to control the B-trees -/// for indexing chunked datasets. -///\param ik - IN: 1/2 rank of chunked storage B-tree -///\exception H5::PropListIException +// Function: FileCreatPropList::setIstorek +///\brief Sets the size of the parameter used to control the B-trees +/// for indexing chunked datasets. +///\param ik - IN: 1/2 rank of chunked storage B-tree +///\exception H5::PropListIException ///\par Description -/// For information, please see the C layer Reference Manual at: +/// For information, please see the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetIstoreK -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setIstorek( unsigned ik ) const +void FileCreatPropList::setIstorek(unsigned ik) const { - herr_t ret_value = H5Pset_istore_k( id, ik ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::setIstorek", - "H5Pset_istore_k failed"); - } + herr_t ret_value = H5Pset_istore_k(id, ik); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::setIstorek", + "H5Pset_istore_k failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getIstorek -///\brief Returns the 1/2 rank of an indexed storage B-tree. -///\return 1/2 rank of chunked storage B-tree -///\exception H5::PropListIException +// Function: FileCreatPropList::getIstorek +///\brief Returns the 1/2 rank of an indexed storage B-tree. +///\return 1/2 rank of chunked storage B-tree +///\exception H5::PropListIException ///\par Description -/// For information, please see +/// For information, please see /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetIstoreK -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- unsigned FileCreatPropList::getIstorek() const { - unsigned ik; - herr_t ret_value = H5Pget_istore_k( id, &ik ); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::getIstorek", - "H5Pget_istore_k failed"); - } - return( ik ); + unsigned ik; + herr_t ret_value = H5Pget_istore_k(id, &ik); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getIstorek", + "H5Pget_istore_k failed"); + } + return(ik); } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setFileSpace -///\brief Sets the strategy and the threshold value that the library -/// will employ in managing file space. -///\param strategy - IN: Strategy for file space management -///\param threshold - IN: Free-space section threshold. The library -/// default is 1, which is to track all free-space sections. -///\exception H5::PropListIException +// Function: FileCreatPropList::setFileSpace +///\brief Sets the strategy and the threshold value that the library +/// will employ in managing file space. +///\param strategy - IN: Strategy for file space management +///\param threshold - IN: Free-space section threshold. The library +/// default is 1, which is to track all free-space sections. +///\exception H5::PropListIException ///\par Description -/// If the given strategy is zero, the property will not be -/// changed and the existing strategy will be retained. -/// If the given threshold value is zero, the property will not be -/// changed and the existing threshold will be retained. -/// Valid values of \a libver_low are as follows: -/// \li \c H5F_FILE_SPACE_ALL (Default) -/// \li \c H5F_FILE_SPACE_ALL_PERSIST -/// \li \c H5F_FILE_SPACE_AGGR_VFD -/// \li \c H5F_FILE_SPACE_VFD -/// For information, please see the C layer Reference Manual at: +/// If the given strategy is zero, the property will not be +/// changed and the existing strategy will be retained. +/// If the given threshold value is zero, the property will not be +/// changed and the existing threshold will be retained. +/// Valid values of \a libver_low are as follows: +/// \li \c H5F_FILE_SPACE_ALL (Default) +/// \li \c H5F_FILE_SPACE_ALL_PERSIST +/// \li \c H5F_FILE_SPACE_AGGR_VFD +/// \li \c H5F_FILE_SPACE_VFD +/// For information, please see the C layer Reference Manual at: /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFileSpace -// Programmer Binh-Minh Ribler - Feb, 2017 +// Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- void FileCreatPropList::setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const { - herr_t ret_value = H5Pset_file_space(id, strategy, threshold); - if( ret_value < 0 ) - { - throw PropListIException("FileCreatPropList::setFileSpace", - "H5Pset_file_space failed"); - } + herr_t ret_value = H5Pset_file_space(id, strategy, threshold); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::setFileSpace", + "H5Pset_file_space failed"); + } } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getFileSpaceStrategy -///\brief Returns the strategy that the library uses in managing file space. -///\return The strategy value -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - Feb, 2017 +// Function: FileCreatPropList::getFileSpaceStrategy +///\brief Returns the strategy that the library uses in managing file space. +///\return The strategy value +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- H5F_file_space_type_t FileCreatPropList::getFileSpaceStrategy() const { - H5F_file_space_type_t strategy = H5F_FILE_SPACE_ALL; - herr_t ret_value = H5Pget_file_space(id, &strategy, NULL); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getFileSpaceStrategy", - "H5Pget_file_space for strategy failed"); - } - return(strategy); + H5F_file_space_type_t strategy = H5F_FILE_SPACE_ALL; + herr_t ret_value = H5Pget_file_space(id, &strategy, NULL); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getFileSpaceStrategy", + "H5Pget_file_space for strategy failed"); + } + return(strategy); } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getFileSpaceThreshold -///\brief Returns the threshold value that the library uses in tracking -/// free space sections. -///\return The threshold value -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - Feb, 2017 +// Function: FileCreatPropList::getFileSpaceThreshold +///\brief Returns the threshold value that the library uses in tracking +/// free space sections. +///\return The threshold value +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- hsize_t FileCreatPropList::getFileSpaceThreshold() const { - hsize_t threshold = 0; - herr_t ret_value = H5Pget_file_space(id, NULL, &threshold); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getFileSpaceThreshold", - "H5Pget_file_space for threshold failed"); - } - return(threshold); + hsize_t threshold = 0; + herr_t ret_value = H5Pget_file_space(id, NULL, &threshold); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getFileSpaceThreshold", + "H5Pget_file_space for threshold failed"); + } + return(threshold); } //-------------------------------------------------------------------------- -// Function: FileCreatPropList destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: FileCreatPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileCreatPropList::~FileCreatPropList() {} diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index cadff8b..1bbaabf 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -27,78 +27,78 @@ namespace H5 { */ class H5_DLLCPP FileCreatPropList : public PropList { public: - ///\brief Default file creation property list. - static const FileCreatPropList& DEFAULT; + ///\brief Default file creation property list. + static const FileCreatPropList& DEFAULT; - // Creates a file create property list. - FileCreatPropList(); + // Creates a file create property list. + FileCreatPropList(); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves version information for various parts of a file. - void getVersion( unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr ) const; + // Retrieves version information for various parts of a file. + void getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Sets the userblock size field of a file creation property list. - void setUserblock( hsize_t size ) const; + // Sets the userblock size field of a file creation property list. + void setUserblock(hsize_t size) const; - // Gets the size of a user block in this file creation property list. - hsize_t getUserblock() const; + // Gets the size of a user block in this file creation property list. + hsize_t getUserblock() const; - // Retrieves the size-of address and size quantities stored in a - // file according to this file creation property list. - void getSizes( size_t& sizeof_addr, size_t& sizeof_size ) const; + // Retrieves the size-of address and size quantities stored in a + // file according to this file creation property list. + void getSizes(size_t& sizeof_addr, size_t& sizeof_size) const; - // Sets file size-of addresses and sizes. - void setSizes( size_t sizeof_addr = 4, size_t sizeof_size = 4 ) const; + // Sets file size-of addresses and sizes. + void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; - // Retrieves the size of the symbol table B-tree 1/2 rank and the - // symbol table leaf node 1/2 size. - void getSymk( unsigned& int_nodes_k, unsigned& leaf_nodes_k ) const; + // Retrieves the size of the symbol table B-tree 1/2 rank and the + // symbol table leaf node 1/2 size. + void getSymk(unsigned& int_nodes_k, unsigned& leaf_nodes_k) const; - // Sets the size of parameters used to control the symbol table nodes. - void setSymk( unsigned int_nodes_k, unsigned leaf_nodes_k ) const; + // Sets the size of parameters used to control the symbol table nodes. + void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; - // Returns the 1/2 rank of an indexed storage B-tree. - unsigned getIstorek() const; + // Returns the 1/2 rank of an indexed storage B-tree. + unsigned getIstorek() const; - // Sets the size of parameter used to control the B-trees for - // indexing chunked datasets. - void setIstorek( unsigned ik ) const; + // Sets the size of parameter used to control the B-trees for + // indexing chunked datasets. + void setIstorek(unsigned ik) const; - // Sets the strategy and the threshold value that the library will - // will employ in managing file space. - void setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const; + // Sets the strategy and the threshold value that the library will + // will employ in managing file space. + void setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const; - // Returns the strategy that the library uses in managing file space. - H5F_file_space_type_t getFileSpaceStrategy() const; + // Returns the strategy that the library uses in managing file space. + H5F_file_space_type_t getFileSpaceStrategy() const; - // Returns the threshold value that the library uses in tracking free - // space sections. - hsize_t getFileSpaceThreshold() const; + // Returns the threshold value that the library uses in tracking free + // space sections. + hsize_t getFileSpaceThreshold() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FileCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass() const { return("FileCreatPropList"); } - // Copy constructor: creates a copy of a FileCreatPropList object. - FileCreatPropList(const FileCreatPropList& orig); + // Copy constructor: creates a copy of a FileCreatPropList object. + FileCreatPropList(const FileCreatPropList& orig); - // Creates a copy of an existing file create property list - // using the property list id. - FileCreatPropList (const hid_t plist_id); + // Creates a copy of an existing file create property list + // using the property list id. + FileCreatPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileCreatPropList(); + // Noop destructor + virtual ~FileCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); private: - static FileCreatPropList* DEFAULT_; + static FileCreatPropList* DEFAULT_; - // Creates the global constant, should only be used by the library - static FileCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileCreatPropList* getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index cd97025..cdb5837 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -46,43 +46,43 @@ namespace H5 { //-------------------------------------------------------------------------- // Function H5File default constructor -///\brief Default constructor: creates a stub H5File object. -// Programmer Binh-Minh Ribler - 2000 +///\brief Default constructor: creates a stub H5File object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File() : Group(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- -// Function: H5File overloaded constructor -///\brief Creates or opens an HDF5 file depending on the parameter flags. -///\param name - IN: Name of the file -///\param flags - IN: File access flags -///\param create_plist - IN: File creation property list, used when -/// modifying default file meta-data. Default to -/// FileCreatPropList::DEFAULT -///\param access_plist - IN: File access property list. Default to -/// FileAccPropList::DEFAULT +// Function: H5File overloaded constructor +///\brief Creates or opens an HDF5 file depending on the parameter flags. +///\param name - IN: Name of the file +///\param flags - IN: File access flags +///\param create_plist - IN: File creation property list, used when +/// modifying default file meta-data. Default to +/// FileCreatPropList::DEFAULT +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT ///\par Description -/// Valid values of \a flags include: -/// \li \c H5F_ACC_TRUNC - Truncate file, if it already exists, -/// erasing all data previously stored in -/// the file. -/// \li \c H5F_ACC_EXCL - Fail if file already exists. -/// \c H5F_ACC_TRUNC and \c H5F_ACC_EXCL are mutually exclusive -/// \li \c H5F_ACC_RDONLY - Open file as read-only, if it already -/// exists, and fail, otherwise -/// \li \c H5F_ACC_RDWR - Open file for read/write, if it already -/// exists, and fail, otherwise +/// Valid values of \a flags include: +/// \li \c H5F_ACC_TRUNC - Truncate file, if it already exists, +/// erasing all data previously stored in +/// the file. +/// \li \c H5F_ACC_EXCL - Fail if file already exists. +/// \c H5F_ACC_TRUNC and \c H5F_ACC_EXCL are mutually exclusive +/// \li \c H5F_ACC_RDONLY - Open file as read-only, if it already +/// exists, and fail, otherwise +/// \li \c H5F_ACC_RDWR - Open file for read/write, if it already +/// exists, and fail, otherwise ///\par -/// For info on file creation in the case of an already-open file, -/// please refer to the \b Special \b case section in the C layer -/// Reference Manual at: +/// For info on file creation in the case of an already-open file, +/// please refer to the \b Special \b case section in the C layer +/// Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Create // Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file -// could not be caught in the applications. Added try block here -// to catch then re-throw it. -BMR 2013/03/21 -// Programmer Binh-Minh Ribler - 2000 +// could not be caught in the applications. Added try block here +// to catch then re-throw it. -BMR 2013/03/21 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) { try { p_get_file(name, flags, create_plist, access_plist); @@ -92,22 +92,22 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c } //-------------------------------------------------------------------------- -// Function: H5File overloaded constructor -///\brief This is another overloaded constructor. It differs from the -/// above constructor only in the type of the \a name argument. -///\param name - IN: Name of the file - \c H5std_string -///\param flags - IN: File access flags -///\param create_plist - IN: File creation property list, used when -/// modifying default file meta-data. Default to -/// FileCreatPropList::DEFAULT -///\param access_plist - IN: File access property list. Default to -/// FileAccPropList::DEFAULT +// Function: H5File overloaded constructor +///\brief This is another overloaded constructor. It differs from the +/// above constructor only in the type of the \a name argument. +///\param name - IN: Name of the file - \c H5std_string +///\param flags - IN: File access flags +///\param create_plist - IN: File creation property list, used when +/// modifying default file meta-data. Default to +/// FileCreatPropList::DEFAULT +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT // Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file -// could not be caught in the applications. Added try block here -// to catch then re-throw it. -BMR 2013/03/21 -// Programmer Binh-Minh Ribler - 2000 +// could not be caught in the applications. Added try block here +// to catch then re-throw it. -BMR 2013/03/21 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); @@ -120,21 +120,21 @@ H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPro //-------------------------------------------------------------------------- // This function is private and contains common code between the // constructors taking a string or a char* -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 // Modification -// - removed H5F_ACC_CREAT because H5Fcreate will fail with -// H5F_ACC_CREAT. - BMR, Sep 17, 2014 +// - removed H5F_ACC_CREAT because H5Fcreate will fail with +// H5F_ACC_CREAT. - BMR, Sep 17, 2014 //-------------------------------------------------------------------------- void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) { // These bits only set for creation, so if any of them are set, // create the file. - if( flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) + if (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) { hid_t create_plist_id = create_plist.getId(); hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate( name, flags, create_plist_id, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail + id = H5Fcreate(name, flags, create_plist_id, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fcreate failed"); } @@ -143,8 +143,8 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro else { hid_t access_plist_id = access_plist.getId(); - id = H5Fopen( name, flags, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fopen failed"); } @@ -152,17 +152,17 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro } //-------------------------------------------------------------------------- -// Function: H5File overloaded constructor -///\brief Creates an H5File object using an existing file id. -///\param existing_id - IN: Id of an existing file -// Programmer Binh-Minh Ribler - 2015 +// Function: H5File overloaded constructor +///\brief Creates an H5File object using an existing file id. +///\param existing_id - IN: Id of an existing file +// Programmer Binh-Minh Ribler - 2015 // Description // Mar 29, 2015 -// Added in responding to a request from user Jason Newton. -// However, it is not recommended to use the private member "id" -// in applications. Unlike other situations, where similar -// constructor is needed by the library in order to return -// an object, H5File doesn't need it. -BMR (HDFFV-8766 partially) +// Added in responding to a request from user Jason Newton. +// However, it is not recommended to use the private member "id" +// in applications. Unlike other situations, where similar +// constructor is needed by the library in order to return +// an object, H5File doesn't need it. -BMR (HDFFV-8766 partially) //-------------------------------------------------------------------------- H5File::H5File(hid_t existing_id) : Group() { @@ -173,11 +173,11 @@ H5File::H5File(hid_t existing_id) : Group() #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File copy constructor -///\brief Copy constructor: makes a copy of the original -/// H5File object. -///\param original - IN: H5File instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File copy constructor +///\brief Copy constructor: makes a copy of the original +/// H5File object. +///\param original - IN: H5File instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File(const H5File& original) : Group() { @@ -186,57 +186,57 @@ H5File::H5File(const H5File& original) : Group() } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 (static) -///\brief Determines whether a file in HDF5 format. (Static) -///\param name - IN: Name of the file -///\return true if the file is in HDF5 format, and false, otherwise -///\exception H5::FileIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::isHdf5 (static) +///\brief Determines whether a file in HDF5 format. (Static) +///\param name - IN: Name of the file +///\return true if the file is in HDF5 format, and false, otherwise +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool H5File::isHdf5(const char* name) { - // Calls C routine H5Fis_hdf5 to determine whether the file is in - // HDF5 format. It returns positive value, 0, or negative value - htri_t ret_value = H5Fis_hdf5( name ); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else // Raise exception when H5Fis_hdf5 returns a negative value - { - throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value"); - } + // Calls C routine H5Fis_hdf5 to determine whether the file is in + // HDF5 format. It returns positive value, 0, or negative value + htri_t ret_value = H5Fis_hdf5(name); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Fis_hdf5 returns a negative value + { + throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value"); + } } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 (static) -///\brief This is an overloaded member function, provided for convenience. -/// It takes an \c H5std_string for \a name. (Static) -///\param name - IN: Name of the file - \c H5std_string -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::isHdf5 (static) +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \c H5std_string for \a name. (Static) +///\param name - IN: Name of the file - \c H5std_string +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const H5std_string& name ) +bool H5File::isHdf5(const H5std_string& name) { - return( isHdf5( name.c_str()) ); + return(isHdf5( name.c_str())); } //-------------------------------------------------------------------------- -// Function: openFile -///\brief Opens an HDF5 file -///\param name - IN: Name of the file -///\param flags - IN: File access flags -///\param access_plist - IN: File access property list. Default to -/// FileAccPropList::DEFAULT +// Function: openFile +///\brief Opens an HDF5 file +///\param name - IN: Name of the file +///\param flags - IN: File access flags +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT ///\par Description -/// Valid values of \a flags include: -/// H5F_ACC_RDWR: Open with read/write access. If the file is -/// currently open for read-only access then it -/// will be reopened. Absence of this flag -/// implies read-only access. +/// Valid values of \a flags include: +/// H5F_ACC_RDWR: Open with read/write access. If the file is +/// currently open for read-only access then it +/// will be reopened. Absence of this flag +/// implies read-only access. /// -/// H5F_ACC_RDONLY: Open with read only access. - default +/// H5F_ACC_RDONLY: Open with read only access. - default /// -// Programmer Binh-Minh Ribler - Oct, 2005 +// Programmer Binh-Minh Ribler - Oct, 2005 //-------------------------------------------------------------------------- void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist) { @@ -256,14 +256,14 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis } //-------------------------------------------------------------------------- -// Function: H5File::openFile -///\brief This is an overloaded member function, provided for convenience. -/// It takes an \c H5std_string for \a name. -///\param name - IN: Name of the file - \c H5std_string -///\param flags - IN: File access flags -///\param access_plist - IN: File access property list. Default to -/// FileAccPropList::DEFAULT -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::openFile +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \c H5std_string for \a name. +///\param name - IN: Name of the file - \c H5std_string +///\param flags - IN: File access flags +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAccPropList& access_plist) { @@ -271,21 +271,21 @@ void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAc } //-------------------------------------------------------------------------- -// Function: H5File::reOpen -///\brief Reopens this file. +// Function: H5File::reOpen +///\brief Reopens this file. /// -///\exception H5::FileIException +///\exception H5::FileIException // Description -// If this object has represented another HDF5 file, the previous -// HDF5 file need to be closed first. -// Programmer Binh-Minh Ribler - 2000 +// If this object has represented another HDF5 file, the previous +// HDF5 file need to be closed first. +// Programmer Binh-Minh Ribler - 2000 // Note: This wrapper doesn't seem right regarding the 'id' and should // be investigated. BMR - 2/20/2005 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Feb 20, 2005 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- void H5File::reOpen() { @@ -296,148 +296,148 @@ void H5File::reOpen() throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } - // call C routine to reopen the file - Note: not sure about this, - // which id to be the parameter when closing? - id = H5Freopen( id ); - if( id < 0 ) // Raise exception when H5Freopen returns a neg value - throw FileIException("H5File::reOpen", "H5Freopen failed"); + // call C routine to reopen the file - Note: not sure about this, + // which id to be the parameter when closing? + id = H5Freopen(id); + if (id < 0) // Raise exception when H5Freopen returns a neg value + throw FileIException("H5File::reOpen", "H5Freopen failed"); } //-------------------------------------------------------------------------- -// Function: H5File::getCreatePlist -///\brief Returns the creation property list of this file -///\return FileCreatPropList object -///\exception H5::FileIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::getCreatePlist +///\brief Returns the creation property list of this file +///\return FileCreatPropList object +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileCreatPropList H5File::getCreatePlist() const { - hid_t create_plist_id = H5Fget_create_plist( id ); - - // if H5Fget_create_plist returns a valid id, create and return - // the FileCreatPropList object for this property list - if( create_plist_id > 0 ) - { - FileCreatPropList create_plist( create_plist_id ); - return( create_plist ); - } - else - { - throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed"); - } + hid_t create_plist_id = H5Fget_create_plist(id); + + // if H5Fget_create_plist returns a valid id, create and return + // the FileCreatPropList object for this property list + if (create_plist_id > 0) + { + FileCreatPropList create_plist(create_plist_id); + return(create_plist); + } + else + { + throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getAccessPlist -///\brief Returns the access property list of this file -///\return FileAccPropList object -///\exception H5::FileIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::getAccessPlist +///\brief Returns the access property list of this file +///\return FileAccPropList object +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FileAccPropList H5File::getAccessPlist() const { - hid_t access_plist_id = H5Fget_access_plist( id ); + hid_t access_plist_id = H5Fget_access_plist(id); - // if H5Fget_access_plist returns a valid id, create and return - // the FileAccPropList object for this property list - if( access_plist_id > 0 ) - { - FileAccPropList access_plist( access_plist_id ); + // if H5Fget_access_plist returns a valid id, create and return + // the FileAccPropList object for this property list + if (access_plist_id > 0) + { + FileAccPropList access_plist(access_plist_id); return access_plist; - } - else // Raise an exception - { - throw FileIException("H5File::getAccessPlist", "H5Fget_access_plist failed"); - } + } + else // Raise an exception + { + throw FileIException("H5File::getAccessPlist", "H5Fget_access_plist failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getFileInfo -///\brief Retrieves the general information of this file. +// Function: H5File::getFileInfo +///\brief Retrieves the general information of this file. /// -///\exception H5::FileIException +///\exception H5::FileIException ///\par Description -/// The retrieved information may include information about -/// superblock extension, free space management, and shared object +/// The retrieved information may include information about +/// superblock extension, free space management, and shared object // Programmer Binh-Minh Ribler - February 2017 //-------------------------------------------------------------------------- void H5File::getFileInfo(H5F_info2_t& file_info) const { - herr_t ret_value = H5Fget_info2(id, &file_info); - if (ret_value < 0) - { - throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed"); - } + herr_t ret_value = H5Fget_info2(id, &file_info); + if (ret_value < 0) + { + throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getFreeSpace -///\brief Returns the amount of free space in the file. -///\return Amount of free space -///\exception H5::FileIException +// Function: H5File::getFreeSpace +///\brief Returns the amount of free space in the file. +///\return Amount of free space +///\exception H5::FileIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- hssize_t H5File::getFreeSpace() const { - hssize_t free_space = H5Fget_freespace(id); - if( free_space < 0 ) - { - throw FileIException("H5File::getFreeSpace", "H5Fget_freespace failed"); - } - return (free_space); + hssize_t free_space = H5Fget_freespace(id); + if (free_space < 0) + { + throw FileIException("H5File::getFreeSpace", "H5Fget_freespace failed"); + } + return (free_space); } //-------------------------------------------------------------------------- -// Function: H5File::getObjCount -///\brief Returns the number of opened object IDs (files, datasets, -/// groups and datatypes) in the same file. -///\param types - Type of object to retrieve the count -///\return Number of opened object IDs -///\exception H5::FileIException +// Function: H5File::getObjCount +///\brief Returns the number of opened object IDs (files, datasets, +/// groups and datatypes) in the same file. +///\param types - Type of object to retrieve the count +///\return Number of opened object IDs +///\exception H5::FileIException ///\par Description -/// The valid values for \a types include: -/// \li \c H5F_OBJ_FILE - Files only -/// \li \c H5F_OBJ_DATASET - Datasets only -/// \li \c H5F_OBJ_GROUP - Groups only -/// \li \c H5F_OBJ_DATATYPE - Named datatypes only -/// \li \c H5F_OBJ_ATTR - Attributes only -/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE -/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP -/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR +/// The valid values for \a types include: +/// \li \c H5F_OBJ_FILE - Files only +/// \li \c H5F_OBJ_DATASET - Datasets only +/// \li \c H5F_OBJ_GROUP - Groups only +/// \li \c H5F_OBJ_DATATYPE - Named datatypes only +/// \li \c H5F_OBJ_ATTR - Attributes only +/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE +/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP +/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR ///\par /// Multiple object types can be combined with the logical OR operator (|). // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- ssize_t H5File::getObjCount(unsigned types) const { - ssize_t num_objs = H5Fget_obj_count(id, types); - if( num_objs < 0 ) - { - throw FileIException("H5File::getObjCount", "H5Fget_obj_count failed"); - } - return (num_objs); + ssize_t num_objs = H5Fget_obj_count(id, types); + if (num_objs < 0) + { + throw FileIException("H5File::getObjCount", "H5Fget_obj_count failed"); + } + return (num_objs); } //-------------------------------------------------------------------------- -// Function: H5File::getObjIDs -///\brief Retrieves a list of opened object IDs (files, datasets, -/// groups and datatypes) in the same file. -///\param types - Type of object to retrieve the count -///\param max_objs - Maximum number of object identifiers to place -/// into obj_id_list. -///\param oid_list - List of open object identifiers -///\exception H5::FileIException +// Function: H5File::getObjIDs +///\brief Retrieves a list of opened object IDs (files, datasets, +/// groups and datatypes) in the same file. +///\param types - Type of object to retrieve the count +///\param max_objs - Maximum number of object identifiers to place +/// into obj_id_list. +///\param oid_list - List of open object identifiers +///\exception H5::FileIException ///\par Description -/// The valid values for \a types include: -/// \li \c H5F_OBJ_FILE - Files only -/// \li \c H5F_OBJ_DATASET - Datasets only -/// \li \c H5F_OBJ_GROUP - Groups only -/// \li \c H5F_OBJ_DATATYPE - Named datatypes only -/// \li \c H5F_OBJ_ATTR - Attributes only -/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE -/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP -/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR +/// The valid values for \a types include: +/// \li \c H5F_OBJ_FILE - Files only +/// \li \c H5F_OBJ_DATASET - Datasets only +/// \li \c H5F_OBJ_GROUP - Groups only +/// \li \c H5F_OBJ_DATATYPE - Named datatypes only +/// \li \c H5F_OBJ_ATTR - Attributes only +/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE +/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP +/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR ///\par /// Multiple object types can be combined with the logical OR operator (|). // @@ -446,56 +446,56 @@ ssize_t H5File::getObjCount(unsigned types) const //-------------------------------------------------------------------------- void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const { - ssize_t ret_value = H5Fget_obj_ids(id, types, max_objs, oid_list); - if( ret_value < 0 ) - { - throw FileIException("H5File::getObjIDs", "H5Fget_obj_ids failed"); - } + ssize_t ret_value = H5Fget_obj_ids(id, types, max_objs, oid_list); + if (ret_value < 0) + { + throw FileIException("H5File::getObjIDs", "H5Fget_obj_ids failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getVFDHandle -///\brief Returns the pointer to the file handle of the low-level file -/// driver. -///\param fapl - File access property list -///\param file_handle - Pointer to the file handle being used by -/// the low-level virtual file driver -///\exception H5::FileIException +// Function: H5File::getVFDHandle +///\brief Returns the pointer to the file handle of the low-level file +/// driver. +///\param fapl - File access property list +///\param file_handle - Pointer to the file handle being used by +/// the low-level virtual file driver +///\exception H5::FileIException ///\par Description -/// For the \c FAMILY or \c MULTI drivers, \a fapl should be -/// defined through the property list functions: -/// \c FileAccPropList::setFamilyOffset for the \c FAMILY driver -/// and \c FileAccPropList::setMultiType for the \c MULTI driver. +/// For the \c FAMILY or \c MULTI drivers, \a fapl should be +/// defined through the property list functions: +/// \c FileAccPropList::setFamilyOffset for the \c FAMILY driver +/// and \c FileAccPropList::setMultiType for the \c MULTI driver. /// -/// The obtained file handle is dynamic and is valid only while -/// the file remains open; it will be invalid if the file is -/// closed and reopened or opened during a subsequent session. +/// The obtained file handle is dynamic and is valid only while +/// the file remains open; it will be invalid if the file is +/// closed and reopened or opened during a subsequent session. // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const { - hid_t fapl_id = fapl.getId(); - herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle); - if( ret_value < 0 ) - { - throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); - } + hid_t fapl_id = fapl.getId(); + herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle); + if (ret_value < 0) + { + throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getVFDHandle -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. +// Function: H5File::getVFDHandle +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. // Param fapl - File access property list // Param file_handle - Pointer to the file handle being used by -// the low-level virtual file driver +// the low-level virtual file driver // Exception H5::FileIException // Programmer Binh-Minh Ribler - May 2004 // Modification -// Planned for removal. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Planned for removal. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const //{ @@ -503,103 +503,103 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const //} //-------------------------------------------------------------------------- -// Function: H5File::getVFDHandle -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param file_handle - Pointer to the file handle being used by -/// the low-level virtual file driver -///\exception H5::FileIException +// Function: H5File::getVFDHandle +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param file_handle - Pointer to the file handle being used by +/// the low-level virtual file driver +///\exception H5::FileIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- void H5File::getVFDHandle(void **file_handle) const { - herr_t ret_value = H5Fget_vfd_handle(id, H5P_DEFAULT, file_handle); - if( ret_value < 0 ) - { - throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); - } + herr_t ret_value = H5Fget_vfd_handle(id, H5P_DEFAULT, file_handle); + if (ret_value < 0) + { + throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); + } } //-------------------------------------------------------------------------- -// Function: H5File::getFileSize -///\brief Returns the file size of the HDF5 file. -///\return File size -///\exception H5::FileIException +// Function: H5File::getFileSize +///\brief Returns the file size of the HDF5 file. +///\return File size +///\exception H5::FileIException ///\par Description -/// This function is called after an existing file is opened in -/// order to learn the true size of the underlying file. +/// This function is called after an existing file is opened in +/// order to learn the true size of the underlying file. // Programmer Raymond Lu - June 24, 2004 //-------------------------------------------------------------------------- hsize_t H5File::getFileSize() const { - hsize_t file_size; - herr_t ret_value = H5Fget_filesize(id, &file_size); - if (ret_value < 0) - { - throw FileIException("H5File::getFileSize", "H5Fget_filesize failed"); - } - return (file_size); + hsize_t file_size; + herr_t ret_value = H5Fget_filesize(id, &file_size); + if (ret_value < 0) + { + throw FileIException("H5File::getFileSize", "H5Fget_filesize failed"); + } + return (file_size); } //-------------------------------------------------------------------------- -// Function: H5File::getId -///\brief Get the id of this file -///\return File identifier -// Modification: +// Function: H5File::getId +///\brief Get the id of this file +///\return File identifier +// Modification // May 2008 - BMR -// Class hierarchy is revised to address bugzilla 1068. Class -// AbstractDS and Attribute are moved out of H5Object. In -// addition, member IdComponent::id is moved into subclasses, and -// IdComponent::getId now becomes pure virtual function. -// Programmer Binh-Minh Ribler - May, 2008 +// Class hierarchy is revised to address bugzilla 1068. Class +// AbstractDS and Attribute are moved out of H5Object. In +// addition, member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. +// Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- hid_t H5File::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::reopen -// Purpose: Reopens this file. +// Function: H5File::reopen +// Purpose Reopens this file. // Exception H5::FileIException // Description -// This function is replaced by the above function reOpen. -// Programmer Binh-Minh Ribler - 2000 +// This function is replaced by the above function reOpen. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::reopen() { - H5File::reOpen(); + H5File::reOpen(); } //-------------------------------------------------------------------------- -// Function: H5File::getLocId -// Purpose: Get the id of this file +// Function: H5File::getLocId +// Purpose Get the id of this file // Description -// This function is a redefinition of CommonFG::getLocId. It -// is used by CommonFG member functions to get the file id. -// Programmer Binh-Minh Ribler - 2000 +// This function is a redefinition of CommonFG::getLocId. It +// is used by CommonFG member functions to get the file id. +// Programmer Binh-Minh Ribler - 2000 // Deprecated: // After HDFFV-9920, the Group's methods can use getId() and getLocId() // is kept for backward compatibility. Aug 18, 2016 -BMR //-------------------------------------------------------------------------- hid_t H5File::getLocId() const { - return( getId() ); + return(getId()); } //-------------------------------------------------------------------------- -// Function: H5File::p_setId (protected) -///\brief Sets the identifier of this object to a new value. +// Function: H5File::p_setId (protected) +///\brief Sets the identifier of this object to a new value. /// -///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails -// Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::IdComponentException when the attempt to close the HDF5 +/// object fails +// Description +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::p_setId(const hid_t new_id) { @@ -610,24 +610,24 @@ void H5File::p_setId(const hid_t new_id) catch (Exception& E) { throw FileIException("H5File::p_setId", E.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::close -///\brief Closes this HDF5 file. +// Function: H5File::close +///\brief Closes this HDF5 file. /// -///\exception H5::FileIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void H5File::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Fclose( id ); - if( ret_value < 0 ) + herr_t ret_value = H5Fclose(id); + if (ret_value < 0) { throw FileIException("H5File::close", "H5Fclose failed"); } @@ -637,34 +637,34 @@ void H5File::close() } //-------------------------------------------------------------------------- -// Function: H5File::throwException -///\brief Throws file exception - initially implemented for CommonFG -///\param func_name - Name of the function where failure occurs -///\param msg - Message describing the failure -///\exception H5::FileIException +// Function: H5File::throwException +///\brief Throws file exception - initially implemented for CommonFG +///\param func_name - Name of the function where failure occurs +///\param msg - Message describing the failure +///\exception H5::FileIException // Description // This function is also used in H5Location implementation so that -// proper exception can be thrown for file or group. The -// "H5File::" will be inserted to indicate the function called is -// an implementation of H5File. -// Programmer Binh-Minh Ribler - 2000 +// proper exception can be thrown for file or group. The +// "H5File::" will be inserted to indicate the function called is +// an implementation of H5File. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::throwException(const H5std_string& func_name, const H5std_string& msg) const { - H5std_string full_name = func_name; - full_name.insert(0, "H5File::"); - throw FileIException(full_name, msg); + H5std_string full_name = func_name; + full_name.insert(0, "H5File::"); + throw FileIException(full_name, msg); } //-------------------------------------------------------------------------- -// Function: H5File destructor -///\brief Properly terminates access to this file. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File destructor +///\brief Properly terminates access to this file. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Feb 20, 2005 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- H5File::~H5File() { diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 495b4d0..5ac9118 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -28,100 +28,100 @@ namespace H5 { */ class H5_DLLCPP H5File : public Group { public: - // Creates or opens an HDF5 file. - H5File( const char* name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT ); - H5File( const H5std_string& name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT ); + // Creates or opens an HDF5 file. + H5File(const char* name, unsigned int flags, + const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + H5File(const H5std_string& name, unsigned int flags, + const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - // Open the file - void openFile(const H5std_string& name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - void openFile(const char* name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Open the file + void openFile(const H5std_string& name, unsigned int flags, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + void openFile(const char* name, unsigned int flags, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - // Close this file. - virtual void close(); + // Close this file. + virtual void close(); - // Gets the access property list of this file. - FileAccPropList getAccessPlist() const; + // Gets the access property list of this file. + FileAccPropList getAccessPlist() const; - // Gets the creation property list of this file. - FileCreatPropList getCreatePlist() const; + // Gets the creation property list of this file. + FileCreatPropList getCreatePlist() const; - // Gets general information about this file. - void getFileInfo(H5F_info2_t& file_info) const; + // Gets general information about this file. + void getFileInfo(H5F_info2_t& file_info) const; - // Returns the amount of free space in the file. - hssize_t getFreeSpace() const; + // Returns the amount of free space in the file. + hssize_t getFreeSpace() const; - // Returns the number of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; + // Returns the number of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; - // Retrieves a list of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; + // Retrieves a list of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; - // Returns the pointer to the file handle of the low-level file driver. - void getVFDHandle(void **file_handle) const; - void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; - //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 + // Returns the pointer to the file handle of the low-level file driver. + void getVFDHandle(void **file_handle) const; + void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; + //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 - // Returns the file size of the HDF5 file. - hsize_t getFileSize() const; + // Returns the file size of the HDF5 file. + hsize_t getFileSize() const; - // Determines if a file, specified by its name, is in HDF5 format - static bool isHdf5(const char* name ); - static bool isHdf5(const H5std_string& name ); + // Determines if a file, specified by its name, is in HDF5 format + static bool isHdf5(const char* name); + static bool isHdf5(const H5std_string& name); - // Reopens this file. - void reOpen(); // added for better name + // Reopens this file. + void reOpen(); // added for better name #ifndef DOXYGEN_SHOULD_SKIP_THIS - void reopen(); // obsolete in favor of reOpen() + void reopen(); // obsolete in favor of reOpen() - // Creates an H5File using an existing file id. Not recommended - // in applications. - H5File(hid_t existing_id); + // Creates an H5File using an existing file id. Not recommended + // in applications. + H5File(hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("H5File"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("H5File"); } - // Throw file exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw file exception. + virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const; - // Default constructor - H5File(); + // Default constructor + H5File(); - // Copy constructor: makes a copy of the original H5File object. - H5File(const H5File& original); + // Copy constructor: makes a copy of the original H5File object. + H5File(const H5File& original); - // Gets the HDF5 file id. - virtual hid_t getId() const; + // Gets the HDF5 file id. + virtual hid_t getId() const; - // H5File destructor. - virtual ~H5File(); + // H5File destructor. + virtual ~H5File(); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the HDF5 file id. - virtual void p_setId(const hid_t new_id); + // Sets the HDF5 file id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS private: - hid_t id; // HDF5 file id + hid_t id; // HDF5 file id - // This function is private and contains common code between the - // constructors taking a string or a char* - void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ); + // This function is private and contains common code between the + // constructors taking a string or a char* + void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist); }; } diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index 73e8072..5902cbe 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -36,73 +36,73 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: FloatType default constructor -///\brief Default constructor: Creates a stub floating-point datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType default constructor +///\brief Default constructor: Creates a stub floating-point datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FloatType::FloatType() {} //-------------------------------------------------------------------------- -// Function: FloatType overloaded constructor -///\brief Creates a floating-point datatype using a predefined type. -///\param pred_type - IN: Predefined datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType overloaded constructor +///\brief Creates a floating-point datatype using a predefined type. +///\param pred_type - IN: Predefined datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType( const PredType& pred_type ) : AtomType() +FloatType::FloatType(const PredType& pred_type) : AtomType() { - // use DataType::copy to make a copy of this predefined type - copy( pred_type ); + // use DataType::copy to make a copy of this predefined type + copy(pred_type); } //-------------------------------------------------------------------------- -// Function: FloatType overloaded constructor -///\brief Creates an FloatType object using the id of an existing -/// datatype. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType overloaded constructor +///\brief Creates an FloatType object using the id of an existing +/// datatype. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType( const hid_t existing_id ) : AtomType( existing_id ) {} +FloatType::FloatType(const hid_t existing_id) : AtomType( existing_id ) {} //-------------------------------------------------------------------------- -// Function: FloatType copy constructor -///\brief Copy constructor: makes a copy of the original FloatType object. -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType copy constructor +///\brief Copy constructor: makes a copy of the original FloatType object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType( const FloatType& original ) : AtomType( original ){} +FloatType::FloatType(const FloatType& original) : AtomType( original ){} //-------------------------------------------------------------------------- -// Function: EnumType overloaded constructor -///\brief Gets the floating-point datatype of the specified dataset -///\param dataset - IN: Dataset that this floating-point datatype -/// associates with -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: EnumType overloaded constructor +///\brief Gets the floating-point datatype of the specified dataset +///\param dataset - IN: Dataset that this floating-point datatype +/// associates with +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType( const DataSet& dataset ) : AtomType() +FloatType::FloatType(const DataSet& dataset) : AtomType() { - // Calls C function H5Dget_type to get the id of the datatype - id = H5Dget_type( dataset.getId() ); + // Calls C function H5Dget_type to get the id of the datatype + id = H5Dget_type(dataset.getId()); - if( id < 0 ) - { - throw DataSetIException("FloatType constructor", "H5Dget_type failed"); - } + if (id < 0) + { + throw DataSetIException("FloatType constructor", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType overloaded constructor -///\brief Creates an FloatType instance by opening an HDF5 float datatype -/// given its name, provided as a C character string. -///\param dtype_name - IN: Float type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: FloatType overloaded constructor +///\brief Creates an FloatType instance by opening an HDF5 float datatype +/// given its name, provided as a C character string. +///\param dtype_name - IN: Float type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openFloatType(const char*) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openFloatType(const char*) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() { @@ -110,213 +110,213 @@ FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() } //-------------------------------------------------------------------------- -// Function: FloatType overloaded constructor -///\brief Creates an FloatType instance by opening an HDF5 float datatype -/// given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Float type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: FloatType overloaded constructor +///\brief Creates an FloatType instance by opening an HDF5 float datatype +/// given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Float type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openFloatType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openFloatType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: FloatType::getFields -///\brief Retrieves floating point datatype bit field information. -///\param spos - OUT: Retrieved floating-point sign bit -///\param epos - OUT: Retrieved exponent bit-position -///\param esize - OUT: Retrieved size of exponent, in bits -///\param mpos - OUT: Retrieved mantissa bit-position -///\param msize - OUT: Retrieved size of mantissa, in bits -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void FloatType::getFields( size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize ) const +// Function: FloatType::getFields +///\brief Retrieves floating point datatype bit field information. +///\param spos - OUT: Retrieved floating-point sign bit +///\param epos - OUT: Retrieved exponent bit-position +///\param esize - OUT: Retrieved size of exponent, in bits +///\param mpos - OUT: Retrieved mantissa bit-position +///\param msize - OUT: Retrieved size of mantissa, in bits +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const { - herr_t ret_value = H5Tget_fields( id, &spos, &epos, &esize, &mpos, &msize ); - if( ret_value < 0 ) - { - throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed"); - } + herr_t ret_value = H5Tget_fields(id, &spos, &epos, &esize, &mpos, &msize); + if (ret_value < 0) + { + throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType::setFields -///\brief Sets locations and sizes of floating point bit fields. -///\param spos - OUT: Sign position, i.e., the bit offset of the -/// floating-point sign bit. -///\param epos - OUT: Exponent bit position -///\param esize - OUT: Size of exponent, in bits -///\param mpos - OUT: Mantissa bit-position -///\param msize - OUT: Size of mantissa, in bits -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void FloatType::setFields( size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize ) const +// Function: FloatType::setFields +///\brief Sets locations and sizes of floating point bit fields. +///\param spos - OUT: Sign position, i.e., the bit offset of the +/// floating-point sign bit. +///\param epos - OUT: Exponent bit position +///\param esize - OUT: Size of exponent, in bits +///\param mpos - OUT: Mantissa bit-position +///\param msize - OUT: Size of mantissa, in bits +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const { - herr_t ret_value = H5Tset_fields( id, spos, epos, esize, mpos, msize ); - if( ret_value < 0 ) - { - throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed"); - } + herr_t ret_value = H5Tset_fields(id, spos, epos, esize, mpos, msize); + if (ret_value < 0) + { + throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType::getEbias -///\brief Retrieves the exponent bias of a floating-point type. -///\return Exponent bias -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType::getEbias +///\brief Retrieves the exponent bias of a floating-point type. +///\return Exponent bias +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- size_t FloatType::getEbias() const { - size_t ebias = H5Tget_ebias( id ); - // Returns the bias if successful - if( ebias == 0 ) - { - throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0"); - } - return( ebias ); + size_t ebias = H5Tget_ebias(id); + // Returns the bias if successful + if (ebias == 0) + { + throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0"); + } + return(ebias); } //-------------------------------------------------------------------------- -// Function: FloatType::setEbias -///\brief Sets the exponent bias of a floating-point type. -///\param ebias - Exponent bias value -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType::setEbias +///\brief Sets the exponent bias of a floating-point type. +///\param ebias - Exponent bias value +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setEbias( size_t ebias ) const +void FloatType::setEbias(size_t ebias) const { - herr_t ret_value = H5Tset_ebias( id, ebias ); - if( ret_value < 0 ) - { - throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed"); - } + herr_t ret_value = H5Tset_ebias(id, ebias); + if (ret_value < 0) + { + throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType::getNorm -///\brief Retrieves mantissa normalization of a floating-point datatype. -///\param norm_string - OUT: Text string of the normalization type -///\return Valid normalization type, which can be: -/// \li \c H5T_NORM_IMPLIED (0) - MSB of mantissa is not stored -/// \li \c H5T_NORM_MSBSET (1) - MSB of mantissa is always 1 -/// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized -///\exception H5::DataTypeIException +// Function: FloatType::getNorm +///\brief Retrieves mantissa normalization of a floating-point datatype. +///\param norm_string - OUT: Text string of the normalization type +///\return Valid normalization type, which can be: +/// \li \c H5T_NORM_IMPLIED (0) - MSB of mantissa is not stored +/// \li \c H5T_NORM_MSBSET (1) - MSB of mantissa is always 1 +/// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized +///\exception H5::DataTypeIException ///\par Description -/// For your convenience, this function also provides the text -/// string of the returned normalization type, via parameter -/// \a norm_string. -// Programmer Binh-Minh Ribler - 2000 +/// For your convenience, this function also provides the text +/// string of the returned normalization type, via parameter +/// \a norm_string. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_norm_t FloatType::getNorm( H5std_string& norm_string ) const +H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const { - H5T_norm_t norm = H5Tget_norm( id ); // C routine - // Returns a valid normalization type if successful - if( norm == H5T_NORM_ERROR ) - { - throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR"); - } - if( norm == H5T_NORM_IMPLIED ) - norm_string = "H5T_NORM_IMPLIED (0)"; - else if( norm == H5T_NORM_MSBSET ) - norm_string = "H5T_NORM_MSBSET (1)"; - else if( norm == H5T_NORM_NONE ) - norm_string = "H5T_NORM_NONE (2)"; - return( norm ); + H5T_norm_t norm = H5Tget_norm(id); // C routine + // Returns a valid normalization type if successful + if (norm == H5T_NORM_ERROR) + { + throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR"); + } + if (norm == H5T_NORM_IMPLIED) + norm_string = "H5T_NORM_IMPLIED (0)"; + else if (norm == H5T_NORM_MSBSET) + norm_string = "H5T_NORM_MSBSET (1)"; + else if (norm == H5T_NORM_NONE) + norm_string = "H5T_NORM_NONE (2)"; + return(norm); } //-------------------------------------------------------------------------- -// Function: FloatType::setNorm -///\brief Sets the mantissa normalization of a floating-point datatype. -///\param norm - IN: Mantissa normalization type -///\exception H5::DataTypeIException +// Function: FloatType::setNorm +///\brief Sets the mantissa normalization of a floating-point datatype. +///\param norm - IN: Mantissa normalization type +///\exception H5::DataTypeIException ///\par Description -/// Valid values for normalization type include: -/// \li \c H5T_NORM_IMPLIED (0) - MSB of mantissa is not stored -/// \li \c H5T_NORM_MSBSET (1) - MSB of mantissa is always 1 -/// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for normalization type include: +/// \li \c H5T_NORM_IMPLIED (0) - MSB of mantissa is not stored +/// \li \c H5T_NORM_MSBSET (1) - MSB of mantissa is always 1 +/// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setNorm( H5T_norm_t norm ) const +void FloatType::setNorm(H5T_norm_t norm) const { - herr_t ret_value = H5Tset_norm( id, norm ); - if( ret_value < 0 ) - { - throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed"); - } + herr_t ret_value = H5Tset_norm(id, norm); + if (ret_value < 0) + { + throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType::getInpad -///\brief Retrieves the internal padding type for unused bits in -/// this floating-point datatypes. -///\return Internal padding type, which can be: -/// \li \c H5T_PAD_ZERO (0) - Set background to zeros -/// \li \c H5T_PAD_ONE (1) - Set background to ones -/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone -///\exception H5::DataTypeIException +// Function: FloatType::getInpad +///\brief Retrieves the internal padding type for unused bits in +/// this floating-point datatypes. +///\return Internal padding type, which can be: +/// \li \c H5T_PAD_ZERO (0) - Set background to zeros +/// \li \c H5T_PAD_ONE (1) - Set background to ones +/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone +///\exception H5::DataTypeIException ///\par Description -/// For your convenience, this function also provides the text -/// string of the returned internal padding type, via parameter -/// \a pad_string. -// Programmer Binh-Minh Ribler - 2000 +/// For your convenience, this function also provides the text +/// string of the returned internal padding type, via parameter +/// \a pad_string. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_pad_t FloatType::getInpad( H5std_string& pad_string ) const +H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const { - H5T_pad_t pad_type = H5Tget_inpad( id ); - // Returns a valid padding type if successful - if( pad_type == H5T_PAD_ERROR ) - { - throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR"); - } - if( pad_type == H5T_PAD_ZERO ) - pad_string = "H5T_PAD_ZERO (0)"; - else if( pad_type == H5T_PAD_ONE ) - pad_string = "H5T_PAD_ONE (1)"; - else if( pad_type == H5T_PAD_BACKGROUND ) - pad_string = "H5T_PAD_BACKGROUD (2)"; - return( pad_type ); + H5T_pad_t pad_type = H5Tget_inpad(id); + // Returns a valid padding type if successful + if (pad_type == H5T_PAD_ERROR) + { + throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR"); + } + if (pad_type == H5T_PAD_ZERO) + pad_string = "H5T_PAD_ZERO (0)"; + else if (pad_type == H5T_PAD_ONE) + pad_string = "H5T_PAD_ONE (1)"; + else if (pad_type == H5T_PAD_BACKGROUND) + pad_string = "H5T_PAD_BACKGROUD (2)"; + return(pad_type); } //-------------------------------------------------------------------------- -// Function: FloatType::setInpad -///\brief Fills unused internal floating point bits. -///\param inpad - IN: Internal padding type -///\exception H5::DataTypeIException +// Function: FloatType::setInpad +///\brief Fills unused internal floating point bits. +///\param inpad - IN: Internal padding type +///\exception H5::DataTypeIException ///\par Description -/// If any internal bits of a floating point type are unused -/// (that is, those significant bits which are not part of the -/// sign, exponent, or mantissa), then they will be filled -/// according to the padding value provided by \a inpad. +/// If any internal bits of a floating point type are unused +/// (that is, those significant bits which are not part of the +/// sign, exponent, or mantissa), then they will be filled +/// according to the padding value provided by \a inpad. ///\par -/// Valid values for normalization type include: -/// \li \c H5T_PAD_ZERO (0) - Set background to zeros -/// \li \c H5T_PAD_ONE (1) - Set background to ones -/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone -// Programmer Binh-Minh Ribler - 2000 +/// Valid values for normalization type include: +/// \li \c H5T_PAD_ZERO (0) - Set background to zeros +/// \li \c H5T_PAD_ONE (1) - Set background to ones +/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setInpad( H5T_pad_t inpad ) const +void FloatType::setInpad(H5T_pad_t inpad) const { - herr_t ret_value = H5Tset_inpad( id, inpad ); - if( ret_value < 0 ) - { - throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed"); - } + herr_t ret_value = H5Tset_inpad(id, inpad); + if (ret_value < 0) + { + throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed"); + } } //-------------------------------------------------------------------------- -// Function: FloatType destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: FloatType destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- FloatType::~FloatType() {} diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 1f4b227..2c925de 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -27,54 +27,54 @@ namespace H5 { */ class H5_DLLCPP FloatType : public AtomType { public: - // Creates a floating-point type using a predefined type. - FloatType( const PredType& pred_type ); + // Creates a floating-point type using a predefined type. + FloatType(const PredType& pred_type); - // Gets the floating-point datatype of the specified dataset. - FloatType( const DataSet& dataset ); + // Gets the floating-point datatype of the specified dataset. + FloatType(const DataSet& dataset); - // Constructors that open an HDF5 float datatype, given a location. - FloatType(const H5Location& loc, const char* name); - FloatType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 float datatype, given a location. + FloatType(const H5Location& loc, const char* name); + FloatType(const H5Location& loc, const H5std_string& name); - // Retrieves the exponent bias of a floating-point type. - size_t getEbias() const; + // Retrieves the exponent bias of a floating-point type. + size_t getEbias() const; - // Sets the exponent bias of a floating-point type. - void setEbias( size_t ebias ) const; + // Sets the exponent bias of a floating-point type. + void setEbias(size_t ebias) const; - // Retrieves floating point datatype bit field information. - void getFields( size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize ) const; + // Retrieves floating point datatype bit field information. + void getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const; - // Sets locations and sizes of floating point bit fields. - void setFields( size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize ) const; + // Sets locations and sizes of floating point bit fields. + void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; - // Retrieves the internal padding type for unused bits in floating-point datatypes. - H5T_pad_t getInpad( H5std_string& pad_string ) const; + // Retrieves the internal padding type for unused bits in floating-point datatypes. + H5T_pad_t getInpad(H5std_string& pad_string) const; - // Fills unused internal floating point bits. - void setInpad( H5T_pad_t inpad ) const; + // Fills unused internal floating point bits. + void setInpad(H5T_pad_t inpad) const; - // Retrieves mantissa normalization of a floating-point datatype. - H5T_norm_t getNorm( H5std_string& norm_string ) const; + // Retrieves mantissa normalization of a floating-point datatype. + H5T_norm_t getNorm(H5std_string& norm_string) const; - // Sets the mantissa normalization of a floating-point datatype. - void setNorm( H5T_norm_t norm ) const; + // Sets the mantissa normalization of a floating-point datatype. + void setNorm(H5T_norm_t norm) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FloatType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("FloatType"); } - // Default constructor - FloatType(); + // Default constructor + FloatType(); - // Creates a floating-point datatype using an existing id. - FloatType( const hid_t existing_id ); + // Creates a floating-point datatype using an existing id. + FloatType(const hid_t existing_id); - // Copy constructor: makes a copy of the original FloatType object. - FloatType( const FloatType& original ); + // Copy constructor: makes a copy of the original FloatType object. + FloatType(const FloatType& original); - // Noop destructor. - virtual ~FloatType(); + // Noop destructor. + virtual ~FloatType(); }; } #endif // __H5FloatType_H diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index c976b00..6b143b5 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -46,17 +46,17 @@ namespace H5 { using std::endl; //-------------------------------------------------------------------------- -// Function: Group default constructor -///\brief Default constructor: creates a stub Group. -// Programmer Binh-Minh Ribler - 2000 +// Function: Group default constructor +///\brief Default constructor: creates a stub Group. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- -// Function: Group copy constructor -///\brief Copy constructor: makes a copy of the original Group object. -///\param original - IN: Original group to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: Group copy constructor +///\brief Copy constructor: makes a copy of the original Group object. +///\param original - IN: Original group to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) { @@ -64,26 +64,26 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) } //-------------------------------------------------------------------------- -// Function: Group::getLocId +// Function: Group::getLocId // Purpose: Get the id of this group -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 // Description -// This function is a redefinition of CommonFG::getLocId. It -// is used by CommonFG member functions to get the file id. +// This function is a redefinition of CommonFG::getLocId. It +// is used by CommonFG member functions to get the file id. // Deprecated: // After HDFFV-9920, the Group's methods can use getId() and getLocId() // is kept for backward compatibility. Aug 18, 2016 -BMR //-------------------------------------------------------------------------- hid_t Group::getLocId() const { - return( getId() ); + return(getId()); } //-------------------------------------------------------------------------- -// Function: Group overloaded constructor -///\brief Creates a Group object using the id of an existing group. -///\param existing_id - IN: Id of an existing group -// Programmer Binh-Minh Ribler - 2000 +// Function: Group overloaded constructor +///\brief Creates a Group object using the id of an existing group. +///\param existing_id - IN: Id of an existing group +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id) { @@ -91,17 +91,17 @@ Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id) } //-------------------------------------------------------------------------- -// Function: Group overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 group, creates a Group object -///\param loc - IN: Specifying location referenced object is in -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException +// Function: Group overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 group, creates a Group object +///\param loc - IN: Specifying location referenced object is in +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException ///\par Description -/// \c obj can be DataSet, Group, or named DataType, that -/// is a datatype that has been named by DataType::commit. -// Programmer Binh-Minh Ribler - Oct, 2006 +/// \c obj can be DataSet, Group, or named DataType, that +/// is a datatype that has been named by DataType::commit. +// Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), CommonFG(), id(H5I_INVALID_HID) { @@ -109,14 +109,14 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const } //-------------------------------------------------------------------------- -// Function: Group overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 group, creates a Group object -///\param attr - IN: Specifying location where the referenced object is in -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type - default to H5R_OBJECT -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// Function: Group overload constructor - dereference +///\brief Given a reference, ref, to an hdf5 group, creates a Group object +///\param attr - IN: Specifying location where the referenced object is in +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type - default to H5R_OBJECT +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- /* Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { @@ -126,19 +126,19 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const //-------------------------------------------------------------------------- // Function: Group::getId -///\brief Get the id of this group -///\return Group identifier +///\brief Get the id of this group +///\return Group identifier // Modification: // May 2008 - BMR -// Class hierarchy is revised to address bugzilla 1068. Class -// AbstractDS and Attribute are moved out of H5Object. In -// addition, member IdComponent::id is moved into subclasses, and -// IdComponent::getId now becomes pure virtual function. +// Class hierarchy is revised to address bugzilla 1068. Class +// AbstractDS and Attribute are moved out of H5Object. In +// addition, member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- hid_t Group::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -147,11 +147,11 @@ hid_t Group::getId() const ///\brief Sets the identifier of this object to a new value. /// ///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails +/// object fails // Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Group::p_setId(const hid_t new_id) @@ -163,24 +163,24 @@ void Group::p_setId(const hid_t new_id) catch (Exception& close_error) { throwException("Group::p_setId", close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Group::close -///\brief Closes this group. +// Function: Group::close +///\brief Closes this group. /// -///\exception H5::GroupIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void Group::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Gclose( id ); - if( ret_value < 0 ) + herr_t ret_value = H5Gclose(id); + if (ret_value < 0) { throwException("Group::close", "H5Gclose failed"); } @@ -190,34 +190,34 @@ void Group::close() } //-------------------------------------------------------------------------- -// Function: Group::throwException -///\brief Throws H5::GroupIException. -///\param func_name - Name of the function where failure occurs -///\param msg - Message describing the failure -///\exception H5::GroupIException +// Function: Group::throwException +///\brief Throws H5::GroupIException. +///\param func_name - Name of the function where failure occurs +///\param msg - Message describing the failure +///\exception H5::GroupIException // Description -// This function is also used in H5Location's methods so that -// proper exception can be thrown for file or group. The -// "Group::" will be inserted to indicate the function called is -// an implementation of Group. -// Programmer Binh-Minh Ribler - 2000 +// This function is also used in H5Location's methods so that +// proper exception can be thrown for file or group. The +// "Group::" will be inserted to indicate the function called is +// an implementation of Group. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Group::throwException(const H5std_string& func_name, const H5std_string& msg) const { - H5std_string full_name = func_name; - full_name.insert(0, "Group::"); - throw GroupIException(full_name, msg); + H5std_string full_name = func_name; + full_name.insert(0, "Group::"); + throw GroupIException(full_name, msg); } //-------------------------------------------------------------------------- -// Function: Group destructor -///\brief Properly terminates access to this group. -// Programmer Binh-Minh Ribler - 2000 +// Function: Group destructor +///\brief Properly terminates access to this group. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Feb 20, 2005 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- Group::~Group() { diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 0a9e975..96dc5c1 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -30,53 +30,53 @@ class VarLenType; class H5_DLLCPP Group : public H5Object, public CommonFG { public: - // Group constructor to create a group or file (aka root group). - Group(const char* name, size_t size_hint = 0); - Group(const H5std_string& name, size_t size_hint = 0); + // Group constructor to create a group or file (aka root group). + Group(const char* name, size_t size_hint = 0); + Group(const H5std_string& name, size_t size_hint = 0); - // Group constructor to open a group or file (aka root group). - Group(const char* name); - Group(const H5std_string& name); + // Group constructor to open a group or file (aka root group). + Group(const char* name); + Group(const H5std_string& name); - // Close this group. - virtual void close(); + // Close this group. + virtual void close(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Group"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("Group"); } - // Throw group exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw group exception. + virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const; - // Creates a group by way of dereference. - Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a group by way of dereference. + Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // default constructor - Group(); + // default constructor + Group(); - // Copy constructor: makes a copy of the original object - Group(const Group& original); + // Copy constructor: makes a copy of the original object + Group(const Group& original); - // Gets the group id. - virtual hid_t getId() const; + // Gets the group id. + virtual hid_t getId() const; - // Destructor - virtual ~Group(); + // Destructor + virtual ~Group(); - // Creates a copy of an existing group using its id. - Group( const hid_t group_id ); + // Creates a copy of an existing group using its id. + Group(const hid_t group_id); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the group id. - virtual void p_setId(const hid_t new_id); + // Sets the group id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS private: - hid_t id; // HDF5 group id + hid_t id; // HDF5 group id }; } diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index ae60c5e..574b28a 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -15,7 +15,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5Library.h" @@ -34,21 +34,21 @@ bool IdComponent::H5cppinit = false; bool IdComponent::H5dontAtexit_called = false; //-------------------------------------------------------------------------- -// Function: IdComponent::incRefCount -///\brief Increment reference counter for a given id. -// Programmer Binh-Minh Ribler - May 2005 +// Function: IdComponent::incRefCount +///\brief Increment reference counter for a given id. +// Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- void IdComponent::incRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) - if (H5Iinc_ref(obj_id) < 0) - throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed"); + if (H5Iinc_ref(obj_id) < 0) + throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed"); } //-------------------------------------------------------------------------- -// Function: IdComponent::incRefCount -///\brief Increment reference counter for the id of this object. -// Programmer Binh-Minh Ribler - 2000 +// Function: IdComponent::incRefCount +///\brief Increment reference counter for the id of this object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void IdComponent::incRefCount() const { @@ -56,31 +56,31 @@ void IdComponent::incRefCount() const } //-------------------------------------------------------------------------- -// Function: IdComponent::decRefCount -///\brief Decrement reference counter for a given id. -// Programmer Binh-Minh Ribler - May 2005 +// Function: IdComponent::decRefCount +///\brief Decrement reference counter for a given id. +// Programmer Binh-Minh Ribler - May 2005 // Modification: -// Added the check for ref counter to give a little more info -// on why H5Idec_ref fails in some cases - BMR 5/19/2005 +// Added the check for ref counter to give a little more info +// on why H5Idec_ref fails in some cases - BMR 5/19/2005 //-------------------------------------------------------------------------- void IdComponent::decRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) - if (H5Idec_ref(obj_id) < 0) - { - if (H5Iget_ref(obj_id) <= 0) - throw IdComponentException(inMemFunc("decRefCount"), - "object ref count is 0 or negative"); - else - throw IdComponentException(inMemFunc("decRefCount"), - "decrementing object ref count failed"); - } + if (H5Idec_ref(obj_id) < 0) + { + if (H5Iget_ref(obj_id) <= 0) + throw IdComponentException(inMemFunc("decRefCount"), + "object ref count is 0 or negative"); + else + throw IdComponentException(inMemFunc("decRefCount"), + "decrementing object ref count failed"); + } } //-------------------------------------------------------------------------- -// Function: IdComponent::decRefCount -///\brief Decrement reference counter for the id of this object. -// Programmer Binh-Minh Ribler - 2000 +// Function: IdComponent::decRefCount +///\brief Decrement reference counter for the id of this object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void IdComponent::decRefCount() const { @@ -88,28 +88,28 @@ void IdComponent::decRefCount() const } //-------------------------------------------------------------------------- -// Function: IdComponent::getCounter -///\brief Returns the reference counter for a given id. -///\return Reference count -// Programmer Binh-Minh Ribler - May 2005 +// Function: IdComponent::getCounter +///\brief Returns the reference counter for a given id. +///\return Reference count +// Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- int IdComponent::getCounter(const hid_t obj_id) const { int counter = 0; if (p_valid_id(obj_id)) { - counter = H5Iget_ref(obj_id); - if (counter < 0) - throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative"); + counter = H5Iget_ref(obj_id); + if (counter < 0) + throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative"); } return (counter); } //-------------------------------------------------------------------------- -// Function: IdComponent::getCounter -///\brief Returns the reference counter for the id of this object. -///\return Reference count -// Programmer Binh-Minh Ribler - 2000 +// Function: IdComponent::getCounter +///\brief Returns the reference counter for the id of this object. +///\return Reference count +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int IdComponent::getCounter() const { @@ -117,43 +117,43 @@ int IdComponent::getCounter() const } //-------------------------------------------------------------------------- -// Function: getHDFObjType (static) -///\brief Given an id, returns the type of the object. -///\return a valid HDF object type, which may be one of the following: -/// \li \c H5I_FILE -/// \li \c H5I_GROUP -/// \li \c H5I_DATATYPE -/// \li \c H5I_DATASPACE -/// \li \c H5I_DATASET -/// \li \c H5I_ATTR -/// \li or \c H5I_BADID, if no valid type can be determined or the -/// input object id is invalid. +// Function: getHDFObjType (static) +///\brief Given an id, returns the type of the object. +///\return a valid HDF object type, which may be one of the following: +/// \li \c H5I_FILE +/// \li \c H5I_GROUP +/// \li \c H5I_DATATYPE +/// \li \c H5I_DATASPACE +/// \li \c H5I_DATASET +/// \li \c H5I_ATTR +/// \li or \c H5I_BADID, if no valid type can be determined or the +/// input object id is invalid. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) { if (obj_id <= 0) - return H5I_BADID; // invalid + return H5I_BADID; // invalid H5I_type_t id_type = H5Iget_type(obj_id); if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) - return H5I_BADID; // invalid + return H5I_BADID; // invalid else - return id_type; // valid type + return id_type; // valid type } //-------------------------------------------------------------------------- -// Function: getHDFObjType -///\brief Returns the type of the object. It is an overloaded function -/// of the above function. -///\return a valid HDF object type, which may be one of the following: -/// \li \c H5I_FILE -/// \li \c H5I_GROUP -/// \li \c H5I_DATATYPE -/// \li \c H5I_DATASPACE -/// \li \c H5I_DATASET -/// \li \c H5I_ATTR -/// \li or \c H5I_BADID, if no valid type can be determined or the -/// input object id is invalid. +// Function: getHDFObjType +///\brief Returns the type of the object. It is an overloaded function +/// of the above function. +///\return a valid HDF object type, which may be one of the following: +/// \li \c H5I_FILE +/// \li \c H5I_GROUP +/// \li \c H5I_DATATYPE +/// \li \c H5I_DATASPACE +/// \li \c H5I_DATASET +/// \li \c H5I_ATTR +/// \li or \c H5I_BADID, if no valid type can be determined or the +/// input object id is invalid. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- H5I_type_t IdComponent::getHDFObjType() const @@ -162,25 +162,25 @@ H5I_type_t IdComponent::getHDFObjType() const } //-------------------------------------------------------------------------- -// Function: getNumMembers (static) -///\brief Returns the number of members of the given type. -///\return Number of members +// Function: getNumMembers (static) +///\brief Returns the number of members of the given type. +///\return Number of members ///\Description -/// If there is no member of the given type, getNumMembers will -/// return 0. Valid types are: -/// \li \c H5I_FILE (= 1) -/// \li \c H5I_GROUP -/// \li \c H5I_DATATYPE -/// \li \c H5I_DATASPACE -/// \li \c H5I_DATASET -/// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE -/// \li \c H5I_VFL -/// \li \c H5I_GENPROP_CLS -/// \li \c H5I_GENPROP_LST -/// \li \c H5I_ERROR_CLASS -/// \li \c H5I_ERROR_MSG -/// \li \c H5I_ERROR_STACK +/// If there is no member of the given type, getNumMembers will +/// return 0. Valid types are: +/// \li \c H5I_FILE (= 1) +/// \li \c H5I_GROUP +/// \li \c H5I_DATATYPE +/// \li \c H5I_DATASPACE +/// \li \c H5I_DATASET +/// \li \c H5I_ATTR +/// \li \c H5I_REFERENCE +/// \li \c H5I_VFL +/// \li \c H5I_GENPROP_CLS +/// \li \c H5I_GENPROP_LST +/// \li \c H5I_ERROR_CLASS +/// \li \c H5I_ERROR_MSG +/// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- hsize_t IdComponent::getNumMembers(H5I_type_t type) @@ -188,31 +188,31 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type) hsize_t nmembers = 0; herr_t ret_value = H5Inmembers(type, &nmembers); if (ret_value < 0) - throw IdComponentException("getNumMembers", "H5Inmembers failed"); + throw IdComponentException("getNumMembers", "H5Inmembers failed"); else - return(nmembers); + return(nmembers); } //-------------------------------------------------------------------------- -// Function: typeExists (static) -///\brief Queries if a given type is currently registered with the -/// library. -///\return true if the given type exists, and false, otherwise. +// Function: typeExists (static) +///\brief Queries if a given type is currently registered with the +/// library. +///\return true if the given type exists, and false, otherwise. ///\Description -/// Valid types are: -/// \li \c H5I_FILE (= 1) -/// \li \c H5I_GROUP -/// \li \c H5I_DATATYPE -/// \li \c H5I_DATASPACE -/// \li \c H5I_DATASET -/// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE -/// \li \c H5I_VFL -/// \li \c H5I_GENPROP_CLS -/// \li \c H5I_GENPROP_LST -/// \li \c H5I_ERROR_CLASS -/// \li \c H5I_ERROR_MSG -/// \li \c H5I_ERROR_STACK +/// Valid types are: +/// \li \c H5I_FILE (= 1) +/// \li \c H5I_GROUP +/// \li \c H5I_DATATYPE +/// \li \c H5I_DATASPACE +/// \li \c H5I_DATASET +/// \li \c H5I_ATTR +/// \li \c H5I_REFERENCE +/// \li \c H5I_VFL +/// \li \c H5I_GENPROP_CLS +/// \li \c H5I_GENPROP_LST +/// \li \c H5I_ERROR_CLASS +/// \li \c H5I_ERROR_MSG +/// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- bool IdComponent::typeExists(H5I_type_t type) @@ -220,82 +220,82 @@ bool IdComponent::typeExists(H5I_type_t type) // Call C function htri_t ret_value = H5Itype_exists(type); if (ret_value > 0) - return true; + return true; else if (ret_value == 0) - return false; + return false; else // Raise exception when H5Itype_exists returns a negative value - throw IdComponentException("typeExists", "H5Itype_exists failed"); + throw IdComponentException("typeExists", "H5Itype_exists failed"); } //-------------------------------------------------------------------------- -// Function: IdComponent::operator= -///\brief Assignment operator. -///\param rhs - IN: Reference to the existing object -///\return Reference to IdComponent instance -///\exception H5::IdComponentException when attempt to close the HDF5 -/// object fails +// Function: IdComponent::operator= +///\brief Assignment operator. +///\param rhs - IN: Reference to the existing object +///\return Reference to IdComponent instance +///\exception H5::IdComponentException when attempt to close the HDF5 +/// object fails // Description -// First, close the current valid id of this object. Then -// copy the id from rhs to this object, and increment the -// reference counter of the id to indicate that another object -// is referencing that id. +// First, close the current valid id of this object. Then +// copy the id from rhs to this object, and increment the +// reference counter of the id to indicate that another object +// is referencing that id. // Modification -// 2010/5/9 - BMR -// Removed close() and incRefCount() because setId/p_setId takes -// care of close() and setId takes care incRefCount(). -// Programmer Binh-Minh Ribler - 2000 +// 2010/5/9 - BMR +// Removed close() and incRefCount() because setId/p_setId takes +// care of close() and setId takes care incRefCount(). +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent& IdComponent::operator=( const IdComponent& rhs ) +IdComponent& IdComponent::operator=(const IdComponent& rhs) { if (this != &rhs) { - // handling references to this id - try { - setId(rhs.getId()); - // Note: a = b, so there are two objects with the same hdf5 id - // that's why incRefCount is needed, and it is called by setId - } - catch (Exception& close_error) { - throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); - } + // handling references to this id + try { + setId(rhs.getId()); + // Note: a = b, so there are two objects with the same hdf5 id + // that's why incRefCount is needed, and it is called by setId + } + catch (Exception& close_error) { + throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); + } } return *this; } //-------------------------------------------------------------------------- -// Function: IdComponent::setId -///\brief Sets the identifier of this object to a new value. -///\param new_id - IN: New identifier to be set to -///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails +// Function: IdComponent::setId +///\brief Sets the identifier of this object to a new value. +///\param new_id - IN: New identifier to be set to +///\exception H5::IdComponentException when the attempt to close the HDF5 +/// object fails // Description: -// p_setId ensures that the current valid id of this object is -// properly closed before resetting the object's id to the new id. -// Programmer Binh-Minh Ribler - 2000 +// p_setId ensures that the current valid id of this object is +// properly closed before resetting the object's id to the new id. +// Programmer Binh-Minh Ribler - 2000 // Modification -// 2008/7/23 - BMR -// Changed all subclasses' setId to p_setId and put back setId -// here. p_setId is used in the library where the id provided -// by a C API passed on to user's application in the form of a -// C++ API object, which will be destroyed properly, and so -// p_setId does not call incRefCount. On the other hand, the -// public version setId is used by other applications, in which -// the id passed to setId is that of another C++ API object, so -// setId must call incRefCount. +// 2008/7/23 - BMR +// Changed all subclasses' setId to p_setId and put back setId +// here. p_setId is used in the library where the id provided +// by a C API passed on to user's application in the form of a +// C++ API object, which will be destroyed properly, and so +// p_setId does not call incRefCount. On the other hand, the +// public version setId is used by other applications, in which +// the id passed to setId is that of another C++ API object, so +// setId must call incRefCount. //-------------------------------------------------------------------------- void IdComponent::setId(const hid_t new_id) { - // set to new_id - p_setId(new_id); + // set to new_id + p_setId(new_id); - // increment the reference counter of the new id - incRefCount(); + // increment the reference counter of the new id + incRefCount(); } //-------------------------------------------------------------------------- -// Function: IdComponent destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: IdComponent destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- IdComponent::~IdComponent() {} @@ -306,29 +306,29 @@ IdComponent::~IdComponent() {} #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: IdComponent::inMemFunc -///\brief Makes and returns string "::" -///\param func_name - Name of the function where failure occurs +// Function: IdComponent::inMemFunc +///\brief Makes and returns string "::" +///\param func_name - Name of the function where failure occurs // Description -/// Concatenates the class name of this object with the -/// passed-in function name to create a string that indicates -/// where the failure occurs. The class-name is provided by -/// fromClass(). This string will be used by a base class when -/// an exception is thrown. -// Programmer Binh-Minh Ribler - Aug 6, 2005 +/// Concatenates the class name of this object with the +/// passed-in function name to create a string that indicates +/// where the failure occurs. The class-name is provided by +/// fromClass(). This string will be used by a base class when +/// an exception is thrown. +// Programmer Binh-Minh Ribler - Aug 6, 2005 //-------------------------------------------------------------------------- H5std_string IdComponent::inMemFunc(const char* func_name) const { - H5std_string full_name = func_name; - full_name.insert(0, "::"); - full_name.insert(0, fromClass()); - return (full_name); + H5std_string full_name = func_name; + full_name.insert(0, "::"); + full_name.insert(0, fromClass()); + return (full_name); } //-------------------------------------------------------------------------- -// Function: IdComponent default constructor - private -///\brief Default constructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: IdComponent default constructor - private +///\brief Default constructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- IdComponent::IdComponent() { @@ -342,45 +342,45 @@ IdComponent::IdComponent() } //-------------------------------------------------------------------------- -// Function: IdComponent::p_get_file_name (protected) -// Purpose: Gets the name of the file, in which this object belongs. -// Exception: H5::IdComponentException +// Function: IdComponent::p_get_file_name (protected) +// Purpose Gets the name of the file, in which this object belongs. +// Exception: H5::IdComponentException // Description: -// This function is protected so that the user applications can -// only have access to its code via allowable classes, namely, -// Attribute and H5Location subclasses. -// Programmer Binh-Minh Ribler - Jul, 2004 +// This function is protected so that the user applications can +// only have access to its code via allowable classes, namely, +// Attribute and H5Location subclasses. +// Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- H5std_string IdComponent::p_get_file_name() const { - hid_t temp_id = getId(); + hid_t temp_id = getId(); - // Preliminary call to H5Fget_name to get the length of the file name - ssize_t name_size = H5Fget_name(temp_id, NULL, 0); + // Preliminary call to H5Fget_name to get the length of the file name + ssize_t name_size = H5Fget_name(temp_id, NULL, 0); - // If H5Aget_name returns a negative value, raise an exception, - if( name_size < 0 ) - { - throw IdComponentException("", "H5Fget_name failed"); - } + // If H5Aget_name returns a negative value, raise an exception, + if (name_size < 0) + { + throw IdComponentException("", "H5Fget_name failed"); + } - // Call H5Fget_name again to get the actual file name - char* name_C = new char[name_size+1]; // temporary C-string for C API - HDmemset(name_C, 0, name_size+1); // clear buffer + // Call H5Fget_name again to get the actual file name + char* name_C = new char[name_size+1]; // temporary C-string for C API + HDmemset(name_C, 0, name_size+1); // clear buffer - name_size = H5Fget_name(temp_id, name_C, name_size+1); + name_size = H5Fget_name(temp_id, name_C, name_size+1); - // Check for failure again - if( name_size < 0 ) - { + // Check for failure again + if (name_size < 0) + { delete []name_C; - throw IdComponentException("", "H5Fget_name failed"); - } + throw IdComponentException("", "H5Fget_name failed"); + } - // Convert the C file name and return - H5std_string file_name(name_C); - delete []name_C; - return(file_name); + // Convert the C file name and return + H5std_string file_name(name_C); + delete []name_C; + return(file_name); } // @@ -388,22 +388,22 @@ H5std_string IdComponent::p_get_file_name() const // //-------------------------------------------------------------------------- -// Function: p_valid_id -// Purpose: Verifies that the given id is a valid id so it can be passed -// into an H5I C function. -// Return true if id is valid, false, otherwise -// Programmer Binh-Minh Ribler - May, 2005 +// Function: p_valid_id +// Purpose Verifies that the given id is a valid id so it can be passed +// into an H5I C function. +// Return true if id is valid, false, otherwise +// Programmer Binh-Minh Ribler - May, 2005 //-------------------------------------------------------------------------- bool IdComponent::p_valid_id(const hid_t obj_id) { if (obj_id <= 0) - return false; + return false; H5I_type_t id_type = H5Iget_type(obj_id); if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) - return false; + return false; else - return true; + return true; } // Notes about IdComponent::id diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 70522dc..6f57364 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -30,92 +30,92 @@ class DataSpace; class H5_DLLCPP IdComponent { public: - // Increment reference counter. - void incRefCount(const hid_t obj_id) const; - void incRefCount() const; + // Increment reference counter. + void incRefCount(const hid_t obj_id) const; + void incRefCount() const; - // Decrement reference counter. - void decRefCount(const hid_t obj_id) const; - void decRefCount() const; + // Decrement reference counter. + void decRefCount(const hid_t obj_id) const; + void decRefCount() const; - // Get the reference counter to this identifier. - int getCounter(const hid_t obj_id) const; - int getCounter() const; + // Get the reference counter to this identifier. + int getCounter(const hid_t obj_id) const; + int getCounter() const; - // Returns an HDF5 object type, given the object id. - static H5I_type_t getHDFObjType(const hid_t obj_id); + // Returns an HDF5 object type, given the object id. + static H5I_type_t getHDFObjType(const hid_t obj_id); - // Returns an HDF5 object type of this object. - H5I_type_t getHDFObjType() const; + // Returns an HDF5 object type of this object. + H5I_type_t getHDFObjType() const; - // Returns the number of members in a type. - static hsize_t getNumMembers(H5I_type_t type); + // Returns the number of members in a type. + static hsize_t getNumMembers(H5I_type_t type); - // Determines if an type exists. - static bool typeExists(H5I_type_t type); + // Determines if an type exists. + static bool typeExists(H5I_type_t type); - // Assignment operator. - IdComponent& operator=( const IdComponent& rhs ); + // Assignment operator. + IdComponent& operator=(const IdComponent& rhs); - // Sets the identifier of this object to a new value. - void setId(const hid_t new_id); + // Sets the identifier of this object to a new value. + void setId(const hid_t new_id); - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates an object to hold an HDF5 identifier. - IdComponent( const hid_t h5_id ); + // Creates an object to hold an HDF5 identifier. + // IdComponent(const hid_t h5_id); - removed from 1.10.1 #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Copy constructor: makes copy of the original IdComponent object. - // IdComponent( const IdComponent& original ); - removed from 1.8.15 + // Copy constructor: makes copy of the original IdComponent object. + // IdComponent(const IdComponent& original); - removed from 1.8.15 - // Gets the identifier of this object. - virtual hid_t getId () const = 0; + // Gets the identifier of this object. + virtual hid_t getId () const = 0; - // Pure virtual function for there are various H5*close for the - // subclasses. - virtual void close() = 0; + // Pure virtual function for there are various H5*close for the + // subclasses. + virtual void close() = 0; - // Makes and returns the string "::"; - // is returned by fromClass(). - H5std_string inMemFunc(const char* func_name) const; + // Makes and returns the string "::"; + // is returned by fromClass(). + H5std_string inMemFunc(const char* func_name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("IdComponent");} + ///\brief Returns this class name. + virtual H5std_string fromClass() const { return("IdComponent");} #endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor - virtual ~IdComponent(); + // Destructor + virtual ~IdComponent(); #ifndef DOXYGEN_SHOULD_SKIP_THIS protected: - // Default constructor. - IdComponent(); + // Default constructor. + IdComponent(); - // Gets the name of the file, in which an HDF5 object belongs. - H5std_string p_get_file_name() const; + // Gets the name of the file, in which an HDF5 object belongs. + H5std_string p_get_file_name() const; - // Verifies that the given id is valid. - static bool p_valid_id(const hid_t obj_id); + // Verifies that the given id is valid. + static bool p_valid_id(const hid_t obj_id); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // This flag is used to decide whether H5dont_atexit should be called - static bool H5dontAtexit_called; + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; private: - // This flag indicates whether H5Library::initH5cpp has been called - // to register various terminating functions with atexit() + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index 1e0e952..ba82d78 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -33,10 +33,10 @@ const bool true = 1; // so re-define them here for now. /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 +#define H5O_VERSION_2 2 diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 38e2a7d..c64dae9 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -36,72 +36,72 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: IntType default constructor -///\brief Default constructor: Creates a stub integer datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType default constructor +///\brief Default constructor: Creates a stub integer datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- IntType::IntType() {} //-------------------------------------------------------------------------- -// Function: IntType copy constructor -///\brief Copy constructor: makes a copy of the original IntType object. -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType copy constructor +///\brief Copy constructor: makes a copy of the original IntType object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType( const IntType& original ) : AtomType( original ) {} +IntType::IntType(const IntType& original) : AtomType( original ) {} //-------------------------------------------------------------------------- -// Function: IntType overloaded constructor -///\brief Creates a integer type using a predefined type -///\param pred_type - IN: Predefined datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType overloaded constructor +///\brief Creates a integer type using a predefined type +///\param pred_type - IN: Predefined datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType( const PredType& pred_type ) : AtomType() +IntType::IntType(const PredType& pred_type) : AtomType() { - // use DataType::copy to make a copy of this predefined type - copy( pred_type ); + // use DataType::copy to make a copy of this predefined type + copy(pred_type); } //-------------------------------------------------------------------------- -// Function: IntType overloaded constructor -///\brief Creates an integer datatype using the id of an existing -/// datatype. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType overloaded constructor +///\brief Creates an integer datatype using the id of an existing +/// datatype. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType( const hid_t existing_id ) : AtomType( existing_id ) {} +IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} //-------------------------------------------------------------------------- -// Function: IntType overloaded constructor -///\brief Gets the integer datatype of the specified dataset. -///\param dataset - IN: Dataset that this integer datatype associates with -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType overloaded constructor +///\brief Gets the integer datatype of the specified dataset. +///\param dataset - IN: Dataset that this integer datatype associates with +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType( const DataSet& dataset ) : AtomType() +IntType::IntType(const DataSet& dataset) : AtomType() { - // Calls C function H5Dget_type to get the id of the datatype - id = H5Dget_type( dataset.getId() ); - - if( id < 0 ) - { - throw DataSetIException("IntType constructor", "H5Dget_type failed"); - } + // Calls C function H5Dget_type to get the id of the datatype + id = H5Dget_type(dataset.getId()); + + if (id < 0) + { + throw DataSetIException("IntType constructor", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: IntType overloaded constructor -///\brief Creates a IntType instance by opening an HDF5 integer datatype -/// given its name as a char*. -///\param dtype_name - IN: Integer type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: IntType overloaded constructor +///\brief Creates a IntType instance by opening an HDF5 integer datatype +/// given its name as a char*. +///\param dtype_name - IN: Integer type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openIntType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openIntType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() { @@ -109,17 +109,17 @@ IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() } //-------------------------------------------------------------------------- -// Function: IntType overloaded constructor -///\brief Creates a IntType instance by opening an HDF5 integer datatype -/// given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Integer type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: IntType overloaded constructor +///\brief Creates a IntType instance by opening an HDF5 integer datatype +/// given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Integer type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openArrayType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openArrayType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() { @@ -127,46 +127,46 @@ IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy } //-------------------------------------------------------------------------- -// Function: IntType::getSign -///\brief Retrieves the sign type for an integer type. -///\return Valid sign type -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType::getSign +///\brief Retrieves the sign type for an integer type. +///\return Valid sign type +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5T_sign_t IntType::getSign() const { - H5T_sign_t type_sign = H5Tget_sign( id ); // C routine - - // Returns a valid sign type if no errors - if( type_sign == H5T_SGN_ERROR ) - { - throw DataTypeIException("IntType::getSign", - "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); - } - return( type_sign ); + H5T_sign_t type_sign = H5Tget_sign(id); // C routine + + // Returns a valid sign type if no errors + if (type_sign == H5T_SGN_ERROR) + { + throw DataTypeIException("IntType::getSign", + "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); + } + return(type_sign); } //-------------------------------------------------------------------------- -// Function: IntType::getSign -///\brief Sets the sign property for an integer type. -///\param sign - IN: Sign type -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType::getSign +///\brief Sets the sign property for an integer type. +///\param sign - IN: Sign type +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IntType::setSign( H5T_sign_t sign ) const +void IntType::setSign(H5T_sign_t sign) const { - // Call C routine to set the sign property - herr_t ret_value = H5Tset_sign( id, sign ); - if( ret_value < 0 ) - { - throw DataTypeIException("IntType::setSign", "H5Tset_sign failed"); - } + // Call C routine to set the sign property + herr_t ret_value = H5Tset_sign(id, sign); + if (ret_value < 0) + { + throw DataTypeIException("IntType::setSign", "H5Tset_sign failed"); + } } //-------------------------------------------------------------------------- -// Function: IntType destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: IntType destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- IntType::~IntType() {} diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 74786b9..ae4b3df 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -27,36 +27,36 @@ namespace H5 { */ class H5_DLLCPP IntType : public AtomType { public: - // Creates an integer type using a predefined type - IntType(const PredType& pred_type); + // Creates an integer type using a predefined type + IntType(const PredType& pred_type); - // Gets the integer datatype of the specified dataset - IntType(const DataSet& dataset); + // Gets the integer datatype of the specified dataset + IntType(const DataSet& dataset); - // Constructors that open an HDF5 integer datatype, given a location. - IntType(const H5Location& loc, const char* name); - IntType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 integer datatype, given a location. + IntType(const H5Location& loc, const char* name); + IntType(const H5Location& loc, const H5std_string& name); - // Retrieves the sign type for an integer type - H5T_sign_t getSign() const; + // Retrieves the sign type for an integer type + H5T_sign_t getSign() const; - // Sets the sign proprety for an integer type. - void setSign( H5T_sign_t sign ) const; + // Sets the sign proprety for an integer type. + void setSign(H5T_sign_t sign) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("IntType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("IntType"); } - // Default constructor - IntType(); + // Default constructor + IntType(); - // Creates a integer datatype using an existing id - IntType(const hid_t existing_id); + // Creates a integer datatype using an existing id + IntType(const hid_t existing_id); - // Copy constructor: makes copy of IntType object - IntType(const IntType& original); + // Copy constructor: makes copy of IntType object + IntType(const IntType& original); - // Noop destructor. - virtual ~IntType(); + // Noop destructor. + virtual ~IntType(); }; } #endif // __H5IntType_H diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index e225b36..e9adb12 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -47,7 +47,7 @@ LinkAccPropList* LinkAccPropList::getConstant() // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() if (!IdComponent::H5dontAtexit_called) - { + { (void) H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -75,39 +75,39 @@ void LinkAccPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose: Constant for default property +// Purpose: Constant for default property //-------------------------------------------------------------------------- const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Default Constructor -///\brief Creates a file access property list -// Programmer: Binh-Minh Ribler - 2000 +// Function: Default Constructor +///\brief Creates a file access property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList() : PropList( H5P_LINK_ACCESS ) {} +LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} //-------------------------------------------------------------------------- -// Function: LinkAccPropList copy constructor -///\brief Copy Constructor: makes a copy of the original -///\param original - IN: LinkAccPropList instance to copy -// Programmer: Binh-Minh Ribler - 2000 +// Function: LinkAccPropList copy constructor +///\brief Copy Constructor: makes a copy of the original +///\param original - IN: LinkAccPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {} //-------------------------------------------------------------------------- -// Function: LinkAccPropList overloaded constructor -///\brief Creates a file access property list using the id of an -/// existing one. -// Programmer: Binh-Minh Ribler - 2000 +// Function: LinkAccPropList overloaded constructor +///\brief Creates a file access property list using the id of an +/// existing one. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} //-------------------------------------------------------------------------- -// Function: LinkAccPropList destructor -///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Function: LinkAccPropList destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- LinkAccPropList::~LinkAccPropList() {} diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index 2a84ffb..8bcdd64 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -30,24 +30,24 @@ namespace H5 { */ class H5_DLLCPP LinkAccPropList : public PropList { public: - ///\brief Default file access property list. - static const LinkAccPropList& DEFAULT; + ///\brief Default file access property list. + static const LinkAccPropList& DEFAULT; - // Creates a file access property list. - LinkAccPropList(); + // Creates a file access property list. + LinkAccPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("LinkAccPropList"); } - // Copy constructor: creates a copy of a LinkAccPropList object. - LinkAccPropList( const LinkAccPropList& original ); + // Copy constructor: creates a copy of a LinkAccPropList object. + LinkAccPropList(const LinkAccPropList& original); - // Creates a copy of an existing file access property list - // using the property list id. - LinkAccPropList (const hid_t plist_id); + // Creates a copy of an existing file access property list + // using the property list id. + LinkAccPropList (const hid_t plist_id); - // Noop destructor - virtual ~LinkAccPropList(); + // Noop destructor + virtual ~LinkAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index 0ee6b4d..dc453b7 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -38,46 +38,46 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: H5Library::open (static) -///\brief Initializes the HDF5 library. +// Function: H5Library::open (static) +///\brief Initializes the HDF5 library. /// -///\exception H5::LibraryIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::LibraryIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5Library::open() { - herr_t ret_value = H5open(); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::open", "H5open failed"); - } + herr_t ret_value = H5open(); + if (ret_value < 0) + { + throw LibraryIException("H5Library::open", "H5open failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Library::close (static) -///\brief Flushes all data to disk, closes files, and cleans up memory. +// Function: H5Library::close (static) +///\brief Flushes all data to disk, closes files, and cleans up memory. /// -///\exception H5::LibraryIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::LibraryIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5Library::close() { - herr_t ret_value = H5close(); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::close", "H5close failed"); - } + herr_t ret_value = H5close(); + if (ret_value < 0) + { + throw LibraryIException("H5Library::close", "H5close failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Library::dontAtExit (static) -///\brief Instructs library not to install the C \c atexit cleanup routine +// Function: H5Library::dontAtExit (static) +///\brief Instructs library not to install the C \c atexit cleanup routine /// -///\exception H5::LibraryIException -// Programmer Binh-Minh Ribler - 2000 +///\exception H5::LibraryIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Removed the check for failure returned from H5dont_atexit. -// will be fixed to not fail (HDFFV-9540) +// Removed the check for failure returned from H5dont_atexit. +// will be fixed to not fail (HDFFV-9540) //-------------------------------------------------------------------------- void H5Library::dontAtExit() { @@ -85,80 +85,80 @@ void H5Library::dontAtExit() } //-------------------------------------------------------------------------- -// Function: H5Library::getLibVersion (static) -///\brief Returns the HDF library release number. -///\param majnum - OUT: Major version of the library -///\param minnum - OUT: Minor version of the library -///\param relnum - OUT: Release number of the library -///\exception H5::LibraryIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Library::getLibVersion (static) +///\brief Returns the HDF library release number. +///\param majnum - OUT: Major version of the library +///\param minnum - OUT: Minor version of the library +///\param relnum - OUT: Release number of the library +///\exception H5::LibraryIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& relnum ) +void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum) { - herr_t ret_value = H5get_libversion( &majnum, &minnum, &relnum ); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed"); - } + herr_t ret_value = H5get_libversion(&majnum, &minnum, &relnum); + if (ret_value < 0) + { + throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Library::checkVersion (static) -///\brief Verifies that the arguments match the version numbers -/// compiled into the library -///\param majnum - IN: Major version of the library -///\param minnum - IN: Minor version of the library -///\param relnum - IN: Release number of the library -///\exception H5::LibraryIException +// Function: H5Library::checkVersion (static) +///\brief Verifies that the arguments match the version numbers +/// compiled into the library +///\param majnum - IN: Major version of the library +///\param minnum - IN: Minor version of the library +///\param relnum - IN: Release number of the library +///\exception H5::LibraryIException ///\par Description -/// For information about library version, please refer to -/// the C layer Reference Manual at: +/// For information about library version, please refer to +/// the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5.html#Library-VersCheck -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) { - herr_t ret_value = H5check_version(majnum, minnum, relnum); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::checkVersion", "H5check_version failed"); - } + herr_t ret_value = H5check_version(majnum, minnum, relnum); + if (ret_value < 0) + { + throw LibraryIException("H5Library::checkVersion", "H5check_version failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Library::garbageCollect (static) -///\brief Walks through all the garbage collection routines for the -/// library, which are supposed to free any unused memory they -/// have allocated. +// Function: H5Library::garbageCollect (static) +///\brief Walks through all the garbage collection routines for the +/// library, which are supposed to free any unused memory they +/// have allocated. /// -///\exception H5::LibraryIException +///\exception H5::LibraryIException ///\par Description -/// It is not required that H5Library::garbageCollect be called -/// at any particular time; it is only necessary in certain -/// situations, such as when the application has performed actions -/// that cause the library to allocate many objects. The -/// application should call H5Library::garbageCollect if it -/// eventually releases those objects and wants to reduce the -/// memory used by the library from the peak usage required. +/// It is not required that H5Library::garbageCollect be called +/// at any particular time; it is only necessary in certain +/// situations, such as when the application has performed actions +/// that cause the library to allocate many objects. The +/// application should call H5Library::garbageCollect if it +/// eventually releases those objects and wants to reduce the +/// memory used by the library from the peak usage required. ///\par -/// The library automatically garbage collects all the free -/// lists when the application ends. -// Programmer Binh-Minh Ribler - May, 2004 +/// The library automatically garbage collects all the free +/// lists when the application ends. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Library::garbageCollect() { - herr_t ret_value = H5garbage_collect(); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::garbageCollect", "H5garbage_collect failed"); - } + herr_t ret_value = H5garbage_collect(); + if (ret_value < 0) + { + throw LibraryIException("H5Library::garbageCollect", "H5garbage_collect failed"); + } } //-------------------------------------------------------------------------- // Function: H5Library::initH5cpp (static) ///\brief Initializes C++ library and registers terminating functions at -/// exit. Only for the library functions, not for user-defined -/// functions. +/// exit. Only for the library functions, not for user-defined +/// functions. // Description // initH5cpp registers the following functions with std::atexit(): // termH5cpp() - calls H5close() after all cleanup in @@ -231,45 +231,45 @@ void H5Library::termH5cpp() } //-------------------------------------------------------------------------- -// Function: H5Library::setFreeListLimits (static) -///\brief Sets limits on the different kinds of free lists. -///\param reg_global_lim - IN: Limit on all "regular" free list memory used -///\param reg_list_lim - IN: Limit on memory used in each "regular" free list -///\param arr_global_lim - IN: Limit on all "array" free list memory used -///\param arr_list_lim - IN: Limit on memory used in each "array" free list -///\param blk_global_lim - IN: Limit on all "block" free list memory used -///\param blk_list_lim - IN: Limit on memory used in each "block" free list -///\exception H5::LibraryIException +// Function: H5Library::setFreeListLimits (static) +///\brief Sets limits on the different kinds of free lists. +///\param reg_global_lim - IN: Limit on all "regular" free list memory used +///\param reg_list_lim - IN: Limit on memory used in each "regular" free list +///\param arr_global_lim - IN: Limit on all "array" free list memory used +///\param arr_list_lim - IN: Limit on memory used in each "array" free list +///\param blk_global_lim - IN: Limit on all "block" free list memory used +///\param blk_list_lim - IN: Limit on memory used in each "block" free list +///\exception H5::LibraryIException ///\par Description -/// Setting a value of -1 for a limit means no limit of that type. -/// For more information on free list limits, please refer to C -/// layer Reference Manual at: +/// Setting a value of -1 for a limit means no limit of that type. +/// For more information on free list limits, please refer to C +/// layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5.html#Library-SetFreeListLimits -// Programmer Binh-Minh Ribler - May, 2004 +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim) + int arr_global_lim, int arr_list_lim, int blk_global_lim, + int blk_list_lim) { - herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); - if( ret_value < 0 ) - { - throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed"); - } + herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); + if (ret_value < 0) + { + throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed"); + } } #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Library default constructor - private -///\brief Default constructor: Creates a stub H5Library object -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Library default constructor - private +///\brief Default constructor: Creates a stub H5Library object +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Library::H5Library(){} //-------------------------------------------------------------------------- -// Function: H5Library destructor -///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Library destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Library::~H5Library(){} #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 694b052..018ba38 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -27,32 +27,32 @@ namespace H5 { */ class H5_DLLCPP H5Library { public: - // Initializes the HDF5 library. - static void open(); + // Initializes the HDF5 library. + static void open(); - // Flushes all data to disk, closes files, and cleans up memory. - static void close(); + // Flushes all data to disk, closes files, and cleans up memory. + static void close(); - // Instructs library not to install atexit cleanup routine - static void dontAtExit(); + // Instructs library not to install atexit cleanup routine + static void dontAtExit(); - // Returns the HDF library release number. - static void getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& relnum ); + // Returns the HDF library release number. + static void getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum); - // Verifies that the arguments match the version numbers compiled - // into the library - static void checkVersion( unsigned majnum, unsigned minnum, unsigned relnum ); + // Verifies that the arguments match the version numbers compiled + // into the library + static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); - // Walks through all the garbage collection routines for the library, - // which are supposed to free any unused memory they have allocated. - static void garbageCollect(); + // Walks through all the garbage collection routines for the library, + // which are supposed to free any unused memory they have allocated. + static void garbageCollect(); - // Sets limits on the different kinds of free lists. - static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int - arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); + // Sets limits on the different kinds of free lists. + static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int + arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); // Initializes C++ library and registers terminating functions at exit. - // Only for the library functions, not for user-defined functions. + // Only for the library functions, not for user-defined functions. static void initH5cpp(void); // Sends request for terminating the HDF5 library. diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index a3e6738..5a0bb73 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -15,7 +15,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -40,17 +40,17 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location default constructor (protected) -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location default constructor (protected) +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Location::H5Location() : IdComponent() {} //-------------------------------------------------------------------------- -// Function: H5Location overloaded constructor (protected) -// Purpose Creates an H5Location object using the id of an existing HDF5 -// object. -// Parameters object_id - IN: Id of an existing HDF5 object -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location overloaded constructor (protected) +// Purpose Creates an H5Location object using the id of an existing HDF5 +// object. +// Parameters object_id - IN: Id of an existing HDF5 object +// Programmer Binh-Minh Ribler - 2000 // *** Deprecation warning *** // This constructor is no longer appropriate because the data member "id" had @@ -62,11 +62,11 @@ H5Location::H5Location() : IdComponent() {} // H5Location::H5Location(const hid_t object_id) : IdComponent() {} //-------------------------------------------------------------------------- -// Function: H5Location copy constructor -// Purpose: This noop copy constructor is removed as a result of the data -// member "id" being moved down to sub-classes. (Mar 2015) -///\param original - IN: H5Location instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location copy constructor +// Purpose This noop copy constructor is removed as a result of the data +// member "id" being moved down to sub-classes. (Mar 2015) +///\param original - IN: H5Location instance to copy +// Programmer Binh-Minh Ribler - 2000 // // *** Deprecation warning *** // This constructor is no longer appropriate because the data member "id" had @@ -78,34 +78,34 @@ H5Location::H5Location() : IdComponent() {} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::exists -///\brief Checks if a link of a given name exists in a location -///\param name - IN: Searched name -///\param lapl - IN: Link access property list -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - Nov, 2016 +// Function: H5Location::exists +///\brief Checks if a link of a given name exists in a location +///\param name - IN: Searched name +///\param lapl - IN: Link access property list +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Nov, 2016 // Modification //-------------------------------------------------------------------------- bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const { htri_t ret_value = H5Lexists(getId(), name, lapl.getId()); if (ret_value > 0) - return true; + return true; else if (ret_value == 0) - return false; + return false; else // Raise exception when H5Lexists returns a negative value { - throwException("exists", "H5Lexists failed"); + throwException("exists", "H5Lexists failed"); } } //-------------------------------------------------------------------------- -// Function: H5Location::exists -///\brief Checks if a link of a given name exists in a location -///\param name - IN: Searched name -///\param lapl - IN: Link access property list -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - Dec, 2016 +// Function: H5Location::exists +///\brief Checks if a link of a given name exists in a location +///\param name - IN: Searched name +///\param lapl - IN: Link access property list +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Dec, 2016 // Modification //-------------------------------------------------------------------------- bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) const @@ -114,156 +114,156 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c } //-------------------------------------------------------------------------- -// Function: H5Location::flush -///\brief Flushes all buffers associated with a location to disk. -///\param scope - IN: Specifies the scope of the flushing action, -/// which can be either of these values: -/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file -/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file -///\exception H5::Exception +// Function: H5Location::flush +///\brief Flushes all buffers associated with a location to disk. +///\param scope - IN: Specifies the scope of the flushing action, +/// which can be either of these values: +/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file +/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file +///\exception H5::Exception ///\par Description -/// This location is used to identify the file to be flushed. -// Programmer Binh-Minh Ribler - 2012 +/// This location is used to identify the file to be flushed. +// Programmer Binh-Minh Ribler - 2012 // Modification -// Sep 2012 - BMR -// Moved from H5File/H5Object +// Sep 2012 - BMR +// Moved from H5File/H5Object //-------------------------------------------------------------------------- void H5Location::flush(H5F_scope_t scope) const { - herr_t ret_value = H5Fflush(getId(), scope); - if( ret_value < 0 ) - { - throw LocationException(inMemFunc("flush"), "H5Fflush failed"); - } + herr_t ret_value = H5Fflush(getId(), scope); + if (ret_value < 0) + { + throw LocationException(inMemFunc("flush"), "H5Fflush failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Location::getFileName -///\brief Gets the name of the file, in which this HDF5 object belongs. -///\return File name -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - Jul, 2004 +// Function: H5Location::getFileName +///\brief Gets the name of the file, in which this HDF5 object belongs. +///\return File name +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- H5std_string H5Location::getFileName() const { - try { + try { return(p_get_file_name()); - } - catch (LocationException& E) { - throw FileIException(inMemFunc("getFileName"), E.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- -// Function: H5Location::setComment -///\brief Sets or resets the comment for an object specified by its name. -///\param name - IN: Name of the object -///\param comment - IN: New comment -///\exception H5::LocationException -///\par Description -/// If \a comment is an empty string or a null pointer, the comment -/// message is removed from the object. -/// Comments should be relatively short, null-terminated, ASCII -/// strings. They can be attached to any object that has an -/// object header, e.g., data sets, groups, named data types, -/// and data spaces, but not symbolic links. -// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) + } + catch (LocationException& E) { + throw FileIException(inMemFunc("getFileName"), E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: H5Location::setComment +///\brief Sets or resets the comment for an object specified by its name. +///\param name - IN: Name of the object +///\param comment - IN: New comment +///\exception H5::LocationException +///\par Description +/// If \a comment is an empty string or a null pointer, the comment +/// message is removed from the object. +/// Comments should be relatively short, null-terminated, ASCII +/// strings. They can be attached to any object that has an +/// object header, e.g., data sets, groups, named data types, +/// and data spaces, but not symbolic links. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) // Modification -// 2007: QAK modified to use H5O APIs; however the first parameter is -// no longer just file or group, this function should be moved -// to another class to accommodate attribute, dataset, and named -// datatype. - BMR +// 2007: QAK modified to use H5O APIs; however the first parameter is +// no longer just file or group, this function should be moved +// to another class to accommodate attribute, dataset, and named +// datatype. - BMR //-------------------------------------------------------------------------- void H5Location::setComment(const char* name, const char* comment) const { - herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT); - if( ret_value < 0 ) - throw LocationException(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); + herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT); + if (ret_value < 0) + throw LocationException(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::setComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name and \a comment. -// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name and \a comment. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- void H5Location::setComment(const H5std_string& name, const H5std_string& comment) const { - setComment(name.c_str(), comment.c_str()); + setComment(name.c_str(), comment.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Location::setComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it doesn't take -/// an object name. -// Programmer Binh-Minh Ribler - Sep 2013 +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it doesn't take +/// an object name. +// Programmer Binh-Minh Ribler - Sep 2013 // Modification //-------------------------------------------------------------------------- void H5Location::setComment(const char* comment) const { - herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); - if( ret_value < 0 ) - throw LocationException(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); + herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); + if (ret_value < 0) + throw LocationException(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::setComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a comment. -// Programmer Binh-Minh Ribler - Sep 2013 +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a comment. +// Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- void H5Location::setComment(const H5std_string& comment) const { - setComment(comment.c_str()); + setComment(comment.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Location::removeComment -///\brief Removes the comment from an object specified by its name. -///\param name - IN: Name of the object -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) -// 2007: QAK modified to use H5O APIs; however the first parameter is -// no longer just file or group, this function should be moved -// to another class to accommodate attribute, dataset, and named -// datatype. - BMR +// Function: H5Location::removeComment +///\brief Removes the comment from an object specified by its name. +///\param name - IN: Name of the object +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) +// 2007: QAK modified to use H5O APIs; however the first parameter is +// no longer just file or group, this function should be moved +// to another class to accommodate attribute, dataset, and named +// datatype. - BMR //-------------------------------------------------------------------------- void H5Location::removeComment(const char* name) const { - herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); - if( ret_value < 0 ) - throw LocationException(inMemFunc("removeComment"), "H5Oset_comment_by_name failed"); + herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); + if (ret_value < 0) + throw LocationException(inMemFunc("removeComment"), "H5Oset_comment_by_name failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::removeComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) +// Function: H5Location::removeComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- void H5Location::removeComment(const H5std_string& name) const { - removeComment (name.c_str()); + removeComment (name.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Location::getComment -///\brief Retrieves the comment for this location, returning its length. -///\param name - IN: Name of the object -///\param buf_size - IN: Length of the comment to retrieve -///\param comment - OUT: Retrieved comment -///\return Actual length of the comment -///\exception H5::LocationException +// Function: H5Location::getComment +///\brief Retrieves the comment for this location, returning its length. +///\param name - IN: Name of the object +///\param buf_size - IN: Length of the comment to retrieve +///\param comment - OUT: Retrieved comment +///\return Actual length of the comment +///\exception H5::LocationException ///\par Description -/// This function retrieves \a buf_size characters of the comment -/// including the null terminator. Thus, if the actual length -/// of the comment is more than buf_size-1, the retrieved comment -/// will be truncated to accommodate the null terminator. -// Programmer Binh-Minh Ribler - Mar 2014 +/// This function retrieves \a buf_size characters of the comment +/// including the null terminator. Thus, if the actual length +/// of the comment is more than buf_size-1, the retrieved comment +/// will be truncated to accommodate the null terminator. +// Programmer Binh-Minh Ribler - Mar 2014 //-------------------------------------------------------------------------- ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) const { @@ -274,27 +274,27 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) // If H5Oget_comment_by_name returns a negative value, raise an exception if (comment_len < 0) - { + { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If the comment is longer than the provided buffer size, the C library // will not null terminate it if (static_cast(comment_len) >= buf_size) - comment[buf_size-1] = '\0'; + comment[buf_size-1] = '\0'; // Return the actual comment length, which might be different from buf_size return(comment_len); } //-------------------------------------------------------------------------- -// Function: H5Location::getComment -///\brief Returns the comment as \a string for this location, -/// returning its length. -///\param name - IN: Name of the object -///\param buf_size - IN: Length of the comment to retrieve, default to 0 -///\return Comment string -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +// Function: H5Location::getComment +///\brief Returns the comment as \a string for this location, +/// returning its length. +///\param name - IN: Name of the object +///\param buf_size - IN: Length of the comment to retrieve, default to 0 +///\return Comment string +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- H5std_string H5Location::getComment(const char* name, size_t buf_size) const { @@ -307,36 +307,36 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const // If H5Oget_comment_by_name returns a negative value, raise an exception if (comment_len < 0) - { + { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If comment exists, calls C routine again to get it else if (comment_len > 0) - { - size_t tmp_len = buf_size; - - // If buffer size is not provided, use comment length - if (tmp_len == 0) - tmp_len = comment_len; - - // Temporary buffer for char* comment - char* comment_C = new char[tmp_len+1]; - HDmemset(comment_C, 0, tmp_len+1); // clear buffer - - // Used overloaded function - ssize_t temp_len = getComment(name, tmp_len+1, comment_C); - if (temp_len < 0) - { - delete []comment_C; - throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); - } - - // Convert the C comment to return - comment = comment_C; - - // Clean up resource - delete []comment_C; + { + size_t tmp_len = buf_size; + + // If buffer size is not provided, use comment length + if (tmp_len == 0) + tmp_len = comment_len; + + // Temporary buffer for char* comment + char* comment_C = new char[tmp_len+1]; + HDmemset(comment_C, 0, tmp_len+1); // clear buffer + + // Used overloaded function + ssize_t temp_len = getComment(name, tmp_len+1, comment_C); + if (temp_len < 0) + { + delete []comment_C; + throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); + } + + // Convert the C comment to return + comment = comment_C; + + // Clean up resource + delete []comment_C; } // Return the string comment @@ -344,11 +344,11 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const } //-------------------------------------------------------------------------- -// Function: H5Location::getComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +// Function: H5Location::getComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) const { @@ -357,112 +357,112 @@ H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) c #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::p_reference (protected) -// Purpose Creates a reference to an HDF5 object or a dataset region. +// Function: H5Location::p_reference (protected) +// Purpose Creates a reference to an HDF5 object or a dataset region. // Parameters -// name - IN: Name of the object to be referenced -// dataspace - IN: Dataspace with selection -// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION -// Exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// name - IN: Name of the object to be referenced +// dataspace - IN: Dataspace with selection +// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION +// Exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const { - herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id); - if (ret_value < 0) - { - throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); - } + herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id); + if (ret_value < 0) + { + throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); + } } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::reference -///\brief Creates a reference to an HDF5 object or a dataset region. -///\param ref - IN: Reference pointer -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference. -/// \li \c H5R_DATASET_REGION - Reference is a dataset region -/// reference. (default) -///\exception H5::ReferenceException -///\note This method is more suitable for a dataset region reference. -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::reference +///\brief Creates a reference to an HDF5 object or a dataset region. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced +///\param dataspace - IN: Dataspace with selection +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference. +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +/// reference. (default) +///\exception H5::ReferenceException +///\note This method is more suitable for a dataset region reference. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const { - try { - p_reference(ref, name, dataspace.getId(), ref_type); - } - catch (ReferenceException& E) { - throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- -// Function: H5Location::reference -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -///\param ref - IN: Reference pointer -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference. -/// \li \c H5R_DATASET_REGION - Reference is a dataset region -/// reference. (default) -///\exception H5::ReferenceException -///\note This method is more suitable for a dataset region reference. -// Programmer Binh-Minh Ribler - May, 2004 + try { + p_reference(ref, name, dataspace.getId(), ref_type); + } + catch (ReferenceException& E) { + throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: H5Location::reference +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced +///\param dataspace - IN: Dataspace with selection +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference. +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +/// reference. (default) +///\exception H5::ReferenceException +///\note This method is more suitable for a dataset region reference. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const { - try { - p_reference(ref, name.c_str(), dataspace.getId(), ref_type); - } - catch (ReferenceException& E) { - throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); - } + try { + p_reference(ref, name.c_str(), dataspace.getId(), ref_type); + } + catch (ReferenceException& E) { + throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: H5Location::reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it does not take -/// a DataSpace object and the reference type must be specified. -///\param ref - IN: Reference pointer -///\param name - IN: Name of the object to be referenced -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference (default) -/// \li \c H5R_DATASET_REGION - Reference is a dataset region -///\exception H5::ReferenceException -///\note This method is more suitable for an object reference. -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it does not take +/// a DataSpace object and the reference type must be specified. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference (default) +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +///\exception H5::ReferenceException +///\note This method is more suitable for an object reference. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const { - try { - p_reference(ref, name, -1, ref_type); - } - catch (ReferenceException& E) { - throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); - } + try { + p_reference(ref, name, -1, ref_type); + } + catch (ReferenceException& E) { + throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- -// Function: H5Location::reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for the object's name. -///\param ref - IN: Reference pointer -///\param name - IN: Name of the object to be referenced - \c H5std_string -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference (default) -/// \li \c H5R_DATASET_REGION - Reference is a dataset region -///\note This method is more suitable for an object reference. -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for the object's name. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced - \c H5std_string +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference (default) +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +///\note This method is more suitable for an object reference. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const { @@ -471,69 +471,69 @@ void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_t #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::p_dereference (protected) -// Purpose Dereference a ref into an hdf5 object. +// Function: H5Location::p_dereference (protected) +// Purpose Dereference a ref into an hdf5 object. // Parameters -// loc_id - IN: An hdf5 identifier specifying the location of the -// referenced object -// ref - IN: Reference pointer -// ref_type - IN: Reference type -// plist - IN: Property list - default to PropList::DEFAULT -// from_func - IN: Name of the calling function -// Exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// loc_id - IN: An hdf5 identifier specifying the location of the +// referenced object +// ref - IN: Reference pointer +// ref_type - IN: Reference type +// plist - IN: Property list - default to PropList::DEFAULT +// from_func - IN: Name of the calling function +// Exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// May 2008 - BMR -// Moved from IdComponent. +// May 2008 - BMR +// Moved from IdComponent. //-------------------------------------------------------------------------- hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func) { - hid_t plist_id; - if (p_valid_id(plist.getId())) - plist_id = plist.getId(); - else - plist_id = H5P_DEFAULT; + hid_t plist_id; + if (p_valid_id(plist.getId())) + plist_id = plist.getId(); + else + plist_id = H5P_DEFAULT; - hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); - if (temp_id < 0) - { - throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed"); - } + hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); + if (temp_id < 0) + { + throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed"); + } - return(temp_id); + return(temp_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::dereference -///\brief Dereferences a reference into an HDF5 object, given an HDF5 object. -///\param loc - IN: Location of the referenced object -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// Function: H5Location::dereference +///\brief Dereferences a reference into an HDF5 object, given an HDF5 object. +///\param loc - IN: Location of the referenced object +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// May, 2008 -// Corrected missing parameters. - BMR +// May, 2008 +// Corrected missing parameters. - BMR //-------------------------------------------------------------------------- void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) { - p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference")); + p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference")); } //-------------------------------------------------------------------------- -// Function: H5Location::dereference -///\brief Dereferences a reference into an HDF5 object, given an attribute. -///\param attr - IN: Attribute specifying the location of the referenced object -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type -///\param plist - IN: Property list - default to PropList::DEFAULT -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// Function: H5Location::dereference +///\brief Dereferences a reference into an HDF5 object, given an attribute. +///\param attr - IN: Attribute specifying the location of the referenced object +///\param ref - IN: Reference pointer +///\param ref_type - IN: Reference type +///\param plist - IN: Property list - default to PropList::DEFAULT +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - Oct, 2006 // Modification -// May, 2008 -// Corrected missing parameters. - BMR +// May, 2008 +// Corrected missing parameters. - BMR //-------------------------------------------------------------------------- /* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) { @@ -543,153 +543,152 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- -// Function: H5Location::getObjType -///\brief Retrieves the type of object that an object reference points to. -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference. -/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference. -///\param ref - IN: Reference to query -///\return An object type, which can be one of the following: -/// \li \c H5G_UNKNOWN - A failure occurs. (-1) -/// \li \c H5G_GROUP - Object is a group. -/// \li \c H5G_DATASET - Object is a dataset. -/// \li \c H5G_TYPE Object - is a named datatype -/// \li \c H5G_LINK - Object is a symbolic link. -/// \li \c H5G_UDLINK - Object is a user-defined link. -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::getObjType +///\brief Retrieves the type of object that an object reference points to. +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference. +/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference. +///\param ref - IN: Reference to query +///\return An object type, which can be one of the following: +/// \li \c H5G_UNKNOWN - A failure occurs. (-1) +/// \li \c H5G_GROUP - Object is a group. +/// \li \c H5G_DATASET - Object is a dataset. +/// \li \c H5G_TYPE Object - is a named datatype +/// \li \c H5G_LINK - Object is a symbolic link. +/// \li \c H5G_UDLINK - Object is a user-defined link. +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 // Modification -// Sep 2012: Moved up from H5File, Group, DataSet, and DataType +// Sep 2012: Moved up from H5File, Group, DataSet, and DataType //-------------------------------------------------------------------------- H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const { - try { - return(p_get_obj_type(ref, ref_type)); - } - catch (ReferenceException& E) { - throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); - } + try { + return(p_get_obj_type(ref, ref_type)); + } + catch (ReferenceException& E) { + throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); + } } #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::p_get_obj_type (protected) -// Purpose Retrieves the type of object that an object reference points to. +// Function: H5Location::p_get_obj_type (protected) +// Purpose Retrieves the type of object that an object reference points to. // Parameters -// ref - IN: Reference to query -// ref_type - IN: Type of reference to query -// Return An object type, which can be one of the following: -// H5G_UNKNOWN \tFailure occurs (-1) -// H5G_GROUP \tObject is a group. -// H5G_DATASET \tObject is a dataset. -// H5G_TYPE Object \tis a named datatype. -// H5G_LINK \tObject is a symbolic link. -// H5G_UDLINK \tObject is a user-defined link. -// Exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// ref - IN: Reference to query +// ref_type - IN: Type of reference to query +// Return An object type, which can be one of the following: +// H5G_UNKNOWN \tFailure occurs (-1) +// H5G_GROUP \tObject is a group. +// H5G_DATASET \tObject is a dataset. +// H5G_TYPE Object \tis a named datatype. +// H5G_LINK \tObject is a symbolic link. +// H5G_UDLINK \tObject is a user-defined link. +// Exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const { H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); - if (obj_type == H5G_UNKNOWN) - { - throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); - } + { + throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); + } return(obj_type); } #endif // DOXYGEN_SHOULD_SKIP_THIS #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- -// Function: H5Location::getRefObjType -///\brief Retrieves the type of object that an object reference points to. -///\param ref - IN: Reference to query -///\param ref_type - IN: Type of reference to query, valid values are: -/// \li \c H5R_OBJECT - Reference is an object reference. -/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference. -///\return An object type, which can be one of the following: -/// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1) -/// \li \c H5O_TYPE_GROUP - Object is a group -/// \li \c H5O_TYPE_DATASET - Object is a dataset -/// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype -/// \li \c H5O_TYPE_NTYPES - Number of different object types -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::getRefObjType +///\brief Retrieves the type of object that an object reference points to. +///\param ref - IN: Reference to query +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference. +/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference. +///\return An object type, which can be one of the following: +/// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1) +/// \li \c H5O_TYPE_GROUP - Object is a group +/// \li \c H5O_TYPE_DATASET - Object is a dataset +/// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype +/// \li \c H5O_TYPE_NTYPES - Number of different object types +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const { - try { + try { return(p_get_ref_obj_type(ref, ref_type)); - } - catch (ReferenceException& E) { - throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); - } + } + catch (ReferenceException& E) { + throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); + } } #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::p_get_ref_obj_type (protected) -// Purpose Retrieves the type of object that an object reference points to. +// Function: H5Location::p_get_ref_obj_type (protected) +// Purpose Retrieves the type of object that an object reference points to. // Parameters -// ref - IN: Reference to query -// ref_type - IN: Type of reference to query -// Return An object type, which can be one of the following: -// H5O_TYPE_UNKNOWN - Unknown object type (-1) -// H5O_TYPE_GROUP - Object is a group -// H5O_TYPE_DATASET - Object is a dataset -// H5O_TYPE_NAMED_DATATYPE - Object is a named datatype -// H5O_TYPE_NTYPES - Number of object types -// Exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// ref - IN: Reference to query +// ref_type - IN: Type of reference to query +// Return An object type, which can be one of the following: +// H5O_TYPE_UNKNOWN - Unknown object type (-1) +// H5O_TYPE_GROUP - Object is a group +// H5O_TYPE_DATASET - Object is a dataset +// H5O_TYPE_NAMED_DATATYPE - Object is a named datatype +// H5O_TYPE_NTYPES - Number of object types +// Exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const { - H5O_type_t obj_type = H5O_TYPE_UNKNOWN; - herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); - if (ret_value < 0) - { - throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); - } - if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) - { - throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); - } - return(obj_type); + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; + herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); + if (ret_value < 0) + { + throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); + } + if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) + { + throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); + } + return(obj_type); } //-------------------------------------------------------------------------- -// Function: H5Location::getRegion -///\brief Retrieves a dataspace with the region pointed to selected. -///\param ref - IN: Reference to get region of -///\param ref_type - IN: Type of reference to get region of - default -// to H5R_DATASET_REGION -///\return DataSpace object -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: H5Location::getRegion +///\brief Retrieves a dataspace with the region pointed to selected. +///\param ref - IN: Reference to get region of +///\param ref_type - IN: Type of reference to get region of - default +// to H5R_DATASET_REGION +///\return DataSpace object +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 // Modification -// Mar 29, 2015 -// Used friend function to set id for DataSpace instead of the -// existing id constructor or the setId method to avoid incrementing -// ref count, as a work-around for a problem described in the JIRA -// issue HDFFV-7947. -BMR +// Mar 29, 2015 +// Used friend function to set id for DataSpace instead of the +// existing id constructor or the setId method to avoid incrementing +// ref count, as a work-around for a problem described in the JIRA +// issue HDFFV-7947. -BMR //-------------------------------------------------------------------------- DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const { - hid_t space_id = H5Rget_region(getId(), ref_type, ref); - if (space_id < 0) - { - throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); - } - try { - DataSpace dataspace; - f_DataSpace_setId(&dataspace, space_id); - return(dataspace); - } - catch (DataSpaceIException& E) { - throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); - } + hid_t space_id = H5Rget_region(getId(), ref_type, ref); + if (space_id < 0) + { + throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); + } + try { + DataSpace dataspace; + f_DataSpace_setId(&dataspace, space_id); + return(dataspace); + } + catch (DataSpaceIException& E) { + throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); + } } @@ -705,11 +704,11 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const // to call the right getId() - although, as the structure of the // library at this time, getId() is basically the IdComponent::getId() // ***Updated: after the classes are rearranged (HDFFV-9920), functions -// in CommonFG are moved to Group, and they can call getId() -// instead of getLocId(). getLocId() is kept for backward -// compatibility on user applications. Aug 18, 2016 -BMR +// in CommonFG are moved to Group, and they can call getId() +// instead of getLocId(). getLocId() is kept for backward +// compatibility on user applications. Aug 18, 2016 -BMR // ***Updated: Moving to Group was a mistake, now to H5Location -// Aug 24, 2016 -BMR +// Aug 24, 2016 -BMR // - when a failure returned by the C API, the functions will call // throwException, which is a pure virtual function and is implemented // by H5File to throw a FileIException and by Group to throw a @@ -722,29 +721,29 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const // is kept in those methods as well. Sep 17, 2016 -BMR //-------------------------------------------------------------------------- -// Function: H5Location::createGroup -///\brief Creates a new group at this location which can be a file -/// or another group. -///\param name - IN: Name of the group to create -///\param size_hint - IN: Indicates the number of bytes to reserve for -/// the names that will appear in the group -///\return Group instance -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::createGroup +///\brief Creates a new group at this location which can be a file +/// or another group. +///\param name - IN: Name of the group to create +///\param size_hint - IN: Indicates the number of bytes to reserve for +/// the names that will appear in the group +///\return Group instance +///\exception H5::FileIException or H5::GroupIException ///\par Description -/// The optional \a size_hint specifies how much file space to -/// reserve for storing the names that will appear in this new -/// group. If a non-positive value is provided for the \a size_hint -/// then a default size is chosen. -// Programmer Binh-Minh Ribler - 2000 +/// The optional \a size_hint specifies how much file space to +/// reserve for storing the names that will appear in this new +/// group. If a non-positive value is provided for the \a size_hint +/// then a default size is chosen. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup( const char* name, size_t size_hint ) const +Group H5Location::createGroup(const char* name, size_t size_hint) const { // Group creation property list for size hint hid_t gcpl_id = 0; // Set the local heap size hint if (size_hint > 0) - { + { // If the creation of the property list failed, throw an exception if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) throwException("createGroup", "H5Pcreate failed"); @@ -755,351 +754,351 @@ Group H5Location::createGroup( const char* name, size_t size_hint ) const } } - // Call C routine H5Gcreate2 to create the named group, giving the - // location id which can be a file id or a group id - hid_t group_id = H5Gcreate2(getId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT ); + // Call C routine H5Gcreate2 to create the named group, giving the + // location id which can be a file id or a group id + hid_t group_id = H5Gcreate2(getId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT); - // Close the group creation property list, if necessary - if(gcpl_id > 0) + // Close the group creation property list, if necessary + if(gcpl_id > 0) H5Pclose(gcpl_id); - // If the creation of the group failed, throw an exception - if( group_id < 0 ) - throwException("createGroup", "H5Gcreate2 failed"); + // If the creation of the group failed, throw an exception + if (group_id < 0) + throwException("createGroup", "H5Gcreate2 failed"); - // No failure, create and return the Group object - Group group; - //group.p_setId(group_id); - H5Location *ptr = &group; - ptr->p_setId(group_id); - return( group ); + // No failure, create and return the Group object + Group group; + //group.p_setId(group_id); + H5Location *ptr = &group; + ptr->p_setId(group_id); + return(group); } //-------------------------------------------------------------------------- -// Function: H5Location::createGroup -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::createGroup +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup( const H5std_string& name, size_t size_hint ) const +Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const { - return( createGroup( name.c_str(), size_hint )); + return(createGroup( name.c_str(), size_hint)); } //-------------------------------------------------------------------------- -// Function: H5Location::openGroup -///\brief Opens an existing group in a location which can be a file -/// or another group. -///\param name - IN: Name of the group to open -///\return Group instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::openGroup +///\brief Opens an existing group in a location which can be a file +/// or another group. +///\param name - IN: Name of the group to open +///\return Group instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup( const char* name ) const +Group H5Location::openGroup(const char* name) const { - // Call C routine H5Gopen2 to open the named group, giving the - // location id which can be a file id or a group id - hid_t group_id = H5Gopen2(getId(), name, H5P_DEFAULT ); + // Call C routine H5Gopen2 to open the named group, giving the + // location id which can be a file id or a group id + hid_t group_id = H5Gopen2(getId(), name, H5P_DEFAULT); - // If the opening of the group failed, throw an exception - if( group_id < 0 ) - throwException("openGroup", "H5Gopen2 failed"); + // If the opening of the group failed, throw an exception + if (group_id < 0) + throwException("openGroup", "H5Gopen2 failed"); - // No failure, create and return the Group object - Group group; - //group.p_setId(group_id); - H5Location *ptr = &group; - ptr->p_setId(group_id); - return( group ); + // No failure, create and return the Group object + Group group; + //group.p_setId(group_id); + H5Location *ptr = &group; + ptr->p_setId(group_id); + return(group); } //-------------------------------------------------------------------------- -// Function: H5Location::openGroup -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::openGroup +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup( const H5std_string& name ) const +Group H5Location::openGroup(const H5std_string& name) const { - return( openGroup( name.c_str() )); + return(openGroup( name.c_str())); } //-------------------------------------------------------------------------- -// Function: H5Location::createDataSet -///\brief Creates a new dataset at this location. -///\param name - IN: Name of the dataset to create -///\param data_type - IN: Datatype of the dataset -///\param data_space - IN: Dataspace for the dataset -///\param create_plist - IN: Creation properly list for the dataset -///\return DataSet instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::createDataSet +///\brief Creates a new dataset at this location. +///\param name - IN: Name of the dataset to create +///\param data_type - IN: Datatype of the dataset +///\param data_space - IN: Dataspace for the dataset +///\param create_plist - IN: Creation properly list for the dataset +///\return DataSet instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet( const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist ) const +DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist) const { // Obtain identifiers for C API - hid_t type_id = data_type.getId(); - hid_t space_id = data_space.getId(); - hid_t create_plist_id = create_plist.getId(); + hid_t type_id = data_type.getId(); + hid_t space_id = data_space.getId(); + hid_t create_plist_id = create_plist.getId(); - // Call C routine H5Dcreate2 to create the named dataset - hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, H5P_DEFAULT, create_plist_id, H5P_DEFAULT ); + // Call C routine H5Dcreate2 to create the named dataset + hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, H5P_DEFAULT, create_plist_id, H5P_DEFAULT); - // If the creation of the dataset failed, throw an exception - if( dataset_id < 0 ) - throwException("createDataSet", "H5Dcreate2 failed"); + // If the creation of the dataset failed, throw an exception + if (dataset_id < 0) + throwException("createDataSet", "H5Dcreate2 failed"); - // No failure, create and return the DataSet object - DataSet dataset; - f_DataSet_setId(&dataset, dataset_id); - return( dataset ); + // No failure, create and return the DataSet object + DataSet dataset; + f_DataSet_setId(&dataset, dataset_id); + return(dataset); } //-------------------------------------------------------------------------- -// Function: H5Location::createDataSet -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::createDataSet +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist ) const +DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist) const { - return( createDataSet( name.c_str(), data_type, data_space, create_plist )); + return(createDataSet( name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- -// Function: H5Location::openDataSet -///\brief Opens an existing dataset at this location. -///\param name - IN: Name of the dataset to open -///\return DataSet instance -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::openDataSet +///\brief Opens an existing dataset at this location. +///\param name - IN: Name of the dataset to open +///\return DataSet instance +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet( const char* name ) const +DataSet H5Location::openDataSet(const char* name) const { - // Call C function H5Dopen2 to open the specified dataset, giving - // the location id and the dataset's name - hid_t dataset_id = H5Dopen2(getId(), name, H5P_DEFAULT ); + // Call C function H5Dopen2 to open the specified dataset, giving + // the location id and the dataset's name + hid_t dataset_id = H5Dopen2(getId(), name, H5P_DEFAULT); - // If the dataset's opening failed, throw an exception - if(dataset_id < 0) - throwException("openDataSet", "H5Dopen2 failed"); + // If the dataset's opening failed, throw an exception + if(dataset_id < 0) + throwException("openDataSet", "H5Dopen2 failed"); - // No failure, create and return the DataSet object - DataSet dataset; - f_DataSet_setId(&dataset, dataset_id); - return( dataset ); + // No failure, create and return the DataSet object + DataSet dataset; + f_DataSet_setId(&dataset, dataset_id); + return(dataset); } //-------------------------------------------------------------------------- -// Function: H5Location::openDataSet -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::openDataSet +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet( const H5std_string& name ) const +DataSet H5Location::openDataSet(const H5std_string& name) const { - return( openDataSet( name.c_str() )); + return(openDataSet( name.c_str())); } //-------------------------------------------------------------------------- -// Function: H5Location::link -///\brief Creates a link of the specified type from \a new_name to -/// \a curr_name. -///\param link_type - IN: Link type; possible values are -/// \li \c H5G_LINK_HARD -/// \li \c H5G_LINK_SOFT -///\param curr_name - IN: Name of the existing object if link is a hard -/// link; can be anything for the soft link -///\param new_name - IN: New name for the object -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::link +///\brief Creates a link of the specified type from \a new_name to +/// \a curr_name. +///\param link_type - IN: Link type; possible values are +/// \li \c H5G_LINK_HARD +/// \li \c H5G_LINK_SOFT +///\param curr_name - IN: Name of the existing object if link is a hard +/// link; can be anything for the soft link +///\param new_name - IN: New name for the object +///\exception H5::FileIException or H5::GroupIException ///\par Description -/// Note that both names are interpreted relative to the -/// specified location. -/// For information on creating hard link and soft link, please -/// refer to the C layer Reference Manual at: +/// Note that both names are interpreted relative to the +/// specified location. +/// For information on creating hard link and soft link, please +/// refer to the C layer Reference Manual at: /// http://hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-CreateHard and /// http://hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-CreateSoft -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 // Modification -// 2007: QAK modified to use H5L APIs - BMR +// 2007: QAK modified to use H5L APIs - BMR //-------------------------------------------------------------------------- -void H5Location::link( H5L_type_t link_type, const char* curr_name, const char* new_name ) const +void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* new_name) const { herr_t ret_value = -1; switch(link_type) { case H5L_TYPE_HARD: - ret_value = H5Lcreate_hard(getId(), curr_name, H5L_SAME_LOC, new_name, H5P_DEFAULT, H5P_DEFAULT ); + ret_value = H5Lcreate_hard(getId(), curr_name, H5L_SAME_LOC, new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_SOFT: - ret_value = H5Lcreate_soft( curr_name,getId(), new_name, H5P_DEFAULT, H5P_DEFAULT ); + ret_value = H5Lcreate_soft(curr_name,getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); break; - case H5L_TYPE_ERROR: - case H5L_TYPE_EXTERNAL: - case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_MAX: default: throwException("link", "unknown link type"); break; } /* end switch */ - if( ret_value < 0 ) - throwException("link", "creating link failed"); + if (ret_value < 0) + throwException("link", "creating link failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::link -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a curr_name and \a new_name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::link +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a curr_name and \a new_name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::link( H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name ) const +void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const { - link( link_type, curr_name.c_str(), new_name.c_str() ); + link(link_type, curr_name.c_str(), new_name.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Location::unlink -///\brief Removes the specified name at this location. -///\param name - IN: Name of the object to be removed -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::unlink +///\brief Removes the specified name at this location. +///\param name - IN: Name of the object to be removed +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// 2007: QAK modified to use H5L APIs - BMR +// 2007: QAK modified to use H5L APIs - BMR //-------------------------------------------------------------------------- -void H5Location::unlink( const char* name ) const +void H5Location::unlink(const char* name) const { - herr_t ret_value = H5Ldelete(getId(), name, H5P_DEFAULT ); - if( ret_value < 0 ) - throwException("unlink", "H5Ldelete failed"); + herr_t ret_value = H5Ldelete(getId(), name, H5P_DEFAULT); + if (ret_value < 0) + throwException("unlink", "H5Ldelete failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::unlink -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::unlink +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unlink( const H5std_string& name ) const +void H5Location::unlink(const H5std_string& name) const { - unlink( name.c_str() ); + unlink(name.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Location::move -///\brief Renames an object at this location. -///\param src - IN: Object's original name -///\param dst - IN: Object's new name -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::move +///\brief Renames an object at this location. +///\param src - IN: Object's original name +///\param dst - IN: Object's new name +///\exception H5::FileIException or H5::GroupIException ///\note -/// Exercise care in moving groups as it is possible to render -/// data in a file inaccessible with H5Location::move. Please refer -/// to the Group Interface in the HDF5 User's Guide for details at: +/// Exercise care in moving groups as it is possible to render +/// data in a file inaccessible with H5Location::move. Please refer +/// to the Group Interface in the HDF5 User's Guide for details at: /// https://www.hdfgroup.org/HDF5/doc/UG/HDF5_Users_Guide-Responsive%20HTML5/index.html#t=HDF5_Users_Guide%2FGroups%2FHDF5_Groups.htm -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 // Modification -// 2007: QAK modified to use H5L APIs - BMR +// 2007: QAK modified to use H5L APIs - BMR //-------------------------------------------------------------------------- -void H5Location::move( const char* src, const char* dst ) const +void H5Location::move(const char* src, const char* dst) const { - herr_t ret_value = H5Lmove(getId(), src, H5L_SAME_LOC, dst, H5P_DEFAULT, H5P_DEFAULT ); - if( ret_value < 0 ) - throwException("move", "H5Lmove failed"); + herr_t ret_value = H5Lmove(getId(), src, H5L_SAME_LOC, dst, H5P_DEFAULT, H5P_DEFAULT); + if (ret_value < 0) + throwException("move", "H5Lmove failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::move -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a src and \a dst. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::move +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a src and \a dst. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::move( const H5std_string& src, const H5std_string& dst ) const +void H5Location::move(const H5std_string& src, const H5std_string& dst) const { - move( src.c_str(), dst.c_str() ); + move(src.c_str(), dst.c_str()); } #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- -// Function: H5Location::getObjinfo -///\brief Returns information about an object. -///\param name - IN: Name of the object -///\param follow_link - IN: Link flag -///\param statbuf - OUT: Buffer to return information about the object -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::getObjinfo +///\brief Returns information about an object. +///\param name - IN: Name of the object +///\param follow_link - IN: Link flag +///\param statbuf - OUT: Buffer to return information about the object +///\exception H5::FileIException or H5::GroupIException ///\par Description -/// For more information, please refer to the C layer Reference -/// Manual at: +/// For more information, please refer to the C layer Reference +/// Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5G.html#Group-GetObjinfo -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& statbuf ) const +void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const { - herr_t ret_value = H5Gget_objinfo(getId(), name, follow_link, &statbuf ); - if( ret_value < 0 ) - throwException("getObjinfo", "H5Gget_objinfo failed"); + herr_t ret_value = H5Gget_objinfo(getId(), name, follow_link, &statbuf); + if (ret_value < 0) + throwException("getObjinfo", "H5Gget_objinfo failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjinfo -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::getObjinfo +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo( const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf ) const +void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const { - getObjinfo( name.c_str(), follow_link, statbuf ); + getObjinfo(name.c_str(), follow_link, statbuf); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjinfo -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above functions in that it doesn't have -/// the paramemter \a follow_link. -// Programmer Binh-Minh Ribler - Nov, 2005 +// Function: H5Location::getObjinfo +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above functions in that it doesn't have +/// the paramemter \a follow_link. +// Programmer Binh-Minh Ribler - Nov, 2005 // Note: need to modify to use H5Oget_info and H5Lget_info - BMR //-------------------------------------------------------------------------- -void H5Location::getObjinfo( const char* name, H5G_stat_t& statbuf ) const +void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const { - herr_t ret_value = H5Gget_objinfo(getId(), name, 0, &statbuf ); - if( ret_value < 0 ) - throwException("getObjinfo", "H5Gget_objinfo failed"); + herr_t ret_value = H5Gget_objinfo(getId(), name, 0, &statbuf); + if (ret_value < 0) + throwException("getObjinfo", "H5Gget_objinfo failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjinfo -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - Nov, 2005 +// Function: H5Location::getObjinfo +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo( const H5std_string& name, H5G_stat_t& statbuf ) const +void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const { - getObjinfo( name.c_str(), statbuf ); + getObjinfo(name.c_str(), statbuf); } #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- -// Function: H5Location::getLinkval -///\brief Returns the name of the object that the symbolic link points to. -///\param name - IN: Symbolic link to the object -///\param size - IN: Maximum number of characters of value to be returned -///\return Name of the object -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::getLinkval +///\brief Returns the name of the object that the symbolic link points to. +///\param name - IN: Symbolic link to the object +///\param size - IN: Maximum number of characters of value to be returned +///\return Name of the object +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval( const char* name, size_t size ) const +H5std_string H5Location::getLinkval(const char* name, size_t size) const { H5L_info_t linkinfo; - char *value_C; // value in C string + char *value_C; // value in C string size_t val_size = size; H5std_string value = ""; herr_t ret_value; @@ -1107,81 +1106,81 @@ H5std_string H5Location::getLinkval( const char* name, size_t size ) const // if user doesn't provide buffer size, determine it if (size == 0) { - ret_value = H5Lget_info(getId(), name, &linkinfo, H5P_DEFAULT); - if( ret_value < 0 ) - throwException("getLinkval", "H5Lget_info to find buffer size failed"); + ret_value = H5Lget_info(getId(), name, &linkinfo, H5P_DEFAULT); + if (ret_value < 0) + throwException("getLinkval", "H5Lget_info to find buffer size failed"); - val_size = linkinfo.u.val_size; + val_size = linkinfo.u.val_size; } // if link has value, retrieve the value, otherwise, return null string if (val_size > 0) { - value_C = new char[val_size+1]; // temporary C-string for C API - HDmemset(value_C, 0, val_size+1); // clear buffer - - ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); - if( ret_value < 0 ) - { - delete []value_C; - throwException("getLinkval", "H5Lget_val failed"); - } - - value = H5std_string(value_C); - delete []value_C; + value_C = new char[val_size+1]; // temporary C-string for C API + HDmemset(value_C, 0, val_size+1); // clear buffer + + ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); + if (ret_value < 0) + { + delete []value_C; + throwException("getLinkval", "H5Lget_val failed"); + } + + value = H5std_string(value_C); + delete []value_C; } return(value); } //-------------------------------------------------------------------------- -// Function: H5Location::getLinkval -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::getLinkval +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval( const H5std_string& name, size_t size ) const +H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const { - return( getLinkval( name.c_str(), size )); + return(getLinkval( name.c_str(), size)); } //-------------------------------------------------------------------------- -// Function: H5Location::mount -///\brief Mounts the file \a child onto this group. -///\param name - IN: Name of the group -///\param child - IN: File to mount -///\param plist - IN: Property list to use -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2014 (original 2000) +// Function: H5Location::mount +///\brief Mounts the file \a child onto this group. +///\param name - IN: Name of the group +///\param child - IN: File to mount +///\param plist - IN: Property list to use +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2014 (original 2000) //-------------------------------------------------------------------------- -void H5Location::mount(const char* name, const H5File& child, const PropList& plist ) const +void H5Location::mount(const char* name, const H5File& child, const PropList& plist) const { - // Obtain identifiers for C API - hid_t plist_id = plist.getId(); - hid_t child_id = child.getId(); + // Obtain identifiers for C API + hid_t plist_id = plist.getId(); + hid_t child_id = child.getId(); - // Call C routine H5Fmount to do the mouting - herr_t ret_value = H5Fmount(getId(), name, child_id, plist_id ); + // Call C routine H5Fmount to do the mouting + herr_t ret_value = H5Fmount(getId(), name, child_id, plist_id); - // Raise exception if H5Fmount returns negative value - if( ret_value < 0 ) - throwException("mount", "H5Fmount failed"); + // Raise exception if H5Fmount returns negative value + if (ret_value < 0) + throwException("mount", "H5Fmount failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::mount -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Param name - IN: Name of the group -// Param child - IN: File to mount -// Param plist - IN: Property list to use -// Exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::mount +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Param name - IN: Name of the group +// Param child - IN: File to mount +// Param plist - IN: Property list to use +// Exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void H5Location::mount(const char* name, H5File& child, PropList& plist) const //{ @@ -1189,26 +1188,26 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl //} //-------------------------------------------------------------------------- -// Function: H5Location::mount -///\brief This is an overloaded member function, provided for convenience. -/// It takes an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::mount +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5Location::mount(const H5std_string& name, const H5File& child, const PropList& plist) const { - mount(name.c_str(), child, plist); + mount(name.c_str(), child, plist); } //-------------------------------------------------------------------------- -// Function: H5Location::mount -// Purpose This is an overloaded member function, kept for backward -// compatibility. It differs from the above function in that it -// misses const's. This wrapper will be removed in future release. -// Programmer Binh-Minh Ribler - 2014 +// Function: H5Location::mount +// Purpose This is an overloaded member function, kept for backward +// compatibility. It differs from the above function in that it +// misses const's. This wrapper will be removed in future release. +// Programmer Binh-Minh Ribler - 2014 // Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 +// Modified to call its replacement. -BMR, 2014/04/16 +// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 +// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- //void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const //{ @@ -1216,109 +1215,109 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop //} //-------------------------------------------------------------------------- -// Function: H5Location::unmount -///\brief Unmounts the specified file. -///\param name - IN: Name of the file to unmount -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::unmount +///\brief Unmounts the specified file. +///\param name - IN: Name of the file to unmount +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount( const char* name ) const +void H5Location::unmount(const char* name) const { - // Call C routine H5Fmount to do the mouting - herr_t ret_value = H5Funmount(getId(), name ); + // Call C routine H5Fmount to do the mouting + herr_t ret_value = H5Funmount(getId(), name); - // Raise exception if H5Funmount returns negative value - if( ret_value < 0 ) - throwException("unmount", "H5Funmount failed"); + // Raise exception if H5Funmount returns negative value + if (ret_value < 0) + throwException("unmount", "H5Funmount failed"); } //-------------------------------------------------------------------------- -// Function: H5Location::unmount -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::unmount +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount( const H5std_string& name ) const +void H5Location::unmount(const H5std_string& name) const { - unmount( name.c_str() ); + unmount(name.c_str()); } #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- -// Function: H5Location::iterateElems -///\brief Iterates a user's function over the entries of a group. -///\param name - IN : Name of group to iterate over -///\param idx - IN/OUT: Starting (IN) and ending (OUT) entry indices -///\param op - IN : User's function to operate on each entry -///\param op_data - IN/OUT: Data associated with the operation -///\return The return value of the first operator that returns non-zero, -/// or zero if all members were processed with no operator -/// returning non-zero. -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::iterateElems +///\brief Iterates a user's function over the entries of a group. +///\param name - IN : Name of group to iterate over +///\param idx - IN/OUT: Starting (IN) and ending (OUT) entry indices +///\param op - IN : User's function to operate on each entry +///\param op_data - IN/OUT: Data associated with the operation +///\return The return value of the first operator that returns non-zero, +/// or zero if all members were processed with no operator +/// returning non-zero. +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems( const char* name, int *idx, H5G_iterate_t op , void* op_data ) +int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void* op_data) { - int ret_value = H5Giterate(getId(), name, idx, op, op_data ); - if( ret_value < 0 ) - { - throwException("iterateElems", "H5Giterate failed"); - } - return( ret_value ); + int ret_value = H5Giterate(getId(), name, idx, op, op_data); + if (ret_value < 0) + { + throwException("iterateElems", "H5Giterate failed"); + } + return(ret_value); } //-------------------------------------------------------------------------- -// Function: H5Location::iterateElems -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location::iterateElems +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems( const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data ) +int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data) { - return( iterateElems( name.c_str(), idx, op, op_data )); + return(iterateElems( name.c_str(), idx, op, op_data)); } #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- -// Function: H5Location::getNumObjs -///\brief Returns the number of objects in this group. -///\return Number of objects -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - January, 2003 +// Function: H5Location::getNumObjs +///\brief Returns the number of objects in this group. +///\return Number of objects +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- hsize_t H5Location::getNumObjs() const { - H5G_info_t ginfo; /* Group information */ + H5G_info_t ginfo; // Group information - herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) - throwException("getNumObjs", "H5Gget_info failed"); - return (ginfo.nlinks); + herr_t ret_value = H5Gget_info(getId(), &ginfo); + if(ret_value < 0) + throwException("getNumObjs", "H5Gget_info failed"); + return (ginfo.nlinks); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjnameByIdx -///\brief Returns the name of an object in this group, given the -/// object's index. -///\param idx - IN: Transient index of the object -///\return Object name -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::getObjnameByIdx +///\brief Returns the name of an object in this group, given the +/// object's index. +///\param idx - IN: Transient index of the object +///\return Object name +///\exception H5::FileIException or H5::GroupIException ///\par Description -/// The value of idx can be any nonnegative number less than the -/// total number of objects in the group, which is returned by -/// the function \c H5Location::getNumObjs. Note that this is a -/// transient index; thus, an object may have a different index -/// each time the group is opened. -// Programmer Binh-Minh Ribler - Mar, 2005 +/// The value of idx can be any nonnegative number less than the +/// total number of objects in the group, which is returned by +/// the function \c H5Location::getNumObjs. Note that this is a +/// transient index; thus, an object may have a different index +/// each time the group is opened. +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- H5std_string H5Location::getObjnameByIdx(hsize_t idx) const { // call H5Lget_name_by_idx with name as NULL to get its length ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); if(name_len < 0) - throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); // now, allocate C buffer to get the name char* name_C = new char[name_len+1]; @@ -1328,8 +1327,8 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const if (name_len < 0) { - delete []name_C; - throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + delete []name_C; + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string @@ -1339,74 +1338,74 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const } //-------------------------------------------------------------------------- -// Function: H5Location::getObjnameByIdx -///\brief Retrieves the name of an object in this group, given the -/// object's index. -///\param idx - IN: Transient index of the object -///\param name - IN/OUT: Retrieved name of the object -///\param size - IN: Length to retrieve -///\return Actual size of the object name or 0, if object has no name -///\exception H5::FileIException or H5::GroupIException +// Function: H5Location::getObjnameByIdx +///\brief Retrieves the name of an object in this group, given the +/// object's index. +///\param idx - IN: Transient index of the object +///\param name - IN/OUT: Retrieved name of the object +///\param size - IN: Length to retrieve +///\return Actual size of the object name or 0, if object has no name +///\exception H5::FileIException or H5::GroupIException ///\par Description -/// The value of idx can be any nonnegative number less than the -/// total number of objects in the group, which is returned by -/// the function \c H5Location::getNumObjs. Note that this is a -/// transient index; thus, an object may have a different index -/// each time the group is opened. -// Programmer Binh-Minh Ribler - January, 2003 +/// The value of idx can be any nonnegative number less than the +/// total number of objects in the group, which is returned by +/// the function \c H5Location::getNumObjs. Note that this is a +/// transient index; thus, an object may have a different index +/// each time the group is opened. +// Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const { - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); - if(name_len < 0) - throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); + if(name_len < 0) + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); - return (name_len); + return (name_len); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjnameByIdx -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - January, 2003 +// Function: H5Location::getObjnameByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for object name - HDmemset(name_C, 0, size+1); // clear buffer + char* name_C = new char[size+1]; // temporary C-string for object name + HDmemset(name_C, 0, size+1); // clear buffer - // call overloaded function to get the name - ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); - if(name_len < 0) - { + // call overloaded function to get the name + ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); + if(name_len < 0) + { delete []name_C; - throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); - } - - // clean up and return the string - name = H5std_string(name_C); - delete []name_C; - return (name_len); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::childObjType -///\brief Returns the type of an object in this file/group, given the -/// object's name. -///\param objname - IN: Name of the object -///\return Object type, which can have the following values for group, -/// dataset, and named datatype -/// \li \c H5O_TYPE_GROUP -/// \li \c H5O_TYPE_DATASET -/// \li \c H5O_TYPE_NAMED_DATATYPE -/// Refer to the C API documentation for more details: -/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo -///\exception H5::FileIException or H5::GroupIException -/// Exception will be thrown when: -/// - an error returned by the C API -/// - object type is not one of the valid values above -// Programmer Binh-Minh Ribler - April, 2014 + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + } + + // clean up and return the string + name = H5std_string(name_C); + delete []name_C; + return (name_len); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::childObjType +///\brief Returns the type of an object in this file/group, given the +/// object's name. +///\param objname - IN: Name of the object +///\return Object type, which can have the following values for group, +/// dataset, and named datatype +/// \li \c H5O_TYPE_GROUP +/// \li \c H5O_TYPE_DATASET +/// \li \c H5O_TYPE_NAMED_DATATYPE +/// Refer to the C API documentation for more details: +/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo +///\exception H5::FileIException or H5::GroupIException +/// Exception will be thrown when: +/// - an error returned by the C API +/// - object type is not one of the valid values above +// Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- H5O_type_t H5Location::childObjType(const char* objname) const { @@ -1418,33 +1417,33 @@ H5O_type_t H5Location::childObjType(const char* objname) const // Throw exception if C API returns failure if (ret_value < 0) - throwException("childObjType", "H5Oget_info_by_name failed"); + throwException("childObjType", "H5Oget_info_by_name failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); - } + switch (objinfo.type) + { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); + } return(objtype); } //-------------------------------------------------------------------------- -// Function: H5Location::childObjType -///\brief This is an overloaded member function, provided for convenience. -/// It takes an \a H5std_string for the object's name. -///\brief Returns the type of an object in this group, given the -/// object's name. -///\param objname - IN: Name of the object (H5std_string&) -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - April, 2014 +// Function: H5Location::childObjType +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \a H5std_string for the object's name. +///\brief Returns the type of an object in this group, given the +/// object's name. +///\param objname - IN: Name of the object (H5std_string&) +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- H5O_type_t H5Location::childObjType(const H5std_string& objname) const { @@ -1454,33 +1453,33 @@ H5O_type_t H5Location::childObjType(const H5std_string& objname) const } //-------------------------------------------------------------------------- -// Function: H5Location::childObjType -///\brief Returns the type of an object in this file/group, given the -/// object's index and its type and order. -///\param index - IN: Position of the object -///\param index_type - IN: Type of the index, default to H5_INDEX_NAME -///\param order - IN: Traversing order, default to H5_ITER_INC -///\param objname - IN: Name of the object, default to "." -///\return Object type, which can have the following values for group, -/// dataset, and named datatype -/// \li \c H5O_TYPE_GROUP -/// \li \c H5O_TYPE_DATASET -/// \li \c H5O_TYPE_NAMED_DATATYPE -/// Refer to the C API documentation for more details: -/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo -///\exception H5::FileIException or H5::GroupIException -/// Exception will be thrown when: -/// - an error returned by the C API -/// - object type is not one of the valid values above +// Function: H5Location::childObjType +///\brief Returns the type of an object in this file/group, given the +/// object's index and its type and order. +///\param index - IN: Position of the object +///\param index_type - IN: Type of the index, default to H5_INDEX_NAME +///\param order - IN: Traversing order, default to H5_ITER_INC +///\param objname - IN: Name of the object, default to "." +///\return Object type, which can have the following values for group, +/// dataset, and named datatype +/// \li \c H5O_TYPE_GROUP +/// \li \c H5O_TYPE_DATASET +/// \li \c H5O_TYPE_NAMED_DATATYPE +/// Refer to the C API documentation for more details: +/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo +///\exception H5::FileIException or H5::GroupIException +/// Exception will be thrown when: +/// - an error returned by the C API +/// - object type is not one of the valid values above // Developer's Notes: -// - this overload uses H5Oget_info_by_idx instead of H5Oget_info_by_name -// like the previous childObjType() -// - index is the required argument so, first -// - objname is last because it's more likely the location is already -// fully specified -// - Leave property list out for now because C API is not using it, it -// can be added later when needed. -// Programmer Binh-Minh Ribler - April, 2014 +// - this overload uses H5Oget_info_by_idx instead of H5Oget_info_by_name +// like the previous childObjType() +// - index is the required argument so, first +// - objname is last because it's more likely the location is already +// fully specified +// - Leave property list out for now because C API is not using it, it +// can be added later when needed. +// Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, const char* objname) const { @@ -1493,37 +1492,37 @@ H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_ite // Throw exception if C API returns failure if (ret_value < 0) - throwException("childObjType", "H5Oget_info_by_idx failed"); + throwException("childObjType", "H5Oget_info_by_idx failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); - } + switch (objinfo.type) + { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); + } return(objtype); } //-------------------------------------------------------------------------- -// Function: H5Location::childObjVersion -///\brief Returns the object header version of an object in this file/group, -/// given the object's name. -///\param objname - IN: Name of the object -///\return Object version, which can have the following values: -/// \li \c H5O_VERSION_1 -/// \li \c H5O_VERSION_2 -///\exception H5::FileIException or H5::GroupIException -/// Exception will be thrown when: -/// - an error returned by the C API -/// - version number is not one of the valid values above -// Programmer Binh-Minh Ribler - April, 2014 +// Function: H5Location::childObjVersion +///\brief Returns the object header version of an object in this file/group, +/// given the object's name. +///\param objname - IN: Name of the object +///\return Object version, which can have the following values: +/// \li \c H5O_VERSION_1 +/// \li \c H5O_VERSION_2 +///\exception H5::FileIException or H5::GroupIException +/// Exception will be thrown when: +/// - an error returned by the C API +/// - version number is not one of the valid values above +// Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- unsigned H5Location::childObjVersion(const char* objname) const { @@ -1535,26 +1534,26 @@ unsigned H5Location::childObjVersion(const char* objname) const // Throw exception if C API returns failure if (ret_value < 0) - throwException("childObjVersion", "H5Oget_info_by_name failed"); + throwException("childObjVersion", "H5Oget_info_by_name failed"); // Return a valid version or throw an exception for invalid value else { - version = objinfo.hdr.version; - if (version != H5O_VERSION_1 && version != H5O_VERSION_2) - throwException("childObjVersion", "Invalid version for object"); + version = objinfo.hdr.version; + if (version != H5O_VERSION_1 && version != H5O_VERSION_2) + throwException("childObjVersion", "Invalid version for object"); } return(version); } //-------------------------------------------------------------------------- -// Function: H5Location::childObjVersion -///\brief This is an overloaded member function, provided for convenience. -/// It takes an \a H5std_string for the object's name. -///\brief Returns the type of an object in this group, given the -/// object's name. -///\param objname - IN: Name of the object (H5std_string&) -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - April, 2014 +// Function: H5Location::childObjVersion +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \a H5std_string for the object's name. +///\brief Returns the type of an object in this group, given the +/// object's name. +///\param objname - IN: Name of the object (H5std_string&) +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- unsigned H5Location::childObjVersion(const H5std_string& objname) const { @@ -1566,35 +1565,35 @@ unsigned H5Location::childObjVersion(const H5std_string& objname) const #ifndef H5_NO_DEPRECATED_SYMBOLS #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Location::getObjTypeByIdx -///\brief Returns the type of an object in this group, given the -/// object's index. -///\param idx - IN: Transient index of the object -///\return Object type -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - January, 2003 +// Function: H5Location::getObjTypeByIdx +///\brief Returns the type of an object in this group, given the +/// object's index. +///\param idx - IN: Transient index of the object +///\return Object type +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const { H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); if (obj_type == H5G_UNKNOWN) - throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); return (obj_type); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjTypeByIdx -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function because it also provides -/// the returned object type in text (char*) -///\param idx - IN: Transient index of the object -///\param type_name - OUT: Object type in text -///\return Object type -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - May, 2010 +// Function: H5Location::getObjTypeByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function because it also provides +/// the returned object type in text (char*) +///\param idx - IN: Transient index of the object +///\param type_name - OUT: Object type in text +///\return Object type +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - May, 2010 // Modification -// Modified to use the other function. -BMR, 2016/03/07 +// Modified to use the other function. -BMR, 2016/03/07 //-------------------------------------------------------------------------- H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const { @@ -1602,32 +1601,32 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const return(getObjTypeByIdx(idx, stype_name)); } //-------------------------------------------------------------------------- -// Function: H5Location::getObjTypeByIdx -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function because it also provides -/// the returned object type in text (H5std_string&) -///\param idx - IN: Transient index of the object -///\param type_name - OUT: Object type in text -///\return Object type -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - January, 2003 +// Function: H5Location::getObjTypeByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function because it also provides +/// the returned object type in text (H5std_string&) +///\param idx - IN: Transient index of the object +///\param type_name - OUT: Object type in text +///\return Object type +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const { H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); switch (obj_type) { - case H5G_LINK: type_name = H5std_string("symbolic link"); break; - case H5G_GROUP: type_name = H5std_string("group"); break; - case H5G_DATASET: type_name = H5std_string("dataset"); break; - case H5G_TYPE: type_name = H5std_string("datatype"); break; - case H5G_UNKNOWN: - case H5G_UDLINK: - case H5G_RESERVED_5: - case H5G_RESERVED_6: - case H5G_RESERVED_7: - default: - throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + case H5G_LINK: type_name = H5std_string("symbolic link"); break; + case H5G_GROUP: type_name = H5std_string("group"); break; + case H5G_DATASET: type_name = H5std_string("dataset"); break; + case H5G_TYPE: type_name = H5std_string("datatype"); break; + case H5G_UNKNOWN: + case H5G_UDLINK: + case H5G_RESERVED_5: + case H5G_RESERVED_6: + case H5G_RESERVED_7: + default: + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); } return (obj_type); } @@ -1645,34 +1644,34 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) cons //-------------------------------------------------------------------------- void H5Location::throwException(const H5std_string& func_name, const H5std_string& msg) const { - throwException(func_name, msg); + throwException(func_name, msg); } //-------------------------------------------------------------------------- -// Function: f_DataSet_setId - friend +// Function: f_DataSet_setId - friend // Modification: -// Moved to H5CommonFG.cpp after the rearrangement of classes -// -BMR, Dec 2016 +// Moved to H5CommonFG.cpp after the rearrangement of classes +// -BMR, Dec 2016 //-------------------------------------------------------------------------- // end of From H5CommonFG.cpp //-------------------------------------------------------------------------- -// Function: f_Attribute_setId - friend +// Function: f_Attribute_setId - friend // Modification: -// Moved to H5Object.cpp after the rearrangement of classes -// -BMR, Dec 2016 +// Moved to H5Object.cpp after the rearrangement of classes +// -BMR, Dec 2016 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -// Function: f_DataSpace_setId - friend -// Purpose: This function is friend to class H5::DataSpace so that it can -// can set DataSpace::id in order to work around a problem -// described in the JIRA issue HDFFV-7947. -// Applications shouldn't need to use it. -// param dspace - IN/OUT: DataSpace object to be changed -// param new_id - IN: New id to set -// Programmer Binh-Minh Ribler - 2015 +// Function: f_DataSpace_setId - friend +// Purpose This function is friend to class H5::DataSpace so that it can +// can set DataSpace::id in order to work around a problem +// described in the JIRA issue HDFFV-7947. +// Applications shouldn't need to use it. +// param dspace - IN/OUT: DataSpace object to be changed +// param new_id - IN: New id to set +// Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) { @@ -1680,9 +1679,9 @@ void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) } //-------------------------------------------------------------------------- -// Function: H5Location destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Location destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Location::~H5Location() {} diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 6a449dc..337a2b3 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -17,7 +17,7 @@ #ifndef __H5Location_H #define __H5Location_H -#include "H5Classes.h" // constains forward class declarations +#include "H5Classes.h" // constains forward class declarations namespace H5 { @@ -37,188 +37,188 @@ class H5_DLLCPP LinkAccPropList; class H5_DLLCPP VarLenType; class H5_DLLCPP H5Location : public IdComponent { public: - // Checks if a link of a given name exists in a location - bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Checks if a link of a given name exists in a location + bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - // Flushes all buffers associated with this location to disk. - void flush( H5F_scope_t scope ) const; + // Flushes all buffers associated with this location to disk. + void flush(H5F_scope_t scope) const; - // Gets the name of the file, specified by this location. - H5std_string getFileName() const; + // Gets the name of the file, specified by this location. + H5std_string getFileName() const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; - // Note: getRefObjType deprecates getObjType, but getObjType's name is - // misleading, so getRefObjType is used in the new function instead. - - // Sets the comment for an HDF5 object specified by its name. - void setComment(const char* name, const char* comment) const; - void setComment(const H5std_string& name, const H5std_string& comment) const; - void setComment(const char* comment) const; - void setComment(const H5std_string& comment) const; - - // Retrieves comment for the HDF5 object specified by its name. - ssize_t getComment(const char* name, size_t buf_size, char* comment) const; - H5std_string getComment(const char* name, size_t buf_size=0) const; - H5std_string getComment(const H5std_string& name, size_t buf_size=0) const; - - // Removes the comment for the HDF5 object specified by its name. - void removeComment(const char* name) const; - void removeComment(const H5std_string& name) const; - - // Creates a reference to a named object or to a dataset region - // in this object. - void reference(void* ref, const char* name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const H5std_string& name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const char* name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - void reference(void* ref, const H5std_string& name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - - // Open a referenced object whose location is specified by either - // a file, an HDF5 object, or an attribute. - void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - //void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - - // Retrieves a dataspace with the region pointed to selected. - DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Note: getRefObjType deprecates getObjType, but getObjType's name is + // misleading, so getRefObjType is used in the new function instead. + + // Sets the comment for an HDF5 object specified by its name. + void setComment(const char* name, const char* comment) const; + void setComment(const H5std_string& name, const H5std_string& comment) const; + void setComment(const char* comment) const; + void setComment(const H5std_string& comment) const; + + // Retrieves comment for the HDF5 object specified by its name. + ssize_t getComment(const char* name, size_t buf_size, char* comment) const; + H5std_string getComment(const char* name, size_t buf_size=0) const; + H5std_string getComment(const H5std_string& name, size_t buf_size=0) const; + + // Removes the comment for the HDF5 object specified by its name. + void removeComment(const char* name) const; + void removeComment(const H5std_string& name) const; + + // Creates a reference to a named object or to a dataset region + // in this object. + void reference(void* ref, const char* name, + H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void* ref, const H5std_string& name, + H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void* ref, const char* name, const DataSpace& dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + void reference(void* ref, const H5std_string& name, const DataSpace& dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Open a referenced object whose location is specified by either + // a file, an HDF5 object, or an attribute. + void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + //void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; // From CommonFG - // Creates a new group at this location which can be a file - // or another group. - Group createGroup(const char* name, size_t size_hint = 0) const; - Group createGroup(const H5std_string& name, size_t size_hint = 0) const; - - // Opens an existing group in a location which can be a file - // or another group. - Group openGroup(const char* name) const; - Group openGroup(const H5std_string& name) const; - - // Creates a new dataset in this group. - DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - - // Opens an existing dataset at this location. - DataSet openDataSet(const char* name) const; - DataSet openDataSet(const H5std_string& name) const; - - // Returns the value of a symbolic link. - H5std_string getLinkval(const char* link_name, size_t size=0) const; - H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; - - // Returns the number of objects in this group. - hsize_t getNumObjs() const; - - // Retrieves the name of an object in this group, given the - // object's index. - H5std_string getObjnameByIdx(hsize_t idx) const; - ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; - ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; - - // Retrieves the type of an object in this file or group, given the - // object's name - H5O_type_t childObjType(const H5std_string& objname) const; - H5O_type_t childObjType(const char* objname) const; - H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const; - - // Returns the object header version of an object in this file or group, - // given the object's name. - unsigned childObjVersion(const char* objname) const; - unsigned childObjVersion(const H5std_string& objname) const; + // Creates a new group at this location which can be a file + // or another group. + Group createGroup(const char* name, size_t size_hint = 0) const; + Group createGroup(const H5std_string& name, size_t size_hint = 0) const; + + // Opens an existing group in a location which can be a file + // or another group. + Group openGroup(const char* name) const; + Group openGroup(const H5std_string& name) const; + + // Creates a new dataset in this group. + DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; + DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; + + // Opens an existing dataset at this location. + DataSet openDataSet(const char* name) const; + DataSet openDataSet(const H5std_string& name) const; + + // Returns the value of a symbolic link. + H5std_string getLinkval(const char* link_name, size_t size=0) const; + H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; + + // Returns the number of objects in this group. + hsize_t getNumObjs() const; + + // Retrieves the name of an object in this group, given the + // object's index. + H5std_string getObjnameByIdx(hsize_t idx) const; + ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; + ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; + + // Retrieves the type of an object in this file or group, given the + // object's name + H5O_type_t childObjType(const H5std_string& objname) const; + H5O_type_t childObjType(const char* objname) const; + H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const; + + // Returns the object header version of an object in this file or group, + // given the object's name. + unsigned childObjVersion(const char* objname) const; + unsigned childObjVersion(const H5std_string& objname) const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Returns the type of an object in this group, given the - // object's index. - H5G_obj_t getObjTypeByIdx(hsize_t idx) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; - - // Returns information about an HDF5 object, given by its name, - // at this location. - void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const char* name, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; - - // Iterates over the elements of this group - not implemented in - // C++ style yet. - int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); - int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data); + // Returns the type of an object in this group, given the + // object's index. + H5G_obj_t getObjTypeByIdx(hsize_t idx) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; + + // Returns information about an HDF5 object, given by its name, + // at this location. + void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; + void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; + void getObjinfo(const char* name, H5G_stat_t& statbuf) const; + void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; + + // Iterates over the elements of this group - not implemented in + // C++ style yet. + int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); + int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Creates a link of the specified type from new_name to current_name; - // both names are interpreted relative to the specified location id. - void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; - void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; + // Creates a link of the specified type from new_name to current_name; + // both names are interpreted relative to the specified location id. + void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; + void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; - // Removes the specified name at this location. - void unlink(const char* name) const; - void unlink(const H5std_string& name) const; + // Removes the specified name at this location. + void unlink(const char* name) const; + void unlink(const H5std_string& name) const; - // Mounts the file 'child' onto this location. - void mount(const char* name, const H5File& child, const PropList& plist) const; - //void mount(const char* name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1 - void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; - //void mount(const H5std_string& name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1 + // Mounts the file 'child' onto this location. + void mount(const char* name, const H5File& child, const PropList& plist) const; + //void mount(const char* name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1 + void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; + //void mount(const H5std_string& name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1 - // Unmounts the file named 'name' from this parent location. - void unmount(const char* name) const; - void unmount(const H5std_string& name) const; + // Unmounts the file named 'name' from this parent location. + void unmount(const char* name) const; + void unmount(const H5std_string& name) const; - // Renames an object at this location. - void move(const char* src, const char* dst) const; - void move(const H5std_string& src, const H5std_string& dst) const; + // Renames an object at this location. + void move(const char* src, const char* dst) const; + void move(const H5std_string& src, const H5std_string& dst) const; // end From CommonFG - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - // Default constructor - H5Location(); + // Default constructor + H5Location(); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates a copy of an existing object giving the location id. - H5Location(const hid_t loc_id); + // Creates a copy of an existing object giving the location id. + H5Location(const hid_t loc_id); - // Creates a reference to an HDF5 object or a dataset region. - void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; + // Creates a reference to an HDF5 object or a dataset region. + void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; - // Dereferences a ref into an HDF5 id. - hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func); + // Dereferences a ref into an HDF5 id. + hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - //virtual void p_setId(const hid_t new_id); + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + //virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - // Noop destructor. - virtual ~H5Location(); + // Noop destructor. + virtual ~H5Location(); }; /* end class H5Location */ diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 48d81f8..b5d0f88 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -15,7 +15,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -46,25 +46,25 @@ namespace H5 { extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) { - H5std_string s_attr_name = H5std_string( attr_name ); + H5std_string s_attr_name = H5std_string(attr_name); UserData4Aiterate* myData = reinterpret_cast (op_data); - myData->op( *myData->location, s_attr_name, myData->opData ); + myData->op(*myData->location, s_attr_name, myData->opData); return 0; } #endif //-------------------------------------------------------------------------- -// Function: H5Object default constructor (protected) -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object default constructor (protected) +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Object::H5Object() : H5Location() {} //-------------------------------------------------------------------------- -// Function: H5Object overloaded constructor (protected) -// Purpose Creates an H5Object object using the id of an existing HDF5 -// object. -// Parameters object_id - IN: Id of an existing HDF5 object -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object overloaded constructor (protected) +// Purpose Creates an H5Object object using the id of an existing HDF5 +// object. +// Parameters object_id - IN: Id of an existing HDF5 object +// Programmer Binh-Minh Ribler - 2000 // *** Deprecation warning *** // This constructor is no longer appropriate because the data member "id" had // been moved to the sub-classes. It will be removed in 1.10 release. If its @@ -75,11 +75,11 @@ H5Object::H5Object() : H5Location() {} //H5Object::H5Object(const hid_t object_id) : H5Location() {} //-------------------------------------------------------------------------- -// Function: H5Object copy constructor -///\brief Copy constructor: makes a copy of the original H5Object -/// instance. -///\param original - IN: H5Object instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object copy constructor +///\brief Copy constructor: makes a copy of the original H5Object +/// instance. +///\param original - IN: H5Object instance to copy +// Programmer Binh-Minh Ribler - 2000 // *** Deprecation warning *** // This constructor is no longer appropriate because the data member "id" had // been moved to the sub-classes. It is removed from 1.8.15 because it is @@ -103,158 +103,157 @@ void f_Attribute_setId(Attribute* attr, hid_t new_id) } //-------------------------------------------------------------------------- -// Function: H5Object::createAttribute -///\brief Creates an attribute for a group, dataset, or named datatype. -///\param name - IN: Name of the attribute -///\param data_type - IN: Datatype for the attribute -///\param data_space - IN: Dataspace for the attribute - only simple -/// dataspaces are allowed at this time -///\param create_plist - IN: Creation property list - default to -/// PropList::DEFAULT -///\return Attribute instance -///\exception H5::AttributeIException +// Function: H5Object::createAttribute +///\brief Creates an attribute for a group, dataset, or named datatype. +///\param name - IN: Name of the attribute +///\param data_type - IN: Datatype for the attribute +///\param data_space - IN: Dataspace for the attribute - only simple +/// dataspaces are allowed at this time +///\param create_plist - IN: Creation property list - default to +/// PropList::DEFAULT +///\return Attribute instance +///\exception H5::AttributeIException ///\par Description -/// The attribute name specified in \a name must be unique. -/// Attempting to create an attribute with the same name as an -/// existing attribute will raise an exception, leaving the -/// pre-existing attribute intact. To overwrite an existing -/// attribute with a new attribute of the same name, first -/// delete the existing one with \c H5Object::removeAttr, then -/// recreate it with this function. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -Attribute H5Object::createAttribute( const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const +/// The attribute name specified in \a name must be unique. +/// Attempting to create an attribute with the same name as an +/// existing attribute will raise an exception, leaving the +/// pre-existing attribute intact. To overwrite an existing +/// attribute with a new attribute of the same name, first +/// delete the existing one with \c H5Object::removeAttr, then +/// recreate it with this function. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +Attribute H5Object::createAttribute(const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const { - hid_t type_id = data_type.getId(); - hid_t space_id = data_space.getId(); - hid_t plist_id = create_plist.getId(); - hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT ); - - // If the attribute id is valid, create and return the Attribute object - if( attr_id > 0 ) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return( attr ); - } - else - throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); + hid_t type_id = data_type.getId(); + hid_t space_id = data_space.getId(); + hid_t plist_id = create_plist.getId(); + hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); + + // If the attribute id is valid, create and return the Attribute object + if (attr_id > 0) + { + Attribute attr; + f_Attribute_setId(&attr, attr_id); + return(attr); + } + else + throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); } //-------------------------------------------------------------------------- -// Function: H5Object::createAttribute -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::createAttribute +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const +Attribute H5Object::createAttribute(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const { - return( createAttribute( name.c_str(), data_type, data_space, create_plist )); + return(createAttribute( name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- -// Function: H5Object::openAttribute -///\brief Opens an attribute given its name. -///\param name - IN: Name of the attribute -///\return Attribute instance -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::openAttribute +///\brief Opens an attribute given its name. +///\param name - IN: Name of the attribute +///\return Attribute instance +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute( const char* name ) const +Attribute H5Object::openAttribute(const char* name) const { - hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); - if( attr_id > 0 ) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return( attr ); - } - else - { - throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); - } + hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); + if (attr_id > 0) + { + Attribute attr; + f_Attribute_setId(&attr, attr_id); + return(attr); + } + else + { + throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Object::openAttribute -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::openAttribute +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute( const H5std_string& name ) const +Attribute H5Object::openAttribute(const H5std_string& name) const { - return( openAttribute( name.c_str()) ); + return(openAttribute( name.c_str())); } //-------------------------------------------------------------------------- -// Function: H5Object::openAttribute -///\brief Opens an attribute given its index. -///\param idx - IN: Index of the attribute, a 0-based, non-negative integer -///\return Attribute instance -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::openAttribute +///\brief Opens an attribute given its index. +///\param idx - IN: Index of the attribute, a 0-based, non-negative integer +///\return Attribute instance +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute( const unsigned int idx ) const +Attribute H5Object::openAttribute(const unsigned int idx) const { - hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, static_cast(idx), H5P_DEFAULT, H5P_DEFAULT); - if( attr_id > 0 ) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return(attr); - } - else - { - throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); - } + hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, + H5_ITER_INC, static_cast(idx), H5P_DEFAULT, H5P_DEFAULT); + if (attr_id > 0) + { + Attribute attr; + f_Attribute_setId(&attr, attr_id); + return(attr); + } + else + { + throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); + } } //-------------------------------------------------------------------------- -// Function: H5Object::iterateAttrs -///\brief Iterates a user's function over all the attributes of an H5 -/// object, which may be a group, dataset or named datatype. -///\param user_op - IN: User's function to operate on each attribute -///\param _idx - IN/OUT: Starting (IN) and ending (OUT) attribute indices -///\param op_data - IN: User's data to pass to user's operator function -///\return Returned value of the last operator if it was non-zero, or -/// zero if all attributes were processed -///\exception H5::AttributeIException +// Function: H5Object::iterateAttrs +///\brief Iterates a user's function over all the attributes of an H5 +/// object, which may be a group, dataset or named datatype. +///\param user_op - IN: User's function to operate on each attribute +///\param _idx - IN/OUT: Starting (IN) and ending (OUT) attribute indices +///\param op_data - IN: User's data to pass to user's operator function +///\return Returned value of the last operator if it was non-zero, or +/// zero if all attributes were processed +///\exception H5::AttributeIException ///\par Description -/// The signature of user_op is -/// void (*)(H5::H5Location&, H5std_string, void*). -/// For information, please refer to the C layer Reference Manual -/// at: +/// The signature of user_op is +/// void (*)(H5::H5Location&, H5std_string, void*). +/// For information, please refer to the C layer Reference Manual +/// at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5A.html#Annot-Iterate -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_data ) +int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) { - // store the user's function and data - UserData4Aiterate* userData = new UserData4Aiterate; - userData->opData = op_data; - userData->op = user_op; - userData->location = this; - - // call the C library routine H5Aiterate2 to iterate the attributes - hsize_t idx = _idx ? static_cast(*_idx) : 0; - int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, reinterpret_cast(userData)); - - // release memory - delete userData; - - if( ret_value >= 0 ) { - /* Pass back update index value to calling code */ - if (_idx) - *_idx = static_cast(idx); - - return( ret_value ); - } - else // raise exception when H5Aiterate returns a negative value - throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed"); + // store the user's function and data + UserData4Aiterate* userData = new UserData4Aiterate; + userData->opData = op_data; + userData->op = user_op; + userData->location = this; + + // call the C library routine H5Aiterate2 to iterate the attributes + hsize_t idx = _idx ? static_cast(*_idx) : 0; + int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, + userAttrOpWrpr, reinterpret_cast(userData)); + + // release memory + delete userData; + + if (ret_value >= 0) { + /* Pass back update index value to calling code */ + if (_idx) + *_idx = static_cast(idx); + return(ret_value); + } + else // raise exception when H5Aiterate returns a negative value + throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed"); } //-------------------------------------------------------------------------- @@ -291,106 +290,106 @@ unsigned H5Object::objVersion() const } //-------------------------------------------------------------------------- -// Function: H5Object::getNumAttrs -///\brief Returns the number of attributes attached to this HDF5 object. -///\return Number of attributes -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::getNumAttrs +///\brief Returns the number of attributes attached to this HDF5 object. +///\return Number of attributes +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- int H5Object::getNumAttrs() const { - H5O_info_t oinfo; /* Object info */ + H5O_info_t oinfo; /* Object info */ - if(H5Oget_info(getId(), &oinfo) < 0) - throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); - else - return(static_cast(oinfo.num_attrs)); + if(H5Oget_info(getId(), &oinfo) < 0) + throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); + else + return(static_cast(oinfo.num_attrs)); } //-------------------------------------------------------------------------- -// Function: H5Object::attrExists -///\brief Checks whether the named attribute exists at this location. -///\param name - IN: Name of the attribute to be queried -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2013 +// Function: H5Object::attrExists +///\brief Checks whether the named attribute exists at this location. +///\param name - IN: Name of the attribute to be queried +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2013 //-------------------------------------------------------------------------- bool H5Object::attrExists(const char* name) const { - // Call C routine H5Aexists to determine whether an attribute exists - // at this location, which could be specified by a file, group, dataset, - // or named datatype. - herr_t ret_value = H5Aexists(getId(), name); - if( ret_value > 0 ) - return true; - else if(ret_value == 0) - return false; - else // Raise exception when H5Aexists returns a negative value - throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); + // Call C routine H5Aexists to determine whether an attribute exists + // at this location, which could be specified by a file, group, dataset, + // or named datatype. + herr_t ret_value = H5Aexists(getId(), name); + if (ret_value > 0) + return true; + else if(ret_value == 0) + return false; + else // Raise exception when H5Aexists returns a negative value + throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); } //-------------------------------------------------------------------------- -// Function: H5Object::attrExists -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::attrExists +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- bool H5Object::attrExists(const H5std_string& name) const { - return(attrExists(name.c_str())); + return(attrExists(name.c_str())); } //-------------------------------------------------------------------------- -// Function: H5Object::removeAttr -///\brief Removes the named attribute from this object. -///\param name - IN: Name of the attribute to be removed -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::removeAttr +///\brief Removes the named attribute from this object. +///\param name - IN: Name of the attribute to be removed +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr( const char* name ) const +void H5Object::removeAttr(const char* name) const { - herr_t ret_value = H5Adelete(getId(), name); - if( ret_value < 0 ) - throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed"); + herr_t ret_value = H5Adelete(getId(), name); + if (ret_value < 0) + throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed"); } //-------------------------------------------------------------------------- -// Function: H5Object::removeAttr -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object::removeAttr +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr( const H5std_string& name ) const +void H5Object::removeAttr(const H5std_string& name) const { - removeAttr( name.c_str() ); + removeAttr(name.c_str()); } //-------------------------------------------------------------------------- -// Function: H5Object::renameAttr -///\brief Renames the named attribute from this object. -///\param oldname - IN: Name of the attribute to be renamed -///\param newname - IN: New name ame of the attribute -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Mar, 2005 +// Function: H5Object::renameAttr +///\brief Renames the named attribute from this object. +///\param oldname - IN: Name of the attribute to be renamed +///\param newname - IN: New name ame of the attribute +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- void H5Object::renameAttr(const char* oldname, const char* newname) const { - herr_t ret_value = H5Arename(getId(), oldname, newname); - if (ret_value < 0) - throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed"); + herr_t ret_value = H5Arename(getId(), oldname, newname); + if (ret_value < 0) + throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed"); } //-------------------------------------------------------------------------- -// Function: H5Object::renameAttr -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for the names. -// Programmer Binh-Minh Ribler - Mar, 2005 +// Function: H5Object::renameAttr +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for the names. +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newname) const { - renameAttr (oldname.c_str(), newname.c_str()); + renameAttr (oldname.c_str(), newname.c_str()); } //-------------------------------------------------------------------------- // Function: getObjName @@ -405,11 +404,11 @@ ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const // If H5Iget_name returns a negative value, raise an exception if (name_size < 0) - { + { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } else if (name_size == 0) - { + { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Return length of the name @@ -433,16 +432,16 @@ H5std_string H5Object::getObjName() const // If H5Iget_name failed, throw exception if (name_size < 0) - { + { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } else if (name_size == 0) - { + { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Object's name exists, retrieve it else if (name_size > 0) - { + { char* name_C = new char[name_size+1]; // temporary C-string HDmemset(name_C, 0, name_size+1); // clear buffer @@ -478,13 +477,13 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const // If no length is provided, get the entire object name if (len == 0) - { + { obj_name = getObjName(); name_size = obj_name.length(); } // If length is provided, get that number of characters in name else - { + { char* name_C = new char[len+1]; // temporary C-string HDmemset(name_C, 0, len+1); // clear buffer @@ -505,9 +504,9 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Object destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: H5Object destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Object::~H5Object() {} #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index 5ea8937..866d739 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -24,20 +24,20 @@ namespace H5 { and Group. Modification: - Sept 18, 2012: Added class H5Location in between IdComponent and - H5Object. An H5File now inherits from H5Location. All HDF5 - wrappers in H5Object are moved up to H5Location. H5Object - is left mostly empty for future wrappers that are only for - group, dataset, and named datatype. Note that the reason for - adding H5Location instead of simply moving H5File to be under - H5Object is H5File is not an HDF5 object, and renaming H5Object - to H5Location will risk breaking user applications. - -BMR - Apr 2, 2014: Added wrapper getObjName for H5Iget_name - Sep 21, 2016: Rearranging classes (HDFFV-9920) moved H5A wrappers back - into H5Object. This way, C functions that takes attribute id - can be in H5Location and those that cannot take attribute id - can be in H5Object. + Sept 18, 2012: Added class H5Location in between IdComponent and + H5Object. An H5File now inherits from H5Location. All HDF5 + wrappers in H5Object are moved up to H5Location. H5Object + is left mostly empty for future wrappers that are only for + group, dataset, and named datatype. Note that the reason for + adding H5Location instead of simply moving H5File to be under + H5Object is H5File is not an HDF5 object, and renaming H5Object + to H5Location will risk breaking user applications. + -BMR + Apr 2, 2014: Added wrapper getObjName for H5Iget_name + Sep 21, 2016: Rearranging classes (HDFFV-9920) moved H5A wrappers back + into H5Object. This way, C functions that takes attribute id + can be in H5Location and those that cannot take attribute id + can be in H5Object. Inheritance: H5Location -> IdComponent */ @@ -46,88 +46,88 @@ class H5_DLLCPP H5Object; class H5_DLLCPP Attribute; // Define the operator function pointer for H5Aiterate(). -typedef void (*attr_operator_t)( H5Object& loc/*in*/, +typedef void (*attr_operator_t)(H5Object& loc/*in*/, const H5std_string attr_name/*in*/, void *operator_data/*in,out*/); // User data for attribute iteration class UserData4Aiterate { public: - attr_operator_t op; - void* opData; - H5Object* location; + attr_operator_t op; + void* opData; + H5Object* location; }; class H5_DLLCPP H5Object : public H5Location { public: - // Creates an attribute for the specified object - // PropList is currently not used, so always be default. - Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const; - Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const; + // Creates an attribute for the specified object + // PropList is currently not used, so always be default. + Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; - // Given its name, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute( const char* name ) const; - Attribute openAttribute( const H5std_string& name ) const; + // Given its name, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const char* name) const; + Attribute openAttribute(const H5std_string& name) const; - // Given its index, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute( const unsigned int idx ) const; + // Given its index, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const unsigned int idx) const; - // Iterate user's function over the attributes of this object. - int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL); + // Iterate user's function over the attributes of this object. + int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL); - // Returns the object header version of an object - unsigned objVersion() const; + // Returns the object header version of an object + unsigned objVersion() const; - // Determines the number of attributes belong to this object. - int getNumAttrs() const; + // Determines the number of attributes belong to this object. + int getNumAttrs() const; - // Checks whether the named attribute exists for this object. - bool attrExists(const char* name) const; - bool attrExists(const H5std_string& name) const; + // Checks whether the named attribute exists for this object. + bool attrExists(const char* name) const; + bool attrExists(const H5std_string& name) const; - // Renames the named attribute to a new name. - void renameAttr(const char* oldname, const char* newname) const; - void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; + // Renames the named attribute to a new name. + void renameAttr(const char* oldname, const char* newname) const; + void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; - // Removes the named attribute from this object. - void removeAttr(const char* name) const; - void removeAttr(const H5std_string& name) const; + // Removes the named attribute from this object. + void removeAttr(const char* name) const; + void removeAttr(const H5std_string& name) const; - // Returns an identifier. - virtual hid_t getId() const = 0; + // Returns an identifier. + virtual hid_t getId() const = 0; #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Gets the name of this HDF5 object, i.e., Group, DataSet, or - // DataType. These should have const but are retiring anyway. - ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; - ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; - H5std_string getObjName() const; + // Gets the name of this HDF5 object, i.e., Group, DataSet, or + // DataType. These should have const but are retiring anyway. + ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; + ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; + H5std_string getObjName() const; protected: - // Default constructor - H5Object(); + // Default constructor + H5Object(); - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates a copy of an existing object giving the object id - H5Object( const hid_t object_id ); + // Creates a copy of an existing object giving the object id + H5Object(const hid_t object_id); - // Copy constructor: makes copy of an H5Object object. - // H5Object(const H5Object& original); + // Copy constructor: makes copy of an H5Object object. + // H5Object(const H5Object& original); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // Noop destructor. - virtual ~H5Object(); + // Noop destructor. + virtual ~H5Object(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 397a96f..6fdd9dc 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -75,49 +75,49 @@ void ObjCreatPropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose: Constant for default property +// Purpose: Constant for default property //-------------------------------------------------------------------------- const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Default Constructor -///\brief Creates a file access property list -// Programmer: Binh-Minh Ribler - 2000 +// Function: Default Constructor +///\brief Creates a file access property list +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} //-------------------------------------------------------------------------- -// Function: ObjCreatPropList copy constructor -///\brief Copy Constructor: makes a copy of the original -///\param original - IN: ObjCreatPropList instance to copy -// Programmer: Binh-Minh Ribler - 2000 +// Function: ObjCreatPropList copy constructor +///\brief Copy Constructor: makes a copy of the original +///\param original - IN: ObjCreatPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {} //-------------------------------------------------------------------------- -// Function: ObjCreatPropList overloaded constructor -///\brief Creates a file access property list using the id of an -/// existing one. -// Programmer: Binh-Minh Ribler - 2000 +// Function: ObjCreatPropList overloaded constructor +///\brief Creates a file access property list using the id of an +/// existing one. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} //-------------------------------------------------------------------------- -// Function: ObjCreatPropList::setAttrPhaseChange -///\brief Sets attribute storage phase change thresholds. -///\param max_compact - IN: Maximum number of attributes to be stored in -/// compact storage. Default to 8 -///\param min_dense - IN: Minimum number of attributes to be stored in -/// dense storage. Default to 6 -///\exception H5::PropListIException +// Function: ObjCreatPropList::setAttrPhaseChange +///\brief Sets attribute storage phase change thresholds. +///\param max_compact - IN: Maximum number of attributes to be stored in +/// compact storage. Default to 8 +///\param min_dense - IN: Minimum number of attributes to be stored in +/// dense storage. Default to 6 +///\exception H5::PropListIException ///\par Description -/// If \c max_compact is set to 0, dense storage will be used. -/// For more detail about on attribute storage, please refer to the -/// C layer Reference Manual at: +/// If \c max_compact is set to 0, dense storage will be used. +/// For more detail about on attribute storage, please refer to the +/// C layer Reference Manual at: /// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrPhaseChange -// Programmer: Binh-Minh Ribler - September 2015 +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const { @@ -129,19 +129,19 @@ void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_den } //-------------------------------------------------------------------------- -// Function: ObjCreatPropList::getAttrPhaseChange -///\brief Gets attribute storage phase change thresholds. -///\param max_compact - OUT: Maximum number of attributes to be stored in -/// compact storage. -///\param min_dense - OUT: Minimum number of attributes to be stored in -/// dense storage. -///\exception H5::PropListIException +// Function: ObjCreatPropList::getAttrPhaseChange +///\brief Gets attribute storage phase change thresholds. +///\param max_compact - OUT: Maximum number of attributes to be stored in +/// compact storage. +///\param min_dense - OUT: Minimum number of attributes to be stored in +/// dense storage. +///\exception H5::PropListIException ///\par Description -/// If \c max_compact is set to 0, dense storage will be used. -/// For more detail about on attribute storage, please refer to the -/// C layer Reference Manual at: +/// If \c max_compact is set to 0, dense storage will be used. +/// For more detail about on attribute storage, please refer to the +/// C layer Reference Manual at: /// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrPhaseChange -// Programmer: Binh-Minh Ribler - September 2015 +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const { @@ -154,23 +154,23 @@ void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_d } //-------------------------------------------------------------------------- -// Function: ObjCreatPropList::setAttrCrtOrder -///\brief Sets tracking and indexing of attribute creation order. -///\param crt_order_flags - IN: Flags specifying whether to track and -/// index attribute creation order. Default: No flag set -///\exception H5::PropListIException +// Function: ObjCreatPropList::setAttrCrtOrder +///\brief Sets tracking and indexing of attribute creation order. +///\param crt_order_flags - IN: Flags specifying whether to track and +/// index attribute creation order. Default: No flag set +///\exception H5::PropListIException ///\par Description -/// Valid flags are: -/// \li \c H5P_CRT_ORDER_TRACKED - Attribute creation order is tracked -/// \li \c H5P_CRT_ORDER_INDEXED - Attribute creation order is -/// indexed (requires H5P_CRT_ORDER_TRACKED). -/// When no flag is set, attribute creation order is neither -/// tracked not indexed. Note that HDF5 currently provides no -/// mechanism to turn on attribute creation order tracking at object -/// creation time and to build the index later. -/// The C layer Reference Manual at can be found at: +/// Valid flags are: +/// \li \c H5P_CRT_ORDER_TRACKED - Attribute creation order is tracked +/// \li \c H5P_CRT_ORDER_INDEXED - Attribute creation order is +/// indexed (requires H5P_CRT_ORDER_TRACKED). +/// When no flag is set, attribute creation order is neither +/// tracked not indexed. Note that HDF5 currently provides no +/// mechanism to turn on attribute creation order tracking at object +/// creation time and to build the index later. +/// The C layer Reference Manual at can be found at: /// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrCreationOrder -// Programmer: Binh-Minh Ribler - September 2015 +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const { @@ -182,18 +182,18 @@ void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const } //-------------------------------------------------------------------------- -// Function: ObjCreatPropList::getAttrCrtOrder -///\brief Gets tracking and indexing settings for attribute -/// creation order. -///\param crt_order_flags - OUT: Flags specifying whether to track and -/// index attribute creation order -///\exception H5::PropListIException +// Function: ObjCreatPropList::getAttrCrtOrder +///\brief Gets tracking and indexing settings for attribute +/// creation order. +///\param crt_order_flags - OUT: Flags specifying whether to track and +/// index attribute creation order +///\exception H5::PropListIException ///\par Description -/// When no flag is set, i.e. crt_order_flags = 0, attribute -/// creation order is neither tracked not indexed. -/// The C layer Reference Manual at can be found at: +/// When no flag is set, i.e. crt_order_flags = 0, attribute +/// creation order is neither tracked not indexed. +/// The C layer Reference Manual at can be found at: /// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrCreationOrder -// Programmer: Binh-Minh Ribler - September 2015 +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- unsigned ObjCreatPropList::getAttrCrtOrder() const { @@ -208,9 +208,9 @@ unsigned ObjCreatPropList::getAttrCrtOrder() const } //-------------------------------------------------------------------------- -// Function: ObjCreatPropList destructor -///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Function: ObjCreatPropList destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- ObjCreatPropList::~ObjCreatPropList() {} diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index bfba1c4..4858e07 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -27,37 +27,37 @@ namespace H5 { */ class H5_DLLCPP ObjCreatPropList : public PropList { public: - ///\brief Default object creation property list. - static const ObjCreatPropList& DEFAULT; + ///\brief Default object creation property list. + static const ObjCreatPropList& DEFAULT; - // Creates a object creation property list. - ObjCreatPropList(); + // Creates a object creation property list. + ObjCreatPropList(); - // Sets attribute storage phase change thresholds. - void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; + // Sets attribute storage phase change thresholds. + void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; - // Gets attribute storage phase change thresholds. - void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; + // Gets attribute storage phase change thresholds. + void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; - // Sets tracking and indexing of attribute creation order. - void setAttrCrtOrder(unsigned crt_order_flags) const; + // Sets tracking and indexing of attribute creation order. + void setAttrCrtOrder(unsigned crt_order_flags) const; - // Gets tracking and indexing settings for attribute creation order. - unsigned getAttrCrtOrder() const; + // Gets tracking and indexing settings for attribute creation order. + unsigned getAttrCrtOrder() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ObjCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("ObjCreatPropList"); } - // Copy constructor: creates a copy of a ObjCreatPropList object. - ObjCreatPropList( const ObjCreatPropList& original ); + // Copy constructor: creates a copy of a ObjCreatPropList object. + ObjCreatPropList(const ObjCreatPropList& original); - // Creates a copy of an existing object creation property list - // using the property list id. - ObjCreatPropList (const hid_t plist_id); + // Creates a copy of an existing object creation property list + // using the property list id. + ObjCreatPropList (const hid_t plist_id); - // Noop destructor - virtual ~ObjCreatPropList(); + // Noop destructor + virtual ~ObjCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index e2eed18..03327c8 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -32,14 +32,14 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: PredType overloaded constructor -///\brief Creates a PredType object using the id of an existing -/// predefined datatype. -///\param predtype_id - IN: Id of a predefined datatype +// Function: PredType overloaded constructor +///\brief Creates a PredType object using the id of an existing +/// predefined datatype. +///\param predtype_id - IN: Id of a predefined datatype // Description -// This constructor creates a PredType object by copying -// the provided HDF5 predefined datatype. -// Programmer Binh-Minh Ribler - 2000 +// This constructor creates a PredType object by copying +// the provided HDF5 predefined datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) { @@ -47,69 +47,69 @@ PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) } //-------------------------------------------------------------------------- -// Function: PredType default constructor -///\brief Default constructor: Creates a stub predefined datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: PredType default constructor +///\brief Default constructor: Creates a stub predefined datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PredType::PredType() : AtomType() {} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: PredType copy constructor -///\brief Copy constructor: makes a copy of the original PredType object. -///\param original - IN: PredType instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: PredType copy constructor +///\brief Copy constructor: makes a copy of the original PredType object. +///\param original - IN: PredType instance to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PredType::PredType(const PredType& original) : AtomType(original) {} //-------------------------------------------------------------------------- -// Function: PredType::operator= -///\brief Assignment operator. -///\param rhs - IN: Reference to the predefined datatype -///\return Reference to PredType instance -///\exception H5::DataTypeIException +// Function: PredType::operator= +///\brief Assignment operator. +///\param rhs - IN: Reference to the predefined datatype +///\return Reference to PredType instance +///\exception H5::DataTypeIException // Description -// Makes a copy of the type on the right hand side and stores -// the new id in the left hand side object. -// Programmer Binh-Minh Ribler - 2000 +// Makes a copy of the type on the right hand side and stores +// the new id in the left hand side object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType& PredType::operator=( const PredType& rhs ) +PredType& PredType::operator=(const PredType& rhs) { if (this != &rhs) - copy(rhs); + copy(rhs); return(*this); } #ifndef DOXYGEN_SHOULD_SKIP_THIS // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. -void PredType::commit(H5Location& loc, const char* name ) +void PredType::commit(H5Location& loc, const char* name) { - throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!" ); + throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); } -void PredType::commit(H5Location& loc, const H5std_string& name ) +void PredType::commit(H5Location& loc, const H5std_string& name) { - commit( loc, name.c_str()); + commit(loc, name.c_str()); } bool PredType::committed() { - throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype." ); + throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype."); } #endif // DOXYGEN_SHOULD_SKIP_THIS // Default destructor //-------------------------------------------------------------------------- -// Function: PredType destructor -///\brief Noop destructor. -// Programmer Binh-Minh Ribler - 2000 +// Function: PredType destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PredType::~PredType() {} /***************************************************************************** - The following section is regarding the global constants PredType, - DataSpace, and PropList. + The following section is regarding the global constants PredType, + DataSpace, and PropList. *****************************************************************************/ @@ -292,18 +292,18 @@ PredType* PredType::NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ //-------------------------------------------------------------------------- -// Function: PredType::getPredTypes -// Purpose: Returns the dummy PredType constant object pointer -// Return: PredType object pointer +// Function: PredType::getPredTypes +// Purpose Returns the dummy PredType constant object pointer +// Return: PredType object pointer // Description -// If the dummy constant PREDTYPE_CONST_ is not allocated yet, -// call makePredTypes() to allocate all of the PredType constants. -// Otherwise, just simply return the object pointer PREDTYPE_CONST_. +// If the dummy constant PREDTYPE_CONST_ is not allocated yet, +// call makePredTypes() to allocate all of the PredType constants. +// Otherwise, just simply return the object pointer PREDTYPE_CONST_. // -// Note that, there is a similar function to getPredTypes() in -// other classes, that have global constants, is called getConstant(). +// Note that, there is a similar function to getPredTypes() in +// other classes, that have global constants, is called getConstant(). // -// Programmer Binh-Minh Ribler - September 2015 +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- PredType* PredType::getPredTypes() { @@ -318,16 +318,16 @@ PredType* PredType::getPredTypes() // If the dummy constant pointer is not allocated, allocate all PredType // constant pointers. Otherwise, throw because it shouldn't be. if (PREDTYPE_CONST_ == 0) - makePredTypes(); + makePredTypes(); else - throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); + throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); return PREDTYPE_CONST_; } //-------------------------------------------------------------------------- -// Function: PredType::makePredTypes -// Purpose: Allocate all PredType constants. -// Programmer Binh-Minh Ribler - September 2015 +// Function: PredType::makePredTypes +// Purpose Allocate all PredType constants. +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- void PredType::makePredTypes() { @@ -515,9 +515,9 @@ void PredType::makePredTypes() //-------------------------------------------------------------------------- -// Function: PredType::deleteConstants -// Purpose: Deletes all PredType constant pointers. -// Programmer Binh-Minh Ribler - September 2015 +// Function: PredType::deleteConstants +// Purpose Deletes all PredType constant pointers. +// Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- void PredType::deleteConstants() { @@ -891,206 +891,205 @@ const PredType& PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; } // end namespace /*************************************************************************** - Design Note - =========== + Design Note + =========== September 2015: - The C++ library has several types of global constants from different - classes, such as PropList, PredType, DataSpace, etc... Previously, - these global constants were declared statically and the C++ library used - a constant, called PredType::AtExit, to detect when all the global - contants are destroyed then close the C library (H5close). This method - relied on the order of the constants being created and destroyed and - that PredType constants be the last to be destroyed. In September - 2015, it was recognized that the order in which the global constants were - created and destroyed was actually undefined, thus can be different - between different compilers. This resulted in failure when compilers - destroy PredType constants before others because when PredType::AtExit - was destroyed, the C library was closed, so when the constants of other - classes such as PropList or DataSpace were being deleted, the C library - would not be available. - - These are the classes that have global constants: - + PredType - + DataSpace - + PropList (and its subclasses below) - + FileAccPropList - + FileCreatPropList - + DSetMemXferPropList - + DSetCreatPropList - - - The new method includes these main points: - - - The C++ library uses dynamically allocated constants to have the - control in which order the global constants are created/destroyed. - - - The previous static constants are changed to be the references to - the dynamically allocated constants to avoid impact on applications. - - - The first time an IdComponent default constructor is invoked, it - will call the function H5Library::initH5cpp which registers the - terminating functions from each class that has the global constants - so that these functions can destroy those constants at the exit of the - application. IdComponent is a baseclass of any object class that has - an identifier, such as Group, DataSet, DataType,... The classes which - have the global constants are all derived from IdComponent. - - - At the normal termination of the application, each registered function - for each constant type will delete all the allocated constants in - that type class, then a different terminating function, which was also - registered with atexit() by initH5cpp, will call H5close to close the - C library. - - The following list presents the differences between the old and new - methods and the changes implemented for the new method. - - 1. The following items are added to class H5Library: - // Private instance to be created by H5Library only - static H5Library* instance; - - // Returns a singleton H5Library to initialize the global - // constants, invoked in IdComponent default constructor - static H5Library* getInstance(); // public - - // Registers cleanup and terminating functions with atexit(), - // called in IdComponent default constructor - static void initH5cpp(void); // public - - // Calls H5close to terminate the library, registered with - // atexit(), as the last thing to be done. - static void termH5cpp(void); // public - - 2. The following shows the differences between the old and new methods - for allocating the PredType constants. There are more than 100 - constants, but only one is shown here for examples. - - Old Method: - ---------- - // Declaration of the constant - in "H5PredType.h" - static const PredType NATIVE_INT; - - // Definition of the constant - in "H5PredType.cpp" - const PredType PredType::NATIVE_INT(H5T_NATIVE_INT); - - New Method: - ---------- - // Declare pointer for a constant - in "H5PredType.h" - static PredType* NATIVE_INT_; // "H5PredType.h" - - // Change previous constant to reference - in "H5PredType.h" - static const PredType& NATIVE_INT; - - // The assignment of the first static constant, named - // PREDTYPE_CONST, calls makePredTypes() which allocates the - // dynamic memory for every PredType constant. - - // Creates a dynamic PredType object representing a C constant - // - in makePredTypes() - NATIVE_INT_ = new PredType(H5T_NATIVE_INT); - - // Assign the constant reference to the dynamic object - // - in "H5PredType.cpp" - const PredType& PredType::NATIVE_INT = *NATIVE_INT_; - - Functions added to class PredType: - - // Creates the constants - static void makePredTypes(); // private - - // Calls makePredTypes to create the constants and returns - // the dummy constant PREDTYPE_CONST; - static PredType* getPredTypes(); // private - - // Deletes the constants - static void deleteConstants(); // public - - 3. This section shows the differences between the old and new methods - for allocating the DataSpace constant, DataSpace::ALL. + The C++ library has several types of global constants from different + classes, such as PropList, PredType, DataSpace, etc... Previously, + these global constants were declared statically and the C++ library used + a constant, called PredType::AtExit, to detect when all the global + contants are destroyed then close the C library (H5close). This method + relied on the order of the constants being created and destroyed and + that PredType constants be the last to be destroyed. In September + 2015, it was recognized that the order in which the global constants were + created and destroyed was actually undefined, thus can be different + between different compilers. This resulted in failure when compilers + destroy PredType constants before others because when PredType::AtExit + was destroyed, the C library was closed, so when the constants of other + classes such as PropList or DataSpace were being deleted, the C library + would not be available. + + These are the classes that have global constants: + + PredType + + DataSpace + + PropList (and its subclasses below) + + FileAccPropList + + FileCreatPropList + + DSetMemXferPropList + + DSetCreatPropList + + The new method includes these main points: + + - The C++ library uses dynamically allocated constants to have the + control in which order the global constants are created/destroyed. + + - The previous static constants are changed to be the references to + the dynamically allocated constants to avoid impact on applications. + + - The first time an IdComponent default constructor is invoked, it + will call the function H5Library::initH5cpp which registers the + terminating functions from each class that has the global constants + so that these functions can destroy those constants at the exit of the + application. IdComponent is a baseclass of any object class that has + an identifier, such as Group, DataSet, DataType,... The classes which + have the global constants are all derived from IdComponent. + + - At the normal termination of the application, each registered function + for each constant type will delete all the allocated constants in + that type class, then a different terminating function, which was also + registered with atexit() by initH5cpp, will call H5close to close the + C library. + + The following list presents the differences between the old and new + methods and the changes implemented for the new method. + + 1. The following items are added to class H5Library: + // Private instance to be created by H5Library only + static H5Library* instance; + + // Returns a singleton H5Library to initialize the global + // constants, invoked in IdComponent default constructor + static H5Library* getInstance(); // public + + // Registers cleanup and terminating functions with atexit(), + // called in IdComponent default constructor + static void initH5cpp(void); // public + + // Calls H5close to terminate the library, registered with + // atexit(), as the last thing to be done. + static void termH5cpp(void); // public + + 2. The following shows the differences between the old and new methods + for allocating the PredType constants. There are more than 100 + constants, but only one is shown here for examples. + + Old Method: + ---------- + // Declaration of the constant - in "H5PredType.h" + static const PredType NATIVE_INT; + + // Definition of the constant - in "H5PredType.cpp" + const PredType PredType::NATIVE_INT(H5T_NATIVE_INT); + + New Method: + ---------- + // Declare pointer for a constant - in "H5PredType.h" + static PredType* NATIVE_INT_; // "H5PredType.h" + + // Change previous constant to reference - in "H5PredType.h" + static const PredType& NATIVE_INT; + + // The assignment of the first static constant, named + // PREDTYPE_CONST, calls makePredTypes() which allocates the + // dynamic memory for every PredType constant. + + // Creates a dynamic PredType object representing a C constant + // - in makePredTypes() + NATIVE_INT_ = new PredType(H5T_NATIVE_INT); + + // Assign the constant reference to the dynamic object + // - in "H5PredType.cpp" + const PredType& PredType::NATIVE_INT = *NATIVE_INT_; + + Functions added to class PredType: + + // Creates the constants + static void makePredTypes(); // private + + // Calls makePredTypes to create the constants and returns + // the dummy constant PREDTYPE_CONST; + static PredType* getPredTypes(); // private + + // Deletes the constants + static void deleteConstants(); // public + + 3. This section shows the differences between the old and new methods + for allocating the DataSpace constant, DataSpace::ALL. - Old Method: - ---------- - // Declaration of the constant - in "H5DataSpace.h" - static const DataSpace ALL; + Old Method: + ---------- + // Declaration of the constant - in "H5DataSpace.h" + static const DataSpace ALL; - // Definition of the constant - in "H5DataSpace.cpp" - const DataSpace DataSpace::ALL(H5S_ALL); + // Definition of the constant - in "H5DataSpace.cpp" + const DataSpace DataSpace::ALL(H5S_ALL); - New Method: - ---------- - // Declare pointer for a constant - in "H5DataSpace.h" - static DataSpace* ALL_; // "H5DataSpace.h" + New Method: + ---------- + // Declare pointer for a constant - in "H5DataSpace.h" + static DataSpace* ALL_; // "H5DataSpace.h" - // Change previous constant to reference - in "H5DataSpace.h" - static const DataSpace& ALL; + // Change previous constant to reference - in "H5DataSpace.h" + static const DataSpace& ALL; - // Creates a dynamic DataSpace object representing the C constant - // - in "H5DataSpace.cpp" - ALL_ = new DataSpace(H5S_ALL); + // Creates a dynamic DataSpace object representing the C constant + // - in "H5DataSpace.cpp" + ALL_ = new DataSpace(H5S_ALL); - // Assign the constant reference to the dynamic object - // - in "H5DataSpace.cpp" - const DataSpace& DataSpace::ALL = *ALL_; + // Assign the constant reference to the dynamic object + // - in "H5DataSpace.cpp" + const DataSpace& DataSpace::ALL = *ALL_; - Functions added to class DataSpace: + Functions added to class DataSpace: - // Creates the constant - static DataSpace* getConstant(); // private + // Creates the constant + static DataSpace* getConstant(); // private - // Deletes the constant - static void deleteConstants(); // public + // Deletes the constant + static void deleteConstants(); // public - 4. This section shows the differences between the old and new methods - for allocating the following constants - - PropList constant, PropList::DEFAULT. - - DSetCreatPropList constant, DSetCreatPropList::DEFAULT. - - DSetMemXferPropList constant, DSetMemXferPropList::DEFAULT. - - FileCreatPropList constant, FileCreatPropList::DEFAULT. - - FileAccPropList constant, FileAccPropList::DEFAULT. + 4. This section shows the differences between the old and new methods + for allocating the following constants + - PropList constant, PropList::DEFAULT. + - DSetCreatPropList constant, DSetCreatPropList::DEFAULT. + - DSetMemXferPropList constant, DSetMemXferPropList::DEFAULT. + - FileCreatPropList constant, FileCreatPropList::DEFAULT. + - FileAccPropList constant, FileAccPropList::DEFAULT. - For these constants, the library has the same changes, except the - class names and the HDF5 corresponding constants. Only the items - of PropList are listed, and "PropList" can be replaced by any of - DSetCreatPropList, DSetMemXferPropList, FileCreatPropList, - FileAccPropList for those classes. The HDF5 C constant "H5P_DEFAULT" - can be replaced by any of these respectively: H5P_DATASET_CREATE, - H5P_DATASET_XFER, H5P_FILE_CREATE, and H5P_FILE_ACCESS. + For these constants, the library has the same changes, except the + class names and the HDF5 corresponding constants. Only the items + of PropList are listed, and "PropList" can be replaced by any of + DSetCreatPropList, DSetMemXferPropList, FileCreatPropList, + FileAccPropList for those classes. The HDF5 C constant "H5P_DEFAULT" + can be replaced by any of these respectively: H5P_DATASET_CREATE, + H5P_DATASET_XFER, H5P_FILE_CREATE, and H5P_FILE_ACCESS. - Old Method: - ---------- - // Declaration of the constant - in "H5PropList.h" - static const PropList DEFAULT; + Old Method: + ---------- + // Declaration of the constant - in "H5PropList.h" + static const PropList DEFAULT; - // Definition of the constant - in "H5PropList.cpp" - const PropList PropList::DEFAULT(H5P_DEFAULT); + // Definition of the constant - in "H5PropList.cpp" + const PropList PropList::DEFAULT(H5P_DEFAULT); - New Method: - ---------- - // Declare pointer for a constant - in "H5PropList.h" - static PropList* DEFAULT_; // "H5PropList.h" + New Method: + ---------- + // Declare pointer for a constant - in "H5PropList.h" + static PropList* DEFAULT_; // "H5PropList.h" - // Change previous constant to reference - in "H5PropList.h" - static const PropList& DEFAULT; + // Change previous constant to reference - in "H5PropList.h" + static const PropList& DEFAULT; - // Creates a dynamic PropList object representing the C constant - // - in "H5PropList.cpp" - DEFAULT_ = new PropList(H5P_DEFAULT); + // Creates a dynamic PropList object representing the C constant + // - in "H5PropList.cpp" + DEFAULT_ = new PropList(H5P_DEFAULT); - // Assign the constant reference to the dynamic object - // - in "H5PropList.cpp" - const PropList& PropList::DEFAULT = *DEFAULT_; + // Assign the constant reference to the dynamic object + // - in "H5PropList.cpp" + const PropList& PropList::DEFAULT = *DEFAULT_; - Functions added to class PropList: + Functions added to class PropList: - // Creates the constant - static PropList* getConstant(); // private + // Creates the constant + static PropList* getConstant(); // private - // Deletes the constants - static void deleteConstants(); // public + // Deletes the constants + static void deleteConstants(); // public - The same functions are added to the subclasses of PropList instead of - using PropList's because of the class types and in favor of clarity. + The same functions are added to the subclasses of PropList instead of + using PropList's because of the class types and in favor of clarity. ****************************************************************************/ diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 750902e..a8d6e37 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -30,207 +30,207 @@ namespace H5 { */ class H5_DLLCPP PredType : public AtomType { public: - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PredType"); } - - // Makes a copy of the predefined type and stores the new - // id in the left hand side object. - PredType& operator=( const PredType& rhs ); - - // Copy constructor - makes copy of the original object - PredType( const PredType& original ); - - // Noop destructor - virtual ~PredType(); - - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const H5std_string& name ); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const char* name ); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - bool committed(); - - ///\brief PredType constants - static const PredType& STD_I8BE; - static const PredType& STD_I8LE; - static const PredType& STD_I16BE; - static const PredType& STD_I16LE; - static const PredType& STD_I32BE; - static const PredType& STD_I32LE; - static const PredType& STD_I64BE; - static const PredType& STD_I64LE; - static const PredType& STD_U8BE; - static const PredType& STD_U8LE; - static const PredType& STD_U16BE; - static const PredType& STD_U16LE; - static const PredType& STD_U32BE; - static const PredType& STD_U32LE; - static const PredType& STD_U64BE; - static const PredType& STD_U64LE; - static const PredType& STD_B8BE; - static const PredType& STD_B8LE; - static const PredType& STD_B16BE; - static const PredType& STD_B16LE; - static const PredType& STD_B32BE; - static const PredType& STD_B32LE; - static const PredType& STD_B64BE; - static const PredType& STD_B64LE; - static const PredType& STD_REF_OBJ; - static const PredType& STD_REF_DSETREG; - - static const PredType& C_S1; - static const PredType& FORTRAN_S1; - - static const PredType& IEEE_F32BE; - static const PredType& IEEE_F32LE; - static const PredType& IEEE_F64BE; - static const PredType& IEEE_F64LE; - - static const PredType& UNIX_D32BE; - static const PredType& UNIX_D32LE; - static const PredType& UNIX_D64BE; - static const PredType& UNIX_D64LE; - - static const PredType& INTEL_I8; - static const PredType& INTEL_I16; - static const PredType& INTEL_I32; - static const PredType& INTEL_I64; - static const PredType& INTEL_U8; - static const PredType& INTEL_U16; - static const PredType& INTEL_U32; - static const PredType& INTEL_U64; - static const PredType& INTEL_B8; - static const PredType& INTEL_B16; - static const PredType& INTEL_B32; - static const PredType& INTEL_B64; - static const PredType& INTEL_F32; - static const PredType& INTEL_F64; - - static const PredType& ALPHA_I8; - static const PredType& ALPHA_I16; - static const PredType& ALPHA_I32; - static const PredType& ALPHA_I64; - static const PredType& ALPHA_U8; - static const PredType& ALPHA_U16; - static const PredType& ALPHA_U32; - static const PredType& ALPHA_U64; - static const PredType& ALPHA_B8; - static const PredType& ALPHA_B16; - static const PredType& ALPHA_B32; - static const PredType& ALPHA_B64; - static const PredType& ALPHA_F32; - static const PredType& ALPHA_F64; - - static const PredType& MIPS_I8; - static const PredType& MIPS_I16; - static const PredType& MIPS_I32; - static const PredType& MIPS_I64; - static const PredType& MIPS_U8; - static const PredType& MIPS_U16; - static const PredType& MIPS_U32; - static const PredType& MIPS_U64; - static const PredType& MIPS_B8; - static const PredType& MIPS_B16; - static const PredType& MIPS_B32; - static const PredType& MIPS_B64; - static const PredType& MIPS_F32; - static const PredType& MIPS_F64; - - static const PredType& NATIVE_CHAR; - static const PredType& NATIVE_SCHAR; - static const PredType& NATIVE_UCHAR; - static const PredType& NATIVE_SHORT; - static const PredType& NATIVE_USHORT; - static const PredType& NATIVE_INT; - static const PredType& NATIVE_UINT; - static const PredType& NATIVE_LONG; - static const PredType& NATIVE_ULONG; - static const PredType& NATIVE_LLONG; - static const PredType& NATIVE_ULLONG; - static const PredType& NATIVE_FLOAT; - static const PredType& NATIVE_DOUBLE; - static const PredType& NATIVE_LDOUBLE; - static const PredType& NATIVE_B8; - static const PredType& NATIVE_B16; - static const PredType& NATIVE_B32; - static const PredType& NATIVE_B64; - static const PredType& NATIVE_OPAQUE; - static const PredType& NATIVE_HSIZE; - static const PredType& NATIVE_HSSIZE; - static const PredType& NATIVE_HERR; - static const PredType& NATIVE_HBOOL; - - static const PredType& NATIVE_INT8; - static const PredType& NATIVE_UINT8; - static const PredType& NATIVE_INT16; - static const PredType& NATIVE_UINT16; - static const PredType& NATIVE_INT32; - static const PredType& NATIVE_UINT32; - static const PredType& NATIVE_INT64; - static const PredType& NATIVE_UINT64; + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("PredType"); } + + // Makes a copy of the predefined type and stores the new + // id in the left hand side object. + PredType& operator=(const PredType& rhs); + + // Copy constructor - makes copy of the original object + PredType(const PredType& original); + + // Noop destructor + virtual ~PredType(); + + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location& loc, const H5std_string& name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location& loc, const char* name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + bool committed(); + + ///\brief PredType constants + static const PredType& STD_I8BE; + static const PredType& STD_I8LE; + static const PredType& STD_I16BE; + static const PredType& STD_I16LE; + static const PredType& STD_I32BE; + static const PredType& STD_I32LE; + static const PredType& STD_I64BE; + static const PredType& STD_I64LE; + static const PredType& STD_U8BE; + static const PredType& STD_U8LE; + static const PredType& STD_U16BE; + static const PredType& STD_U16LE; + static const PredType& STD_U32BE; + static const PredType& STD_U32LE; + static const PredType& STD_U64BE; + static const PredType& STD_U64LE; + static const PredType& STD_B8BE; + static const PredType& STD_B8LE; + static const PredType& STD_B16BE; + static const PredType& STD_B16LE; + static const PredType& STD_B32BE; + static const PredType& STD_B32LE; + static const PredType& STD_B64BE; + static const PredType& STD_B64LE; + static const PredType& STD_REF_OBJ; + static const PredType& STD_REF_DSETREG; + + static const PredType& C_S1; + static const PredType& FORTRAN_S1; + + static const PredType& IEEE_F32BE; + static const PredType& IEEE_F32LE; + static const PredType& IEEE_F64BE; + static const PredType& IEEE_F64LE; + + static const PredType& UNIX_D32BE; + static const PredType& UNIX_D32LE; + static const PredType& UNIX_D64BE; + static const PredType& UNIX_D64LE; + + static const PredType& INTEL_I8; + static const PredType& INTEL_I16; + static const PredType& INTEL_I32; + static const PredType& INTEL_I64; + static const PredType& INTEL_U8; + static const PredType& INTEL_U16; + static const PredType& INTEL_U32; + static const PredType& INTEL_U64; + static const PredType& INTEL_B8; + static const PredType& INTEL_B16; + static const PredType& INTEL_B32; + static const PredType& INTEL_B64; + static const PredType& INTEL_F32; + static const PredType& INTEL_F64; + + static const PredType& ALPHA_I8; + static const PredType& ALPHA_I16; + static const PredType& ALPHA_I32; + static const PredType& ALPHA_I64; + static const PredType& ALPHA_U8; + static const PredType& ALPHA_U16; + static const PredType& ALPHA_U32; + static const PredType& ALPHA_U64; + static const PredType& ALPHA_B8; + static const PredType& ALPHA_B16; + static const PredType& ALPHA_B32; + static const PredType& ALPHA_B64; + static const PredType& ALPHA_F32; + static const PredType& ALPHA_F64; + + static const PredType& MIPS_I8; + static const PredType& MIPS_I16; + static const PredType& MIPS_I32; + static const PredType& MIPS_I64; + static const PredType& MIPS_U8; + static const PredType& MIPS_U16; + static const PredType& MIPS_U32; + static const PredType& MIPS_U64; + static const PredType& MIPS_B8; + static const PredType& MIPS_B16; + static const PredType& MIPS_B32; + static const PredType& MIPS_B64; + static const PredType& MIPS_F32; + static const PredType& MIPS_F64; + + static const PredType& NATIVE_CHAR; + static const PredType& NATIVE_SCHAR; + static const PredType& NATIVE_UCHAR; + static const PredType& NATIVE_SHORT; + static const PredType& NATIVE_USHORT; + static const PredType& NATIVE_INT; + static const PredType& NATIVE_UINT; + static const PredType& NATIVE_LONG; + static const PredType& NATIVE_ULONG; + static const PredType& NATIVE_LLONG; + static const PredType& NATIVE_ULLONG; + static const PredType& NATIVE_FLOAT; + static const PredType& NATIVE_DOUBLE; + static const PredType& NATIVE_LDOUBLE; + static const PredType& NATIVE_B8; + static const PredType& NATIVE_B16; + static const PredType& NATIVE_B32; + static const PredType& NATIVE_B64; + static const PredType& NATIVE_OPAQUE; + static const PredType& NATIVE_HSIZE; + static const PredType& NATIVE_HSSIZE; + static const PredType& NATIVE_HERR; + static const PredType& NATIVE_HBOOL; + + static const PredType& NATIVE_INT8; + static const PredType& NATIVE_UINT8; + static const PredType& NATIVE_INT16; + static const PredType& NATIVE_UINT16; + static const PredType& NATIVE_INT32; + static const PredType& NATIVE_UINT32; + static const PredType& NATIVE_INT64; + static const PredType& NATIVE_UINT64; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static const PredType& NATIVE_INT_LEAST8; + static const PredType& NATIVE_INT_LEAST8; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static const PredType& NATIVE_UINT_LEAST8; + static const PredType& NATIVE_UINT_LEAST8; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static const PredType& NATIVE_INT_LEAST16; + static const PredType& NATIVE_INT_LEAST16; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static const PredType& NATIVE_UINT_LEAST16; + static const PredType& NATIVE_UINT_LEAST16; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static const PredType& NATIVE_INT_LEAST32; + static const PredType& NATIVE_INT_LEAST32; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static const PredType& NATIVE_UINT_LEAST32; + static const PredType& NATIVE_UINT_LEAST32; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static const PredType& NATIVE_INT_LEAST64; + static const PredType& NATIVE_INT_LEAST64; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static const PredType& NATIVE_UINT_LEAST64; + static const PredType& NATIVE_UINT_LEAST64; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static const PredType& NATIVE_INT_FAST8; + static const PredType& NATIVE_INT_FAST8; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static const PredType& NATIVE_UINT_FAST8; + static const PredType& NATIVE_UINT_FAST8; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static const PredType& NATIVE_INT_FAST16; + static const PredType& NATIVE_INT_FAST16; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static const PredType& NATIVE_UINT_FAST16; + static const PredType& NATIVE_UINT_FAST16; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static const PredType& NATIVE_INT_FAST32; + static const PredType& NATIVE_INT_FAST32; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static const PredType& NATIVE_UINT_FAST32; + static const PredType& NATIVE_UINT_FAST32; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static const PredType& NATIVE_INT_FAST64; + static const PredType& NATIVE_INT_FAST64; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static const PredType& NATIVE_UINT_FAST64; + static const PredType& NATIVE_UINT_FAST64; #endif /* H5_SIZEOF_UINT_FAST64_T */ #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -242,11 +242,11 @@ class H5_DLLCPP PredType : public AtomType { static const PredType& PREDTYPE_CONST; // dummy constant protected: - // Default constructor - PredType(); + // Default constructor + PredType(); - // Creates a pre-defined type using an HDF5 pre-defined constant - PredType( const hid_t predtype_id ); // used by the library only + // Creates a pre-defined type using an HDF5 pre-defined constant + PredType(const hid_t predtype_id); // used by the library only private: // Activates the creation of the PredType global constants diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 1564a93..c4176c2 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -21,7 +21,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -42,7 +42,7 @@ PropList* PropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: PropList::getConstant -// Purpose: Creates a PropList object representing the HDF5 constant +// Purpose Creates a PropList object representing the HDF5 constant // H5P_DEFAULT, pointed to by PropList::DEFAULT_. // Exception H5::PropListIException // Description @@ -71,7 +71,7 @@ PropList* PropList::getConstant() //-------------------------------------------------------------------------- // Function: PropList::deleteConstants -// Purpose: Deletes the constant object that PropList::DEFAULT_ points to. +// Purpose Deletes the constant object that PropList::DEFAULT_ points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- void PropList::deleteConstants() @@ -81,24 +81,24 @@ void PropList::deleteConstants() } //-------------------------------------------------------------------------- -// Purpose Constant for default property. +// Purpose Constant for default property. //-------------------------------------------------------------------------- const PropList& PropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function Default constructor -///\brief Default constructor: creates a stub property list object. -// Programmer Binh-Minh Ribler - 2000 +// Function: Default constructor +///\brief Default constructor: creates a stub property list object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} //-------------------------------------------------------------------------- -// Function: PropList copy constructor -///\brief Copy constructor -///\param original - IN: The original property list to copy -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList copy constructor +///\brief Copy constructor +///\param original - IN: The original property list to copy +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PropList::PropList(const PropList& original) : IdComponent(), id(original.id) { @@ -106,166 +106,166 @@ PropList::PropList(const PropList& original) : IdComponent(), id(original.id) } //-------------------------------------------------------------------------- -// Function: PropList overloaded constructor -///\brief Creates a property list using the id of an existing property. -///\param plist_id - IN: Id of the existing property list -///\exception H5::PropListIException +// Function: PropList overloaded constructor +///\brief Creates a property list using the id of an existing property. +///\param plist_id - IN: Id of the existing property list +///\exception H5::PropListIException // Description -// This function creates a new property list if a property -// class is provided or makes a copy of a property list if one -// is given. If the given id is anything else, then set this -// property's id to H5P_DEFAULT. -// Programmer Binh-Minh Ribler - 2000 +// This function creates a new property list if a property +// class is provided or makes a copy of a property list if one +// is given. If the given id is anything else, then set this +// property's id to H5P_DEFAULT. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList( const hid_t plist_id ) : IdComponent() +PropList::PropList(const hid_t plist_id) : IdComponent() { if (plist_id <= 0) - id = H5P_DEFAULT; + id = H5P_DEFAULT; H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { - case H5I_GENPROP_CLS: - // call C routine to create a new property from the given prop class - id = H5Pcreate(plist_id); - if( id < 0 ) - { - throw PropListIException("PropList constructor", "H5Pcreate failed"); - } - break; - case H5I_GENPROP_LST: - // call C routine to make a copy of the given property list - id = H5Pcopy(plist_id); - if( id < 0 ) - { - throw PropListIException("PropList constructor", "H5Pcopy failed"); - } - break; - default: - id = H5P_DEFAULT; - break; + case H5I_GENPROP_CLS: + // call C routine to create a new property from the given prop class + id = H5Pcreate(plist_id); + if (id < 0) + { + throw PropListIException("PropList constructor", "H5Pcreate failed"); + } + break; + case H5I_GENPROP_LST: + // call C routine to make a copy of the given property list + id = H5Pcopy(plist_id); + if (id < 0) + { + throw PropListIException("PropList constructor", "H5Pcopy failed"); + } + break; + default: + id = H5P_DEFAULT; + break; } } //-------------------------------------------------------------------------- -// Function: PropList::copy -///\brief Makes a copy of an existing property list. -///\param like_plist - IN: Reference to the existing property list -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList::copy +///\brief Makes a copy of an existing property list. +///\param like_plist - IN: Reference to the existing property list +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void PropList::copy( const PropList& like_plist ) +void PropList::copy(const PropList& like_plist) { // If this object is representing an hdf5 object, close it before // copying like_plist to it try { - close(); + close(); } catch (Exception& close_error) { - throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); + throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } // call C routine to copy the property list - id = H5Pcopy( like_plist.getId() ); - if( id < 0 ) - throw PropListIException(inMemFunc("copy"), "H5Pcopy failed"); + id = H5Pcopy(like_plist.getId()); + if (id < 0) + throw PropListIException(inMemFunc("copy"), "H5Pcopy failed"); } //-------------------------------------------------------------------------- -// Function: PropList::operator= -///\brief Assignment operator. -///\param rhs - IN: Reference to the existing property list -///\return Reference to PropList instance -///\exception H5::PropListIException +// Function: PropList::operator= +///\brief Assignment operator. +///\param rhs - IN: Reference to the existing property list +///\return Reference to PropList instance +///\exception H5::PropListIException // Description -// Makes a copy of the property list on the right hand side -// and stores the new id in the left hand side object. -// Programmer Binh-Minh Ribler - 2000 +// Makes a copy of the property list on the right hand side +// and stores the new id in the left hand side object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList& PropList::operator=( const PropList& rhs ) +PropList& PropList::operator=(const PropList& rhs) { if (this != &rhs) - copy(rhs); + copy(rhs); return(*this); } //-------------------------------------------------------------------------- -// Function: PropList::copyProp -///\brief Copies a property from this property list or class to another -///\param dest - IN: Destination property list or class -///\param name - IN: Name of the property to copy - \c char pointer -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: PropList::copyProp +///\brief Copies a property from this property list or class to another +///\param dest - IN: Destination property list or class +///\param name - IN: Name of the property to copy - \c char pointer +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- void PropList::copyProp(PropList& dest, const char *name) const { - hid_t dst_id = dest.getId(); - herr_t ret_value = H5Pcopy_prop(dst_id, id, name); - if( ret_value < 0 ) - { - throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); - } + hid_t dst_id = dest.getId(); + herr_t ret_value = H5Pcopy_prop(dst_id, id, name); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::copyProp -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param dest - IN: Destination property list or class -///\param name - IN: Name of the property to copy - \c H5std_string -// Programmer Binh-Minh Ribler - Jul, 2005 +// Function: PropList::copyProp +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param dest - IN: Destination property list or class +///\param name - IN: Name of the property to copy - \c H5std_string +// Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp( PropList& dest, const H5std_string& name ) const +void PropList::copyProp(PropList& dest, const H5std_string& name) const { - copyProp( dest, name.c_str()); + copyProp(dest, name.c_str()); } //-------------------------------------------------------------------------- -// Function: PropList::copyProp -///\brief Copies a property from one list or class to another - Obsolete -///\param dest - IN: Destination property list or class -///\param src - IN: Source property list or class -///\param name - IN: Name of the property to copy - \c char pointer -///\note This member function will be removed in the next release -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList::copyProp +///\brief Copies a property from one list or class to another - Obsolete +///\param dest - IN: Destination property list or class +///\param src - IN: Source property list or class +///\param name - IN: Name of the property to copy - \c char pointer +///\note This member function will be removed in the next release +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp( PropList& dest, PropList& src, const char *name ) const +void PropList::copyProp(PropList& dest, PropList& src, const char *name) const { - hid_t dst_id = dest.getId(); - hid_t src_id = src.getId(); - herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); - if( ret_value < 0 ) - { - throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); - } + hid_t dst_id = dest.getId(); + hid_t src_id = src.getId(); + herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::copyProp -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. - Obsolete -///\param dest - IN: Destination property list or class -///\param src - IN: Source property list or class -///\param name - IN: Name of the property to copy - \c H5std_string -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList::copyProp +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. - Obsolete +///\param dest - IN: Destination property list or class +///\param src - IN: Source property list or class +///\param name - IN: Name of the property to copy - \c H5std_string +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name ) const +void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) const { - copyProp( dest, src, name.c_str()); + copyProp(dest, src, name.c_str()); } //-------------------------------------------------------------------------- // Function: PropList::getId -///\brief Get the id of this property list -///\return Property list identifier +///\brief Get the id of this property list +///\return Property list identifier // Description: // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDS and Attribute are moved out of H5Object. In @@ -275,7 +275,7 @@ void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name //-------------------------------------------------------------------------- hid_t PropList::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -307,444 +307,441 @@ void PropList::p_setId(const hid_t new_id) #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: PropList::close -///\brief Closes the property list if it is not a default one. +// Function: PropList::close +///\brief Closes the property list if it is not a default one. /// -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- void PropList::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Pclose( id ); - if( ret_value < 0 ) - { - throw PropListIException(inMemFunc("close"), "H5Pclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Pclose(id); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("close"), "H5Pclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } //-------------------------------------------------------------------------- -// Function: PropList::getClass -///\brief Returns the class of this property list, i.e. \c H5P_FILE_CREATE... -///\return The property list class if it is not equal to \c H5P_ROOT -///\exception H5::PropListIException -// Programmer Binh-Minh Ribler - April, 2004 +// Function: PropList::getClass +///\brief Returns the class of this property list, i.e. \c H5P_FILE_CREATE... +///\return The property list class if it is not equal to \c H5P_ROOT +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- hid_t PropList::getClass() const { - hid_t plist_class = H5Pget_class( id ); - if( plist_class == H5P_ROOT ) - { - throw PropListIException(inMemFunc("getClass"), - "H5Pget_class failed - returned H5P_ROOT"); - } - return( plist_class ); + hid_t plist_class = H5Pget_class(id); + if (plist_class == H5P_ROOT) + { + throw PropListIException(inMemFunc("getClass"), + "H5Pget_class failed - returned H5P_ROOT"); + } + return(plist_class); } //-------------------------------------------------------------------------- -// Function: PropList::propExist -///\brief Queries the existence of a property in a property object. -///\param name - IN: Name of property to check for - \c char pointer -///\return true if the property exists in the property object, and -/// false, otherwise. -///\exception H5::PropListIException +// Function: PropList::propExist +///\brief Queries the existence of a property in a property object. +///\param name - IN: Name of property to check for - \c char pointer +///\return true if the property exists in the property object, and +/// false, otherwise. +///\exception H5::PropListIException ///\par Description -/// This routine checks if a property exists within a property -/// list or class. +/// This routine checks if a property exists within a property +/// list or class. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const char* name ) const -{ - // Calls C routine H5Pexist to determine whether a property exists - // within a property list or class. It returns a positive value, 0, - // or a negative value - htri_t ret_value = H5Pexist(id, name); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else // Raise exception when H5Pexist returns a negative value - { - throw PropListIException(inMemFunc("propExist"), "H5Pexist failed"); - } -} -//-------------------------------------------------------------------------- -// Function: PropList::propExist -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to check for - \c H5std_string +bool PropList::propExist(const char* name) const +{ + // Calls C routine H5Pexist to determine whether a property exists + // within a property list or class. It returns a positive value, 0, + // or a negative value + htri_t ret_value = H5Pexist(id, name); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Pexist returns a negative value + { + throw PropListIException(inMemFunc("propExist"), "H5Pexist failed"); + } +} +//-------------------------------------------------------------------------- +// Function: PropList::propExist +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to check for - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const H5std_string& name ) const +bool PropList::propExist(const H5std_string& name) const { - return( propExist( name.c_str()) ); + return(propExist( name.c_str())); } //-------------------------------------------------------------------------- -// Function: PropList::closeClass -///\brief Close a property list class. +// Function: PropList::closeClass +///\brief Close a property list class. /// -///\exception H5::PropListIException +///\exception H5::PropListIException ///\par Description -/// Releases memory and detaches a class from the property -/// list class hierarchy. +/// Releases memory and detaches a class from the property +/// list class hierarchy. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::closeClass() const { - herr_t ret_value = H5Pclose_class(id); - if( ret_value < 0 ) - { - throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); - } + herr_t ret_value = H5Pclose_class(id); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::getProperty -///\brief Query the value of a property in a property list. -///\param name - IN: Name of property to query - \c char pointer -///\param value - OUT: Pointer to the buffer for the property value -///\exception H5::PropListIException +// Function: PropList::getProperty +///\brief Query the value of a property in a property list. +///\param name - IN: Name of property to query - \c char pointer +///\param value - OUT: Pointer to the buffer for the property value +///\exception H5::PropListIException ///\par Description -/// Retrieves a copy of the value for a property in a property -/// list. The property name must exist or this routine will -/// throw an exception. +/// Retrieves a copy of the value for a property in a property +/// list. The property name must exist or this routine will +/// throw an exception. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::getProperty(const char* name, void* value) const { - herr_t ret_value = H5Pget(id, name, value); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); - } + herr_t ret_value = H5Pget(id, name, value); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::getProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to query - \c char pointer -///\return The property that is a \c H5std_string. -///\exception H5::PropListIException +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c char pointer +///\return The property that is a \c H5std_string. +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5std_string PropList::getProperty(const char* name) const { - // Get property size first - size_t size = getPropSize(name); + // Get property size first + size_t size = getPropSize(name); - // Allocate buffer then get the property - char* prop_strg_C = new char[size+1]; // temporary C-string for C API - HDmemset(prop_strg_C, 0, size+1); // clear buffer + // Allocate buffer then get the property + char* prop_strg_C = new char[size+1]; // temporary C-string for C API + HDmemset(prop_strg_C, 0, size+1); // clear buffer - herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API + herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API - // Throw exception if H5Pget returns failure - if (ret_value < 0) - { + // Throw exception if H5Pget returns failure + if (ret_value < 0) + { delete []prop_strg_C; - throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); - } + throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); + } - // Return propety value as a string after deleting temp C-string - H5std_string prop_strg(prop_strg_C); - delete []prop_strg_C; - return (prop_strg); + // Return propety value as a string after deleting temp C-string + H5std_string prop_strg(prop_strg_C); + delete []prop_strg_C; + return (prop_strg); } //-------------------------------------------------------------------------- -// Function: PropList::getProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to query - \c H5std_string -///\param value - OUT: Pointer to the buffer for the property value +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c H5std_string +///\param value - OUT: Pointer to the buffer for the property value // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::getProperty(const H5std_string& name, void* value) const { - getProperty(name.c_str(), value); + getProperty(name.c_str(), value); } //-------------------------------------------------------------------------- -// Function: PropList::getProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to query - \c H5std_string -///\return The property that is a \c H5std_string. +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c H5std_string +///\return The property that is a \c H5std_string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5std_string PropList::getProperty(const H5std_string& name) const { - return (getProperty(name.c_str())); + return (getProperty(name.c_str())); } //-------------------------------------------------------------------------- -// Function: PropList::getPropSize -///\brief Query the size of a property in a property list or class. -///\param name - IN: Name of property to query -///\return Size of the property -///\exception H5::PropListIException +// Function: PropList::getPropSize +///\brief Query the size of a property in a property list or class. +///\param name - IN: Name of property to query +///\return Size of the property +///\exception H5::PropListIException ///\par Description -/// This routine retrieves the size of a property's value -/// in bytes. Zero-sized properties are allowed and the return -/// value will be of 0. This function works for both property -/// lists and classes. +/// This routine retrieves the size of a property's value +/// in bytes. Zero-sized properties are allowed and the return +/// value will be of 0. This function works for both property +/// lists and classes. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t PropList::getPropSize(const char *name) const { - size_t prop_size; - herr_t ret_value = H5Pget_size(id, name, &prop_size); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); - } - return(prop_size); + size_t prop_size; + herr_t ret_value = H5Pget_size(id, name, &prop_size); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); + } + return(prop_size); } //-------------------------------------------------------------------------- -// Function: PropList::getPropSize -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to query - \c H5std_string +// Function: PropList::getPropSize +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c H5std_string /// // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t PropList::getPropSize(const H5std_string& name) const { - return (getPropSize(name.c_str())); + return (getPropSize(name.c_str())); } //-------------------------------------------------------------------------- -// Function: PropList::getClassName -///\brief Return the name of a generic property list class. -///\return A string containing the class name, if success, otherwise, -/// a NULL string. +// Function: PropList::getClassName +///\brief Return the name of a generic property list class. +///\return A string containing the class name, if success, otherwise, +/// a NULL string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5std_string PropList::getClassName() const { - char* temp_str; - temp_str = H5Pget_class_name(id); // this API specified that temp_str must - // be freed. - - if (temp_str != NULL) - { - H5std_string class_name(temp_str); - H5free_memory(temp_str); - return(class_name); - } - else - return 0; + char* temp_str; + temp_str = H5Pget_class_name(id); + if (temp_str != NULL) + { + H5std_string class_name(temp_str); + H5free_memory(temp_str); + return(class_name); + } + else + return 0; } //-------------------------------------------------------------------------- -// Function: PropList::getNumProps -///\brief Returns the number of properties in this property list or class. -///\return Size of the property. -///\exception H5::PropListIException +// Function: PropList::getNumProps +///\brief Returns the number of properties in this property list or class. +///\return Size of the property. +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- size_t PropList::getNumProps() const { - size_t nprops; - herr_t ret_value = H5Pget_nprops (id, &nprops); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); - } - return (nprops); + size_t nprops; + herr_t ret_value = H5Pget_nprops (id, &nprops); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); + } + return (nprops); } //-------------------------------------------------------------------------- -// Function: PropList::setProperty -///\brief Set a property's value in a property list. -///\param name - IN: Name of property to set - \c char pointer -///\param value - IN: Void pointer to the value for the property -///\exception H5::PropListIException +// Function: PropList::setProperty +///\brief Set a property's value in a property list. +///\param name - IN: Name of property to set - \c char pointer +///\param value - IN: Void pointer to the value for the property +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const char* name, void* value) const { - herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); - } + herr_t ret_value = H5Pset(id, name, value); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::setProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to set - \c char pointer -///\param charptr - IN: Char pointer to the value for the property +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c char pointer +///\param charptr - IN: Char pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const char* name, const char* charptr) const { - herr_t ret_value = H5Pset(id, name, (void*)charptr); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); - } + herr_t ret_value = H5Pset(id, name, (void*)charptr); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::setProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to set - \c char pointer -///\param strg - IN: Value for the property is a \c H5std_string +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c char pointer +///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const char* name, H5std_string& strg) const { - setProperty(name, strg.c_str()); + setProperty(name, strg.c_str()); } //-------------------------------------------------------------------------- -// Function: PropList::setProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to set - \c H5std_string -///\param value - IN: Void pointer to the value for the property +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c H5std_string +///\param value - IN: Void pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const H5std_string& name, void* value) const { - setProperty(name.c_str(), value); + setProperty(name.c_str(), value); } //-------------------------------------------------------------------------- -// Function: PropList::setProperty -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to set - \c H5std_string -///\param strg - IN: Value for the property is a \c H5std_string +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c H5std_string +///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const H5std_string& name, H5std_string& strg) const { - setProperty(name.c_str(), strg.c_str()); + setProperty(name.c_str(), strg.c_str()); } //-------------------------------------------------------------------------- -// Function: PropList::isAClass -///\brief Determines whether a property list is a certain class. -///\param prop_class - IN: Property class to query -///\return true if the property list is a member of the property list -/// class, and false, otherwise. -///\exception H5::PropListIException +// Function: PropList::isAClass +///\brief Determines whether a property list is a certain class. +///\param prop_class - IN: Property class to query +///\return true if the property list is a member of the property list +/// class, and false, otherwise. +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- bool PropList::isAClass(const PropList& prop_class) const { - htri_t ret_value = H5Pisa_class(id, prop_class.getId()); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else // Raise exception when H5Pisa_class returns a negative value - { - throw PropListIException(inMemFunc("isAClass"), "H5Pisa_class failed"); - } - + htri_t ret_value = H5Pisa_class(id, prop_class.getId()); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Pisa_class returns a negative value + { + throw PropListIException(inMemFunc("isAClass"), "H5Pisa_class failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::removeProp -///\brief Removes a property from a property list. -///\param name - IN: Name of property to remove - \c char pointer -///\exception H5::PropListIException +// Function: PropList::removeProp +///\brief Removes a property from a property list. +///\param name - IN: Name of property to remove - \c char pointer +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::removeProp(const char *name) const { - herr_t ret_value = H5Premove(id, name); - if (ret_value < 0) - { - throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); - } + herr_t ret_value = H5Premove(id, name); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::removeProp -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. -///\param name - IN: Name of property to remove - \c H5std_string +// Function: PropList::removeProp +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to remove - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::removeProp(const H5std_string& name) const { - removeProp(name.c_str()); + removeProp(name.c_str()); } //-------------------------------------------------------------------------- -// Function: PropList::operator== -///\brief Compares this property list or class against the given list or class. -///\param rhs - IN: Reference to the property list to compare -///\return true if the property lists or classes are equal, and -/// false, otherwise. -///\exception H5::PropListIException +// Function: PropList::operator== +///\brief Compares this property list or class against the given list or class. +///\param rhs - IN: Reference to the property list to compare +///\return true if the property lists or classes are equal, and +/// false, otherwise. +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- bool PropList::operator==(const PropList& rhs) const { - htri_t ret_value = H5Pequal(id, rhs.getId()); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else // Raise exception when H5Pequal returns a negative value - { - throw PropListIException(inMemFunc("operator=="), "H5Pequal failed"); - } + htri_t ret_value = H5Pequal(id, rhs.getId()); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Pequal returns a negative value + { + throw PropListIException(inMemFunc("operator=="), "H5Pequal failed"); + } } //-------------------------------------------------------------------------- -// Function: PropList::getClassParent -///\brief Returns the parent class of a generic property class -///\return The parent class of a property class -///\exception H5::PropListIException +// Function: PropList::getClassParent +///\brief Returns the parent class of a generic property class +///\return The parent class of a property class +///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- PropList PropList::getClassParent() const { - hid_t class_id = H5Pget_class_parent(id); - if (class_id < 0) - { - throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); - } - PropList pclass(class_id); - return(pclass); + hid_t class_id = H5Pget_class_parent(id); + if (class_id < 0) + { + throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); + } + PropList pclass(class_id); + return(pclass); } //-------------------------------------------------------------------------- -// Function: PropList destructor -///\brief Properly terminates access to this property list. -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList destructor +///\brief Properly terminates access to this property list. +// Programmer Binh-Minh Ribler - 2000 // Modification -// - Replaced resetIdComponent() with decRefCount() to use C -// library ID reference counting mechanism - BMR, Jun 1, 2004 -// - Replaced decRefCount with close() to let the C library -// handle the reference counting - BMR, Jun 1, 2006 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- PropList::~PropList() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; + cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index faaf68d..3977774 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -28,111 +28,111 @@ namespace H5 { */ class H5_DLLCPP PropList : public IdComponent { public: - ///\brief Default property list + ///\brief Default property list static const PropList& DEFAULT; - // Creates a property list of a given type or creates a copy of an - // existing property list giving the property list id. - PropList(const hid_t plist_id); + // Creates a property list of a given type or creates a copy of an + // existing property list giving the property list id. + PropList(const hid_t plist_id); - // Make a copy of the given property list using assignment statement - PropList& operator=( const PropList& rhs ); + // Make a copy of the given property list using assignment statement + PropList& operator=(const PropList& rhs); - // Compares this property list or class against the given list or class. - bool operator==(const PropList& rhs) const; + // Compares this property list or class against the given list or class. + bool operator==(const PropList& rhs) const; - // Close this property list. - virtual void close(); + // Close this property list. + virtual void close(); - // Close a property list class. - void closeClass() const; + // Close a property list class. + void closeClass() const; - // Makes a copy of the given property list. - void copy( const PropList& like_plist ); + // Makes a copy of the given property list. + void copy(const PropList& like_plist); - // Copies a property from this property list or class to another - void copyProp( PropList& dest, const char* name) const; - void copyProp( PropList& dest, const H5std_string& name) const; + // Copies a property from this property list or class to another + void copyProp(PropList& dest, const char* name) const; + void copyProp(PropList& dest, const H5std_string& name) const; - // Copies a property from one property list or property class to another - void copyProp( PropList& dest, PropList& src, const char* name) const; - void copyProp( PropList& dest, PropList& src, const H5std_string& name) const; + // Copies a property from one property list or property class to another + void copyProp(PropList& dest, PropList& src, const char* name) const; + void copyProp(PropList& dest, PropList& src, const H5std_string& name) const; - // Gets the class of this property list, i.e. H5P_FILE_CREATE, - // H5P_FILE_ACCESS, ... - hid_t getClass() const; + // Gets the class of this property list, i.e. H5P_FILE_CREATE, + // H5P_FILE_ACCESS, ... + hid_t getClass() const; - // Return the name of a generic property list class. - H5std_string getClassName() const; + // Return the name of a generic property list class. + H5std_string getClassName() const; - // Returns the parent class of a generic property class. - PropList getClassParent() const; + // Returns the parent class of a generic property class. + PropList getClassParent() const; - // Returns the number of properties in this property list or class. - size_t getNumProps() const; + // Returns the number of properties in this property list or class. + size_t getNumProps() const; - // Query the value of a property in a property list. - void getProperty(const char* name, void* value) const; - void getProperty(const H5std_string& name, void* value) const; - H5std_string getProperty(const char* name) const; - H5std_string getProperty(const H5std_string& name) const; + // Query the value of a property in a property list. + void getProperty(const char* name, void* value) const; + void getProperty(const H5std_string& name, void* value) const; + H5std_string getProperty(const char* name) const; + H5std_string getProperty(const H5std_string& name) const; - // Set a property's value in a property list. - void setProperty(const char* name, void* value) const; - void setProperty(const char* name, const char* charptr) const; - void setProperty(const char* name, H5std_string& strg) const; - void setProperty(const H5std_string& name, void* value) const; - void setProperty(const H5std_string& name, H5std_string& strg) const; + // Set a property's value in a property list. + void setProperty(const char* name, void* value) const; + void setProperty(const char* name, const char* charptr) const; + void setProperty(const char* name, H5std_string& strg) const; + void setProperty(const H5std_string& name, void* value) const; + void setProperty(const H5std_string& name, H5std_string& strg) const; - // Query the size of a property in a property list or class. - size_t getPropSize(const char *name) const; - size_t getPropSize(const H5std_string& name) const; + // Query the size of a property in a property list or class. + size_t getPropSize(const char *name) const; + size_t getPropSize(const H5std_string& name) const; - // Determines whether a property list is a certain class. - bool isAClass(const PropList& prop_class) const; + // Determines whether a property list is a certain class. + bool isAClass(const PropList& prop_class) const; - /// Query the existance of a property in a property object. - bool propExist(const char* name) const; - bool propExist(const H5std_string& name) const; + /// Query the existance of a property in a property object. + bool propExist(const char* name) const; + bool propExist(const H5std_string& name) const; - // Removes a property from a property list. - void removeProp(const char *name) const; - void removeProp(const H5std_string& name) const; + // Removes a property from a property list. + void removeProp(const char *name) const; + void removeProp(const H5std_string& name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PropList"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("PropList"); } - // Default constructor: creates a stub PropList object. - PropList(); + // Default constructor: creates a stub PropList object. + PropList(); - // Copy constructor: creates a copy of a PropList object. - PropList(const PropList& original); + // Copy constructor: creates a copy of a PropList object. + PropList(const PropList& original); - // Gets the property list id. - virtual hid_t getId() const; + // Gets the property list id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this property list. - virtual ~PropList(); + // Destructor: properly terminates access to this property list. + virtual ~PropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PropList global constant - static void deleteConstants(); + // Deletes the PropList global constant + static void deleteConstants(); protected: - hid_t id; // HDF5 property list id + hid_t id; // HDF5 property list id - // Sets the property list id. - virtual void p_setId(const hid_t new_id); + // Sets the property list id. + virtual void p_setId(const hid_t new_id); private: - static PropList* DEFAULT_; + static PropList* DEFAULT_; - // Dynamically allocates the PropList global constant - static PropList* getConstant(); + // Dynamically allocates the PropList global constant + static PropList* getConstant(); - // Friend function to set PropList id. For library use only. - friend void f_PropList_setId(PropList* plist, hid_t new_id); + // Friend function to set PropList id. For library use only. + friend void f_PropList_setId(PropList* plist, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 50c9e45..54981ab 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -36,249 +36,247 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: StrType default constructor -///\brief Default constructor: Creates a stub string datatype -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType default constructor +///\brief Default constructor: Creates a stub string datatype +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- StrType::StrType() : AtomType() {} //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Creates a string datatype using a predefined type. -///\param pred_type - IN: Predefined datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType overloaded constructor +///\brief Creates a string datatype using a predefined type. +///\param pred_type - IN: Predefined datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType( const PredType& pred_type ) : AtomType() +StrType::StrType(const PredType& pred_type) : AtomType() { - // use DataType::copy to make a copy of this predefined type - copy( pred_type ); + // use DataType::copy to make a copy of this predefined type + copy(pred_type); } //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -// Purpose Creates a string datatype with a specified length -// Param pred_type - IN: String predefined type to replicate. -// Param size - IN: Length of the new string type -// Exception H5::DataTypeIException +// Function: StrType overloaded constructor +// Purpose Creates a string datatype with a specified length +// Param pred_type - IN: String predefined type to replicate. +// Param size - IN: Length of the new string type +// Exception H5::DataTypeIException // Description -// The 1st argument could have been skipped, but this -// constructor will collide with the one that takes an -// existing id. +// The 1st argument could have been skipped, but this +// constructor will collide with the one that takes an +// existing id. // -// Update: replacing the 1st argument with a dummy 0 to -// avoid the clashing problem, that doesn't eliminate the -// the 1st argument but it's simpler for the user to type -// a '0' than PredType::C_S1. - Dec 2, 2005 +// Update: replacing the 1st argument with a dummy 0 to +// avoid the clashing problem, that doesn't eliminate the +// the 1st argument but it's simpler for the user to type +// a '0' than PredType::C_S1. - Dec 2, 2005 // Note -// The use of this constructor can be shortened by using -// its overloaded below as StrType(0, size). -// Programmer Binh-Minh Ribler - 2000 +// The use of this constructor can be shortened by using +// its overloaded below as StrType(0, size). +// Programmer Binh-Minh Ribler - 2000 // Modification -// Planned for removal. -BMR, 2005/12/02 -// Removed from documentation. -BMR, 2016/03/07 +// Planned for removal. -BMR, 2005/12/02 +// Removed from documentation. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -StrType::StrType( const PredType& pred_type, const size_t& size ) : AtomType() +StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() { - // use DataType::copy to make a copy of the string predefined type - // then set its length - copy(pred_type); - setSize(size); + // use DataType::copy to make a copy of the string predefined type + // then set its length + copy(pred_type); + setSize(size); } //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Creates a string datatype with a specified length -///\param dummy - IN: To simplify calling the previous constructor -/// and avoid prototype clash with another constructor -///\param size - IN: Length of the new string type -///\exception H5::DataTypeIException +// Function: StrType overloaded constructor +///\brief Creates a string datatype with a specified length +///\param dummy - IN: To simplify calling the previous constructor +/// and avoid prototype clash with another constructor +///\param size - IN: Length of the new string type +///\exception H5::DataTypeIException ///\par Description -/// The 1st argument is just a dummy to simplify calling the -/// previous constructor, such as: -/// StrType atype(0, size) instead of -/// StrType atype(PredType::C_S1, size) +/// The 1st argument is just a dummy to simplify calling the +/// previous constructor, such as: +/// StrType atype(0, size) instead of +/// StrType atype(PredType::C_S1, size) // Note -// This constructor replaced the previous one. -// Programmer Binh-Minh Ribler - Nov 28, 2005 +// This constructor replaced the previous one. +// Programmer Binh-Minh Ribler - Nov 28, 2005 //-------------------------------------------------------------------------- -StrType::StrType( const int dummy, const size_t& size ) : AtomType() +StrType::StrType(const int dummy, const size_t& size) : AtomType() { - // use DataType::copy to make a copy of the string predefined type - // then set its length - copy(PredType::C_S1); - setSize(size); + // use DataType::copy to make a copy of the string predefined type + // then set its length + copy(PredType::C_S1); + setSize(size); } //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Creates an StrType object using the id of an existing datatype. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType overloaded constructor +///\brief Creates an StrType object using the id of an existing datatype. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType( const hid_t existing_id ) : AtomType( existing_id ) {} +StrType::StrType(const hid_t existing_id) : AtomType( existing_id ) {} //-------------------------------------------------------------------------- -// Function: StrType copy constructor -///\brief Copy constructor: makes a copy of the original StrType object. -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType copy constructor +///\brief Copy constructor: makes a copy of the original StrType object. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType( const StrType& original ) : AtomType ( original ) {} +StrType::StrType(const StrType& original) : AtomType ( original ) {} //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Gets the string datatype of the specified dataset -///\param dataset - IN: Dataset that this string datatype associates with -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType overloaded constructor +///\brief Gets the string datatype of the specified dataset +///\param dataset - IN: Dataset that this string datatype associates with +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType( const DataSet& dataset ) : AtomType () +StrType::StrType(const DataSet& dataset) : AtomType () { - // Calls C function H5Dget_type to get the id of the datatype - id = H5Dget_type( dataset.getId() ); + // Calls C function H5Dget_type to get the id of the datatype + id = H5Dget_type(dataset.getId()); - if( id < 0 ) - { - throw DataSetIException("StrType constructor", "H5Dget_type failed"); - } + if (id < 0) + { + throw DataSetIException("StrType constructor", "H5Dget_type failed"); + } } //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Creates an StrType instance by opening an HDF5 string datatype -/// given its name, provided as a C character string. -///\param dtype_name - IN: String type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: StrType overloaded constructor +///\brief Creates an StrType instance by opening an HDF5 string datatype +/// given its name, provided as a C character string. +///\param dtype_name - IN: String type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openStrType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openStrType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() { - id = p_opentype(loc, dtype_name); + id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- -// Function: StrType overloaded constructor -///\brief Creates an StrType instance by opening an HDF5 string datatype -/// given its name, provided as an \c H5std_string. -///\param dtype_name - IN: String type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: StrType overloaded constructor +///\brief Creates an StrType instance by opening an HDF5 string datatype +/// given its name, provided as an \c H5std_string. +///\param dtype_name - IN: String type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openStrType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openStrType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: StrType::getCset -///\brief Retrieves the character set type of this string datatype. -///\return Character set type, which can be: -/// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. +// Function: StrType::getCset +///\brief Retrieves the character set type of this string datatype. +///\return Character set type, which can be: +/// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. ///\note -/// ASCII and UTF-8 Unicode are the only currently supported character -/// encodings. Extended ASCII encodings (for example, ISO 8859) are not -/// supported. This encoding policy is not enforced by the HDF5 Library. -/// Using encodings other than ASCII and UTF-8 can lead to compatibility -/// and usability problems. See the C API entry H5Pset_char_encoding for -/// more information. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +/// ASCII and UTF-8 Unicode are the only currently supported character +/// encodings. Extended ASCII encodings (for example, ISO 8859) are not +/// supported. This encoding policy is not enforced by the HDF5 Library. +/// Using encodings other than ASCII and UTF-8 can lead to compatibility +/// and usability problems. See the C API entry H5Pset_char_encoding for +/// more information. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5T_cset_t StrType::getCset() const { - H5T_cset_t cset = H5Tget_cset( id ); + H5T_cset_t cset = H5Tget_cset(id); - // Returns a valid character set type if successful - if( cset == H5T_CSET_ERROR ) - { - throw DataTypeIException("StrType::getCset", "H5Tget_cset failed"); - } - return( cset ); + // Returns a valid character set type if successful + if (cset == H5T_CSET_ERROR) + { + throw DataTypeIException("StrType::getCset", "H5Tget_cset failed"); + } + return(cset); } //-------------------------------------------------------------------------- -// Function: StrType::setCset -///\brief Sets character set to be used. -///\param cset - IN: character set type, which can be: -/// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. +// Function: StrType::setCset +///\brief Sets character set to be used. +///\param cset - IN: character set type, which can be: +/// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. ///\note -/// ASCII and UTF-8 Unicode are the only currently supported character -/// encodings. Extended ASCII encodings (for example, ISO 8859) are not -/// supported. This encoding policy is not enforced by the HDF5 Library. -/// Using encodings other than ASCII and UTF-8 can lead to compatibility -/// and usability problems. See the C API entry H5Pset_char_encoding for -/// more information. -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +/// ASCII and UTF-8 Unicode are the only currently supported character +/// encodings. Extended ASCII encodings (for example, ISO 8859) are not +/// supported. This encoding policy is not enforced by the HDF5 Library. +/// Using encodings other than ASCII and UTF-8 can lead to compatibility +/// and usability problems. See the C API entry H5Pset_char_encoding for +/// more information. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setCset( H5T_cset_t cset ) const +void StrType::setCset(H5T_cset_t cset) const { - herr_t ret_value = H5Tset_cset( id, cset ); - - if( ret_value < 0 ) - { - throw DataTypeIException("StrType::setCset", "H5Tset_cset failed"); - } + herr_t ret_value = H5Tset_cset(id, cset); + if (ret_value < 0) + { + throw DataTypeIException("StrType::setCset", "H5Tset_cset failed"); + } } //-------------------------------------------------------------------------- -// Function: StrType::getStrpad -///\brief Retrieves the storage mechanism for of this string datatype. -///\return String storage mechanism, which can be: -/// \li \c H5T_STR_NULLTERM (0) - Null terminate (as C does) -/// \li \c H5T_STR_NULLPAD (0) - Pad with zeros -/// \li \c H5T_STR_SPACEPAD (0) - pad with spaces (as FORTRAN does) -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType::getStrpad +///\brief Retrieves the storage mechanism for of this string datatype. +///\return String storage mechanism, which can be: +/// \li \c H5T_STR_NULLTERM (0) - Null terminate (as C does) +/// \li \c H5T_STR_NULLPAD (0) - Pad with zeros +/// \li \c H5T_STR_SPACEPAD (0) - pad with spaces (as FORTRAN does) +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5T_str_t StrType::getStrpad() const { - H5T_str_t strpad = H5Tget_strpad( id ); + H5T_str_t strpad = H5Tget_strpad(id); - // Returns a valid string padding type if successful - if( strpad == H5T_STR_ERROR ) - { - throw DataTypeIException("StrType::getStrpad", - "H5Tget_strpad failed - returned H5T_STR_ERROR"); - } - return( strpad ); + // Returns a valid string padding type if successful + if (strpad == H5T_STR_ERROR) + { + throw DataTypeIException("StrType::getStrpad", + "H5Tget_strpad failed - returned H5T_STR_ERROR"); + } + return(strpad); } //-------------------------------------------------------------------------- -// Function: StrType::setStrpad -///\brief Defines the storage mechanism for this string datatype. -///\param strpad - IN: String padding type -///\exception H5::DataTypeIException +// Function: StrType::setStrpad +///\brief Defines the storage mechanism for this string datatype. +///\param strpad - IN: String padding type +///\exception H5::DataTypeIException ///\par Description -/// For detail, please refer to the C layer Reference Manual at: +/// For detail, please refer to the C layer Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-SetStrpad -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setStrpad( H5T_str_t strpad ) const +void StrType::setStrpad(H5T_str_t strpad) const { - herr_t ret_value = H5Tset_strpad( id, strpad ); - - if( ret_value < 0 ) - { - throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed"); - } + herr_t ret_value = H5Tset_strpad(id, strpad); + if (ret_value < 0) + { + throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed"); + } } //-------------------------------------------------------------------------- -// Function: StrType destructor -///\brief Properly terminates access to this string datatype. -// Programmer Binh-Minh Ribler - 2000 +// Function: StrType destructor +///\brief Properly terminates access to this string datatype. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- StrType::~StrType() {} diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index b920a3b..3272ad3 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -27,48 +27,48 @@ namespace H5 { */ class H5_DLLCPP StrType : public AtomType { public: - // Creates a string type using a predefined type - StrType(const PredType& pred_type); + // Creates a string type using a predefined type + StrType(const PredType& pred_type); - // Creates a string type with specified length - may be obsolete - StrType(const PredType& pred_type, const size_t& size); + // Creates a string type with specified length - may be obsolete + StrType(const PredType& pred_type, const size_t& size); - // Creates a string type with specified length - StrType(const int dummy, const size_t& size); + // Creates a string type with specified length + StrType(const int dummy, const size_t& size); // Gets the string datatype of the specified dataset - StrType(const DataSet& dataset); + StrType(const DataSet& dataset); - // Constructors that open an HDF5 string datatype, given a location. - StrType(const H5Location& loc, const char* name); - StrType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 string datatype, given a location. + StrType(const H5Location& loc, const char* name); + StrType(const H5Location& loc, const H5std_string& name); - // Retrieves the character set type of this string datatype. - H5T_cset_t getCset() const; + // Retrieves the character set type of this string datatype. + H5T_cset_t getCset() const; - // Sets character set to be used. - void setCset(H5T_cset_t cset) const; + // Sets character set to be used. + void setCset(H5T_cset_t cset) const; - // Retrieves the string padding method for this string datatype. - H5T_str_t getStrpad() const; + // Retrieves the string padding method for this string datatype. + H5T_str_t getStrpad() const; - // Defines the storage mechanism for character strings. - void setStrpad(H5T_str_t strpad) const; + // Defines the storage mechanism for character strings. + void setStrpad(H5T_str_t strpad) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("StrType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("StrType"); } - // default constructor - StrType(); + // default constructor + StrType(); - // Creates a string datatype using an existing id - StrType(const hid_t existing_id); + // Creates a string datatype using an existing id + StrType(const hid_t existing_id); - // Copy constructor - makes a copy of the original object - StrType(const StrType& original); + // Copy constructor - makes a copy of the original object + StrType(const StrType& original); - // Noop destructor. - virtual ~StrType(); + // Noop destructor. + virtual ~StrType(); }; } #endif // __H5StrType_H diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 5ecc39b..7f50b9a 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -30,88 +30,88 @@ namespace H5 { //-------------------------------------------------------------------------- -// Function: VarLenType default constructor -///\brief Default constructor: Creates a stub variable-length datatype. +// Function: VarLenType default constructor +///\brief Default constructor: Creates a stub variable-length datatype. //-------------------------------------------------------------------------- VarLenType::VarLenType() : DataType() {} //-------------------------------------------------------------------------- -// Function: VarLenType overloaded constructor -///\brief Creates an VarLenType object using an existing id. -///\param existing_id - IN: Id of an existing datatype -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May, 2004 +// Function: VarLenType overloaded constructor +///\brief Creates an VarLenType object using an existing id. +///\param existing_id - IN: Id of an existing datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) {} //-------------------------------------------------------------------------- -// Function: VarLenType copy constructor -///\brief Copy constructor: makes a copy of the original VarLenType object. -// Programmer Binh-Minh Ribler - May, 2004 +// Function: VarLenType copy constructor +///\brief Copy constructor: makes a copy of the original VarLenType object. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} //-------------------------------------------------------------------------- -// Function: VarLenType overloaded constructor -///\brief Creates a new variable-length datatype based on the specified -/// \a base_type. -///\param base_type - IN: Pointer to existing datatype -///\exception H5::DataTypeIException +// Function: VarLenType overloaded constructor +///\brief Creates a new variable-length datatype based on the specified +/// \a base_type. +///\param base_type - IN: Pointer to existing datatype +///\exception H5::DataTypeIException // Description -// DataType passed by pointer to avoid clashing with copy -// constructor. -// Programmer Binh-Minh Ribler - May, 2004 +// DataType passed by pointer to avoid clashing with copy +// constructor. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- VarLenType::VarLenType(const DataType* base_type) : DataType() { - id = H5Tvlen_create(base_type->getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", + id = H5Tvlen_create(base_type->getId()); + if (id < 0) + { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); - } + } } //-------------------------------------------------------------------------- -// Function: VarLenType overloaded constructor -///\brief Creates an VarLenType instance by opening an HDF5 variable -/// length datatype given its name, provided as a C char*. -///\param dtype_name - IN: Variable length type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: VarLenType overloaded constructor +///\brief Creates an VarLenType instance by opening an HDF5 variable +/// length datatype given its name, provided as a C char*. +///\param dtype_name - IN: Variable length type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openVarLenType(const char*) to -// improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openVarLenType(const char*) to +// improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType() { - id = p_opentype(loc, dtype_name); + id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- -// Function: VarLenType overloaded constructor -///\brief Creates an VarLenType instance by opening an HDF5 variable -/// length datatype given its name, provided as an \c H5std_string. -///\param dtype_name - IN: Variable length type name -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - Dec 2016 +// Function: VarLenType overloaded constructor +///\brief Creates an VarLenType instance by opening an HDF5 variable +/// length datatype given its name, provided as an \c H5std_string. +///\param dtype_name - IN: Variable length type name +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Dec 2016 // Description -// In 1.10.1, this constructor was introduced and will replace the -// existing function CommonFG::openVarLenType(const H5std_string&) -// to improve usability. -// -BMR, Dec 2016 +// In 1.10.1, this constructor was introduced and will replace the +// existing function CommonFG::openVarLenType(const H5std_string&) +// to improve usability. +// -BMR, Dec 2016 //-------------------------------------------------------------------------- VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : DataType() { - id = p_opentype(loc, dtype_name.c_str()); + id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- -// Function: VarLenType destructor -///\brief Properly terminates access to this datatype. -// Programmer Binh-Minh Ribler - May, 2004 +// Function: VarLenType destructor +///\brief Properly terminates access to this datatype. +// Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- VarLenType::~VarLenType() {} diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index af4f7b7..a93f44d 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -27,28 +27,28 @@ namespace H5 { */ class H5_DLLCPP VarLenType : public DataType { public: - // Constructor that creates a variable-length datatype based - // on the specified base type. - VarLenType(const DataType* base_type); + // Constructor that creates a variable-length datatype based + // on the specified base type. + VarLenType(const DataType* base_type); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("VarLenType"); } + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("VarLenType"); } - // Copy constructor: makes copy of the original object. - VarLenType( const VarLenType& original ); + // Copy constructor: makes copy of the original object. + VarLenType(const VarLenType& original); - // Constructor that takes an existing id - VarLenType( const hid_t existing_id ); + // Constructor that takes an existing id + VarLenType(const hid_t existing_id); - // Constructors that open a variable-length datatype, given a location. - VarLenType(const H5Location& loc, const char* name); - VarLenType(const H5Location& loc, const H5std_string& name); + // Constructors that open a variable-length datatype, given a location. + VarLenType(const H5Location& loc, const char* name); + VarLenType(const H5Location& loc, const H5std_string& name); - // Noop destructor - virtual ~VarLenType(); + // Noop destructor + virtual ~VarLenType(); - // Default constructor - VarLenType(); + // Default constructor + VarLenType(); }; } #endif // __H5VarLenType_H diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 8752744..48a0c4d 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -16,12 +16,12 @@ /***************************************************************************** FILE dsets.cpp - HDF5 C++ testing the functionalities associated with the - C dataset interface (H5D) + C dataset interface (H5D) EXTERNAL ROUTINES/VARIABLES: These routines are in the test directory of the C library: - h5_reset() -- in h5test.c, resets the library by closing it - h5_fileaccess() -- in h5test.c, returns a file access template + h5_reset() -- in h5test.c, resets the library by closing it + h5_fileaccess() -- in h5test.c, returns a file access template ***************************************************************************/ @@ -34,20 +34,20 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("dataset.h5"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_DEFAULT_NAME_PATH("/default"); -const H5std_string DSET_CHUNKED_NAME("chunked"); -const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); -const H5std_string DSET_TCONV_NAME ("tconv"); -const H5std_string DSET_COMPRESS_NAME("compressed"); -const H5std_string DSET_BOGUS_NAME ("bogus"); +const H5std_string FILE1("dataset.h5"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_DEFAULT_NAME_PATH("/default"); +const H5std_string DSET_CHUNKED_NAME("chunked"); +const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); +const H5std_string DSET_TCONV_NAME("tconv"); +const H5std_string DSET_COMPRESS_NAME("compressed"); +const H5std_string DSET_BOGUS_NAME("bogus"); /* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; @@ -58,16 +58,16 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, /*------------------------------------------------------------------------- - * Function: test_create + * Function: test_create * - * Purpose: Attempts to create a dataset. + * Purpose Attempts to create a dataset. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Friday, January 5, 2001 * * Modifications: * @@ -81,125 +81,125 @@ test_create( H5File& file) // Setting this to NULL for cleaning up in failure situations DataSet *dataset = NULL; try { - // Create a data space - hsize_t dims[2]; - dims[0] = 256; - dims[1] = 512; - DataSpace space (2, dims, NULL); - - // Create a dataset using the default dataset creation properties. - // We're not sure what they are, so we won't check. - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); - - - // Add a comment to the dataset - file.setComment (DSET_DEFAULT_NAME, "This is a dataset"); - - // Close the dataset - delete dataset; - dataset = NULL; - - // Try creating a dataset that already exists. This should fail since a - // dataset can only be created once. If an exception is not thrown for - // this action by createDataSet, then throw an invalid action exception. - try { - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); - - // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); - } - catch (FileIException& E) // catching invalid creating dataset - {} // do nothing, exception expected - - // Open the dataset we created above and then close it. This is one - // way to open an existing dataset for accessing. - dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); - - // Get and verify the name of this dataset, using - // H5std_string getObjName() - H5std_string ds_name = dataset->getObjName(); - verify_val(ds_name, DSET_DEFAULT_NAME_PATH, "DataSet::getObjName", __LINE__, __FILE__); - - // Get and verify the comment from this dataset, using - // H5std_string getComment(const H5std_string& name, ) - H5std_string comment = file.getComment(DSET_DEFAULT_NAME); - verify_val(comment, "This is a dataset", "DataSet::getComment", __LINE__, __FILE__); - - // Close the dataset when accessing is completed - delete dataset; - - // This is another way to open an existing dataset for accessing. - DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME)); - - // Try opening a non-existent dataset. This should fail so if an - // exception is not thrown for this action by openDataSet, then - // display failure information and throw an exception. - try { - dataset = new DataSet (file.openDataSet( "does_not_exist" )); - - // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); - } - catch (FileIException& E ) // catching creating non-existent dataset - {} // do nothing, exception expected - - // Create a new dataset that uses chunked storage instead of the default - // layout. - DSetCreatPropList create_parms; - hsize_t csize[2]; - csize[0] = 5; - csize[1] = 100; - create_parms.setChunk( 2, csize ); - - dataset = new DataSet (file.createDataSet - (DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms)); - // Note: this one has no error message in C when failure occurs? - - // clean up and return with success - delete dataset; - - PASSED(); - return 0; - } // outer most try block + // Create a data space + hsize_t dims[2]; + dims[0] = 256; + dims[1] = 512; + DataSpace space (2, dims, NULL); + + // Create a dataset using the default dataset creation properties. + // We're not sure what they are, so we won't check. + dataset = new DataSet (file.createDataSet + (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); + + + // Add a comment to the dataset + file.setComment (DSET_DEFAULT_NAME, "This is a dataset"); + + // Close the dataset + delete dataset; + dataset = NULL; + + // Try creating a dataset that already exists. This should fail since a + // dataset can only be created once. If an exception is not thrown for + // this action by createDataSet, then throw an invalid action exception. + try { + dataset = new DataSet (file.createDataSet + (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); + + // continuation here, that means no exception has been thrown + throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + } + catch (FileIException& E) // catching invalid creating dataset + {} // do nothing, exception expected + + // Open the dataset we created above and then close it. This is one + // way to open an existing dataset for accessing. + dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); + + // Get and verify the name of this dataset, using + // H5std_string getObjName() + H5std_string ds_name = dataset->getObjName(); + verify_val(ds_name, DSET_DEFAULT_NAME_PATH, "DataSet::getObjName", __LINE__, __FILE__); + + // Get and verify the comment from this dataset, using + // H5std_string getComment(const H5std_string& name, ) + H5std_string comment = file.getComment(DSET_DEFAULT_NAME); + verify_val(comment, "This is a dataset", "DataSet::getComment", __LINE__, __FILE__); + + // Close the dataset when accessing is completed + delete dataset; + + // This is another way to open an existing dataset for accessing. + DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME)); + + // Try opening a non-existent dataset. This should fail so if an + // exception is not thrown for this action by openDataSet, then + // display failure information and throw an exception. + try { + dataset = new DataSet (file.openDataSet( "does_not_exist" )); + + // continuation here, that means no exception has been thrown + throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); + } + catch (FileIException& E ) // catching creating non-existent dataset + {} // do nothing, exception expected + + // Create a new dataset that uses chunked storage instead of the default + // layout. + DSetCreatPropList create_parms; + hsize_t csize[2]; + csize[0] = 5; + csize[1] = 100; + create_parms.setChunk( 2, csize ); + + dataset = new DataSet (file.createDataSet(DSET_CHUNKED_NAME, + PredType::NATIVE_DOUBLE, space, create_parms)); + // Note: this one has no error message in C when failure occurs? + + // clean up and return with success + delete dataset; + + PASSED(); + return 0; + } // outer most try block catch (InvalidActionException& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - // clean up and return with failure - if (dataset != NULL) - delete dataset; - return -1; + // clean up and return with failure + if (dataset != NULL) + delete dataset; + return -1; } // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_create", __LINE__, __FILE__); + issue_fail_msg("test_create", __LINE__, __FILE__); - // clean up and return with failure - if (dataset != NULL) - delete dataset; - return -1; + // clean up and return with failure + if (dataset != NULL) + delete dataset; + return -1; } } // test_create /*------------------------------------------------------------------------- - * Function: test_simple_io + * Function: test_simple_io * - * Purpose: Tests simple I/O. That is, reading and writing a complete - * multi-dimensional array without data type or data space - * conversions, without compression, and stored contiguously. + * Purpose Tests simple I/O. That is, reading and writing a complete + * multi-dimensional array without data type or data space + * conversions, without compression, and stored contiguously. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Friday, January 5, 2001 * * Modifications: * @@ -211,81 +211,81 @@ test_simple_io( H5File& file) SUBTEST("Simple I/O"); - int points[100][200]; - int check[100][200]; - int i, j, n; + int points[100][200]; + int check[100][200]; + int i, j, n; // Initialize the dataset for (i = n = 0; i < 100; i++) { - for (j = 0; j < 200; j++) { - points[i][j] = n++; - } + for (j = 0; j < 200; j++) { + points[i][j] = n++; + } } char* tconv_buf = new char [1000]; try { - // Create the data space - hsize_t dims[2]; - dims[0] = 100; - dims[1] = 200; - DataSpace space (2, dims, NULL); - - // Create a small conversion buffer to test strip mining - DSetMemXferPropList xfer; - - xfer.setBuffer (1000, tconv_buf, NULL); - - // Create the dataset - DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); - - // Write the data to the dataset - dataset.write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Read the dataset back - dataset.read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Check that the values read are the same as the values written - for (i = 0; i < 100; i++) - for (j = 0; j < 200; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("DataSet::read"); - } - - // clean up and return with success - delete [] tconv_buf; - PASSED(); - return 0; + // Create the data space + hsize_t dims[2]; + dims[0] = 100; + dims[1] = 200; + DataSpace space (2, dims, NULL); + + // Create a small conversion buffer to test strip mining + DSetMemXferPropList xfer; + + xfer.setBuffer (1000, tconv_buf, NULL); + + // Create the dataset + DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); + + // Write the data to the dataset + dataset.write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Read the dataset back + dataset.read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < 100; i++) + for (j = 0; j < 200; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("DataSet::read"); + } + + // clean up and return with success + delete [] tconv_buf; + PASSED(); + return 0; } // end try // catch all dataset, space, plist exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - // clean up and return with failure - if (tconv_buf) - delete [] tconv_buf; - return -1; + // clean up and return with failure + if (tconv_buf) + delete [] tconv_buf; + return -1; } } // test_simple_io /*------------------------------------------------------------------------- - * Function: test_datasize + * Function: test_datasize * - * Purpose: Tests DataSet::getInMemDataSize(). + * Purpose Tests DataSet::getInMemDataSize(). * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Thursday, March 22, 2012 + * Programmer Binh-Minh Ribler + * Thursday, March 22, 2012 * * Modifications: * @@ -297,65 +297,65 @@ test_datasize(FileAccPropList &fapl) SUBTEST("DataSet::getInMemDataSize()"); try { - // Open FILE1. - H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); - - // Open dataset DSET_SIMPLE_IO_NAME. - DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); - - // Get the dataset's dataspace to calculate the size for verification. - DataSpace space(dset.getSpace()); - - // Get the dimension sizes. - hsize_t dims[2]; - int n_dims = space.getSimpleExtentDims(dims); - if (n_dims < 0) - { - throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed"); - } - - // Calculate the supposed size. Size of each value is int (4), from - // test_simple_io. - size_t expected_size = 4 * dims[0] * dims[1]; - - // getInMemDataSize() returns the in memory size of the data. - size_t ds_size = dset.getInMemDataSize(); - - // Verify the data size. - if (ds_size != expected_size) - { - H5_FAILED(); - cerr << " Expected data size = " << expected_size; - cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; - throw Exception("test_compression", "Failed in testing DataSet::getInMemDataSize()"); - } - - PASSED(); - return 0; + // Open FILE1. + H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); + + // Open dataset DSET_SIMPLE_IO_NAME. + DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); + + // Get the dataset's dataspace to calculate the size for verification. + DataSpace space(dset.getSpace()); + + // Get the dimension sizes. + hsize_t dims[2]; + int n_dims = space.getSimpleExtentDims(dims); + if (n_dims < 0) + { + throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed"); + } + + // Calculate the supposed size. Size of each value is int (4), from + // test_simple_io. + size_t expected_size = 4 * dims[0] * dims[1]; + + // getInMemDataSize() returns the in memory size of the data. + size_t ds_size = dset.getInMemDataSize(); + + // Verify the data size. + if (ds_size != expected_size) + { + H5_FAILED(); + cerr << " Expected data size = " << expected_size; + cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; + throw Exception("test_compression", "Failed in testing DataSet::getInMemDataSize()"); + } + + PASSED(); + return 0; } // end try // catch all dataset, space, plist exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - return -1; + return -1; } } // test_datasize /*------------------------------------------------------------------------- - * Function: test_tconv + * Function: test_tconv * - * Purpose: Test some simple data type conversion stuff. + * Purpose Test some simple data type conversion stuff. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Friday, January 5, 2001 * * Modifications: * @@ -365,7 +365,7 @@ static herr_t test_tconv(H5File& file) { // Prepare buffers for input/output - char *out=NULL, *in=NULL; + char *out=NULL, *in=NULL; out = new char [4*1000000]; // assert (out); - should use exception handler for new - BMR in = new char [4*1000000]; @@ -375,81 +375,81 @@ test_tconv(H5File& file) // Initialize the dataset for (int i = 0; i < 1000000; i++) { - out[i*4+0] = 0x11; - out[i*4+1] = 0x22; - out[i*4+2] = 0x33; - out[i*4+3] = 0x44; + out[i*4+0] = 0x11; + out[i*4+1] = 0x22; + out[i*4+2] = 0x33; + out[i*4+3] = 0x44; } try { - // Create the data space - hsize_t dims[1]; - dims[0] = 1000000; - DataSpace space (1, dims, NULL); - - // Create the data set - DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); - - // Write the data to the dataset - dataset.write (static_cast(out), PredType::STD_I32LE); - - // Read data with byte order conversion - dataset.read (static_cast(in), PredType::STD_I32BE); - - // Check - for (int i = 0; i < 1000000; i++) { - if (in[4*i+0]!=out[4*i+3] || - in[4*i+1]!=out[4*i+2] || - in[4*i+2]!=out[4*i+1] || - in[4*i+3]!=out[4*i+0]) - { - throw Exception("DataSet::read", "Read with byte order conversion failed"); - } - } - - // clean up and return with success - delete [] out; - delete [] in; - PASSED(); - return 0; + // Create the data space + hsize_t dims[1]; + dims[0] = 1000000; + DataSpace space (1, dims, NULL); + + // Create the data set + DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); + + // Write the data to the dataset + dataset.write (static_cast(out), PredType::STD_I32LE); + + // Read data with byte order conversion + dataset.read (static_cast(in), PredType::STD_I32BE); + + // Check + for (int i = 0; i < 1000000; i++) { + if (in[4*i+0]!=out[4*i+3] || + in[4*i+1]!=out[4*i+2] || + in[4*i+2]!=out[4*i+1] || + in[4*i+3]!=out[4*i+0]) + { + throw Exception("DataSet::read", "Read with byte order conversion failed"); + } + } + + // clean up and return with success + delete [] out; + delete [] in; + PASSED(); + return 0; } // end try // catch all dataset and space exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - // clean up and return with failure - delete [] out; - delete [] in; - return -1; + // clean up and return with failure + delete [] out; + delete [] in; + return -1; } } // test_tconv /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encode and decode enabled */ - "bogus", /* Filter name for debugging */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encode and decode enabled */ + "bogus", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; /*------------------------------------------------------------------------- - * Function: bogus + * Function: bogus * - * Purpose: A bogus compression method that doesn't do anything. + * Purpose A bogus compression method that doesn't do anything. * - * Return: Success: Data chunk size + * Return Success: Data chunk size * - * Failure: 0 + * Failure: 0 * - * Programmer: Robb Matzke - * Tuesday, April 21, 1998 + * Programmer Robb Matzke + * Tuesday, April 21, 1998 * * Modifications: * @@ -466,19 +466,19 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, /*------------------------------------------------------------------------- - * Function: test_compression + * Function: test_compression * - * Purpose: Tests dataset compression. If compression is requested when - * it hasn't been compiled into the library (such as when - * updating an existing compressed dataset) then data is sent to - * the file uncompressed but no errors are returned. + * Purpose Tests dataset compression. If compression is requested when + * it hasn't been compiled into the library (such as when + * updating an existing compressed dataset) then data is sent to + * the file uncompressed but no errors are returned. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Friday, January 5, 2001 * * Modifications: * @@ -488,266 +488,266 @@ static herr_t test_compression(H5File& file) { #ifndef H5_HAVE_FILTER_DEFLATE - const char *not_supported; + const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; - hsize_t i, j, n; + int points[100][200]; + int check[100][200]; + hsize_t i, j, n; // Initialize the dataset for (i = n = 0; i < 100; i++) { - for (j = 0; j < 200; j++) { - points[i][j] = static_cast(n++); - } + for (j = 0; j < 200; j++) { + points[i][j] = static_cast(n++); + } } char* tconv_buf = new char [1000]; DataSet* dataset = NULL; try { - const hsize_t size[2] = {100, 200}; - // Create the data space - DataSpace space1(2, size, NULL); + const hsize_t size[2] = {100, 200}; + // Create the data space + DataSpace space1(2, size, NULL); - // Create a small conversion buffer to test strip mining - DSetMemXferPropList xfer; + // Create a small conversion buffer to test strip mining + DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer (1000, tconv_buf, NULL); - // Use chunked storage with compression - DSetCreatPropList dscreatplist; + // Use chunked storage with compression + DSetCreatPropList dscreatplist; - const hsize_t chunk_size[2] = {2, 25}; - dscreatplist.setChunk (2, chunk_size); - dscreatplist.setDeflate (6); + const hsize_t chunk_size[2] = {2, 25}; + dscreatplist.setChunk (2, chunk_size); + dscreatplist.setDeflate (6); #ifdef H5_HAVE_FILTER_DEFLATE - SUBTEST("Compression (setup)"); - - // Create the dataset - dataset = new DataSet (file.createDataSet - (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (uninitialized read)"); - - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - for (i=0; i(i) << "," << - static_cast(j) << endl; - throw Exception("test_compression", "Failed in uninitialized read"); - } - } - } - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 2: Test compression by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (write)"); - - for (i=n=0; i(n++); - } - } - - dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 3: Try to read the data we just wrote. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (read)"); - - // Read the dataset back - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Check that the values read are the same as the values written - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("test_compression", "Failed in read"); - } - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 4: Write new data over the top of the old data. The new data is - * random thus not very compressible, and will cause the chunks to move - * around as they grow. We only change values for the left half of the - * dataset although we rewrite the whole thing. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (modify)"); - - for (i=0; iwrite (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Read the dataset back and check it - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Check that the values read are the same as the values written - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("test_compression", "Failed in modify"); - } - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 5: Close the dataset and then open it and read it again. This - * insures that the compression message is picked up properly from the - * object header. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (re-open)"); - - // close this dataset to reuse the var - delete dataset; - - dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Check that the values read are the same as the values written - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("test_compression", "Failed in re-open"); - } - - PASSED(); - - - /*---------------------------------------------------------------------- - * STEP 6: Test partial I/O by writing to and then reading from a - * hyperslab of the dataset. The hyperslab does not line up on chunk - * boundaries (we know that case already works from above tests). - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (partial I/O)"); - - const hsize_t hs_size[2] = {4, 50}; - const hsize_t hs_offset[2] = {7, 30}; - for (i = 0; i < hs_size[0]; i++) { - for (j = 0; j < hs_size[1]; j++) { - points[hs_offset[0]+i][hs_offset[1]+j] = rand (); - } - } - space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (static_cast(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, space1, space1, xfer); - - // Check that the values read are the same as the values written - for (i=0; i((hs_offset[0]+i)) << - "," << static_cast((hs_offset[1]+j)) << endl; - - cerr << " At original: " << static_cast(points[hs_offset[0]+i][hs_offset[1]+j]) << endl; - cerr << " At returned: " << static_cast(check[hs_offset[0]+i][hs_offset[1]+j]) << endl; - throw Exception("test_compression", "Failed in partial I/O"); - } - } // for j - } // for i - - delete dataset; - dataset = NULL; - - PASSED(); + SUBTEST("Compression (setup)"); + + // Create the dataset + dataset = new DataSet (file.createDataSet + (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (uninitialized read)"); + + dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + for (i=0; i(i) + << "," << static_cast(j) << endl; + throw Exception("test_compression", "Failed in uninitialized read"); + } + } + } + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 2: Test compression by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (write)"); + + for (i=n=0; i(n++); + } + } + + dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (read)"); + + // Read the dataset back + dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("test_compression", "Failed in read"); + } + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (modify)"); + + for (i=0; iwrite (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Read the dataset back and check it + dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("test_compression", "Failed in modify"); + } + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the compression message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (re-open)"); + + // close this dataset to reuse the var + delete dataset; + + dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); + dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("test_compression", "Failed in re-open"); + } + + PASSED(); + + + /*---------------------------------------------------------------------- + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (partial I/O)"); + + const hsize_t hs_size[2] = {4, 50}; + const hsize_t hs_offset[2] = {7, 30}; + for (i = 0; i < hs_size[0]; i++) { + for (j = 0; j < hs_size[1]; j++) { + points[hs_offset[0]+i][hs_offset[1]+j] = rand (); + } + } + space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); + dataset->write (static_cast(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read (static_cast(check), PredType::NATIVE_INT, space1, space1, xfer); + + // Check that the values read are the same as the values written + for (i=0; i((hs_offset[0]+i)) << + "," << static_cast((hs_offset[1]+j)) << endl; + + cerr << " At original: " << static_cast(points[hs_offset[0]+i][hs_offset[1]+j]) << endl; + cerr << " At returned: " << static_cast(check[hs_offset[0]+i][hs_offset[1]+j]) << endl; + throw Exception("test_compression", "Failed in partial I/O"); + } + } // for j + } // for i + + delete dataset; + dataset = NULL; + + PASSED(); #else - SUBTEST("deflate filter"); - SKIPPED(); - cerr << not_supported << endl; + SUBTEST("deflate filter"); + SKIPPED(); + cerr << not_supported << endl; #endif - /*---------------------------------------------------------------------- - * STEP 7: Register an application-defined compression method and use it - * to write and then read the dataset. - *---------------------------------------------------------------------- - */ - SUBTEST("Compression (app-defined method)"); + /*---------------------------------------------------------------------- + * STEP 7: Register an application-defined compression method and use it + * to write and then read the dataset. + *---------------------------------------------------------------------- + */ + SUBTEST("Compression (app-defined method)"); if (H5Zregister (H5Z_BOGUS)<0) - throw Exception("test_compression", "Failed in app-defined method"); - if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0) - throw Exception("test_compression", "Failed in app-defined method"); - dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL); - - DataSpace space2 (2, size, NULL); - dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); - - dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - - // Check that the values read are the same as the values written - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("test_compression", "Failed in app-defined method"); - } - - PASSED(); - - /*---------------------------------------------------------------------- - * Cleanup - *---------------------------------------------------------------------- - */ - delete dataset; - delete [] tconv_buf; - return 0; + throw Exception("test_compression", "Failed in app-defined method"); + if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0) + throw Exception("test_compression", "Failed in app-defined method"); + dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL); + + DataSpace space2 (2, size, NULL); + dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); + + dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("test_compression", "Failed in app-defined method"); + } + + PASSED(); + + /*---------------------------------------------------------------------- + * Cleanup + *---------------------------------------------------------------------- + */ + delete dataset; + delete [] tconv_buf; + return 0; } // end try // catch all dataset, file, space, and plist exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - - // clean up and return with failure - if (dataset != NULL) - delete dataset; - if (tconv_buf) - delete [] tconv_buf; - return -1; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + + // clean up and return with failure + if (dataset != NULL) + delete dataset; + if (tconv_buf) + delete [] tconv_buf; + return -1; } } // test_compression @@ -755,18 +755,18 @@ test_compression(H5File& file) /*------------------------------------------------------------------------- * Function: test_nbit_methods * - * Purpose: Tests setting nbit compression methods. + * Purpose Tests setting nbit compression methods. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, April 22, 2016 + * Programmer Binh-Minh Ribler + * Friday, April 22, 2016 * *------------------------------------------------------------------------- */ -const H5std_string DSET_NBIT_NAME("nbit_dataset"); +const H5std_string DSET_NBIT_NAME("nbit_dataset"); const hsize_t DIM1 = 2; const hsize_t DIM2 = 5; static herr_t test_nbit_compression(H5File& file) @@ -787,101 +787,101 @@ static herr_t test_nbit_compression(H5File& file) try { - // Define datatypes of members of compound datatype - IntType i_type(PredType::NATIVE_INT); - IntType c_type(PredType::NATIVE_CHAR); - IntType s_type(PredType::NATIVE_SHORT); - - // Create a dataset compound datatype - CompType cmpd(sizeof(s1_t)); - cmpd.insertMember("i", HOFFSET(s1_t, i), i_type); - cmpd.insertMember("c", HOFFSET(s1_t, c), c_type); - cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); - - // Create a memory compound datatype - CompType mem_cmpd(sizeof(s1_t)); - mem_cmpd.insertMember("i", HOFFSET(s1_t, i), i_type); - mem_cmpd.insertMember("c", HOFFSET(s1_t, c), c_type); - mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); - - // Set order of dataset compound datatype - //cmpd.setOrder(H5T_ORDER_BE); only for atomic type? - - // Create the data space - DataSpace space(2, size); - - // Use nbit filter - DSetCreatPropList dscreat; - dscreat.setChunk(2, chunk_size); - dscreat.setNbit(); - - // Create the dataset - DataSet dataset(file.createDataSet(DSET_NBIT_NAME, cmpd, space, dscreat)); - - // Initialize data, assuming size of long long >= size of member datatypes - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - orig_data[i][j].i = static_cast(i * j); - orig_data[i][j].c = static_cast('a' + i); - orig_data[i][j].s = static_cast(i + j); - - // Some even-numbered integer values are negative - if ((i*size[1]+j+1)%2 == 0) { - orig_data[i][j].i = -orig_data[i][j].i; - orig_data[i][j].s = static_cast(-orig_data[i][j].s); - } - } - - // Write to the dataset - dataset.write(static_cast(orig_data), mem_cmpd); - - // Read the dataset back */ - dataset.read(static_cast(new_data), mem_cmpd); - - // Check that the values read are the same as the values written. - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - if((new_data[i][j].i != orig_data[i][j].i) || - (new_data[i][j].c != orig_data[i][j].c) || - (new_data[i][j].s != orig_data[i][j].s)) - { - H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", static_cast(i), static_cast(j)); - } + // Define datatypes of members of compound datatype + IntType i_type(PredType::NATIVE_INT); + IntType c_type(PredType::NATIVE_CHAR); + IntType s_type(PredType::NATIVE_SHORT); + + // Create a dataset compound datatype + CompType cmpd(sizeof(s1_t)); + cmpd.insertMember("i", HOFFSET(s1_t, i), i_type); + cmpd.insertMember("c", HOFFSET(s1_t, c), c_type); + cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); + + // Create a memory compound datatype + CompType mem_cmpd(sizeof(s1_t)); + mem_cmpd.insertMember("i", HOFFSET(s1_t, i), i_type); + mem_cmpd.insertMember("c", HOFFSET(s1_t, c), c_type); + mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); + + // Set order of dataset compound datatype + //cmpd.setOrder(H5T_ORDER_BE); only for atomic type? + + // Create the data space + DataSpace space(2, size); + + // Use nbit filter + DSetCreatPropList dscreat; + dscreat.setChunk(2, chunk_size); + dscreat.setNbit(); + + // Create the dataset + DataSet dataset(file.createDataSet(DSET_NBIT_NAME, cmpd, space, dscreat)); + + // Initialize data, assuming size of long long >= size of member datatypes + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + orig_data[i][j].i = static_cast(i * j); + orig_data[i][j].c = static_cast('a' + i); + orig_data[i][j].s = static_cast(i + j); + + // Some even-numbered integer values are negative + if ((i*size[1]+j+1)%2 == 0) { + orig_data[i][j].i = -orig_data[i][j].i; + orig_data[i][j].s = static_cast(-orig_data[i][j].s); + } + } + + // Write to the dataset + dataset.write(static_cast(orig_data), mem_cmpd); + + // Read the dataset back */ + dataset.read(static_cast(new_data), mem_cmpd); + + // Check that the values read are the same as the values written. + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + if((new_data[i][j].i != orig_data[i][j].i) || + (new_data[i][j].c != orig_data[i][j].c) || + (new_data[i][j].s != orig_data[i][j].s)) + { + H5_FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", static_cast(i), static_cast(j)); + } } - PASSED(); - return 0; + PASSED(); + return 0; } // end try block // catch all dataset, file, space, and plist exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - return -1; + return -1; } } // test_nbit_compression /*------------------------------------------------------------------------- - * Function: test_multiopen + * Function: test_multiopen * - * Purpose: Tests that a bug no longer exists. If a dataset is opened - * twice and one of the handles is used to extend the dataset, - * then the other handle should return the new size when - * queried. + * Purpose Tests that a bug no longer exists. If a dataset is opened + * twice and one of the handles is used to extend the dataset, + * then the other handle should return the new size when + * queried. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Saturday, February 17, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Saturday, February 17, 2001 * * Modifications: * @@ -896,74 +896,75 @@ test_multiopen (H5File& file) DataSpace* space = NULL; try { - // Create a dataset creation property list - DSetCreatPropList dcpl; + // Create a dataset creation property list + DSetCreatPropList dcpl; - // Set chunk size to given size - hsize_t cur_size[1] = {10}; - dcpl.setChunk (1, cur_size); + // Set chunk size to given size + hsize_t cur_size[1] = {10}; + dcpl.setChunk (1, cur_size); - // Create a simple data space with unlimited size - hsize_t max_size[1] = {H5S_UNLIMITED}; - space = new DataSpace (1, cur_size, max_size); + // Create a simple data space with unlimited size + hsize_t max_size[1] = {H5S_UNLIMITED}; + space = new DataSpace (1, cur_size, max_size); - // Create first dataset - DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl); + // Create first dataset + DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl); - // Open again the first dataset from the file to another DataSet object. - DataSet dset2 = file.openDataSet ("multiopen"); + // Open again the first dataset from the file to another DataSet object. + DataSet dset2 = file.openDataSet ("multiopen"); - // Relieve the dataspace - delete space; - space = NULL; + // Relieve the dataspace + delete space; + space = NULL; - // Extend the dimensionality of the first dataset - cur_size[0] = 20; - dset1.extend (cur_size); + // Extend the dimensionality of the first dataset + cur_size[0] = 20; + dset1.extend (cur_size); - // Get the size from the second handle - space = new DataSpace (dset2.getSpace()); + // Get the size from the second handle + space = new DataSpace (dset2.getSpace()); - hsize_t tmp_size[1]; - space->getSimpleExtentDims (tmp_size); - if (cur_size[0]!=tmp_size[0]) - { - cerr << " Got " << static_cast(tmp_size[0]) << " instead of " - << static_cast(cur_size[0]) << "!" << endl; - throw Exception("test_multiopen", "Failed in multi-open with extending"); - } + hsize_t tmp_size[1]; + space->getSimpleExtentDims (tmp_size); + if (cur_size[0]!=tmp_size[0]) + { + cerr << " Got " << static_cast(tmp_size[0]) + << " instead of " << static_cast(cur_size[0]) + << "!" << endl; + throw Exception("test_multiopen", "Failed in multi-open with extending"); + } - // clean up and return with success - delete space; - PASSED(); - return 0; + // clean up and return with success + delete space; + PASSED(); + return 0; } // end try block // catch all dataset, file, space, and plist exceptions catch (Exception& E) { - cerr << " FAILED" << endl; - cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; - // clean up and return with failure - if (space != NULL) - delete space; - return -1; + // clean up and return with failure + if (space != NULL) + delete space; + return -1; } } // test_multiopen /*------------------------------------------------------------------------- - * Function: test_types + * Function: test_types * - * Purpose: Test various types - should be moved to dtypes.cpp + * Purpose Test various types - should be moved to dtypes.cpp * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * February 17, 2001 + * Programmer Binh-Minh Ribler (using C version) + * February 17, 2001 * * Modifications: * @@ -974,239 +975,238 @@ test_types(H5File& file) { SUBTEST("Various datatypes"); - size_t i; + size_t i; DataSet* dset = NULL; try { - // Create a group in the file that was passed in from the caller - Group grp = file.createGroup ("typetests"); - - /* bitfield_1 */ - unsigned char buf[32]; - hsize_t nelmts = sizeof(buf); - DataType type; - try { // block of bitfield_1 - // test copying a predefined type - type.copy (PredType::STD_B8LE); - - // Test copying a user-defined type using DataType::copy - DataType copied_type; - copied_type.copy(type); - - // Test copying a user-defined type using DataType::operator= - DataType another_copied_type; - another_copied_type = type; - - // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); - DataType generic_type; - generic_type = orig_int; - - // Test copying an integer predefined type - IntType new_int_type(PredType::STD_B8LE); - - // Test copying an int predefined type using DataType::operator= - IntType another_int_type; - another_int_type = new_int_type; - - DataSpace space (1, &nelmts); - dset = new DataSet(grp.createDataSet("bitfield_1", type, space)); - - // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); - - // Write data from buf using all default dataspaces and property list - dset->write (buf, type); - - // no failure in bitfield_1, close this dataset - delete dset; - } // end try block of bitfield_1 - - // catch exceptions thrown in try block of bitfield_1 - catch (Exception& E) - { - cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; - if (dset != NULL) - delete dset; - return -1; - } - - /* bitfield_2 */ - nelmts = sizeof(buf)/2; - try { // bitfield_2 block - type.copy (PredType::STD_B16LE); - DataSpace space (1, &nelmts); - dset = new DataSet(grp.createDataSet("bitfield_2", type, space)); - - // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); - - // Write data from buf using all default dataspaces and property - // list; if writing fails, deallocate dset and return. - dset->write (buf, type); - - // no failure in bitfield_2, close this dataset and reset for - // variable reuse - delete dset; - dset = NULL; - } // end try block of bitfield_2 - - // catch exceptions thrown in try block of bitfield_2 - catch (Exception& E) - { - cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; - if (dset != NULL) - delete dset; - throw E; // propagate the exception - } - - /* opaque_1 */ - DataType* optype = NULL; - try { // opaque_1 block - optype = new DataType(H5T_OPAQUE, 1); - nelmts = sizeof(buf); - DataSpace space (1, &nelmts); - optype->setTag ("testing 1-byte opaque type"); - dset = new DataSet(grp.createDataSet("opaque_1", *optype, space)); - - // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); - - // Write data from buf using all default dataspaces and property - // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); - - // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; - } // end try block of opaque_1 - - // catch exceptions thrown in try block of opaque_1 - catch (Exception& E) - { - cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; - if (dset != NULL) - delete dset; - if (optype != NULL) - delete optype; - throw E; // propagate the exception - } - - /* opaque_2 */ - try { // block opaque_2 - nelmts = sizeof(buf)/4; - DataSpace space (1, &nelmts); - optype = new DataType(H5T_OPAQUE, 4); - optype->setTag ("testing 4-byte opaque type"); - dset = new DataSet(grp.createDataSet("opaque_2", *optype, space)); - - // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); - - // Write data from buf using all default dataspaces and property - // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); - - // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; - } //end try block of opaque_2 - - // catch exceptions thrown in try block of opaque_2 - catch (Exception& E) - { - cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; - if (dset != NULL) - delete dset; - if (optype != NULL) - delete optype; - throw E; // propagate the exception - } - - PASSED(); - return 0; + // Create a group in the file that was passed in from the caller + Group grp = file.createGroup ("typetests"); + + /* bitfield_1 */ + unsigned char buf[32]; + hsize_t nelmts = sizeof(buf); + DataType type; + try { // block of bitfield_1 + // test copying a predefined type + type.copy (PredType::STD_B8LE); + + // Test copying a user-defined type using DataType::copy + DataType copied_type; + copied_type.copy(type); + + // Test copying a user-defined type using DataType::operator= + DataType another_copied_type; + another_copied_type = type; + + // Test copying a user-defined int type using DataType::operator= + IntType orig_int(PredType::STD_B8LE); + DataType generic_type; + generic_type = orig_int; + + // Test copying an integer predefined type + IntType new_int_type(PredType::STD_B8LE); + + // Test copying an int predefined type using DataType::operator= + IntType another_int_type; + another_int_type = new_int_type; + + DataSpace space (1, &nelmts); + dset = new DataSet(grp.createDataSet("bitfield_1", type, space)); + + // Fill buffer + for (i=0; i(0xff) ^ static_cast(i); + + // Write data from buf using all default dataspaces and property list + dset->write (buf, type); + + // no failure in bitfield_1, close this dataset + delete dset; + } // end try block of bitfield_1 + + // catch exceptions thrown in try block of bitfield_1 + catch (Exception& E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << "bitfield_1: " << E.getFuncName() + << " - " << E.getDetailMsg() << " >>>" << endl << endl; + if (dset != NULL) + delete dset; + return -1; + } + + /* bitfield_2 */ + nelmts = sizeof(buf)/2; + try { // bitfield_2 block + type.copy (PredType::STD_B16LE); + DataSpace space (1, &nelmts); + dset = new DataSet(grp.createDataSet("bitfield_2", type, space)); + + // Fill buffer + for (i=0; i(0xff) ^ static_cast(i); + + // Write data from buf using all default dataspaces and property + // list; if writing fails, deallocate dset and return. + dset->write (buf, type); + + // no failure in bitfield_2, close this dataset and reset for + // variable reuse + delete dset; + dset = NULL; + } // end try block of bitfield_2 + + // catch exceptions thrown in try block of bitfield_2 + catch (Exception& E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << "bitfield_2: " << E.getFuncName() + << " - " << E.getDetailMsg() << " >>>" << endl << endl; + if (dset != NULL) + delete dset; + throw E; // propagate the exception + } + + /* opaque_1 */ + DataType* optype = NULL; + try { // opaque_1 block + optype = new DataType(H5T_OPAQUE, 1); + nelmts = sizeof(buf); + DataSpace space (1, &nelmts); + optype->setTag ("testing 1-byte opaque type"); + dset = new DataSet(grp.createDataSet("opaque_1", *optype, space)); + + // Fill buffer + for (i=0; i(0xff) ^ static_cast(i); + + // Write data from buf using all default dataspaces and property + // list; if writing fails, deallocate dset and return. + dset->write (buf, *optype); + + // no failure in opaque_1 + delete dset; dset = NULL; + delete optype; optype = NULL; + } // end try block of opaque_1 + + // catch exceptions thrown in try block of opaque_1 + catch (Exception& E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << "opaque_1: " << E.getFuncName() + << " - " << E.getDetailMsg() << " >>>" << endl << endl; + if (dset != NULL) + delete dset; + if (optype != NULL) + delete optype; + throw E; // propagate the exception + } + + /* opaque_2 */ + try { // block opaque_2 + nelmts = sizeof(buf)/4; + DataSpace space (1, &nelmts); + optype = new DataType(H5T_OPAQUE, 4); + optype->setTag ("testing 4-byte opaque type"); + dset = new DataSet(grp.createDataSet("opaque_2", *optype, space)); + + // Fill buffer + for (i=0; i(0xff) ^ static_cast(i); + + // Write data from buf using all default dataspaces and property + // list; if writing fails, deallocate dset and return. + dset->write (buf, *optype); + + // no failure in opaque_1 + delete dset; dset = NULL; + delete optype; optype = NULL; + } //end try block of opaque_2 + + // catch exceptions thrown in try block of opaque_2 + catch (Exception& E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << "opaque_2: " << E.getFuncName() + << " - " << E.getDetailMsg() << " >>>" << endl << endl; + if (dset != NULL) + delete dset; + if (optype != NULL) + delete optype; + throw E; // propagate the exception + } + + PASSED(); + return 0; } // end top try block catch (Exception& E) { - return -1; + return -1; } } // test_types /*------------------------------------------------------------------------- - * Function: test_dset + * Function: test_dset * - * Purpose: Tests the dataset interface (H5D) + * Purpose Tests the dataset interface (H5D) * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 + * Programmer Binh-Minh Ribler (using C version) + * Friday, January 5, 2001 * * Modifications: - * Nov 12, 01: - * - moved h5_cleanup to outside of try block because - * dataset.h5 cannot be removed until "file" is out of - * scope and dataset.h5 is closed. - * Feb 20, 05: - * - cleanup_dsets took care of the cleanup now. + * Nov 12, 01: + * - moved h5_cleanup to outside of try block because + * dataset.h5 cannot be removed until "file" is out of + * scope and dataset.h5 is closed. + * Feb 20, 05: + * - cleanup_dsets took care of the cleanup now. * *------------------------------------------------------------------------- */ extern "C" void test_dset() { - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - - int nerrors=0; // keep track of number of failures occurr + int nerrors=0; // keep track of number of failures occur try { - // Use the file access template id to create a file access prop. - // list object to pass in H5File::H5File - FileAccPropList fapl(fapl_id); + // Use the file access template id to create a file access prop. + // list object to pass in H5File::H5File + FileAccPropList fapl(fapl_id); - H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - // Cause the library to emit initial messages - Group grp = file.createGroup( "emit diagnostics", 0); - grp.setComment("Causes diagnostic messages to be emitted"); + // Cause the library to emit initial messages + Group grp = file.createGroup( "emit diagnostics", 0); + grp.setComment("Causes diagnostic messages to be emitted"); - nerrors += test_create(file) < 0 ? 1:0; - nerrors += test_simple_io(file) < 0 ? 1:0; - nerrors += test_tconv(file) < 0 ? 1:0; - nerrors += test_compression(file) < 0 ? 1:0; - nerrors += test_nbit_compression(file) < 0 ? 1:0; - nerrors += test_multiopen (file) < 0 ? 1:0; - nerrors += test_types(file) < 0 ? 1:0; + nerrors += test_create(file) < 0 ? 1:0; + nerrors += test_simple_io(file) < 0 ? 1:0; + nerrors += test_tconv(file) < 0 ? 1:0; + nerrors += test_compression(file) < 0 ? 1:0; + nerrors += test_nbit_compression(file) < 0 ? 1:0; + nerrors += test_multiopen (file) < 0 ? 1:0; + nerrors += test_types(file) < 0 ? 1:0; - // Close group "emit diagnostics". - grp.close(); + // Close group "emit diagnostics". + grp.close(); - // Close the file before testing data size. - file.close(); + // Close the file before testing data size. + file.close(); - nerrors += test_datasize(fapl) <0 ? 1:0; + nerrors += test_datasize(fapl) <0 ? 1:0; } catch (Exception& E) { - test_report(nerrors, H5std_string(" Dataset")); + test_report(nerrors, H5std_string(" Dataset")); } // Clean up data file @@ -1216,11 +1216,11 @@ void test_dset() /*------------------------------------------------------------------------- * Function: cleanup_dsets * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: (use C version) + * Programmer (use C version) * * Modifications: * diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index 95d29a8..cf7fc2c 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -37,18 +37,18 @@ using namespace H5; #include "h5cpputil.h" // C++ utilility header file /*------------------------------------------------------------------------- - * Function: test_report + * Function: test_report * - * Purpose: Prints out the number of errors for the tests indicated - * by 'testname,' if there were any failures occurred. If - * no failure, test_report prints out the tests passed message. + * Purpose Prints out the number of errors for the tests indicated + * by 'testname,' if there were any failures occurred. If + * no failure, test_report prints out the tests passed message. * - * Return: if any failure has occurred: 1 + * Return if any failure has occurred: 1 * - * if no failure occurs: 0 + * if no failure occurs: 0 * - * Programmer: Binh-Minh Ribler (using C code segment for reporting tests) - * Friday, February 6, 2001 + * Programmer Binh-Minh Ribler (using C code segment for reporting tests) + * Friday, February 6, 2001 * * Modifications: * @@ -59,12 +59,12 @@ int test_report( int nerrors, const H5std_string& testname ) if (nerrors) { nerrors = MAX(1, nerrors); - if (1 == nerrors) - cerr << "***** " << nerrors << testname - << " TEST FAILED! *****" << endl; - else - cerr << "***** " << nerrors << testname - << " TESTS FAILED! *****" << endl; + if (1 == nerrors) + cerr << "***** " << nerrors << testname + << " TEST FAILED! *****" << endl; + else + cerr << "***** " << nerrors << testname + << " TESTS FAILED! *****" << endl; return 1; } else @@ -75,68 +75,68 @@ int test_report( int nerrors, const H5std_string& testname ) } /*------------------------------------------------------------------------- - * Function: issue_fail_msg + * Function: issue_fail_msg * - * Purpose: Displays that a function has failed with its location. + * Purpose Displays that a function has failed with its location. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (copied and modified macro CHECK from C) - * Monday, December 20, 2004 + * Programmer Binh-Minh Ribler (copied and modified macro CHECK from C) + * Monday, December 20, 2004 * *------------------------------------------------------------------------- */ void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message) + const char* message) { if (GetTestVerbosity()>=VERBO_HI) { - cerr << endl; + cerr << endl; cerr << ">>> FAILED in " << where << " at line " << line << " in " << file_name << " - " << message << endl << endl; } } /*------------------------------------------------------------------------- - * Function: issue_fail_msg + * Function: issue_fail_msg * - * Purpose: Displays that a function has failed with its location. + * Purpose Displays that a function has failed with its location. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (copied and modified macro CHECK from C) - * Monday, December 20, 2004 + * Programmer Binh-Minh Ribler (copied and modified macro CHECK from C) + * Monday, December 20, 2004 * *------------------------------------------------------------------------- */ void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message) + const char* func_name, const char* message) { if (GetTestVerbosity()>=VERBO_HI) { - cerr << endl; + cerr << endl; cerr << ">>> FAILED in " << where << ": " << func_name << endl << - " at line " << line << " in " << file_name << endl << - " C library detail: " << message << endl << endl; + " at line " << line << " in " << file_name << endl << + " C library detail: " << message << endl << endl; } } /*------------------------------------------------------------------------- - * Function: check_values + * Function: check_values * - * Purpose: Checks a read value against the written value. If they are - * different, the function will print out a message and the - * different values. This function is made to reuse the code - * segment that is used in various places throughout - * the test code. Where the C version of this code segment - * "goto error," this function will return -1. + * Purpose Checks a read value against the written value. If they are + * different, the function will print out a message and the + * different values. This function is made to reuse the code + * segment that is used in various places throughout + * the test code. Where the C version of this code segment + * "goto error," this function will return -1. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C code segment for checking values) - * Friday, February 6, 2001 + * Programmer Binh-Minh Ribler (using C code segment for checking values) + * Friday, February 6, 2001 * * Modifications: * @@ -146,26 +146,26 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) { if (apoint != acheck) { - cerr << " Read different values than written.\n" << endl; - cerr << " At index " << static_cast(i) << "," << - static_cast(j) << endl; - return -1; + cerr << " Read different values than written.\n" << endl; + cerr << " At index " << static_cast(i) << "," << + static_cast(j) << endl; + return -1; } return 0; } // check_values /*------------------------------------------------------------------------- - * Function: check_values + * Function: check_values * - * Purpose: Checks a char string pointer for NULL. If it is NULL, - * the function will print out a message + * Purpose Checks a char string pointer for NULL. If it is NULL, + * the function will print out a message * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler (using C code segment for checking values) - * Friday, September 16, 2016 + * Programmer Binh-Minh Ribler (using C code segment for checking values) + * Friday, September 16, 2016 * *------------------------------------------------------------------------- */ @@ -173,26 +173,26 @@ void check_values(const char *value, const char* msg, int line, const char* file { if (value == NULL) { - cerr << endl; + cerr << endl; cerr << "*** ERROR: " << msg << ", at line " << line << endl; - IncTestNumErrs(); - throw TestFailedException(file_name, msg); + IncTestNumErrs(); + throw TestFailedException(file_name, msg); } } /*------------------------------------------------------------------------- - * Function: verify_val (const char*, const char*,...) + * Function: verify_val (const char*, const char*,...) * - * Purpose: Compares two character strings. If they are - * different, the function will print out a message and the - * different values. + * Purpose Compares two character strings. If they are + * different, the function will print out a message and the + * different values. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * May 2, 2010 + * Programmer Binh-Minh Ribler + * May 2, 2010 * * Modifications: * @@ -225,12 +225,12 @@ InvalidActionException::InvalidActionException():Exception(){} //-------------------------------------------------------------------------- // Function: InvalidActionException overloaded constructor // -// Purpose: Creates an InvalidActionException with the name of the function, +// Purpose Creates an InvalidActionException with the name of the function, // which the failure should have occurred but didn't, and a -// message explaining why it should fail. +// message explaining why it should fail. // Parameters -// func - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} @@ -247,12 +247,12 @@ TestFailedException::TestFailedException():Exception(){} //-------------------------------------------------------------------------- // Function: TestFailedException overloaded constructor // -// Purpose: Creates an TestFailedException with the name of the function, +// Purpose Creates an TestFailedException with the name of the function, // which the failure should have occurred but didn't, and a -// message explaining why it should fail. +// message explaining why it should fail. // Parameters -// func - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index f8aaec7..7f92e60 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -37,22 +37,22 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck); void check_values(const char *value, const char* msg, int line, const char* file_name); int test_report (int, const H5std_string&); void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message=""); + const char* message=""); void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message); + const char* func_name, const char* message); class InvalidActionException : public Exception { public: - InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - InvalidActionException(); - virtual ~InvalidActionException() throw(); + InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + InvalidActionException(); + virtual ~InvalidActionException() throw(); }; class TestFailedException : public Exception { public: - TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - TestFailedException(); - virtual ~TestFailedException() throw(); + TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + TestFailedException(); + virtual ~TestFailedException() throw(); }; // Overloaded/Template functions to verify values and display proper info @@ -65,18 +65,18 @@ template { if (GetTestVerbosity()>=VERBO_HI) { - cerr << endl; + cerr << endl; cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + << " in " << file_name << " had value " << x << endl; } if (x != value) { - cerr << endl; + cerr << endl; cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; - IncTestNumErrs(); - throw TestFailedException(where, ""); + << value << ", but is " << x << " at line " << line + << " in " << file_name << endl; + IncTestNumErrs(); + throw TestFailedException(where, ""); } } @@ -85,12 +85,12 @@ template { if (x != value) { - cerr << endl; + cerr << endl; cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << endl; - IncTestNumErrs(); - throw TestFailedException(file_name, msg); + << ": " << msg << " different: " << x << ", should be " << value + << endl; + IncTestNumErrs(); + throw TestFailedException(file_name, msg); } } @@ -99,17 +99,17 @@ template { if (GetTestVerbosity()>=VERBO_HI) { - cerr << endl; + cerr << endl; cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + << " in " << file_name << " had value " << x << endl; } if (x == value) { - cerr << endl; + cerr << endl; cerr << "*** UNEXPECTED VALUE from " << where << " should not be " - << value << " at line " << line << " in " << file_name << endl; - IncTestNumErrs(); - throw TestFailedException(where, ""); + << value << " at line " << line << " in " << file_name << endl; + IncTestNumErrs(); + throw TestFailedException(where, ""); } } @@ -118,10 +118,10 @@ template { if (x == value) { - cerr << endl; + cerr << endl; cerr << "*** Function " << msg << " FAILED at line " << line << endl; - IncTestNumErrs(); - throw TestFailedException(file_name, msg); + IncTestNumErrs(); + throw TestFailedException(file_name, msg); } } @@ -130,12 +130,12 @@ template { if (x == value) { - cerr << endl; - cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << " (epsilon=" << epsilon << ")" << endl; - IncTestNumErrs(); - throw TestFailedException(file_name, msg); + cerr << endl; + cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line + << ": " << msg << " different: " << x << ", should be " << value + << " (epsilon=" << epsilon << ")" << endl; + IncTestNumErrs(); + throw TestFailedException(file_name, msg); } } diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index f10016f..490772f 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -53,12 +53,12 @@ typedef enum int_t { /*------------------------------------------------------------------------- * Function: test_array_compound_array * - * Purpose: Tests 1-D array of compound datatypes (with array fields) + * Purpose Tests 1-D array of compound datatypes (with array fields) * - * Return: None. + * Return None. * - * Programmer: Binh-Minh Ribler (using C version) - * January, 2016 + * Programmer Binh-Minh Ribler (using C version) + * January, 2016 * * Modifications: * @@ -76,7 +76,7 @@ static void test_array_compound_array() hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; int nmemb; // Number of compound members - int ii; // counting variables + int ii; // counting variables hsize_t idxi, idxj, idxk; // dimension indicing variables H5T_class_t mclass; // Datatype class for field @@ -85,193 +85,193 @@ static void test_array_compound_array() for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = idxi * 10 + idxj; for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { + { float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; - } + } } // end for try { - // Create File - H5File file1(FILENAME, H5F_ACC_TRUNC); + // Create File + H5File file1(FILENAME, H5F_ACC_TRUNC); - // Create dataspace for datasets - DataSpace space(SPACE1_RANK, sdims1, NULL); + // Create dataspace for datasets + DataSpace space(SPACE1_RANK, sdims1, NULL); - /* - * Create an array datatype of compounds, arrtype. Each compound - * datatype, comptype, contains an integer and an array of floats, - * arrfltype. - */ + /* + * Create an array datatype of compounds, arrtype. Each compound + * datatype, comptype, contains an integer and an array of floats, + * arrfltype. + */ - // Create a compound datatype - CompType comptype(sizeof(s1_t)); + // Create a compound datatype + CompType comptype(sizeof(s1_t)); - // Insert integer field - comptype.insertMember("i", HOFFSET(s1_t, i), PredType::NATIVE_INT); + // Insert integer field + comptype.insertMember("i", HOFFSET(s1_t, i), PredType::NATIVE_INT); - // Create an array of floats datatype - ArrayType arrfltype(PredType::NATIVE_FLOAT, ARRAY1_RANK, tdims1); + // Create an array of floats datatype + ArrayType arrfltype(PredType::NATIVE_FLOAT, ARRAY1_RANK, tdims1); - // Insert float array field - comptype.insertMember("f", HOFFSET(s1_t, f), arrfltype); + // Insert float array field + comptype.insertMember("f", HOFFSET(s1_t, f), arrfltype); - // Close array of floats field datatype - arrfltype.close(); + // Close array of floats field datatype + arrfltype.close(); - // Create an array datatype of the compound datatype - ArrayType arrtype(comptype, ARRAY1_RANK, tdims1); + // Create an array datatype of the compound datatype + ArrayType arrtype(comptype, ARRAY1_RANK, tdims1); - // Close compound datatype comptype - comptype.close(); + // Close compound datatype comptype + comptype.close(); - // Create a dataset - DataSet dataset = file1.createDataSet("Dataset1", arrtype, space); + // Create a dataset + DataSet dataset = file1.createDataSet("Dataset1", arrtype, space); - // Write dataset to disk - dataset.write(wdata, arrtype); + // Write dataset to disk + dataset.write(wdata, arrtype); - // Test opening ArrayType with opening constructor (Dec 2016) + // Test opening ArrayType with opening constructor (Dec 2016) - // Commit the arrtype to give it a name - arrtype.commit(file1, ARRAYTYPE_NAME); + // Commit the arrtype to give it a name + arrtype.commit(file1, ARRAYTYPE_NAME); - // Close it, then re-open with the opening constructor - arrtype.close(); - ArrayType named_type(file1, ARRAYTYPE_NAME); + // Close it, then re-open with the opening constructor + arrtype.close(); + ArrayType named_type(file1, ARRAYTYPE_NAME); - // Get and verify the type's name - H5std_string type_name = named_type.getObjName(); - verify_val(type_name, ARRAYTYPE_NAME, "DataType::getObjName tests constructor", __LINE__, __FILE__); - named_type.close(); + // Get and verify the type's name + H5std_string type_name = named_type.getObjName(); + verify_val(type_name, ARRAYTYPE_NAME, "DataType::getObjName tests constructor", __LINE__, __FILE__); + named_type.close(); - // Close all - dataset.close(); - space.close(); - file1.close(); + // Close all + dataset.close(); + space.close(); + file1.close(); - // Re-open file - file1.openFile(FILENAME, H5F_ACC_RDONLY); + // Re-open file + file1.openFile(FILENAME, H5F_ACC_RDONLY); - // Open the dataset - dataset = file1.openDataSet("Dataset1"); + // Open the dataset + dataset = file1.openDataSet("Dataset1"); - /* - * Check the datatype array of compounds - */ + /* + * Check the datatype array of compounds + */ - // Verify that it is an array of compounds - DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + // Verify that it is an array of compounds + DataType dstype = dataset.getDataType(); + mclass = dstype.getClass(); + verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); - dstype.close(); + dstype.close(); - // Get the array datatype to check - ArrayType atype_check = dataset.getArrayType(); + // Get the array datatype to check + ArrayType atype_check = dataset.getArrayType(); - // Check the array rank - int ndims = atype_check.getArrayNDims(); - verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); + // Check the array rank + int ndims = atype_check.getArrayNDims(); + verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); - // Get the array dimensions - hsize_t rdims1[H5S_MAX_RANK]; - atype_check.getArrayDims(rdims1); + // Get the array dimensions + hsize_t rdims1[H5S_MAX_RANK]; + atype_check.getArrayDims(rdims1); - // Check the array dimensions - for (ii =0; ii FP_EPSILON) - verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__); + // Read attribute information + float read_data2=0.0; // Buffer for reading 1st attribute + ds_attr.read(PredType::NATIVE_FLOAT,&read_data2); + if (HDfabs(read_data2 - attr_data5) > FP_EPSILON) + verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__); - // Get the dataspace of the attribute - DataSpace att_space = ds_attr.getSpace(); + // Get the dataspace of the attribute + DataSpace att_space = ds_attr.getSpace(); - // Make certain the dataspace is scalar - H5S_class_t space_type = att_space.getSimpleExtentType(); - verify_val(space_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); + // Make certain the dataspace is scalar + H5S_class_t space_type = att_space.getSimpleExtentType(); + verify_val(space_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_scalar_read() @@ -877,65 +877,65 @@ static void test_attr_mult_write() SUBTEST("Multiple Attribute Writing Functions"); try { - // Create file - H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC); + // Create file + H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC); - // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - DataSpace ds_space (SPACE1_RANK, dims1); + // Create dataspace for dataset + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + DataSpace ds_space (SPACE1_RANK, dims1); - // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); + // Create a dataset + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); - // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR1_DIM1}; - DataSpace att_space (ATTR1_RANK, dims2); + // Create dataspace for 1st attribute + hsize_t dims2[] = {ATTR1_DIM1}; + DataSpace att_space (ATTR1_RANK, dims2); - // Create 1st attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + // Create 1st attribute for the dataset + Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); - // Write attribute information - ds_attr.write (PredType::NATIVE_INT, attr_data1); + // Write attribute information + ds_attr.write (PredType::NATIVE_INT, attr_data1); - // Create dataspace for 2nd attribute - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - DataSpace att2_space (ATTR2_RANK, dims3); + // Create dataspace for 2nd attribute + hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; + DataSpace att2_space (ATTR2_RANK, dims3); - // Create 2nd attribute for the dataset - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space); + // Create 2nd attribute for the dataset + Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space); - // Write 2nd attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data2); + // Write 2nd attribute information + ds_attr2.write (PredType::NATIVE_INT, attr_data2); - // Create dataspace for 3rd attribute - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - DataSpace att3_space (ATTR3_RANK, dims4); + // Create dataspace for 3rd attribute + hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; + DataSpace att3_space (ATTR3_RANK, dims4); - // Create 3rd attribute for the dataset - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + // Create 3rd attribute for the dataset + Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); - // Try creating an attribute that already exists. This should fail - // since two attributes cannot have the same name. If an exception - // is not thrown for this action by createAttribute, then throw an - // invalid action exception. - try { - Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + // Try creating an attribute that already exists. This should fail + // since two attributes cannot have the same name. If an exception + // is not thrown for this action by createAttribute, then throw an + // invalid action exception. + try { + Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); - // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); - } - catch (AttributeIException& E) // catching invalid creating attribute + // continuation here, that means no exception has been thrown + throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); + } + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected - // Write 3rd attribute information - ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); + // Write 3rd attribute information + ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); - PASSED(); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_mult_write() @@ -951,39 +951,39 @@ static void test_attr_mult_read() double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute hsize_t i,j,k; - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Reading Functions"); try { - // Open file - H5File fid1(FILE_MULTI, H5F_ACC_RDWR); + // Open file + H5File fid1(FILE_MULTI, H5F_ACC_RDWR); - // Open the dataset - DataSet dataset = fid1.openDataSet(DSET1_NAME); + // Open the dataset + DataSet dataset = fid1.openDataSet(DSET1_NAME); - // Verify the correct number of attributes - int num_attrs = dataset.getNumAttrs(); - verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__); + // Verify the correct number of attributes + int num_attrs = dataset.getNumAttrs(); + verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__); - // Open 1st attribute for the dataset - Attribute attr = dataset.openAttribute((unsigned)0); + // Open 1st attribute for the dataset + Attribute attr = dataset.openAttribute((unsigned)0); - /* Verify Dataspace */ + /* Verify Dataspace */ - // Get the dataspace of the attribute - DataSpace space = attr.getSpace(); + // Get the dataspace of the attribute + DataSpace space = attr.getSpace(); - // Get the rank of the dataspace and verify it - int rank = space.getSimpleExtentNdims(); - verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + // Get the rank of the dataspace and verify it + int rank = space.getSimpleExtentNdims(); + verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - // Get the dims of the dataspace and verify them - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - int ndims = space.getSimpleExtentDims(dims); - if ((long)dims[0] != (long)ATTR1_DIM1) - TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); + // Get the dims of the dataspace and verify them + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + int ndims = space.getSimpleExtentDims(dims); + if ((long)dims[0] != (long)ATTR1_DIM1) + TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); - /* Verify Datatype */ + /* Verify Datatype */ // Get the class of the datatype that is used by attr H5T_class_t type_class = attr.getTypeClass(); @@ -991,51 +991,51 @@ static void test_attr_mult_read() // Verify that the type is of integer datatype verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); - // Get the integer datatype + // Get the integer datatype IntType i_type1 = attr.getIntType(); - // Get and verify the order of this type - H5T_order_t order = i_type1.getOrder(); - verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); + // Get and verify the order of this type + H5T_order_t order = i_type1.getOrder(); + verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); - // Get and verify the size of this type - size_t size = i_type1.getSize(); - verify_val(size, PredType::NATIVE_INT.getSize(), "DataType::getSize", __LINE__, __FILE__); + // Get and verify the size of this type + size_t size = i_type1.getSize(); + verify_val(size, PredType::NATIVE_INT.getSize(), "DataType::getSize", __LINE__, __FILE__); - // Read attribute information - attr.read(PredType::NATIVE_INT, read_data1); + // Read attribute information + attr.read(PredType::NATIVE_INT, read_data1); - // Verify values read in - for(i=0; iopenAttribute(ATTR1_NAME)); + // Open attribute + Attribute *attr2 = new Attribute (dset2->openAttribute(ATTR1_NAME)); - // Read data from the attribute - attr2->read(PredType::NATIVE_INT, &rdata); - verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); + // Read data from the attribute + attr2->read(PredType::NATIVE_INT, &rdata); + verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); - // Close attribute and dataset - delete attr2; - delete dset2; + // Close attribute and dataset + delete attr2; + delete dset2; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } // end of second enclosing + } // end of second enclosing - // Unlink the dataset - fid1.unlink(DSET1_NAME); + // Unlink the dataset + fid1.unlink(DSET1_NAME); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Unlink the named datatype - fid1.unlink(TYPE1_NAME); + // Unlink the named datatype + fid1.unlink(TYPE1_NAME); - // Close file - fid1.close(); + // Close file + fid1.close(); - // Check size of file - filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT); - verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); + // Check size of file + filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT); + verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dtype_shared() @@ -1424,116 +1424,116 @@ static void test_string_attr() SUBTEST("I/O on FL and VL String Attributes"); try { - // Create file - H5File fid1(FILE_BASIC, H5F_ACC_RDWR); - - // - // Fixed-lenth string attributes - // - // Create a fixed-length string datatype to refer to. - StrType fls_type(0, ATTR_LEN); - - // Open the root group. - Group root = fid1.openGroup("/"); - - // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); - - /* Test Attribute::write(...,const void *buf) with Fixed len string */ - - // Create an attribute for the root group. - Attribute gr_flattr1 = root.createAttribute(ATTR1_FL_STR_NAME, fls_type, att_space); - - // Write data to the attribute. - gr_flattr1.write(fls_type, ATTRSTR_DATA.c_str()); - - /* Test Attribute::write(...,const H5std_string& strg) with FL string */ - - // Create an attribute for the root group. - Attribute gr_flattr2 = root.createAttribute(ATTR2_FL_STR_NAME, fls_type, att_space); - - // Write data to the attribute. - gr_flattr2.write(fls_type, ATTRSTR_DATA); - - /* Test Attribute::read(...,void *buf) with FL string */ - - // Read and verify the attribute string as a string of chars. - char flstring_att_check[ATTR_LEN]; - gr_flattr1.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); - - // Read and verify the attribute string as a string of chars; buffer - // is dynamically allocated. - size_t attr_size = gr_flattr1.getInMemDataSize(); - char *fl_dyn_string_att_check; - fl_dyn_string_att_check = new char[attr_size+1]; - gr_flattr1.read(fls_type, fl_dyn_string_att_check); - if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); - delete []fl_dyn_string_att_check; - - /* Test Attribute::read(...,H5std_string& strg) with FL string */ - - // Read and verify the attribute string as an std::string. - H5std_string read_flstr1; - gr_flattr1.read(fls_type, read_flstr1); - if (read_flstr1 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); - - // Read and verify the attribute string as a string of chars. - HDstrcpy(flstring_att_check, ""); - gr_flattr2.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); - - /* Test Attribute::read(...,H5std_string& strg) with FL string */ - - // Read and verify the attribute string as an std::string. - H5std_string read_flstr2; - gr_flattr2.read(fls_type, read_flstr2); - if (read_flstr2 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); - - // - // Variable-lenth string attributes - // - // Create a variable length string datatype to refer to. - StrType vls_type(0, H5T_VARIABLE); - - // Create an attribute for the root group. - Attribute gr_vlattr = root.createAttribute(ATTR_VL_STR_NAME, vls_type, att_space); - - // Write data to the attribute. - gr_vlattr.write(vls_type, ATTRSTR_DATA); - - /* Test Attribute::read(...,void *buf) with Variable len string */ - // Read and verify the attribute string as a string of chars. - char *string_att_check; - gr_vlattr.read(vls_type, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); - HDfree(string_att_check); - - /* Test Attribute::read(...,H5std_string& strg) with VL string */ - // Read and verify the attribute string as an std::string. - H5std_string read_str; - gr_vlattr.read(vls_type, read_str); - if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); - PASSED(); + // Create file + H5File fid1(FILE_BASIC, H5F_ACC_RDWR); + + // + // Fixed-lenth string attributes + // + // Create a fixed-length string datatype to refer to. + StrType fls_type(0, ATTR_LEN); + + // Open the root group. + Group root = fid1.openGroup("/"); + + // Create dataspace for the attribute. + DataSpace att_space (H5S_SCALAR); + + /* Test Attribute::write(...,const void *buf) with Fixed len string */ + + // Create an attribute for the root group. + Attribute gr_flattr1 = root.createAttribute(ATTR1_FL_STR_NAME, fls_type, att_space); + + // Write data to the attribute. + gr_flattr1.write(fls_type, ATTRSTR_DATA.c_str()); + + /* Test Attribute::write(...,const H5std_string& strg) with FL string */ + + // Create an attribute for the root group. + Attribute gr_flattr2 = root.createAttribute(ATTR2_FL_STR_NAME, fls_type, att_space); + + // Write data to the attribute. + gr_flattr2.write(fls_type, ATTRSTR_DATA); + + /* Test Attribute::read(...,void *buf) with FL string */ + + // Read and verify the attribute string as a string of chars. + char flstring_att_check[ATTR_LEN]; + gr_flattr1.read(fls_type, flstring_att_check); + if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + + // Read and verify the attribute string as a string of chars; buffer + // is dynamically allocated. + size_t attr_size = gr_flattr1.getInMemDataSize(); + char *fl_dyn_string_att_check; + fl_dyn_string_att_check = new char[attr_size+1]; + gr_flattr1.read(fls_type, fl_dyn_string_att_check); + if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); + delete []fl_dyn_string_att_check; + + /* Test Attribute::read(...,H5std_string& strg) with FL string */ + + // Read and verify the attribute string as an std::string. + H5std_string read_flstr1; + gr_flattr1.read(fls_type, read_flstr1); + if (read_flstr1 != ATTRSTR_DATA) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); + + // Read and verify the attribute string as a string of chars. + HDstrcpy(flstring_att_check, ""); + gr_flattr2.read(fls_type, flstring_att_check); + if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + + /* Test Attribute::read(...,H5std_string& strg) with FL string */ + + // Read and verify the attribute string as an std::string. + H5std_string read_flstr2; + gr_flattr2.read(fls_type, read_flstr2); + if (read_flstr2 != ATTRSTR_DATA) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); + + // + // Variable-lenth string attributes + // + // Create a variable length string datatype to refer to. + StrType vls_type(0, H5T_VARIABLE); + + // Create an attribute for the root group. + Attribute gr_vlattr = root.createAttribute(ATTR_VL_STR_NAME, vls_type, att_space); + + // Write data to the attribute. + gr_vlattr.write(vls_type, ATTRSTR_DATA); + + /* Test Attribute::read(...,void *buf) with Variable len string */ + // Read and verify the attribute string as a string of chars. + char *string_att_check; + gr_vlattr.read(vls_type, &string_att_check); + if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + HDfree(string_att_check); + + /* Test Attribute::read(...,H5std_string& strg) with VL string */ + // Read and verify the attribute string as an std::string. + H5std_string read_str; + gr_vlattr.read(vls_type, read_str); + if (read_str != ATTRSTR_DATA) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_string_attr() /**************************************************************** ** ** test_attr_exists(): Test checking for attribute existence. -** (additional attrExists tests are in test_attr_rename()) +** (additional attrExists tests are in test_attr_rename()) ** ****************************************************************/ static void test_attr_exists() @@ -1542,40 +1542,40 @@ static void test_attr_exists() SUBTEST("Check Attribute Existence"); try { - // Open file. - H5File fid1(FILE_BASIC, H5F_ACC_RDWR); + // Open file. + H5File fid1(FILE_BASIC, H5F_ACC_RDWR); - // Open the root group. - Group root = fid1.openGroup("/"); + // Open the root group. + Group root = fid1.openGroup("/"); - // Check for existence of attribute - bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME); - if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); + // Check for existence of attribute + bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME); + if (attr_exists == false) + throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); - // Check for existence of attribute - attr_exists = fid1.attrExists(FATTR1_NAME); - if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not"); + // Check for existence of attribute + attr_exists = fid1.attrExists(FATTR1_NAME); + if (attr_exists == false) + throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not"); - // Open a group. - Group group = fid1.openGroup(GROUP1_NAME); + // Open a group. + Group group = fid1.openGroup(GROUP1_NAME); - // Check for existence of attribute - attr_exists = group.attrExists(ATTR2_NAME); - if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not"); + // Check for existence of attribute + attr_exists = group.attrExists(ATTR2_NAME); + if (attr_exists == false) + throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not"); - PASSED(); + PASSED(); } // end try block catch (InvalidActionException& E) { - issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } catch (Exception& E) { - issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_exists() @@ -1591,100 +1591,100 @@ const unsigned MAX_COMPACT_DEF = 8; const unsigned MIN_DENSE_DEF = 6; static void test_attr_dense_create(FileCreatPropList& fcpl, - FileAccPropList& fapl) + FileAccPropList& fapl) { // Output message about test being performed SUBTEST("Dense Attribute Storage Creation"); try { - // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + // Create file + H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); - // Close file - fid1.close(); + // Close file + fid1.close(); - // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file - empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); - if (empty_filesize < 0) + // Get size of file + h5_stat_size_t empty_filesize; // Size of empty file + empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); - // Re-open file - fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); + // Re-open file + fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); - // Create dataspace for dataset - DataSpace ds_space(H5S_SCALAR); + // Create dataspace for dataset + DataSpace ds_space(H5S_SCALAR); - // Create dataset creation property list. - DSetCreatPropList dcpl; + // Create dataset creation property list. + DSetCreatPropList dcpl; - // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); + // Create a dataset + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); - unsigned max_compact = 0, min_dense = 0; + unsigned max_compact = 0, min_dense = 0; - // Retrieve limits for compact/dense attribute storage - dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + // Retrieve limits for compact/dense attribute storage + dcpl.getAttrPhaseChange(max_compact, min_dense); + verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - // Set new compact/dense attribute storage limits to some random numbers - dcpl.setAttrPhaseChange(7, 5); + // Set new compact/dense attribute storage limits to some random numbers + dcpl.setAttrPhaseChange(7, 5); - // Retrieve limits for compact/dense attribute storage and verify them - dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, static_cast(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, static_cast(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + // Retrieve limits for compact/dense attribute storage and verify them + dcpl.getAttrPhaseChange(max_compact, min_dense); + verify_val(max_compact, static_cast(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, static_cast(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - // Close property list - dcpl.close(); + // Close property list + dcpl.close(); - // H5O_is_attr_dense_test - un-usable + // H5O_is_attr_dense_test - un-usable - // Add attributes, until just before converting to dense storage - char attr_name[NAME_BUF_SIZE]; - unsigned attr_num; - for (attr_num = 0; attr_num < max_compact; attr_num++) - { - // Create attribute - sprintf(attr_name, "attr %02u", attr_num); - Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + // Add attributes, until just before converting to dense storage + char attr_name[NAME_BUF_SIZE]; + unsigned attr_num; + for (attr_num = 0; attr_num < max_compact; attr_num++) + { + // Create attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); - // Write data to the attribute - attr.write(PredType::NATIVE_UINT, &attr_num); - } // end for + // Write data to the attribute + attr.write(PredType::NATIVE_UINT, &attr_num); + } // end for - // H5O_is_attr_dense_test - un-usable + // H5O_is_attr_dense_test - un-usable - { // Add one more attribute, to push into "dense" storage + { // Add one more attribute, to push into "dense" storage - // Create another attribute - sprintf(attr_name, "attr %02u", attr_num); - Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + // Create another attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); - // Write data to the attribute - attr.write(PredType::NATIVE_UINT, &attr_num); - } + // Write data to the attribute + attr.write(PredType::NATIVE_UINT, &attr_num); + } - // Attempt to add attribute again, which should fail - try - { - // Create another attribute - sprintf(attr_name, "attr %02u", attr_num); - Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + // Attempt to add attribute again, which should fail + try + { + // Create another attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); - // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); - } - catch (AttributeIException& E) // catching invalid action + // continuation here, that means no exception has been thrown + throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); + } + catch (AttributeIException& E) // catching invalid action {} // do nothing, exception expected - PASSED(); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dense_create() @@ -1695,81 +1695,81 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, ** ****************************************************************/ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, - FileAccPropList& fapl) + FileAccPropList& fapl) { // Output message about test being performed SUBTEST("Basic Code for Attributes with Creation Order Info"); try { - // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); - - // Create dataset creation property list. - DSetCreatPropList dcpl; - - // Get creation order indexing on object - unsigned crt_order_flags = 0; - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); - - // Setting invalid combination of a attribute order creation order - // indexing on should fail - try { - dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); - - // continuation here, that means no exception has been thrown - throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); - } - catch (PropListIException& E) // catching invalid action + // Create file + H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + + // Create dataset creation property list. + DSetCreatPropList dcpl; + + // Get creation order indexing on object + unsigned crt_order_flags = 0; + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + + // Setting invalid combination of a attribute order creation order + // indexing on should fail + try { + dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); + + // continuation here, that means no exception has been thrown + throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); + } + catch (PropListIException& E) // catching invalid action {} // do nothing, exception expected - // Set attribute creation order tracking & indexing for object then - // verify them - dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + // Set attribute creation order tracking & indexing for object then + // verify them + dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); - // Create dataspace for dataset - DataSpace ds_space(H5S_SCALAR); + // Create dataspace for dataset + DataSpace ds_space(H5S_SCALAR); - // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); + // Create a dataset + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); - // Close dataspace - ds_space.close(); + // Close dataspace + ds_space.close(); - // Check on dataset's attribute storage status. - // NOTE: Wrappers not available yet (H5O_is_attr_empty_test - // and H5O_is_attr_dense_test) + // Check on dataset's attribute storage status. + // NOTE: Wrappers not available yet (H5O_is_attr_empty_test + // and H5O_is_attr_dense_test) - // Close dataset - dataset.close(); + // Close dataset + dataset.close(); - // Close property list - dcpl.close(); + // Close property list + dcpl.close(); - // Close file - fid1.close(); + // Close file + fid1.close(); - // Re-open file - fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); + // Re-open file + fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); - // Open dataset created previously - dataset = fid1.openDataSet(DSET1_NAME); + // Open dataset created previously + dataset = fid1.openDataSet(DSET1_NAME); - // Retrieve dataset creation property list for the dataset - dcpl = dataset.getCreatePlist(); + // Retrieve dataset creation property list for the dataset + dcpl = dataset.getCreatePlist(); - // Query the attribute creation properties - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + // Query the attribute creation properties + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); - PASSED(); + PASSED(); } // end try block catch (Exception& E) { - issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_corder_create_basic() @@ -1814,42 +1814,42 @@ void test_attr() // Set the file access proplist for the type of format if (new_format) { - MESSAGE(7, ("testing with new file format\n")); - curr_fapl = fapl_new; + MESSAGE(7, ("testing with new file format\n")); + curr_fapl = fapl_new; } else { - MESSAGE(7, ("testing with old file format\n")); - curr_fapl = fapl; + MESSAGE(7, ("testing with old file format\n")); + curr_fapl = fapl; } - test_attr_basic_write(); // Test basic H5A writing code - test_attr_getname(); // Test overloads of Attribute::getName - test_attr_rename(); // Test renaming attribute - test_attr_basic_read(); // Test basic H5A reading code + test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName + test_attr_rename(); // Test renaming attribute + test_attr_basic_read(); // Test basic H5A reading code - test_attr_compound_write(); // Test complex datatype H5A writing code - test_attr_compound_read(); // Test complex datatype H5A reading code + test_attr_compound_write(); // Test complex datatype H5A writing code + test_attr_compound_read(); // Test complex datatype H5A reading code - test_attr_scalar_write(); // Test scalar dataspace H5A writing code - test_attr_scalar_read(); // Test scalar dataspace H5A reading code + test_attr_scalar_write(); // Test scalar dataspace H5A writing code + test_attr_scalar_read(); // Test scalar dataspace H5A reading code - test_attr_mult_write(); // Test writing multiple attributes - test_attr_mult_read(); // Test reading multiple attributes - test_attr_delete(); // Test deleting attributes + test_attr_mult_write(); // Test writing multiple attributes + test_attr_mult_read(); // Test reading multiple attributes + test_attr_delete(); // Test deleting attributes - test_attr_dtype_shared(); // Test using shared datatypes in attributes + test_attr_dtype_shared(); // Test using shared datatypes in attributes - test_string_attr(); // Test read/write string attribute - test_attr_exists(); // Test H5Location::attrExists + test_string_attr(); // Test read/write string attribute + test_attr_exists(); // Test H5Location::attrExists // Test with new format if (new_format) { - // Test dense attribute storage creation + // Test dense attribute storage creation test_attr_dense_create(fcpl, curr_fapl); - // Test create objects with attribute creation info + // Test create objects with attribute creation info test_attr_corder_create_basic(fcpl, curr_fapl); } } // end for @@ -1857,18 +1857,18 @@ void test_attr() catch (Exception& E) { - issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr() /*------------------------------------------------------------------------- - * Function: cleanup_attr + * Function cleanup_attr * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: Albert Cheng + * Programmer Albert Cheng * July 2, 1998 * * Modifications: diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index f49ebb2..ee634c2 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -34,7 +34,7 @@ using namespace H5; #include "h5cpputil.h" // C++ utilility header file /* Number of elements in each test */ -#define NTESTELEM 100000 +#define NTESTELEM 100000 typedef struct complex_t { double re; @@ -45,11 +45,11 @@ typedef struct complex_t { /*------------------------------------------------------------------------- * Function: test_compound_1 * - * Purpose: Tests various things about compound data types. + * Purpose Tests various things about compound data types. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * January, 2007 * * Modifications: @@ -61,13 +61,13 @@ static void test_compound_1() // Output message about test being performed SUBTEST("Compound Data Types"); try { - // Create an empty compound datatype - CompType complex_type(sizeof(complex_t)); + // Create an empty compound datatype + CompType complex_type(sizeof(complex_t)); - // Add a couple of fields - complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE); - complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE); - PASSED(); + // Add a couple of fields + complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE); + complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE); + PASSED(); } // end of try block catch (Exception& E) @@ -78,15 +78,15 @@ static void test_compound_1() /*------------------------------------------------------------------------- - * Function: test_compound_2 + * Function: test_compound_2 * - * Purpose: Tests a compound type conversion where the source and - * destination are the same except for the order of the - * elements. + * Purpose Tests a compound type conversion where the source and + * destination are the same except for the order of the + * elements. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * January, 2007 * * Modifications: @@ -96,100 +96,100 @@ static void test_compound_1() static void test_compound_2() { typedef struct { - int a, b, c[4], d, e; + int a, b, c[4], d, e; } src_typ_t; typedef struct { - int e, d, c[4], b, a; + int e, d, c[4], b, a; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - const int nelmts = NTESTELEM; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + const int nelmts = NTESTELEM; const hsize_t four = 4; - int i; + int i; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); try { - // Sizes should be the same, but be careful just in case - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; - } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); - - // Build hdf5 datatypes - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType st(sizeof(src_typ_t)); - st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); - st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); - st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); - st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); - st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); + // Sizes should be the same, but be careful just in case + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i=0; ia = i*8+0; + s_ptr->b = i*8+1; + s_ptr->c[0] = i*8+2; + s_ptr->c[1] = i*8+3; + s_ptr->c[2] = i*8+4; + s_ptr->c[3] = i*8+5; + s_ptr->d = i*8+6; + s_ptr->e = i*8+7; + } + memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + + // Build hdf5 datatypes + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType st(sizeof(src_typ_t)); + st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); + st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); + st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); + st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); delete array_dt; - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType dt(sizeof(dst_typ_t)); - dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); - dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_INT); - dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); - dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_INT); - dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); - - // Perform the conversion - st.convert(dt, (size_t)nelmts, buf, bkg); - - // Compare results - for (i=0; ia != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { - H5_FAILED(); - cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - } - } - // Release resources - HDfree(buf); - HDfree(bkg); - HDfree(orig); - s_ptr = NULL; - d_ptr = NULL; - st.close(); - dt.close(); - PASSED(); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType dt(sizeof(dst_typ_t)); + dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); + dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_INT); + dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); + dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_INT); + dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); + + // Perform the conversion + st.convert(dt, (size_t)nelmts, buf, bkg); + + // Compare results + for (i=0; ia != d_ptr->a || + s_ptr->b != d_ptr->b || + s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || + s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || + s_ptr->e != d_ptr->e) { + H5_FAILED(); + cerr << " i=" << i << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b + << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," + << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" + << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b + << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," + << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" + << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; + } + } + // Release resources + HDfree(buf); + HDfree(bkg); + HDfree(orig); + s_ptr = NULL; + d_ptr = NULL; + st.close(); + dt.close(); + PASSED(); } // end of try block catch (Exception& E) @@ -203,15 +203,15 @@ static void test_compound_2() /*------------------------------------------------------------------------- - * Function: test_compound_3 + * Function: test_compound_3 * - * Purpose: Tests compound conversions where the source and destination - * are the same except the destination is missing a couple - * members which appear in the source. + * Purpose Tests compound conversions where the source and destination + * are the same except the destination is missing a couple + * members which appear in the source. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * January, 2007 * * Modifications: @@ -221,16 +221,16 @@ static void test_compound_2() static void test_compound_3() { typedef struct { - int a, b, c[4], d, e; + int a, b, c[4], d, e; } src_typ_t; typedef struct { - int a, c[4], e; + int a, c[4], e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType* array_dt = NULL; @@ -238,85 +238,85 @@ static void test_compound_3() // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); try { - /* Initialize */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; - } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); - - /* Build hdf5 datatypes */ - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType st(sizeof(src_typ_t)); - st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); - st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); - st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); - st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); - st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); + /* Initialize */ + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i=0; ia = i*8+0; + s_ptr->b = i*8+1; + s_ptr->c[0] = i*8+2; + s_ptr->c[1] = i*8+3; + s_ptr->c[2] = i*8+4; + s_ptr->c[3] = i*8+5; + s_ptr->d = i*8+6; + s_ptr->e = i*8+7; + } + memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + + /* Build hdf5 datatypes */ + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType st(sizeof(src_typ_t)); + st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); + st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); + st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); + st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); delete array_dt; - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType dt(sizeof(dst_typ_t)); - dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); - dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); - dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); - - /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); - - /* Compare results */ - for (i=0; ia != d_ptr->a || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->e != d_ptr->e) { - H5_FAILED(); - cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a - << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" - << d_ptr->e << "}" << endl; - } // if - } // for - - /* Release resources */ - HDfree(buf); - HDfree(bkg); - HDfree(orig); - s_ptr = NULL; - d_ptr = NULL; - st.close(); - dt.close(); - PASSED(); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType dt(sizeof(dst_typ_t)); + dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); + dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); + dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); + + /* Perform the conversion */ + st.convert(dt, (size_t)nelmts, buf, bkg); + + /* Compare results */ + for (i=0; ia != d_ptr->a || + s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || + s_ptr->c[3] != d_ptr->c[3] || + s_ptr->e != d_ptr->e) { + H5_FAILED(); + cerr << " i=" << i << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b + << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," + << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" + << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a + << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," + << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" + << d_ptr->e << "}" << endl; + } // if + } // for + + /* Release resources */ + HDfree(buf); + HDfree(bkg); + HDfree(orig); + s_ptr = NULL; + d_ptr = NULL; + st.close(); + dt.close(); + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } if(array_dt) @@ -325,16 +325,16 @@ static void test_compound_3() /*------------------------------------------------------------------------- - * Function: test_compound_4 + * Function: test_compound_4 * - * Purpose: Tests compound conversions when the destination has the same - * fields as the source but one or more of the fields are - * smaller. + * Purpose Tests compound conversions when the destination has the same + * fields as the source but one or more of the fields are + * smaller. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -344,20 +344,20 @@ static void test_compound_4() { typedef struct { - int a, b, c[4], d, e; + int a, b, c[4], d, e; } src_typ_t; typedef struct { - short b; - int a, c[4]; - short d; - int e; + short b; + int a, c[4]; + short d; + int e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType* array_dt = NULL; @@ -365,85 +365,85 @@ static void test_compound_4() // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); try { - /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; - s_ptr->e = i*8+7; - } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); - - /* Build hdf5 datatypes */ - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType st(sizeof(src_typ_t)); - st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); - st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); - st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); - st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); - st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); + /* Sizes should be the same, but be careful just in case */ + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i=0; ia = i*8+0; + s_ptr->b = (i*8+1) & 0x7fff; + s_ptr->c[0] = i*8+2; + s_ptr->c[1] = i*8+3; + s_ptr->c[2] = i*8+4; + s_ptr->c[3] = i*8+5; + s_ptr->d = (i*8+6) & 0x7fff; + s_ptr->e = i*8+7; + } + memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + + /* Build hdf5 datatypes */ + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType st(sizeof(src_typ_t)); + st.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_INT); + st.insertMember("c", HOFFSET(src_typ_t, c), *array_dt); + st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); + st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); delete array_dt; - array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); - - // Create an empty compound datatype - CompType dt(sizeof(dst_typ_t)); - dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); - dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_SHORT); - dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); - dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_SHORT); - dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); - array_dt->close(); - - /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); - - /* Compare results */ - for (i=0; ia != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) - { - H5_FAILED(); - cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b - << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" - << d_ptr->d << ", e=" << d_ptr->e << "}" << endl; - } // if - } // for - - /* Release resources */ - HDfree(buf); - HDfree(bkg); - HDfree(orig); - s_ptr = NULL; - d_ptr = NULL; - st.close(); - dt.close(); - PASSED(); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + + // Create an empty compound datatype + CompType dt(sizeof(dst_typ_t)); + dt.insertMember("a", HOFFSET(dst_typ_t, a), PredType::NATIVE_INT); + dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_SHORT); + dt.insertMember("c", HOFFSET(dst_typ_t, c), *array_dt); + dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_SHORT); + dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT); + array_dt->close(); + + /* Perform the conversion */ + st.convert(dt, (size_t)nelmts, buf, bkg); + + /* Compare results */ + for (i=0; ia != d_ptr->a || + s_ptr->b != d_ptr->b || + s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || + s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || + s_ptr->e != d_ptr->e) + { + H5_FAILED(); + cerr << " i=" << i << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b + << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," + << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" + << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b + << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," + << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" + << d_ptr->d << ", e=" << d_ptr->e << "}" << endl; + } // if + } // for + + /* Release resources */ + HDfree(buf); + HDfree(bkg); + HDfree(orig); + s_ptr = NULL; + d_ptr = NULL; + st.close(); + dt.close(); + PASSED(); } // end of try block catch (Exception& E) @@ -457,17 +457,17 @@ static void test_compound_4() /*------------------------------------------------------------------------- - * Function: test_compound_5 + * Function: test_compound_5 * - * Purpose: Many versions of HDF5 have a bug in the optimized compound + * Purpose Many versions of HDF5 have a bug in the optimized compound * datatype conversion function, H5T_conv_struct_opt(), which * is triggered when the top-level type contains a struct * which must undergo a conversion. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -499,55 +499,55 @@ static void test_compound_5() SUBTEST("Optimized Struct Converter"); try { - /* Build datatypes */ - array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); - CompType short_array(4*sizeof(short)); - short_array.insertMember("_", 0, *array_dt); - array_dt->close(); + /* Build datatypes */ + array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); + CompType short_array(4*sizeof(short)); + short_array.insertMember("_", 0, *array_dt); + array_dt->close(); delete array_dt; - CompType int_array(4*sizeof(int)); - array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); - int_array.insertMember("_", 0, *array_dt); - array_dt->close(); - - StrType strg(PredType::C_S1, 16); - CompType src_type(sizeof(src_typ_t)); - src_type.insertMember("name", HOFFSET(src_typ_t, name), strg); - src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT); - src_type.insertMember("coll_ids", HOFFSET(src_typ_t, coll_ids), short_array); - - CompType dst_type(sizeof(dst_typ_t)); - dst_type.insertMember("name", HOFFSET(dst_typ_t, name), strg); - dst_type.insertMember("tdim", HOFFSET(dst_typ_t, tdim), PredType::NATIVE_SHORT); - dst_type.insertMember("coll_ids", HOFFSET(dst_typ_t, coll_ids), int_array); - - /* Convert data */ - memcpy(buf, src, sizeof(src)); - src_type.convert(dst_type, (size_t)2, buf, bkg); - dst = (dst_typ_t*)buf; - - /* Cleanup */ - src_type.close(); - dst_type.close(); - strg.close(); - short_array.close(); - int_array.close(); - - /* Check results */ - if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || - src[1].tdim!=dst[1].tdim || - src[1].coll_ids[0]!=dst[1].coll_ids[0] || - src[1].coll_ids[1]!=dst[1].coll_ids[1] || - src[1].coll_ids[2]!=dst[1].coll_ids[2] || - src[1].coll_ids[3]!=dst[1].coll_ids[3]) - { H5_FAILED(); } - - /* Free memory buffers */ - HDfree(buf); - HDfree(bkg); - dst = NULL; - PASSED(); + CompType int_array(4*sizeof(int)); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); + int_array.insertMember("_", 0, *array_dt); + array_dt->close(); + + StrType strg(PredType::C_S1, 16); + CompType src_type(sizeof(src_typ_t)); + src_type.insertMember("name", HOFFSET(src_typ_t, name), strg); + src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT); + src_type.insertMember("coll_ids", HOFFSET(src_typ_t, coll_ids), short_array); + + CompType dst_type(sizeof(dst_typ_t)); + dst_type.insertMember("name", HOFFSET(dst_typ_t, name), strg); + dst_type.insertMember("tdim", HOFFSET(dst_typ_t, tdim), PredType::NATIVE_SHORT); + dst_type.insertMember("coll_ids", HOFFSET(dst_typ_t, coll_ids), int_array); + + /* Convert data */ + memcpy(buf, src, sizeof(src)); + src_type.convert(dst_type, (size_t)2, buf, bkg); + dst = (dst_typ_t*)buf; + + /* Cleanup */ + src_type.close(); + dst_type.close(); + strg.close(); + short_array.close(); + int_array.close(); + + /* Check results */ + if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || + src[1].tdim!=dst[1].tdim || + src[1].coll_ids[0]!=dst[1].coll_ids[0] || + src[1].coll_ids[1]!=dst[1].coll_ids[1] || + src[1].coll_ids[2]!=dst[1].coll_ids[2] || + src[1].coll_ids[3]!=dst[1].coll_ids[3]) + { H5_FAILED(); } + + /* Free memory buffers */ + HDfree(buf); + HDfree(bkg); + dst = NULL; + PASSED(); } // end of try block catch (Exception& E) @@ -561,16 +561,16 @@ static void test_compound_5() /*------------------------------------------------------------------------- - * Function: test_compound_6 + * Function: test_compound_6 * - * Purpose: Tests compound conversions when the destination has the same - * fields as the source but one or more of the fields are - * larger. + * Purpose Tests compound conversions when the destination has the same + * fields as the source but one or more of the fields are + * larger. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -579,72 +579,72 @@ static void test_compound_5() static void test_compound_6() { typedef struct { - short b; - short d; + short b; + short d; } src_typ_t; typedef struct { - long b; - long d; + long b; + long d; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; // Output message about test being performed SUBTEST("Compound Element Growing"); try { - /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ib = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; - } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); - - /* Build hdf5 datatypes */ - CompType st(sizeof(src_typ_t)); - st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_SHORT); - st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_SHORT); - - CompType dt(sizeof(dst_typ_t)); - dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_LONG); - dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_LONG); - - /* Perform the conversion */ - st.convert(dt, (size_t)nelmts, buf, bkg); - - /* Compare results */ - for (i=0; ib != d_ptr->b || - s_ptr->d != d_ptr->d) - { - H5_FAILED(); - cerr << " i=" << i << endl; - cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d - << "}" << endl; - cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d - << "}" << endl; - } // if - } // for - - /* Release resources */ - HDfree(buf); - HDfree(bkg); - HDfree(orig); - s_ptr = NULL; - d_ptr = NULL; - st.close(); - dt.close(); - PASSED(); + /* Sizes should be the same, but be careful just in case */ + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i=0; ib = (i*8+1) & 0x7fff; + s_ptr->d = (i*8+6) & 0x7fff; + } + memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + + /* Build hdf5 datatypes */ + CompType st(sizeof(src_typ_t)); + st.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_SHORT); + st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_SHORT); + + CompType dt(sizeof(dst_typ_t)); + dt.insertMember("b", HOFFSET(dst_typ_t, b), PredType::NATIVE_LONG); + dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_LONG); + + /* Perform the conversion */ + st.convert(dt, (size_t)nelmts, buf, bkg); + + /* Compare results */ + for (i=0; ib != d_ptr->b || + s_ptr->d != d_ptr->d) + { + H5_FAILED(); + cerr << " i=" << i << endl; + cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d + << "}" << endl; + cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d + << "}" << endl; + } // if + } // for + + /* Release resources */ + HDfree(buf); + HDfree(bkg); + HDfree(orig); + s_ptr = NULL; + d_ptr = NULL; + st.close(); + dt.close(); + PASSED(); } // end of try block catch (Exception& E) @@ -654,15 +654,15 @@ static void test_compound_6() } // test_compound_6() /*------------------------------------------------------------------------- - * Function: test_compound_7 + * Function: test_compound_7 * - * Purpose: Tests inserting fields into compound datatypes when the field - * overlaps the end of the compound datatype. + * Purpose Tests inserting fields into compound datatypes when the field + * overlaps the end of the compound datatype. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -671,47 +671,47 @@ static void test_compound_6() static void test_compound_7() { typedef struct { - int a; - float b; - long c; + int a; + float b; + long c; } s1_typ_t; typedef struct { - int a; - float b; - long c; - double d; + int a; + float b; + long c; + double d; } s2_typ_t; // Output message about test being performed SUBTEST("Compound Element Insertion"); try { - CompType tid1(sizeof(s1_typ_t)); + CompType tid1(sizeof(s1_typ_t)); - tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG); + tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG); - size_t type_size = tid1.getSize(); - verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__); + size_t type_size = tid1.getSize(); + verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__); - CompType tid2; - tid2.copy(tid1); + CompType tid2; + tid2.copy(tid1); - type_size = tid2.getSize(); - verify_val_noteq(type_size, sizeof(s2_typ_t), "DataType::getSize", __LINE__, __FILE__); + type_size = tid2.getSize(); + verify_val_noteq(type_size, sizeof(s2_typ_t), "DataType::getSize", __LINE__, __FILE__); - /* Should not be able to insert field past end of compound datatype */ - try { - tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException& err) {} + /* Should not be able to insert field past end of compound datatype */ + try { + tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); + } catch (DataTypeIException& err) {} - /* Release resources */ - tid1.close(); - tid2.close(); - PASSED(); + /* Release resources */ + tid1.close(); + tid2.close(); + PASSED(); } // end of try block catch (Exception& E) @@ -721,13 +721,13 @@ static void test_compound_7() } // test_compound_7() /*------------------------------------------------------------------------- - * Function: test_compound_set_size + * Function: test_compound_set_size * - * Purpose: Tests member function setSize() on compound datatype + * Purpose Tests member function setSize() on compound datatype * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use partial C version test_ooo_order) + * Programmer Binh-Minh Ribler (use partial C version test_ooo_order) * March, 2014 * * Modifications: @@ -738,7 +738,7 @@ const H5std_string COMPFILE("tcompound_types.h5"); static void test_compound_set_size() { typedef struct { - int a, b, c[4], d, e; + int a, b, c[4], d, e; } src_typ_t; // Output message about test being performed @@ -755,53 +755,53 @@ static void test_compound_set_size() dtype.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); dtype.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); - // Verify that the compound is not packed - // bool packed = dtype.packed(); // not until C library provides API - // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + // Verify that the compound is not packed + // bool packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); - dtype.commit(file, "dtype"); + dtype.commit(file, "dtype"); - // Close the type and file - dtype.close(); - file.close(); + // Close the type and file + dtype.close(); + file.close(); - // Open the file for read/write - file.openFile(COMPFILE, H5F_ACC_RDWR); + // Open the file for read/write + file.openFile(COMPFILE, H5F_ACC_RDWR); - // Open the data type "dtype" - CompType dtype_tmp = file.openCompType("dtype"); + // Open the data type "dtype" + CompType dtype_tmp = file.openCompType("dtype"); - // Make a copy of the data type - dtype.copy(dtype_tmp); + // Make a copy of the data type + dtype.copy(dtype_tmp); - // Verify that the compound is not packed - // packed = dtype_tmp.packed(); // not until C library provides API - // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + // Verify that the compound is not packed + // packed = dtype_tmp.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); - // Expand the type, and verify that it became unpacked - dtype.setSize((size_t)33); - // packed = dtype.packed(); // not until C library provides API - // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + // Expand the type, and verify that it became unpacked + dtype.setSize((size_t)33); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); - // Verify setSize() actually set size - size_t new_size = dtype.getSize(); - verify_val(new_size, (size_t)33, "DataType::getSize", __LINE__, __FILE__); + // Verify setSize() actually set size + size_t new_size = dtype.getSize(); + verify_val(new_size, (size_t)33, "DataType::getSize", __LINE__, __FILE__); - // Shrink the type, and verify that it became packed - dtype.setSize((size_t)32); - // packed = dtype.packed(); // not until C library provides API - // verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__); + // Shrink the type, and verify that it became packed + dtype.setSize((size_t)32); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__); - // Verify setSize() actually set size again - new_size = dtype.getSize(); - verify_val(new_size, (size_t)32, "DataType::getSize", __LINE__, __FILE__); + // Verify setSize() actually set size again + new_size = dtype.getSize(); + verify_val(new_size, (size_t)32, "DataType::getSize", __LINE__, __FILE__); - /* Close types and file */ - dtype_tmp.close(); - dtype.close(); - file.close(); + /* Close types and file */ + dtype_tmp.close(); + dtype.close(); + file.close(); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) @@ -811,14 +811,14 @@ static void test_compound_set_size() } // test_compound_set_size() /*------------------------------------------------------------------------- - * Function: test_compound + * Function: test_compound * - * Purpose: Main compound datatype testing routine + * Purpose Main compound datatype testing routine * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler - * January 2007 + * Programmer Binh-Minh Ribler + * January 2007 * * Modifications: * @@ -830,23 +830,23 @@ void test_compound() // Output message about test being performed MESSAGE(5, ("Testing Compound Data Type operations\n")); - test_compound_1(); // various things about compound data types - test_compound_2(); // compound element reordering - test_compound_3(); // compound datatype subset conversions - test_compound_4(); // compound element shrinking & reordering - test_compound_5(); // optimized struct converter - test_compound_6(); // compound element growing - test_compound_7(); // compound element insertion - test_compound_set_size(); // set size on compound data types + test_compound_1(); // various things about compound data types + test_compound_2(); // compound element reordering + test_compound_3(); // compound datatype subset conversions + test_compound_4(); // compound element shrinking & reordering + test_compound_5(); // optimized struct converter + test_compound_6(); // compound element growing + test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types } // test_compound() /*------------------------------------------------------------------------- - * Function: cleanup_compound + * Function: cleanup_compound * - * Purpose: Cleanup temporary test files - nothing at this time. + * Purpose Cleanup temporary test files - nothing at this time. * - * Return: none + * Return none * * Modifications: * diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index d733ffe..f39694b 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -16,7 +16,7 @@ /***************************************************************************** FILE tdspl.cpp - HDF5 C++ testing the dataset memory and transfer property - list functionality + list functionality ***************************************************************************/ #ifdef OLD_HEADER_FILENAME @@ -45,70 +45,70 @@ static void test_transfplist() SUBTEST("DSetMemXferPropList::set/getDataTransform()"); try { - // Create various data set prop lists and set data transform expression. - DSetMemXferPropList dxpl_c_to_f(c_to_f); - - DSetMemXferPropList dxpl_simple; - dxpl_simple.setDataTransform(simple); - - DSetMemXferPropList dxpl_utrans_inv; - dxpl_utrans_inv.setDataTransform(utrans_inv); - - // - // Make a copy of one of those prop lists then read the data transform - // expression and verify that it's the same as the original. - // - - // Copy the prop list. - DSetMemXferPropList dxpl_c_to_f_copy; - dxpl_c_to_f_copy.copy(dxpl_c_to_f); - - // Find out the length of the transform expression, allocate the buffer - // for it, then read and verify the expression from the copied plist - ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); - char *c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); - HDfree(c_to_f_read); - - // - // Read the expression of each of the prop lists and verify the read - // expression - // - - // Get and verify the expression with: - // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) - tran_len = dxpl_c_to_f.getDataTransform(NULL); - c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); - HDfree(c_to_f_read); - - // Get and verify the expression with: - // H5std_string DSetMemXferPropList::getDataTransform() - H5std_string simple_read = dxpl_simple.getDataTransform(); - verify_val((const char*)simple_read.c_str(), (const char*)simple, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); - - // Get and verify the expression with: - // ssize_t getDataTransform(char* exp, const size_t buf_size) - tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); - char *utrans_inv_read = (char *)HDmalloc(tran_len+1); - HDmemset(utrans_inv_read, 0, tran_len+1); - dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); - verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); - HDfree(utrans_inv_read); - - PASSED(); + // Create various data set prop lists and set data transform expression. + DSetMemXferPropList dxpl_c_to_f(c_to_f); + + DSetMemXferPropList dxpl_simple; + dxpl_simple.setDataTransform(simple); + + DSetMemXferPropList dxpl_utrans_inv; + dxpl_utrans_inv.setDataTransform(utrans_inv); + + // + // Make a copy of one of those prop lists then read the data transform + // expression and verify that it's the same as the original. + // + + // Copy the prop list. + DSetMemXferPropList dxpl_c_to_f_copy; + dxpl_c_to_f_copy.copy(dxpl_c_to_f); + + // Find out the length of the transform expression, allocate the buffer + // for it, then read and verify the expression from the copied plist + ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); + char *c_to_f_read = (char *)HDmalloc(tran_len+1); + HDmemset(c_to_f_read, 0, tran_len+1); + dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); + verify_val((const char*)c_to_f_read, (const char*)c_to_f, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(c_to_f_read); + + // + // Read the expression of each of the prop lists and verify the read + // expression + // + + // Get and verify the expression with: + // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) + tran_len = dxpl_c_to_f.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len+1); + HDmemset(c_to_f_read, 0, tran_len+1); + dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); + verify_val((const char*)c_to_f_read, (const char*)c_to_f, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(c_to_f_read); + + // Get and verify the expression with: + // H5std_string DSetMemXferPropList::getDataTransform() + H5std_string simple_read = dxpl_simple.getDataTransform(); + verify_val((const char*)simple_read.c_str(), (const char*)simple, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + + // Get and verify the expression with: + // ssize_t getDataTransform(char* exp, const size_t buf_size) + tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); + char *utrans_inv_read = (char *)HDmalloc(tran_len+1); + HDmemset(utrans_inv_read, 0, tran_len+1); + dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); + verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(utrans_inv_read); + + PASSED(); } catch (Exception& E) { - issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index 28ede6b..779c931 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -28,16 +28,16 @@ base functionality testing. EXTERNAL ROUTINES/VARIABLES: - TestInit(...) -- Initialize testing framework - TestInfo(...) -- Print test info - AddTest(...) -- Setup a test function and add it to the list of tests - TestParseCmdLine(...) -- Parse command line arguments - PerformTests() -- Perform requested testing - GetTestSummary() -- Retrieve Summary request value - TestSummary() -- Display test summary - GetTestCleanup() -- Retrieve Cleanup request value - TestCleanup() -- Clean up files from testing - GetTestNumErrs() -- Retrieve the number of testing errors + TestInit(...) -- Initialize testing framework + TestInfo(...) -- Print test info + AddTest(...) -- Setup a test function and add it to the list of tests + TestParseCmdLine(...) -- Parse command line arguments + PerformTests() -- Perform requested testing + GetTestSummary() -- Retrieve Summary request value + TestSummary() -- Display test summary + GetTestCleanup() -- Retrieve Cleanup request value + TestCleanup() -- Clean up files from testing + GetTestNumErrs() -- Retrieve the number of testing errors ***************************************************************************/ #ifdef OLD_HEADER_FILENAME @@ -60,47 +60,47 @@ main(int argc, char *argv[]) { try { - // Turn of the auto-printing when failure occurs so that we can - // handle the errors appropriately since sometime failures are - // caused deliberately and expected. - Exception::dontPrint(); - /* Initialize testing framework */ - TestInit(argv[0], NULL, NULL); - - // testing file creation and opening in tfile.cpp - AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL); - // testing dataset functionalities in dset.cpp - AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL); - // testing dataspace functionalities in th5s.cpp - AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); - // testing attribute functionalities in tattr.cpp - AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); - // testing object functionalities in tobject.cpp - AddTest("tobject", test_object, cleanup_object, "Objects", NULL); - // testing reference functionalities in trefer.cpp - AddTest("trefer", test_reference, cleanup_reference, "References", NULL); - // testing variable-length strings in tvlstr.cpp - AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); - AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); - AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); - AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); - AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); - AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); - AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); + // Turn of the auto-printing when failure occurs so that we can + // handle the errors appropriately since sometime failures are + // caused deliberately and expected. + Exception::dontPrint(); + /* Initialize testing framework */ + TestInit(argv[0], NULL, NULL); + + // testing file creation and opening in tfile.cpp + AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL); + // testing dataset functionalities in dset.cpp + AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL); + // testing dataspace functionalities in th5s.cpp + AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); + // testing attribute functionalities in tattr.cpp + AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); + // testing object functionalities in tobject.cpp + AddTest("tobject", test_object, cleanup_object, "Objects", NULL); + // testing reference functionalities in trefer.cpp + AddTest("trefer", test_reference, cleanup_reference, "References", NULL); + // testing variable-length strings in tvlstr.cpp + AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); + AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); + AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); + AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); + AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); + AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); + AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); /* Comment out tests that are not done yet. - BMR, Feb 2001 - AddTest("select", test_select, cleanup_select, "Selections", NULL); - AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); - AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); + AddTest("select", test_select, cleanup_select, "Selections", NULL); + AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); */ - AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); /* - AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); - AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); + AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); Comment out tests that are not done yet */ /* Tentative - BMR 2007/1/12 - AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); + AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); */ } catch (Exception& E) diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 934d6e6..261beab 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -66,20 +66,20 @@ const H5std_string FILE4("tfile4.h5"); /*------------------------------------------------------------------------- * Function: test_file_create * - * Purpose: Test file and template creations + * Purpose Test file and template creations * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * January, 2001 * * Modifications: - * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hsize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * January, 2005: C tests' macro VERIFY casts values to 'long' for all + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hsize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. * *------------------------------------------------------------------------- */ @@ -98,81 +98,81 @@ static void test_file_create() // Setting this to NULL for cleaning up in failure situations H5File* file1 = NULL; try { - // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_EXCL); - - // Try to create the same file with H5F_ACC_TRUNC. This should fail - // because file1 is the same file and is currently open. - try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); - } - catch (FileIException& E) // catch truncating existing file - {} // do nothing, FAIL expected - - // Close file1 - delete file1; - file1 = NULL; - - // Try again with H5F_ACC_EXCL. This should fail because the file - // already exists from the previous steps. - try { - H5File file2(FILE1, H5F_ACC_EXCL); // should throw E - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File constructor", "File already exists."); - } - catch (FileIException& E) // catching creating existing file - {} // do nothing, FAIL expected - - // Test create with H5F_ACC_TRUNC. This will truncate the existing file. - file1 = new H5File (FILE1, H5F_ACC_TRUNC); - - // Try to create first file again. This should fail because file1 - // is the same file and is currently open. - try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); - } - catch (FileIException& E) // catching truncating opened file - {} // do nothing, FAIL expected - - // Try with H5F_ACC_EXCL. This should fail too because the file already - // exists. - try { - H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); - } - catch (FileIException& E) // catching H5F_ACC_EXCL on existing file - {} // do nothing, FAIL expected - - // Get the file-creation template - FileCreatPropList tmpl1 = file1->getCreatePlist(); - - hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); - verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + // Create file FILE1 + file1 = new H5File (FILE1, H5F_ACC_EXCL); + + // Try to create the same file with H5F_ACC_TRUNC. This should fail + // because file1 is the same file and is currently open. + try { + H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); + } + catch (FileIException& E) // catch truncating existing file + {} // do nothing, FAIL expected + + // Close file1 + delete file1; + file1 = NULL; + + // Try again with H5F_ACC_EXCL. This should fail because the file + // already exists from the previous steps. + try { + H5File file2(FILE1, H5F_ACC_EXCL); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "File already exists."); + } + catch (FileIException& E) // catching creating existing file + {} // do nothing, FAIL expected + + // Test create with H5F_ACC_TRUNC. This will truncate the existing file. + file1 = new H5File (FILE1, H5F_ACC_TRUNC); + + // Try to create first file again. This should fail because file1 + // is the same file and is currently open. + try { + H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); + } + catch (FileIException& E) // catching truncating opened file + {} // do nothing, FAIL expected + + // Try with H5F_ACC_EXCL. This should fail too because the file already + // exists. + try { + H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); + } + catch (FileIException& E) // catching H5F_ACC_EXCL on existing file + {} // do nothing, FAIL expected + + // Get the file-creation template + FileCreatPropList tmpl1 = file1->getCreatePlist(); + + hsize_t ublock = tmpl1.getUserblock(); + verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes( parm1, parm2); + verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); unsigned iparm1,iparm2; // file-creation parameters tmpl1.getSymk( iparm1, iparm2); verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - // tmpl1 is automatically closed; if error occurs, it'll be - // caught in the catch block + // tmpl1 is automatically closed; if error occurs, it'll be + // caught in the catch block - // Close first file - delete file1; + // Close first file + delete file1; } catch (InvalidActionException& E) { @@ -184,7 +184,7 @@ static void test_file_create() // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up delete file1; } @@ -193,79 +193,79 @@ static void test_file_create() FileCreatPropList* tmpl1 = NULL; try { - // Create a new file with a non-standard file-creation template - tmpl1 = new FileCreatPropList; + // Create a new file with a non-standard file-creation template + tmpl1 = new FileCreatPropList; - // Set the new file-creation parameters - tmpl1->setUserblock (F2_USERBLOCK_SIZE); - tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE ); - tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K ); + // Set the new file-creation parameters + tmpl1->setUserblock (F2_USERBLOCK_SIZE); + tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE ); + tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K ); - // Try to create second file, with non-standard file-creation template - // params. - H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 ); + // Try to create second file, with non-standard file-creation template + // params. + H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 ); - // Release file-creation template - delete tmpl1; - tmpl1 = NULL; + // Release file-creation template + delete tmpl1; + tmpl1 = NULL; - // Get the file-creation template - tmpl1 = new FileCreatPropList (file2.getCreatePlist()); + // Get the file-creation template + tmpl1 = new FileCreatPropList (file2.getCreatePlist()); - // Get the file-creation parameters - hsize_t ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + // Get the file-creation parameters + hsize_t ublock = tmpl1->getUserblock(); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1->getSizes( parm1, parm2); - verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + size_t parm1, parm2; // file-creation parameters + tmpl1->getSizes( parm1, parm2); + verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters + unsigned iparm1,iparm2; // file-creation parameters tmpl1->getSymk( iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - // Clone the file-creation template - FileCreatPropList tmpl2; - tmpl2.copy (*tmpl1); + // Clone the file-creation template + FileCreatPropList tmpl2; + tmpl2.copy (*tmpl1); - // Release file-creation template - delete tmpl1; - tmpl1 = NULL; + // Release file-creation template + delete tmpl1; + tmpl1 = NULL; - // Set the new file-creation parameter - tmpl2.setUserblock( F3_USERBLOCK_SIZE ); + // Set the new file-creation parameter + tmpl2.setUserblock( F3_USERBLOCK_SIZE ); - // Try to create second file, with non-standard file-creation template - // params - H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 ); + // Try to create second file, with non-standard file-creation template + // params + H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 ); - // Get the file-creation template - tmpl1 = new FileCreatPropList (file3.getCreatePlist()); + // Get the file-creation template + tmpl1 = new FileCreatPropList (file3.getCreatePlist()); - // Get the file-creation parameters - ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + // Get the file-creation parameters + ublock = tmpl1->getUserblock(); + verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - tmpl1->getSizes( parm1, parm2); - verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + tmpl1->getSizes( parm1, parm2); + verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - tmpl1->getSymk( iparm1, iparm2); - verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + tmpl1->getSymk( iparm1, iparm2); + verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - // Release file-creation template - delete tmpl1; - PASSED(); + // Release file-creation template + delete tmpl1; + PASSED(); } // catch all exceptions catch (Exception& E) { - issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); - if (tmpl1 != NULL) // clean up - delete tmpl1; + issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); + if (tmpl1 != NULL) // clean up + delete tmpl1; } } // test_file_create() @@ -273,20 +273,20 @@ static void test_file_create() /*------------------------------------------------------------------------- * Function: test_file_open * - * Purpose: Test file accesses + * Purpose Test file accesses * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * January, 2001 * * Modifications: - * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hsize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * January, 2005: C tests' macro VERIFY casts values to 'long' for all + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hsize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. * *------------------------------------------------------------------------- */ @@ -297,53 +297,53 @@ static void test_file_open() try { - // Open first file - H5File file1 (FILE2, H5F_ACC_RDWR ); + // Open first file + H5File file1 (FILE2, H5F_ACC_RDWR ); - // Get the file-creation template - FileCreatPropList tmpl1 = file1.getCreatePlist(); + // Get the file-creation template + FileCreatPropList tmpl1 = file1.getCreatePlist(); - // Get the file-creation parameters - hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + // Get the file-creation parameters + hsize_t ublock = tmpl1.getUserblock(); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); - verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes( parm1, parm2); + verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); unsigned iparm1,iparm2; // file-creation parameters tmpl1.getSymk( iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - // Test H5File constructor with existing file id - H5File file2(file1.getId()); - file1.close(); + // Test H5File constructor with existing file id + H5File file2(file1.getId()); + file1.close(); - // Try truncating the file, and it should fail because the file is - // still opened with file2. - try { - H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + // Try truncating the file, and it should fail because the file is + // still opened with file2. + try { + H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); - } - catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file - {} // do nothing, FAIL expected + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); + } + catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file + {} // do nothing, FAIL expected - // Now, really close the file. - file2.close(); + // Now, really close the file. + file2.close(); - // Truncating should succeed now. - H5File file3(FILE2, H5F_ACC_TRUNC); + // Truncating should succeed now. + H5File file3(FILE2, H5F_ACC_TRUNC); - // Opening another file to file3 object, FILE2 should be closed, so - // the next attempt to truncate FILE2 should succeed. - file3.openFile(FILE1, H5F_ACC_RDONLY); - H5File file4(FILE2, H5F_ACC_TRUNC); + // Opening another file to file3 object, FILE2 should be closed, so + // the next attempt to truncate FILE2 should succeed. + file3.openFile(FILE1, H5F_ACC_RDONLY); + H5File file4(FILE2, H5F_ACC_TRUNC); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) @@ -356,11 +356,11 @@ static void test_file_open() /*------------------------------------------------------------------------- * Function: test_file_size * - * Purpose: Test file size. + * Purpose Test file size. * - * Return: None + * Return None * - * Programmer: Raymond Lu + * Programmer Raymond Lu * June, 2004 * * Modifications: @@ -372,7 +372,7 @@ static void test_file_size() // Output message about test being performed SUBTEST("File Size"); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template try { @@ -380,13 +380,13 @@ static void test_file_size() // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); - // Set to sec2 driver. Do we want to test other file drivers? + // Set to sec2 driver. Do we want to test other file drivers? // They're not tested in C++. // File drivers seem not implemented. - // fapl.setSec2(); + // fapl.setSec2(); // Create a file - H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Get file size hsize_t file_size = file4.getFileSize(); @@ -395,14 +395,14 @@ static void test_file_size() if (file_size < 1*KB || file_size > 4*KB) issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value"); - // Get the amount of free space in the file - hssize_t free_space = file4.getFreeSpace(); + // Get the amount of free space in the file + hssize_t free_space = file4.getFreeSpace(); - // Check if it's reasonable. It's 0 now. - if (free_space < 0 || free_space > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); + // Check if it's reasonable. It's 0 now. + if (free_space < 0 || free_space > 4*KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) @@ -421,25 +421,25 @@ static void test_file_size() /*------------------------------------------------------------------------- * Function: test_file_name * - * Purpose: Test getting file's name. + * Purpose Test getting file's name. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler + * Programmer Binh-Minh Ribler * July, 2004 * * Modifications: * *------------------------------------------------------------------------- */ -const int RANK = 2; -const int NX = 4; -const int NY = 5; -const H5std_string GROUPNAME ("group"); -const H5std_string DSETNAME ("dataset"); -const H5std_string DATTRNAME ("dataset attribute"); -const H5std_string FATTRNAME ("file attribute"); -const H5std_string DTYPENAME ("compound"); +const int RANK = 2; +const int NX = 4; +const int NY = 5; +const H5std_string GROUPNAME ("group"); +const H5std_string DSETNAME ("dataset"); +const H5std_string DATTRNAME ("dataset attribute"); +const H5std_string FATTRNAME ("file attribute"); +const H5std_string DTYPENAME ("compound"); // Compound datatype typedef struct s1_t { @@ -455,51 +455,51 @@ static void test_file_name() H5std_string file_name; try { // Create a file using default properties. - H5File file4(FILE4, H5F_ACC_TRUNC); + H5File file4(FILE4, H5F_ACC_TRUNC); // Get file name from the file instance. file_name = file4.getFileName(); - verify_val(file_name, FILE4, "H5File::getFileName", __LINE__, __FILE__); + verify_val(file_name, FILE4, "H5File::getFileName", __LINE__, __FILE__); - // Create a group in the root group. - Group group(file4.createGroup(GROUPNAME, 0)); + // Create a group in the root group. + Group group(file4.createGroup(GROUPNAME, 0)); - // Get and verify file name via a group. - file_name = group.getFileName(); - verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); + // Get and verify file name via a group. + file_name = group.getFileName(); + verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); - // Create the data space. - hsize_t dims[RANK] = {NX, NY}; - DataSpace space(RANK, dims); + // Create the data space. + hsize_t dims[RANK] = {NX, NY}; + DataSpace space(RANK, dims); - // Create a new dataset. - DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + // Create a new dataset. + DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); - // Get and verify file name via a dataset. - file_name = dataset.getFileName(); - verify_val(file_name, FILE4, "DataSet::getFileName", __LINE__, __FILE__); + // Get and verify file name via a dataset. + file_name = dataset.getFileName(); + verify_val(file_name, FILE4, "DataSet::getFileName", __LINE__, __FILE__); - // Create an attribute for the dataset. - Attribute attr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); + // Create an attribute for the dataset. + Attribute attr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); - // Get and verify file name via an attribute. - file_name = attr.getFileName(); - verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); + // Get and verify file name via an attribute. + file_name = attr.getFileName(); + verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); - // Create a compound datatype. - CompType comp_type (sizeof(s1_t)); + // Create a compound datatype. + CompType comp_type (sizeof(s1_t)); - // Insert fields. - comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); - comp_type.insertMember("b", HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); + // Insert fields. + comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); + comp_type.insertMember("b", HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); - // Save it on file. - comp_type.commit(file4, DTYPENAME); + // Save it on file. + comp_type.commit(file4, DTYPENAME); - // Get and verify file name via a committed datatype. - comp_type.getFileName(); - verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__); - PASSED(); + // Get and verify file name via a committed datatype. + comp_type.getFileName(); + verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__); + PASSED(); } // end of try block catch (Exception& E) @@ -509,11 +509,11 @@ static void test_file_name() } // test_file_name() -const int RANK1 = 1; -const int ATTR1_DIM1 = 3; -const H5std_string FILE5("tfattrs.h5"); -const H5std_string FATTR1_NAME ("file attribute 1"); -const H5std_string FATTR2_NAME ("file attribute 2"); +const int RANK1 = 1; +const int ATTR1_DIM1 = 3; +const H5std_string FILE5("tfattrs.h5"); +const H5std_string FATTR1_NAME ("file attribute 1"); +const H5std_string FATTR2_NAME ("file attribute 2"); int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute @@ -528,89 +528,89 @@ static void test_file_attribute() H5std_string file_name; try { // Create a file using default properties. - H5File file5(FILE5, H5F_ACC_TRUNC); + H5File file5(FILE5, H5F_ACC_TRUNC); - // Create the data space - hsize_t dims[RANK1] = {ATTR1_DIM1}; - DataSpace space(RANK1, dims); + // Create the data space + hsize_t dims[RANK1] = {ATTR1_DIM1}; + DataSpace space(RANK1, dims); - // Create two attributes for the file - Attribute fattr1(file5.createAttribute(FATTR1_NAME, PredType::NATIVE_FLOAT, space)); - Attribute fattr2(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); + // Create two attributes for the file + Attribute fattr1(file5.createAttribute(FATTR1_NAME, PredType::NATIVE_FLOAT, space)); + Attribute fattr2(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); - fattr2.write(PredType::NATIVE_INT, fattr_data); + fattr2.write(PredType::NATIVE_INT, fattr_data); - try { - // Try to create the same attribute again (should fail) - Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); - } - catch (AttributeIException& E) // catch creating existing attribute - {} // do nothing, FAIL expected + try { + // Try to create the same attribute again (should fail) + Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); + } + catch (AttributeIException& E) // catch creating existing attribute + {} // do nothing, FAIL expected - // Create a new dataset - DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + // Create a new dataset + DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); - // Create an attribute for the dataset - Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); + // Create an attribute for the dataset + Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); - // Write data to the second file attribute - dattr.write(PredType::NATIVE_INT, dattr_data); + // Write data to the second file attribute + dattr.write(PredType::NATIVE_INT, dattr_data); - // Test flushing out the data from the attribute object + // Test flushing out the data from the attribute object dattr.flush(H5F_SCOPE_GLOBAL); - // Get and verify the number of all objects in the file - // Current: 1 file, 2 file attr, 1 ds, and 1 ds attr. - ssize_t num_objs = file5.getObjCount(H5F_OBJ_ALL); - verify_val(num_objs, 5, "H5File::getObjCount", __LINE__, __FILE__); - - num_objs = file5.getObjCount(H5F_OBJ_GROUP); - verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_GROUP)", __LINE__, __FILE__); - num_objs = file5.getObjCount(H5F_OBJ_DATASET); - verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_DATASET)", __LINE__, __FILE__); - num_objs = file5.getObjCount(H5F_OBJ_ATTR); - verify_val(num_objs, 3, "H5File::getObjCount(H5F_OBJ_ATTR)", __LINE__, __FILE__); - num_objs = file5.getObjCount(H5F_OBJ_DATATYPE); - verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_DATATYPE)", __LINE__, __FILE__); - num_objs = file5.getObjCount(H5F_OBJ_FILE); - verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_FILE)", __LINE__, __FILE__); - - // Get the file name using the attributes - H5std_string fname = fattr1.getFileName(); - verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__); - - fname.clear(); - fname = dattr.getFileName(); - verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__); - - // Get the class of a file attribute's datatype - H5T_class_t atclass = fattr1.getTypeClass(); - verify_val(atclass, H5T_FLOAT, "Attribute::getTypeClass()", __LINE__, __FILE__); - - // Get and verify the number of attributes attached to a file - int n_attrs = file5.getNumAttrs(); - verify_val(n_attrs, 2, "H5File::getNumAttrs()", __LINE__, __FILE__); - - // Get and verify the number of attributes attached to a dataset - n_attrs = 0; - n_attrs = dataset.getNumAttrs(); - verify_val(n_attrs, 1, "DataSet::getNumAttrs()", __LINE__, __FILE__); - - // Read back attribute's data - HDmemset(rdata, 0, sizeof(rdata)); + // Get and verify the number of all objects in the file + // Current: 1 file, 2 file attr, 1 ds, and 1 ds attr. + ssize_t num_objs = file5.getObjCount(H5F_OBJ_ALL); + verify_val(num_objs, 5, "H5File::getObjCount", __LINE__, __FILE__); + + num_objs = file5.getObjCount(H5F_OBJ_GROUP); + verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_GROUP)", __LINE__, __FILE__); + num_objs = file5.getObjCount(H5F_OBJ_DATASET); + verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_DATASET)", __LINE__, __FILE__); + num_objs = file5.getObjCount(H5F_OBJ_ATTR); + verify_val(num_objs, 3, "H5File::getObjCount(H5F_OBJ_ATTR)", __LINE__, __FILE__); + num_objs = file5.getObjCount(H5F_OBJ_DATATYPE); + verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_DATATYPE)", __LINE__, __FILE__); + num_objs = file5.getObjCount(H5F_OBJ_FILE); + verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_FILE)", __LINE__, __FILE__); + + // Get the file name using the attributes + H5std_string fname = fattr1.getFileName(); + verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__); + + fname.clear(); + fname = dattr.getFileName(); + verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__); + + // Get the class of a file attribute's datatype + H5T_class_t atclass = fattr1.getTypeClass(); + verify_val(atclass, H5T_FLOAT, "Attribute::getTypeClass()", __LINE__, __FILE__); + + // Get and verify the number of attributes attached to a file + int n_attrs = file5.getNumAttrs(); + verify_val(n_attrs, 2, "H5File::getNumAttrs()", __LINE__, __FILE__); + + // Get and verify the number of attributes attached to a dataset + n_attrs = 0; + n_attrs = dataset.getNumAttrs(); + verify_val(n_attrs, 1, "DataSet::getNumAttrs()", __LINE__, __FILE__); + + // Read back attribute's data + HDmemset(rdata, 0, sizeof(rdata)); dattr.read(PredType::NATIVE_INT, rdata); /* Check results */ for (i = 0; i < ATTR1_DIM1; i++) { if (rdata[i] != dattr_data[i]) { H5_FAILED(); - cerr << endl; + cerr << endl; cerr << "element [" << i << "] is " << rdata[i] << - "but should have been " << dattr_data[i] << endl; + "but should have been " << dattr_data[i] << endl; } } - PASSED(); + PASSED(); } // end of try block catch (Exception& E) @@ -620,28 +620,28 @@ static void test_file_attribute() } // test_file_attribute() -const H5std_string FILE6("tfile5.h5"); -const H5std_string ROOTGROUP("/"); -const H5std_string GROUP1("/G1"); -const H5std_string SUBGROUP3("/G1/G3"); +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); /*------------------------------------------------------------------------- - * Function: test_libver_bounds_real + * Function: test_libver_bounds_real * - * Purpose: Verify that a file created and modified with the - * specified libver bounds has the specified object header - * versions for the right objects. + * Purpose Verify that a file created and modified with the + * specified libver bounds has the specified object header + * versions for the right objects. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * March, 2015 + * Programmer Binh-Minh Ribler (use C version) + * March, 2015 * *------------------------------------------------------------------------- */ static void test_libver_bounds_real( - H5F_libver_t libver_create, unsigned oh_vers_create, - H5F_libver_t libver_mod, unsigned oh_vers_mod) + H5F_libver_t libver_create, unsigned oh_vers_create, + H5F_libver_t libver_mod, unsigned oh_vers_mod) { try { @@ -713,12 +713,12 @@ static void test_libver_bounds_real( * * Function: test_libver_bounds * - * Purpose: Verify that a file created and modified with various - * libver bounds is handled correctly. + * Purpose Verify that a file created and modified with various + * libver bounds is handled correctly. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * March 2015 * *------------------------------------------------------------------------- @@ -735,14 +735,14 @@ static void test_libver_bounds() } /* end test_libver_bounds() */ /*------------------------------------------------------------------------- - * Function: test_commonfg + * Function: test_commonfg * - * Purpose: Verify that H5File works as a root group. + * Purpose Verify that H5File works as a root group. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * March, 2015 + * Programmer Binh-Minh Ribler (use C version) + * March, 2015 * *------------------------------------------------------------------------- */ @@ -753,40 +753,40 @@ static void test_commonfg() try { // Create a file using default properties. - H5File file4(FILE4, H5F_ACC_TRUNC); + H5File file4(FILE4, H5F_ACC_TRUNC); - // Try opening the root group. - Group rootgroup(file4.openGroup(ROOTGROUP)); + // Try opening the root group. + Group rootgroup(file4.openGroup(ROOTGROUP)); - // Create a group in the root group. - Group group(rootgroup.createGroup(GROUPNAME, 0)); + // Create a group in the root group. + Group group(rootgroup.createGroup(GROUPNAME, 0)); - // Create the data space. - hsize_t dims[RANK] = {NX, NY}; - DataSpace space(RANK, dims); + // Create the data space. + hsize_t dims[RANK] = {NX, NY}; + DataSpace space(RANK, dims); - // Create a new dataset. - DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + // Create a new dataset. + DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); - // Get and verify file name via a dataset. - H5std_string file_name = dataset.getFileName(); - verify_val(file_name, FILE4, "DataSet::getFileName", __LINE__, __FILE__); + // Get and verify file name via a dataset. + H5std_string file_name = dataset.getFileName(); + verify_val(file_name, FILE4, "DataSet::getFileName", __LINE__, __FILE__); - // Create an attribute for the dataset. - Attribute attr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); + // Create an attribute for the dataset. + Attribute attr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); - // Get and verify file name via an attribute. - file_name = attr.getFileName(); - verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); + // Get and verify file name via an attribute. + file_name = attr.getFileName(); + verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); - // Create an attribute for the file via root group. - Attribute rootg_attr(rootgroup.createAttribute(FATTRNAME, PredType::NATIVE_INT, space)); + // Create an attribute for the file via root group. + Attribute rootg_attr(rootgroup.createAttribute(FATTRNAME, PredType::NATIVE_INT, space)); - // Get and verify file name via an attribute. - file_name = attr.getFileName(); - verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); + // Get and verify file name via an attribute. + file_name = attr.getFileName(); + verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) @@ -796,19 +796,19 @@ static void test_commonfg() } /* end test_commonfg() */ -const H5std_string FILE7("tfile7.h5"); +const H5std_string FILE7("tfile7.h5"); /*------------------------------------------------------------------------- - * Function: test_file_info + * Function: test_file_info * - * Purpose: Verify that various properties in a file creation property - * lists are stored correctly in the file and can be retrieved - * when the file is re-opened. + * Purpose Verify that various properties in a file creation property + * lists are stored correctly in the file and can be retrieved + * when the file is re-opened. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler - * February, 2017 + * Programmer Binh-Minh Ribler + * February, 2017 * *------------------------------------------------------------------------- */ @@ -817,8 +817,8 @@ static void test_file_info() // Output message about test being performed SUBTEST("File general information"); - hsize_t in_threshold = 2; // Free space section threshold to set */ - hsize_t out_threshold = 0; // Free space section threshold to get */ + hsize_t in_threshold = 2; // Free space section threshold to set */ + hsize_t out_threshold = 0; // Free space section threshold to get */ // File space handling strategy H5F_file_space_type_t in_strategy = H5F_FILE_SPACE_ALL; // File space handling strategy @@ -826,88 +826,88 @@ static void test_file_info() try { // Create a file using default properties. - H5File tempfile(FILE7, H5F_ACC_TRUNC); + H5File tempfile(FILE7, H5F_ACC_TRUNC); - // Get the file's version information. - H5F_info2_t finfo; - tempfile.getFileInfo(finfo); - verify_val(finfo.super.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + // Get the file's version information. + H5F_info2_t finfo; + tempfile.getFileInfo(finfo); + verify_val(finfo.super.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - // Close the file. - tempfile.close(); + // Close the file. + tempfile.close(); - // Create file creation property list. - FileCreatPropList fcpl; + // Create file creation property list. + FileCreatPropList fcpl; - // Set various file information. - fcpl.setUserblock(F2_USERBLOCK_SIZE); - fcpl.setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); - fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); - fcpl.setIstorek(F2_ISTORE); - fcpl.setFileSpace(in_strategy, in_threshold); + // Set various file information. + fcpl.setUserblock(F2_USERBLOCK_SIZE); + fcpl.setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); + fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); + fcpl.setIstorek(F2_ISTORE); + fcpl.setFileSpace(in_strategy, in_threshold); - // Creating a file with the non-default file creation property list - // should create a version 1 superblock + // Creating a file with the non-default file creation property list + // should create a version 1 superblock - // Create file with custom file creation property list. - H5File file7(FILE7, H5F_ACC_TRUNC, fcpl); + // Create file with custom file creation property list. + H5File file7(FILE7, H5F_ACC_TRUNC, fcpl); - // Close the file creation property list. - fcpl.close(); + // Close the file creation property list. + fcpl.close(); - // Get the file's version information. - file7.getFileInfo(finfo); - verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + // Get the file's version information. + file7.getFileInfo(finfo); + verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - // Close the file. - file7.close(); + // Close the file. + file7.close(); - // Re-open the file. - file7.openFile(FILE7, H5F_ACC_RDONLY); + // Re-open the file. + file7.openFile(FILE7, H5F_ACC_RDONLY); - // Get the file's creation property list. - FileCreatPropList fcpl2 = file7.getCreatePlist(); + // Get the file's creation property list. + FileCreatPropList fcpl2 = file7.getCreatePlist(); - // Get the file's version information. - file7.getFileInfo(finfo); - verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + // Get the file's version information. + file7.getFileInfo(finfo); + verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); - // Retrieve the property values & check them. - hsize_t userblock = fcpl2.getUserblock(); - verify_val(userblock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + // Retrieve the property values & check them. + hsize_t userblock = fcpl2.getUserblock(); + verify_val(userblock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t off_size = 0, len_size = 0; - fcpl2.getSizes(off_size, len_size); - verify_val(off_size, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - verify_val(len_size, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + size_t off_size = 0, len_size = 0; + fcpl2.getSizes(off_size, len_size); + verify_val(off_size, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); + verify_val(len_size, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned sym_ik = 0, sym_lk = 0; - fcpl2.getSymk(sym_ik, sym_lk); - verify_val(sym_ik, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - verify_val(sym_lk, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + unsigned sym_ik = 0, sym_lk = 0; + fcpl2.getSymk(sym_ik, sym_lk); + verify_val(sym_ik, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + verify_val(sym_lk, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); - unsigned istore_ik = fcpl2.getIstorek(); - verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__); + unsigned istore_ik = fcpl2.getIstorek(); + verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__); /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes); CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); */ - // Get and verify the file space info from the creation property list */ - out_strategy = fcpl2.getFileSpaceStrategy(); - verify_val(static_cast(out_strategy), static_cast(in_strategy), "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); + // Get and verify the file space info from the creation property list */ + out_strategy = fcpl2.getFileSpaceStrategy(); + verify_val(static_cast(out_strategy), static_cast(in_strategy), "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); - out_threshold = fcpl2.getFileSpaceThreshold(); - verify_val(static_cast(out_threshold), static_cast(in_threshold), "FileCreatPropList::getFileSpaceThreshold", __LINE__, __FILE__); + out_threshold = fcpl2.getFileSpaceThreshold(); + verify_val(static_cast(out_threshold), static_cast(in_threshold), "FileCreatPropList::getFileSpaceThreshold", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) { @@ -918,11 +918,11 @@ static void test_file_info() /*------------------------------------------------------------------------- * Function: test_file * - * Purpose: Main file testing routine + * Purpose Main file testing routine * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) + * Programmer Binh-Minh Ribler (use C version) * January 2001 * * Modifications: @@ -935,25 +935,25 @@ void test_file() // Output message about test being performed MESSAGE(5, ("Testing File I/O Operations\n")); - test_file_create(); // Test file creation (also creation templates) - test_file_open(); // Test file opening - test_file_size(); // Test file size - test_file_name(); // Test getting file's name - test_file_attribute(); // Test file attribute feature - test_libver_bounds(); // Test format version - test_commonfg(); // Test H5File as a root group - test_file_info(); // Test various file info + test_file_create(); // Test file creation (also creation templates) + test_file_open(); // Test file opening + test_file_size(); // Test file size + test_file_name(); // Test getting file's name + test_file_attribute(); // Test file attribute feature + test_libver_bounds(); // Test format version + test_commonfg(); // Test H5File as a root group + test_file_info(); // Test various file info } // test_file() /*------------------------------------------------------------------------- - * Function: cleanup_file + * Function: cleanup_file * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: (use C version) + * Programmer (use C version) * * Modifications: * diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index ee78fe1..19f5b5a 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -33,15 +33,15 @@ using namespace H5; #include "h5test.h" #include "h5cpputil.h" // C++ utilility header file -#define DSET_DIM1 100 -#define DSET_DIM2 200 +#define DSET_DIM1 100 +#define DSET_DIM2 200 #define FILTER_CHUNK_DIM1 2 #define FILTER_CHUNK_DIM2 25 // will do this function later or use it as guideline - BMR - 2007/01/26 #if 0 static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, - int if_fletcher32, int corrupted, hsize_t *dset_size) + int if_fletcher32, int corrupted, hsize_t *dset_size) { cerr << "do nothing right now" << endl; return(0); @@ -58,25 +58,25 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, static size_t filter_bogus(size_t nbytes); /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; /*------------------------------------------------------------------------- * Function: filter_bogus * - * Purpose: A bogus compression method that doesn't do anything. + * Purpose A bogus compression method that doesn't do anything. * - * Return: Success: Data chunk size + * Return Success: Data chunk size * - * Failure: 0 + * Failure: 0 * - * Programmer: Robb Matzke + * Programmer Robb Matzke * Tuesday, April 21, 1998 * * Modifications: @@ -95,17 +95,17 @@ filter_bogus(size_t nbytes) } /*------------------------------------------------------------------------- - * Function: test_null_filter + * Function: test_null_filter * - * Purpose: Test null I/O filter by itself. + * Purpose Test null I/O filter by itself. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version, from dsets.c/test_filters) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version, from dsets.c/test_filters) + * January, 2007 * * Modifications: - * Note: H5Z interface is not implemented yet. + * Note: H5Z interface is not implemented yet. * *------------------------------------------------------------------------- */ @@ -118,25 +118,25 @@ static void test_null_filter() // Output message about test being performed SUBTEST("'Null' filter"); try { - //hsize_t null_size; // Size of dataset with null filter + //hsize_t null_size; // Size of dataset with null filter - // Prepare dataset create property list - DSetCreatPropList dsplist; - dsplist.setChunk(2, chunk_size); + // Prepare dataset create property list + DSetCreatPropList dsplist; + dsplist.setChunk(2, chunk_size); - if (H5Zregister (H5Z_BOGUS)<0) + if (H5Zregister (H5Z_BOGUS)<0) throw Exception("test_null_filter", "H5Zregister failed"); - // Set some pretent filter - dsplist.setFilter(H5Z_FILTER_BOGUS); + // Set some pretent filter + dsplist.setFilter(H5Z_FILTER_BOGUS); - // this function is just a stub right now; will work on it later - BMR - //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) + // this function is just a stub right now; will work on it later - BMR + //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) // throw Exception("test_null_filter", "test_filter_internal failed"); - // Close objects. - dsplist.close(); - PASSED(); + // Close objects. + dsplist.close(); + PASSED(); } // end of try // catch all other exceptions @@ -147,17 +147,17 @@ static void test_null_filter() } // test_null_filter /*------------------------------------------------------------------------- - * Function: test_szip_filter + * Function: test_szip_filter * - * Purpose: Test SZIP filter by itself. + * Purpose Test SZIP filter by itself. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (partly from dsets.c/test_filters) - * January, 2007 + * Programmer Binh-Minh Ribler (partly from dsets.c/test_filters) + * January, 2007 * * Modifications: - * Note: H5Z interface is not implemented yet. + * Note: H5Z interface is not implemented yet. * *------------------------------------------------------------------------- */ @@ -232,7 +232,7 @@ static void test_szip_filter(H5File& file1) delete[] tconv_buf; } // if szip presents else { - SKIPPED(); + SKIPPED(); } #else /* H5_HAVE_FILTER_SZIP */ @@ -266,9 +266,9 @@ void test_filters() H5File file1(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - // Test basic VL string datatype - test_null_filter(); - test_szip_filter(file1); + // Test basic VL string datatype + test_null_filter(); + test_szip_filter(file1); } catch (Exception& E) { @@ -277,13 +277,13 @@ void test_filters() } // test_filters() /*------------------------------------------------------------------------- - * Function: cleanup_filters + * Function: cleanup_filters * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: Quincey Koziol + * Programmer Quincey Koziol * September 10, 1999 * * Modifications: diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index c795c08..a3aafb3 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -35,7 +35,7 @@ using namespace H5; #include "h5test.h" #include "h5cpputil.h" // C++ utilility header file -#include "H5srcdir.h" // srcdir querying header file +#include "H5srcdir.h" // srcdir querying header file const H5std_string TESTFILE("th5s.h5"); const H5std_string DATAFILE("th5s1.h5"); @@ -86,124 +86,123 @@ int space5_data = 7; /*------------------------------------------------------------------------- * - * Function: test_h5s_basic + * Function: test_h5s_basic * - * Purpose: Test basic H5S (dataspace) code + * Purpose Test basic H5S (dataspace) code * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. * April 12, 2011: Raymond Lu - * Starting from the 1.8.7 release, we allow dimension - * size to be zero. So I took out the test against it. + * Starting from the 1.8.7 release, we allow dimension + * size to be zero. So I took out the test against it. *------------------------------------------------------------------------- */ static void test_h5s_basic() { - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, - SPACE2_DIM4}; - hsize_t dims3[H5S_MAX_RANK+1]; - hsize_t tmax[4]; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}; + hsize_t dims3[H5S_MAX_RANK+1]; + hsize_t tmax[4]; // Output message about test being performed SUBTEST("Dataspace Manipulation"); try { - // Create simple dataspace sid1 - DataSpace sid1 (SPACE1_RANK, dims1 ); - - // Get simple extent npoints of the dataspace sid1 and verify it - hssize_t n; // Number of dataspace elements - n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - - // Get the logical rank of dataspace sid1 and verify it - int rank; // Logical rank of dataspace - rank = sid1.getSimpleExtentNdims(); - verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - - // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions - hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); - verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - - // Create simple dataspace sid2 - hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; - DataSpace sid2 (SPACE2_RANK, dims2, max2); - - // Get simple extent npoints of dataspace sid2 and verify it - n = sid2.getSimpleExtentNpoints(); - verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - - // Get the logical rank of dataspace sid2 and verify it - rank = sid2.getSimpleExtentNdims(); - verify_val(rank, SPACE2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - - // Retrieves dimension size and max size of dataspace sid2 and - // verify them - ndims = sid2.getSimpleExtentDims( tdims, tmax ); - verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - - // Check to be sure we can't create a simple data space that has too - // many dimensions. - try { - DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); - } - catch (DataSpaceIException& E) // Simple data space with too many dims - {} // do nothing, exception expected + // Create simple dataspace sid1 + DataSpace sid1 (SPACE1_RANK, dims1 ); + + // Get simple extent npoints of the dataspace sid1 and verify it + hssize_t n; // Number of dataspace elements + n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + + // Get the logical rank of dataspace sid1 and verify it + int rank; // Logical rank of dataspace + rank = sid1.getSimpleExtentNdims(); + verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + + // Retrieves dimension size of dataspace sid1 and verify it + int ndims; // Number of dimensions + hsize_t tdims[4]; // Dimension array to test with + ndims = sid1.getSimpleExtentDims( tdims ); + verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0, + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + + // Create simple dataspace sid2 + hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; + DataSpace sid2 (SPACE2_RANK, dims2, max2); + + // Get simple extent npoints of dataspace sid2 and verify it + n = sid2.getSimpleExtentNpoints(); + verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + + // Get the logical rank of dataspace sid2 and verify it + rank = sid2.getSimpleExtentNdims(); + verify_val(rank, SPACE2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + + // Retrieves dimension size and max size of dataspace sid2 and + // verify them + ndims = sid2.getSimpleExtentDims( tdims, tmax ); + verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0, + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + + // Check to be sure we can't create a simple data space that has too + // many dimensions. + try { + DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); + } + catch (DataSpaceIException& E) // Simple data space with too many dims + {} // do nothing, exception expected /* - * Try reading a file that has been prepared that has a dataset with a - * higher dimensionality than what the library can handle. - * - * If this test fails and the H5S_MAX_RANK variable has changed, follow - * the instructions in space_overflow.c for regenating the th5s.h5 file. - */ - char *tmp_str = new char[TESTFILE.length()+1]; - strcpy(tmp_str, TESTFILE.c_str()); - const char *testfile = H5_get_srcdir_filename(tmp_str); - delete []tmp_str; - - // Create file - H5File fid1(testfile, H5F_ACC_RDONLY); - - // Try to open the dataset that has higher dimensionality than - // what the library can handle and this operation should fail. - try { - DataSet dset1 = fid1.openDataSet( "dset" ); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); - } - catch (FileIException& E) // catching higher dimensionality dataset - {} // do nothing, exception expected + * Try reading a file that has been prepared that has a dataset with a + * higher dimensionality than what the library can handle. + * + * If this test fails and the H5S_MAX_RANK variable has changed, follow + * the instructions in space_overflow.c for regenating the th5s.h5 file. + */ + char *tmp_str = new char[TESTFILE.length()+1]; + strcpy(tmp_str, TESTFILE.c_str()); + const char *testfile = H5_get_srcdir_filename(tmp_str); + delete []tmp_str; + + // Create file + H5File fid1(testfile, H5F_ACC_RDONLY); + + // Try to open the dataset that has higher dimensionality than + // what the library can handle and this operation should fail. + try { + DataSet dset1 = fid1.openDataSet( "dset" ); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); + } + catch (FileIException& E) // catching higher dimensionality dataset + {} // do nothing, exception expected // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure - // in the p_close see how this will handle it. - BMR + // in the p_close see how this will handle it. - BMR - PASSED(); - } // end of try block + PASSED(); + } // end of try block catch (InvalidActionException& E) { @@ -219,22 +218,22 @@ static void test_h5s_basic() /*------------------------------------------------------------------------- * - * Function: test_h5s_scalar_write + * Function: test_h5s_scalar_write * - * Purpose: Test scalar H5S (dataspace) writing code + * Purpose Test scalar H5S (dataspace) writing code * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. *------------------------------------------------------------------------- */ static void test_h5s_scalar_write() @@ -243,124 +242,124 @@ static void test_h5s_scalar_write() SUBTEST("Scalar Dataspace Writing"); try { - // Create file - H5File fid1(DATAFILE, H5F_ACC_TRUNC); + // Create file + H5File fid1(DATAFILE, H5F_ACC_TRUNC); - // Create scalar dataspace - DataSpace sid1(SPACE3_RANK, NULL); + // Create scalar dataspace + DataSpace sid1(SPACE3_RANK, NULL); - //n = H5Sget_simple_extent_npoints(sid1); - hssize_t n; // Number of dataspace elements - n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + //n = H5Sget_simple_extent_npoints(sid1); + hssize_t n; // Number of dataspace elements + n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - int rank; // Logical rank of dataspace - rank = sid1.getSimpleExtentNdims(); - verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + int rank; // Logical rank of dataspace + rank = sid1.getSimpleExtentNdims(); + verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions - hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); - verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + // Retrieves dimension size of dataspace sid1 and verify it + int ndims; // Number of dimensions + hsize_t tdims[4]; // Dimension array to test with + ndims = sid1.getSimpleExtentDims( tdims ); + verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - // Verify extent type - H5S_class_t ext_type; // Extent type - ext_type = sid1.getSimpleExtentType(); - verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); + // Verify extent type + H5S_class_t ext_type; // Extent type + ext_type = sid1.getSimpleExtentType(); + verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); - // Create and write a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); - dataset.write(&space3_data, PredType::NATIVE_UINT); + // Create and write a dataset + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + dataset.write(&space3_data, PredType::NATIVE_UINT); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_h5s_scalar_write() /*------------------------------------------------------------------------- * - * Function: test_h5s_scalar_read + * Function: test_h5s_scalar_read * - * Purpose: Test scalar H5S (dataspace) reading code + * Purpose Test scalar H5S (dataspace) reading code * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. *------------------------------------------------------------------------- */ static void test_h5s_scalar_read() { - hsize_t tdims[4]; // Dimension array to test with + hsize_t tdims[4]; // Dimension array to test with // Output message about test being performed SUBTEST("Scalar Dataspace Reading"); try { - // Open file - H5File fid1(DATAFILE, H5F_ACC_RDWR); + // Open file + H5File fid1(DATAFILE, H5F_ACC_RDWR); - // Create a dataset - DataSet dataset = fid1.openDataSet("Dataset1"); + // Create a dataset + DataSet dataset = fid1.openDataSet("Dataset1"); - DataSpace sid1 = dataset.getSpace(); + DataSpace sid1 = dataset.getSpace(); - // Get the number of dataspace elements - hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + // Get the number of dataspace elements + hssize_t n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - // Get the logical rank of the dataspace - int ndims = sid1.getSimpleExtentNdims(); - verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + // Get the logical rank of the dataspace + int ndims = sid1.getSimpleExtentNdims(); + verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - ndims = sid1.getSimpleExtentDims(tdims); - verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + ndims = sid1.getSimpleExtentDims(tdims); + verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - // Read data back and verify it - unsigned rdata; // Scalar data read in - dataset.read(&rdata, PredType::NATIVE_UINT); - verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__); + // Read data back and verify it + unsigned rdata; // Scalar data read in + dataset.read(&rdata, PredType::NATIVE_UINT); + verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) { - // all the exceptions caused by negative returned values by C APIs - issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); + // all the exceptions caused by negative returned values by C APIs + issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_h5s_scalar_read() /*------------------------------------------------------------------------- * - * Function: test_h5s_null + * Function: test_h5s_null * - * Purpose: Test null H5S (dataspace) code + * Purpose Test null H5S (dataspace) code * - * Return: none + * Return none * - * Programmer: Raymond Lu (using C version) + * Programmer Raymond Lu (using C version) * May 18, 2004 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. *------------------------------------------------------------------------- */ static void test_h5s_null() @@ -369,53 +368,53 @@ static void test_h5s_null() SUBTEST("Null Dataspace Writing"); try { - // Create file - H5File fid1(DATAFILE, H5F_ACC_TRUNC); + // Create file + H5File fid1(DATAFILE, H5F_ACC_TRUNC); - // Create scalar dataspace - DataSpace sid1(H5S_NULL); + // Create scalar dataspace + DataSpace sid1(H5S_NULL); - hssize_t n; // Number of dataspace elements - n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + hssize_t n; // Number of dataspace elements + n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - // Create a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + // Create a dataset + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); // Try to write nothing to the dataset - dataset.write(&space5_data, PredType::NATIVE_INT); + dataset.write(&space5_data, PredType::NATIVE_INT); // Read the data. Make sure no change to the buffer - dataset.read(&space5_data, PredType::NATIVE_INT); - verify_val(space5_data, 7, "DataSet::read", __LINE__, __FILE__); + dataset.read(&space5_data, PredType::NATIVE_INT); + verify_val(space5_data, 7, "DataSet::read", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_h5s_null() /*------------------------------------------------------------------------- * - * Function: test_h5s_compound_scalar_write + * Function: test_h5s_compound_scalar_write * - * Purpose: Test scalar H5S (dataspace) writing for compound - * datatypes + * Purpose Test scalar H5S (dataspace) writing for compound + * datatypes * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. *------------------------------------------------------------------------- */ static void test_h5s_compound_scalar_write() @@ -424,135 +423,135 @@ static void test_h5s_compound_scalar_write() SUBTEST("Compound Dataspace Writing"); try { - // Create file - H5File fid1(DATAFILE, H5F_ACC_TRUNC); - - // Create the compound datatype. - CompType tid1(sizeof(struct space4_struct)); - space4_field1_off=HOFFSET(struct space4_struct, c1); - tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, - PredType::NATIVE_SCHAR); - space4_field2_off=HOFFSET(struct space4_struct, u); - tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, - PredType::NATIVE_UINT); - space4_field3_off=HOFFSET(struct space4_struct, f); - tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, - PredType::NATIVE_FLOAT); - space4_field4_off=HOFFSET(struct space4_struct, c2); - tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, - PredType::NATIVE_SCHAR); - - // Create scalar dataspace - DataSpace sid1(SPACE3_RANK, NULL); - - // Get the number of dataspace elements - hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - - // Get the logical rank of the dataspace - int ndims = sid1.getSimpleExtentNdims(); - verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - - hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims(tdims); - verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - - // Create and write a dataset - DataSet dataset = fid1.createDataSet("Dataset1", tid1, sid1); - dataset.write(&space4_data, tid1); - - PASSED(); - } // end of try block + // Create file + H5File fid1(DATAFILE, H5F_ACC_TRUNC); + + // Create the compound datatype. + CompType tid1(sizeof(struct space4_struct)); + space4_field1_off=HOFFSET(struct space4_struct, c1); + tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, + PredType::NATIVE_SCHAR); + space4_field2_off=HOFFSET(struct space4_struct, u); + tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, + PredType::NATIVE_UINT); + space4_field3_off=HOFFSET(struct space4_struct, f); + tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, + PredType::NATIVE_FLOAT); + space4_field4_off=HOFFSET(struct space4_struct, c2); + tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, + PredType::NATIVE_SCHAR); + + // Create scalar dataspace + DataSpace sid1(SPACE3_RANK, NULL); + + // Get the number of dataspace elements + hssize_t n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + + // Get the logical rank of the dataspace + int ndims = sid1.getSimpleExtentNdims(); + verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + + hsize_t tdims[4]; // Dimension array to test with + ndims = sid1.getSimpleExtentDims(tdims); + verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + + // Create and write a dataset + DataSet dataset = fid1.createDataSet("Dataset1", tid1, sid1); + dataset.write(&space4_data, tid1); + + PASSED(); + } // end of try block catch (Exception& E) { - // all the exceptions caused by negative returned values by C APIs - issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); + // all the exceptions caused by negative returned values by C APIs + issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_h5s_compound_scalar_write() /*------------------------------------------------------------------------- * - * Function: test_h5s_compound_scalar_read + * Function: test_h5s_compound_scalar_read * - * Purpose: Test scalar H5S (dataspace) reading for compound - * datatypes + * Purpose Test scalar H5S (dataspace) reading for compound + * datatypes * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hssize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hssize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. *------------------------------------------------------------------------- */ static void test_h5s_compound_scalar_read() { - hsize_t tdims[4]; // Dimension array to test with + hsize_t tdims[4]; // Dimension array to test with // Output message about test being performed SUBTEST("Compound Dataspace Reading"); try { - // Open file - H5File fid1(DATAFILE, H5F_ACC_RDWR); + // Open file + H5File fid1(DATAFILE, H5F_ACC_RDWR); - // Create a dataset - DataSet dataset = fid1.openDataSet("Dataset1"); + // Create a dataset + DataSet dataset = fid1.openDataSet("Dataset1"); - DataSpace sid1 = dataset.getSpace(); + DataSpace sid1 = dataset.getSpace(); - // Get the number of dataspace elements - hssize_t n = sid1.getSimpleExtentNpoints(); - verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + // Get the number of dataspace elements + hssize_t n = sid1.getSimpleExtentNpoints(); + verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - // Get the logical rank of the dataspace - int ndims = sid1.getSimpleExtentNdims(); - verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); + // Get the logical rank of the dataspace + int ndims = sid1.getSimpleExtentNdims(); + verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - ndims = sid1.getSimpleExtentDims(tdims); - verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + ndims = sid1.getSimpleExtentDims(tdims); + verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - // Get the datatype of this dataset. - CompType type(dataset); + // Get the datatype of this dataset. + CompType type(dataset); - struct space4_struct rdata; // Scalar data read in - dataset.read(&rdata, type); + struct space4_struct rdata; // Scalar data read in + dataset.read(&rdata, type); - // Verify read data - if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) - { + // Verify read data + if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) + { cerr << "scalar data different: space4_data.c1=" - << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl; + << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl; cerr << "scalar data different: space4_data.u=" - << space4_data.u << ", read_data4.u=" << rdata.u << endl; + << space4_data.u << ", read_data4.u=" << rdata.u << endl; cerr << "scalar data different: space4_data.f=" - << space4_data.f << ", read_data4.f=" << rdata.f << endl; + << space4_data.f << ", read_data4.f=" << rdata.f << endl; TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", - space4_data.c1, rdata.c2); - } // end if - PASSED(); + space4_data.c1, rdata.c2); + } // end if + PASSED(); } // end of try block catch (Exception& E) { - // all the exceptions caused by negative returned values by C APIs - issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); + // all the exceptions caused by negative returned values by C APIs + issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_h5s_compound_scalar_read() /*------------------------------------------------------------------------- * - * Function: test_h5s + * Function: test_h5s * - * Purpose: Main dataspace testing routine + * Purpose Main dataspace testing routine * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler (using C version) + * Programmer Binh-Minh Ribler (using C version) * Mar 2001 * * Modifications: @@ -564,23 +563,23 @@ void test_h5s() // Output message about test being performed MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); // Test basic H5S code - test_h5s_scalar_write(); // Test scalar H5S writing code - test_h5s_scalar_read(); // Test scalar H5S reading code - test_h5s_null(); // Test null H5S 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 + test_h5s_basic(); // Test basic H5S code + test_h5s_scalar_write(); // Test scalar H5S writing code + test_h5s_scalar_read(); // Test scalar H5S reading code + test_h5s_null(); // Test null H5S 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 } // test_h5s() /*------------------------------------------------------------------------- - * Function: cleanup_h5s + * Function: cleanup_h5s * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: Albert Cheng + * Programmer Albert Cheng * July 2, 1998 * * Modifications: diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 7ee2b53..fce42fa 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -49,20 +49,20 @@ using namespace H5; //#define SPACE1_RANK 1 //#define SPACE1_DIM1 4 -const H5std_string FILE_ITERATE("titerate.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); +const H5std_string FILE_ITERATE("titerate.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); typedef enum { RET_ZERO, @@ -127,15 +127,15 @@ liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t H5_ATTR_ } /* end liter_cb() */ /*------------------------------------------------------------------------- - * Function: test_iter_group + * Function: test_iter_group * - * Purpose: Tests group iteration + * Purpose Tests group iteration * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, September 9, 2016 + * Programmer Binh-Minh Ribler + * Friday, September 9, 2016 * * Modifications: * @@ -148,142 +148,142 @@ static void test_iter_group(FileAccPropList& fapl) char name[NAMELEN]; /* temporary name buffer */ char *lnames[NDATASETS + 2];/* Names of the links created */ iter_info info; /* Custom iteration information */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ SUBTEST("Group Iteration"); /* Create the test file with the datasets */ try { - // Create file - H5File file(FILE_ITERATE, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + // Create file + H5File file(FILE_ITERATE, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - /* Test iterating over empty group */ - info.command = RET_ZERO; - idx = 0; - ret = H5Literate(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); - verify_val(ret, SUCCEED, "H5Literate", __LINE__, __FILE__); + /* Test iterating over empty group */ + info.command = RET_ZERO; + idx = 0; + ret = H5Literate(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + verify_val(ret, SUCCEED, "H5Literate", __LINE__, __FILE__); - DataType datatype(PredType::NATIVE_INT); + DataType datatype(PredType::NATIVE_INT); - // Create a scalar file space - DataSpace filespace; + // Create a scalar file space + DataSpace filespace; - for (i=0; i< NDATASETS; i++) - { + for (i=0; i< NDATASETS; i++) + { sprintf(name, "Dataset %d", i); - // Create a dataset in the file - DataSet dataset = file.createDataSet(name, datatype, filespace); + // Create a dataset in the file + DataSet dataset = file.createDataSet(name, datatype, filespace); /* Keep a copy of the dataset names */ lnames[i] = HDstrdup(name); check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); - } /* end for */ + } /* end for */ - /* Create a group and named datatype under root group for testing */ - Group grp(file.createGroup(GROUP1, 0)); - lnames[NDATASETS] = HDstrdup("grp"); - check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); + /* Create a group and named datatype under root group for testing */ + Group grp(file.createGroup(GROUP1, 0)); + lnames[NDATASETS] = HDstrdup("grp"); + check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); - datatype.commit(file, "dtype"); - lnames[NDATASETS + 1] = HDstrdup("dtype"); - check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); + datatype.commit(file, "dtype"); + lnames[NDATASETS + 1] = HDstrdup("dtype"); + check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); - /* Sort the dataset names */ - HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); + /* Sort the dataset names */ + HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); - /* Iterate through the datasets in the root group in various ways */ + /* Iterate through the datasets in the root group in various ways */ - // Open data file to read - file.openFile(FILE_ITERATE, H5F_ACC_RDONLY, fapl); + // Open data file to read + file.openFile(FILE_ITERATE, H5F_ACC_RDONLY, fapl); - // Open the root group - Group root_group(file.openGroup("/")); + // Open the root group + Group root_group(file.openGroup("/")); - // Get the number of object in the root group - hsize_t nobjs = root_group.getNumObjs(); - verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); + // Get the number of object in the root group + hsize_t nobjs = root_group.getNumObjs(); + verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); - H5std_string obj_name; - for (i = 0; i < nobjs; i++) - { - //H5O_info_t oinfo; /* Object info */ + H5std_string obj_name; + for (i = 0; i < nobjs; i++) + { + //H5O_info_t oinfo; /* Object info */ - obj_name = root_group.getObjnameByIdx(i); + obj_name = root_group.getObjnameByIdx(i); //ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - //oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); + //oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); //ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); - } /* end for */ - - // Attempted to iterate with invalid index, should fail - try { - obj_name = root_group.getObjnameByIdx(NDATASETS + 3); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with invalid index"); - } - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected - - // Attempted to iterate with negative index, should fail - try { - info.command = RET_ZERO; - idx = (hsize_t)-1; - obj_name = root_group.getObjnameByIdx(idx); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); - } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected - - /* Test skipping exactly as many entries as in the group */ - try { - info.command = RET_ZERO; - idx = NDATASETS + 2; - obj_name = root_group.getObjnameByIdx(idx); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); - } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected - - /* Test skipping more entries than are in the group */ - try { - info.command = RET_ZERO; - idx = NDATASETS + 3; - obj_name = root_group.getObjnameByIdx(idx); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); - } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected - - /* Free the dataset names */ - for(i = 0; i< (NDATASETS + 2); i++) - HDfree(lnames[i]); - - // Everything will be closed as they go out of scope - - PASSED(); - } // try block + } /* end for */ + + // Attempted to iterate with invalid index, should fail + try { + obj_name = root_group.getObjnameByIdx(NDATASETS + 3); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with invalid index"); + } + catch (GroupIException& invalid_action) // invalid index + {} // do nothing, exception expected + + // Attempted to iterate with negative index, should fail + try { + info.command = RET_ZERO; + idx = (hsize_t)-1; + obj_name = root_group.getObjnameByIdx(idx); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); + } + catch (FileIException& invalid_action) // invalid index + {} // do nothing, exception expected + catch (GroupIException& invalid_action) // invalid index + {} // do nothing, exception expected + + /* Test skipping exactly as many entries as in the group */ + try { + info.command = RET_ZERO; + idx = NDATASETS + 2; + obj_name = root_group.getObjnameByIdx(idx); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); + } + catch (FileIException& invalid_action) // invalid index + {} // do nothing, exception expected + catch (GroupIException& invalid_action) // invalid index + {} // do nothing, exception expected + + /* Test skipping more entries than are in the group */ + try { + info.command = RET_ZERO; + idx = NDATASETS + 3; + obj_name = root_group.getObjnameByIdx(idx); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); + } + catch (FileIException& invalid_action) // invalid index + {} // do nothing, exception expected + catch (GroupIException& invalid_action) // invalid index + {} // do nothing, exception expected + + /* Free the dataset names */ + for(i = 0; i< (NDATASETS + 2); i++) + HDfree(lnames[i]); + + // Everything will be closed as they go out of scope + + PASSED(); + } // try block // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_iter_group", __LINE__, __FILE__); + issue_fail_msg("test_iter_group", __LINE__, __FILE__); } #if 0 @@ -355,59 +355,59 @@ static void test_iter_group(FileAccPropList& fapl) /**************************************************************** ** ** printelems(): Open an attribute and verify that it has a -** the correct name +** the correct name ** ****************************************************************/ -const H5std_string FILE_NAME("titerate.h5"); -const H5std_string GRP_NAME("/Group_A"); -const H5std_string FDATASET_NAME( "file dset" ); -const H5std_string GDATASET_NAME( "group dset" ); -const H5std_string ATTR_NAME( "Units" ); -const H5std_string FATTR_NAME( "F attr" ); -const H5std_string GATTR_NAME( "G attr" ); -const int DIM1 = 2; +const H5std_string FILE_NAME("titerate.h5"); +const H5std_string GRP_NAME("/Group_A"); +const H5std_string FDATASET_NAME("file dset"); +const H5std_string GDATASET_NAME("group dset"); +const H5std_string ATTR_NAME("Units"); +const H5std_string FATTR_NAME("F attr"); +const H5std_string GATTR_NAME("G attr"); +const int DIM1 = 2; void printelems(const Group& group, const H5std_string& dsname, const H5std_string& atname) { try { - DataSet d1(group.openDataSet(dsname)); - DataSpace s1 = d1.getSpace(); - s1.close(); - d1.close(); - - unsigned idx = 0; - Attribute a1(group.openAttribute(idx)); - H5std_string aname = a1.getName(); + DataSet d1(group.openDataSet(dsname)); + DataSpace s1 = d1.getSpace(); + s1.close(); + d1.close(); + + unsigned idx = 0; + Attribute a1(group.openAttribute(idx)); + H5std_string aname = a1.getName(); verify_val(aname, atname, "printelems", __LINE__, __FILE__); - a1.close(); + a1.close(); } // catch failure caused by the DataSpace operations catch( DataSpaceIException error ) { - error.printError(); + error.printError(); } // catch failure caused by the Group operations catch( GroupIException error ) { - error.printError(); + error.printError(); } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printError(); + error.printError(); } } /*------------------------------------------------------------------------- - * Function: test_HDFFV_9920 + * Function: test_HDFFV_9920 * - * Purpose: Tests the fix for HDFFV-9920 + * Purpose Tests the fix for HDFFV-9920 * - * Programmer: Binh-Minh Ribler - * Friday, September 9, 2016 + * Programmer Binh-Minh Ribler + * Friday, September 9, 2016 * * Modifications: * @@ -420,74 +420,74 @@ static void test_HDFFV_9920() try { - // Create a new file and a group in it - H5File file( FILE_NAME, H5F_ACC_TRUNC ); + // Create a new file and a group in it + H5File file( FILE_NAME, H5F_ACC_TRUNC ); - Group gr1(file.createGroup(GRP_NAME)); + Group gr1(file.createGroup(GRP_NAME)); - // Create the data space for the attribute. - DataSpace dspace = DataSpace (1, dims ); + // Create the data space for the attribute. + DataSpace dspace = DataSpace (1, dims ); - DataSet fds = file.createDataSet(FDATASET_NAME, PredType::STD_I32BE, dspace); - DataSet gds = gr1.createDataSet(GDATASET_NAME, PredType::STD_I32BE, dspace); + DataSet fds = file.createDataSet(FDATASET_NAME, PredType::STD_I32BE, dspace); + DataSet gds = gr1.createDataSet(GDATASET_NAME, PredType::STD_I32BE, dspace); - // Create a file attribute and a group attribute. - Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, - dspace); - Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, - dspace); + // Create a file attribute and a group attribute. + Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, + dspace); + Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, + dspace); - // Write the attribute data. - fa1.write( PredType::NATIVE_INT, attr_data); - ga1.write( PredType::NATIVE_INT, attr_data); + // Write the attribute data. + fa1.write( PredType::NATIVE_INT, attr_data); + ga1.write( PredType::NATIVE_INT, attr_data); - fa1.close(); - ga1.close(); - fds.close(); - gds.close(); + fa1.close(); + ga1.close(); + fds.close(); + gds.close(); - // Verify the attributes have correct names. - printelems(file, FDATASET_NAME, FATTR_NAME); - printelems(gr1, GDATASET_NAME, GATTR_NAME); + // Verify the attributes have correct names. + printelems(file, FDATASET_NAME, FATTR_NAME); + printelems(gr1, GDATASET_NAME, GATTR_NAME); } // end of try block // catch failure caused by the H5File operations catch( DataSpaceIException error ) { - error.printError(); + error.printError(); } // catch failure caused by the H5File operations catch( AttributeIException error ) { - error.printError(); + error.printError(); } // catch failure caused by the H5File operations catch( FileIException error ) { - error.printError(); + error.printError(); } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printError(); + error.printError(); } } /*------------------------------------------------------------------------- - * Function: test_iterate + * Function: test_iterate * - * Purpose: Tests iterate functionality + * Purpose Tests iterate functionality * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Tuesday, September 6, 2016 + * Programmer Binh-Minh Ribler + * Tuesday, September 6, 2016 * * Modifications: * @@ -503,20 +503,20 @@ void test_iterate() FileAccPropList fapl; fapl.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - test_iter_group(fapl); // Test iterating groups - test_HDFFV_9920(); // Test the fix of HDFFV-9920 - //test_iter_attr(fapl); // Test iterating attributes + test_iter_group(fapl); // Test iterating groups + test_HDFFV_9920(); // Test the fix of HDFFV-9920 + //test_iter_attr(fapl); // Test iterating attributes } // test_iterate /*------------------------------------------------------------------------- * Function: cleanup_iterate * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: (use C version) + * Programmer (use C version) * * Modifications: * diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 3acf4e1..c217718 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -43,9 +43,9 @@ using namespace H5; //#define H5G_TESTING //#include "h5test.h" -//#include "H5Gpkg.h" /* Groups */ -//#include "H5Iprivate.h" /* IDs */ -//#include "H5Lprivate.h" /* Links */ +//#include "H5Gpkg.h" /* Groups */ +//#include "H5Iprivate.h" /* IDs */ +//#include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -64,39 +64,39 @@ const char *FILENAME[] = { "links6", /* 9 */ "links7", /* 10 */ "links8", /* 11 */ - "extlinks0", /* 12: main files */ - "tmp/extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - "tmp/extlinks1", /* 15: */ - "extlinks2", /* 16: */ - "tmp/extlinks2", /* 17: */ - "extlinks3", /* 18: */ - "tmp/extlinks3", /* 19: */ - "extlinks4", /* 20: */ - "tmp/extlinks4", /* 21: */ - "extlinks5", /* 22: */ - "tmp/extlinks6", /* 23: */ - "extlinks7", /* 24: */ - "tmp/extlinks7", /* 25: */ - "tmp/extlinks8", /* 26: */ - "extlinks9", /* 27: */ - "tmp/extlinks9", /* 28: */ - "extlinks10", /* 29: */ /* TESTS for windows */ - "tmp/extlinks10", /* 30: */ - "tmp/extlinks11", /* 31: */ - "tmp/extlinks12", /* 32: */ - "extlinks13", /* 33: */ - "tmp/extlinks13", /* 34: */ - "tmp/extlinks14", /* 35: */ - "tmp/extlinks15", /* 36: */ - "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ - "extlinks16B", /* 38: */ - "extlinks17", /* 39: */ - "extlinks18A", /* 40: */ - "extlinks18B", /* 41: */ - "extlinks19A", /* 42: */ - "extlinks19B", /* 43: */ - "extlinks20", /* 44: */ + "extlinks0", /* 12: main files */ + "tmp/extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + "tmp/extlinks1", /* 15: */ + "extlinks2", /* 16: */ + "tmp/extlinks2", /* 17: */ + "extlinks3", /* 18: */ + "tmp/extlinks3", /* 19: */ + "extlinks4", /* 20: */ + "tmp/extlinks4", /* 21: */ + "extlinks5", /* 22: */ + "tmp/extlinks6", /* 23: */ + "extlinks7", /* 24: */ + "tmp/extlinks7", /* 25: */ + "tmp/extlinks8", /* 26: */ + "extlinks9", /* 27: */ + "tmp/extlinks9", /* 28: */ + "extlinks10", /* 29: */ /* TESTS for windows */ + "tmp/extlinks10", /* 30: */ + "tmp/extlinks11", /* 31: */ + "tmp/extlinks12", /* 32: */ + "extlinks13", /* 33: */ + "tmp/extlinks13", /* 34: */ + "tmp/extlinks14", /* 35: */ + "tmp/extlinks15", /* 36: */ + "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ + "extlinks16B", /* 38: */ + "extlinks17", /* 39: */ + "extlinks18A", /* 40: */ + "extlinks18B", /* 41: */ + "extlinks19A", /* 42: */ + "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ NULL }; @@ -104,12 +104,12 @@ const char *FILENAME[] = { #define TMPDIR "tmp" -#define FAMILY_SIZE 1024 +#define FAMILY_SIZE 1024 #define CORE_INCREMENT 1024 -#define NUM400 400 +#define NUM400 400 /* do not do check_all_closed() for "ext*" files and "tmp/ext*" */ -#define EXTSTOP 12 +#define EXTSTOP 12 #define LINK_BUF_SIZE 1024 #define NAME_BUF_SIZE 1024 @@ -323,16 +323,16 @@ static const char *FILENAME[] = { /*------------------------------------------------------------------------- - * Function: test_basic_links + * Function: test_basic_links * - * Purpose: Test building a file with assorted links. + * Purpose Test building a file with assorted links. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * October 16, 2009 + * Programmer Binh-Minh Ribler + * October 16, 2009 * * Modifications: * @@ -340,114 +340,114 @@ static const char *FILENAME[] = { */ static void test_basic_links(hid_t fapl_id, hbool_t new_format) { - hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); try { - if(new_format) - SUBTEST("Link creation (w/new group format)") - else - SUBTEST("Link creation") + if(new_format) + SUBTEST("Link creation (w/new group format)") + else + SUBTEST("Link creation") - h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); - H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - // Create simple dataspace - DataSpace scalar (1, size, size); + // Create simple dataspace + DataSpace scalar (1, size, size); - // Create a group then close it by letting the object go out of scope - { - Group group(file.createGroup("grp1", 0)); - } + // Create a group then close it by letting the object go out of scope + { + Group group(file.createGroup("grp1", 0)); + } - // Create a dataset then close it by letting the object go out of scope - { - DataSet dset1(file.createDataSet("dset1", PredType::NATIVE_INT, scalar)); - } + // Create a dataset then close it by letting the object go out of scope + { + DataSet dset1(file.createDataSet("dset1", PredType::NATIVE_INT, scalar)); + } - hid_t file_id = file.getId(); + hid_t file_id = file.getId(); - // Because these are not implemented in the C++ API yet, they are - // used so CommonFG::getLinkval can be tested. - // Create a hard link - if(H5Lcreate_hard( - file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", - H5P_DEFAULT, H5P_DEFAULT) < 0) - throw Exception("test_basic_links", "H5Lcreate_hard failed"); + // Because these are not implemented in the C++ API yet, they are + // used so CommonFG::getLinkval can be tested. + // Create a hard link + if(H5Lcreate_hard( + file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", + H5P_DEFAULT, H5P_DEFAULT) < 0) + throw Exception("test_basic_links", "H5Lcreate_hard failed"); - // Create a symbolic link - if(H5Lcreate_soft( - "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) - throw Exception("test_basic_links", "H5Lcreate_soft failed"); + // Create a symbolic link + if(H5Lcreate_soft( + "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + throw Exception("test_basic_links", "H5Lcreate_soft failed"); - // Create a symbolic link to something that doesn't exist - if(H5Lcreate_soft( - "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) - throw Exception("test_basic_links", "H5Lcreate_soft failed"); + // Create a symbolic link to something that doesn't exist + if(H5Lcreate_soft( + "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + throw Exception("test_basic_links", "H5Lcreate_soft failed"); - // Create a recursive symbolic link - if(H5Lcreate_soft( - "/grp1/recursive", file_id, "/grp1/recursive", - H5P_DEFAULT, H5P_DEFAULT) < 0) - throw Exception("test_basic_links", "H5Lcreate_soft failed"); + // Create a recursive symbolic link + if(H5Lcreate_soft( + "/grp1/recursive", file_id, "/grp1/recursive", + H5P_DEFAULT, H5P_DEFAULT) < 0) + throw Exception("test_basic_links", "H5Lcreate_soft failed"); - // Verify link values before closing the file + // Verify link values before closing the file - H5std_string softlink_val = file.getLinkval("grp1/soft"); - verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__); + H5std_string softlink_val = file.getLinkval("grp1/soft"); + verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__); - H5std_string dngllink_val = file.getLinkval("grp1/dangle"); - verify_val(dngllink_val, "foobar", "H5File::getLinkval grp1/dangle", __LINE__, __FILE__); + H5std_string dngllink_val = file.getLinkval("grp1/dangle"); + verify_val(dngllink_val, "foobar", "H5File::getLinkval grp1/dangle", __LINE__, __FILE__); - H5std_string reclink_val = file.getLinkval("grp1/recursive"); - verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); + H5std_string reclink_val = file.getLinkval("grp1/recursive"); + verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block catch (Exception& E) { - issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } // Open the file and check on the links in it try { - // Open the file above - H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); + // Open the file above + H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); - // Verify link existence - if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) - throw InvalidActionException("H5File::exists", "dset1 doesn't exist"); - if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) - throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); + // Verify link existence + if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) + throw InvalidActionException("H5File::exists", "dset1 doesn't exist"); + if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); - // Verify link values - H5std_string softlink_val = file.getLinkval("grp1/soft"); - verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__); + // Verify link values + H5std_string softlink_val = file.getLinkval("grp1/soft"); + verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__); - H5std_string reclink_val = file.getLinkval("grp1/recursive"); - verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); + H5std_string reclink_val = file.getLinkval("grp1/recursive"); + verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); - PASSED(); + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } /*------------------------------------------------------------------------- - * Function: test_links + * Function: test_links * - * Purpose: Test links + * Purpose Test links * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler + * Programmer Binh-Minh Ribler * October 16, 2009 * *------------------------------------------------------------------------- @@ -455,7 +455,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) extern "C" void test_links() { - hid_t fapl_id, fapl2_id; /* File access property lists */ + hid_t fapl_id, fapl2_id; /* File access property lists */ unsigned new_format; /* Whether to use the new format or not */ const char *envval; @@ -469,40 +469,40 @@ void test_links() MESSAGE(5, ("Testing Various Links\n")); try { - /* Copy the file access property list */ - if((fapl2_id = H5Pcopy(fapl_id)) < 0) - throw Exception("test_links", "H5Pcopy failed"); - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - throw Exception("test_links", "H5Pset_libver_bounds failed"); - - /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) - { - hid_t my_fapl_id; - - /* Check for FAPL to use */ - if(new_format) - my_fapl_id = fapl2_id; - else - my_fapl_id = fapl_id; - - /* General tests... (on both old & new format groups */ - // FileAccPropList may be passed in instead of fapl id - test_basic_links(my_fapl_id, new_format); + /* Copy the file access property list */ + if((fapl2_id = H5Pcopy(fapl_id)) < 0) + throw Exception("test_links", "H5Pcopy failed"); + + /* Set the "use the latest version of the format" bounds for creating objects in the file */ + if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + throw Exception("test_links", "H5Pset_libver_bounds failed"); + + /* Loop over using new group format */ + for(new_format = FALSE; new_format <= TRUE; new_format++) + { + hid_t my_fapl_id; + + /* Check for FAPL to use */ + if(new_format) + my_fapl_id = fapl2_id; + else + my_fapl_id = fapl_id; + + /* General tests... (on both old & new format groups */ + // FileAccPropList may be passed in instead of fapl id + test_basic_links(my_fapl_id, new_format); #if 0 // these tests are from the C test links.c and left here for future // implementation of H5L API - nerrors += test_basic_links(fapl_id, new_format) < 0 ? 1 : 0; - nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0; - - /* Test new H5L link creation routine */ - nerrors += test_lcpl(my_fapl, new_format); + nerrors += test_basic_links(fapl_id, new_format) < 0 ? 1 : 0; + nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0; + + /* Test new H5L link creation routine */ + nerrors += test_lcpl(my_fapl, new_format); nerrors += test_move(my_fapl, new_format); nerrors += test_copy(my_fapl, new_format); nerrors += test_move_preserves(my_fapl, new_format); @@ -579,7 +579,7 @@ void test_links() /* do not do this for files used by external link tests */ nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0; #endif // 0 - } /* end for */ + } /* end for */ #if 0 /* New group revision feature tests */ @@ -609,33 +609,33 @@ void test_links() nerrors += group_info_old(fapl) < 0 ? 1 : 0; #endif - /* Close 2nd FAPL */ - H5Pclose(fapl2_id); + /* Close 2nd FAPL */ + H5Pclose(fapl2_id); - h5_clean_files(FILENAME, fapl_id); + h5_clean_files(FILENAME, fapl_id); - /* Test that external links can be used after a library reset. MUST be - * called last so the reset doesn't interfere with the property lists. This - * routine will delete its own file. */ - /* nerrors += external_reset_register() < 0 ? 1 : 0; + /* Test that external links can be used after a library reset. MUST be + * called last so the reset doesn't interfere with the property lists. This + * routine will delete its own file. */ + /* nerrors += external_reset_register() < 0 ? 1 : 0; */ } catch (Exception& E) { - issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } /*------------------------------------------------------------------------- - * Function: cleanup_links + * Function: cleanup_links * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: Binh-Minh Ribler - * October 16, 2009 + * Programmer Binh-Minh Ribler + * October 16, 2009 * * Modifications: * diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 325b2b0..6003dd6 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -31,41 +31,41 @@ using namespace H5; #include "h5test.h" #include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE_OBJECTS("tobjects.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); +const H5std_string FILE_OBJECTS("tobjects.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); /*------------------------------------------------------------------------- - * Function: test_get_objname + * Function: test_get_objname * - * Purpose: Tests getting object name of groups and datasets. + * Purpose Tests getting object name of groups and datasets. * * Description: - * File structure: - * GROUP1 - * GROUP1_1 - * GROUP1_2 - * DSET_IN_GRP1_2 - * DSET_IN_GRP1 - * DSET_IN_FILE + * File structure: + * GROUP1 + * GROUP1_1 + * GROUP1_2 + * DSET_IN_GRP1_2 + * DSET_IN_GRP1 + * DSET_IN_FILE * * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, March 4, 2014 + * Programmer Binh-Minh Ribler + * Friday, March 4, 2014 * * Modifications: * @@ -76,104 +76,104 @@ static void test_get_objname() SUBTEST("H5Object::getObjName on Groups and Datasets"); try { - // Create file - H5File file(FILE_OBJECTS, H5F_ACC_TRUNC); + // Create file + H5File file(FILE_OBJECTS, H5F_ACC_TRUNC); - // Create a top group and 2 subgroups - Group grp1 = file.createGroup(GROUP1, 0); - Group grp1_1 = grp1.createGroup(GROUP1_1, 0); - Group grp1_2 = grp1.createGroup(GROUP1_2, 0); + // Create a top group and 2 subgroups + Group grp1 = file.createGroup(GROUP1, 0); + Group grp1_1 = grp1.createGroup(GROUP1_1, 0); + Group grp1_2 = grp1.createGroup(GROUP1_2, 0); - // Get part of the group's name, random length using - // ssize_t getObjName(char* comment, size_t buf_size) + // Get part of the group's name, random length using + // ssize_t getObjName(char* comment, size_t buf_size) - // Get the length of the group's name first - ssize_t name_len = grp1.getObjName(NULL); + // Get the length of the group's name first + ssize_t name_len = grp1.getObjName(NULL); - // Random length is 4 - if (name_len > 4) - { - char* grp1_name = new char[5]; - name_len = grp1.getObjName(grp1_name, 5); - verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); - delete []grp1_name; - } + // Random length is 4 + if (name_len > 4) + { + char* grp1_name = new char[5]; + name_len = grp1.getObjName(grp1_name, 5); + verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); + delete []grp1_name; + } - // Create a data space - hsize_t dims[2]; - dims[0] = 2; - dims[1] = 5; - DataSpace space (2, dims, NULL); + // Create a data space + hsize_t dims[2]; + dims[0] = 2; + dims[1] = 5; + DataSpace space (2, dims, NULL); - // Create a dataset in the file - DataSet dsinfile = file.createDataSet(DSET_IN_FILE, - PredType::NATIVE_DOUBLE, space); + // Create a dataset in the file + DataSet dsinfile = file.createDataSet(DSET_IN_FILE, + PredType::NATIVE_DOUBLE, space); - // Create a dataset in the group - DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, - PredType::NATIVE_INT, space); + // Create a dataset in the group + DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, + PredType::NATIVE_INT, space); - // Get and verify the name of each dataset, using - // H5std_string getObjName() and - // ssize_t getObjName(H5std_string& obj_name, size_t len = 0) - H5std_string ds_name = dsinfile.getObjName(); - verify_val(ds_name, DSET_IN_FILE_PATH, "DataSet::getObjName", __LINE__, __FILE__); + // Get and verify the name of each dataset, using + // H5std_string getObjName() and + // ssize_t getObjName(H5std_string& obj_name, size_t len = 0) + H5std_string ds_name = dsinfile.getObjName(); + verify_val(ds_name, DSET_IN_FILE_PATH, "DataSet::getObjName", __LINE__, __FILE__); - name_len = dsingrp.getObjName(ds_name); // default len - verify_val(ds_name, DSET_IN_GRP1_PATH, "DataSet::getObjName", __LINE__, __FILE__); + name_len = dsingrp.getObjName(ds_name); // default len + verify_val(ds_name, DSET_IN_GRP1_PATH, "DataSet::getObjName", __LINE__, __FILE__); - // Close dataset - dsingrp.close(); + // Close dataset + dsingrp.close(); - // Create a dataset in sub-group 1.2 - dsingrp = grp1_2.createDataSet(DSET_IN_GRP1_2, PredType::NATIVE_INT, space); + // Create a dataset in sub-group 1.2 + dsingrp = grp1_2.createDataSet(DSET_IN_GRP1_2, PredType::NATIVE_INT, space); - // Get and verify the name of the dataset that belongs to subgroup - // 1.2, using H5std_string getObjName() - ds_name = dsingrp.getObjName(); - verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); + // Get and verify the name of the dataset that belongs to subgroup + // 1.2, using H5std_string getObjName() + ds_name = dsingrp.getObjName(); + verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); - // Close dataset - dsingrp.close(); + // Close dataset + dsingrp.close(); - // Reopen that same dataset then check the name again with another - // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0) - dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); - name_len = dsingrp.getObjName(ds_name); - verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); + // Reopen that same dataset then check the name again with another + // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0) + dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); + name_len = dsingrp.getObjName(ds_name); + verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); - // Everything will be closed as they go out of scope + // Everything will be closed as they go out of scope - PASSED(); - } // try block + PASSED(); + } // try block // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_get_objname", __LINE__, __FILE__); + issue_fail_msg("test_get_objname", __LINE__, __FILE__); } } // test_get_objname /*------------------------------------------------------------------------- - * Function: test_existance + * Function: test_existance * - * Purpose: Tests getting object name of groups and datasets. + * Purpose Tests getting object name of groups and datasets. * * Description: - * File structure: - * GROUP1 - * GROUP1_1 - * GROUP1_2 - * DSET_IN_GRP1_2 - * DSET_IN_GRP1 - * DSET_IN_FILE + * File structure: + * GROUP1 + * GROUP1_1 + * GROUP1_2 + * DSET_IN_GRP1_2 + * DSET_IN_GRP1 + * DSET_IN_FILE * * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, March 4, 2014 + * Programmer Binh-Minh Ribler + * Friday, March 4, 2014 * * Modifications: * @@ -184,62 +184,62 @@ static void test_existance() SUBTEST("H5File::exists and Group::exists"); try { - // Open file - H5File file(FILE_OBJECTS, H5F_ACC_RDONLY); + // Open file + H5File file(FILE_OBJECTS, H5F_ACC_RDONLY); - // Check if GROUP1 exists in the file - bool exists = file.exists(GROUP1); + // Check if GROUP1 exists in the file + bool exists = file.exists(GROUP1); - // Open GROUP1 - Group grp1 = file.openGroup(GROUP1); + // Open GROUP1 + Group grp1 = file.openGroup(GROUP1); - // Check if GROUP1_1 and GROUP1_2 exist in GROUP1 - exists = grp1.exists(GROUP1_1); - verify_val(exists, TRUE, "Group::exists GROUP1_1", __LINE__, __FILE__); - exists = grp1.exists(GROUP1_2); - verify_val(exists, TRUE, "Group::exists GROUP1_2", __LINE__, __FILE__); + // Check if GROUP1_1 and GROUP1_2 exist in GROUP1 + exists = grp1.exists(GROUP1_1); + verify_val(exists, TRUE, "Group::exists GROUP1_1", __LINE__, __FILE__); + exists = grp1.exists(GROUP1_2); + verify_val(exists, TRUE, "Group::exists GROUP1_2", __LINE__, __FILE__); - // Check if DSET_IN_GRP1 exists in GROUP1 - exists = grp1.exists(DSET_IN_GRP1); - verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__); + // Check if DSET_IN_GRP1 exists in GROUP1 + exists = grp1.exists(DSET_IN_GRP1); + verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__); - // Open GROUP1_2 - Group grp1_2 = grp1.openGroup(GROUP1_2); + // Open GROUP1_2 + Group grp1_2 = grp1.openGroup(GROUP1_2); - // Check if DSET_IN_GRP1_2 exists in GROUP1_2 - exists = grp1_2.exists(DSET_IN_GRP1_2); - verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1_2", __LINE__, __FILE__); + // Check if DSET_IN_GRP1_2 exists in GROUP1_2 + exists = grp1_2.exists(DSET_IN_GRP1_2); + verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1_2", __LINE__, __FILE__); - // Check if a dataset exists given dataset as location with full path name - DataSet dset1 = file.openDataSet(DSET_IN_FILE); - exists = dset1.exists("/Top Group/Dataset_in_Group_1"); - verify_val(exists, TRUE, "Group::exists given dataset with full path name", __LINE__, __FILE__); + // Check if a dataset exists given dataset as location with full path name + DataSet dset1 = file.openDataSet(DSET_IN_FILE); + exists = dset1.exists("/Top Group/Dataset_in_Group_1"); + verify_val(exists, TRUE, "Group::exists given dataset with full path name", __LINE__, __FILE__); - exists = grp1_2.exists(DSET_IN_GRP1); - verify_val(exists, FALSE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__); + exists = grp1_2.exists(DSET_IN_GRP1); + verify_val(exists, FALSE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__); - // Everything will be closed as they go out of scope + // Everything will be closed as they go out of scope - PASSED(); - } // try block + PASSED(); + } // try block // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_existance", __LINE__, __FILE__); + issue_fail_msg("test_existance", __LINE__, __FILE__); } } // test_existance /*------------------------------------------------------------------------- - * Function: test_get_objname_ontypes + * Function: test_get_objname_ontypes * - * Purpose: Test getting object name from various committed types. + * Purpose Test getting object name from various committed types. * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * March 4, 2014 + * Programmer Binh-Minh Ribler + * March 4, 2014 * * Modifications: * @@ -250,97 +250,97 @@ static void test_get_objname_ontypes() SUBTEST("H5Object::getObjName on Committed Datatypes"); try { - // Create a file with default prop lists - H5File file(FILE_OBJECTS, H5F_ACC_RDWR); - - // Create a group - Group grp = file.createGroup ("typetests"); - - // Create a datatype and save it - IntType inttype(PredType::STD_B8LE); - inttype.commit(file, "INT type of STD_B8LE"); - - // Close the type then open it again to test getting its name - inttype.close(); - inttype = file.openIntType("INT type of STD_B8LE"); // deprecated - - // Get and verify its name - H5std_string inttype_name = inttype.getObjName(); - verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); - - // Close the type then open it again to test getting its name, but - // with the constructor this time - inttype.close(); - IntType std_b8le(file, "INT type of STD_B8LE"); - - // Get and verify its name - H5std_string std_b8le_name = std_b8le.getObjName(); - verify_val(std_b8le_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); - - // Make copy of a predefined type and save it - DataType dtype(PredType::STD_B8LE); - dtype.commit(file, "STD_B8LE"); - - // Close the data type and file - dtype.close(); - file.close(); - - // Re-open the file and the data type to test getting its name - file.openFile(FILE_OBJECTS, H5F_ACC_RDWR); - dtype = file.openDataType("STD_B8LE"); // deprecated - - // Get and verify its name - H5std_string type_name = dtype.getObjName(); - verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); - - // Close the type and open it again with the constructor then test - // getting its name - dtype.close(); - DataType dtype2(file, "STD_B8LE"); - type_name = dtype2.getObjName(); - verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); - - // Test getting type's name from copied type - DataType copied_type; - copied_type.copy(dtype2); - copied_type.commit(file, "copy of STD_B8LE"); - type_name = copied_type.getObjName(); - verify_val(type_name, "/copy of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); - - // Test copying an integer predefined type - IntType new_int_type(PredType::NATIVE_INT); - - // Name this datatype - new_int_type.commit(grp, "IntType NATIVE_INT"); - ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); - verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); - - // Close everything or they can be closed when objects go out of scope - dtype2.close(); - copied_type.close(); - new_int_type.close(); - grp.close(); - - PASSED(); + // Create a file with default prop lists + H5File file(FILE_OBJECTS, H5F_ACC_RDWR); + + // Create a group + Group grp = file.createGroup ("typetests"); + + // Create a datatype and save it + IntType inttype(PredType::STD_B8LE); + inttype.commit(file, "INT type of STD_B8LE"); + + // Close the type then open it again to test getting its name + inttype.close(); + inttype = file.openIntType("INT type of STD_B8LE"); // deprecated + + // Get and verify its name + H5std_string inttype_name = inttype.getObjName(); + verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Close the type then open it again to test getting its name, but + // with the constructor this time + inttype.close(); + IntType std_b8le(file, "INT type of STD_B8LE"); + + // Get and verify its name + H5std_string std_b8le_name = std_b8le.getObjName(); + verify_val(std_b8le_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Make copy of a predefined type and save it + DataType dtype(PredType::STD_B8LE); + dtype.commit(file, "STD_B8LE"); + + // Close the data type and file + dtype.close(); + file.close(); + + // Re-open the file and the data type to test getting its name + file.openFile(FILE_OBJECTS, H5F_ACC_RDWR); + dtype = file.openDataType("STD_B8LE"); // deprecated + + // Get and verify its name + H5std_string type_name = dtype.getObjName(); + verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Close the type and open it again with the constructor then test + // getting its name + dtype.close(); + DataType dtype2(file, "STD_B8LE"); + type_name = dtype2.getObjName(); + verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Test getting type's name from copied type + DataType copied_type; + copied_type.copy(dtype2); + copied_type.commit(file, "copy of STD_B8LE"); + type_name = copied_type.getObjName(); + verify_val(type_name, "/copy of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Test copying an integer predefined type + IntType new_int_type(PredType::NATIVE_INT); + + // Name this datatype + new_int_type.commit(grp, "IntType NATIVE_INT"); + ssize_t name_len = new_int_type.getObjName(type_name); // default len + verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); + verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); + + // Close everything or they can be closed when objects go out of scope + dtype2.close(); + copied_type.close(); + new_int_type.close(); + grp.close(); + + PASSED(); } // end top try block catch (Exception& E) { - issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); + issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } } // test_get_objname_ontypes /*------------------------------------------------------------------------- - * Function: test_get_objtype + * Function: test_get_objtype * - * Purpose: Tests getting object type + * Purpose Tests getting object type * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, March 4, 2014 + * Programmer Binh-Minh Ribler + * Friday, March 4, 2014 * * Modifications: * @@ -351,61 +351,61 @@ static void test_get_objtype() SUBTEST("H5File::childObjType and H5Group::childObjType"); try { - // Open file - H5File file(FILE_OBJECTS, H5F_ACC_RDWR); + // Open file + H5File file(FILE_OBJECTS, H5F_ACC_RDWR); - // Open the top group - Group grp1 = file.openGroup(GROUP1); + // Open the top group + Group grp1 = file.openGroup(GROUP1); - // Create a datatype and save it - DataType dtype(PredType::STD_I32LE); - dtype.commit(grp1, "STD_I32LE"); + // Create a datatype and save it + DataType dtype(PredType::STD_I32LE); + dtype.commit(grp1, "STD_I32LE"); - // Get and verify object type with - // H5O_type_t childObjType(const H5std_string& objname) - H5O_type_t objtype = file.childObjType(DSET_IN_FILE); - verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__); + // Get and verify object type with + // H5O_type_t childObjType(const H5std_string& objname) + H5O_type_t objtype = file.childObjType(DSET_IN_FILE); + verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__); - // Get and verify object type with - // H5O_type_t childObjType(const char* objname) - objtype = grp1.childObjType(GROUP1_1.c_str()); - verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + // Get and verify object type with + // H5O_type_t childObjType(const char* objname) + objtype = grp1.childObjType(GROUP1_1.c_str()); + verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); - // Get and verify object type with - // H5O_type_t childObjType(hsize_t index, H5_index_t index_type, - // H5_iter_order_t order, const char* objname=".") - objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC); - verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__); + // Get and verify object type with + // H5O_type_t childObjType(hsize_t index, H5_index_t index_type, + // H5_iter_order_t order, const char* objname=".") + objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC); + verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__); - // Get and verify object type with - // H5O_type_t childObjType(hsize_t index, - // H5_index_t index_type=H5_INDEX_NAME, - // H5_iter_order_t order=H5_ITER_INC, const char* objname=".") - objtype = grp1.childObjType((hsize_t)2); - verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + // Get and verify object type with + // H5O_type_t childObjType(hsize_t index, + // H5_index_t index_type=H5_INDEX_NAME, + // H5_iter_order_t order=H5_ITER_INC, const char* objname=".") + objtype = grp1.childObjType((hsize_t)2); + verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); - // Everything will be closed as they go out of scope + // Everything will be closed as they go out of scope - PASSED(); - } // try block + PASSED(); + } // try block // catch all other exceptions catch (Exception& E) { - issue_fail_msg("test_get_objtype", __LINE__, __FILE__); + issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } } // test_get_objtype /*------------------------------------------------------------------------- - * Function: test_objects + * Function: test_objects * - * Purpose: Tests HDF5 object related functionality + * Purpose Tests HDF5 object related functionality * - * Return: Success: 0 - * Failure: -1 + * Return Success: 0 + * Failure: -1 * - * Programmer: Binh-Minh Ribler - * Friday, Mar 4, 2014 + * Programmer Binh-Minh Ribler + * Friday, Mar 4, 2014 * * Modifications: * @@ -419,7 +419,7 @@ void test_object() test_get_objname(); // Test get object name from groups/datasets test_existance(); // Test check for object existance - test_get_objname_ontypes(); // Test get object name from types + test_get_objname_ontypes(); // Test get object name from types test_get_objtype(); // Test get object type } // test_objects @@ -427,11 +427,11 @@ void test_object() /*------------------------------------------------------------------------- * Function: cleanup_objects * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: (use C version) + * Programmer (use C version) * * Modifications: * diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 9bc2eb0..d8a0d5f 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -16,7 +16,7 @@ /***************************************************************************** FILE trefer.cpp - HDF5 C++ testing the functionalities associated with the C - Reference interface (H5R) + Reference interface (H5R) ***************************************************************************/ #ifdef OLD_HEADER_FILENAME @@ -79,100 +79,100 @@ test_reference_params(void) H5File* file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk - // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + // Allocate write & read buffers + int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); + wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); // Create file FILE1 file1 = new H5File (FILE1, H5F_ACC_TRUNC); - // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; - DataSpace sid1(SPACE1_RANK, dims1); - - // Create a group - Group group = file1->createGroup("Group1"); - - // Set group's comment - group.setComment(".", write_comment); - - // Create a dataset (inside /Group1) - DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - - unsigned *tu32; // Temporary pointer to uint32 data - int i; - for (tu32=(unsigned *)wbuf, i=0; icreateDataSet("Dataset3", PredType::STD_REF_OBJ, sid1); - - /* Test parameters to H5Location::reference */ - try { - file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException& E) {} // We expect this to fail - try { - file1->reference(&wbuf[0], NULL); - } catch (ReferenceException& E) {} // We expect this to fail - try { - file1->reference(&wbuf[0], ""); - } catch (ReferenceException& E) {} // We expect this to fail - try { - file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException& E) {} // We expect this to fail - try { - file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException& E) {} // We expect this to fail - - // Close resources - dataset.close(); - file1->close(); - // Let sid1 go out of scope - - // Free memory buffers - HDfree(wbuf); - HDfree(rbuf); - HDfree(tbuf); - - PASSED(); + // Create dataspace for datasets + hsize_t dims1[] = {SPACE1_DIM1}; + DataSpace sid1(SPACE1_RANK, dims1); + + // Create a group + Group group = file1->createGroup("Group1"); + + // Set group's comment + group.setComment(".", write_comment); + + // Create a dataset (inside /Group1) + DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); + + unsigned *tu32; // Temporary pointer to uint32 data + int i; + for (tu32=(unsigned *)wbuf, i=0; icreateDataSet("Dataset3", PredType::STD_REF_OBJ, sid1); + + /* Test parameters to H5Location::reference */ + try { + file1->reference(NULL, "/Group1/Dataset1"); + } catch (ReferenceException& E) {} // We expect this to fail + try { + file1->reference(&wbuf[0], NULL); + } catch (ReferenceException& E) {} // We expect this to fail + try { + file1->reference(&wbuf[0], ""); + } catch (ReferenceException& E) {} // We expect this to fail + try { + file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); + } catch (ReferenceException& E) {} // We expect this to fail + try { + file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); + } catch (ReferenceException& E) {} // We expect this to fail + + // Close resources + dataset.close(); + file1->close(); + // Let sid1 go out of scope + + // Free memory buffers + HDfree(wbuf); + HDfree(rbuf); + HDfree(tbuf); + + PASSED(); } // end try catch (Exception& E) { - issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + issue_fail_msg("test_reference_param()",__LINE__,__FILE__, + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -182,7 +182,7 @@ test_reference_params(void) /**************************************************************** ** ** test_reference_obj(): Test basic object reference functions -** to various kinds of objects +** to various kinds of objects ** ****************************************************************/ static void test_reference_obj(void) @@ -195,176 +195,176 @@ static void test_reference_obj(void) H5File* file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk - // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + // Allocate write & read buffers + int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); + wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); // Create file FILE1 file1 = new H5File (FILE1, H5F_ACC_TRUNC); - // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; - DataSpace sid1(SPACE1_RANK, dims1); + // Create dataspace for datasets + hsize_t dims1[] = {SPACE1_DIM1}; + DataSpace sid1(SPACE1_RANK, dims1); - // Create dataset access property list - PropList dapl(H5P_DATASET_ACCESS); + // Create dataset access property list + PropList dapl(H5P_DATASET_ACCESS); - // Create a group - Group group = file1->createGroup("Group1"); + // Create a group + Group group = file1->createGroup("Group1"); - // Set group's comment - group.setComment(".", write_comment); + // Set group's comment + group.setComment(".", write_comment); - // Create a dataset (inside /Group1) - DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); + // Create a dataset (inside /Group1) + DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data - for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + unsigned *tu32; // Temporary pointer to uint32 data + for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + *tu32++=i*3; // from C test - // Write selection to disk - dataset.write(wbuf, PredType::NATIVE_UINT); + // Write selection to disk + dataset.write(wbuf, PredType::NATIVE_UINT); - // Close Dataset - dataset.close(); + // Close Dataset + dataset.close(); - // Create another dataset (inside /Group1) - dataset = group.createDataSet("Dataset2", PredType::NATIVE_UCHAR, sid1); + // Create another dataset (inside /Group1) + dataset = group.createDataSet("Dataset2", PredType::NATIVE_UCHAR, sid1); - // Close Dataset - dataset.close(); + // Close Dataset + dataset.close(); - // Create a datatype to refer to - CompType dtype1(sizeof(s1_t)); + // Create a datatype to refer to + CompType dtype1(sizeof(s1_t)); - // Insert fields - dtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); - dtype1.insertMember(MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_INT); - dtype1.insertMember(MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_FLOAT); + // Insert fields + dtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); + dtype1.insertMember(MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_INT); + dtype1.insertMember(MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_FLOAT); - // Save datatype for later - dtype1.commit(group, "Datatype1"); + // Save datatype for later + dtype1.commit(group, "Datatype1"); - // Close datatype and group - dtype1.close(); - group.close(); + // Close datatype and group + dtype1.close(); + group.close(); - // Create a dataset - dataset = file1->createDataSet("Dataset3", PredType::STD_REF_OBJ, sid1); + // Create a dataset + dataset = file1->createDataSet("Dataset3", PredType::STD_REF_OBJ, sid1); - // Create reference to dataset and test getRefObjType - file1->reference(&wbuf[0], "/Group1/Dataset1"); - H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + // Create reference to dataset and test getRefObjType + file1->reference(&wbuf[0], "/Group1/Dataset1"); + H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); - // Create reference to dataset and test getRefObjType - file1->reference(&wbuf[1], "/Group1/Dataset2"); - refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + // Create reference to dataset and test getRefObjType + file1->reference(&wbuf[1], "/Group1/Dataset2"); + refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); - // Create reference to group - file1->reference(&wbuf[2], "/Group1"); - refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__); + // Create reference to group + file1->reference(&wbuf[2], "/Group1"); + refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); + verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__); - // Create reference to named datatype - file1->reference(&wbuf[3], "/Group1/Datatype1"); - refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__); + // Create reference to named datatype + file1->reference(&wbuf[3], "/Group1/Datatype1"); + refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); + verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__); - // Write selection to disk - dataset.write(wbuf, PredType::STD_REF_OBJ); + // Write selection to disk + dataset.write(wbuf, PredType::STD_REF_OBJ); - // Close disk dataspace, dataset, and file - sid1.close(); - dataset.close(); - delete file1; + // Close disk dataspace, dataset, and file + sid1.close(); + dataset.close(); + delete file1; - // Re-open the file - file1 = new H5File(FILE1, H5F_ACC_RDWR); + // Re-open the file + file1 = new H5File(FILE1, H5F_ACC_RDWR); - // Open the dataset - dataset = file1->openDataSet("/Dataset3"); + // Open the dataset + dataset = file1->openDataSet("/Dataset3"); - // Read selection from disk - dataset.read(rbuf, PredType::STD_REF_OBJ); + // Read selection from disk + dataset.read(rbuf, PredType::STD_REF_OBJ); - // Dereference dataset object by ctor, from the location where - // 'dataset' is located - DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl); + // Dereference dataset object by ctor, from the location where + // 'dataset' is located + DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl); - // Check information in the referenced dataset - sid1 = dset2.getSpace(); - hssize_t n_elements = sid1.getSimpleExtentNpoints(); - verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + // Check information in the referenced dataset + sid1 = dset2.getSpace(); + hssize_t n_elements = sid1.getSimpleExtentNpoints(); + verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); - // Read from disk - dset2.read(tbuf, PredType::NATIVE_UINT); + // Read from disk + dset2.read(tbuf, PredType::NATIVE_UINT); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) + verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); - // Close dereferenced dataset - dset2.close(); + // Close dereferenced dataset + dset2.close(); - // Dereference group object from the location where 'dataset' is located - group.dereference(dataset, &rbuf[2]); + // Dereference group object from the location where 'dataset' is located + group.dereference(dataset, &rbuf[2]); - // Get group's comment using - // H5std_string getComment(const char* name, ) - H5std_string read_comment1 = group.getComment(".", 10); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + // Get group's comment using + // H5std_string getComment(const char* name, ) + H5std_string read_comment1 = group.getComment(".", 10); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); - // Test with the old default value - read_comment1 = group.getComment(".", 256); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + // Test with the old default value + read_comment1 = group.getComment(".", 256); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); - // Test that getComment handles failures gracefully, using - // H5std_string getComment(const char* name, ) - try { - H5std_string read_comment_tmp = group.getComment(NULL); - } - catch (Exception& E) {} // We expect this to fail + // Test that getComment handles failures gracefully, using + // H5std_string getComment(const char* name, ) + try { + H5std_string read_comment_tmp = group.getComment(NULL); + } + catch (Exception& E) {} // We expect this to fail - // Close group - group.close(); + // Close group + group.close(); - /* - * Verify correct referenced datatype - */ - // Open datatype object - dtype1.dereference(dataset, &rbuf[3]); + /* + * Verify correct referenced datatype + */ + // Open datatype object + dtype1.dereference(dataset, &rbuf[3]); - // Verify correct datatype + // Verify correct datatype H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); - int n_members = dtype1.getNmembers(); + verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); + int n_members = dtype1.getNmembers(); verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__); - // Close all objects and file - dtype1.close(); - dataset.close(); - file1->close(); + // Close all objects and file + dtype1.close(); + dataset.close(); + file1->close(); - // Free allocated buffers - HDfree(wbuf); - HDfree(rbuf); - HDfree(tbuf); + // Free allocated buffers + HDfree(wbuf); + HDfree(rbuf); + HDfree(tbuf); - PASSED(); + PASSED(); } // end try catch (Exception& E) { - issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -376,7 +376,7 @@ static void test_reference_obj(void) ** ** test_reference_group(): Test object reference functionality ** Tests for correct behavior of various routines on -** dereferenced group +** dereferenced group ** ****************************************************************/ #define GROUPNAME "/group" @@ -389,8 +389,8 @@ static void test_reference_obj(void) static void test_reference_group(void) { - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ + hobj_ref_t wref; /* Reference to write */ + hobj_ref_t rref; /* Reference to read */ const H5std_string write_comment="Foo!"; // Comments for group // Output message about test being performed @@ -398,102 +398,102 @@ test_reference_group(void) H5File* file1 = NULL; try { - /* - * Create file with a group and a dataset containing an object - * reference to the group - */ + /* + * Create file with a group and a dataset containing an object + * reference to the group + */ // Create file FILE1 file1 = new H5File (FILE1, H5F_ACC_TRUNC); - // Create scalar dataspace - DataSpace sid1; + // Create scalar dataspace + DataSpace sid1; - // Create a group - Group group = file1->createGroup(GROUPNAME); + // Create a group + Group group = file1->createGroup(GROUPNAME); - /* Create nested groups */ - Group group2 = group.createGroup(GROUPNAME2); - group2.close(); - group2 = group.createGroup(GROUPNAME3); - group2.close(); + /* Create nested groups */ + Group group2 = group.createGroup(GROUPNAME2); + group2.close(); + group2 = group.createGroup(GROUPNAME3); + group2.close(); - // Create bottom dataset - DataSet dset1 = group.createDataSet(DSETNAME2, PredType::NATIVE_INT, sid1); - dset1.close(); + // Create bottom dataset + DataSet dset1 = group.createDataSet(DSETNAME2, PredType::NATIVE_INT, sid1); + dset1.close(); - // Close group 1 - group.close(); + // Close group 1 + group.close(); - // Create dataset - DataSet dset2 = file1->createDataSet(DSETNAME, PredType::STD_REF_OBJ, sid1); + // Create dataset + DataSet dset2 = file1->createDataSet(DSETNAME, PredType::STD_REF_OBJ, sid1); - file1->reference(&wref, GROUPNAME); + file1->reference(&wref, GROUPNAME); - // Write selection to disk - dset2.write(&wref, PredType::STD_REF_OBJ); + // Write selection to disk + dset2.write(&wref, PredType::STD_REF_OBJ); - // Close resources - dset2.close(); - sid1.close(); - file1->close(); + // Close resources + dset2.close(); + sid1.close(); + file1->close(); - /* - * Re-open the file and test deferencing group - */ + /* + * Re-open the file and test deferencing group + */ - // Re-open file + // Re-open file file1->openFile(FILE1, H5F_ACC_RDWR); - // Re-open dataset - dset1 = file1->openDataSet(DSETNAME); + // Re-open dataset + dset1 = file1->openDataSet(DSETNAME); - // Read in the reference - dset1.read(&rref, PredType::STD_REF_OBJ); + // Read in the reference + dset1.read(&rref, PredType::STD_REF_OBJ); - // Dereference to get the group - Group refgroup(dset1, &rref); + // Dereference to get the group + Group refgroup(dset1, &rref); - // Dereference group object the other way - group.dereference(dset1, &rref); + // Dereference group object the other way + group.dereference(dset1, &rref); - /* - * Various queries on the group opened - */ + /* + * Various queries on the group opened + */ - // Check number of objects in the group dereferenced by constructor - hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + // Check number of objects in the group dereferenced by constructor + hsize_t nobjs = refgroup.getNumObjs(); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); - // Check number of objects in the group dereferenced by ::reference - nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + // Check number of objects in the group dereferenced by ::reference + nobjs = group.getNumObjs(); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); - // Check getting file name given the group dereferenced via constructor - H5std_string fname = refgroup.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + // Check getting file name given the group dereferenced via constructor + H5std_string fname = refgroup.getFileName(); + verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); - // Check getting file name given the group dereferenced by ::reference - fname = group.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); - - // Unlink one of the objects in the dereferenced group, and re-check - refgroup.unlink(GROUPNAME2); - nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); - - // Close resources - group.close(); - refgroup.close(); - dset1.close(); - file1->close(); - - PASSED(); + // Check getting file name given the group dereferenced by ::reference + fname = group.getFileName(); + verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + + // Unlink one of the objects in the dereferenced group, and re-check + refgroup.unlink(GROUPNAME2); + nobjs = refgroup.getNumObjs(); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); + + // Close resources + group.close(); + refgroup.close(); + dset1.close(); + file1->close(); + + PASSED(); } // end try catch (Exception& E) { - issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + issue_fail_msg("test_reference_group()",__LINE__,__FILE__, + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -509,283 +509,283 @@ test_reference_group(void) static void test_reference_region_1D(void) { - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ hsize_t * coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ int i; /* counting variables */ // Output message about test being performed SUBTEST("1-D Dataset Region Reference Functions"); try { - hdset_reg_ref_t *wbuf, // buffer to write to disk - *rbuf; // buffer read from disk - uint8_t *dwbuf, // Buffer for writing numeric data to disk - *drbuf; // Buffer for reading numeric data from disk + hdset_reg_ref_t *wbuf, // buffer to write to disk + *rbuf; // buffer read from disk + uint8_t *dwbuf, // Buffer for writing numeric data to disk + *drbuf; // Buffer for reading numeric data from disk - // Allocate write & read buffers - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); - dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); - drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); + // Allocate write & read buffers + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); + drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); // Create file FILE1 H5File file1(FILE2, H5F_ACC_TRUNC); - // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; - DataSpace sid3(SPACE3_RANK, dims3); + // Create dataspace for datasets + hsize_t dims3[] = {SPACE3_DIM1}; + DataSpace sid3(SPACE3_RANK, dims3); - // Create dataset access property list - PropList dapl(H5P_DATASET_ACCESS); + // Create dataset access property list + PropList dapl(H5P_DATASET_ACCESS); - // Create a dataset - DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); + // Create a dataset + DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); - uint8_t *tu8; // Temporary pointer to uint8 data - for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) - *tu8++ = i * 3; // from C test + uint8_t *tu8; // Temporary pointer to uint8 data + for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) + *tu8++ = i * 3; // from C test - // Write selection to disk - dset3.write(dwbuf, PredType::STD_U8LE); + // Write selection to disk + dset3.write(dwbuf, PredType::STD_U8LE); - // Close Dataset - dset3.close(); + // Close Dataset + dset3.close(); - // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; - DataSpace sid1(SPACE1_RANK, dims1); + // Create dataspace for datasets + hsize_t dims1[] = {SPACE1_DIM1}; + DataSpace sid1(SPACE1_RANK, dims1); - // Create a dataset - DataSet dset1 = file1.createDataSet(DSET1_NAME, PredType::STD_REF_DSETREG, sid1); + // Create a dataset + DataSet dset1 = file1.createDataSet(DSET1_NAME, PredType::STD_REF_DSETREG, sid1); - /* - * Create references and prepare for testing - */ + /* + * Create references and prepare for testing + */ - /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; - stride[0] = 5; - count[0] = 15; - block[0] = 2; + /* Select 15 2x1 hyperslabs for first reference */ + start[0] = 2; + stride[0] = 5; + count[0] = 15; + block[0] = 2; - // Select a hyperslab region to add to the current selected region - sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); + // Select a hyperslab region to add to the current selected region + sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); - // Get and verify the number of elements in a dataspace selection - hssize_t nelms = sid3.getSelectNpoints(); - verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__); + // Get and verify the number of elements in a dataspace selection + hssize_t nelms = sid3.getSelectNpoints(); + verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__); - // Store first dataset region - file1.reference(&wbuf[0], "/Dataset2", sid3); + // Store first dataset region + file1.reference(&wbuf[0], "/Dataset2", sid3); - // Get and verify object type - H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + // Get and verify object type + H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); - /* Select sequence of ten points for second reference */ - coord1[0][0] = 16; - coord1[1][0] = 22; - coord1[2][0] = 38; - coord1[3][0] = 41; - coord1[4][0] = 52; - coord1[5][0] = 63; - coord1[6][0] = 70; - coord1[7][0] = 89; - coord1[8][0] = 97; - coord1[9][0] = 3; - - // Selects array elements to be included in the selection for sid3 - sid3.selectElements(H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); - - // Get and verify the number of elements in a dataspace selection - nelms = sid3.getSelectNpoints(); - verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); - - // Store first dataset region - file1.reference(&wbuf[1], "/Dataset2", sid3); - - // Write selection to disk - dset1.write(wbuf, PredType::STD_REF_DSETREG); - - // Close disk dataspace, dataset, and file - sid1.close(); - dset1.close(); - sid3.close(); - file1.close(); - - /* - * Testing various dereference functions - */ - - // Re-open the file - file1.openFile(FILE2, H5F_ACC_RDWR); - - // Open the dataset - dset1 = file1.openDataSet("/Dataset1"); - - // Read selection from disk - dset1.read(rbuf, PredType::STD_REF_DSETREG); - - { // Test DataSet::dereference - dset3.dereference(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); - - // Get and verify object type - obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); - - // Get dataspace of dset3 the verify number of elements - sid1 = dset3.getSpace(); - nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); - } // End of test DataSet::dereference - - { // Test DataSet constructor -by dereference - // Dereference dataset object by ctor, from the location where - // 'dset1' is located - DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); - - // Get dataspace of newds then verify number of elements - sid1 = newds.getSpace(); - nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); - - // Close objects for this mini test - newds.close(); - sid1.close(); - } // End of test DataSet constructor -by dereference - - // Read from disk - dset3.read(drbuf, PredType::STD_U8LE); - - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); - - /* - * Test getting the referenced region - */ - - // Get region - DataSpace reg_sp = dset1.getRegion(&rbuf[0]); - - // Get and verify number of elements in a dataspace selection - nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); - - // Get and verify number of hyperslab blocks - nelms = reg_sp.getSelectHyperNblocks(); - verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__); - - /* Allocate space for the hyperslab blocks */ - coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); - - // Get the list of hyperslab blocks currently selected - reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); - - // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); - - HDfree(coords); - - // Check boundaries - reg_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); - - /* Close region space */ - reg_sp.close(); - - /* - * Another test on getting the referenced region - */ - - // Get region - DataSpace elm_sp = dset1.getRegion(&rbuf[1]); - - // Get and verify number of element points in the current selection - hssize_t nelmspts = elm_sp.getSelectElemNpoints(); - verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__); - - /* Allocate space for the hyperslab blocks */ - coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); - - // Get the list of element points currently selected - elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); - - // Verify points - verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__); - - HDfree(coords); - - // Check boundaries - elm_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); - - // Close element space - elm_sp.close(); - - // Close resources - sid1.close(); - dset3.close(); - dset1.close(); - file1.close(); - - // Free memory buffers - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); - - PASSED(); + /* Select sequence of ten points for second reference */ + coord1[0][0] = 16; + coord1[1][0] = 22; + coord1[2][0] = 38; + coord1[3][0] = 41; + coord1[4][0] = 52; + coord1[5][0] = 63; + coord1[6][0] = 70; + coord1[7][0] = 89; + coord1[8][0] = 97; + coord1[9][0] = 3; + + // Selects array elements to be included in the selection for sid3 + sid3.selectElements(H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + + // Get and verify the number of elements in a dataspace selection + nelms = sid3.getSelectNpoints(); + verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); + + // Store first dataset region + file1.reference(&wbuf[1], "/Dataset2", sid3); + + // Write selection to disk + dset1.write(wbuf, PredType::STD_REF_DSETREG); + + // Close disk dataspace, dataset, and file + sid1.close(); + dset1.close(); + sid3.close(); + file1.close(); + + /* + * Testing various dereference functions + */ + + // Re-open the file + file1.openFile(FILE2, H5F_ACC_RDWR); + + // Open the dataset + dset1 = file1.openDataSet("/Dataset1"); + + // Read selection from disk + dset1.read(rbuf, PredType::STD_REF_DSETREG); + + { // Test DataSet::dereference + dset3.dereference(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); + + // Get and verify object type + obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + + // Get dataspace of dset3 the verify number of elements + sid1 = dset3.getSpace(); + nelms = sid1.getSimpleExtentNpoints(); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + } // End of test DataSet::dereference + + { // Test DataSet constructor -by dereference + // Dereference dataset object by ctor, from the location where + // 'dset1' is located + DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); + + // Get dataspace of newds then verify number of elements + sid1 = newds.getSpace(); + nelms = sid1.getSimpleExtentNpoints(); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + + // Close objects for this mini test + newds.close(); + sid1.close(); + } // End of test DataSet constructor -by dereference + + // Read from disk + dset3.read(drbuf, PredType::STD_U8LE); + + for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + + /* + * Test getting the referenced region + */ + + // Get region + DataSpace reg_sp = dset1.getRegion(&rbuf[0]); + + // Get and verify number of elements in a dataspace selection + nelms = reg_sp.getSelectNpoints(); + verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + + // Get and verify number of hyperslab blocks + nelms = reg_sp.getSelectHyperNblocks(); + verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + + /* Allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); + + // Get the list of hyperslab blocks currently selected + reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); + + // Verify values in the list + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); + + HDfree(coords); + + // Check boundaries + reg_sp.getSelectBounds(low, high); + verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + + /* Close region space */ + reg_sp.close(); + + /* + * Another test on getting the referenced region + */ + + // Get region + DataSpace elm_sp = dset1.getRegion(&rbuf[1]); + + // Get and verify number of element points in the current selection + hssize_t nelmspts = elm_sp.getSelectElemNpoints(); + verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + + /* Allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); + + // Get the list of element points currently selected + elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); + + // Verify points + verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__); + + HDfree(coords); + + // Check boundaries + elm_sp.getSelectBounds(low, high); + verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + + // Close element space + elm_sp.close(); + + // Close resources + sid1.close(); + dset3.close(); + dset1.close(); + file1.close(); + + // Free memory buffers + HDfree(wbuf); + HDfree(rbuf); + HDfree(dwbuf); + HDfree(drbuf); + + PASSED(); } // end try catch (Exception& E) { - issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, + E.getCFuncName(), E.getCDetailMsg()); } } /* test_reference_region_1D() */ @@ -823,9 +823,9 @@ void test_reference(void) /**************************************************************** -** Function: cleanup_reference -** Purpose: Cleanup temporary test files -** Return: none +** Function: cleanup_reference +** Purpose Cleanup temporary test files +** Return none ****************************************************************/ extern "C" void cleanup_reference(void) diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 6605c03..0cc8918 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -37,7 +37,7 @@ using namespace H5; * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -70,7 +70,7 @@ const char *FILENAME[] = { * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) +#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) typedef enum flt_t { @@ -86,12 +86,12 @@ typedef enum int_t { /*------------------------------------------------------------------------- * Function: test_classes * - * Purpose: Test type classes + * Purpose Test type classes * - * Return: None. + * Return None. * - * Programmer: Binh-Minh Ribler (using C version) - * January, 2007 + * Programmer Binh-Minh Ribler (using C version) + * January, 2007 * * Modifications: * @@ -101,38 +101,38 @@ static void test_classes() { SUBTEST("PredType::getClass()"); try { - // maybe later, int curr_nerrors = GetTestNumErrs(); - - // PredType::NATIVE_INT should be in H5T_INTEGER class - H5T_class_t tcls = PredType::NATIVE_INT.getClass(); - if (H5T_INTEGER!=tcls) { - puts(" Invalid type class for H5T_NATIVE_INT"); - } - - // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class - tcls = PredType::NATIVE_DOUBLE.getClass(); - if (H5T_FLOAT!=tcls) { - verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); - } - PASSED(); + // maybe later, int curr_nerrors = GetTestNumErrs(); + + // PredType::NATIVE_INT should be in H5T_INTEGER class + H5T_class_t tcls = PredType::NATIVE_INT.getClass(); + if (H5T_INTEGER!=tcls) { + puts(" Invalid type class for H5T_NATIVE_INT"); + } + + // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class + tcls = PredType::NATIVE_DOUBLE.getClass(); + if (H5T_FLOAT!=tcls) { + verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); + } + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } /*------------------------------------------------------------------------- * Function: test_copy * - * Purpose: Test datatype copy functionality + * Purpose Test datatype copy functionality * - * Return: Success: 0 + * Return Success: 0 * - * Failure: number of errors + * Failure: number of errors * - * Programmer: Binh-Minh Ribler (using C version) - * January, 2007 + * Programmer Binh-Minh Ribler (using C version) + * January, 2007 * * Modifications: * @@ -143,21 +143,21 @@ static void test_copy() SUBTEST("DataType::copy() and DataType::operator="); try { - // Test copying from a predefined datatype using DataType::operator= - DataType assigned_type; - assigned_type = PredType::NATIVE_SHORT; + // Test copying from a predefined datatype using DataType::operator= + DataType assigned_type; + assigned_type = PredType::NATIVE_SHORT; // Test copying a predefined type using DataType::copy - DataType copied_type; + DataType copied_type; copied_type.copy (PredType::STD_B8LE); - // Test copying a user-defined type using DataType::operator= - DataType assigned_usertype; - assigned_usertype = copied_type; + // Test copying a user-defined type using DataType::operator= + DataType assigned_usertype; + assigned_usertype = copied_type; - // Test copying from a user-defined datatype using DataType::copy - DataType copied_usertype; - copied_usertype.copy(copied_type); + // Test copying from a user-defined datatype using DataType::copy + DataType copied_usertype; + copied_usertype.copy(copied_type); // Test copying a user-defined int type using DataType::operator= IntType orig_int(PredType::STD_B8LE); @@ -171,26 +171,26 @@ static void test_copy() IntType another_int_type; another_int_type = new_int_type; - PASSED(); + PASSED(); } catch (Exception& E) { - issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } /*------------------------------------------------------------------------- - * Function: test_query + * Function: test_query * - * Purpose: Tests query functions of compound and enumeration types. + * Purpose Tests query functions of compound and enumeration types. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: number of errors + * Failure: number of errors * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -203,113 +203,113 @@ const H5std_string EnumT_NAME("Enum_type"); static void test_query() { typedef struct { - int a; - float b; - long c; - double d; + int a; + float b; + long c; + double d; } src_typ_t; - short enum_val; + short enum_val; // Output message about test being performed SUBTEST("Query functions of compound and enumeration types"); try { - // Create File - H5File file(FILENAME[2], H5F_ACC_TRUNC); - - // Create a compound datatype - CompType tid1(sizeof(src_typ_t)); - - tid1.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); - tid1.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); - - // Create a enumerate datatype - EnumType tid2(sizeof(short)); - - tid2.insert("RED", (enum_val=0,&enum_val)); - tid2.insert("GREEN", (enum_val=1,&enum_val)); - tid2.insert("BLUE", (enum_val=2,&enum_val)); - tid2.insert("ORANGE", (enum_val=3,&enum_val)); - tid2.insert("YELLOW", (enum_val=4,&enum_val)); - - // Query member number and member index by name, for compound type - int nmembs = tid1.getNmembers(); - verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__); - - int index = tid1.getMemberIndex("c"); - verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__); - - // Query member number and member index by name, for enumeration type. - nmembs = tid2.getNmembers(); - verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__); - - index = tid2.getMemberIndex("ORANGE"); - verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__); - - // Commit compound datatype and close it - tid1.commit(file, CompT_NAME); - tid1.close(); - - // Commit enumeration datatype and close it - tid2.commit(file, EnumT_NAME); - tid2.close(); - - // Open the datatypes for query - - // Deprecated functions - tid1 = file.openCompType(CompT_NAME); - tid1.close(); - tid2 = file.openEnumType(EnumT_NAME); - tid2.close(); - - CompType comptype(file, CompT_NAME); - EnumType enumtype(file, EnumT_NAME); - - // Query member number and member index by name, for compound type - nmembs = comptype.getNmembers(); - verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__); - index = comptype.getMemberIndex("c"); - verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__); - - // Query member number and member index by name, for enumeration type - nmembs = enumtype.getNmembers(); - verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__); - index = enumtype.getMemberIndex("ORANGE"); - verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__); - - // Close datatypes and file - comptype.close(); - enumtype.close(); - file.close(); - - // Try truncating the file to make sure reference counting is good. - // If any references to ids of the accessed types are left unterminated, - // the truncating will fail, because the file will not be closed in - // the file.close() above. - H5File file1(FILENAME[2], H5F_ACC_TRUNC); - - PASSED(); + // Create File + H5File file(FILENAME[2], H5F_ACC_TRUNC); + + // Create a compound datatype + CompType tid1(sizeof(src_typ_t)); + + tid1.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); + tid1.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); + + // Create a enumerate datatype + EnumType tid2(sizeof(short)); + + tid2.insert("RED", (enum_val=0,&enum_val)); + tid2.insert("GREEN", (enum_val=1,&enum_val)); + tid2.insert("BLUE", (enum_val=2,&enum_val)); + tid2.insert("ORANGE", (enum_val=3,&enum_val)); + tid2.insert("YELLOW", (enum_val=4,&enum_val)); + + // Query member number and member index by name, for compound type + int nmembs = tid1.getNmembers(); + verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__); + + int index = tid1.getMemberIndex("c"); + verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__); + + // Query member number and member index by name, for enumeration type. + nmembs = tid2.getNmembers(); + verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__); + + index = tid2.getMemberIndex("ORANGE"); + verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__); + + // Commit compound datatype and close it + tid1.commit(file, CompT_NAME); + tid1.close(); + + // Commit enumeration datatype and close it + tid2.commit(file, EnumT_NAME); + tid2.close(); + + // Open the datatypes for query + + // Deprecated functions + tid1 = file.openCompType(CompT_NAME); + tid1.close(); + tid2 = file.openEnumType(EnumT_NAME); + tid2.close(); + + CompType comptype(file, CompT_NAME); + EnumType enumtype(file, EnumT_NAME); + + // Query member number and member index by name, for compound type + nmembs = comptype.getNmembers(); + verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__); + index = comptype.getMemberIndex("c"); + verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__); + + // Query member number and member index by name, for enumeration type + nmembs = enumtype.getNmembers(); + verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__); + index = enumtype.getMemberIndex("ORANGE"); + verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__); + + // Close datatypes and file + comptype.close(); + enumtype.close(); + file.close(); + + // Try truncating the file to make sure reference counting is good. + // If any references to ids of the accessed types are left unterminated, + // the truncating will fail, because the file will not be closed in + // the file.close() above. + H5File file1(FILENAME[2], H5F_ACC_TRUNC); + + PASSED(); } // end of try block catch (Exception& E) { - issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_query /*------------------------------------------------------------------------- - * Function: test_transient + * Function: test_transient * - * Purpose: Tests transient datatypes. + * Purpose Tests transient datatypes. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: number of errors + * Failure: number of errors * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -318,58 +318,58 @@ static void test_query() const char* filename1 = "dtypes1.h5"; static void test_transient () { - static hsize_t ds_size[2] = {10, 20}; + static hsize_t ds_size[2] = {10, 20}; SUBTEST("Transient datatypes"); try { - // Create the file and the dataspace. - H5File file(filename1, H5F_ACC_TRUNC); - DataSpace space(2, ds_size, ds_size); - - // Copying a predefined type results in a modifiable copy - IntType type(PredType::NATIVE_INT); - type.setPrecision(256); - - // It should not be possible to create an attribute for a transient type - try { - Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException& err) {} // do nothing, failure expected - - // Create a dataset from a transient datatype - // type.close(); - put trace in H5Tclose to make sure it's closed - type.copy(PredType::NATIVE_INT); - DataSet dset(file.createDataSet("dset1", type, space)); - - // The type returned from a dataset should not be modifiable - IntType itype(dset); - try { - itype.setPrecision(256); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException& err) {} - itype.close(); - - // Get a copy of the dataset's datatype by applying DataType::copy() - // to the dataset. The resulted datatype should be modifiable. - itype.copy(dset); - itype.setPrecision(256); - itype.close(); - - // Close the dataset and reopen it, testing that its type is still - // read-only. (Note that a copy of it is modifiable.) - dset.close(); - dset = file.openDataSet("dset1"); - - // Close objects and file. - dset.close(); - file.close(); - type.close(); - space.close(); - PASSED(); + // Create the file and the dataspace. + H5File file(filename1, H5F_ACC_TRUNC); + DataSpace space(2, ds_size, ds_size); + + // Copying a predefined type results in a modifiable copy + IntType type(PredType::NATIVE_INT); + type.setPrecision(256); + + // It should not be possible to create an attribute for a transient type + try { + Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); + } catch (AttributeIException& err) {} // do nothing, failure expected + + // Create a dataset from a transient datatype + // type.close(); - put trace in H5Tclose to make sure it's closed + type.copy(PredType::NATIVE_INT); + DataSet dset(file.createDataSet("dset1", type, space)); + + // The type returned from a dataset should not be modifiable + IntType itype(dset); + try { + itype.setPrecision(256); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); + } catch (DataTypeIException& err) {} + itype.close(); + + // Get a copy of the dataset's datatype by applying DataType::copy() + // to the dataset. The resulted datatype should be modifiable. + itype.copy(dset); + itype.setPrecision(256); + itype.close(); + + // Close the dataset and reopen it, testing that its type is still + // read-only. (Note that a copy of it is modifiable.) + dset.close(); + dset = file.openDataSet("dset1"); + + // Close objects and file. + dset.close(); + file.close(); + type.close(); + space.close(); + PASSED(); } // end of try block catch (Exception& E) { @@ -379,16 +379,16 @@ static void test_transient () /*------------------------------------------------------------------------- - * Function: test_named + * Function: test_named * - * Purpose: Tests named datatypes. + * Purpose Tests named datatypes. * - * Return: Success: 0 + * Return Success: 0 * - * Failure: number of errors + * Failure: number of errors * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * * Modifications: * @@ -397,141 +397,141 @@ static void test_transient () const H5std_string filename2("dtypes2.h5"); static void test_named () { - static hsize_t ds_size[2] = {10, 20}; - hsize_t i; - unsigned attr_data[10][20]; - DataType *ds_type = NULL; + static hsize_t ds_size[2] = {10, 20}; + hsize_t i; + unsigned attr_data[10][20]; + DataType *ds_type = NULL; SUBTEST("Named datatypes"); try { - // Create the file. - H5File file(filename2, H5F_ACC_TRUNC); + // Create the file. + H5File file(filename2, H5F_ACC_TRUNC); - // Create a simple dataspace. - DataSpace space(2, ds_size, ds_size); + // Create a simple dataspace. + DataSpace space(2, ds_size, ds_size); - // Predefined types cannot be committed. - try { - PredType nativeint(PredType::NATIVE_INT); - nativeint.commit(file, "test_named_1 (should not exist)"); + // Predefined types cannot be committed. + try { + PredType nativeint(PredType::NATIVE_INT); + nativeint.commit(file, "test_named_1 (should not exist)"); - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException& err) {} + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); + } catch (DataTypeIException& err) {} - // Copy a predefined datatype and commit the copy. + // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); itype.commit(file, "native-int"); - // Test commit passing in const H5File& for prototype with const - try - { - // Create random char type - IntType atype(PredType::NATIVE_UCHAR); + // Test commit passing in const H5File& for prototype with const + try + { + // Create random char type + IntType atype(PredType::NATIVE_UCHAR); - // Creating group, declared as const - const Group const_grp = file.createGroup("GR as loc"); + // Creating group, declared as const + const Group const_grp = file.createGroup("GR as loc"); - // Commit type passing in const group; compilation would fail if - // no matching prototype - atype.commit(const_grp, "random uchar"); - } // end of try block - catch (Exception& E) + // Commit type passing in const group; compilation would fail if + // no matching prototype + atype.commit(const_grp, "random uchar"); + } // end of try block + catch (Exception& E) { - issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); - } - - // Check that it is committed. - if (itype.committed() == false) - cerr << "IntType::committed() returned false" << endl; - - // We should not be able to modify a type after it has been committed. - try { - itype.setPrecision(256); // attempt an invalid action... - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException& err) {} - - // We should not be able to re-commit a committed type - try { - itype.commit(file, "test_named_2 (should not exist)"); - - // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException& err) {} // do nothing, failure expected - - // It should be possible to define an attribute for the named type - Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); - for (i=0; icommitted(); - if (!iscommitted) - throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); - dset.close(); - ds_type->close(); + issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); + } + + // Check that it is committed. + if (itype.committed() == false) + cerr << "IntType::committed() returned false" << endl; + + // We should not be able to modify a type after it has been committed. + try { + itype.setPrecision(256); // attempt an invalid action... + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); + } catch (DataTypeIException& err) {} + + // We should not be able to re-commit a committed type + try { + itype.commit(file, "test_named_2 (should not exist)"); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); + } catch (DataTypeIException& err) {} // do nothing, failure expected + + // It should be possible to define an attribute for the named type + Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); + for (i=0; icommitted(); + if (!iscommitted) + throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); + dset.close(); + ds_type->close(); delete ds_type; - // Reopen the dataset and its type, then make sure the type is - // a named type. - dset = file.openDataSet("dset1"); - ds_type = new DataType(dset.getDataType()); - iscommitted = ds_type->committed(); - if (!iscommitted) - throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); - - // Close the dataset and create another with the type returned from - // the first dataset. - dset.close(); - dset = file.createDataSet("dset2", *ds_type, space); - ds_type->close(); - dset.close(); + // Reopen the dataset and its type, then make sure the type is + // a named type. + dset = file.openDataSet("dset1"); + ds_type = new DataType(dset.getDataType()); + iscommitted = ds_type->committed(); + if (!iscommitted) + throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); + + // Close the dataset and create another with the type returned from + // the first dataset. + dset.close(); + dset = file.createDataSet("dset2", *ds_type, space); + ds_type->close(); + dset.close(); delete ds_type; - // Reopen the second dataset and make sure the type is shared - dset = file.openDataSet("dset2"); - ds_type = new DataType(dset.getDataType()); - iscommitted = ds_type->committed(); - if (!iscommitted) - throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!"); - ds_type->close(); - - // Get the dataset datatype by applying DataType::copy() to the - // dataset. The resulted datatype should be modifiable. - IntType copied_type; - copied_type.copy(dset); - copied_type.setPrecision(256); - copied_type.close(); - - // Clean up - dset.close(); - itype.close(); - space.close(); - file.close(); - PASSED(); + // Reopen the second dataset and make sure the type is shared + dset = file.openDataSet("dset2"); + ds_type = new DataType(dset.getDataType()); + iscommitted = ds_type->committed(); + if (!iscommitted) + throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!"); + ds_type->close(); + + // Get the dataset datatype by applying DataType::copy() to the + // dataset. The resulted datatype should be modifiable. + IntType copied_type; + copied_type.copy(dset); + copied_type.setPrecision(256); + copied_type.close(); + + // Clean up + dset.close(); + itype.close(); + space.close(); + file.close(); + PASSED(); } // end of try block catch (Exception& E) { @@ -565,14 +565,14 @@ void test_types() /*------------------------------------------------------------------------- - * Function: cleanup_types + * Function: cleanup_types * - * Purpose: Cleanup temporary test files + * Purpose Cleanup temporary test files * - * Return: none + * Return none * - * Programmer: Quincey Koziol - * September 10, 1999 + * Programmer Quincey Koziol + * September 10, 1999 * * Modifications: * @@ -582,5 +582,5 @@ extern "C" void cleanup_types() { for (int i = 0; i < 3; i++) - HDremove(FILENAME[i]); + HDremove(FILENAME[i]); } // cleanup_types diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 43dcc0b..5dee1a2 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -45,9 +45,9 @@ const hsize_t SPACE1_DIM1 = 4; /**************************************************************** ** ** test_vlstr_alloc_custom(): Test VL datatype custom memory -** allocation routines. This routine just uses malloc to -** allocate the memory and increments the amount of memory -** allocated. It is passed into setVlenMemManager. +** allocation routines. This routine just uses malloc to +** allocate the memory and increments the amount of memory +** allocated. It is passed into setVlenMemManager. ** ** Note: exact copy from the C version. ** (Not used now) @@ -55,9 +55,9 @@ const hsize_t SPACE1_DIM1 = 4; #if 0 // not used now static void *test_vlstr_alloc_custom(size_t size, void *info) { - void *ret_value=NULL; // Pointer to return + void *ret_value=NULL; // Pointer to return size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -67,8 +67,8 @@ static void *test_vlstr_alloc_custom(size_t size, void *info) extra=MAX(sizeof(void *),sizeof(size_t)); if((ret_value=HDmalloc(extra+size))!=NULL) { - *(size_t *)ret_value=size; - *mem_used+=size; + *(size_t *)ret_value=size; + *mem_used+=size; } // end if ret_value = ((unsigned char *)ret_value) + extra; @@ -79,9 +79,9 @@ static void *test_vlstr_alloc_custom(size_t size, void *info) /**************************************************************** ** ** test_vlstr_free_custom(): Test VL datatype custom memory -** allocation routines. This routine just uses free to -** release the memory and decrements the amount of memory -** allocated. It is passed into setVlenMemManager. +** allocation routines. This routine just uses free to +** release the memory and decrements the amount of memory +** allocated. It is passed into setVlenMemManager. ** ** Note: exact copy from the C version. ** (Not used now) @@ -91,7 +91,7 @@ static void test_vlstr_free_custom(void *_mem, void *info) { unsigned char *mem; size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -109,14 +109,14 @@ static void test_vlstr_free_custom(void *_mem, void *info) #endif /*------------------------------------------------------------------------- - * Function: test_vlstring_dataset + * Function: test_vlstring_dataset * - * Purpose: Test writing/reading VL strings on datasets. + * Purpose Test writing/reading VL strings on datasets. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * *------------------------------------------------------------------------- */ @@ -136,89 +136,89 @@ static void test_vlstring_dataset() SUBTEST("VL String on Datasets"); try { - // Open the file - H5File file1(FILENAME, H5F_ACC_TRUNC); + // Open the file + H5File file1(FILENAME, H5F_ACC_TRUNC); - // Create a datatype to refer to. - StrType vlst(0, H5T_VARIABLE); + // Create a datatype to refer to. + StrType vlst(0, H5T_VARIABLE); - // Open the root group. - Group root = file1.openGroup("/"); + // Open the root group. + Group root = file1.openGroup("/"); - // Create dataspace for the dataset. - DataSpace ds_space (H5S_SCALAR); + // Create dataspace for the dataset. + DataSpace ds_space (H5S_SCALAR); - // Create an dataset in the root group. - DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); + // Create an dataset in the root group. + DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); - // Write data to the dataset. - dset1.write(DSET1_DATA, vlst); + // Write data to the dataset. + dset1.write(DSET1_DATA, vlst); - // Read and verify the dataset string as a string of chars. - dset1.read(&string_ds_check, vlst); - if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); + // Read and verify the dataset string as a string of chars. + dset1.read(&string_ds_check, vlst); + if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); - HDfree(string_ds_check); // note: no need for std::string test + HDfree(string_ds_check); // note: no need for std::string test string_ds_check = NULL; - // Read and verify the dataset string as an std::string. - H5std_string read_str; - dset1.read(read_str, vlst); - if (read_str != DSET1_DATA) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); + // Read and verify the dataset string as an std::string. + H5std_string read_str; + dset1.read(read_str, vlst); + if (read_str != DSET1_DATA) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); - // Close the dataset. - dset1.close(); + // Close the dataset. + dset1.close(); - // Test scalar type dataset with 1 value. - dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); + // Test scalar type dataset with 1 value. + dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); - dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); - HDmemset(dynstring_ds_write, 'A', 1); + dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); + HDmemset(dynstring_ds_write, 'A', 1); - // Write data to the dataset, then read it back. - dset1.write(&dynstring_ds_write, vlst); - dset1.read(&string_ds_check, vlst); + // Write data to the dataset, then read it back. + dset1.write(&dynstring_ds_write, vlst); + dset1.read(&string_ds_check, vlst); - // Verify data read. - if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) - TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); - HDfree(string_ds_check); + // Verify data read. + if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) + TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); + HDfree(string_ds_check); string_ds_check = NULL; - dset1.close(); + dset1.close(); - // Open dataset DSET1_NAME again. - dset1 = root.openDataSet(DSET1_NAME); + // Open dataset DSET1_NAME again. + dset1 = root.openDataSet(DSET1_NAME); - // Close dataset and file - dset1.close(); - file1.close(); + // Close dataset and file + dset1.close(); + file1.close(); - PASSED(); + PASSED(); } // end try block // Catch all exceptions. catch (Exception& E) { - issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } if(dynstring_ds_write) HDfree(dynstring_ds_write); if(string_ds_check) - HDfree(string_ds_check); + HDfree(string_ds_check); } // test_vlstring_dataset() /*------------------------------------------------------------------------- - * Function: test_vlstring_array_dataset + * Function: test_vlstring_array_dataset * - * Purpose: Test writing/reading VL string array to/from datasets. + * Purpose Test writing/reading VL string array to/from datasets. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler - * July, 2009 + * Programmer Binh-Minh Ribler + * July, 2009 * *------------------------------------------------------------------------- */ @@ -235,89 +235,89 @@ static void test_vlstring_array_dataset() H5File* file1 = NULL; try { // Create file. - file1 = new H5File(FILENAME, H5F_ACC_RDWR); + file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create dataspace for datasets. hsize_t dims1[] = {SPACE1_DIM1}; DataSpace ds_space(SPACE1_RANK, dims1); - // Create a datatype to refer to. - StrType vlst(0, H5T_VARIABLE); - - // Create and write a dataset. - DataSet dataset(file1->createDataSet(DSSTRARR_NAME, vlst, ds_space)); - dataset.write(string_ds_array, vlst); - - // Read and verify the dataset using strings of chars as buffer. - // Note: reading by array of H5std_string doesn't work yet. - char *string_ds_check[SPACE1_DIM1]; - dataset.read(string_ds_check, vlst); - - hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); - - HDfree(string_ds_check[ii]); - } - - // Close objects that are no longer needed. - dataset.close(); - ds_space.close(); - - // - // Test with scalar data space. - // - - // Create H5S_SCALAR data space. - DataSpace scalar_space; - - // Create and write another dataset. - DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); - char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); - HDmemset(wdata2, 'A', 65533); - dataset2.write(&wdata2, vlst); - - char *rdata2; - dataset2.read(&rdata2, vlst); - if (HDstrcmp(wdata2, rdata2)!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); - - // Release resources from second dataset operation. - scalar_space.close(); - dataset2.close(); - HDfree(wdata2); - HDfree(rdata2); - - // Close objects and file. - dataset2.close(); - vlst.close(); - file1->close(); - - PASSED(); + // Create a datatype to refer to. + StrType vlst(0, H5T_VARIABLE); + + // Create and write a dataset. + DataSet dataset(file1->createDataSet(DSSTRARR_NAME, vlst, ds_space)); + dataset.write(string_ds_array, vlst); + + // Read and verify the dataset using strings of chars as buffer. + // Note: reading by array of H5std_string doesn't work yet. + char *string_ds_check[SPACE1_DIM1]; + dataset.read(string_ds_check, vlst); + + hsize_t ii; + for (ii = 0; ii < SPACE1_DIM1; ii++) + { + if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + + HDfree(string_ds_check[ii]); + } + + // Close objects that are no longer needed. + dataset.close(); + ds_space.close(); + + // + // Test with scalar data space. + // + + // Create H5S_SCALAR data space. + DataSpace scalar_space; + + // Create and write another dataset. + DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); + char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); + HDmemset(wdata2, 'A', 65533); + dataset2.write(&wdata2, vlst); + + char *rdata2; + dataset2.read(&rdata2, vlst); + if (HDstrcmp(wdata2, rdata2)!=0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); + + // Release resources from second dataset operation. + scalar_space.close(); + dataset2.close(); + HDfree(wdata2); + HDfree(rdata2); + + // Close objects and file. + dataset2.close(); + vlst.close(); + file1->close(); + + PASSED(); } // end try // Catch all exceptions. catch (Exception& E) { - issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } if(file1) - delete file1; + delete file1; } // end test_vlstring_array_dataset() /*------------------------------------------------------------------------- - * Function: test_vlstrings_special + * Function: test_vlstrings_special * - * Purpose: Test VL string code for special string cases, nil and - * zero-sized. + * Purpose Test VL string code for special string cases, nil and + * zero-sized. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * *------------------------------------------------------------------------- */ @@ -331,110 +331,110 @@ static void test_vlstrings_special() SUBTEST("Special VL Strings"); try { - // Create file. - H5File file1(FILENAME, H5F_ACC_TRUNC); + // Create file. + H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets. hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); - // Create a datatype to refer to. - StrType vlst(0, H5T_VARIABLE); - - // Create a dataset. - DataSet dataset(file1.createDataSet("Dataset3", vlst, sid1)); - - // Read from the dataset before writing data. - dataset.read(rdata, vlst); - - // Check data read in. - hsize_t ii; // counting variable - for (ii=0; iiopenStrType(VLSTR_TYPE); // deprecated + // Try opening datatype again. + vlst = file1->openStrType(VLSTR_TYPE); // deprecated - // Close again and reopen with constructor. - vlst.close(); - StrType vlst1(*file1, VLSTR_TYPE); + // Close again and reopen with constructor. + vlst.close(); + StrType vlst1(*file1, VLSTR_TYPE); - // Close datatype and file. - vlst1.close(); - file1->close(); + // Close datatype and file. + vlst1.close(); + file1->close(); delete file1; - // Open file. - file1 = new H5File(FILENAME, H5F_ACC_RDWR); + // Open file. + file1 = new H5File(FILENAME, H5F_ACC_RDWR); - // Open the variable-length string datatype just created - StrType vlst2(*file1, VLSTR_TYPE); + // Open the variable-length string datatype just created + StrType vlst2(*file1, VLSTR_TYPE); - // Verify character set and padding - cset = vlst2.getCset(); - verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); - pad = vlst2.getStrpad(); - verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + // Verify character set and padding + cset = vlst2.getCset(); + verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); + pad = vlst2.getStrpad(); + verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); - // Close datatype and file - vlst2.close(); - file1->close(); + // Close datatype and file + vlst2.close(); + file1->close(); - PASSED(); + PASSED(); } // end try block // Catch all exceptions. @@ -516,18 +516,18 @@ static void test_vlstring_type() } if(file1) - delete file1; + delete file1; } // end test_vlstring_type() /*------------------------------------------------------------------------- - * Function: test_compact_vlstring + * Function: test_compact_vlstring * - * Purpose: Test storing VL strings in compact datasets. + * Purpose Test storing VL strings in compact datasets. * - * Return: None + * Return None * - * Programmer: Binh-Minh Ribler (use C version) - * January, 2007 + * Programmer Binh-Minh Ribler (use C version) + * January, 2007 * *------------------------------------------------------------------------- */ @@ -537,55 +537,55 @@ static void test_compact_vlstring() SUBTEST("VL Strings on Compact Dataset"); try { - // Create file - H5File file1(FILENAME, H5F_ACC_TRUNC); + // Create file + H5File file1(FILENAME, H5F_ACC_TRUNC); - // Create dataspace for datasets + // Create dataspace for datasets hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); - // Create a datatype to refer to - StrType vlst(0, H5T_VARIABLE); - - // Create dataset create property list and set layout - DSetCreatPropList plist; - plist.setLayout(H5D_COMPACT); - - // Create a dataset - DataSet dataset(file1.createDataSet("Dataset5", vlst, sid1, plist)); - - // Write dataset to disk - const char *wdata[SPACE1_DIM1] = {"one", "two", "three", "four"}; - dataset.write(wdata, vlst); - - // Read dataset from disk - char *rdata[SPACE1_DIM1]; // Information read in - dataset.read(rdata, vlst); - - // Compare data read in - hsize_t i; - for (i=0; i Date: Tue, 7 Mar 2017 12:50:41 -0800 Subject: Align with incoming page buffering changes: minor cleanups, centralize removing entries from collective metadata read list --- src/H5C.c | 65 +++++++++++++++------------- src/H5Cimage.c | 134 ++++++++++++++++++++++++++++++++++++++++----------------- src/H5Fint.c | 11 ++--- 3 files changed, 133 insertions(+), 77 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index 805b4f5..8b43c77 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -925,12 +925,6 @@ H5C_expunge_entry(H5F_t *f, hid_t dxpl_id, const H5C_class_t *type, HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected") if(entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned") -#ifdef H5_HAVE_PARALLEL - if(entry_ptr->coll_access) { - entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ /* If we get this far, call H5C__flush_single_entry() with the * H5C__FLUSH_INVALIDATE_FLAG and the H5C__FLUSH_CLEAR_ONLY_FLAG. @@ -1465,10 +1459,15 @@ H5C_insert_entry(H5F_t * f, entry_ptr->prefetched = FALSE; entry_ptr->prefetch_type_id = 0; entry_ptr->age = 0; + entry_ptr->prefetched_dirty = FALSE; #ifndef NDEBUG /* debugging field */ entry_ptr->serialization_count = 0; #endif /* NDEBUG */ + entry_ptr->tl_next = NULL; + entry_ptr->tl_prev = NULL; + entry_ptr->tag_info = NULL; + /* Apply tag to newly inserted entry */ if(H5C__tag_entry(cache_ptr, entry_ptr, dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") @@ -2437,7 +2436,7 @@ H5C_protect(H5F_t * f, marked as collective, and is clean, it is possible that other processes will not have it in its cache and will expect a bcast of the entry from process 0. So process 0 - will bcast the entry to all other ranks. Ranks that do have + will bcast the entry to all other ranks. Ranks that _do_ have the entry in their cache still have to participate in the bcast. */ #ifdef H5_HAVE_PARALLEL @@ -6033,10 +6032,6 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, else destroy_entry = destroy; -#ifdef H5_HAVE_PARALLEL - HDassert(FALSE == entry_ptr->coll_access); -#endif - /* we will write the entry to disk if it exists, is dirty, and if the * clear only flag is not set. */ @@ -6232,9 +6227,11 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, * * 2) Delete it from the skip list if requested. * - * 3) Update the replacement policy for eviction + * 3) Delete it from the collective read access list. * - * 4) Remove it from the tag list for this object + * 4) Update the replacement policy for eviction + * + * 5) Remove it from the tag list for this object * * Finally, if the destroy_entry flag is set, discard the * entry. @@ -6244,6 +6241,14 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, if(entry_ptr->in_slist && del_from_slist_on_destroy) H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) +#ifdef H5_HAVE_PARALLEL + /* Check for collective read access flag */ + if(entry_ptr->coll_access) { + entry_ptr->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) /* Remove entry from tag list */ @@ -6290,7 +6295,8 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") /* Propagate the clean flag up the flush dependency chain if appropriate */ - HDassert(entry_ptr->flush_dep_ndirty_children == 0); + if(entry_ptr->flush_dep_ndirty_children != 0) + HDassert(entry_ptr->flush_dep_ndirty_children == 0); if(entry_ptr->flush_dep_nparents > 0) if(H5C__mark_flush_dep_clean(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep clean flag") @@ -6826,6 +6832,10 @@ H5C_load_entry(H5F_t * f, entry->serialization_count = 0; #endif /* NDEBUG */ + entry->tl_next = NULL; + entry->tl_prev = NULL; + entry->tag_info = NULL; + H5C__RESET_CACHE_ENTRY_STATS(entry); ret_value = thing; @@ -6864,13 +6874,6 @@ done: * Thus the function simply does its best, returning success * unless an error is encountered. * - * The primary_dxpl_id and secondary_dxpl_id parameters - * specify the dxpl_ids used on the first write occasioned - * by the call (primary_dxpl_id), and on all subsequent - * writes (secondary_dxpl_id). This is useful in the metadata - * cache, but may not be needed elsewhere. If so, just use the - * same dxpl_id for both parameters. - * * Observe that this function cannot occasion a read. * * Return: Non-negative on success/Negative on failure. @@ -6980,13 +6983,6 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; -#ifdef H5_HAVE_PARALLEL - if(TRUE == entry_ptr->coll_access) { - entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) - } /* end if */ -#endif - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") @@ -8723,12 +8719,21 @@ H5C_remove_entry(void *_entry) /* Update the cache internal data structures as appropriate for a destroy. * Specifically: * 1) Delete it from the index - * 2) Update the replacement policy for eviction - * 3) Remove it from the tag list for this object + * 2) Delete it from the collective read access list + * 3) Update the replacement policy for eviction + * 4) Remove it from the tag list for this object */ H5C__DELETE_FROM_INDEX(cache, entry, FAIL) +#ifdef H5_HAVE_PARALLEL + /* Check for collective read access flag */ + if(entry->coll_access) { + entry->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL) /* Remove entry from tag list */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 1da2545..3a21137 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -489,7 +489,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, */ HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); - HDassert(H5F_addr_defined(addr)); HDassert(type->get_initial_load_size); HDassert(type->deserialize); @@ -498,6 +497,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, * relationships now. The client will restore the relationship(s) with * the deserialized entry if appropriate. */ + HDassert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); for(i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { HDassert(pf_entry_ptr->flush_dep_parent); HDassert(pf_entry_ptr->flush_dep_parent[i]); @@ -525,7 +525,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, */ if(pf_entry_ptr->fd_child_count > 0) { if(NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc(sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") if(H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry child flush dependency(s).") @@ -544,7 +544,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, */ if(NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image") - ds_entry_ptr = (H5C_cache_entry_t *)thing; /* In general, an entry should be clean just after it is loaded. @@ -583,8 +582,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; ds_entry_ptr->image_up_to_date = !dirty; ds_entry_ptr->type = type; - ds_entry_ptr->is_dirty = dirty | - pf_entry_ptr->is_dirty; + ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; ds_entry_ptr->dirtied = FALSE; ds_entry_ptr->is_protected = FALSE; ds_entry_ptr->is_read_only = FALSE; @@ -626,7 +624,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, pf_entry_ptr->coll_prev = NULL; #endif /* H5_HAVE_PARALLEL */ - /* initialize cache image related fields */ + /* Initialize cache image related fields */ ds_entry_ptr->include_in_image = FALSE; ds_entry_ptr->lru_rank = 0; ds_entry_ptr->image_dirty = FALSE; @@ -638,6 +636,10 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, ds_entry_ptr->prefetched = FALSE; ds_entry_ptr->prefetch_type_id = 0; ds_entry_ptr->age = 0; + ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; +#ifndef NDEBUG /* debugging field */ + ds_entry_ptr->serialization_count = 0; +#endif /* NDEBUG */ H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr); @@ -666,7 +668,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, * and H5C__FLUSH_CLEAR_ONLY_FLAG flags set. */ pf_entry_ptr->image_ptr = NULL; - if ( pf_entry_ptr->is_dirty ) { + if(pf_entry_ptr->is_dirty) { HDassert(pf_entry_ptr->in_slist); flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; } /* end if */ @@ -684,7 +686,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL) HDassert(!ds_entry_ptr->in_slist); - if(ds_entry_ptr->is_dirty) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL) @@ -699,16 +700,13 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache") - /* restore flush dependencies with the flush dependency children of + /* Restore flush dependencies with the flush dependency children of * of the prefetched entry. Note that we must protect *ds_entry_ptr * before the call to avoid triggering sanity check failures, and * then unprotect it afterwards. */ i = 0; if(fd_children != NULL) { - int j; - hbool_t found; - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL) ds_entry_ptr->is_protected = TRUE; while(fd_children[i] != NULL) { @@ -718,15 +716,22 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, HDassert((fd_children[i])->fd_parent_count > 0); HDassert((fd_children[i])->fd_parent_addrs); - j = 0; - found = FALSE; - while((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { - if((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) - found = TRUE; +#ifndef NDEBUG + { + int j; + hbool_t found; - j++; - } /* end while */ - HDassert(found); + j = 0; + found = FALSE; + while((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { + if((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) + found = TRUE; + + j++; + } /* end while */ + HDassert(found); + } +#endif /* NDEBUG */ if(H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency") @@ -735,7 +740,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, } /* end while */ H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, ds_entry_ptr, FAIL); - ds_entry_ptr->is_protected = FALSE; } /* end if ( fd_children != NULL ) */ HDassert((unsigned)i == ds_entry_ptr->fd_child_count); @@ -1262,6 +1266,26 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") } /* end if */ + /* Before we start to generate the cache image (if requested), verify + * that the superblock supports superblock extension messages, and + * silently cancel any request for a cache image if it does not. + * + * Ideally, we would do this when the cache image is requested, + * but the necessary information is not necessary available at that + * time -- hence this last minute check. + * + * Note that under some error conditions, the superblock will be + * undefined in this case as well -- if so, assume that the + * superblock does not support superblock extension messages. + */ + if((NULL == f->shared->sblock) || + (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2)) { + H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; + + cache_ptr->image_ctl = default_image_ctl; + HDassert(!(cache_ptr->image_ctl.generate_image)); + } /* end if */ + /* Generate the cache image, if requested */ if(cache_ptr->image_ctl.generate_image) { /* Create the cache image super block extension message. @@ -1386,7 +1410,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) */ if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) if(H5C__write_cache_image_superblock_msg(f, dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "update of cache image SB mesg failed.") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "update of cache image SB mesg failed") /* At this point: * @@ -1440,7 +1464,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) */ if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) if(H5F_super_ext_remove_msg(f, dxpl_id, H5O_MDCI_MSG_ID) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove MDC image msg from superblock ext.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove MDC image msg from superblock ext") cache_ptr->image_ctl.generate_image = FALSE; } /* end else */ @@ -1458,6 +1482,18 @@ done: * image_ctl field of *cache_ptr. Make adjustments for * changes in configuration as required. * + * If the file is open read only, silently + * force the cache image configuration to its default + * (which disables construction of a cache image). + * + * Note that in addition to being inapplicable in the + * read only case, cache image is also inapplicable if + * the superblock does not support superblock extension + * messages. Unfortunately, this information need not + * be available at this point. Thus we check for this + * later, in H5C_prep_for_file_close() and cancel the + * cache image request if appropriate. + * * Fail if the new configuration is invalid. * * Return: SUCCEED on success, and FAIL on failure. @@ -1483,26 +1519,13 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, /* Check arguments */ if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") - if(config_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5C__CURR_CACHE_IMAGE_CTL_VER) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown config version") - /* check general configuration section of the config: */ + /* Validate the config: */ if(H5C_validate_cache_image_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid cache image configuration") - if(H5F_INTENT(f) & H5F_ACC_RDWR) /* file has been opened R/W */ - cache_ptr->image_ctl = *config_ptr; - else { /* file opened R/O -- suppress cache image silently */ - H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; - - cache_ptr->image_ctl = default_image_ctl; - HDassert(!(cache_ptr->image_ctl.generate_image)); - } /* end else */ - #ifdef H5_HAVE_PARALLEL - /* the collective metadata write code is not currently compatible + /* The collective metadata write code is not currently compatible * with cache image. Until this is fixed, suppress cache image silently * if there is more than one process. * JRM -- 11/8/16 @@ -1513,6 +1536,30 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, cache_ptr->image_ctl = default_image_ctl; HDassert(!(cache_ptr->image_ctl.generate_image)); } /* end if */ + else { +#endif /* H5_HAVE_PARALLEL */ + /* A cache image can only be generated if the file is opened read / write + * and the superblock supports superblock extension messages. + * + * However, the superblock version is not available at this point -- + * hence we can only check the former requirement now. Do the latter + * check just before we construct the image.. + * + * If the file is opened read / write, apply the supplied configuration. + * + * If it is not, set the image configuration to the default, which has + * the effect of silently disabling the cache image if it was requested. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) + cache_ptr->image_ctl = *config_ptr; + else { + H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; + + cache_ptr->image_ctl = default_image_ctl; + HDassert(!(cache_ptr->image_ctl.generate_image)); + } /* end else */ +#ifdef H5_HAVE_PARALLEL + } /* end else */ #endif /* H5_HAVE_PARALLEL */ done: @@ -3186,7 +3233,13 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, * this as otherwise the cache will attempt to write them on file * close. Since the file is R/O, the metadata cache image superblock * extension message and the cache image block will not be removed. - * Hence no danger in this. + * Hence no danger in this for subsequent opens. + * + * However, if the dirty entry (marked clean for purposes of the R/O + * file open) is evicted and then referred to, the cache will read + * either invalid or obsolete data from the file. Handle this by + * setting the prefetched_dirty field, and hiding such entries from + * the eviction candidate selection algorithm. */ pf_entry_ptr->is_dirty = (is_dirty && file_is_rw); @@ -3204,6 +3257,8 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode dirty dependency child count */ UINT16DECODE(p, pf_entry_ptr->fd_dirty_child_count); + if(!file_is_rw) + pf_entry_ptr->fd_dirty_child_count = 0; if(pf_entry_ptr->fd_dirty_child_count > pf_entry_ptr->fd_child_count) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid dirty flush dependency child count") @@ -3263,6 +3318,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, pf_entry_ptr->image_up_to_date = TRUE; pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; pf_entry_ptr->prefetched = TRUE; + pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); /* Sanity checks */ HDassert(pf_entry_ptr->size > 0 && pf_entry_ptr->size < H5C_MAX_ENTRY_SIZE); diff --git a/src/H5Fint.c b/src/H5Fint.c index d122357..4e308a5 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1312,7 +1312,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") } /* end if */ else if (1 == shared->nrefs) { - /* Read the superblock if it hasn't been read before. */ if(H5F__super_read(file, dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") @@ -1360,12 +1359,11 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, */ if(H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get evict on close value") - - if(shared->nrefs == 1) { + if(shared->nrefs == 1) shared->evict_on_close = evict_on_close; - } else if(shared->nrefs > 1) { + else if(shared->nrefs > 1) { if(shared->evict_on_close != evict_on_close) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file evict-on-close value doesn't match") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "file evict-on-close value doesn't match") } /* end if */ /* Formulate the absolute path for later search of target file for external links */ @@ -1405,7 +1403,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, else { /* H5F_ACC_RDONLY: check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) { if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) @@ -1413,12 +1410,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is not already open for SWMR writing") - } /* end if */ else if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) || (file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write (may use to clear file consistency flags)") - } /* version 3 superblock */ } /* end else */ } /* end if set_flag */ -- cgit v0.12 From 71fa3dc480d9d6b1ea00c4f10e9ee0ec10c2c8d9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Mar 2017 11:51:17 -0600 Subject: Fix alignment --- test/vds.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/vds.c b/test/vds.c index 999148c..e6bfeb3 100644 --- a/test/vds.c +++ b/test/vds.c @@ -11147,15 +11147,15 @@ test_dapl_values(hid_t fapl_id) hid_t src_sid = -1; /* source data space */ hid_t did1 = -1; /* dataset */ hid_t did2 = -1; /* dataset */ - hsize_t start; /* hyperslab start */ - hsize_t stride; /* hyperslab count */ - hsize_t count; /* hyperslab count */ - hsize_t block; /* hyperslab count */ - hsize_t dims; /* dataset size */ - hsize_t max_dims; /* dataset max size */ - H5D_vds_view_t view; /* view from dapl */ - hsize_t gap_size; /* gap size from dapl */ - char filename[1024]; /* file names */ + hsize_t start; /* hyperslab start */ + hsize_t stride; /* hyperslab count */ + hsize_t count; /* hyperslab count */ + hsize_t block; /* hyperslab count */ + hsize_t dims; /* dataset size */ + hsize_t max_dims; /* dataset max size */ + H5D_vds_view_t view; /* view from dapl */ + hsize_t gap_size; /* gap size from dapl */ + char filename[1024]; /* file names */ TESTING("H5Dget_access_plist() returns dapl w/ correct values"); -- cgit v0.12 From ed37cbfd2e3b8146944d0deaff65309959ac8724 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Wed, 8 Mar 2017 16:21:24 -0600 Subject: Added a check for AM_SILENT_RULES before enabling it. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1b4e0fb..74d2fdb 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ AC_CONFIG_MACRO_DIR([m4]) ## AM_INIT_AUTOMAKE takes a list of options that should be applied to ## every Makefile.am when automake is run. AM_INIT_AUTOMAKE([foreign subdir-objects]) -AM_SILENT_RULES([yes]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) # use silent rules where available - automake 1.11 ## AM_MAINTAINER_MODE turns off "rebuild rules" that contain dependencies ## for Makefiles, configure, src/H5config.h, etc. If AM_MAINTAINER_MODE -- cgit v0.12 From d297ee6e82adbbbbca168997953cdf0c5a3922eb Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Thu, 9 Mar 2017 09:54:19 -0600 Subject: updated AM_SILENT_RULES syntax --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 74d2fdb..2af7988 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ AC_CONFIG_MACRO_DIR([m4]) ## AM_INIT_AUTOMAKE takes a list of options that should be applied to ## every Makefile.am when automake is run. AM_INIT_AUTOMAKE([foreign subdir-objects]) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) # use silent rules where available - automake 1.11 +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # use silent rules where available - automake 1.11 ## AM_MAINTAINER_MODE turns off "rebuild rules" that contain dependencies ## for Makefiles, configure, src/H5config.h, etc. If AM_MAINTAINER_MODE -- cgit v0.12 From 36f06cab798cd45261988e2618018e0763f5e2fd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 9 Mar 2017 21:38:26 -0800 Subject: Remove some usage of "prefetched_dirty" flag (which hasn't been merged from the page_buffering branch yet. Also, bring over improvements to flush candidate entries for parallel code. --- src/H5C.c | 1 - src/H5Cimage.c | 2 - src/H5Cmpio.c | 990 +++++++++++++++++++++++++++++++++------------------------ 3 files changed, 577 insertions(+), 416 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index 8b43c77..cdf01b3 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1459,7 +1459,6 @@ H5C_insert_entry(H5F_t * f, entry_ptr->prefetched = FALSE; entry_ptr->prefetch_type_id = 0; entry_ptr->age = 0; - entry_ptr->prefetched_dirty = FALSE; #ifndef NDEBUG /* debugging field */ entry_ptr->serialization_count = 0; #endif /* NDEBUG */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 3a21137..dcaf968 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -636,7 +636,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, ds_entry_ptr->prefetched = FALSE; ds_entry_ptr->prefetch_type_id = 0; ds_entry_ptr->age = 0; - ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; #ifndef NDEBUG /* debugging field */ ds_entry_ptr->serialization_count = 0; #endif /* NDEBUG */ @@ -3318,7 +3317,6 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, pf_entry_ptr->image_up_to_date = TRUE; pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; pf_entry_ptr->prefetched = TRUE; - pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); /* Sanity checks */ HDassert(pf_entry_ptr->size > 0 && pf_entry_ptr->size < H5C_MAX_ENTRY_SIZE); diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index ebb98b3..1f43866 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -65,6 +65,11 @@ /* Local Prototypes */ /********************/ static herr_t H5C__collective_write(H5F_t *f, hid_t dxpl_id); +static herr_t H5C__flush_candidate_entries(H5F_t *f, hid_t dxpl_id, + unsigned entries_to_flush[H5C_RING_NTYPES], + unsigned entries_to_clear[H5C_RING_NTYPES]); +static herr_t H5C__flush_candidates_in_ring(H5F_t *f, hid_t dxpl_id, + H5C_ring_t ring, unsigned entries_to_flush, unsigned entries_to_clear); /*********************/ @@ -175,31 +180,18 @@ H5C_apply_candidate_list(H5F_t * f, int mpi_rank, int mpi_size) { - hbool_t restart_scan; - hbool_t prev_is_dirty; int i; int m; int n; unsigned first_entry_to_flush; unsigned last_entry_to_flush; - unsigned entries_to_clear = 0; - unsigned entries_to_flush = 0; - unsigned entries_to_flush_or_clear_last = 0; - unsigned entries_to_flush_collectively = 0; - unsigned entries_cleared = 0; - unsigned entries_flushed = 0; - unsigned entries_delayed = 0; - unsigned entries_flushed_or_cleared_last = 0; - unsigned entries_flushed_collectively = 0; - unsigned entries_examined = 0; - unsigned initial_list_len; + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; int * candidate_assignment_table = NULL; + unsigned entries_to_flush[H5C_RING_NTYPES]; + unsigned entries_to_clear[H5C_RING_NTYPES]; haddr_t addr; - H5C_cache_entry_t * clear_ptr = NULL; - H5C_cache_entry_t * next_ptr = NULL; H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * flush_ptr = NULL; - H5C_cache_entry_t * delayed_ptr = NULL; #if H5C_DO_SANITY_CHECKS haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ @@ -220,6 +212,10 @@ H5C_apply_candidate_list(H5F_t * f, HDassert(0 <= mpi_rank); HDassert(mpi_rank < mpi_size); + /* Initialize the entries_to_flush and entries_to_clear arrays */ + HDmemset(entries_to_flush, 0, sizeof(entries_to_flush)); + HDmemset(entries_to_clear, 0, sizeof(entries_to_clear)); + #if H5C_APPLY_CANDIDATE_LIST__DEBUG HDfprintf(stdout, "%s:%d: setting up candidate assignment table.\n", FUNC, mpi_rank); @@ -330,17 +326,26 @@ H5C_apply_candidate_list(H5F_t * f, */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry is protected?!?!?") + /* Sanity checks */ + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring >= H5C_RING_USER); + HDassert(entry_ptr->ring <= H5C_RING_SB); + HDassert(!entry_ptr->flush_immediately); + HDassert(!entry_ptr->clear_on_unprotect); + /* Determine whether the entry is to be cleared or flushed, * and mark it accordingly. We will scan the protected and * pinned list shortly, and clear or flush according to these * markings. */ if(u >= first_entry_to_flush && u <= last_entry_to_flush) { - entries_to_flush++; + total_entries_to_flush++; + entries_to_flush[entry_ptr->ring]++; entry_ptr->flush_immediately = TRUE; } /* end if */ else { - entries_to_clear++; + total_entries_to_clear++; + entries_to_clear[entry_ptr->ring]++; entry_ptr->clear_on_unprotect = TRUE; } /* end else */ @@ -356,372 +361,36 @@ H5C_apply_candidate_list(H5F_t * f, } /* end if */ } /* end for */ +#if H5C_DO_SANITY_CHECKS + m = 0; + n = 0; + for(i = 0; i < H5C_RING_NTYPES; i++) { + m += (int)entries_to_flush[i]; + n += (int)entries_to_clear[i]; + } /* end if */ + + HDassert((unsigned)m == total_entries_to_flush); + HDassert((unsigned)n == total_entries_to_clear); +#endif /* H5C_DO_SANITY_CHECKS */ + #if H5C_APPLY_CANDIDATE_LIST__DEBUG HDfprintf(stdout, "%s:%d: num candidates/to clear/to flush = %u/%u/%u.\n", - FUNC, mpi_rank, num_candidates, entries_to_clear, - entries_to_flush); + FUNC, mpi_rank, num_candidates, total_entries_to_clear, + total_entries_to_flush); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ /* We have now marked all the entries on the candidate list for * either flush or clear -- now scan the LRU and the pinned list - * for these entries and do the deed. + * for these entries and do the deed. Do this via a call to + * H5C__flush_candidate_entries(). * * Note that we are doing things in this round about manner so as * to preserve the order of the LRU list to the best of our ability. * If we don't do this, my experiments indicate that we will have a * noticably poorer hit ratio as a result. */ - -#if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, "%s:%d: scanning LRU list. len = %d.\n", FUNC, mpi_rank, - (int)(cache_ptr->LRU_list_len)); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* ===================================================================== * - * Now scan the LRU and PEL lists, flushing or clearing entries as - * needed. - * - * The flush_me_last flag may dictate how or - * when some entries can be flushed, and should be addressed here. - * However, in their initial implementation, these flags only apply to the - * superblock, so there's only a relatively small change to this function - * to account for this one case where they come into play. If these flags - * are ever expanded upon, this function and the following flushing steps - * should be reworked to account for additional cases. - * ===================================================================== */ - - HDassert(entries_to_flush >= 0); - - restart_scan = FALSE; - entries_examined = 0; - initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; - - /* Examine each entry in the LRU list */ - while ( ( entry_ptr != NULL ) - && - ( entries_examined <= (entries_to_flush + 1) * initial_list_len ) - && - ( (entries_cleared + entries_flushed) < num_candidates ) ) { - - if ( entry_ptr->prev != NULL ) - prev_is_dirty = entry_ptr->prev->is_dirty; - - /* If this process needs to clear this entry. */ - if(entry_ptr->clear_on_unprotect) { - - HDassert(entry_ptr->is_dirty); - - next_ptr = entry_ptr->next; - entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->prev; - entries_cleared++; - -#if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: clearing 0x%llx.\n", FUNC, mpi_rank, - (long long)clear_ptr->addr); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - * - * Note that as of this writing (April 2015) this - * case cannot occur in the parallel case. However - * Quincey is making noises about changing this, hence - * the insertion of this test. - * - * Note also that there is no test code to verify - * that this code actually works (although similar code - * in the serial version exists and is tested). - * - * Implementing a test will likely require implementing - * flush op like facilities in the parallel tests. At - * a guess this will not be terribly painful, but it - * will take a bit of time. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") - - if((cache_ptr->entries_removed_counter > 1) || - (cache_ptr->last_entry_removed_ptr == entry_ptr)) - restart_scan = TRUE; - } /* end if */ - - /* Else, if this process needs to flush this entry. */ - else if (entry_ptr->flush_immediately) { - - HDassert(entry_ptr->is_dirty); - - next_ptr = entry_ptr->next; - entry_ptr->flush_immediately = FALSE; - flush_ptr = entry_ptr; - entry_ptr = entry_ptr->prev; - entries_flushed++; - -#if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: flushing 0x%llx.\n", FUNC, mpi_rank, - (long long)flush_ptr->addr); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - * - * Note that as of this writing (April 2015) this - * case cannot occur in the parallel case. However - * Quincey is making noises about changing this, hence - * the insertion of this test. - * - * Note also that there is no test code to verify - * that this code actually works (although similar code - * in the serial version exists and is tested). - * - * Implementing a test will likely require implementing - * flush op like facilities in the parallel tests. At - * a guess this will not be terribly painful, but it - * will take a bit of time. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - - /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") - - if((cache_ptr->entries_removed_counter > 1) || - (cache_ptr->last_entry_removed_ptr == entry_ptr)) - restart_scan = TRUE; - } /* end else-if */ - - /* Otherwise, no action to be taken on this entry. Grab the next. */ - else { - entry_ptr = entry_ptr->prev; - - if ( entry_ptr != NULL ) - next_ptr = entry_ptr->next; - - } /* end else */ - - if ( ( entry_ptr != NULL ) - && - ( ( restart_scan ) - || - ( entry_ptr->is_dirty != prev_is_dirty ) - || - ( entry_ptr->next != next_ptr ) - || - ( entry_ptr->is_protected ) - || - ( entry_ptr->is_pinned ) - ) - ) { - - /* something has happened to the LRU -- start over - * from the tail. - * - * Recall that this code should be un-reachable at present, - * as all the operations by entries on flush that could cause - * it to be reachable are disallowed in the parallel case at - * present. Hence the following assertion which should be - * removed if the above changes. - */ - - HDassert( ! restart_scan ); - HDassert( entry_ptr->is_dirty == prev_is_dirty ); - HDassert( entry_ptr->next == next_ptr ); - HDassert( ! entry_ptr->is_protected ); - HDassert( ! entry_ptr->is_pinned ); - - HDassert(FALSE); /* see comment above */ - - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; -/* - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) -*/ - } - - entries_examined++; - } /* end while */ - -#if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, "%s:%d: entries examined/cleared/flushed = %u/%u/%u.\n", - FUNC, mpi_rank, entries_examined, - entries_cleared, entries_flushed); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* It is also possible that some of the cleared entries are on the - * pinned list. Must scan that also. - * - * WARNING: - * - * As we now allow unpinning, and removal of other entries as a side - * effect of flushing an entry, it is possible that the next entry - * in a PEL scan could either be no longer pinned, or no longer in - * the cache by the time we get to it. - * - * At present, this is not possible in this case, as we disallow such - * operations in the parallel version of the library. However, Quincey - * has been making noises about relaxing this. If and when he does, - * we have a potential problem here. - * - * The same issue exists in the serial cache, and there are tests - * to detect this problem when it occurs, and adjust to it. As seen - * above in the LRU scan, I have ported such tests to the parallel - * code where a close cognate exists in the serial code. - * - * I haven't done so here, as there are no PEL scans where the problem - * can occur in the serial code. Needless to say, this will have to - * be repaired if the constraints on pre_serialize and serialize - * callbacks are relaxed in the parallel version of the metadata cache. - * - * JRM -- 4/1/15 - */ - -#if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, "%s:%d: scanning pinned entry list. len = %d\n", - FUNC, mpi_rank, (int)(cache_ptr->pel_len)); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - entry_ptr = cache_ptr->pel_head_ptr; - while((entry_ptr != NULL) && - ((entries_cleared + entries_flushed + entries_delayed) - < num_candidates)) { - - /* If entry is marked for flush or for clear */ - if((entry_ptr->clear_on_unprotect||entry_ptr->flush_immediately)) { - - /* If this entry needs to be flushed last */ - if (entry_ptr->flush_me_last) { - - /* At this time, only the superblock supports being - flushed last. Conveniently, it also happens to be the only - entry that supports being flushed collectively, as well. Also - conveniently, it's always pinned, so we only need to check - for it while scanning the PEL here. Finally, it's never - included in a candidate list that excludes other dirty - entries in a cache, so we can handle this relatively simple - case here. - - For now, this function asserts this and saves the entry - to flush it after scanning the rest of the PEL list. - - If there are ever more entries that either need to be - flushed last and/or flushed collectively, this whole routine - will need to be reworked to handle all additional cases. As - it is the simple case of a single pinned entry needing - flushed last and collectively is just a minor addition to - this routine, but signficantly buffing up the usage of - flush_me_last will require a more - intense rework of this function and potentially the function - of candidate lists as a whole. */ - - entries_to_flush_or_clear_last++; - entries_to_flush_collectively++; - HDassert(entries_to_flush_or_clear_last == 1); - HDassert(entries_to_flush_collectively == 1); - - /* Delay the entry. It will be flushed later. */ - delayed_ptr = entry_ptr; - entries_delayed++; - HDassert(entries_delayed == 1); - - } /* end if */ - - /* Else, this process needs to clear this entry. */ - else if (entry_ptr->clear_on_unprotect) { - HDassert(!entry_ptr->flush_immediately); - entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->next; - entries_cleared++; - -#if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: clearing 0x%llx.\n", FUNC, mpi_rank, - (long long)clear_ptr->addr); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") - } /* end else-if */ - - /* Else, if this process needs to independently flush this entry. */ - else if (entry_ptr->flush_immediately) { - entry_ptr->flush_immediately = FALSE; - flush_ptr = entry_ptr; - entry_ptr = entry_ptr->next; - entries_flushed++; - -#if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: flushing 0x%llx.\n", FUNC, mpi_rank, - (long long)flush_ptr->addr); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") - } /* end else-if */ - } /* end if */ - - /* Otherwise, this entry is not marked for flush or clear. Grab the next. */ - else { - entry_ptr = entry_ptr->next; - } /* end else */ - - } /* end while */ - -#if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, - "%s:%d: pel entries examined/cleared/flushed = %u/%u/%u.\n", - FUNC, mpi_rank, entries_examined, - entries_cleared, entries_flushed); - HDfprintf(stdout, "%s:%d: done.\n", FUNC, mpi_rank); - - HDfsync(stdout); -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - /* ====================================================================== * - * Now, handle all delayed entries. * - * * - * This can *only* be the superblock at this time, so it's relatively * - * easy to deal with. We're collectively flushing the entry saved from * - * above. This will need to be handled differently if there are ever more * - * than one entry needing this special treatment.) * - * ====================================================================== */ - - if (delayed_ptr) { - - if (delayed_ptr->clear_on_unprotect) { - if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") - - entry_ptr->clear_on_unprotect = FALSE; - entries_cleared++; - } else if (delayed_ptr->flush_immediately) { - /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry collectively.") - - entry_ptr->flush_immediately = FALSE; - entries_flushed++; - } /* end if */ - - entries_flushed_collectively++; - entries_flushed_or_cleared_last++; - } /* end if */ + if(H5C__flush_candidate_entries(f, dxpl_id, entries_to_flush, entries_to_clear) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates failed") /* If we've deferred writing to do it collectively, take care of that now */ if(f->coll_md_write) { @@ -733,21 +402,6 @@ H5C_apply_candidate_list(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata collectively") } /* end if */ - /* ====================================================================== * - * Finished flushing everything. * - * ====================================================================== */ - - HDassert((entries_flushed == entries_to_flush)); - HDassert((entries_cleared == entries_to_clear)); - HDassert((entries_flushed_or_cleared_last == entries_to_flush_or_clear_last)); - HDassert((entries_flushed_collectively == entries_to_flush_collectively)); - - if((entries_flushed != entries_to_flush) || - (entries_cleared != entries_to_clear) || - (entries_flushed_or_cleared_last != entries_to_flush_or_clear_last) || - (entries_flushed_collectively != entries_to_flush_collectively)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry count mismatch") - done: if(candidate_assignment_table != NULL) candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table); @@ -998,11 +652,13 @@ H5C_mark_entries_as_clean(H5F_t * f, { H5C_t * cache_ptr; unsigned entries_cleared; + unsigned pinned_entries_cleared; + hbool_t progress; unsigned entries_examined; unsigned initial_list_len; haddr_t addr; -#if H5C_DO_SANITY_CHECKS unsigned pinned_entries_marked = 0; +#if H5C_DO_SANITY_CHECKS unsigned protected_entries_marked = 0; unsigned other_entries_marked = 0; haddr_t last_addr; @@ -1086,19 +742,13 @@ H5C_mark_entries_as_clean(H5F_t * f, } /* end if */ entry_ptr->clear_on_unprotect = TRUE; + if(entry_ptr->is_pinned) + pinned_entries_marked++; #if H5C_DO_SANITY_CHECKS - if ( entry_ptr->is_protected ) { - + else if(entry_ptr->is_protected) protected_entries_marked++; - - } else if ( entry_ptr->is_pinned ) { - - pinned_entries_marked++; - - } else { - + else other_entries_marked++; - } #endif /* H5C_DO_SANITY_CHECKS */ } } @@ -1140,7 +790,8 @@ H5C_mark_entries_as_clean(H5F_t * f, entry_ptr = entry_ptr->prev; entries_cleared++; - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else @@ -1155,19 +806,27 @@ H5C_mark_entries_as_clean(H5F_t * f, /* It is also possible that some of the cleared entries are on the * pinned list. Must scan that also. */ - entry_ptr = cache_ptr->pel_head_ptr; - while(entry_ptr != NULL) { - if(entry_ptr->clear_on_unprotect) { - entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->next; - entries_cleared++; + pinned_entries_cleared = 0; + progress = TRUE; + while((pinned_entries_cleared < pinned_entries_marked) && progress) { + progress = FALSE; + entry_ptr = cache_ptr->pel_head_ptr; + while(entry_ptr != NULL) { + if(entry_ptr->clear_on_unprotect && entry_ptr->flush_dep_ndirty_children == 0) { + entry_ptr->clear_on_unprotect = FALSE; + clear_ptr = entry_ptr; + entry_ptr = entry_ptr->next; + entries_cleared++; + pinned_entries_cleared++; + progress = TRUE; - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry") - } /* end if */ - else - entry_ptr = entry_ptr->next; + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") + } /* end if */ + else + entry_ptr = entry_ptr->next; + } /* end while */ } /* end while */ #if H5C_DO_SANITY_CHECKS @@ -1297,7 +956,6 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id) /* Get number of entries in collective write list */ count = (int)H5SL_count(cache_ptr->coll_write_list); - if(count > 0) { H5FD_mpio_xfer_t xfer_mode = H5FD_MPIO_COLLECTIVE; H5SL_node_t *node; @@ -1410,4 +1068,510 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5C__collective_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__flush_candidate_entries + * + * Purpose: Flush or clear (as indicated) the candidate entries that + * have been marked in the metadata cache. In so doing, + * observe rings and flush dependencies. + * + * Note that this function presumes that: + * + * 1) no candidate entries are protected, + * + * 2) all candidate entries are dirty, and + * + * 3) if a candidate entry has a dirty flush dependency + * child, that child is also a candidate entry. + * + * The function will fail if any of these preconditions are + * not met. + * + * Candidate entries are marked by setting either the + * flush_immediately or the clear_on_unprotect flags in the + * cache entry (but not both). Entries marked flush_immediately + * will be flushed, those marked clear_on_unprotect will be + * cleared. + * + * Note that this function is a modified version of + * H5C_flush_cache() -- any changes there may need to be + * reflected here and vise versa. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer + * 2/10/17 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__flush_candidate_entries(H5F_t *f, hid_t dxpl_id, + unsigned entries_to_flush[H5C_RING_NTYPES], + unsigned entries_to_clear[H5C_RING_NTYPES]) +{ +#if H5C_DO_SANITY_CHECKS + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; +#endif /* H5C_DO_SANITY_CHECKS */ + H5C_ring_t ring; + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(f); + HDassert(f->shared); + + cache_ptr = f->shared->cache; + + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); + + HDassert(entries_to_flush[H5C_RING_UNDEFINED] == 0); + HDassert(entries_to_clear[H5C_RING_UNDEFINED] == 0); + +#if H5C_DO_SANITY_CHECKS + HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; + } /* end for */ + + HDassert(cache_ptr->index_len == index_len); + HDassert(cache_ptr->index_size == index_size); + HDassert(cache_ptr->clean_index_size == clean_index_size); + HDassert(cache_ptr->dirty_index_size == dirty_index_size); + HDassert(cache_ptr->slist_len == slist_len); + HDassert(cache_ptr->slist_size == slist_size); +#endif /* H5C_DO_SANITY_CHECKS */ + +#if H5C_DO_EXTREME_SANITY_CHECKS + if(H5C_validate_protected_entry_list(cache_ptr) < 0 + || H5C_validate_pinned_entry_list(cache_ptr) < 0 + || H5C_validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + cache_ptr->flush_in_progress = TRUE; + + /* flush each ring, starting from the outermost ring and + * working inward. + */ + ring = H5C_RING_USER; + while(ring < H5C_RING_NTYPES) { + if(H5C__flush_candidates_in_ring(f, dxpl_id, ring, entries_to_flush[ring], entries_to_clear[ring]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates in ring failed") + + ring++; + } /* end while */ + +done: + cache_ptr->flush_in_progress = FALSE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_candidate_entries() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__flush_candidates_in_ring + * + * Purpose: Flush or clear (as indicated) the candidate entries + * contained in the specified cache and ring. All candidate + * entries in rings outside the specified ring must have been + * flushed (or cleared) on entry. + * + * Note that this function presumes that: + * + * 1) no candidate entries are protected, + * + * 2) all candidate entries are dirty, and + * + * 3) if a candidate entry has a dirty flush dependency + * child, that child is also a candidate entry. + * + * The function will fail if any of these preconditions are + * not met. + * + * Candidate entries are marked by setting either the + * flush_immediately or the clear_on_unprotect flags in the + * cache entry (but not both). Entries marked flush_immediately + * will be flushed, those marked clear_on_unprotect will be + * cleared. + * + * Candidate entries residing in the LRU must be flushed + * (or cleared) in LRU order to avoid performance issues. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer + * 2/10/17 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__flush_candidates_in_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, + unsigned entries_to_flush, unsigned entries_to_clear) +{ + H5C_t * cache_ptr; + hbool_t progress; + hbool_t restart_scan = FALSE; + unsigned entries_flushed = 0; + unsigned entries_cleared = 0; +#if H5C_DO_SANITY_CHECKS + unsigned init_index_len; +#endif /* H5C_DO_SANITY_CHECKS */ + unsigned clear_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__GENERATE_IMAGE_FLAG; + unsigned flush_flags = H5C__NO_FLAGS_SET; + unsigned op_flags; + H5C_cache_entry_t *op_ptr; + H5C_cache_entry_t *entry_ptr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); + HDassert(ring > H5C_RING_UNDEFINED); + HDassert(ring < H5C_RING_NTYPES); + +#if H5C_DO_EXTREME_SANITY_CHECKS + if((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || + (H5C_validate_lru_list(cache_ptr) < 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +#if H5C_DO_SANITY_CHECKS + /* index len should not change */ + init_index_len = cache_ptr->index_len; +#endif /* H5C_DO_SANITY_CHECKS */ + + /* Examine entries in the LRU list, and flush or clear all entries + * so marked in the target ring. + * + * With the current implementation of flush dependencies, no entry + * in the LRU can have flush dependency children -- thus one pass + * through the LRU will be sufficient. + * + * It is possible that this will change -- hence the assertion. + */ + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + while(((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear)) + && (entry_ptr != NULL)) { + hbool_t prev_is_dirty = FALSE; + H5C_cache_entry_t *next_ptr; + + /* Entries in the LRU must not have flush dependency children */ + HDassert(entry_ptr->flush_dep_nchildren == 0); + + /* Remember dirty state of entry to advance to */ + if(entry_ptr->prev != NULL) + prev_is_dirty = entry_ptr->prev->is_dirty; + + /* If the entry is in the ring */ + if(entry_ptr->ring == ring) { + /* If this process needs to clear this entry. */ + if(entry_ptr->clear_on_unprotect) { + HDassert(entry_ptr->is_dirty); + + /* Set entry and flags for operation */ + op_ptr = entry_ptr; + op_flags = clear_flags; + + /* Set next entry appropriately */ + next_ptr = entry_ptr->next; + + /* Reset entry flag */ + entry_ptr->clear_on_unprotect = FALSE; + entries_cleared++; + } /* end if */ + else if(entry_ptr->flush_immediately) { + HDassert(entry_ptr->is_dirty); + + /* Set entry and flags for operation */ + op_ptr = entry_ptr; + op_flags = flush_flags; + + /* Set next entry appropriately */ + next_ptr = entry_ptr->next; + + /* Reset entry flag */ + entry_ptr->flush_immediately = FALSE; + entries_flushed++; + } /* end else-if */ + else { + /* No operation for this entry */ + op_ptr = NULL; + + /* Set next entry appropriately */ + next_ptr = entry_ptr; + } /* end else */ + + /* Advance to next entry */ + entry_ptr = entry_ptr->prev; + + /* Check for operation */ + if(op_ptr) { + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + * + * Note that as of this writing, this + * case cannot occur in the parallel case. + * + * Note also that there is no test code to verify + * that this code actually works (although similar code + * in the serial version exists and is tested). + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + + if(H5C__flush_single_entry(f, dxpl_id, op_ptr, op_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") + + if(cache_ptr->entries_removed_counter != 0 + || cache_ptr->last_entry_removed_ptr != NULL) + restart_scan = TRUE; + } /* end if */ + } /* end if */ + else { + /* Remember "next" pointer (after advancing entries) */ + next_ptr = entry_ptr; + + /* Advance to next entry */ + entry_ptr = entry_ptr->prev; + } /* end else */ + + /* Check for restarts, etc. */ + if((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != prev_is_dirty) + || (entry_ptr->next != next_ptr) || entry_ptr->is_protected + || entry_ptr->is_pinned)) { + + /* Something has happened to the LRU -- start over + * from the tail. + * + * Recall that this code should be un-reachable at present, + * as all the operations by entries on flush that could cause + * it to be reachable are disallowed in the parallel case at + * present. Hence the following assertion which should be + * removed if the above changes. + */ + HDassert(!restart_scan); + HDassert(entry_ptr->is_dirty == prev_is_dirty); + HDassert(entry_ptr->next == next_ptr); + HDassert(!entry_ptr->is_protected); + HDassert(!entry_ptr->is_pinned); + + HDassert(FALSE); /* see comment above */ + + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + } /* end if */ + } /* end while */ + + /* It is also possible that some of the cleared entries are on the + * pinned list. Must scan that also. + * + * Observe that in the case of the pinned entry list, most of the + * entries will have flush dependency children. As entries with + * flush dependency children may not be flushed until all of their + * children are clean, multiple passes throguh the pinned entry list + * may be required. + * + * WARNING: + * + * As we now allow unpinning, and removal of other entries as a side + * effect of flushing an entry, it is possible that the next entry + * in a PEL scan could either be no longer pinned, or no longer in + * the cache by the time we get to it. + * + * At present, this should not be possible in this case, as we disallow + * such operations in the parallel version of the library. However, + * this may change, and to that end, I have included code to detect + * such changes and cause this function to fail if they are detected. + */ + progress = TRUE; + while(progress && ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + progress = FALSE; + entry_ptr = cache_ptr->pel_head_ptr; + while((entry_ptr != NULL) && + ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + H5C_cache_entry_t *prev_ptr; + hbool_t next_is_dirty = FALSE; + + HDassert(entry_ptr->is_pinned); + + /* Remember dirty state of entry to advance to */ + if(entry_ptr->next != NULL) + next_is_dirty = entry_ptr->next->is_dirty; + + if(entry_ptr->ring == ring && entry_ptr->flush_dep_ndirty_children == 0) { + if(entry_ptr->clear_on_unprotect) { + HDassert(entry_ptr->is_dirty); + + /* Set entry and flags for operation */ + op_ptr = entry_ptr; + op_flags = clear_flags; + + /* Reset entry flag */ + entry_ptr->clear_on_unprotect = FALSE; + entries_cleared++; + progress = TRUE; + } /* end if */ + else if(entry_ptr->flush_immediately) { + HDassert(entry_ptr->is_dirty); + + /* Set entry and flags for operation */ + op_ptr = entry_ptr; + op_flags = flush_flags; + + /* Reset entry flag */ + entry_ptr->flush_immediately = FALSE; + entries_flushed++; + progress = TRUE; + } /* end else-if */ + else + /* No operation for this entry */ + op_ptr = NULL; + + /* Check for operation */ + if(op_ptr) { + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + * + * Note that as of this writing, this + * case cannot occur in the parallel case. + * + * Note also that there is no test code to verify + * that this code actually works (although similar code + * in the serial version exists and is tested). + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + + /* Add this entry to the list of entries to collectively write + * + * This comment is misleading -- the entry will be added to the + * collective write list only if said list exists. + * + * JRM -- 2/9/17 + */ + if(H5C__flush_single_entry(f, dxpl_id, op_ptr, op_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") + + if(cache_ptr->entries_removed_counter != 0 + || cache_ptr->last_entry_removed_ptr != NULL) + restart_scan = TRUE; + } /* end if */ + } /* end if */ + + /* Remember "previous" pointer (after advancing entries) */ + prev_ptr = entry_ptr; + + /* Advance to next entry */ + entry_ptr = entry_ptr->next; + + /* Check for restarts, etc. */ + if((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != next_is_dirty) + || (entry_ptr->prev != prev_ptr) || entry_ptr->is_protected + || !entry_ptr->is_pinned)) { + /* Something has happened to the pinned entry list -- start + * over from the head. + * + * Recall that this code should be un-reachable at present, + * as all the operations by entries on flush that could cause + * it to be reachable are disallowed in the parallel case at + * present. Hence the following assertion which should be + * removed if the above changes. + */ + + HDassert(!restart_scan); + HDassert(entry_ptr->is_dirty == next_is_dirty); + HDassert(entry_ptr->prev == prev_ptr); + HDassert(!entry_ptr->is_protected); + HDassert(entry_ptr->is_pinned); + + HDassert(FALSE); /* see comment above */ + + restart_scan = FALSE; + + entry_ptr = cache_ptr->pel_head_ptr; + + /* we don't keeps stats for pinned entry list scan + * restarts. If this code ever becomes reachable, + * define the necessary field, and implement the + * the following macro: + * + * H5C__UPDATE_STATS_FOR_PEL_SCAN_RESTART(cache_ptr) + */ + } /* end if */ + } /* end while ( ( entry_ptr != NULL ) && + * ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) ) + */ + } /* end while ( ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) && + * ( progress ) ) + */ + +#if H5C_DO_SANITY_CHECKS + HDassert(init_index_len == cache_ptr->index_len); +#endif /* H5C_DO_SANITY_CHECKS */ + + if(entries_flushed != entries_to_flush || entries_cleared != entries_to_clear) { + entry_ptr = cache_ptr->il_head; + while(entry_ptr != NULL) { + HDassert(!entry_ptr->clear_on_unprotect || (entry_ptr->ring > ring)); + HDassert(!entry_ptr->flush_immediately || (entry_ptr->ring > ring)); + entry_ptr = entry_ptr->il_next; + } /* end while */ + + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush/clear all entries") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_candidates_in_ring() */ #endif /* H5_HAVE_PARALLEL */ + -- cgit v0.12 From c4a36e0bb3b56e0c8397876be1c66fedb2f57d83 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 12 Mar 2017 01:57:19 -0800 Subject: Minor cleanups and bring over "prefetched dirty" fixes for entries loaded from a cache image. --- src/H5AC.c | 9 ++--- src/H5ACdbg.c | 2 + src/H5ACprivate.h | 2 +- src/H5C.c | 42 +++++++++++++++----- src/H5Cdbg.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++--- src/H5Cimage.c | 2 + src/H5Cpkg.h | 12 ++++++ src/H5Cprivate.h | 58 +++++++++++++++++++++++---- src/H5Ctag.c | 2 +- test/cache.c | 5 ++- test/cache_tagging.c | 58 ++++++++++++++++++++++++++- test/evict_on_close.c | 1 + 12 files changed, 265 insertions(+), 34 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index ee68a6f..2fb7992 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -501,7 +501,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co /* Turn on metadata cache logging, if being used */ if(H5F_USE_MDC_LOGGING(f)) { if(H5C_set_up_logging(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "mdc logging setup failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "mdc logging setup failed") /* Write the log header regardless of current logging status */ if(H5AC__write_create_cache_log_msg(f->shared->cache) < 0) @@ -510,9 +510,9 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co /* Set the cache parameters */ if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "auto resize configuration failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") - /* don't need to get the current H5C image config here since the + /* Don't need to get the current H5C image config here since the * cache has just been created, and thus f->shared->cache->image_ctl * must still set to its initial value (H5C__DEFAULT_CACHE_IMAGE_CTL). * Note that this not true as soon as control returns to the application @@ -522,9 +522,8 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co int_ci_config.generate_image = image_config_ptr->generate_image; int_ci_config.save_resize_status = image_config_ptr->save_resize_status; int_ci_config.entry_ageout = image_config_ptr->entry_ageout; - if(H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "auto resize configuration failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") done: #ifdef H5_HAVE_PARALLEL diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index 8ca5102..6073288 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -101,6 +101,7 @@ H5AC_stats(const H5F_t *f) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC_stats() */ +#ifndef NDEBUG /*------------------------------------------------------------------------- * Function: H5AC_dump_cache @@ -133,6 +134,7 @@ H5AC_dump_cache(const H5F_t *f) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_dump_cache() */ +#endif /* NDEBUG */ /*------------------------------------------------------------------------- diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 1fe6456..1dc8270 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -482,8 +482,8 @@ H5_DLL herr_t H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr); /* Debugging functions */ H5_DLL herr_t H5AC_stats(const H5F_t *f); -H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); #ifndef NDEBUG +H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr); H5_DLL herr_t H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, diff --git a/src/H5C.c b/src/H5C.c index cdf01b3..0eb9d9b 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1459,6 +1459,7 @@ H5C_insert_entry(H5F_t * f, entry_ptr->prefetched = FALSE; entry_ptr->prefetch_type_id = 0; entry_ptr->age = 0; + entry_ptr->prefetched_dirty = FALSE; #ifndef NDEBUG /* debugging field */ entry_ptr->serialization_count = 0; #endif /* NDEBUG */ @@ -4584,7 +4585,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && ( bytes_evicted < eviction_size_limit ) ) { - hbool_t corked = FALSE; + hbool_t skipping_entry = FALSE; HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert( ! (entry_ptr->is_protected) ); @@ -4598,9 +4599,11 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, prev_is_dirty = prev_ptr->is_dirty; if(entry_ptr->is_dirty ) { + HDassert(!entry_ptr->prefetched_dirty); + /* dirty corked entry is skipped */ if(entry_ptr->tag_info && entry_ptr->tag_info->corked) - corked = TRUE; + skipping_entry = TRUE; else { /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to @@ -4620,16 +4623,22 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, restart_scan = TRUE; } /* end else */ } /* end if */ - else { + else if(!entry_ptr->prefetched_dirty) { bytes_evicted += entry_ptr->size; if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } + } /* end else-if */ + else { + HDassert(!entry_ptr->is_dirty); + HDassert(entry_ptr->prefetched_dirty); + + skipping_entry = TRUE; + } /* end else */ if(prev_ptr != NULL) { - if(corked) /* dirty corked entry is skipped */ + if(skipping_entry) entry_ptr = prev_ptr; else if(restart_scan || (prev_ptr->is_dirty != prev_is_dirty) || (prev_ptr->next != next_ptr) @@ -4689,10 +4698,10 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, prev_ptr = entry_ptr->prev; - if(!(entry_ptr->is_dirty)) { + if(!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") - } /* end if */ + /* just skip the entry if it is dirty, as we can't do * anything with it now since we can't write. * @@ -6827,6 +6836,7 @@ H5C_load_entry(H5F_t * f, entry->prefetched = FALSE; entry->prefetch_type_id = 0; entry->age = 0; + entry->prefetched_dirty = FALSE; #ifndef NDEBUG /* debugging field */ entry->serialization_count = 0; #endif /* NDEBUG */ @@ -6888,6 +6898,7 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, H5C_t * cache_ptr = f->shared->cache; #if H5C_COLLECT_CACHE_STATS int32_t clean_entries_skipped = 0; + int32_t dirty_pf_entries_skipped = 0; int32_t total_entries_scanned = 0; #endif /* H5C_COLLECT_CACHE_STATS */ uint32_t entries_examined = 0; @@ -6956,7 +6967,8 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, didnt_flush_entry = TRUE; } else if ( ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && - ( ! entry_ptr->flush_in_progress ) ) { + ( ! entry_ptr->flush_in_progress ) && + ( ! entry_ptr->prefetched_dirty ) ) { didnt_flush_entry = FALSE; @@ -7015,10 +7027,16 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, } else { - /* Skip epoch markers and entries that are in the process - * of being flushed. + /* Skip epoch markers, entries that are in the process + * of being flushed, and entries marked as prefetched_dirty + * (occurs in the R/O case only). */ didnt_flush_entry = TRUE; + +#if H5C_COLLECT_CACHE_STATS + if(entry_ptr->prefetched_dirty) + dirty_pf_entries_skipped++; +#endif /* H5C_COLLECT_CACHE_STATS */ } if ( prev_ptr != NULL ) { @@ -7083,6 +7101,7 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, cache_ptr->calls_to_msic++; cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; + cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; if ( clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic ) { @@ -7090,6 +7109,9 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; } + if(dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) + cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; + if ( total_entries_scanned > cache_ptr->max_entries_scanned_in_msic ) { cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index eb5f123..a955eaf 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -70,6 +70,7 @@ /*******************/ +#ifndef NDEBUG /*------------------------------------------------------------------------- * Function: H5C_dump_cache @@ -175,6 +176,85 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dump_cache() */ +#endif /* NDEBUG */ + +#ifndef NDEBUG + +/*------------------------------------------------------------------------- + * Function: H5C_dump_cache_LRU + * + * Purpose: Print a summary of the contents of the metadata cache + * LRU for debugging purposes. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 10/10/10 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) +{ + H5C_cache_entry_t * entry_ptr; + int i = 0; + + FUNC_ENTER_NOAPI_NOERR + + /* Sanity check */ + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_name != NULL ); + + HDfprintf(stdout, "\n\nDump of metadata cache LRU \"%s\"\n", cache_name); + HDfprintf(stdout, "LRU len = %d, LRU size = %d\n", + cache_ptr->LRU_list_len, (int)(cache_ptr->LRU_list_size)); + HDfprintf(stdout, "index_size = %d, max_cache_size = %d, delta = %d\n\n", + (int)(cache_ptr->index_size), (int)(cache_ptr->max_cache_size), + (int)(cache_ptr->max_cache_size) - (int)(cache_ptr->index_size)); + + /* Print header */ + HDfprintf(stdout, "Entry "); + HDfprintf(stdout, "| Address "); + HDfprintf(stdout, "| Tag "); + HDfprintf(stdout, "| Size "); + HDfprintf(stdout, "| Ring "); + HDfprintf(stdout, "| Type "); + HDfprintf(stdout, "| Dirty"); + HDfprintf(stdout, "\n"); + + HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + + entry_ptr = cache_ptr->LRU_head_ptr; + while(entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + + /* Print entry */ + HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); + HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); + + if(NULL == entry_ptr->tag_info) + HDfprintf(stdout, " %16s ", "N/A"); + else + HDfprintf(stdout, " 0x%16llx ", + (long long)(entry_ptr->tag_info->tag)); + + HDfprintf(stdout, " %5lld ", (long long)(entry_ptr->size)); + HDfprintf(stdout, " %d ", (int)(entry_ptr->ring)); + HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), + (entry_ptr->type->name)); + HDfprintf(stdout, " %d", (int)(entry_ptr->is_dirty)); + HDfprintf(stdout, "\n"); + + i++; + entry_ptr = entry_ptr->next; + } /* end while */ + + HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5C_dump_cache_LRU() */ +#endif /* NDEBUG */ /*------------------------------------------------------------------------- @@ -385,6 +465,7 @@ H5C_stats(H5C_t * cache_ptr, double average_successful_search_depth = 0.0f; double average_failed_search_depth = 0.0f; double average_entries_skipped_per_calls_to_msic = 0.0f; + double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0f; double average_entries_scanned_per_calls_to_msic = 0.0f; #endif /* H5C_COLLECT_CACHE_STATS */ herr_t ret_value = SUCCEED; /* Return value */ @@ -620,6 +701,17 @@ H5C_stats(H5C_t * cache_ptr, (long)(cache_ptr->max_entries_skipped_in_msic)); if(cache_ptr->calls_to_msic > 0) + average_dirty_pf_entries_skipped_per_call_to_msic = + (((double)(cache_ptr->total_dirty_pf_entries_skipped_in_msic)) / + ((double)(cache_ptr->calls_to_msic))); + + HDfprintf(stdout, + "%s MSIC: Average/max dirty pf entries skipped = %lf / %ld\n", + cache_ptr->prefix, + average_dirty_pf_entries_skipped_per_call_to_msic, + (long)(cache_ptr->max_dirty_pf_entries_skipped_in_msic)); + + if(cache_ptr->calls_to_msic > 0) average_entries_scanned_per_calls_to_msic = (((double)(cache_ptr->total_entries_scanned_in_msic)) / ((double)(cache_ptr->calls_to_msic))); @@ -887,12 +979,14 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) cache_ptr->max_pel_len = 0; cache_ptr->max_pel_size = (size_t)0; - cache_ptr->calls_to_msic = 0; - cache_ptr->total_entries_skipped_in_msic = 0; - cache_ptr->total_entries_scanned_in_msic = 0; - cache_ptr->max_entries_skipped_in_msic = 0; - cache_ptr->max_entries_scanned_in_msic = 0; - cache_ptr->entries_scanned_to_make_space = 0; + cache_ptr->calls_to_msic = 0; + cache_ptr->total_entries_skipped_in_msic = 0; + cache_ptr->total_dirty_pf_entries_skipped_in_msic = 0; + cache_ptr->total_entries_scanned_in_msic = 0; + cache_ptr->max_entries_skipped_in_msic = 0; + cache_ptr->max_dirty_pf_entries_skipped_in_msic = 0; + cache_ptr->max_entries_scanned_in_msic = 0; + cache_ptr->entries_scanned_to_make_space = 0; cache_ptr->slist_scan_restarts = 0; cache_ptr->LRU_scan_restarts = 0; diff --git a/src/H5Cimage.c b/src/H5Cimage.c index dcaf968..3a21137 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -636,6 +636,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t *cache_ptr, ds_entry_ptr->prefetched = FALSE; ds_entry_ptr->prefetch_type_id = 0; ds_entry_ptr->age = 0; + ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; #ifndef NDEBUG /* debugging field */ ds_entry_ptr->serialization_count = 0; #endif /* NDEBUG */ @@ -3317,6 +3318,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, pf_entry_ptr->image_up_to_date = TRUE; pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; pf_entry_ptr->prefetched = TRUE; + pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); /* Sanity checks */ HDassert(pf_entry_ptr->size > 0 && pf_entry_ptr->size < H5C_MAX_ENTRY_SIZE); diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 5b923e9..3ea5144 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4500,12 +4500,22 @@ typedef struct H5C_tag_info_t { * total_entries_skipped_in_msic: Number of clean entries skipped while * enforcing the min_clean_fraction in H5C__make_space_in_cache(). * + * total_dirty_pf_entries_skipped_in_msic: Number of dirty prefetched entries + * skipped in H5C__make_space_in_cache(). Note that this can + * only occur when a file is opened R/O with a cache image + * containing dirty entries. + * * total_entries_scanned_in_msic: Number of clean entries skipped while * enforcing the min_clean_fraction in H5C__make_space_in_cache(). * * max_entries_skipped_in_msic: Maximum number of clean entries skipped * in any one call to H5C__make_space_in_cache(). * + * max_dirty_pf_entries_skipped_in_msic: Maximum number of dirty prefetched + * entries skipped in any one call to H5C__make_space_in_cache(). + * Note that this can only occur when the file is opened + * R/O with a cache image containing dirty entries. + * * max_entries_scanned_in_msic: Maximum number of entries scanned over * in any one call to H5C__make_space_in_cache(). * @@ -4822,8 +4832,10 @@ struct H5C_t { /* Fields for tracking 'make space in cache' (msic) operations */ int64_t calls_to_msic; int64_t total_entries_skipped_in_msic; + int64_t total_dirty_pf_entries_skipped_in_msic; int64_t total_entries_scanned_in_msic; int32_t max_entries_skipped_in_msic; + int32_t max_dirty_pf_entries_skipped_in_msic; int32_t max_entries_scanned_in_msic; int64_t entries_scanned_to_make_space; diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 28eacf2..3408839 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -1066,9 +1066,9 @@ typedef int H5C_ring_t; * * is_read_only: Boolean flag that is only meaningful if is_protected is * TRUE. In this circumstance, it indicates whether the - * entry has been protected read only, or read/write. + * entry has been protected read-only, or read/write. * - * If the entry has been protected read only (i.e. is_protected + * If the entry has been protected read-only (i.e. is_protected * and is_read_only are both TRUE), we allow the entry to be * protected more than once. * @@ -1078,7 +1078,7 @@ typedef int H5C_ring_t; * the entry is actually unprotected. * * ro_ref_count: Integer field used to maintain a count of the number of - * outstanding read only protects on this entry. This field + * outstanding read-only protects on this entry. This field * must be zero whenever either is_protected or is_read_only * are TRUE. * @@ -1458,13 +1458,13 @@ typedef int H5C_ring_t; * the load of a cache image block, although other scenarios * are contemplated for the use of this feature. Note that * unlike the usual prefetch situation, this means that a - * pre fetched entry can be dirty, and/or can be a party to + * prefetched entry can be dirty, and/or can be a party to * flush dependency relationship(s). This complicates matters * somewhat. * - * The essential feature of a pre-fetched entry is that it + * The essential feature of a prefetched entry is that it * consists only of a buffer containing the on disk image of - * the entry. Thus it must be deserialized before it can + * the entry. Thus it must be deserialized before it can * be passed back to the library on a protect call. This * task is handled by H5C_deserialized_prefetched_entry(). * In essence, this routine calls the deserialize callback @@ -1475,7 +1475,7 @@ typedef int H5C_ring_t; * * Further, if the prefetched entry is a flush dependency parent, * all its flush dependency children (which must also be - * pre-fetched entries), must be tranfered to the new cache + * prefetched entries), must be tranfered to the new cache * entry returned by the deserailization callback. * * Finally, if the prefetched entry is a flush dependency child, @@ -1511,6 +1511,46 @@ typedef int H5C_ring_t; * * This field must be zero if prefetched is FALSE. * + * prefetched_dirty: Boolean field that must be set to FALSE unless the + * following conditions hold: + * + * 1) The file has been opened R/O. + * + * 2) The entry is either a prefetched entry, or was + * re-constructed from a prefetched entry. + * + * 3) The base prefetched entry was marked dirty. + * + * This field exists to solve the following problem with + * files containing cache images that are opened R/O. + * + * If the cache image contains a dirty entry, that entry + * must be marked clean when it is inserted into the cache + * in the read-only case, as otherwise the metadata cache + * will attempt to flush it on file close -- which is poor + * form in the read-only case. + * + * However, since the entry is marked clean, it is possible + * that the metadata cache will evict it if the size of the + * metadata in the file exceeds the size of the metadata cache, + * and the application visits much of this data. + * + * If this happens, and the metadata cache is then asked for + * this entry, it will attempt to read it from file, and will + * obtain either obsolete or invalid data depending on whether + * the entry has ever been written to it assigned location in + * the file. + * + * With this background, the purpose of this field should be + * obvious -- when set, it allows the eviction candidate + * selection code to skip over the entry, thus avoiding the + * issue. + * + * Since the issue only arises in the R/O case, there is + * no possible interaction with SWMR. There are also + * potential interactions with Evict On Close -- at present, + * we deal with this by disabling EOC in the R/O case. + * * serialization_count: Integer field used to maintain a count of the * number of times each entry is serialized during cache * serialization. While no entry should be serialized more than @@ -1627,6 +1667,7 @@ typedef struct H5C_cache_entry_t { hbool_t prefetched; int prefetch_type_id; int32_t age; + hbool_t prefetched_dirty; #ifndef NDEBUG /* debugging field */ int serialization_count; @@ -2259,7 +2300,6 @@ H5_DLL herr_t H5C_set_trace_file_ptr(H5C_t *cache_ptr, FILE *trace_file_ptr); H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t display_detailed_stats); H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); -H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); H5_DLL herr_t H5C_unpin_entry(void *thing); H5_DLL herr_t H5C_destroy_flush_dependency(void *parent_thing, void *child_thing); H5_DLL herr_t H5C_unprotect(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *thing, @@ -2289,6 +2329,8 @@ H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, hid_t dxpl_id, unsigned ce_arr #endif /* H5_HAVE_PARALLEL */ #ifndef NDEBUG /* debugging functions */ +H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); +H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name); H5_DLL hbool_t H5C_get_serialization_in_progress(const H5C_t *cache_ptr); H5_DLL hbool_t H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring); H5_DLL herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); diff --git a/src/H5Ctag.c b/src/H5Ctag.c index 157a838..a9bcca1 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -465,7 +465,7 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) entry and we'll loop back around again (as evicting other entries will hopefully unpin this entry) */ ctx->pinned_entries_need_evicted = TRUE; - else { + else if(!entry->prefetched_dirty) { /* Evict the Entry */ if(H5C__flush_single_entry(ctx->f, ctx->dxpl_id, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Entry eviction failed.") diff --git a/test/cache.c b/test/cache.c index 87b1272..ee4bff5 100644 --- a/test/cache.c +++ b/test/cache.c @@ -9825,7 +9825,6 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) } } - if(pass) { /* Now load a large entry. This should result in the eviction @@ -10550,7 +10549,9 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) expected[i].is_dirty = TRUE; } - /* update MET 0 to set its in cache flag, and reset the its destroyed flag */ + /* update MET 0 to set its in cache flag, and reset + * its destroyed flag + */ expected[10].in_cache = TRUE; /* pass through non variable entries will flush VET 8, and evict VET 9. diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 02ce19b..8901468 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -53,13 +53,16 @@ /* ===================== */ /* Helper Functions */ +#ifndef NDEBUG static int dump_cache(hid_t fid); +#endif /* NDEBUG */ /* end debugging functions */ static int verify_no_unknown_tags(hid_t fid); static int mark_all_entries_investigated(hid_t fid); static int reset_all_entries_investigated(hid_t fid); static int verify_tag(hid_t fid, int id, haddr_t tag); static int get_object_header_tag(hid_t loc_id, haddr_t *tag); static int get_sbe_tag(hid_t fid, haddr_t *tag); + /* Tests */ static unsigned check_file_creation_tags(hid_t fcpl_id, int type); static unsigned check_file_open_tags(hid_t fcpl, int type); @@ -71,7 +74,6 @@ static unsigned check_attribute_rename_tags(hid_t fcpl, int type); static unsigned check_dataset_creation_tags(hid_t fcpl, int type); static unsigned check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type); static unsigned check_link_removal_tags(hid_t fcpl, int type); - static unsigned check_group_creation_tags(void); static unsigned check_multi_group_creation_tags(void); static unsigned check_group_open_tags(void); @@ -95,6 +97,7 @@ static unsigned check_invalid_tag_application(void); /* ================ */ +#ifndef NDEBUG /*------------------------------------------------------------------------- * Function: dump_cache() @@ -128,6 +131,7 @@ static int dump_cache(hid_t fid) error: return -1; } /* dump_cache */ +#endif /* NDEBUG */ /* end debugging functions */ /*------------------------------------------------------------------------- @@ -445,8 +449,10 @@ check_file_creation_tags(hid_t fcpl_id, int type) /* Create a test file with provided fcpl_t */ if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0 ) TEST_ERROR; +#ifndef NDEBUG /* if verbose, print cache index to screen before verification . */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify there is a superblock entry with superblock tag */ if ( verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0 ) TEST_ERROR; @@ -551,8 +557,10 @@ check_file_open_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen before verification . */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify there is a superblock entry with superblock tag. */ if ( verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0 ) TEST_ERROR; @@ -653,8 +661,10 @@ check_group_creation_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -756,8 +766,10 @@ check_multi_group_creation_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify there is an object header for each group */ for (i = 0; i < MULTIGROUPS; i++) { @@ -888,8 +900,10 @@ check_link_iteration_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -1005,8 +1019,10 @@ check_dense_attribute_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify free space header and section info */ if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, d_tag) < 0 ) TEST_ERROR; @@ -1061,8 +1077,10 @@ check_dense_attribute_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to dataset */ if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; @@ -1169,8 +1187,10 @@ check_group_open_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -1273,8 +1293,10 @@ check_attribute_creation_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; @@ -1407,8 +1429,10 @@ check_attribute_open_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; @@ -1550,8 +1574,10 @@ check_attribute_rename_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -1712,8 +1738,10 @@ check_attribute_delete_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; @@ -1834,8 +1862,10 @@ check_dataset_creation_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -1959,8 +1989,10 @@ check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -2097,8 +2129,10 @@ check_dataset_open_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -2228,8 +2262,10 @@ check_dataset_write_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify 10 b-tree nodes belonging to dataset */ for (i=0; i<10; i++) @@ -2351,8 +2387,10 @@ check_attribute_write_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify object header of group */ if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; @@ -2506,8 +2544,10 @@ check_dataset_read_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify 19 b-tree nodes belonging to dataset */ for (i=0; i<19; i++) @@ -2636,8 +2676,10 @@ check_dataset_size_retrieval(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify 19 b-tree nodes belonging to dataset */ for (i=0; i<19; i++) @@ -2769,8 +2811,10 @@ check_dataset_extend_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; @@ -2866,8 +2910,10 @@ check_object_info_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -2972,8 +3018,10 @@ check_object_copy_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -3122,8 +3170,10 @@ check_link_removal_tags(hid_t fcpl, int type) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -3271,8 +3321,10 @@ check_link_getname_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -3371,8 +3423,10 @@ check_external_link_creation_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; @@ -3478,8 +3532,10 @@ check_external_link_open_tags(void) /* Verification of Metadata Tag Values */ /* =================================== */ +#ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ if ( verbose ) dump_cache(fid); +#endif /* NDEBUG */ /* end debugging functions */ /* verify tag value of first file's root group */ if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; diff --git a/test/evict_on_close.c b/test/evict_on_close.c index 3986d5a..b00c1e4 100644 --- a/test/evict_on_close.c +++ b/test/evict_on_close.c @@ -40,6 +40,7 @@ #include "H5Ipkg.h" /* Uncomment to manually inspect cache states */ +/* (Requires debug build of the library) */ /* #define EOC_MANUAL_INSPECTION */ const char *FILENAMES[] = { -- cgit v0.12 From 0b78740ff471ff6fe68ceae65e3df76fef886ec4 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Mar 2017 07:45:42 -0700 Subject: Merge in reentrency changes to "make space in cache" from page_buffering branch. --- src/H5C.c | 20 ++ src/H5Cpkg.h | 18 ++ test/cache.c | 97 ++++---- test/cache_image.c | 649 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 733 insertions(+), 51 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index 0eb9d9b..1759292 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -386,6 +386,7 @@ H5C_create(size_t max_cache_size, cache_ptr->cache_full = FALSE; cache_ptr->size_decreased = FALSE; cache_ptr->resize_in_progress = FALSE; + cache_ptr->msic_in_progress = FALSE; (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; (cache_ptr->resize_ctl).rpt_fcn = NULL; @@ -6904,6 +6905,7 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, uint32_t entries_examined = 0; uint32_t initial_list_len; size_t empty_space; + hbool_t reentrant_call = FALSE; hbool_t prev_is_dirty = FALSE; hbool_t didnt_flush_entry = FALSE; hbool_t restart_scan; @@ -6921,6 +6923,18 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the make + * space in cache process. To avoid an infinite recursion, set + * reentrant_call to TRUE, and goto done. + */ + if(cache_ptr->msic_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED); + } /* end if */ + + cache_ptr->msic_in_progress = TRUE; + if ( write_permitted ) { restart_scan = FALSE; initial_list_len = cache_ptr->LRU_list_len; @@ -7180,6 +7194,12 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, } done: + /* Sanity checks */ + HDassert(cache_ptr->msic_in_progress); + if(!reentrant_call) + cache_ptr->msic_in_progress = FALSE; + HDassert((!reentrant_call) || (cache_ptr->msic_in_progress)); + FUNC_LEAVE_NOAPI(ret_value) } /* H5C__make_space_in_cache() */ diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3ea5144..321f1fb 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4104,6 +4104,23 @@ typedef struct H5C_tag_info_t { * of changes to the file driver info superblock extension * management code needed to support rings. * + * msic_in_progress: As the metadata cache has become re-entrant, and as + * the free space manager code has become more tightly + * integrated with the metadata cache, it is possible that + * a call to H5C_insert_entry() may trigger a call to + * H5C_make_space_in_cache(), which, via H5C__flush_single_entry() + * and client callbacks, may trigger an infinite regression + * of calls to H5C_make_space_in_cache(). + * + * The msic_in_progress boolean flag is used to detect this, + * and prevent the infinite regression that would otherwise + * occur. + * + * Note that this is issue is not hypothetical -- this field + * was added 2/16/17 to address this issue when it was + * exposed by modifications to test/fheap.c to cause it to + * use paged allocation. + * * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration * data for automatic cache resizing. * @@ -4743,6 +4760,7 @@ struct H5C_t { hbool_t cache_full; hbool_t size_decreased; hbool_t resize_in_progress; + hbool_t msic_in_progress; H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ diff --git a/test/cache.c b/test/cache.c index ee4bff5..c381776 100644 --- a/test/cache.c +++ b/test/cache.c @@ -10369,14 +10369,28 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * However, (VET 9)'s serialize function needs to modify (VET, 8), * which is currently not in cache. Thus it calls H5C_protect(VET, 8) * to gain access to it. H5C_protect(VET, 8) loads (VET, 8), and - * then attempts to evict entries to make space for it. While (VET, 9) - * is still at the bottom of the LRU, it is marked flush in progress - * and this is skipped. Thus the next entries on the LRU are (MET, 0) - * thru (MET, 30) and (LET, 0) thru (LET, 10) -- all of which are dirty, + * then attempts to evict entries to make space for it. + * + * However, H5C_make_space_in_cache() now exits without taking + * any action on re-entrant calls. Thus H5C_protect(VET, 8) simply + * loads the entry into the cache -- resulting in a cache that is + * 10 KB oversize. The subsequent unprotect puts (VET, 8) at the + * head of the LRU and marks it dirty. + * + * After (VET, 9) is serialized, it is flushed, and moved to the + * head of the LRU. + * + * At this point, the H5C_make_space_in_cache() call made by + * H5C_protect(LET, 11) now has 14 KB of space to make. + * + * The next entries on the LRU are (MET, 0) thru (MET, 30), + * (LET, 0) thru (LET, 10), and (VET, 8) -- all of which are dirty, * and are therefore flushed and moved to the head of the LRU list. * * The next entry on the bottom of the LRU list is (VET, 0), which - * is clean, and is therefore evicted to make space for (VET, 8). + * is clean, and is therefore evicted, leaving H5C_make_space_in_cache() + * with 4 KB of space to create. + * * This space is sufficient, so H5C_protect(VET, 8) inserts * (VET, 8) into the cache's index, marks it as protected, and * returns to the serialize function for (VET, 9). @@ -10385,22 +10399,10 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * calls H5C_unprotect(VET, 8), which markes (VET, 8) as dirty and * unprotected, and places it at the head of the LRU. * - * The serialize function for (VET, 9) then returns, and (VET, 9) is - * is written to disk, marked clean, and moved to the head of the LRU. + * (VET, 0) is the next item on the LRU -- it is clean and is therefore + * evicted -- leaving 6 KB of free space after (LET, 11) is inserted + * into the cache. * - * At this point, the cache is still full (since (VET, 8) took the - * space created by the eviction of (VET, 0)). Thus - * H5C_protect(LET, 11) continues to look for space. While - * (MET, 0) was the next item on the LRU list when it called the - * serialize function for (VET, 9), the function notices that the - * LRU has been modified, and restarts its search for candidates - * for eviction at the bottom of the LRU. - * - * (MET, 0) is now at the bottom of the LRU, and is clean. Thus - * it is evicted. This makes sufficient space for (LET, 11), so - * H5C_protect(LET, 11) inserts it into the cache, marks it as - * protected, and returns. - * * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then * returns as well. * @@ -10426,9 +10428,9 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * * (VET, 7) N 5 KB N N - - * - * (VET, 8) Y 10 KB Y N - - + * (VET, 8) Y 10 KB N N - - * - * (VET, 9) Y 10 KB N N - - + * (VET, 9) N 10 KB N N - - * * Start by updating the expected table for the expected changes in * entry status: @@ -10447,25 +10449,22 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) expected[0].serialized = TRUE; expected[0].destroyed = TRUE; expected[8].in_cache = TRUE; - expected[8].is_dirty = TRUE; + expected[8].is_dirty = FALSE; expected[8].deserialized = TRUE; - expected[8].serialized = FALSE; + expected[8].serialized = TRUE; expected[8].destroyed = FALSE; - expected[9].in_cache = TRUE; + expected[9].in_cache = FALSE; expected[9].is_dirty = FALSE; expected[9].serialized = TRUE; - expected[9].destroyed = FALSE; + expected[9].destroyed = TRUE; - expected[10].in_cache = FALSE; + expected[10].in_cache = TRUE; expected[10].is_dirty = FALSE; expected[10].serialized = TRUE; - expected[10].destroyed = TRUE; + expected[10].destroyed = FALSE; num_large_entries = 12; - /* a newly loaded entry is not inserted in the cache until after - * space has been made for it. Thus (LET, 11) will not be flushed. - */ for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; i++) @@ -10483,10 +10482,10 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* verify cache size */ if((cache_ptr->index_len != 44) || (cache_ptr->index_size != (2 * 1024 * 1024) - - (2 * VARIABLE_ENTRY_SIZE) - - (10 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE) + - (30 * MONSTER_ENTRY_SIZE) + + (2 * 1024) - + (1 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { pass = FALSE; @@ -10496,15 +10495,27 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* verify entry status */ verify_entry_status(cache_ptr, 9, - (num_variable_entries + num_monster_entries + num_large_entries), + (num_variable_entries + num_monster_entries + + num_large_entries), expected); } if(pass) { - /* protect and unprotect VET 8 to move it to the top of the LRU */ + /* protect and unprotect VET 9 to evict MET 0 */ + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); + + /* protect and unprotect VET 8 to dirty it and move it to the + * top of the LRU. Since we are dirtying it again, reset its + * serialized flag. + */ + base_addr = entries[VARIABLE_ENTRY_TYPE]; + entry_ptr = &(base_addr[8]); + entry_ptr->serialized = FALSE; + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__DIRTIED_FLAG); /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the @@ -10516,7 +10527,13 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* skip MET 0 in first pass so that we evict VET 9 when we * reload MET 0 + * + * Since we are reloading MET 0, reset its destroyed flag. */ + base_addr = entries[MONSTER_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); + entry_ptr->destroyed = FALSE; + for (i = 1; i < num_monster_entries; i++) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); @@ -10720,8 +10737,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) if((cache_ptr->insertions[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->pinned_insertions[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->clears[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 8) || - (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 11) || + (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 9) || + (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 12) || (cache_ptr->take_ownerships[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->moves[VARIABLE_ENTRY_TYPE] != 1) || (cache_ptr->entry_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || diff --git a/test/cache_image.c b/test/cache_image.c index de0507b..0e7928a 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -4560,7 +4560,7 @@ cache_image_smoke_check_4(void) * If sufficient zoos have been created, continue to * 10). Otherwise goto 5) * - * 10) Open the file. + * 10) Open the file R/O. * * Verify that the file contains a metadata cache * image superblock extension message. @@ -4571,14 +4571,23 @@ cache_image_smoke_check_4(void) * * 13) Open the file. * - * Verify that the file doesn't contain a metadata cache + * Verify that the file contains a metadata cache * image superblock extension message. * * 14) Validate all the zoos. * * 15) Close the file. * - * 16) Delete the file. + * 16) Open the file. + * + * Verify that the file doesn't contain a metadata cache + * image superblock extension message. + * + * 17) Validate all the zoos. + * + * 18) Close the file. + * + * 19) Delete the file. * * Return: void * @@ -4821,9 +4830,56 @@ cache_image_smoke_check_5(void) } /* end while */ cp += 5; + /* 10) Open the file read only. + * + * Verify that the file contains a metadata cache image + * superblock extension message. + */ + if(pass) { + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ 0, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Validate all the zoos. */ + i = min_group; + while(pass && i <= max_group) { + sprintf(process_group_name, "/process_%d", i); + validate_zoo(file_id, process_group_name, i++); + } - - /* 10) Open the file. +#if H5C_COLLECT_CACHE_STATS + if( pass) { + if(cache_ptr->images_loaded == 0) { + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 12) Close the file. */ + if(pass) { + if(H5Fclose(file_id) < 0) { + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + /* 13) Open the file R/W. * * Verify that the file contains a metadata cache image * superblock extension message. @@ -4847,7 +4903,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Validate all the zoos. */ + /* 14) Validate all the zoos. */ i = min_group; while ( ( pass ) && ( i <= max_group ) ) { @@ -4871,7 +4927,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ + /* 15) Close the file. */ if ( pass ) { @@ -4883,7 +4939,7 @@ cache_image_smoke_check_5(void) } - /* 13) Open the file. + /* 16) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. @@ -4907,7 +4963,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Validate all the zoos. + /* 17) Validate all the zoos. * * Verify that the metadata cache image superblock * extension message has been deleted. @@ -4935,7 +4991,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Close the file. */ + /* 18) Close the file. */ if ( pass ) { @@ -4950,7 +5006,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 16) Delete the file */ + /* 19) Delete the file */ if ( pass ) { @@ -6444,6 +6500,576 @@ cache_image_api_error_check_3(void) /*------------------------------------------------------------------------- + * Function: cache_image_api_error_check_4() + * + * Purpose: This test is one of a sequence of tests intended + * to verify correct management of API errors. + * + * The object of this test is to verify that a request for + * a cache image when a version 2 superblock is not available/ + * not requested is handled correctly. + * (the cache image request should be ignored silently). + * + * The test is set up as follows: + * + * 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + * + * 2) Create a HDF5 file using the above FAPL. + * + * 3) Create some datasets in the file. + * + * 4) Close the file. + * + * 5) Open the file read only. Verify that the file doesn't + * contain a cache image. + * + * 6) Verify that the datasets exist and contain the + * expected data + * + * Verify that the cache image was not loaded. + * + * 7) Close the file. + * + * 8) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 9) Close the file. + * + * 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + * + * 12) Create several more data sets. + * + * 13) Close the file. + * + * 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + * + * 15) Verify the data sets exist and contain the expected + * data. + * + * Verify that a cache image was not loaded. + * + * 16) Close the file. + * + * 17) Delete the file. + * + * Return: void + * + * Programmer: John Mainzer + * 9/25/15 + * + *------------------------------------------------------------------------- + */ + +static unsigned +cache_image_api_error_check_4(void) +{ + const char * fcn_name = "cache_image_api_error_check_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t fapl_id = -1; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + int cp = 0; + H5AC_cache_image_config_t cache_image_config; + + TESTING("metadata cache image api error check 4"); + + pass = TRUE; + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + */ + if ( pass ) { + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + + if ( fapl_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + /* set cache image config fields to taste */ + cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; + cache_image_config.generate_image = TRUE; + cache_image_config.save_resize_status = FALSE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + + if ( H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_mdc_image_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Create a HDF5 file using the above FAPL. */ + + if ( pass ) { + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fcreate() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 3) Create some datasets in the file. */ + + if ( pass ) { + + create_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + HDassert(cache_ptr); + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 4) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 5) Open the file read only. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 6) Verify that the datasets exist and contain the + * expected data + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 7) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 8) Open the file R/W using the FAPL defined in 1) above. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 9) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + + /* 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 12) Create several more data sets. */ + + if ( pass ) { + + create_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 13) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 15) Verify the data sets exist and contain the expected data. + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 10); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 16) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 17) Delete the file */ + + if ( pass ) { + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "HDremove() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* tidy up */ + if ( fapl_id != -1 ) + H5Pclose(fapl_id); + + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + FUNC, failure_mssg); + + return !pass; + +} /* cache_image_api_error_check_4() */ +/*------------------------------------------------------------------------- * Function: main * * Purpose: Run tests on the cache code contained in H5C.c @@ -6489,6 +7115,7 @@ main(void) nerrs += cache_image_api_error_check_1(); nerrs += cache_image_api_error_check_2(); nerrs += cache_image_api_error_check_3(); + nerrs += cache_image_api_error_check_4(); return(nerrs > 0); -- cgit v0.12 From 4fad103187db9095afc8eab90b5f5544feb1d19b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Mar 2017 08:21:28 -0700 Subject: Bring changes to I/O parameters from page_buffering branch. --- src/H5F.c | 24 ++++++----- src/H5FD.c | 42 ++++++++++++++----- src/H5FDint.c | 59 ++++++++++++++++---------- src/H5FDprivate.h | 32 +++++++------- src/H5Faccum.c | 88 +++++++++++++++++++++++++------------- src/H5Fint.c | 123 +++++++++++++++++++++++++++++------------------------- src/H5Fio.c | 64 ++++++++++++++-------------- src/H5Fmount.c | 10 ++--- src/H5Fpkg.h | 22 +++++----- src/H5Fprivate.h | 12 +++++- src/H5Fsuper.c | 51 ++++++++++++---------- src/H5MF.c | 16 +++++-- src/H5Z.c | 2 +- test/accum.c | 59 +++++++++++++------------- 14 files changed, 355 insertions(+), 249 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index 5fd3a7d..431b56f 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -406,7 +406,7 @@ H5Fis_hdf5(const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") /* call the private is_HDF5 function */ - if((ret_value = H5F_is_hdf5(name, H5AC_ind_read_dxpl_id)) < 0) + if((ret_value = H5F__is_hdf5(name, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable open file") done: @@ -535,7 +535,7 @@ done: * Modifications: * Robb Matzke, 1997-07-18 * File struct creation and destruction is through H5F_new() and - * H5F_dest(). Reading the root symbol table entry is done with + * H5F__dest(). Reading the root symbol table entry is done with * H5G_decode(). * * Robb Matzke, 1997-09-23 @@ -713,12 +713,12 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) /* Flush other files, depending on scope */ if(H5F_SCOPE_GLOBAL == scope) { /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f, H5AC_ind_read_dxpl_id) < 0) + if(H5F_flush_mounts(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") } /* end if */ else { /* Call the flush routine, for this file */ - if(H5F_flush(f, H5AC_ind_read_dxpl_id, FALSE) < 0) + if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") } /* end else */ } /* end if */ @@ -773,7 +773,7 @@ H5Fclose(hid_t file_id) if((nref = H5I_get_ref(file_id, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") if(nref == 1) - if(H5F_flush(f, H5AC_ind_read_dxpl_id, FALSE) < 0) + if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ @@ -838,7 +838,7 @@ H5Freopen(hid_t file_id) done: if(ret_value < 0 && new_file) - if(H5F_dest(new_file, H5AC_ind_read_dxpl_id, FALSE) < 0) + if(H5F__dest(new_file, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") FUNC_LEAVE_API(ret_value) @@ -1042,7 +1042,7 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* call private get_file_image function */ - if((ret_value = H5F_get_file_image(file, buf_ptr, buf_len, H5AC_ind_read_dxpl_id)) < 0) + if((ret_value = H5F_get_file_image(file, buf_ptr, buf_len, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file image") done: @@ -1619,7 +1619,7 @@ H5Fstart_swmr_write(hid_t file_id) H5G_name_t *obj_paths=NULL; /* Group hierarchy path */ size_t u; /* Local index variable */ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1650,7 +1650,7 @@ H5Fstart_swmr_write(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and MDC cache image") /* Flush data buffers */ - if(H5F_flush(file, H5AC_ind_read_dxpl_id, FALSE) < 0) + if(H5F__flush(file, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Get the # of opened named datatypes and attributes */ @@ -1704,7 +1704,9 @@ H5Fstart_swmr_write(hid_t file_id) /* Set up I/O info for operation */ fio_info.f = file; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Flush and reset the accumulator */ @@ -1923,7 +1925,7 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) latest_flags = H5F_USE_LATEST_FLAGS(f, H5F_LATEST_ALL_FLAGS); if(latest_format != (H5F_LATEST_ALL_FLAGS == latest_flags)) { /* Call the flush routine, for this file */ - if(H5F_flush(f, H5AC_ind_read_dxpl_id, FALSE) < 0) + if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Toggle the 'latest format' flag */ diff --git a/src/H5FD.c b/src/H5FD.c index 660f496..db8c09c 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -1530,7 +1530,7 @@ herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - H5P_genplist_t *dxpl; /* DXPL object */ + H5FD_io_info_t fdio_info; /* File driver I/O object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1549,13 +1549,24 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer") - /* Get the DXPL plist object for DXPL ID */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Set up the file driver I/O info object */ + fdio_info.file = file; + if(H5FD_MEM_DRAW == type) { + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end if */ + else { + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end else */ /* Do the real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_read(file, dxpl, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_read(&fdio_info, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: @@ -1584,7 +1595,7 @@ herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5P_genplist_t *dxpl; /* DXPL object */ + H5FD_io_info_t fdio_info; /* File driver I/O object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1602,13 +1613,24 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer") - /* Get the DXPL plist object for DXPL ID */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Set up the file driver I/O info object */ + fdio_info.file = file; + if(H5FD_MEM_DRAW == type) { + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end if */ + else { + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end else */ /* The real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_write(file, dxpl, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_write(&fdio_info, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: diff --git a/src/H5FDint.c b/src/H5FDint.c index 744c3d1..0809ac8 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -93,12 +93,9 @@ *------------------------------------------------------------------------- */ herr_t -H5FD_locate_signature(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, haddr_t *sig_addr) +H5FD_locate_signature(H5FD_io_info_t *fdio_info, haddr_t *sig_addr) { + H5FD_t *file; haddr_t addr, eoa, eof; uint8_t buf[H5F_SIGNATURE_LEN]; unsigned n, maxpow; @@ -106,6 +103,10 @@ H5P_genplist_t *dxpl, haddr_t *sig_addr) FUNC_ENTER_NOAPI_NOINIT + HDassert(fdio_info); + file = fdio_info->file; + HDassert(file); + /* Find the least N such that 2^N is larger than the file size */ eof = H5FD_get_eof(file, H5FD_MEM_SUPER); eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); @@ -124,7 +125,7 @@ H5P_genplist_t *dxpl, haddr_t *sig_addr) addr = (8 == n) ? 0 : (haddr_t)1 << n; if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") - if(H5FD_read(file, dxpl, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) + if(H5FD_read(fdio_info, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) break; @@ -162,29 +163,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_read(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, +H5FD_read(H5FD_io_info_t *fdio_info, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) { + H5FD_t *file; + H5P_genplist_t *io_dxpl; haddr_t eoa = HADDR_UNDEF; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + HDassert(fdio_info); + file = fdio_info->file; HDassert(file && file->cls); - HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(fdio_info->meta_dxpl), H5P_CLS_DATASET_XFER_g)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(fdio_info->raw_dxpl), H5P_CLS_DATASET_XFER_g)); HDassert(buf); + /* Set up proper DXPL for I/O */ + if(H5FD_MEM_DRAW == type) + io_dxpl = fdio_info->raw_dxpl; + else + io_dxpl = fdio_info->meta_dxpl; + /* Sanity check the dxpl type against the mem type */ #ifdef H5_DEBUG_BUILD { H5FD_dxpl_type_t dxpl_type; /* Property indicating the type of the internal dxpl */ /* get the dxpl type */ - if(H5P_get(dxpl, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0) + if(H5P_get(io_dxpl, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't retrieve dxpl type") /* we shouldn't be here if the dxpl is labeled with NO I/O */ @@ -219,7 +227,7 @@ H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)(addr + file->base_addr), (unsigned long long)size, (unsigned long long)eoa) /* Dispatch to driver */ - if((file->cls->read)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0) + if((file->cls->read)(file, type, H5P_PLIST_ID(io_dxpl), addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") done: @@ -241,29 +249,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_write(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, +H5FD_write(const H5FD_io_info_t *fdio_info, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { + H5FD_t *file; + H5P_genplist_t *io_dxpl; haddr_t eoa = HADDR_UNDEF; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + HDassert(fdio_info); + file = fdio_info->file; HDassert(file && file->cls); - HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(fdio_info->meta_dxpl), H5P_CLS_DATASET_XFER_g)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(fdio_info->raw_dxpl), H5P_CLS_DATASET_XFER_g)); HDassert(buf); + /* Set up proper DXPL for I/O */ + if(H5FD_MEM_DRAW == type) + io_dxpl = fdio_info->raw_dxpl; + else + io_dxpl = fdio_info->meta_dxpl; + /* Sanity check the dxpl type against the mem type */ #ifdef H5_DEBUG_BUILD { H5FD_dxpl_type_t dxpl_type; /* Property indicating the type of the internal dxpl */ /* get the dxpl type */ - if(H5P_get(dxpl, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0) + if(H5P_get(io_dxpl, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't retrieve dxpl type") /* we shouldn't be here if the dxpl is labeled with NO I/O */ @@ -291,7 +306,7 @@ H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, (unsigned long long)(addr+ file->base_addr), (unsigned long long)size, (unsigned long long)eoa) /* Dispatch to driver */ - if((file->cls->write)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0) + if((file->cls->write)(file, type, H5P_PLIST_ID(io_dxpl), addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") done: diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 45f0187..0e2928d 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -115,6 +115,19 @@ typedef enum { #define H5FD_DXPL_TYPE_NAME "H5P_dxpl_type" #endif /* H5_DEBUG_BUILD */ +/* I/O Info for an operation */ +typedef struct H5FD_io_info_t { + H5FD_t *file; /* File driver object */ +#ifndef H5_DEBUG_BUILD + const +#endif /* H5_DEBUG_BUILD */ + H5P_genplist_t *meta_dxpl; /* Metadata DXPL object */ +#ifndef H5_DEBUG_BUILD + const +#endif /* H5_DEBUG_BUILD */ + H5P_genplist_t *raw_dxpl; /* Raw data DXPL object */ +} H5FD_io_info_t; + /*****************************/ /* Library Private Variables */ @@ -126,15 +139,10 @@ typedef enum { /******************************/ /* Forward declarations for prototype arguments */ -struct H5P_genplist_t; struct H5F_t; H5_DLL int H5FD_term_interface(void); -H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, haddr_t *sig_addr); +H5_DLL herr_t H5FD_locate_signature(H5FD_io_info_t *fdio_info, haddr_t *sig_addr); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); @@ -159,17 +167,9 @@ H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file); H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags); H5_DLL herr_t H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags); H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map); -H5_DLL herr_t H5FD_read(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, H5FD_mem_t type, +H5_DLL herr_t H5FD_read(H5FD_io_info_t *fdio_info, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5FD_write(H5FD_t *file, -#ifndef H5_DEBUG_BUILD -const -#endif /* H5_DEBUG_BUILD */ -H5P_genplist_t *dxpl, H5FD_mem_t type, +H5_DLL herr_t H5FD_write(const H5FD_io_info_t *fdio_info, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 48f9bdd..7f3bb39 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -112,18 +112,25 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); *------------------------------------------------------------------------- */ herr_t -H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr, +H5F__accum_read(const H5F_io_info2_t *fio_info, H5FD_mem_t map_type, haddr_t addr, size_t size, void *buf/*out*/) { + H5FD_io_info_t fdio_info; /* File driver I/O info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(fio_info); HDassert(fio_info->f); - HDassert(fio_info->dxpl); + HDassert(fio_info->meta_dxpl); + HDassert(fio_info->raw_dxpl); HDassert(buf); + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + /* Check if this information is in the metadata accumulator */ if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ @@ -178,7 +185,7 @@ H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr accum->dirty_off += amount_before; /* Dispatch to driver */ - if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, amount_before, accum->buf) < 0) + if(H5FD_read(&fdio_info, map_type, addr, amount_before, accum->buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ else @@ -192,7 +199,7 @@ H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)), hsize_t); /* Dispatch to driver */ - if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, (accum->loc + accum->size), amount_after, (accum->buf + accum->size + amount_before)) < 0) + if(H5FD_read(&fdio_info, map_type, (accum->loc + accum->size), amount_after, (accum->buf + accum->size + amount_before)) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ @@ -206,13 +213,13 @@ H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr /* Current read doesn't overlap with metadata accumulator, read it from file */ else { /* Dispatch to driver */ - if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) + if(H5FD_read(&fdio_info, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ } /* end if */ else { /* Read the data */ - if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) + if(H5FD_read(&fdio_info, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") /* Check for overlap w/dirty accumulator */ @@ -255,7 +262,7 @@ H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr } /* end if */ else { /* Read the data */ - if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) + if(H5FD_read(&fdio_info, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ @@ -278,7 +285,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__accum_adjust(H5F_meta_accum_t *accum, const H5F_io_info_t *fio_info, +H5F__accum_adjust(H5F_meta_accum_t *accum, const H5FD_io_info_t *fdio_info, H5F_accum_adjust_t adjust, size_t size) { herr_t ret_value = SUCCEED; /* Return value */ @@ -286,7 +293,7 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, const H5F_io_info_t *fio_info, FUNC_ENTER_STATIC HDassert(accum); - HDassert(fio_info); + HDassert(fdio_info); HDassert(H5F_ACCUM_APPEND == adjust || H5F_ACCUM_PREPEND == adjust); HDassert(size > 0); HDassert(size <= H5F_ACCUM_MAX_SIZE); @@ -344,7 +351,7 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, const H5F_io_info_t *fio_info, /* Check if the dirty region overlaps the region to eliminate from the accumulator */ if((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if(H5FD_write(fdio_info, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -355,7 +362,7 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, const H5F_io_info_t *fio_info, /* Check if the dirty region overlaps the region to eliminate from the accumulator */ if(shrink_size > accum->dirty_off) { /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if(H5FD_write(fdio_info, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -417,9 +424,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t addr, +H5F__accum_write(const H5F_io_info2_t *fio_info, H5FD_mem_t map_type, haddr_t addr, size_t size, const void *buf) { + H5FD_io_info_t fdio_info; /* File driver I/O info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -427,9 +435,15 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add HDassert(fio_info); HDassert(fio_info->f); HDassert(H5F_INTENT(fio_info->f) & H5F_ACC_RDWR); - HDassert(fio_info->dxpl); + HDassert(fio_info->meta_dxpl); + HDassert(fio_info->raw_dxpl); HDassert(buf); + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + /* Check for accumulating metadata */ if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ @@ -446,7 +460,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add /* Check if the new metadata adjoins the beginning of the current accumulator */ if((addr + size) == accum->loc) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_PREPEND, size) < 0) + if(H5F__accum_adjust(accum, &fdio_info, H5F_ACCUM_PREPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Move the existing metadata to the proper location */ @@ -471,7 +485,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add /* Check if the new metadata adjoins the end of the current accumulator */ else if(addr == (accum->loc + accum->size)) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_APPEND, size) < 0) + if(H5F__accum_adjust(accum, &fdio_info, H5F_ACCUM_APPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Copy the new metadata to the end */ @@ -531,7 +545,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add H5_CHECKED_ASSIGN(add_size, size_t, (accum->loc - addr), hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_PREPEND, add_size) < 0) + if(H5F__accum_adjust(accum, &fdio_info, H5F_ACCUM_PREPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Calculate the proper offset of the existing metadata */ @@ -571,7 +585,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add H5_CHECKED_ASSIGN(add_size, size_t, (addr + size) - (accum->loc + accum->size), hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_APPEND, add_size) < 0) + if(H5F__accum_adjust(accum, &fdio_info, H5F_ACCUM_APPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Compute offset of dirty region (after adjusting accumulator) */ @@ -637,7 +651,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add else { /* Write out the existing metadata accumulator, with dispatch to driver */ if(accum->dirty) { - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if(H5FD_write(&fdio_info, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -733,7 +747,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Write the data */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) + if(H5FD_write(&fdio_info, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Check for overlap w/accumulator */ @@ -818,7 +832,7 @@ H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t map_type, haddr_t add } /* end if */ else { /* Write the data */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) + if(H5FD_write(&fdio_info, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end else */ @@ -842,10 +856,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, +H5F__accum_free(const H5F_io_info2_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, hsize_t size) { H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -853,11 +868,17 @@ H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, h /* check arguments */ HDassert(fio_info); HDassert(fio_info->f); - HDassert(fio_info->dxpl); + HDassert(fio_info->meta_dxpl); + HDassert(fio_info->raw_dxpl); /* Set up alias for file's metadata accumulator info */ accum = &fio_info->f->shared->accum; + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + /* Adjust the metadata accumulator to remove the freed block, if it overlaps */ if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && H5F_addr_overlap(addr, size, accum->loc, accum->size)) { @@ -930,7 +951,7 @@ H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, h /* Check if block to free is entirely before dirty region */ if(H5F_addr_le(tail_addr, dirty_start)) { /* Write out the entire dirty region of the accumulator */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if(H5FD_write(&fdio_info, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Block to free overlaps with some/all of dirty region */ @@ -945,7 +966,7 @@ H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, h HDassert(write_size > 0); /* Write out the unfreed dirty region of the accumulator */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if(H5FD_write(&fdio_info, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ @@ -965,7 +986,7 @@ H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t H5_ATTR_UNUSED type, h HDassert(write_size > 0); /* Write out the unfreed end of the dirty region of the accumulator */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if(H5FD_write(&fdio_info, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ @@ -1006,7 +1027,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_flush(const H5F_io_info_t *fio_info) +H5F__accum_flush(const H5F_io_info2_t *fio_info) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1014,12 +1035,20 @@ H5F__accum_flush(const H5F_io_info_t *fio_info) HDassert(fio_info); HDassert(fio_info->f); - HDassert(fio_info->dxpl); + HDassert(fio_info->meta_dxpl); + HDassert(fio_info->raw_dxpl); /* Check if we need to flush out the metadata accumulator */ if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && fio_info->f->shared->accum.dirty) { + H5FD_io_info_t fdio_info; /* File driver I/O info */ + + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + /* Flush the metadata contents */ - if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, fio_info->f->shared->accum.loc + fio_info->f->shared->accum.dirty_off, fio_info->f->shared->accum.dirty_len, fio_info->f->shared->accum.buf + fio_info->f->shared->accum.dirty_off) < 0) + if(H5FD_write(&fdio_info, H5FD_MEM_DEFAULT, fio_info->f->shared->accum.loc + fio_info->f->shared->accum.dirty_off, fio_info->f->shared->accum.dirty_len, fio_info->f->shared->accum.buf + fio_info->f->shared->accum.dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset the dirty flag */ @@ -1045,7 +1074,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_reset(const H5F_io_info_t *fio_info, hbool_t flush) +H5F__accum_reset(const H5F_io_info2_t *fio_info, hbool_t flush) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1053,7 +1082,6 @@ H5F__accum_reset(const H5F_io_info_t *fio_info, hbool_t flush) HDassert(fio_info); HDassert(fio_info->f); - HDassert(fio_info->dxpl); /* Flush any dirty data in accumulator, if requested */ if(flush) diff --git a/src/H5Fint.c b/src/H5Fint.c index 4e308a5..3c98c8f 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -76,8 +76,8 @@ typedef struct H5F_olist_t { static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ -static herr_t H5F__flush_phase1(H5F_t *f, hid_t dxpl_id); -static herr_t H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing); +static herr_t H5F__flush_phase1(H5F_t *f, hid_t meta_dxpl_id); +static herr_t H5F__flush_phase2(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing); /*********************/ @@ -495,7 +495,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_is_hdf5 + * Function: H5F__is_hdf5 * * Purpose: Check the file signature to detect an HDF5 file. * @@ -509,17 +509,14 @@ done: * * Programmer: Unknown * - * Modifications: - * Robb Matzke, 1999-08-02 - * Rewritten to use the virtual file layer. *------------------------------------------------------------------------- */ htri_t -H5F_is_hdf5(const char *name, hid_t dxpl_id) +H5F__is_hdf5(const char *name, hid_t meta_dxpl_id, hid_t raw_dxpl_id) { H5FD_t *file = NULL; /* Low-level file struct */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ haddr_t sig_addr; /* Addess of hdf5 file signature */ - H5P_genplist_t *xfer_plist= NULL; /* Dataset transfer property list object */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -528,12 +525,15 @@ H5F_is_hdf5(const char *name, hid_t dxpl_id) if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") - /* Get the property list object */ - if(NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + /* Set up the file driver info */ + fdio_info.file = file; + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(meta_dxpl_id))) + HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(raw_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* The file is an hdf5 file if the hdf5 file signature can be found */ - if(H5FD_locate_signature(file, xfer_plist, &sig_addr) < 0) + if(H5FD_locate_signature(&fdio_info, &sig_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") ret_value = (HADDR_UNDEF != sig_addr); @@ -544,7 +544,7 @@ done: HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_is_hdf5() */ +} /* end H5F__is_hdf5() */ /*------------------------------------------------------------------------- @@ -796,7 +796,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_dest + * Function: H5F__dest * * Purpose: Destroys a file structure. This function flushes the cache * but doesn't do any other cleanup other than freeing memory @@ -812,11 +812,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) +H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -824,14 +824,14 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) if(1 == f->shared->nrefs) { int actype; /* metadata cache type (enum value) */ - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ /* Flush at this point since the file will be closed (phase 1). * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. */ if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase1(f, dxpl_id) < 0) + if(H5F__flush_phase1(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)") @@ -839,7 +839,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) * This allows the cache to set up for creating a metadata cache * image if this has been requested. */ - if(H5AC_prep_for_file_close(f, dxpl_id) < 0) + if(H5AC_prep_for_file_close(f, meta_dxpl_id) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "metadata cache prep for close failed") @@ -848,7 +848,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) * the caller requested a flush. */ if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase2(f, dxpl_id, TRUE) < 0) + if(H5F__flush_phase2(f, meta_dxpl_id, raw_dxpl_id, TRUE) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)") @@ -895,7 +895,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) * -- JRM */ if(H5F_ACC_RDWR & H5F_INTENT(f)) { - if(H5MF_close(f, dxpl_id) < 0) + if(H5MF_close(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info") @@ -913,7 +913,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f, dxpl_id) < 0) + if(H5F_eoa_dirty(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") @@ -924,12 +924,12 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) * At most, this should change the superblock or the * superblock extension messages. */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) + if(H5MF_free_aggrs(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, dxpl_id, TRUE) < 0) + if(H5FD_truncate(f->shared->lf, meta_dxpl_id, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") @@ -968,7 +968,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Shutdown the metadata cache */ - if(H5AC_dest(f, dxpl_id)) + if(H5AC_dest(f, meta_dxpl_id)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") @@ -990,7 +990,9 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) /* Set up I/O info for operation */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(meta_dxpl_id))) + HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Destroy other components of the file */ @@ -1130,7 +1132,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) */ H5F_t * H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t dxpl_id) + hid_t meta_dxpl_id) { H5F_t *file = NULL; /*the success return value */ H5F_file_t *shared = NULL; /*shared part of `file' */ @@ -1139,6 +1141,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_class_t *drvr; /*file driver class info */ H5P_genplist_t *a_plist; /*file access property list */ H5F_close_degree_t fc_degree; /*file close degree */ + hid_t raw_dxpl_id = H5AC_rawdata_dxpl_id; /* Raw data dxpl used by library */ hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ hbool_t clear = FALSE; /*clear the status_flags */ hbool_t evict_on_close; /* evict on close value from plist */ @@ -1301,23 +1304,23 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, /* Initialize information about the superblock and allocate space for it */ /* (Writes superblock extension messages, if there are any) */ - if(H5F__super_init(file, dxpl_id) < 0) + if(H5F__super_init(file, meta_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") /* Create and open the root group */ /* (This must be after the space for the superblock is allocated in * the file, since the superblock must be at offset 0) */ - if(H5G_mkroot(file, dxpl_id, TRUE) < 0) + if(H5G_mkroot(file, meta_dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") } /* end if */ else if (1 == shared->nrefs) { /* Read the superblock if it hasn't been read before. */ - if(H5F__super_read(file, dxpl_id, TRUE) < 0) + if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Open the root group */ - if(H5G_mkroot(file, dxpl_id, FALSE) < 0) + if(H5G_mkroot(file, meta_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ @@ -1391,7 +1394,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, /* Flush the superblock */ if(H5F_super_dirty(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, NULL, "unable to mark superblock as dirty") - if(H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG, H5AC_ind_read_dxpl_id) < 0) + if(H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG, meta_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock") /* Remove the file lock for SWMR_WRITE */ @@ -1423,7 +1426,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, done: if((NULL == ret_value) && file) - if(H5F_dest(file, dxpl_id, FALSE) < 0) + if(H5F__dest(file, meta_dxpl_id, raw_dxpl_id, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ @@ -1443,7 +1446,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__flush_phase1(H5F_t *f, hid_t dxpl_id) +H5F__flush_phase1(H5F_t *f, hid_t meta_dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1453,7 +1456,7 @@ H5F__flush_phase1(H5F_t *f, hid_t dxpl_id) HDassert(f); /* Flush any cached dataset storage raw data */ - if(H5D_flush(f, dxpl_id) < 0) + if(H5D_flush(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") @@ -1463,7 +1466,7 @@ H5F__flush_phase1(H5F_t *f, hid_t dxpl_id) /* (needs to happen before cache flush, with superblock write, since the * 'eoa' value is written in superblock -QAK) */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) + if(H5MF_free_aggrs(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") @@ -1485,9 +1488,9 @@ H5F__flush_phase1(H5F_t *f, hid_t dxpl_id) *------------------------------------------------------------------------- */ static herr_t -H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing) +H5F__flush_phase2(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1496,23 +1499,26 @@ H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing) HDassert(f); /* Flush the entire metadata cache */ - if(H5AC_flush(f, dxpl_id) < 0) + if(H5AC_flush(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, dxpl_id, closing) < 0) + if(H5FD_truncate(f->shared->lf, meta_dxpl_id, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") /* Flush the entire metadata cache again since the EOA could have changed in the truncate call. */ - if(H5AC_flush(f, dxpl_id) < 0) + if(H5AC_flush(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") /* Set up I/O info for operation */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(meta_dxpl_id))) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(raw_dxpl_id))) /* Push error, but keep going*/ HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") @@ -1522,7 +1528,7 @@ H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing) HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") /* Flush file buffers to disk. */ - if(H5FD_flush(f->shared->lf, dxpl_id, closing) < 0) + if(H5FD_flush(f->shared->lf, meta_dxpl_id, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "low level flush failed") @@ -1531,7 +1537,7 @@ H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing) /*------------------------------------------------------------------------- - * Function: H5F_flush + * Function: H5F__flush * * Purpose: Flushes cached data. * @@ -1544,28 +1550,27 @@ H5F__flush_phase2(H5F_t *f, hid_t dxpl_id, hbool_t closing) *------------------------------------------------------------------------- */ herr_t -H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing) +H5F__flush(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity check arguments */ HDassert(f); /* First phase of flushing data */ - if(H5F__flush_phase1(f, dxpl_id) < 0) + if(H5F__flush_phase1(f, meta_dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") /* Second phase of flushing data */ - if(H5F__flush_phase2(f, dxpl_id, closing) < 0) + if(H5F__flush_phase2(f, meta_dxpl_id, raw_dxpl_id, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_flush() */ +} /* end H5F__flush() */ /*------------------------------------------------------------------------- @@ -1790,7 +1795,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) if(H5F_efc_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't attempt to close EFC") - /* Delay flush until the shared file struct is closed, in H5F_dest. If the + /* Delay flush until the shared file struct is closed, in H5F__dest. If the * application called H5Fclose, it would have been flushed in that function * (unless it will have been flushed in H5F_dest anyways). */ @@ -1799,7 +1804,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * shared H5F_file_t struct. If the reference count for the H5F_file_t * struct reaches zero then destroy it also. */ - if(H5F_dest(f, H5AC_ind_read_dxpl_id, TRUE) < 0) + if(H5F__dest(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") /* Since we closed the file, this should be set to TRUE */ @@ -2357,7 +2362,8 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) *------------------------------------------------------------------------- */ ssize_t -H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t dxpl_id) +H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t meta_dxpl_id, + hid_t raw_dxpl_id) { H5FD_t *fd_ptr; /* file driver */ haddr_t eoa; /* End of file address */ @@ -2424,10 +2430,10 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t dxpl_id) /* test to see if a buffer was provided -- if not, we are done */ if(buf_ptr != NULL) { + H5FD_io_info_t fdio_info; /* File driver I/O info */ size_t space_needed; /* size of file image */ hsize_t tmp; size_t tmp_size; - H5P_genplist_t *xfer_plist= NULL; /* Dataset transfer property list object */ /* Check for buffer too small */ if((haddr_t)buf_len < eoa) @@ -2435,13 +2441,16 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t dxpl_id) space_needed = (size_t)eoa; - /* Get the property list object */ - if(NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") + /* Set up file driver I/O info object */ + fdio_info.file = fd_ptr; + if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(meta_dxpl_id))) + HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list object") + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(raw_dxpl_id))) + HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list object") /* read in the file image */ /* (Note compensation for base address addition in internal routine) */ - if(H5FD_read(fd_ptr, xfer_plist, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) + if(H5FD_read(&fdio_info, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed") /* Offset to "status_flags" in the superblock */ diff --git a/src/H5Fio.c b/src/H5Fio.c index afe1278..d40483f 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -96,15 +96,11 @@ herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ H5FD_mem_t map_type; /* Mapped memory type */ - hid_t my_dxpl_id = dxpl_id; /* transfer property to use for I/O */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) -#ifdef QAK -HDfprintf(stderr, "%s: read from addr = %a, size = %Zu\n", FUNC, addr, size); -#endif /* QAK */ HDassert(f); HDassert(f->shared); @@ -118,16 +114,20 @@ HDfprintf(stderr, "%s: read from addr = %a, size = %Zu\n", FUNC, addr, size); /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; -#ifdef H5_DEBUG_BUILD - /* GHEAP type is treated as RAW, so update the dxpl type property too */ - if(H5FD_MEM_GHEAP == type) - my_dxpl_id = H5AC_rawdata_dxpl_id; -#endif /* H5_DEBUG_BUILD */ - - /* Set up I/O info for operation */ + /* Set up the I/O info object */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(my_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(H5FD_MEM_DRAW == type) { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end if */ + else { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end else */ /* Pass through metadata accumulator layer */ if(H5F__accum_read(&fio_info, map_type, addr, size, buf) < 0) @@ -157,15 +157,11 @@ herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ H5FD_mem_t map_type; /* Mapped memory type */ - hid_t my_dxpl_id = dxpl_id; /* transfer property to use for I/O */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) -#ifdef QAK -HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size); -#endif /* QAK */ HDassert(f); HDassert(f->shared); @@ -180,16 +176,20 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size); /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; -#ifdef H5_DEBUG_BUILD - /* GHEAP type is treated as RAW, so update the dxpl type property too */ - if(H5FD_MEM_GHEAP == type) - my_dxpl_id = H5AC_rawdata_dxpl_id; -#endif /* H5_DEBUG_BUILD */ - - /* Set up I/O info for operation */ + /* Set up the I/O info object */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(my_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(H5FD_MEM_DRAW == type) { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end if */ + else { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end else */ /* Pass through metadata accumulator layer */ if(H5F__accum_write(&fio_info, map_type, addr, size, buf) < 0) @@ -216,7 +216,7 @@ done: herr_t H5F_flush_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -227,10 +227,10 @@ H5F_flush_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id) /* Set up I/O info for operation */ fio_info.f = f; - - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - /* Flush and reset the accumulator */ if(H5F__accum_reset(&fio_info, TRUE) < 0) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e3d4952..859b9d6 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -614,7 +614,7 @@ H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) *------------------------------------------------------------------------- */ static herr_t -H5F_flush_mounts_recurse(H5F_t *f, hid_t dxpl_id) +H5F_flush_mounts_recurse(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id) { unsigned nerrors = 0; /* Errors from recursive flushes */ unsigned u; /* Index variable */ @@ -627,11 +627,11 @@ H5F_flush_mounts_recurse(H5F_t *f, hid_t dxpl_id) /* Flush all child files, not stopping for errors */ for(u = 0; u < f->shared->mtab.nmounts; u++) - if(H5F_flush_mounts_recurse(f->shared->mtab.child[u].file, dxpl_id) < 0) + if(H5F_flush_mounts_recurse(f->shared->mtab.child[u].file, meta_dxpl_id, raw_dxpl_id) < 0) nerrors++; /* Call the "real" flush routine, for this file */ - if(H5F_flush(f, dxpl_id, FALSE) < 0) + if(H5F__flush(f, meta_dxpl_id, raw_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Check flush errors for children - errors are already on the stack */ @@ -656,7 +656,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_flush_mounts(H5F_t *f, hid_t dxpl_id) +H5F_flush_mounts(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ @@ -670,7 +670,7 @@ H5F_flush_mounts(H5F_t *f, hid_t dxpl_id) f = f->parent; /* Flush the mounted file hierarchy */ - if(H5F_flush_mounts_recurse(f, dxpl_id) < 0) + if(H5F_flush_mounts_recurse(f, meta_dxpl_id, raw_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 93a3978..aaa19d9 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -383,11 +383,12 @@ H5FL_EXTERN(H5F_file_t); /* General routines */ H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); -herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); -H5_DLL herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing); -H5_DLL htri_t H5F_is_hdf5(const char *name, hid_t dxpl_id); +herr_t H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush); +H5_DLL herr_t H5F__flush(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing); +H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t meta_dxpl_id, hid_t raw_dxpl_id); H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); -H5_DLL ssize_t H5F_get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len, hid_t dxpl_id); +H5_DLL ssize_t H5F_get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len, + hid_t meta_dxpl_id, hid_t raw_dxpl_id); H5_DLL herr_t H5F_close(H5F_t *f); /* File mount related routines */ @@ -397,7 +398,8 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop /* Superblock related routines */ H5_DLL herr_t H5F__super_init(H5F_t *f, hid_t dxpl_id); -H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read); +H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, + hbool_t initial_read); H5_DLL herr_t H5F__super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size); H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); @@ -410,14 +412,14 @@ H5_DLL herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id, hbool_t was_created); /* Metadata accumulator routines */ -H5_DLL herr_t H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_read(const H5F_io_info2_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_write(const H5F_io_info2_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_free(const H5F_io_info2_t *fio_info, H5FD_mem_t type, haddr_t addr, hsize_t size); -H5_DLL herr_t H5F__accum_flush(const H5F_io_info_t *fio_info); -H5_DLL herr_t H5F__accum_reset(const H5F_io_info_t *fio_info, hbool_t flush); +H5_DLL herr_t H5F__accum_flush(const H5F_io_info2_t *fio_info); +H5_DLL herr_t H5F__accum_reset(const H5F_io_info2_t *fio_info, hbool_t flush); /* Shared file list related routines */ H5_DLL herr_t H5F_sfile_add(H5F_file_t *shared); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 7d288fa..f980347 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -628,12 +628,20 @@ typedef struct H5F_object_flush_t { void *udata; /* User data */ } H5F_object_flush_t; -/* I/O Info for an operation */ +/* I/O Info for an operation (old) */ typedef struct H5F_io_info_t { const H5F_t *f; /* File object */ const struct H5P_genplist_t *dxpl; /* DXPL object */ } H5F_io_info_t; +/* I/O Info for an operation */ +/* (Migrate toward this one, so that both raw data & metadata DXPLs are available) */ +typedef struct H5F_io_info2_t { + const H5F_t *f; /* File object */ + const struct H5P_genplist_t *meta_dxpl; /* Metadata DXPL object */ + const struct H5P_genplist_t *raw_dxpl; /* Raw data DXPL object */ +} H5F_io_info2_t; + /* Concise info about a block of bytes in a file */ typedef struct H5F_block_t { haddr_t offset; /* Offset of the block in the file */ @@ -723,7 +731,7 @@ H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_hand H5_DLL hbool_t H5F_is_mount(const H5F_t *file); H5_DLL hbool_t H5F_has_mount(const H5F_t *file); H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); -H5_DLL herr_t H5F_flush_mounts(H5F_t *f, hid_t dxpl_id); +H5_DLL herr_t H5F_flush_mounts(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id); /* Functions that operate on blocks of bytes wrt super block */ H5_DLL herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 3b86dae..3050a28 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -320,13 +320,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) +H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial_read) { H5P_genplist_t *dxpl = NULL; /* DXPL object */ H5AC_ring_t ring, orig_ring = H5AC_RING_INV; H5F_super_t * sblock = NULL; /* Superblock structure */ H5F_superblock_cache_ud_t udata; /* User data for cache callbacks */ H5P_genplist_t *c_plist; /* File creation property list */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ haddr_t super_addr; /* Absolute address of superblock */ haddr_t eof; /* End of file address */ @@ -334,7 +335,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL) + FUNC_ENTER_PACKAGE_TAG(meta_dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL) /* initialize the drvinfo to NULL -- we will overwrite this if there * is a driver information block @@ -342,13 +343,19 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) f->shared->drvinfo = NULL; /* Get the DXPL plist object for DXPL ID */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(meta_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if((H5P_get(dxpl, H5AC_RING_NAME, &orig_ring)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get property value"); + /* Set up file driver I/O info */ + fdio_info.file = f->shared->lf; + fdio_info.meta_dxpl = dxpl; + if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(raw_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Find the superblock */ - if(H5FD_locate_signature(f->shared->lf, dxpl, &super_addr) < 0) + if(H5FD_locate_signature(&fdio_info, &super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") if(HADDR_UNDEF == super_addr) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") @@ -396,7 +403,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set property value"); /* Look up the superblock */ - if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) + if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, meta_dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock") if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) @@ -556,7 +563,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") /* Look up the driver info block */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) + if(NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, meta_dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load driver info block") /* Loading the driver info block is enough to set up the right info */ @@ -571,7 +578,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) drvinfo_flags |= H5AC__PIN_ENTRY_FLAG; /* Release the driver info block */ - if(H5AC_unprotect(f, dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) + if(H5AC_unprotect(f, meta_dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to release driver info block") /* save a pointer to the driver information cache entry */ @@ -612,14 +619,14 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") /* Check for the extension having a 'driver info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID, dxpl_id)) < 0) + if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID, meta_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") if(status) { /* Check for ignoring the driver info for this file */ if(!udata.ignore_drvrinfo) { /* Retrieve the 'driver info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo, dxpl_id)) + if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo, meta_dxpl_id)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") /* Validate and decode driver information */ @@ -637,15 +644,15 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) } /* end if */ /* Read in the shared OH message information if there is any */ - if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0) + if(H5SM_get_info(&ext_loc, c_plist, meta_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read SOHM table information") /* Check for the extension having a 'v1 B-tree "K"' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID, dxpl_id)) < 0) + if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID, meta_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") if(status) { /* Retrieve the 'v1 B-tree "K"' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek, dxpl_id)) + if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek, meta_dxpl_id)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "v1 B-tree 'K' info message not present") /* Set non-default v1 B-tree 'K' value info from file */ @@ -661,13 +668,13 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) } /* end if */ /* Check for the extension having a 'free-space manager info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID, dxpl_id)) < 0) + if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID, meta_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") if(status) { H5O_fsinfo_t fsinfo; /* Free-space manager info message from superblock extension */ /* Retrieve the 'free-space manager info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, dxpl_id)) + if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, meta_dxpl_id)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message") /* Check for non-default info */ @@ -693,7 +700,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) } /* end if */ /* Check for the extension having a 'metadata cache image' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID, dxpl_id)) < 0) + if((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID, meta_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") if(status) { hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); @@ -712,7 +719,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) */ /* Retrieve the 'metadata cache image message' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg, dxpl_id)) + if(NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg, meta_dxpl_id)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache image message") /* Indicate to the cache that there's an image to load on first protect call */ @@ -721,7 +728,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) } /* end if */ /* Close superblock extension */ - if(H5F_super_ext_close(f, &ext_loc, dxpl_id, FALSE) < 0) + if(H5F_super_ext_close(f, &ext_loc, meta_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close file's superblock extension") } /* end if */ @@ -765,7 +772,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) HDassert(f->shared->sblock == NULL); f->shared->sblock = sblock; #endif /* JRM */ - if(H5F_super_ext_write_msg(f, dxpl_id, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) + if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ @@ -777,7 +784,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read) /* Check for eliminating the driver info block */ else if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { /* Remove the driver info message from the superblock extension */ - if(H5F_super_ext_remove_msg(f, dxpl_id, H5O_DRVINFO_ID) < 0) + if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_DRVINFO_ID) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") /* Check if the superblock extension was removed */ @@ -795,7 +802,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set property value") /* Release the superblock */ - if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) + if(sblock && H5AC_unprotect(f, meta_dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") /* If we have failed, make sure no entries are left in the @@ -808,7 +815,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") /* Evict the driver info block from the cache */ - if(H5AC_expunge_entry(f, dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_expunge_entry(f, meta_dxpl_id, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") } /* end if */ @@ -819,7 +826,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_expunge_entry(f, meta_dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ } /* end if */ diff --git a/src/H5MF.c b/src/H5MF.c index 23f128f..36b9386 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -645,7 +645,7 @@ herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ H5MF_free_section_t *node = NULL; /* Free space section pointer */ H5MF_sect_ud_t udata; /* User data for callback */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ @@ -688,8 +688,18 @@ HDfprintf(stderr, "%s: fs_type = %u\n", FUNC, (unsigned)fs_type); /* Set up I/O info for operation */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(H5FD_MEM_DRAW == alloc_type) { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end if */ + else { + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + } /* end else */ /* Check if the space to free intersects with the file's metadata accumulator */ if(H5F__accum_free(&fio_info, alloc_type, addr, size) < 0) diff --git a/src/H5Z.c b/src/H5Z.c index e7a2186..0be0bbe 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -626,7 +626,7 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_UNUS /* Call the flush routine for mounted file hierarchies. Do a global flush * if the file is opened for write */ if(H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) { - if(H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id) < 0) + if(H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") } /* end if */ diff --git a/test/accum.c b/test/accum.c index 1fcd051..d134bbc 100644 --- a/test/accum.c +++ b/test/accum.c @@ -45,18 +45,18 @@ H5F_t * f = NULL; /* Function Prototypes */ -unsigned test_write_read(const H5F_io_info_t *fio_info); -unsigned test_write_read_nonacc_front(const H5F_io_info_t *fio_info); -unsigned test_write_read_nonacc_end(const H5F_io_info_t *fio_info); -unsigned test_accum_overlap(const H5F_io_info_t *fio_info); -unsigned test_accum_overlap_clean(const H5F_io_info_t *fio_info); -unsigned test_accum_overlap_size(const H5F_io_info_t *fio_info); -unsigned test_accum_non_overlap_size(const H5F_io_info_t *fio_info); -unsigned test_accum_adjust(const H5F_io_info_t *fio_info); -unsigned test_read_after(const H5F_io_info_t *fio_info); -unsigned test_free(const H5F_io_info_t *fio_info); -unsigned test_big(const H5F_io_info_t *fio_info); -unsigned test_random_write(const H5F_io_info_t *fio_info); +unsigned test_write_read(const H5F_io_info2_t *fio_info); +unsigned test_write_read_nonacc_front(const H5F_io_info2_t *fio_info); +unsigned test_write_read_nonacc_end(const H5F_io_info2_t *fio_info); +unsigned test_accum_overlap(const H5F_io_info2_t *fio_info); +unsigned test_accum_overlap_clean(const H5F_io_info2_t *fio_info); +unsigned test_accum_overlap_size(const H5F_io_info2_t *fio_info); +unsigned test_accum_non_overlap_size(const H5F_io_info2_t *fio_info); +unsigned test_accum_adjust(const H5F_io_info2_t *fio_info); +unsigned test_read_after(const H5F_io_info2_t *fio_info); +unsigned test_free(const H5F_io_info2_t *fio_info); +unsigned test_big(const H5F_io_info2_t *fio_info); +unsigned test_random_write(const H5F_io_info2_t *fio_info); unsigned test_swmr_write_big(hbool_t newest_format); /* Helper Function Prototypes */ @@ -90,7 +90,7 @@ void accum_printf(void); int main(void) { - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ unsigned nerrors = 0; /* track errors */ hid_t fid = -1; @@ -109,7 +109,8 @@ main(void) /* Set up I/O info for operation */ fio_info.f = f; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) FAIL_STACK_ERROR + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) FAIL_STACK_ERROR + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) FAIL_STACK_ERROR /* Reset metadata accumulator for the file */ if(accum_reset(&fio_info) < 0) FAIL_STACK_ERROR @@ -166,7 +167,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read(const H5F_io_info_t *fio_info) +test_write_read(const H5F_io_info2_t *fio_info) { int i = 0; int *write_buf, *read_buf; @@ -222,7 +223,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read_nonacc_front(const H5F_io_info_t *fio_info) +test_write_read_nonacc_front(const H5F_io_info2_t *fio_info) { int i = 0; int *write_buf, *read_buf; @@ -281,7 +282,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read_nonacc_end(const H5F_io_info_t *fio_info) +test_write_read_nonacc_end(const H5F_io_info2_t *fio_info) { int i = 0; int *write_buf, *read_buf; @@ -340,7 +341,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_free(const H5F_io_info_t *fio_info) +test_free(const H5F_io_info2_t *fio_info) { int i = 0; int32_t *wbuf = NULL; @@ -527,7 +528,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap(const H5F_io_info_t *fio_info) +test_accum_overlap(const H5F_io_info2_t *fio_info) { int i = 0; int32_t *wbuf, *rbuf; @@ -699,7 +700,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap_clean(const H5F_io_info_t *fio_info) +test_accum_overlap_clean(const H5F_io_info2_t *fio_info) { int i = 0; int32_t *wbuf, *rbuf; @@ -878,7 +879,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_non_overlap_size(const H5F_io_info_t *fio_info) +test_accum_non_overlap_size(const H5F_io_info2_t *fio_info) { int i = 0; int32_t *wbuf, *rbuf; @@ -945,7 +946,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap_size(const H5F_io_info_t *fio_info) +test_accum_overlap_size(const H5F_io_info2_t *fio_info) { int i = 0; int32_t *wbuf, *rbuf; @@ -1023,7 +1024,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_adjust(const H5F_io_info_t *fio_info) +test_accum_adjust(const H5F_io_info2_t *fio_info) { int i = 0; int s = 1048576; /* size of buffer */ @@ -1279,7 +1280,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_read_after(const H5F_io_info_t *fio_info) +test_read_after(const H5F_io_info2_t *fio_info) { int i = 0; int s = 128; /* size of buffer */ @@ -1358,7 +1359,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_big(const H5F_io_info_t *fio_info) +test_big(const H5F_io_info2_t *fio_info) { uint8_t *wbuf, *wbuf2, *rbuf, *zbuf; /* Buffers for reading & writing, etc */ unsigned u; /* Local index variable */ @@ -1666,7 +1667,7 @@ error: *------------------------------------------------------------------------- */ unsigned -test_random_write(const H5F_io_info_t *fio_info) +test_random_write(const H5F_io_info2_t *fio_info) { uint8_t *wbuf, *rbuf; /* Buffers for reading & writing */ unsigned seed = 0; /* Random # seed */ @@ -1820,7 +1821,7 @@ test_swmr_write_big(hbool_t newest_format) pid_t pid; /* Process ID */ #endif /* H5_HAVE_UNISTD_H */ int status; /* Status returned from child process */ - H5F_io_info_t fio_info; /* I/O info for operation */ + H5F_io_info2_t fio_info; /* I/O info for operation */ char *new_argv[] = {NULL}; char *driver = NULL; /* VFD string (from env variable) */ @@ -1877,7 +1878,9 @@ test_swmr_write_big(hbool_t newest_format) /* Set up I/O info for operation */ fio_info.f = rf; - if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) + FAIL_STACK_ERROR + if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) FAIL_STACK_ERROR /* We'll be writing lots of garbage data, so extend the -- cgit v0.12 From a48c9c4024e7ede0021e1a9d8c1d4c197333e0d0 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Mon, 13 Mar 2017 22:53:43 -0500 Subject: Purpose: Add new C++ wrappers Description: Added wrappers for H5Iis_valid, H5Ps/get_nlinks, H5Tget_create_plist, H5Oopen, H5Oclose and H5Pset_virtual // Checks if the given ID is valid. static bool isValid(hid_t an_id); // Sets the number of soft or user-defined links that can be // traversed before a failure occurs. void setNumLinks(size_t nlinks) const; // Gets the number of soft or user-defined link traversals allowed size_t getNumLinks() const; // Returns a copy of the creation property list of a datatype. PropList getCreatePlist() const; // Opens an object within a group or a file, i.e., root group. hid_t getObjId(const char* name,...); hid_t getObjId(const H5std_string& name,...); // Closes an object opened by getObjId(). void closeObjId(hid_t obj_id) const; // Maps elements of a virtual dataset to elements of the source dataset. void setVirtual(const DataSpace& vspace, const char *src_fname,...); void setVirtual(const DataSpace& vspace, const H5std_string src_fname,...); Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5DataType.cpp | 25 ++++++++++ c++/src/H5DataType.h | 3 ++ c++/src/H5DcreatProp.cpp | 50 +++++++++++++++++++ c++/src/H5DcreatProp.h | 5 ++ c++/src/H5FaccProp.h | 6 +++ c++/src/H5Group.cpp | 50 ++++++++++++++++++- c++/src/H5Group.h | 7 +++ c++/src/H5IdComponent.cpp | 21 ++++++++ c++/src/H5IdComponent.h | 4 +- c++/src/H5LaccProp.cpp | 49 ++++++++++++++++--- c++/src/H5LaccProp.h | 7 +++ c++/test/dsets.cpp | 82 +++++++++++++++++++++++++++++++ c++/test/tlinks.cpp | 54 +++++++++++++++++++-- c++/test/tobject.cpp | 121 ++++++++++++++++++++++++++++++++++++++++++++++ c++/test/ttypes.cpp | 20 +++++++- 15 files changed, 490 insertions(+), 14 deletions(-) diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index ae48d16..1cfc259 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -744,6 +744,31 @@ bool DataType::isVariableStr() const } //-------------------------------------------------------------------------- +// Function: DataType::getCreatePlist +///\brief Returns a copy of the property list, which is for datatype +/// creation. +///\return A property list object +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - March, 2017 +// Description +// Currently, there is no datatype creation property list class +// in the C++ API because there is no associated functionality. +//-------------------------------------------------------------------------- +PropList DataType::getCreatePlist() const +{ + hid_t create_plist_id = H5Tget_create_plist(id); + if (create_plist_id < 0) + { + throw DataTypeIException(inMemFunc("getCreatePlist"), + "H5Tget_create_plist returns negative value"); + } + // create and return the DSetCreatPropList object + PropList create_plist; + f_PropList_setId(&create_plist, create_plist_id); + return(create_plist); +} + +//-------------------------------------------------------------------------- // Function: DataType::getId ///\brief Get the id of this datatype ///\return Datatype identifier diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index fd9c17d..6501bb9 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -113,6 +113,9 @@ class H5_DLLCPP DataType : public H5Object { // Checks whether this datatype is a variable-length string. bool isVariableStr() const; + // Returns a copy of the creation property list of a datatype. + PropList getCreatePlist() const; + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DataType"); } diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 86d4d9c..e1be3c4 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -18,6 +18,7 @@ #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" +#include "H5DataSpace.h" #include "H5PropList.h" #include "H5OcreatProp.h" #include "H5DcreatProp.h" @@ -740,6 +741,55 @@ void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, } //-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setVirtual +///\brief Maps elements of a virtual dataset to elements of the source +/// dataset. +///\param vspace - IN: Dataspace the virtual dataset, possibly an +/// unlimited selection +///\param src_fname - IN: Name of the HDF5 file where the source dataset +/// is located (\a char*) +///\param src_fname - IN: Path to the dataset in the file specified by +/// \a src_file_name (\a char*) +///\param sspace - IN: Dataspace with a selection applied, possibly +/// an unlimited selection +///\exception H5::PropListIException +///\par Description +/// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetVirtual +// Programmer Binh-Minh Ribler - Mar, 2017 +//-------------------------------------------------------------------------- +void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const +{ + herr_t ret_value = H5Pset_virtual(id, vspace.getId(), src_fname, src_dsname, sspace.getId()); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::setVirtual", + "H5Pset_virtual failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setVirtual +///\brief Maps elements of a virtual dataset to elements of the source +/// dataset. +///\param vspace - IN: Dataspace the virtual dataset, possibly an +/// unlimited selection +///\param src_fname - IN: Name of the HDF5 file where the source dataset +/// is located (\a H5std_string) +///\param src_fname - IN: Path to the dataset in the file specified by +/// \a src_file_name (\a H5std_string) +///\param sspace - IN: Dataspace with a selection applied, possibly +/// an unlimited selection +///\exception H5::PropListIException +///\par Description +/// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetVirtual +// Programmer Binh-Minh Ribler - Mar, 2017 +//-------------------------------------------------------------------------- +void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const +{ + setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace); +} + +//-------------------------------------------------------------------------- // Function: DSetCreatPropList destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index b536709..5371e03 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -20,6 +20,7 @@ namespace H5 { class DataType; +class DataSpace; /*! \class DSetCreatPropList \brief Class DSetCreatPropList inherits from ObjCreatPropList and provides @@ -116,6 +117,10 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { // Sets N-bit compression method. void setNbit() const; + // Maps elements of a virtual dataset to elements of the source dataset. + void setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const; + void setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const; + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DSetCreatPropList"); } diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index ae7c7f9..586dcf8 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -117,6 +117,12 @@ class H5_DLLCPP FileAccPropList : public PropList { // Returns the degree for the file close behavior. H5F_close_degree_t getFcloseDegree() const; + // Sets file access property list to use the H5FD_DIRECT driver. + void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; + + // Retrieves information about the direct file access property list. + void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; + // Sets garbage collecting references flag. void setGcReferences(unsigned gc_ref = 0) const; diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 6b143b5..6e5cdaa 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -64,8 +64,56 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) } //-------------------------------------------------------------------------- +// Function: Group::getObjId +///\brief Opens an object via object header. +///\exception H5::FileIException or H5::GroupIException +///\par Description +/// This function opens an object in a group or file, using +/// H5Oopen. Thus, an object can be opened without knowing +/// the object's type. +// Programmer Binh-Minh Ribler - March, 2017 +//-------------------------------------------------------------------------- +hid_t Group::getObjId(const char* obj_name, const PropList& plist) const +{ + hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); + if (ret_value < 0) + { + throwException("Group::getObjId", "H5Oopen failed"); + } + return(ret_value); +} + +//-------------------------------------------------------------------------- +// Function: Group::getObjId +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the object's name. +///\param obj_name - IN: Path to the object +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - March, 2017 +//-------------------------------------------------------------------------- +hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const +{ + return(getObjId(obj_name.c_str(), plist)); +} + +//-------------------------------------------------------------------------- +// Function: Group::closeObjId +///\brief Closes an object, which was opened with Group::getObjId +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - March, 2017 +//-------------------------------------------------------------------------- +void Group::closeObjId(hid_t obj_id) const +{ + herr_t ret_value = H5Oclose(obj_id); + if (ret_value < 0) + { + throwException("Group::closeObjId", "H5Oclose failed"); + } +} + +//-------------------------------------------------------------------------- // Function: Group::getLocId -// Purpose: Get the id of this group +// Purpose: Get the id of this group // Programmer Binh-Minh Ribler - 2000 // Description // This function is a redefinition of CommonFG::getLocId. It diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 96dc5c1..3118aa7 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -54,6 +54,13 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Opens an object within a group or a file, i.e., root group. + hid_t getObjId(const char* name, const PropList& plist = PropList::DEFAULT) const; + hid_t getObjId(const H5std_string& name, const PropList& plist = PropList::DEFAULT) const; + + // Closes an object opened by getObjId(). + void closeObjId(hid_t obj_id) const; + // default constructor Group(); diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 574b28a..0bcc67a 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -194,6 +194,27 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type) } //-------------------------------------------------------------------------- +// Function: isValid (static) +///\brief Checks if the given ID is valid. +///\return true if the given identifier is valid, and false, otherwise. +///\Description +/// A valid ID is one that is in use and has an application +/// reference count of at least 1. +// Programmer Binh-Minh Ribler - Mar 1, 2017 +//-------------------------------------------------------------------------- +bool IdComponent::isValid(hid_t an_id) +{ + // Call C function + htri_t ret_value = H5Iis_valid(an_id); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Iis_valid returns a negative value + throw IdComponentException("isValid", "H5Iis_valid failed"); +} + +//-------------------------------------------------------------------------- // Function: typeExists (static) ///\brief Queries if a given type is currently registered with the /// library. diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 6f57364..b449d4a 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -19,7 +19,6 @@ namespace H5 { -class DataSpace; /*! \class IdComponent \brief Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier. @@ -51,6 +50,9 @@ class H5_DLLCPP IdComponent { // Returns the number of members in a type. static hsize_t getNumMembers(H5I_type_t type); + // Checks if the given ID is valid. + static bool isValid(hid_t an_id); + // Determines if an type exists. static bool typeExists(H5I_type_t type); diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index e9adb12..e457e83 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -40,7 +40,7 @@ LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; // If LinkAccPropList::DEFAULT_ already points to an allocated // object, throw a PropListIException. This scenario should not // happen. -// Programmer Binh-Minh Ribler - 2015 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- LinkAccPropList* LinkAccPropList::getConstant() { @@ -66,7 +66,7 @@ LinkAccPropList* LinkAccPropList::getConstant() // Purpose: Deletes the constant object that LinkAccPropList::DEFAULT_ // points to. // exception H5::PropListIException -// Programmer Binh-Minh Ribler - 2015 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- void LinkAccPropList::deleteConstants() { @@ -84,7 +84,7 @@ const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); //-------------------------------------------------------------------------- // Function: Default Constructor ///\brief Creates a file access property list -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} @@ -92,7 +92,7 @@ LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} // Function: LinkAccPropList copy constructor ///\brief Copy Constructor: makes a copy of the original ///\param original - IN: LinkAccPropList instance to copy -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {} @@ -100,14 +100,51 @@ LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(ori // Function: LinkAccPropList overloaded constructor ///\brief Creates a file access property list using the id of an /// existing one. -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} //-------------------------------------------------------------------------- +// Function: LinkAccPropList::setNumLinks +///\brief Set the number of soft or user-defined link traversals allowed +/// before the library assumes it has found a cycle and aborts the +/// traversal. +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - March 1, 2017 +//-------------------------------------------------------------------------- +void LinkAccPropList::setNumLinks(size_t nlinks) const +{ + herr_t ret_value = H5Pset_nlinks(id, nlinks); + // Throw exception if H5Pset_nlinks returns failure + if (ret_value < 0) + { + throw PropListIException("setNumLinks", "H5Pset_nlinks failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: LinkAccPropList::getNumLinks +///\brief Gets the number of soft or user-defined links that can be +/// traversed before a failure occurs. +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - March 1, 2017 +//-------------------------------------------------------------------------- +size_t LinkAccPropList::getNumLinks() const +{ + size_t nlinks = 0; + herr_t ret_value = H5Pget_nlinks(id, &nlinks); + // Throw exception if H5Pget_nlinks returns failure + if (ret_value < 0) + { + throw PropListIException("getNumLinks", "H5Pget_nlinks failed"); + } + return(nlinks); +} + +//-------------------------------------------------------------------------- // Function: LinkAccPropList destructor ///\brief Noop destructor -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- LinkAccPropList::~LinkAccPropList() {} diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index 8bcdd64..1cb80f7 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -46,6 +46,13 @@ class H5_DLLCPP LinkAccPropList : public PropList { // using the property list id. LinkAccPropList (const hid_t plist_id); + // Sets the number of soft or user-defined links that can be + // traversed before a failure occurs. + void setNumLinks(size_t nlinks) const; + + // Gets the number of soft or user-defined link traversals allowed + size_t getNumLinks() const; + // Noop destructor virtual ~LinkAccPropList(); diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 48a0c4d..970f210 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -1148,6 +1148,87 @@ test_types(H5File& file) /*------------------------------------------------------------------------- + * Function: test_virtual + * + * Purpose: Tests fixed, unlimited, and printf selections in the same + * VDS + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Binh-Minh Ribler + * Friday, March 10, 2017 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const int RANK = 2; +static herr_t +test_virtual() +{ + SUBTEST("DSetCreatPropList::setVirtual"); + + try { + // Create DCPLs + DSetCreatPropList dcpl; + DSetCreatPropList srcdcpl; + + // Set fill value + char *fill = NULL; + dcpl.setFillValue(PredType::NATIVE_INT, &fill); + + // Set chunk dimensions + hsize_t cdims[RANK]; + cdims[0] = 2; + cdims[1] = 2; + srcdcpl.setChunk(RANK, cdims); + + // Create memory space + hsize_t mdims[RANK]; + mdims[0] = 10; + mdims[1] = 10; + DataSpace memspace(RANK, mdims); + + // Get the current layout, should be default, H5D_CONTIGUOUS + H5D_layout_t layout = dcpl.getLayout(); + verify_val(layout, H5D_CONTIGUOUS, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + + // Create fixed mapping + hsize_t dims[RANK]; + dims[0] = 6; + dims[1] = 6; + DataSpace vspace(RANK, dims, mdims); + + hsize_t start[RANK]; // Hyperslab start + hsize_t count[RANK]; // Hyperslab count + start[0] = start[1] = 3; + count[0] = count[1] = 3; + vspace.selectHyperslab(H5S_SELECT_SET, count, start); + + DataSpace srcspace(RANK, count); + + H5std_string src_file = "src_file_map.h5"; + H5std_string src_dset = "src_dset_fixed"; + dcpl.setVirtual(vspace, src_file, src_dset, srcspace); + + // Get and verify the new layout + layout = dcpl.getLayout(); + verify_val(layout, H5D_VIRTUAL, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + + PASSED(); + return 0; + } // end top try block + + catch (Exception& E) + { + return -1; + } +} // test_virtual + + +/*------------------------------------------------------------------------- * Function: test_dset * * Purpose Tests the dataset interface (H5D) @@ -1195,6 +1276,7 @@ void test_dset() nerrors += test_nbit_compression(file) < 0 ? 1:0; nerrors += test_multiopen (file) < 0 ? 1:0; nerrors += test_types(file) < 0 ? 1:0; + nerrors += test_virtual() < 0 ? 1:0; // Close group "emit diagnostics". grp.close(); diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index c217718..0bf6ebf 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -142,11 +142,8 @@ const char *FILENAME[] = { #define H5L_DIM2 100 /* Creation order macros */ -#define CORDER_GROUP_NAME "corder_group" #define CORDER_SOFT_GROUP_NAME "corder_soft_group" #define CORDER_NLINKS 18 -#define CORDER_ITER_STOP 3 -#define CORDER_EST_ENTRY_LEN 9 /* Timestamp macros */ #define TIMESTAMP_GROUP_1 "timestamp1" @@ -341,7 +338,7 @@ static const char *FILENAME[] = { static void test_basic_links(hid_t fapl_id, hbool_t new_format) { hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); @@ -441,6 +438,55 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) /*------------------------------------------------------------------------- + * Function: test_num_links + * + * Purpose Test setting and getting limit of number of links + * + * Return Success: 0 + * + * Failure: -1 + * + * Programmer Binh-Minh Ribler + * October 16, 2009 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void test_num_links(hid_t fapl_id, hbool_t new_format) +{ + char filename[NAME_BUF_SIZE]; + + if(new_format) + SUBTEST("Setting number of links (w/new group format)") + else + SUBTEST("Setting number of links") + + try + { + // Use the file access template id to create a file access prop. list. + FileAccPropList fapl(fapl_id); + + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); + + LinkAccPropList lapl; + size_t nlinks = 5; + lapl.setNumLinks(nlinks); + + // Read it back and verify + size_t read_nlinks = lapl.getNumLinks(); + verify_val(read_nlinks, nlinks, "LinkAccPropList::setNumLinks", __LINE__, __FILE__); + + PASSED(); + } // end of try block + catch (Exception& E) + { + issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_num_links + +/*------------------------------------------------------------------------- * Function: test_links * * Purpose Test links diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 6003dd6..3c9c1b0 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -32,6 +32,7 @@ using namespace H5; #include "h5cpputil.h" // C++ utilility header file const H5std_string FILE_OBJECTS("tobjects.h5"); +const H5std_string FILE_OBJHDR("tobject_header.h5"); const H5std_string GROUP1("Top Group"); const H5std_string GROUP1_PATH("/Top Group"); const H5std_string GROUP1_1("Sub-Group 1.1"); @@ -395,7 +396,126 @@ static void test_get_objtype() issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } } // test_get_objtype + +/*------------------------------------------------------------------------- + * Function: test_open_object_header + * + * Purpose Test Group::getObjId function. + * + * Return None + * + * Programmer Binh-Minh Ribler (use C version) + * March, 2017 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const H5std_string GROUPNAME("group"); +const H5std_string DTYPENAME("group/datatype"); +const H5std_string DTYPENAME_INGRP("datatype"); +const H5std_string DSETNAME("dataset"); +#define RANK 2 +#define DIM0 5 +#define DIM1 10 +static void test_open_object_header() +{ + hsize_t dims[2]; + H5G_info_t ginfo; /* Group info struct */ + + // Output message about test being performed + SUBTEST("Group::getObjId"); + + try { + // Create file FILE1 + H5File file1(FILE_OBJHDR, H5F_ACC_TRUNC); + /* Create a group, dataset, and committed datatype within the file */ + + // Create a group in the root group + Group grp(file1.createGroup(GROUPNAME)); + grp.close(); + // Commit the type inside the file + IntType dtype(PredType::NATIVE_INT); + dtype.commit(file1, DTYPENAME); + dtype.close(); + + // Create a new dataset + dims[0] = DIM0; + dims[1] = DIM1; + DataSpace dspace(RANK, dims); + DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); + + // Close dataset and dataspace + dset.close(); + dspace.close(); + + // Now make sure that getObjId can open all three types of objects + hid_t obj_grp = file1.getObjId(GROUPNAME); + hid_t obj_dtype = file1.getObjId(DTYPENAME); + hid_t obj_dset = file1.getObjId(DSETNAME); + + // Make sure that each is the right kind of ID + H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp); + verify_val(id_type, H5I_GROUP, "H5Iget_type for group ID", __LINE__, __FILE__); + id_type = IdComponent::getHDFObjType(obj_dtype); + verify_val(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID", __LINE__, __FILE__); + id_type = IdComponent::getHDFObjType(obj_dset); + verify_val(id_type, H5I_DATASET, "H5Iget_type for dataset ID", __LINE__, __FILE__); + + /* Do something more complex with each of the IDs to make sure */ + + Group grp2(obj_grp); + hsize_t num_objs = grp2.getNumObjs(); + verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); + // There should be one object, the datatype + + // Close datatype object opened from the file + file1.closeObjId(obj_dtype); + + dset.setId(obj_dset); + dspace = dset.getSpace(); + bool is_simple = dspace.isSimple(); + dspace.close(); + + // Open datatype object from the group + obj_dtype = grp2.getObjId(DTYPENAME_INGRP); + + dtype.setId(obj_dtype); + H5T_class_t type_class = dtype.getClass(); + verify_val(type_class, H5T_INTEGER, "H5Tget_class", __LINE__, __FILE__); + dtype.close(); + + // Close datatype object + grp2.closeObjId(obj_dtype); + + // Close the group object + file1.closeObjId(obj_grp); + + // Try doing something with group, the ID should still work + num_objs = grp2.getNumObjs(); + verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); + + // Close the cloned group + grp2.close(); + + PASSED(); + } // end of try block + // catch invalid action exception + catch (InvalidActionException& E) + { + cerr << " in InvalidActionException" << endl; + cerr << " *FAILED*" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + } + // catch all other exceptions + catch (Exception& E) + { + cerr << " in Exception" << endl; + issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} /* test_open_object_header() */ + /*------------------------------------------------------------------------- * Function: test_objects * @@ -421,6 +541,7 @@ void test_object() test_existance(); // Test check for object existance test_get_objname_ontypes(); // Test get object name from types test_get_objtype(); // Test get object type + test_open_object_header(); // Test object header functions (H5O) } // test_objects diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 0cc8918..22db539 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -248,12 +248,28 @@ static void test_query() index = tid2.getMemberIndex("ORANGE"); verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__); - // Commit compound datatype and close it + // Commit compound datatype, and test getting the datatype creation + // prop list, then close it tid1.commit(file, CompT_NAME); + PropList tcpl = tid1.getCreatePlist(); + if (!IdComponent::isValid(tcpl.getId())) + { + // Throw an invalid action exception + throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + } + tcpl.close(); tid1.close(); - // Commit enumeration datatype and close it + // Commit enumeration datatype, and test getting the datatype creation + // prop list, then close it tid2.commit(file, EnumT_NAME); + tcpl = tid2.getCreatePlist(); + if (!IdComponent::isValid(tcpl.getId())) + { + // Throw an invalid action exception + throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + } + tcpl.close(); tid2.close(); // Open the datatypes for query -- cgit v0.12 From 0313cbb91d974b153dbe8747d193ac3c619eea3b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Mar 2017 21:30:37 -0700 Subject: Final merge of page buffering branch to develop --- MANIFEST | 36 +- bin/trace | 2 + c++/src/H5Attribute.cpp | 2 +- c++/src/H5FcreatProp.cpp | 2 + c++/src/H5FcreatProp.h | 2 + c++/test/tfile.cpp | 14 + fortran/test/tH5F.F90 | 6 +- java/src/hdf/hdf5lib/H5.java | 121 +- java/src/hdf/hdf5lib/HDF5Constants.java | 24 +- java/src/jni/h5Constants.c | 12 +- java/src/jni/h5pImp.c | 115 +- java/src/jni/h5pImp.h | 51 +- java/test/JUnit-interface.txt | 5 +- java/test/TestH5P.java | 41 +- src/CMakeLists.txt | 13 + src/H5AC.c | 120 + src/H5ACprivate.h | 3 + src/H5C.c | 126 +- src/H5Cimage.c | 97 +- src/H5Cmpio.c | 7 +- src/H5Cpkg.h | 3 +- src/H5Cprivate.h | 5 + src/H5F.c | 82 +- src/H5FD.c | 24 + src/H5FDlog.c | 8 +- src/H5FDmulti.c | 10 + src/H5FDprivate.h | 5 +- src/H5FDpublic.h | 14 + src/H5FDspace.c | 81 +- src/H5FDstdio.c | 7 - src/H5FS.c | 197 +- src/H5FScache.c | 28 +- src/H5FSpkg.h | 3 +- src/H5FSprivate.h | 28 +- src/H5FSsection.c | 307 +- src/H5Fint.c | 112 +- src/H5Fio.c | 13 +- src/H5Fpkg.h | 59 +- src/H5Fprivate.h | 81 +- src/H5Fpublic.h | 15 + src/H5Fquery.c | 147 + src/H5Fspace.c | 226 + src/H5Fsuper.c | 171 +- src/H5HFsection.c | 42 +- src/H5MF.c | 3636 ++++++++++---- src/H5MFaggr.c | 181 +- src/H5MFdbg.c | 105 +- src/H5MFpkg.h | 67 +- src/H5MFprivate.h | 10 +- src/H5MFsection.c | 714 ++- src/H5Oalloc.c | 8 + src/H5Ocache_image.c | 48 +- src/H5Ofsinfo.c | 190 +- src/H5Omessage.c | 52 + src/H5Oprivate.h | 14 +- src/H5PB.c | 1533 ++++++ src/H5PBmodule.h | 34 + src/H5PBpkg.h | 60 + src/H5PBprivate.h | 108 + src/H5Pdeprec.c | 130 + src/H5Pfapl.c | 132 +- src/H5Pfcpl.c | 250 +- src/H5Ppublic.h | 10 +- src/H5err.txt | 1 + src/H5trace.c | 37 +- src/Makefile.am | 3 +- test/CMakeLists.txt | 1 + test/CMakeTests.cmake | 14 +- test/Makefile.am | 4 +- test/aggr.h5 | Bin 0 -> 2448 bytes test/cache.c | 722 +-- test/cache_api.c | 105 +- test/cache_common.c | 54 +- test/cache_common.h | 2 +- test/cache_image.c | 532 +- test/cache_tagging.c | 49 +- test/dsets.c | 218 +- test/fheap.c | 158 +- test/filespace_1_8.h5 | Bin 2448 -> 2544 bytes test/freespace.c | 24 +- test/fsm_aggr_nopersist.h5 | Bin 0 -> 2448 bytes test/fsm_aggr_persist.h5 | Bin 0 -> 2565 bytes test/gen_filespace.c | 136 +- test/gen_idx.c | 126 - test/gen_plist.c | 6 + test/h5fc_ext1_f.h5 | Bin 0 -> 6760 bytes test/h5fc_ext1_i.h5 | Bin 0 -> 6526 bytes test/h5fc_ext2_if.h5 | Bin 0 -> 6526 bytes test/h5fc_ext2_sf.h5 | Bin 0 -> 5076 bytes test/h5fc_ext3_isf.h5 | Bin 0 -> 6679 bytes test/h5fc_ext_none.h5 | Bin 0 -> 6474 bytes test/links.c | 2 + test/mf.c | 5239 ++++++++++++-------- test/none.h5 | Bin 0 -> 1808 bytes test/page_buffer.c | 2087 ++++++++ test/paged_nopersist.h5 | Bin 0 -> 8192 bytes test/paged_persist.h5 | Bin 0 -> 16384 bytes test/set_extent.c | 18 +- test/stab.c | 81 +- test/testfiles/plist_files/def_fcpl_32be | Bin 412 -> 452 bytes test/testfiles/plist_files/def_fcpl_32le | Bin 412 -> 452 bytes test/testfiles/plist_files/def_fcpl_64be | Bin 412 -> 452 bytes test/testfiles/plist_files/def_fcpl_64le | Bin 412 -> 452 bytes test/testfiles/plist_files/fcpl_32be | Bin 413 -> 453 bytes test/testfiles/plist_files/fcpl_32le | Bin 413 -> 453 bytes test/testfiles/plist_files/fcpl_64be | Bin 413 -> 453 bytes test/testfiles/plist_files/fcpl_64le | Bin 413 -> 453 bytes test/tfile.c | 2078 ++++++-- test/tmisc.c | 16 +- testpar/Makefile.am | 2 +- testpar/t_cache_image.c | 2161 ++++++++ testpar/t_file.c | 615 ++- testpar/t_mdset.c | 6 +- testpar/testphdf5.c | 5 + testpar/testphdf5.h | 1 + tools/src/h5dump/h5dump_ddl.c | 33 +- tools/src/h5repack/h5repack.c | 6 +- tools/src/h5repack/h5repack.h | 16 +- tools/src/h5repack/h5repack_copy.c | 74 +- tools/src/h5repack/h5repack_main.c | 81 +- tools/src/h5repack/h5repack_verify.c | 112 +- tools/src/h5stat/h5stat.c | 25 +- tools/src/misc/h5clear.c | 255 +- .../h5copy/testfiles/h5copy_extlinks_src.out.ls | 14 +- tools/test/h5copy/testfiles/h5copy_ref.out.ls | 10 +- tools/test/h5copy/testfiles/h5copytst.h5 | Bin 15900 -> 15944 bytes tools/test/h5copy/testfiles/h5copytst.out.ls | 182 +- tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 | Bin 5974 -> 0 bytes tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 | Bin 2206 -> 0 bytes tools/test/h5diff/testfiles/h5diff_idx.txt | 14 - tools/test/h5dump/h5dumpgentest.c | 13 +- tools/test/h5format_convert/h5fc_gentest.c | 8 +- .../h5format_convert/testfiles/h5fc_edge_v3.h5 | Bin 2526 -> 2478 bytes .../h5format_convert/testfiles/h5fc_err_level.h5 | Bin 7294 -> 6236774 bytes .../h5format_convert/testfiles/h5fc_ext1_f.ddl | 6 +- .../test/h5format_convert/testfiles/h5fc_ext1_f.h5 | Bin 8296 -> 12288 bytes .../h5format_convert/testfiles/h5fc_ext1_i.ddl | 6 +- .../test/h5format_convert/testfiles/h5fc_ext1_i.h5 | Bin 8062 -> 7990 bytes .../h5format_convert/testfiles/h5fc_ext1_s.ddl | 6 +- .../test/h5format_convert/testfiles/h5fc_ext1_s.h5 | Bin 8128 -> 8167 bytes .../h5format_convert/testfiles/h5fc_ext2_if.ddl | 6 +- .../h5format_convert/testfiles/h5fc_ext2_if.h5 | Bin 8062 -> 8373 bytes .../h5format_convert/testfiles/h5fc_ext2_is.ddl | 6 +- .../h5format_convert/testfiles/h5fc_ext2_is.h5 | Bin 8178 -> 8186 bytes .../h5format_convert/testfiles/h5fc_ext2_sf.ddl | 6 +- .../h5format_convert/testfiles/h5fc_ext2_sf.h5 | Bin 6612 -> 8246 bytes .../h5format_convert/testfiles/h5fc_ext3_isf.ddl | 6 +- .../h5format_convert/testfiles/h5fc_ext3_isf.h5 | Bin 8215 -> 6642 bytes .../h5format_convert/testfiles/h5fc_ext_none.h5 | Bin 8010 -> 8014 bytes .../test/h5format_convert/testfiles/h5fc_non_v3.h5 | Bin 6818 -> 7010 bytes .../h5format_convert/testfiles/old_h5fc_ext1_f.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext1_f.h5 | Bin 19987 -> 28672 bytes .../h5format_convert/testfiles/old_h5fc_ext1_i.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext1_i.h5 | Bin 32716 -> 32716 bytes .../h5format_convert/testfiles/old_h5fc_ext1_s.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext1_s.h5 | Bin 20032 -> 20032 bytes .../testfiles/old_h5fc_ext2_if.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext2_if.h5 | Bin 32720 -> 32984 bytes .../testfiles/old_h5fc_ext2_is.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext2_is.h5 | Bin 32872 -> 32872 bytes .../testfiles/old_h5fc_ext2_sf.ddl | 6 +- .../h5format_convert/testfiles/old_h5fc_ext2_sf.h5 | Bin 18512 -> 20096 bytes .../testfiles/old_h5fc_ext3_isf.ddl | 6 +- .../testfiles/old_h5fc_ext3_isf.h5 | Bin 32896 -> 31344 bytes .../testfiles/old_h5fc_ext_none.h5 | Bin 19912 -> 19912 bytes tools/test/h5repack/h5repacktst.c | 466 +- .../h5repack/testfiles/4_vds.h5-vds_conti-v.ddl | 2 +- tools/test/h5repack/testfiles/h5repack-help.txt | 39 +- tools/test/h5stat/CMakeTests.cmake | 4 - tools/test/h5stat/h5stat_gentest.c | 2 +- tools/test/h5stat/testfiles/h5stat_filters.ddl | 4 +- tools/test/h5stat/testfiles/h5stat_idx.ddl | 8 +- tools/test/h5stat/testfiles/h5stat_idx.h5 | Bin 2206 -> 2158 bytes tools/test/h5stat/testfiles/h5stat_links2.ddl | 4 +- tools/test/h5stat/testfiles/h5stat_newgrat.ddl | 10 +- tools/test/h5stat/testfiles/h5stat_newgrat.h5 | Bin 6362168 -> 6362235 bytes tools/test/h5stat/testfiles/h5stat_numattrs1.ddl | 3 +- tools/test/h5stat/testfiles/h5stat_numattrs2.ddl | 4 +- tools/test/h5stat/testfiles/h5stat_tsohm.ddl | 4 +- tools/test/misc/CMakeLists.txt | 4 +- tools/test/misc/CMakeTests.cmake | 340 -- tools/test/misc/CMakeTestsClear.cmake | 197 + tools/test/misc/CMakeTestsMkgrp.cmake | 188 + tools/test/misc/CMakeTestsRepart.cmake | 85 + tools/test/misc/h5clear_gentest.c | 105 + tools/test/misc/testfiles/h5clear_missing_file.ddl | 15 + tools/test/misc/testfiles/h5clear_no_mdc_image.ddl | 1 + tools/test/misc/testfiles/h5clear_open_fail.ddl | 1 + tools/test/misc/testfiles/h5clear_usage.ddl | 14 + tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 | Bin 0 -> 22048 bytes tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 | Bin 0 -> 800 bytes tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 | Bin 0 -> 830 bytes tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 | Bin 0 -> 195 bytes tools/test/misc/testh5clear.sh.in | 284 +- tools/test/perform/sio_engine.c | 11 +- tools/test/perform/sio_perf.c | 26 +- tools/test/perform/sio_perf.h | 2 + tools/testfiles/file_space.ddl | 6 +- tools/testfiles/file_space.h5 | Bin 792 -> 808 bytes tools/testfiles/tboot1.ddl | 6 +- tools/testfiles/tboot2.ddl | 6 +- tools/testfiles/tboot2A.ddl | 6 +- tools/testfiles/tboot2B.ddl | 6 +- tools/testfiles/tdset_idx.ddl | 61 - 204 files changed, 21159 insertions(+), 5934 deletions(-) create mode 100644 src/H5Fspace.c create mode 100644 src/H5PB.c create mode 100644 src/H5PBmodule.h create mode 100644 src/H5PBpkg.h create mode 100644 src/H5PBprivate.h create mode 100644 test/aggr.h5 create mode 100644 test/fsm_aggr_nopersist.h5 create mode 100644 test/fsm_aggr_persist.h5 delete mode 100644 test/gen_idx.c create mode 100644 test/h5fc_ext1_f.h5 create mode 100644 test/h5fc_ext1_i.h5 create mode 100644 test/h5fc_ext2_if.h5 create mode 100644 test/h5fc_ext2_sf.h5 create mode 100644 test/h5fc_ext3_isf.h5 create mode 100644 test/h5fc_ext_none.h5 create mode 100644 test/none.h5 create mode 100644 test/page_buffer.c create mode 100644 test/paged_nopersist.h5 create mode 100644 test/paged_persist.h5 create mode 100644 testpar/t_cache_image.c delete mode 100644 tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 delete mode 100644 tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 delete mode 100644 tools/test/h5diff/testfiles/h5diff_idx.txt delete mode 100644 tools/test/misc/CMakeTests.cmake create mode 100644 tools/test/misc/CMakeTestsClear.cmake create mode 100644 tools/test/misc/CMakeTestsMkgrp.cmake create mode 100644 tools/test/misc/CMakeTestsRepart.cmake create mode 100644 tools/test/misc/testfiles/h5clear_missing_file.ddl create mode 100644 tools/test/misc/testfiles/h5clear_no_mdc_image.ddl create mode 100644 tools/test/misc/testfiles/h5clear_open_fail.ddl create mode 100644 tools/test/misc/testfiles/h5clear_usage.ddl create mode 100644 tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 create mode 100644 tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 create mode 100644 tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 create mode 100644 tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 delete mode 100644 tools/testfiles/tdset_idx.ddl diff --git a/MANIFEST b/MANIFEST index 95c9bbd..51776fe 100644 --- a/MANIFEST +++ b/MANIFEST @@ -579,6 +579,7 @@ ./src/H5Fmpi.c ./src/H5Fquery.c ./src/H5Fsfile.c +./src/H5Fspace.c ./src/H5Fsuper.c ./src/H5Fsuper_cache.c ./src/H5Fpkg.h @@ -793,6 +794,10 @@ ./src/H5Ppublic.h ./src/H5Pstrcpl.c ./src/H5Ptest.c +./src/H5PB.c +./src/H5PBmodule.h +./src/H5PBpkg.h +./src/H5PBprivate.h ./src/H5PL.c ./src/H5PLmodule.h ./src/H5PLprivate.h @@ -895,6 +900,7 @@ ./test/SWMR_UseCase_UG.txt ./test/accum.c ./test/accum_swmr_reader.c +./test/aggr.h5 ./test/app_ref.c ./test/atomic_reader.c ./test/atomic_writer.c @@ -957,6 +963,8 @@ ./test/flush1.c ./test/flush2.c ./test/flushrefresh.c +./test/fsm_aggr_nopersist.h5 +./test/fsm_aggr_persist.h5 ./test/genall5.c ./test/genall5.h ./test/gen_bad_ohdr.c @@ -966,7 +974,6 @@ ./test/gen_deflate.c ./test/gen_file_image.c ./test/gen_filespace.c -./test/gen_idx.c ./test/gen_mergemsg.c ./test/gen_new_array.c ./test/gen_new_fill.c @@ -986,6 +993,12 @@ ./test/getname.c ./test/gheap.c ./test/group_old.h5 +./test/h5fc_ext1_f.h5 +./test/h5fc_ext1_i.h5 +./test/h5fc_ext2_if.h5 +./test/h5fc_ext2_sf.h5 +./test/h5fc_ext3_isf.h5 +./test/h5fc_ext_none.h5 ./test/h5test.c ./test/h5test.h ./test/hyperslab.c @@ -1002,9 +1015,13 @@ ./test/multi_file_v16-r.h5 ./test/multi_file_v16-s.h5 ./test/noencoder.h5 +./test/none.h5 ./test/ntypes.c ./test/ohdr.c ./test/objcopy.c +./test/page_buffer.c +./test/paged_nopersist.h5 +./test/paged_persist.h5 ./test/plugin.c ./test/reserved.c ./test/pool.c @@ -1203,6 +1220,7 @@ ./testpar/COPYING ./testpar/Makefile.am ./testpar/t_cache.c +./testpar/t_cache_image.c ./testpar/t_chunk_alloc.c ./testpar/t_coll_chunk.c ./testpar/t_dset.c @@ -1448,6 +1466,14 @@ ./tools/test/misc/testh5mkgrp.sh.in ./tools/test/misc/testh5repart.sh.in ./tools/test/misc/talign.c +./tools/test/misc/testfiles/h5clear_missing_file.ddl +./tools/test/misc/testfiles/h5clear_no_mdc_image.ddl +./tools/test/misc/testfiles/h5clear_open_fail.ddl +./tools/test/misc/testfiles/h5clear_usage.ddl +./tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 +./tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 +./tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 +./tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 ./tools/test/misc/testfiles/h5mkgrp_help.txt ./tools/test/misc/testfiles/h5mkgrp_version.txt.in ./tools/test/misc/h5perf_gentest.c @@ -1637,7 +1663,6 @@ ./tools/testfiles/tdset.h5 ./tools/testfiles/tdset2.h5 ./tools/testfiles/tdset_idx.ls -./tools/testfiles/tdset_idx.ddl ./tools/testfiles/tdset_idx.h5 ./tools/testfiles/tempty.ddl ./tools/testfiles/tempty.h5 @@ -2270,7 +2295,6 @@ ./tools/test/h5diff/testfiles/h5diff_457.txt ./tools/test/h5diff/testfiles/h5diff_458.txt ./tools/test/h5diff/testfiles/h5diff_459.txt -./tools/test/h5diff/testfiles/h5diff_idx.txt ./tools/test/h5diff/testfiles/h5diff_465.txt ./tools/test/h5diff/testfiles/h5diff_466.txt ./tools/test/h5diff/testfiles/h5diff_467.txt @@ -2319,8 +2343,6 @@ ./tools/test/h5diff/testfiles/h5diff_basic2.h5 ./tools/test/h5diff/testfiles/h5diff_dset1.h5 ./tools/test/h5diff/testfiles/h5diff_dset2.h5 -./tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 -./tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 ./tools/test/h5diff/testfiles/h5diff_dtypes.h5 ./tools/test/h5diff/testfiles/h5diff_empty.h5 ./tools/test/h5diff/testfiles/h5diff_hyper1.h5 @@ -3123,7 +3145,9 @@ ./tools/test/h5stat/CMakeTests.cmake ./tools/src/misc/CMakeLists.txt ./tools/test/misc/CMakeLists.txt -./tools/test/misc/CMakeTests.cmake +./tools/test/misc/CMakeTestsClear.cmake +./tools/test/misc/CMakeTestsMkgrp.cmake +./tools/test/misc/CMakeTestsRepart.cmake ./tools/test/misc/vds/CMakeLists.txt ./tools/test/perform/CMakeLists.txt ./tools/test/perform/CMakeTests.cmake diff --git a/bin/trace b/bin/trace index 1ce0f15..19c8990 100755 --- a/bin/trace +++ b/bin/trace @@ -49,9 +49,11 @@ $Source = ""; "H5E_error_t" => "Ee", "H5E_type_t" => "Et", "H5F_close_degree_t" => "Fd", + "H5F_fspace_strategy_t" => "Ff", "H5F_file_space_type_t" => "Ff", "H5F_mem_t" => "Fm", "H5F_scope_t" => "Fs", + "H5F_fspace_type_t" => "Ft", "H5F_libver_t" => "Fv", "H5G_obj_t" => "Go", "H5G_stat_t" => "Gs", diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 6701f6e..c506906 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * -/* All rights reserved. * + * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index c490f26..ea69049 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -294,6 +294,7 @@ unsigned FileCreatPropList::getIstorek() const return(ik); } +#ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- // Function: FileCreatPropList::setFileSpace ///\brief Sets the strategy and the threshold value that the library @@ -364,6 +365,7 @@ hsize_t FileCreatPropList::getFileSpaceThreshold() const } return(threshold); } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- // Function: FileCreatPropList destructor diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index 1bbaabf..1d999cb 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -65,6 +65,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { // indexing chunked datasets. void setIstorek(unsigned ik) const; +#ifndef H5_NO_DEPRECATED_SYMBOLS // Sets the strategy and the threshold value that the library will // will employ in managing file space. void setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const; @@ -75,6 +76,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { // Returns the threshold value that the library uses in tracking free // space sections. hsize_t getFileSpaceThreshold() const; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ ///\brief Returns this class name. virtual H5std_string fromClass() const { return("FileCreatPropList"); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 261beab..eb07657 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -817,12 +817,14 @@ static void test_file_info() // Output message about test being performed SUBTEST("File general information"); +#ifndef H5_NO_DEPRECATED_SYMBOLS hsize_t in_threshold = 2; // Free space section threshold to set */ hsize_t out_threshold = 0; // Free space section threshold to get */ // File space handling strategy H5F_file_space_type_t in_strategy = H5F_FILE_SPACE_ALL; // File space handling strategy H5F_file_space_type_t out_strategy = H5F_FILE_SPACE_DEFAULT; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ try { // Create a file using default properties. @@ -846,7 +848,9 @@ static void test_file_info() fcpl.setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); fcpl.setIstorek(F2_ISTORE); +#ifndef H5_NO_DEPRECATED_SYMBOLS fcpl.setFileSpace(in_strategy, in_threshold); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Creating a file with the non-default file creation property list // should create a version 1 superblock @@ -859,7 +863,11 @@ static void test_file_info() // Get the file's version information. file7.getFileInfo(finfo); +#ifndef H5_NO_DEPRECATED_SYMBOLS verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + verify_val(finfo.super.version, 1, "H5File::getFileInfo", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); @@ -874,7 +882,11 @@ static void test_file_info() // Get the file's version information. file7.getFileInfo(finfo); +#ifndef H5_NO_DEPRECATED_SYMBOLS verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + verify_val(finfo.super.version, 1, "H5File::getFileInfo", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); @@ -900,12 +912,14 @@ static void test_file_info() VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); */ +#ifndef H5_NO_DEPRECATED_SYMBOLS // Get and verify the file space info from the creation property list */ out_strategy = fcpl2.getFileSpaceStrategy(); verify_val(static_cast(out_strategy), static_cast(in_strategy), "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); out_threshold = fcpl2.getFileSpaceThreshold(); verify_val(static_cast(out_threshold), static_cast(in_threshold), "FileCreatPropList::getFileSpaceThreshold", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ PASSED(); } // end of try block diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index 8334b30..ea8c53f 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -729,7 +729,7 @@ CONTAINS CALL h5fget_freespace_f(fid, free_space, error) CALL check("h5fget_freespace_f",error,total_error) - if(error .eq.0 .and. free_space .ne. 0) then + if(error .eq.0 .and. free_space .ne. 1248) then total_error = total_error + 1 write(*,*) "1: Wrong amount of free space reported, ", free_space endif @@ -745,7 +745,7 @@ CONTAINS ! Check the free space now CALL h5fget_freespace_f(fid, free_space, error) CALL check("h5fget_freespace_f",error,total_error) - if(error .eq.0 .and. free_space .ne. 0) then + if(error .eq.0 .and. free_space .ne. 216) then total_error = total_error + 1 write(*,*) "2: Wrong amount of free space reported, ", free_space endif @@ -757,7 +757,7 @@ CONTAINS ! Check the free space now CALL h5fget_freespace_f(fid, free_space, error) CALL check("h5fget_freespace_f",error,total_error) - if(error .eq.0 .and. free_space .ne. 0) then + if(error .eq.0 .and. free_space .ne. 1248) then total_error = total_error + 1 write(*,*) "3: Wrong amount of free space reported, ", free_space endif diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 02d35ba..5b35d17 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -5356,39 +5356,24 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, IllegalArgumentException; /** - * H5Pset_file_space sets the file space management strategy for the file associated with fcpl_id to strategy. + * H5Pset_file_space_strategy sets the file space management strategy for the file associated with fcpl_id to strategy. * There are four strategies that applications can select and they are described in the Parameters section. * * @param fcpl_id * IN: File creation property list identifier * @param strategy * IN: The strategy for file space management. - * Passing a value of zero (0) indicates that the value of strategy is not to be modified. - * H5F_FILE_SPACE_ALL_PERSIST - * With this strategy, the free-space managers track the free space that results from the - * manipulation of HDF5 objects in the HDF5 file. The free space information is saved when the - * file is closed, and reloaded when the file is reopened. When space is needed for file metadata - * or raw data, the HDF5 library first requests space from the library's free-space managers. - * If the request is not satisfied, the library requests space from the aggregators. If the request - * is still not satisfied, the library requests space from the virtual file driver. That is, the - * library will use all of the mechanisms for allocating space. - * H5F_FILE_SPACE_ALL (Default file space management strategy) - * With this strategy, the free-space managers track the free space that results from the manipulation - * of HDF5 objects in the HDF5 file. The free space information is NOT saved when the file is closed - * and the free space that exists upon file closing becomes unaccounted space in the file. - * Like the previous strategy, the library will try all of the mechanisms for allocating space. When - * space is needed for file metadata or raw data, the library first requests space from the free-space - * managers. If the request is not satisfied, the library requests space from the aggregators. If the - * request is still not satisfied, the library requests space from the virtual file driver. - * H5F_FILE_SPACE_AGGR_VFD - * With this strategy, the library does not track free space that results from the manipulation of HDF5 - * obejcts in the HDF5 file and the free space becomes unaccounted space in the file. - * When space is needed for file metadata or raw data, the library first requests space from the - * aggregators. If the request is not satisfied, the library requests space from the virtual file driver. - * H5F_FILE_SPACE_VFD - * With this strategy, the library does not track free space that results from the manipulation of HDF5 - * obejcts in the HDF5 file and the free space becomes unaccounted space in the file. - * When space is needed for file metadata or raw data, the library requests space from the virtual file driver. + * H5F_FSPACE_STRATEGY_FSM_AGGR + * Mechanisms: free-space managers, aggregators, and virtual file drivers + * This is the library default when not set. + * H5F_FSPACE_STRATEGY_PAGE + * Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers + * H5F_FSPACE_STRATEGY_AGGR + * Mechanisms: aggregators and virtual file drivers + * H5F_FSPACE_STRATEGY_NONE + * Mechanisms: virtual file drivers + * @param persist + * IN: True to persist free-space. * @param threshold * IN: The free-space section threshold. The library default is 1, which is to track all free-space sections. * Passing a value of zero (0) indicates that the value of threshold is not to be modified. @@ -5399,28 +5384,100 @@ public class H5 implements java.io.Serializable { * - Invalid values of max_list and min_btree. * **/ - public synchronized static native void H5Pset_file_space(long fcpl_id, int strategy, long threshold) + public synchronized static native void H5Pset_file_space_strategy(long fcpl_id, int strategy, boolean persist, long threshold) throws HDF5LibraryException, IllegalArgumentException; /** - * H5Pget_file_space provides the means for applications to manage the HDF5 file's file space for their specific needs. + * H5Pget_file_space_strategy provides the means for applications to manage the HDF5 file's file space strategy for their specific needs. * * @param fcpl_id * IN: File creation property list identifier - * @param strategy - * IN/OUT: The current file space management strategy in use for the file. NULL, strategy not queried. + * @param persist + * IN/OUT: The current free-space persistence. NULL, persist not queried. * @param threshold * IN/OUT: The current free-space section threshold. NULL, threshold not queried. * + * @return the current free-space strategy. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception IllegalArgumentException + * - Invalid values of max_list and min_btree. + * + **/ + public synchronized static native int H5Pget_file_space_strategy(long fcpl_id, boolean[] persist, long[] threshold) + throws HDF5LibraryException, IllegalArgumentException; + + /** + * H5Pget_file_space_strategy_persist provides the means for applications to manage the HDF5 file's file space strategy for their specific needs. + * + * @param fcpl_id + * IN: File creation property list identifier + * + * @return the current free-space persistence. + * * @exception HDF5LibraryException * - Error from the HDF-5 Library. * @exception IllegalArgumentException * - Invalid values of max_list and min_btree. * **/ - public synchronized static native void H5Pget_file_space(long fcpl_id, int[] strategy, long[] threshold) + public synchronized static native boolean H5Pget_file_space_strategy_persist(long fcpl_id) throws HDF5LibraryException, IllegalArgumentException; + /** + * H5Pget_file_space_strategy_threshold provides the means for applications to manage the HDF5 file's file space strategy for their specific needs. + * + * @param fcpl_id + * IN: File creation property list identifier + * + * @return the current free-space section threshold. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception IllegalArgumentException + * - Invalid values of max_list and min_btree. + * + **/ + public synchronized static native long H5Pget_file_space_strategy_threshold(long fcpl_id) + throws HDF5LibraryException, IllegalArgumentException; + + /** + * H5Pset_file_space_page_size retrieves the file space page size for aggregating small metadata or raw data. + * + * @param fcpl_id + * IN: File creation property list identifier + * @param page_size + * IN: the file space page size. + * + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception IllegalArgumentException + * - Invalid values of max_list and min_btree. + * + **/ + public synchronized static native void H5Pset_file_space_page_size(long fcpl_id, long page_size) + throws HDF5LibraryException, IllegalArgumentException; + + /** + * H5Pget_file_space_page_size Sets the file space page size for paged aggregation. + * + * @param fcpl_id + * IN: File creation property list identifier + * + * @return the current file space page size. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception IllegalArgumentException + * - Invalid values of max_list and min_btree. + * + **/ + public synchronized static native long H5Pget_file_space_page_size(long fcpl_id) + throws HDF5LibraryException, IllegalArgumentException; + + // File access property list (FAPL) routines /** diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index acd3eb5..9773100 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -219,12 +219,12 @@ public class HDF5Constants { public static final int H5F_SCOPE_GLOBAL = H5F_SCOPE_GLOBAL(); public static final int H5F_SCOPE_LOCAL = H5F_SCOPE_LOCAL(); public static final int H5F_UNLIMITED = H5F_UNLIMITED(); - public static final int H5F_FILE_SPACE_DEFAULT = H5F_FILE_SPACE_DEFAULT(); - public static final int H5F_FILE_SPACE_ALL_PERSIST = H5F_FILE_SPACE_ALL_PERSIST(); - public static final int H5F_FILE_SPACE_ALL = H5F_FILE_SPACE_ALL(); - public static final int H5F_FILE_SPACE_AGGR_VFD = H5F_FILE_SPACE_AGGR_VFD(); - public static final int H5F_FILE_SPACE_VFD = H5F_FILE_SPACE_VFD(); - public static final int H5F_FILE_SPACE_NTYPES = H5F_FILE_SPACE_NTYPES(); + + public static final int H5F_FSPACE_STRATEGY_FSM_AGGR = H5F_FSPACE_STRATEGY_FSM_AGGR(); + public static final int H5F_FSPACE_STRATEGY_AGGR = H5F_FSPACE_STRATEGY_AGGR(); + public static final int H5F_FSPACE_STRATEGY_PAGE = H5F_FSPACE_STRATEGY_PAGE(); + public static final int H5F_FSPACE_STRATEGY_NONE = H5F_FSPACE_STRATEGY_NONE(); + public static final int H5F_FSPACE_STRATEGY_NTYPES = H5F_FSPACE_STRATEGY_NTYPES(); public static final long H5FD_CORE = H5FD_CORE(); public static final long H5FD_DIRECT = H5FD_DIRECT(); @@ -1024,17 +1024,15 @@ public class HDF5Constants { private static native final int H5F_UNLIMITED(); - private static native final int H5F_FILE_SPACE_DEFAULT(); - - private static native final int H5F_FILE_SPACE_ALL_PERSIST(); + private static native final int H5F_FSPACE_STRATEGY_FSM_AGGR(); - private static native final int H5F_FILE_SPACE_ALL(); + private static native final int H5F_FSPACE_STRATEGY_AGGR(); - private static native final int H5F_FILE_SPACE_AGGR_VFD(); + private static native final int H5F_FSPACE_STRATEGY_PAGE(); - private static native final int H5F_FILE_SPACE_VFD(); + private static native final int H5F_FSPACE_STRATEGY_NONE(); - private static native final int H5F_FILE_SPACE_NTYPES(); + private static native final int H5F_FSPACE_STRATEGY_NTYPES(); private static native final long H5FD_CORE(); diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index ccd0b91..c6aa16c 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -403,17 +403,15 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1UNLIMITED(JNIEnv *env, jclass cls) { return (jint)H5F_UNLIMITED; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1FSM_1AGGR(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_FSM_AGGR; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1ALL_1PERSIST(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_ALL_PERSIST; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1AGGR(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_AGGR; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1ALL(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1PAGE(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_PAGE; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1AGGR_1VFD(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_AGGR_VFD; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NONE(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_NONE; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1VFD(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_VFD; } -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1NTYPES(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NTYPES(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_NTYPES; } JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1CORE(JNIEnv *env, jclass cls) { return H5FD_CORE; } diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index 1368139..f39f0e6 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -4883,61 +4883,130 @@ Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space - * Signature: (J[I[J)V + * Method: H5Pget_file_space_strategy + * Signature: (J[Z[J)I */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space - (JNIEnv *env, jclass clss, jlong fcpl_id, jintArray strategy, jlongArray threshold) +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy + (JNIEnv *env, jclass clss, jlong fcpl_id, jbooleanArray persist, jlongArray threshold) { herr_t status = -1; - jint *thestrategyArray = NULL; + H5F_fspace_strategy_t thestrategy = H5F_FSPACE_STRATEGY_FSM_AGGR; /* Library default */ jlong *thethresholdArray = NULL; + jboolean *thepersistArray = NULL; jboolean isCopy; - if (strategy) { - thestrategyArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR strategy, &isCopy); - if (thestrategyArray == NULL) { - h5JNIFatalError(env, "H5Pget_file_space: strategy not pinned"); - return; + if (persist) { + thepersistArray = (jboolean*)ENVPTR->GetBooleanArrayElements(ENVPAR persist, &isCopy); + if (thepersistArray == NULL) { + h5JNIFatalError(env, "H5Pget_file_space: persist not pinned"); + return -1; } } if (threshold) { thethresholdArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR threshold, &isCopy); if (thethresholdArray == NULL) { - if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, JNI_ABORT); + if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, JNI_ABORT); h5JNIFatalError(env, "H5Pget_file_space: threshold not pinned"); - return; + return -1; } /* end if */ } /* end if */ - status = H5Pget_file_space((hid_t)fcpl_id, (H5F_file_space_type_t*)thestrategyArray, (hsize_t*)thethresholdArray); + status = H5Pget_file_space_strategy((hid_t)fcpl_id, &thestrategy, (hbool_t*)thepersistArray, (hsize_t*)thethresholdArray); if (status < 0) { - if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, JNI_ABORT); + if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, JNI_ABORT); if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, JNI_ABORT); h5libraryError(env); } /* end if */ else { - if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, 0); + if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, 0); if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, 0); } /* end else */ -} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space */ + return (jint)thestrategy; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_persist + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + herr_t status = -1; + hbool_t thepersist = FALSE; + + status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, &thepersist, NULL); + + if (status < 0) + h5libraryError(env); + + return (jboolean)thepersist; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_threshold + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + herr_t status = -1; + hsize_t thethreshold; + + status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, NULL, &thethreshold); + + if (status < 0) + h5libraryError(env); + + return (jlong)thethreshold; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1threshold */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space - * Signature: (JIJ)V + * Method: H5Pset_file_space_strategy + * Signature: (JIZJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space - (JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jlong threshold) +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy + (JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jboolean persist, jlong threshold) { - if (H5Pset_file_space((hid_t)fcpl_id, (H5F_file_space_type_t)strategy, (hsize_t)threshold) < 0) + if (H5Pset_file_space_strategy((hid_t)fcpl_id, (H5F_fspace_strategy_t)strategy, (hbool_t)persist, (hsize_t)threshold) < 0) h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1file_1space */ +} /* end Java_hdf_hdf5lib_H5_H5Pset_file_space_strategy */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_page_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size + (JNIEnv *env, jclass clss, jlong fcpl_id, jlong fsp_size) +{ + if (H5Pset_file_space_page_size((hid_t)fcpl_id, (hsize_t)fsp_size) < 0) + h5libraryError(env); +} + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_page_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + hsize_t fsp_size = 0; + if (H5Pget_file_space_page_size((hid_t)fcpl_id, &fsp_size) < 0) + h5libraryError(env); + return (jlong)fsp_size; +} static herr_t H5P_cls_create_cb diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h index 927501e..03b0e03 100644 --- a/java/src/jni/h5pImp.h +++ b/java/src/jni/h5pImp.h @@ -1385,22 +1385,57 @@ Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space - * Signature: (J[I[J)V + * Method: H5Pget_file_space_strategy + * Signature: (J[Z[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy +(JNIEnv *, jclass, jlong, jbooleanArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_persist + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_threshold + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_strategy + * Signature: (JIZJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space -(JNIEnv *, jclass, jlong, jintArray, jlongArray); +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy +(JNIEnv *, jclass, jlong, jint, jboolean, jlong); +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_page_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size +(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space - * Signature: (JIJ)V + * Method: H5Pset_file_space_page_size + * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space -(JNIEnv *, jclass, jlong, jint, jlong); +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size +(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 diff --git a/java/test/JUnit-interface.txt b/java/test/JUnit-interface.txt index 34ec02a..cae8cef 100644 --- a/java/test/JUnit-interface.txt +++ b/java/test/JUnit-interface.txt @@ -416,6 +416,7 @@ JUnit version 4.11 .testH5P_layout .testH5Pget_link_creation_order .testH5Pset_shared_mesg_nindexes_InvalidHIGHnindexes +.testH5P_file_space_page_size .testH5Pget_shared_mesg_index_Invalid_indexnum .testH5Pset_data_transform_NullExpression .testH5Pset_elink_prefix_null @@ -438,9 +439,9 @@ JUnit version 4.11 .testH5Pset_shared_mesg_index .testH5Pset_copy_object .testH5Pset_link_creation_order_trackedPLUSindexed +.testH5P_file_space_strategy .testH5Pset_copy_object_invalidobject .testH5Pset_est_link_info_InvalidValues -.testH5P_file_space .testH5Pset_local_heap_size_hint .testH5Pget_est_link_info .testH5Pset_scaleoffset @@ -638,7 +639,7 @@ JUnit version 4.11 Time: XXXX -OK (636 tests) +OK (637 tests) HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Fopen(): can't set access and transfer property lists diff --git a/java/test/TestH5P.java b/java/test/TestH5P.java index b8a4376..fa8b525 100644 --- a/java/test/TestH5P.java +++ b/java/test/TestH5P.java @@ -1198,25 +1198,40 @@ public class TestH5P { } @Test - public void testH5P_file_space() { + public void testH5P_file_space_strategy() { long[] threshold = {0}; - int[] strategy = {0}; + boolean[] persist = {false}; + int strategy = 0; try { - H5.H5Pget_file_space(fcpl_id, strategy, threshold); - assertTrue("strategy: "+strategy[0], strategy[0] == HDF5Constants.H5F_FILE_SPACE_ALL); + strategy = H5.H5Pget_file_space_strategy(fcpl_id, persist, threshold); + assertTrue("strategy(default): "+strategy, strategy == HDF5Constants.H5F_FSPACE_STRATEGY_FSM_AGGR); + assertTrue("persist(default): "+persist[0], persist[0] == false); + assertTrue("theshold(default): "+threshold[0], threshold[0] == 1); + H5.H5Pset_file_space_strategy(fcpl_id, HDF5Constants.H5F_FSPACE_STRATEGY_PAGE, true, 1); + strategy = H5.H5Pget_file_space_strategy(fcpl_id, persist, threshold); + assertTrue("strategy: "+strategy, strategy == HDF5Constants.H5F_FSPACE_STRATEGY_PAGE); + assertTrue("persist: "+persist[0], persist[0] == true); assertTrue("theshold: "+threshold[0], threshold[0] == 1); - H5.H5Pset_file_space(fcpl_id, HDF5Constants.H5F_FILE_SPACE_ALL_PERSIST, 10); - H5.H5Pget_file_space(fcpl_id, strategy, threshold); - assertTrue("strategy: "+strategy[0], strategy[0] == HDF5Constants.H5F_FILE_SPACE_ALL_PERSIST); - assertTrue("theshold: "+threshold[0], threshold[0] == 10); - H5.H5Pset_file_space(fcpl_id, HDF5Constants.H5F_FILE_SPACE_VFD, 0); - H5.H5Pget_file_space(fcpl_id, strategy, threshold); - assertTrue("strategy: "+strategy[0], strategy[0] == HDF5Constants.H5F_FILE_SPACE_VFD); - assertTrue("theshold: "+threshold[0], threshold[0] == 10); } catch (Throwable err) { err.printStackTrace(); - fail("testH5P_file_space: " + err); + fail("testH5P_file_space_strategy: " + err); + } + } + + @Test + public void testH5P_file_space_page_size() { + long page_size = 0; + try { + page_size = H5.H5Pget_file_space_page_size(fcpl_id); + assertTrue("page_size(default): "+page_size, page_size == 4096); + H5.H5Pset_file_space_page_size(fcpl_id, 512); + page_size = H5.H5Pget_file_space_page_size(fcpl_id); + assertTrue("page_size: "+page_size, page_size == 512); + } + catch (Throwable err) { + err.printStackTrace(); + fail("testH5P_file_space_page_size: " + err); } } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef361b2..9321bbd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,6 +195,7 @@ set (H5F_SOURCES ${HDF5_SRC_DIR}/H5Fmpi.c ${HDF5_SRC_DIR}/H5Fquery.c ${HDF5_SRC_DIR}/H5Fsfile.c + ${HDF5_SRC_DIR}/H5Fspace.c ${HDF5_SRC_DIR}/H5Fsuper.c ${HDF5_SRC_DIR}/H5Fsuper_cache.c ${HDF5_SRC_DIR}/H5Ftest.c @@ -504,6 +505,15 @@ set (H5P_HDRS ) IDE_GENERATED_PROPERTIES ("H5P" "${H5P_HDRS}" "${H5P_SOURCES}" ) +set (H5PB_SOURCES + ${HDF5_SRC_DIR}/H5PB.c +) + +set (H5PB_HDRS + ${HDF5_SRC_DIR}/H5PBpkg.h +) +IDE_GENERATED_PROPERTIES ("H5PB" "${H5PB_HDRS}" "${H5PB_SOURCES}" ) + set (H5PL_SOURCES ${HDF5_SRC_DIR}/H5PL.c ) @@ -699,6 +709,7 @@ set (common_SRCS ${H5MP_SOURCES} ${H5O_SOURCES} ${H5P_SOURCES} + ${H5PB_SOURCES} ${H5PL_SOURCES} ${H5R_SOURCES} ${H5UC_SOURCES} @@ -739,6 +750,7 @@ set (H5_PUBLIC_HEADERS ${H5MP_HDRS} ${H5O_HDRS} ${H5P_HDRS} + ${H5PB_HDRS} ${H5PL_HDRS} ${H5R_HDRS} ${H5S_HDRS} @@ -777,6 +789,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5MPprivate.h ${HDF5_SRC_DIR}/H5Oprivate.h ${HDF5_SRC_DIR}/H5Pprivate.h + ${HDF5_SRC_DIR}/H5PBprivate.h ${HDF5_SRC_DIR}/H5PLprivate.h ${HDF5_SRC_DIR}/H5UCprivate.h ${HDF5_SRC_DIR}/H5Rprivate.h diff --git a/src/H5AC.c b/src/H5AC.c index 2fb7992..a561852 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -353,6 +353,44 @@ H5AC_term_package(void) /*------------------------------------------------------------------------- + * + * Function: H5AC_cache_image_pending() + * + * Purpose: Debugging function that tests to see if the load of a + * metadata cache image load is pending (i.e. will be executed + * on the next protect or insert) + * + * Returns TRUE if a cache image load is pending, and FALSE + * if not. Throws an assertion failure on error. + * + * Return: TRUE if a cache image load is pending, and FALSE otherwise. + * + * Programmer: John Mainzer, 1/10/17 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +hbool_t +H5AC_cache_image_pending(const H5F_t *f) +{ + H5C_t *cache_ptr; + hbool_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + + ret_value = H5C_cache_image_pending(cache_ptr); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_cache_image_pending() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_create * * Purpose: Initialize the cache just after a file is opened. The @@ -835,6 +873,46 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_force_cache_image_load() + * + * Purpose: On rare occasions, it is necessary to run + * H5MF_tidy_self_referential_fsm_hack() prior to the first + * metadata cache access. This is a problem as if there is a + * cache image at the end of the file, that routine will + * discard it. + * + * We solve this issue by calling this function, which will + * load the cache image and then call + * H5MF_tidy_self_referential_fsm_hack() to discard it. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 1/11/17 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_force_cache_image_load(H5F_t *f, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + + if(H5C_force_cache_image_load(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't load cache image") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_force_cache_image_load() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_get_entry_status * * Purpose: Given a file address, determine whether the metadata @@ -3119,6 +3197,48 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_unsettle_ring() + * + * Purpose: Advise the metadata cache that the specified free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. + * + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. + * + * Note that this function simply passes the call on to + * the metadata cache proper, and returns the result. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 10/15/16 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_unsettle_ring(H5F_t * f, H5C_ring_t ring) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(FAIL == (ret_value = H5C_unsettle_ring(f, ring))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_unsettle_ring() failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_unsettle_ring() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_remove_entry() * * Purpose: Remove an entry from the cache. Must be not protected, pinned, diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 1dc8270..1f8299b 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -451,6 +451,8 @@ H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr); H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); +H5_DLL hbool_t H5AC_cache_image_pending(const H5F_t *f); +H5_DLL herr_t H5AC_force_cache_image_load(H5F_t * f, hid_t dxpl_id); /* Tag & Ring routines */ H5_DLL herr_t H5AC_tag(hid_t dxpl_id, haddr_t metadata_tag, haddr_t *prev_tag); @@ -464,6 +466,7 @@ H5_DLL herr_t H5AC_set_ring(hid_t dxpl_id, H5AC_ring_t ring, H5P_genplist_t **dx H5AC_ring_t *orig_ring); H5_DLL herr_t H5AC_reset_ring(H5P_genplist_t *dxpl, H5AC_ring_t orig_ring); H5_DLL herr_t H5AC_unsettle_entry_ring(void *entry); +H5_DLL herr_t H5AC_unsettle_ring(H5F_t * f, H5AC_ring_t ring); H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5AC_get_tag(const void *thing, /*OUT*/ haddr_t *tag); diff --git a/src/H5C.c b/src/H5C.c index 1759292..120abb8 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -732,7 +732,8 @@ herr_t H5C_prep_for_file_close(H5F_t *f, hid_t dxpl_id) { H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t image_generated = FALSE; /* Whether a cache image was generated */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -756,9 +757,48 @@ H5C_prep_for_file_close(H5F_t *f, hid_t dxpl_id) HDassert(cache_ptr->pl_len == 0); /* Prepare cache image */ - if(H5C__prep_image_for_file_close(f, dxpl_id) < 0) + if(H5C__prep_image_for_file_close(f, dxpl_id, &image_generated) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cache image") +#ifdef H5_HAVE_PARALLEL + if(!image_generated && cache_ptr->aux_ptr != NULL && f->shared->fs_persist) { + /* If persistent free space managers are enabled, flushing the + * metadata cache may result in the deletion, insertion, and/or + * dirtying of entries. + * + * This is a problem in PHDF5, as it breaks two invariants of + * our management of the metadata cache across all processes: + * + * 1) Entries will not be dirtied, deleted, inserted, or moved + * during flush in the parallel case. + * + * 2) All processes contain the same set of dirty metadata + * entries on entry to a sync point. + * + * To solve this problem for the persistent free space managers, + * serialize the metadata cache on all processes prior to the + * first sync point on file shutdown. The shutdown warning is + * a convenient location for this call. + * + * This is sufficient since: + * + * 1) FSM settle routines are only invoked on file close. Since + * serialization make the same settle calls as flush on file + * close, and since the close warning is issued after all + * non FSM related space allocations and just before the + * first sync point on close, this call will leave the caches + * in a consistant state across the processes if they were + * consistant before. + * + * 2) Since the FSM settle routines are only invoked once during + * file close, invoking them now will prevent their invocation + * during a flush, and thus avoid any resulting entrie dirties, + * deletions, insertion, or moves during the flush. + */ + if(H5C__serialize_cache(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialization of the cache failed") + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -3537,6 +3577,73 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_unsettle_ring() + * + * Purpose: Advise the metadata cache that the specified free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. + * + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 10/15/16 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) +{ + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert((H5C_RING_RDFSM == ring) || (H5C_RING_MDFSM == ring)); + cache_ptr = f->shared->cache; + HDassert(H5C__H5C_T_MAGIC == cache_ptr->magic); + + switch(ring) { + case H5C_RING_RDFSM: + if(cache_ptr->rdfsm_settled) { + if(cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache_ptr->rdfsm_settled = FALSE; + } /* end if */ + break; + + case H5C_RING_MDFSM: + if(cache_ptr->mdfsm_settled) { + if(cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache_ptr->mdfsm_settled = FALSE; + } /* end if */ + break; + + default: + HDassert(FALSE); /* this should be un-reachable */ + break; + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_unsettle_ring() */ + + +/*------------------------------------------------------------------------- * Function: H5C_validate_resize_config() * * Purpose: Run a sanity check on the specified sections of the @@ -6007,6 +6114,7 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, hbool_t write_entry; /* internal flag */ hbool_t destroy_entry; /* internal flag */ hbool_t generate_image; /* internal flag */ + hbool_t update_page_buffer; /* internal flag */ hbool_t was_dirty; hbool_t suppress_image_entry_writes = FALSE; hbool_t suppress_image_entry_frees = FALSE; @@ -6032,6 +6140,7 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); + update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); /* Set the flag for destroying the entry, based on the 'take ownership' * and 'destroy' flags @@ -6447,6 +6556,19 @@ H5C__flush_single_entry(H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, } /* end else */ } /* if (destroy) */ + /* Check if we have to update the page buffer with cleared entries + * so it doesn't go out of date + */ + if(update_page_buffer) { + /* Sanity check */ + HDassert(!destroy); + HDassert(entry_ptr->image_ptr); + + if(f->shared->page_buf && f->shared->page_buf->page_size >= entry_ptr->size) + if(H5PB_update_entry(f->shared->page_buf, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) > 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Failed to update PB with metadata cache") + } /* end if */ + if(cache_ptr->log_flush) if((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 3a21137..fc58dac 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -147,6 +147,40 @@ H5FL_DEFINE(H5C_cache_entry_t); /*------------------------------------------------------------------------- + * + * Function: H5C_cache_image_pending() + * + * Purpose: Tests to see if the load of a metadata cache image + * load is pending (i.e. will be executed on the next + * protect or insert) + * + * Returns TRUE if a cache image load is pending, and FALSE + * if not. Throws an assertion failure on error. + * + * Return: TRUE if a cache image load is pending, and FALSE otherwise. + * + * Programmer: John Mainzer, 6/18/16 + * + *------------------------------------------------------------------------- + */ +hbool_t +H5C_cache_image_pending(const H5C_t *cache_ptr) +{ + hbool_t ret_value = TRUE; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity checks */ + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + ret_value = (cache_ptr->load_image && !cache_ptr->image_loaded); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_cache_image_pending() */ + + +/*------------------------------------------------------------------------- * Function: H5C_cache_image_status() * * Purpose: Examine the metadata cache associated with the supplied @@ -832,6 +866,54 @@ H5C__free_image_entries_array(H5C_t * cache_ptr) /*------------------------------------------------------------------------- + * Function: H5C_force_cache_image_load() + * + * Purpose: On rare occasions, it is necessary to run + * H5MF_tidy_self_referential_fsm_hack() prior to the first + * metadata cache access. This is a problem as if there is a + * cache image at the end of the file, that routine will + * discard it. + * + * We solve this issue by calling this function, which will + * load the cache image and then call + * H5MF_tidy_self_referential_fsm_hack() to discard it. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 1/11/17 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_force_cache_image_load(H5F_t *f, hid_t dxpl_id) +{ + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->load_image); + + /* Load the cache image, if requested */ + if(cache_ptr->load_image) { + cache_ptr->load_image = FALSE; + if(H5C__load_cache_image(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_force_cache_image_load() */ + + +/*------------------------------------------------------------------------- * Function: H5C_get_cache_image_config * * Purpose: Copy the current configuration for cache image generation @@ -1239,7 +1321,7 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2) *------------------------------------------------------------------------- */ herr_t -H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) +H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id, hbool_t *image_generated) { H5C_t * cache_ptr = NULL; haddr_t eoa_frag_addr = HADDR_UNDEF; @@ -1255,6 +1337,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) cache_ptr = f->shared->cache; HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(image_generated); /* If the file is opened and closed without any access to * any group or data set, it is possible that the cache image (if @@ -1379,6 +1462,15 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) (hsize_t)(cache_ptr->image_data_len), &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") + /* Make note of the eoa after allocation of the cache image + * block. This value is used for sanity checking when we + * shutdown the self referential free space managers after + * we destroy the metadata cache. + */ + HDassert(HADDR_UNDEF == f->shared->eoa_post_mdci_fsalloc); + if(HADDR_UNDEF == (f->shared->eoa_post_mdci_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + /* For now, drop any fragment left over from the allocation of the * image block on the ground. A fragment should only be returned * if the underlying file alignment is greater than 1. @@ -1468,6 +1560,9 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id) cache_ptr->image_ctl.generate_image = FALSE; } /* end else */ + + /* Indicate that a cache image was generated */ + *image_generated = TRUE; } /* end if */ done: diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 1f43866..06ce714 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -791,7 +791,7 @@ H5C_mark_entries_as_clean(H5F_t * f, entries_cleared++; if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG)) < 0) + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else @@ -821,7 +821,7 @@ H5C_mark_entries_as_clean(H5F_t * f, progress = TRUE; if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG)) < 0) + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else @@ -1242,7 +1242,8 @@ H5C__flush_candidates_in_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned init_index_len; #endif /* H5C_DO_SANITY_CHECKS */ unsigned clear_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__GENERATE_IMAGE_FLAG; + H5C__GENERATE_IMAGE_FLAG | + H5C__UPDATE_PAGE_BUFFER_FLAG; unsigned flush_flags = H5C__NO_FLAGS_SET; unsigned op_flags; H5C_cache_entry_t *op_ptr; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 321f1fb..69e8145 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4901,7 +4901,8 @@ typedef int (*H5C_tag_iter_cb_t)(H5C_cache_entry_t *entry, void *ctx); /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id); +H5_DLL herr_t H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id, + hbool_t *image_generated); H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, hid_t dxpl_id, H5C_t * cache_ptr, H5C_cache_entry_t** entry_ptr_ptr, const H5C_class_t * type, haddr_t addr, void * udata); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 3408839..539dece 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -185,6 +185,7 @@ * H5C__TAKE_OWNERSHIP_FLAG * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG * H5C__GENERATE_IMAGE_FLAG + * H5C__UPDATE_PAGE_BUFFER_FLAG */ #define H5C__NO_FLAGS_SET 0x00000 #define H5C__SET_FLUSH_MARKER_FLAG 0x00001 @@ -205,6 +206,7 @@ #define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 #define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ #define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ +#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ /* Debugging/sanity checking/statistics settings */ #ifndef NDEBUG @@ -2249,6 +2251,7 @@ H5_DLL herr_t H5C_expunge_entry(H5F_t *f, hid_t dxpl_id, const H5C_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5C_flush_cache(H5F_t *f, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag); +H5_DLL herr_t H5C_force_cache_image_load(H5F_t * f, hid_t dxpl_id); H5_DLL herr_t H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_global); H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5C_get_tag(const void *thing, /*OUT*/ haddr_t *tag); @@ -2313,9 +2316,11 @@ H5_DLL herr_t H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest H5_DLL herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked); H5_DLL herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring); H5_DLL herr_t H5C_unsettle_entry_ring(void *thing); +H5_DLL herr_t H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring); H5_DLL herr_t H5C_remove_entry(void *thing); H5_DLL herr_t H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr); +H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, hid_t dxpl_id, diff --git a/src/H5F.c b/src/H5F.c index 431b56f..a0f7599 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1975,7 +1975,9 @@ H5Fformat_convert(hid_t fid) /* Check for persistent freespace manager, which needs to be downgraded */ if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF)) { + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { /* Check to remove free-space manager info message from superblock extension */ if(H5F_addr_defined(f->shared->sblock->ext_addr)) if(H5F_super_ext_remove_msg(f, H5AC_ind_read_dxpl_id, H5O_FSINFO_ID) < 0) @@ -1987,7 +1989,9 @@ H5Fformat_convert(hid_t fid) /* Set non-persistent freespace manager */ f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; + f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; /* Indicate that the superblock should be marked dirty */ mark_dirty = TRUE; @@ -2006,3 +2010,79 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fformat_convert() */ + +/*------------------------------------------------------------------------- + * Function: H5Freset_page_buffering_stats + * + * Purpose: Resets statistics for the page buffer layer. + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5Freset_page_buffering_stats(hid_t file_id) +{ + H5F_t *file; /* File to reset stats on */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", file_id); + + /* Check args */ + if(NULL == (file = (H5F_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + if(NULL == file->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if(H5PB_reset_stats(file->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Freset_page_buffering_stats() */ + + +/*------------------------------------------------------------------------- + * Function: H5Fget_page_buffering_stats + * + * Purpose: Retrieves statistics for the page buffer layer. + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +{ + H5F_t *file; /* File object for file ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions, + bypasses); + + /* Check args */ + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + if(NULL == file->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") + if(NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") + + /* Get the statistics */ + if(H5PB_get_stats(file->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fget_page_buffering_stats() */ + diff --git a/src/H5FD.c b/src/H5FD.c index db8c09c..96d1230 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2054,3 +2054,27 @@ H5FD_get_base_addr(const H5FD_t *file) FUNC_LEAVE_NOAPI(file->base_addr) } /* end H5FD_get_base_addr() */ + +/*-------------------------------------------------------------------------- + * Function: H5FD_set_paged_aggr + * + * Purpose: Set "paged_aggr" for the file. + * + * Return: Non-negative if succeed; negative if fails. + * + * Programmer: Vailin Choi; April 2013 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(file); + + /* Indicate whether paged aggregation for handling file space is enabled or not */ + file->paged_aggr = paged; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_set_paged_aggr() */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 03228d2..f320946 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -934,13 +934,7 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi /* Compute the address for the block to allocate */ addr = file->eoa; - /* Check if we need to align this block */ - if(size >= file->pub.threshold) { - /* Check for an already aligned block */ - if(addr % file->pub.alignment != 0) - addr = ((addr / file->pub.alignment) + 1) * file->pub.alignment; - } /* end if */ - + /* Extend the end-of-allocated space address */ file->eoa = addr + size; /* Retain the (first) flavor of the information written to the file */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 7e12869..0ab7fc5 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -1194,6 +1194,8 @@ H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) *flags = 0; *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_USE_ALLOC_SIZE; /* OK just pass the allocation size to the alloc callback */ + *flags |= H5FD_FEAT_PAGED_AGGR; /* OK special file space mapping for paged aggregation */ } /* end if */ return(0); @@ -1538,6 +1540,14 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; + /* XXX: NEED to work on this again */ + if(file->pub.paged_aggr) { + ALL_MEMBERS(mt) { + if(file->memb[mt]) + file->memb[mt]->paged_aggr = file->pub.paged_aggr; + } END_MEMBERS; + } + if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF) addr += file->fa.memb_addr[mmt]; diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 0e2928d..c64ec30 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -154,8 +154,8 @@ H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, - hsize_t size, haddr_t *align_addr, hsize_t *align_size); +H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, + struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, haddr_t addr, hsize_t size); H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, @@ -179,6 +179,7 @@ H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); +H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); /* Function prototypes for MPI based VFDs*/ #ifdef H5_HAVE_PARALLEL diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 436be10..883b28d 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -239,6 +239,19 @@ typedef enum H5F_mem_t H5FD_mem_t; * driver supports the single-writer/multiple-readers I/O pattern. */ #define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000 + /* + * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver + * means that the library will just pass the allocation size to the + * the driver's allocation callback which will eventually handle alignment. + * This is specifically used for the multi/split driver. + */ +#define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000 + /* + * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver + * means that the driver needs special file space mapping for paged aggregation. + * This is specifically used for the multi/split driver. + */ +#define H5FD_FEAT_PAGED_AGGR 0x00004000 /* Forward declaration */ typedef struct H5FD_t H5FD_t; @@ -307,6 +320,7 @@ struct H5FD_t { /* Space allocation management fields */ hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Allocation alignment */ + hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ }; /* Define enum for the source of file image callbacks */ diff --git a/src/H5FDspace.c b/src/H5FDspace.c index fcddecf..0ad3cf0 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -99,7 +99,7 @@ H5FL_DEFINE(H5FD_free_t); *------------------------------------------------------------------------- */ static haddr_t -H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) +H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) { hsize_t orig_size = size; /* Original allocation size */ haddr_t eoa; /* Address of end-of-allocated space */ @@ -117,40 +117,18 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd /* Get current end-of-allocated space address */ eoa = file->cls->get_eoa(file, type); - /* Compute extra space to allocate, if this is a new block and should be aligned */ - extra = 0; - if(new_block && file->alignment > 1 && orig_size >= file->threshold) { - hsize_t mis_align; /* Amount EOA is misaligned */ - - /* Check for EOA already aligned */ - if((mis_align = (eoa % file->alignment)) > 0) { - extra = file->alignment - mis_align; - if(frag_addr) - *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ - if(frag_size) - *frag_size = extra; - } /* end if */ - } /* end if */ - - /* Add in extra allocation amount */ - size += extra; - /* Check for overflow when extending */ if(H5F_addr_overflow(eoa, size) || (eoa + size) > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") - /* Set the [possibly aligned] address to return */ - ret_value = eoa + extra; + /* Set the [NOT aligned] address to return */ + ret_value = eoa; /* Extend the end-of-allocated space address */ eoa += size; if(file->cls->set_eoa(file, type, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") - /* Post-condition sanity check */ - if(new_block && file->alignment && orig_size >= file->threshold) - HDassert(!(ret_value % file->alignment)); - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_extend() */ @@ -160,6 +138,8 @@ done: * Function: H5FD_alloc_real * * Purpose: Allocate space in the file with the VFD + * Note: the handling of alignment is moved up from each driver to + * this routine. * * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF @@ -170,8 +150,14 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) +H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, + haddr_t *frag_addr, hsize_t *frag_size) { + hsize_t orig_size = size; /* Original allocation size */ + haddr_t eoa; /* Address of end-of-allocated space */ + hsize_t extra; /* Extra space to allocate, to align request */ + unsigned long flags = 0; /* Driver feature flags */ + hbool_t use_alloc_size; /* Just pass alloc size to the driver */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -185,16 +171,53 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(size > 0); + /* Check for query driver and call it */ + if(file->cls->query) + (file->cls->query)(file, &flags); + + /* Check for the driver feature flag */ + use_alloc_size = flags & H5FD_FEAT_USE_ALLOC_SIZE; + + /* Get current end-of-allocated space address */ + eoa = file->cls->get_eoa(file, type); + + /* Compute extra space to allocate, if this should be aligned */ + extra = 0; + if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) { + hsize_t mis_align; /* Amount EOA is misaligned */ + + /* Check for EOA already aligned */ + if((mis_align = (eoa % file->alignment)) > 0) { + extra = file->alignment - mis_align; + if(frag_addr) + *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ + if(frag_size) + *frag_size = extra; + } /* end if */ + } /* end if */ + /* Dispatch to driver `alloc' callback or extend the end-of-address marker */ + /* For the multi/split driver: the size passed down to the alloc callback is the original size from H5FD_alloc() */ + /* For all other drivers: the size passed down to the alloc callback is the size + [possibly] alignment size */ if(file->cls->alloc) { - if((ret_value = (file->cls->alloc)(file, type, dxpl_id, size)) == HADDR_UNDEF) + ret_value = (file->cls->alloc)(file, type, dxpl_id, use_alloc_size ? size : size + extra); + if(!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed") } /* end if */ else { - if((ret_value = H5FD_extend(file, type, TRUE, size, frag_addr, frag_size)) == HADDR_UNDEF) + ret_value = H5FD_extend(file, type, size + extra); + if(!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") } /* end else */ + /* Set the [possibly aligned] address to return */ + if(!use_alloc_size) + ret_value += extra; + + /* Post-condition sanity check */ + if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) + HDassert(!(ret_value % file->alignment)); + /* Convert absolute file offset to relative address */ ret_value -= file->base_addr; @@ -420,7 +443,7 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hid_t dxpl_id, /* Check if the block is exactly at the end of the file */ if(H5F_addr_eq(blk_end, eoa)) { /* Extend the object by extending the underlying file */ - if(HADDR_UNDEF == H5FD_extend(file, type, FALSE, extra_requested, NULL, NULL)) + if(HADDR_UNDEF == H5FD_extend(file, type, extra_requested)) HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed") /* Mark EOA info dirty in cache, so change will get encoded */ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 4c62bcc..13f728e 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -601,13 +601,6 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp /* Compute the address for the block to allocate */ addr = file->eoa; - /* Check if we need to align this block */ - if(size >= file->pub.threshold) { - /* Check for an already aligned block */ - if((addr % file->pub.alignment) != 0) - addr = ((addr / file->pub.alignment) + 1) * file->pub.alignment; - } /* end if */ - file->eoa = addr + size; return addr; diff --git a/src/H5FS.c b/src/H5FS.c index 8644a6f..a433fbb 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -135,7 +135,7 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl fspace->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; fspace->alignment = alignment; - fspace->threshold = threshold; + fspace->align_thres = threshold; /* Check if the free space tracker is supposed to be persistant */ if(fs_addr) { @@ -227,7 +227,7 @@ HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") fspace->alignment = alignment; - fspace->threshold = threshold; + fspace->align_thres = threshold; /* Unlock free space header */ if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) @@ -873,10 +873,7 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) HDassert(fspace); if(!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) { - /* Allocate space for section info from aggregator/vfd (or temp. address space) */ - /* (The original version called H5MF_alloc(), but that may cause sect_size to change again) */ - /* (This routine is only called during file close operations, so don't allocate from temp. address space) */ - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_aggr_vfd_alloc(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_size))) + if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info") fspace->alloc_sect_size = fspace->sect_size; @@ -901,169 +898,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5FS_alloc_vfd_alloc_hdr_and_section_info - * - * Purpose: This function is part of a hack to patch over a design - * flaw in the free space managers for file space allocation. - * Specifically, if a free space manager allocates space for - * its own section info, it is possible for it to - * go into an infinite loop as it: - * - * 1) computes the size of the section info - * - * 2) allocates file space for the section info - * - * 3) notices that the size of the section info - * has changed - * - * 4) deallocates the section info file space and - * returns to 1) above. - * - * Similarly, if it allocates space for its own header, it - * can go into an infinte loop as it: - * - * 1) allocates space for the header - * - * 2) notices that the free space manager is empty - * and thus should not have file space allocated - * to its header - * - * 3) frees the space allocated to the header - * - * 4) notices that the free space manager is not - * empty and thus must have file space allocated - * to it, and thus returns to 1) above. - * - * In a nutshell, the solution applied in this hack is to - * deallocate file space for the free space manager(s) that - * handle FSM header and/or section info file space allocations, - * wait until all other allocation/deallocation requests have - * been handled, and then test to see if the free space manager(s) - * in question are empty. If they are, do nothing. If they - * are not, allocate space for them at end of file bypassing the - * usual file space allocation calls, and thus avoiding the - * potential infinite loops. - * - * The purpose of this function is to allocate file space for - * the header and section info of the target free space manager - * directly from the VFD if needed. In this case the function - * also re-inserts the header and section info in the metadata - * cache with this allocation. - * - * Note that if f->shared->alignment > 1, and EOA is not a - * multiple of the alignment, it is possible that performing - * this allocation may generate a fragment of file space in - * addition to the space allocated for the section info. - * - * At present we deal with this by screaming and dying. - * Obviously, this is not acceptatable, but it should do - * for now. - * - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: John Mainzer - * 6/6/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5FS_alloc_vfd_alloc_hdr_and_section_info(H5F_t *f, hid_t dxpl_id, - H5FS_t *fspace, haddr_t *fs_addr_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) - - /* Check arguments */ - HDassert(f); - HDassert(fspace); - HDassert(fs_addr_ptr); - - /* The section info should be unlocked */ - HDassert(fspace->sinfo_lock_count == 0); - - /* No space should be allocated */ - HDassert(*fs_addr_ptr == HADDR_UNDEF); - HDassert(fspace->addr == HADDR_UNDEF); - HDassert(fspace->sect_addr == HADDR_UNDEF); - HDassert(fspace->alloc_sect_size == 0); - - /* Check if any space will be needed */ - if(fspace->serial_sect_count > 0) { - haddr_t sect_addr; /* Address of sinfo */ - - /* The section info is floating, so fspace->sinfo should be defined */ - HDassert(fspace->sinfo); - - /* Start by allocating file space for the header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_vfd_alloc(f, dxpl_id, H5FD_MEM_FSPACE_HDR, - (hsize_t)H5FS_HEADER_SIZE(f), FALSE))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space for hdr") - - /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add free space header to cache") - - - /* Now allocate file space for the section info */ - if(HADDR_UNDEF == (sect_addr = H5MF_vfd_alloc(f, dxpl_id, H5FD_MEM_FSPACE_SINFO, - fspace->sect_size, FALSE))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space") - - /* Update fspace->alloc_sect_size and fspace->sect_addr to reflect - * the allocation - */ - fspace->alloc_sect_size = fspace->sect_size; - fspace->sect_addr = sect_addr; - - /* We have changed the sinfo address -- Mark free space header dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") - - /* Insert the new section info into the metadata cache. */ - - /* Question: Do we need to worry about this insertion causing an - * eviction from the metadata cache? Think on this. If so, add a - * flag to H5AC_insert() to force it to skip the call to make space in - * cache. - * - * On reflection, no. - * - * On a regular file close, any eviction will not change the - * the contents of the free space manger(s), as all entries - * should have correct file space allocated by the time this - * function is called. - * - * In the cache image case, the selection of entries for inclusion - * in the cache image will not take place until after this call. - * (Recall that this call is made during the metadata fsm settle - * routine, which is called during the serialization routine in - * the cache image case. Entries are not selected for inclusion - * in the image until after the cache is serialized.) - * - * JRM -- 11/4/16 - */ - if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add free space sinfo to cache") - - /* Since space has been allocated for the section info and the sinfo - * has been inserted into the cache, relinquish owership (i.e. float) - * the section info. - */ - fspace->sinfo = NULL; - - /* Set the address of the free space header, on success */ - *fs_addr_ptr = fspace->addr; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* H5FS_alloc_vfd_alloc_hdr_and_section_info() */ - - -/*------------------------------------------------------------------------- * Function: H5FS_free() * * Purpose: Free space for free-space manager header and section info header @@ -1076,7 +910,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) +H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id, hbool_t free_file_space) { haddr_t saved_addr; /* Previous address of item */ unsigned cache_flags; /* Flags for unprotecting cache entries */ @@ -1123,7 +957,8 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) /* Free space for the free-space manager section info */ if(!H5F_IS_TMP_ADDR(f, saved_addr)) { - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, saved_addr, saved_size) < 0) + if(free_file_space && + H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, saved_addr, saved_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end if */ @@ -1165,7 +1000,8 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) fspace->addr = HADDR_UNDEF; /* Free space for the free-space manager header */ - if(H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, dxpl_id, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) + if(free_file_space && + H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, dxpl_id, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header") } /* end if */ @@ -1339,6 +1175,23 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sinfo_dest() */ +herr_t +H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments. */ + HDassert(frsp); + HDassert(tot_sect_count); + + /* Report statistics for free space */ + *tot_sect_count = frsp->serial_sect_count; + + FUNC_LEAVE_NOAPI(ret_value) +} + #ifdef H5FS_DEBUG_ASSERT /*------------------------------------------------------------------------- diff --git a/src/H5FScache.c b/src/H5FScache.c index dcc8122..ddc66fd 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -37,6 +37,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File */ #include "H5FSpkg.h" /* File free space */ #include "H5MFprivate.h" /* File memory management */ #include "H5VMprivate.h" /* Vectors and arrays */ @@ -296,7 +297,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, /* # of section classes */ /* (only check if we actually have some classes) */ UINT16DECODE(image, nclasses); - if(fspace->nclasses > 0 && fspace->nclasses != nclasses) + if(fspace->nclasses > 0 && nclasses > fspace->nclasses) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch") /* Shrink percent */ @@ -596,9 +597,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, hid_t dxpl_id, void *_thing, * real file space lest the header be written to file with * a nonsense section info address. */ - HDassert(fspace->serial_sect_count > 0); - HDassert(fspace->sect_size > 0); - HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); + if(!H5F_POINT_OF_NO_RETURN(f)) { + HDassert(fspace->serial_sect_count > 0); + HDassert(fspace->sect_size > 0); + HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); + } /* end if */ if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { unsigned sect_status = 0; @@ -702,10 +705,12 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t len, * The following asserts are a cursory check on this. */ HDassert((! H5F_addr_defined(fspace->sect_addr)) || (! H5F_IS_TMP_ADDR(f, fspace->sect_addr))); - HDassert((! H5F_addr_defined(fspace->sect_addr)) || - ((fspace->serial_sect_count > 0) && - (fspace->sect_size > 0) && - (fspace->alloc_sect_size == (size_t)fspace->sect_size))); + + if(!H5F_POINT_OF_NO_RETURN(f)) + HDassert((! H5F_addr_defined(fspace->sect_addr)) || + ((fspace->serial_sect_count > 0) && + (fspace->sect_size > 0) && + (fspace->alloc_sect_size == (size_t)fspace->sect_size))); /* Magic number */ HDmemcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); @@ -1061,7 +1066,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t len, void *_udata, /* Insert section in free space manager, unless requested not to */ if(!(des_flags & H5FS_DESERIALIZE_NO_ADD)) - if(H5FS_sect_add(udata->f, udata->dxpl_id, udata->fspace, new_sect, H5FS_ADD_DESERIALIZING, NULL) < 0) + if(H5FS_sect_add(udata->f, udata->dxpl_id, udata->fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, "can't add section to free space manager") } /* end for */ } while(image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM)); @@ -1177,8 +1182,9 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, hid_t dxpl_id, void *_thing, HDassert(new_len); HDassert(flags); - /* we shouldn't be called if the section info is empty */ - HDassert(fspace->serial_sect_count > 0); + /* we shouldn't be called if the section info is empty, unless we hit the point of no return. */ + if(!H5F_POINT_OF_NO_RETURN(f)) + HDassert(fspace->serial_sect_count > 0); sinfo_addr = addr; /* this will change if we relocate the section data */ diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 4411236..ab97955 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -187,8 +187,9 @@ struct H5FS_t { /* must be either H5C__NO_FLAGS_SET (i.e r/w) */ /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */ size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ - hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Alignment */ + hsize_t align_thres; /* Threshold for alignment */ + /* Memory data structures (not stored directly) */ H5FS_section_class_t *sect_cls; /* Array of section classes for this free list */ diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index 1816a6e..74f9dcb 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -67,6 +67,12 @@ * managed sections is in flux) */ +#define H5FS_PAGE_END_NO_ADD 0x08 /* For "small" page fs: + * Don't add section to free space: + * when the section is at page end and + * when the section size is <= "small" + */ + /* Flags for deserialize callback */ #define H5FS_DESERIALIZE_NO_ADD 0x01 /* Don't add section to free space * manager after it's deserialized @@ -98,11 +104,11 @@ typedef struct H5FS_section_class_t { herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */ /* Object methods */ - herr_t (*add)(H5FS_section_info_t *, unsigned *, void *); /* Routine called when section is about to be added to manager */ + herr_t (*add)(H5FS_section_info_t **, unsigned *, void *); /* Routine called when section is about to be added to manager */ herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, uint8_t *); /* Routine to serialize a "live" section into a buffer */ H5FS_section_info_t *(*deserialize)(const struct H5FS_section_class_t *, hid_t dxpl_id, const uint8_t *, haddr_t, hsize_t, unsigned *); /* Routine to deserialize a buffer into a "live" section */ htri_t (*can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, void *); /* Routine to determine if two nodes are mergable */ - herr_t (*merge)(H5FS_section_info_t *, H5FS_section_info_t *, void *); /* Routine to merge two nodes */ + herr_t (*merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *); /* Routine to merge two nodes */ htri_t (*can_shrink)(const H5FS_section_info_t *, void *); /* Routine to determine if node can shrink container */ herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */ herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */ @@ -182,9 +188,8 @@ H5_DLL herr_t H5FS_delete(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr); H5_DLL herr_t H5FS_close(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace); H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr, hid_t dxpl_id); H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id); -H5_DLL herr_t H5FS_alloc_vfd_alloc_hdr_and_section_info(H5F_t *f, hid_t dxpl_id, - H5FS_t *fspace, haddr_t *fs_addr_ptr); -H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id); +H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id, + hbool_t free_file_space); /* Free space section routines */ H5_DLL herr_t H5FS_sect_add(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, @@ -192,7 +197,7 @@ H5_DLL herr_t H5FS_sect_add(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data); H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, - haddr_t addr, hsize_t size, hsize_t extra_requested); + haddr_t addr, hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data); H5_DLL herr_t H5FS_sect_remove(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *node); H5_DLL htri_t H5FS_sect_find(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, @@ -202,11 +207,18 @@ H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects); H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class); -H5_DLL htri_t H5FS_sect_try_shrink_eoa(const H5F_t *f, hid_t dxpl_id, const H5FS_t *fspace, void *op_data); -H5_DLL herr_t H5FS_sect_query_last_sect(const H5FS_t *fspace, haddr_t *sect_addr, hsize_t *sect_size); +H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, + void *op_data); /* Statistics routine */ H5_DLL herr_t H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats); +H5_DLL herr_t H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count); + +/* free space manager settling routines */ +H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, + hid_t dxpl_id, + H5FS_t *fspace, + haddr_t *fs_addr_ptr); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, diff --git a/src/H5FSsection.c b/src/H5FSsection.c index efe0031..49ff003 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -25,6 +25,8 @@ /* Module Setup */ /****************/ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ + #include "H5FSmodule.h" /* This source code file is part of the H5FS module */ @@ -33,6 +35,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ #include "H5FSpkg.h" /* File free space */ #include "H5MFprivate.h" /* File memory management */ #include "H5VMprivate.h" /* Vectors and arrays */ @@ -1210,11 +1213,13 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") /* Merge the two sections together */ - if((*tmp_sect_cls->merge)(tmp_sect, *sect, op_data) < 0) + if((*tmp_sect_cls->merge)(&tmp_sect, *sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") /* Retarget section pointer to 'less than' node that was merged into */ *sect = tmp_sect; + if(*sect == NULL) + HGOTO_DONE(ret_value); /* Indicate successful merge occurred */ modified = TRUE; @@ -1254,9 +1259,13 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") /* Merge the two sections together */ - if((*sect_cls->merge)(*sect, tmp_sect, op_data) < 0) + if((*sect_cls->merge)(sect, tmp_sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") + /* It's possible that the merge caused the section to be deleted (particularly in the paged allocation case) */ + if(*sect == NULL) + HGOTO_DONE(ret_value); + /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ @@ -1383,7 +1392,7 @@ HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->siz /* Call "add" section class callback, if there is one */ cls = &fspace->sect_cls[sect->type]; if(cls->add) { - if((*cls->add)(sect, &flags, op_data) < 0) + if((*cls->add)(§, &flags, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") } /* end if */ @@ -1411,7 +1420,7 @@ HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* H5FS_SINFO_DEBUG */ /* Mark free space sections as changed */ /* (if adding sections while deserializing sections, don't set the flag) */ - if(!(flags & H5FS_ADD_DESERIALIZING)) + if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_PAGE_END_NO_ADD))) sinfo_modified = TRUE; done: @@ -1444,7 +1453,7 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); */ htri_t H5FS_sect_try_extend(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, haddr_t addr, - hsize_t size, hsize_t extra_requested) + hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data) { hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ @@ -1528,10 +1537,16 @@ if(_section_) /* Adjust section by amount requested */ sect->addr += extra_requested; sect->size -= extra_requested; - - /* Re-add adjusted section to free sections data structures */ - if(H5FS_sect_link(fspace, sect, 0) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if(cls->add) + if((*cls->add)(§, &flags, op_data) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") + + /* Re-adding the section could cause it to disappear (particularly when paging) */ + if(sect) { + /* Re-add adjusted section to free sections data structures */ + if(H5FS_sect_link(fspace, sect, 0) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + } /* end if */ } /* end if */ else { /* Sanity check */ @@ -1667,7 +1682,7 @@ HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins) HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); #endif /* QAK */ alignment = fspace->alignment; - if(!((alignment > 1) && (request >= fspace->threshold))) + if(!((alignment > 1) && (request >= fspace->align_thres))) alignment = 0; /* no alignment */ do { @@ -2349,7 +2364,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H *------------------------------------------------------------------------- */ htri_t -H5FS_sect_try_shrink_eoa(const H5F_t *f, hid_t dxpl_id, const H5FS_t *fspace, void *op_data) +H5FS_sect_try_shrink_eoa(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, void *op_data) { hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ hbool_t section_removed = FALSE; /* Whether a section was removed */ @@ -2406,42 +2421,264 @@ done: /*------------------------------------------------------------------------- - * Function: H5FS_sect_query_last_sect - * - * Purpose: Retrieve info about the last section on the merge list - * - * Return: Success: non-negative - * Failure: negative + * Function: H5FS_vfd_alloc_hdr_and_section_info_if_needed + * + * Purpose: This function is part of a hack to patch over a design + * flaw in the free space managers for file space allocation. + * Specifically, if a free space manager allocates space for + * its own section info, it is possible for it to + * go into an infinite loop as it: + * + * 1) computes the size of the section info + * + * 2) allocates file space for the section info + * + * 3) notices that the size of the section info + * has changed + * + * 4) deallocates the section info file space and + * returns to 1) above. + * + * Similarly, if it allocates space for its own header, it + * can go into an infinte loop as it: + * + * 1) allocates space for the header + * + * 2) notices that the free space manager is empty + * and thus should not have file space allocated + * to its header + * + * 3) frees the space allocated to the header + * + * 4) notices that the free space manager is not + * empty and thus must have file space allocated + * to it, and thus returns to 1) above. + * + * In a nutshell, the solution applied in this hack is to + * deallocate file space for the free space manager(s) that + * handle FSM header and/or section info file space allocations, + * wait until all other allocation/deallocation requests have + * been handled, and then test to see if the free space manager(s) + * in question are empty. If they are, do nothing. If they + * are not, allocate space for them at end of file bypassing the + * usual file space allocation calls, and thus avoiding the + * potential infinite loops. + * + * The purpose of this function is to allocate file space for + * the header and section info of the target free space manager + * directly from the VFD if needed. In this case the function + * also re-inserts the header and section info in the metadata + * cache with this allocation. + * + * When paged allocation is not enabled, allocation of space + * for the free space manager header and section info is + * straight forward -- we simply allocate the space directly + * from file driver. + * + * Note that if f->shared->alignment > 1, and EOA is not a + * multiple of the alignment, it is possible that performing + * these allocations may generate a fragment of file space in + * addition to the space allocated for the section info. This + * excess space is dropped on the floor. As shall be seen, + * it will usually be reclaimed later. + * + * When page allocation is enabled, things are more difficult, + * as there is the possibility that page buffering will be + * enabled when the free space managers are read. To allow + * for this, we must ensure that space allocated for the + * free space manager header and section info is either larger + * than a page, or resides completely withing a page. + * + * Do this by allocating space for the free space header and + * section info starting at page boundaries, and extending + * allocation to the next page boundary. This of course wastes + * space, but see below. + * + * On the first free space allocation / deallocation after the + * next file open, we will read the self referential free space + * managers, float them and reduce the EOA to its value prior + * to allocation of file space for the self referential free + * space managers on the preceeding file close. This EOA value + * is stored in the free space manager superblock extension + * message. + * + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: John Mainzer + * 6/6/16 * *------------------------------------------------------------------------- */ herr_t -H5FS_sect_query_last_sect(const H5FS_t *fspace, haddr_t *sect_addr, hsize_t *sect_size) +H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, hid_t dxpl_id, + H5FS_t *fspace, haddr_t *fs_addr_ptr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + hsize_t hdr_alloc_size; + hsize_t sinfo_alloc_size; + haddr_t sect_addr = HADDR_UNDEF; /* address of sinfo */ + haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ + hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT /* Check arguments. */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); HDassert(fspace); + HDassert(fs_addr_ptr); - if(fspace->sinfo && fspace->sinfo->merge_list) { - H5SL_node_t *last_node; /* Last node in merge list */ + /* the section info should be unlocked */ + HDassert(fspace->sinfo_lock_count == 0); - /* Check for last node in the merge list */ - if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { - H5FS_section_info_t *tmp_sect; /* Temporary free space section */ + /* no space should be allocated */ + HDassert(*fs_addr_ptr == HADDR_UNDEF); + HDassert(fspace->addr == HADDR_UNDEF); + HDassert(fspace->sect_addr == HADDR_UNDEF); + HDassert(fspace->alloc_sect_size == 0); - /* Get the pointer to the last section, from the last node */ - tmp_sect = (H5FS_section_info_t *)H5SL_item(last_node); - HDassert(tmp_sect); - if(sect_addr) - *sect_addr = tmp_sect->addr; - if(sect_size) - *sect_size = tmp_sect->size; - } /* end if */ + /* persistant free space managers must be enabled */ + HDassert(f->shared->fs_persist); + + /* At present, all free space strategies enable the free space managers. + * This will probably change -- at which point this assertion should + * be revisited. + */ + /* Updated: Only the following two strategies enable the free-space managers */ + HDassert((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || + (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE)); + + if(fspace->serial_sect_count > 0) { + /* the section info is floating, so space->sinfo should be defined */ + HDassert(fspace->sinfo); + + /* start by allocating file space for the header */ + + /* Get the EOA for the file -- need for sanity check below */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_HDR))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + + /* check for overlap into temporary allocation space */ + if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "hdr file space alloc will overlap into 'temporary' file space") + + hdr_alloc_size = H5FS_HEADER_SIZE(f); + + /* if page allocation is enabled, extend the hdr_alloc_size to the + * next page boundary. + */ + if(H5F_PAGED_AGGR(f)) { + HDassert(0 == (eoa % f->shared->fs_page_size)); + + hdr_alloc_size = ((hdr_alloc_size / f->shared->fs_page_size) + 1) * f->shared->fs_page_size; + + HDassert(hdr_alloc_size >= H5FS_HEADER_SIZE(f)); + HDassert((hdr_alloc_size % f->shared->fs_page_size) == 0); + } /* end if */ + + /* allocate space for the hdr */ + if(HADDR_UNDEF == (fspace->addr = H5FD_alloc(f->shared->lf, dxpl_id, + H5FD_MEM_FSPACE_HDR, f, + hdr_alloc_size, + &eoa_frag_addr, + &eoa_frag_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space for hdr") + + /* if the file alignement is 1, there should be no + * eoa fragment. Otherwise, drop any fragment on the floor. + */ + HDassert((eoa_frag_size == 0) || (f->shared->alignment != 1)); + + /* Cache the new free space header (pinned) */ + if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") + + *fs_addr_ptr = fspace->addr; + + /* now allocate file space for the section info */ + + /* Get the EOA for the file -- need for sanity check below */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_SINFO))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "Unable to get eoa") + + /* check for overlap into temporary allocation space */ + if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_BADRANGE, FAIL, "sinfo file space alloc will overlap into 'temporary' file space") + + sinfo_alloc_size = fspace->sect_size; + + /* if paged allocation is enabled, extend the sinfo_alloc_size to the + * next page boundary. + */ + if(H5F_PAGED_AGGR(f)) { + HDassert(0 == (eoa % f->shared->fs_page_size)); + + sinfo_alloc_size = ((sinfo_alloc_size / f->shared->fs_page_size) + 1) * f->shared->fs_page_size; + + HDassert(sinfo_alloc_size >= fspace->sect_size); + HDassert((sinfo_alloc_size % f->shared->fs_page_size) == 0); + } /* end if */ + + /* allocate space for the section info */ + if(HADDR_UNDEF == (sect_addr = H5FD_alloc(f->shared->lf, dxpl_id, + H5FD_MEM_FSPACE_SINFO, f, + sinfo_alloc_size, + &eoa_frag_addr, + &eoa_frag_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space") + + /* if the file alignement is 1, there should be no + * eoa fragment. Otherwise, drop the fragment on the floor. + */ + HDassert((eoa_frag_size == 0) || (f->shared->alignment != 1)); + + /* update fspace->alloc_sect_size and fspace->sect_addr to reflect + * the allocation + */ + fspace->alloc_sect_size = fspace->sect_size; + fspace->sect_addr = sect_addr; + + /* insert the new section info into the metadata cache. */ + + /* Question: Do we need to worry about this insertion causing an + * eviction from the metadata cache? Think on this. If so, add a + * flag to H5AC_insert() to force it to skip the call to make space in + * cache. + * + * On reflection, no. + * + * On a regular file close, any eviction will not change the + * the contents of the free space manger(s), as all entries + * should have correct file space allocated by the time this + * function is called. + * + * In the cache image case, the selection of entries for inclusion + * in the cache image will not take place until after this call. + * (Recall that this call is made during the metadata fsm settle + * routine, which is called during the serialization routine in + * the cache image case. Entries are not selected for inclusion + * in the image until after the cache is serialized.) + * + * JRM -- 11/4/16 + */ + if(H5AC_insert_entry(f, dxpl_id, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sinfo to cache") + + /* We have changed the sinfo address -- Mark free space header dirty */ + if(H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + + /* since space has been allocated for the section info and the sinfo + * has been inserted into the cache, relinquish owership (i.e. float) + * the section info. + */ + fspace->sinfo = NULL; } /* end if */ - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FS_sect_query_last_sect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FS_vfd_alloc_hdr_and_section_info_if_needed() */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 3c98c8f..794be50 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -182,6 +182,14 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) efc_size = H5F_efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") + if(f->shared->page_buf != NULL) { + if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->page_buf->max_size)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set page buffer size") + if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->page_buf->min_meta_perc)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set minimum metadata fraction of page buffer") + if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->page_buf->min_raw_perc)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set minimum raw data fraction of page buffer") + } /* end if */ #ifdef H5_HAVE_PARALLEL if(H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set collective metadata read flag") @@ -597,11 +605,26 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->flags = flags; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; - for(u = 0; u < NELMTS(f->shared->fs_addr); u++) - f->shared->fs_addr[u] = HADDR_UNDEF; f->shared->accum.loc = HADDR_UNDEF; f->shared->lf = lf; + /* Initialization for handling file space */ + for(u = 0; u < NELMTS(f->shared->fs_addr); u++) { + f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; + f->shared->fs_addr[u] = HADDR_UNDEF; + f->shared->fs_man[u] = NULL; + } /* end for */ + f->shared->first_alloc_dealloc = FALSE; + f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; + f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; + f->shared->eoa_post_mdci_fsalloc = HADDR_UNDEF; + + /* Initialization for handling file space (for paged aggregation) */ + f->shared->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; + + /* intialize point of no return */ + f->shared->point_of_no_return = FALSE; + /* * Copy the file creation and file access property lists into the * new file handle. We do this early because some values might need @@ -621,8 +644,19 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HDassert(f->shared->sohm_nindexes < 255); if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space strategy") + if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &f->shared->fs_persist) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space persisting status") if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get free-space section threshold") + if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &f->shared->fs_page_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space page size") + HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); + + /* Temporary for multi/split drivers: fail file creation + when persisting free-space or using paged aggregation strategy */ + if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) + if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") /* Get the FAPL values to cache */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) @@ -972,6 +1006,11 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + /* Shutdown the page buffer cache */ + if(H5PB_dest(f) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing page buffer cache") + /* Clean up the metadata cache log location string */ if(f->shared->mdc_log_location) f->shared->mdc_log_location = (char *)H5MM_xfree(f->shared->mdc_log_location); @@ -1142,6 +1181,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5P_genplist_t *a_plist; /*file access property list */ H5F_close_degree_t fc_degree; /*file close degree */ hid_t raw_dxpl_id = H5AC_rawdata_dxpl_id; /* Raw data dxpl used by library */ + size_t page_buf_size; + unsigned page_buf_min_meta_perc; + unsigned page_buf_min_raw_perc; hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ hbool_t clear = FALSE; /*clear the status_flags */ hbool_t evict_on_close; /* evict on close value from plist */ @@ -1292,6 +1334,25 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") + /* Check if page buffering is enabled */ + if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size") + if(page_buf_size) { +#ifdef H5_HAVE_PARALLEL + /* Collective metadata writes are not supported with page buffering */ + if(file->coll_md_write) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "collective metadata writes are not supported with page buffering") + + /* Temporary: fail file create when page buffering feature is enabled for parallel */ + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "page buffering is disabled for parallel") +#endif /* H5_HAVE_PARALLEL */ + /* Query for other page buffer cache properties */ + if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &page_buf_min_meta_perc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum metadata fraction of page buffer") + if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &page_buf_min_raw_perc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum raw data fraction of page buffer") + } /* end if */ + /* * Read or write the file superblock, depending on whether the file is * empty or not. @@ -1302,6 +1363,11 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, * to create & write the superblock. */ + /* Create the page buffer before initializing the superblock */ + if(page_buf_size) + if(H5PB_create(file, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") + /* Initialize information about the superblock and allocate space for it */ /* (Writes superblock extension messages, if there are any) */ if(H5F__super_init(file, meta_dxpl_id) < 0) @@ -1319,6 +1385,11 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") + /* Create the page buffer before initializing the superblock */ + if(page_buf_size) + if(H5PB_create(file, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") + /* Open the root group */ if(H5G_mkroot(file, meta_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") @@ -1527,6 +1598,11 @@ H5F__flush_phase2(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closi /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") + /* Flush the page buffer */ + if(H5PB_flush(&fio_info) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "page buffer flush failed") + /* Flush file buffers to disk. */ if(H5FD_flush(f->shared->lf, meta_dxpl_id, closing) < 0) /* Push error, but keep going*/ @@ -2652,6 +2728,38 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_eoa() */ + +/*------------------------------------------------------------------------- + * Function: H5F__set_paged_aggr + * + * Purpose: Quick and dirty routine to set the file's paged_aggr mode + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * June 19, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + /* Dispatch to driver */ + if(H5FD_set_paged_aggr(f->shared->lf, paged) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set paged aggr mode failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__set_paged_aggr() */ + #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5Fio.c b/src/H5Fio.c index d40483f..6d23995 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -39,6 +39,7 @@ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5PBprivate.h" /* Page Buffer */ /****************/ @@ -129,9 +130,9 @@ H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") } /* end else */ - /* Pass through metadata accumulator layer */ - if(H5F__accum_read(&fio_info, map_type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through metadata accumulator failed") + /* Pass through page buffer layer */ + if(H5PB_read(&fio_info, map_type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -191,9 +192,9 @@ H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") } /* end else */ - /* Pass through metadata accumulator layer */ - if(H5F__accum_write(&fio_info, map_type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through metadata accumulator failed") + /* Pass through page buffer layer */ + if(H5PB_write(&fio_info, map_type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index aaa19d9..4dd9e20 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -42,6 +42,7 @@ #include "H5FSprivate.h" /* File free space */ #include "H5Gprivate.h" /* Groups */ #include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ #include "H5UCprivate.h" /* Reference counted object functions */ @@ -68,8 +69,8 @@ /* Macro to abstract checking whether file is using a free space manager */ #define H5F_HAVE_FREE_SPACE_MANAGER(F) \ - ((F)->shared->fs_strategy == H5F_FILE_SPACE_ALL || \ - (F)->shared->fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) + ((F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || \ + (F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) /* Macros for encoding/decoding superblock */ #define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ @@ -200,13 +201,6 @@ typedef struct H5F_meta_accum_t { hbool_t dirty; /* Flag to indicate that the accumulated metadata is dirty */ } H5F_meta_accum_t; -/* Enum for free space manager state */ -typedef enum H5F_fs_state_t { - H5F_FS_STATE_CLOSED, /* Free space manager is closed */ - H5F_FS_STATE_OPEN, /* Free space manager has been opened */ - H5F_FS_STATE_DELETING /* Free space manager is being deleted */ -} H5F_fs_state_t; - /* A record of the mount table */ typedef struct H5F_mount_t { struct H5G_t *group; /* Mount point group held open */ @@ -281,6 +275,7 @@ struct H5F_file_t { unsigned long feature_flags; /* VFL Driver feature Flags */ haddr_t maxaddr; /* Maximum address for file */ + H5PB_t *page_buf; /* The page buffer cache */ H5AC_t *cache; /* The object cache */ H5AC_cache_config_t mdc_initCacheCfg; /* initial configuration for the */ @@ -316,19 +311,38 @@ struct H5F_file_t { H5UC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ /* File space allocation information */ - H5F_file_space_type_t fs_strategy; /* File space handling strategy */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ hsize_t fs_threshold; /* Free space section threshold */ + hbool_t fs_persist; /* Free-space persist or not */ hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ haddr_t tmp_addr; /* Next address to use for temp. space in the file */ + hbool_t point_of_no_return; /* flag to indicate that we can't go back and delete a freespace header when it's used up */ + + H5F_fs_state_t fs_state[H5F_MEM_PAGE_NTYPES]; /* State of free space manager for each type */ + haddr_t fs_addr[H5F_MEM_PAGE_NTYPES]; /* Address of free space manager info for each type */ + H5FS_t *fs_man[H5F_MEM_PAGE_NTYPES]; /* Free space manager for each file space type */ + hbool_t first_alloc_dealloc; /* TRUE iff free space managers */ + /* are persistant and have not */ + /* been used accessed for either */ + /* allocation or deallocation */ + /* since file open. */ + haddr_t eoa_pre_fsm_fsalloc; /* eoa pre file space allocation */ + /* for self referential FSMs */ + haddr_t eoa_post_fsm_fsalloc; /* eoa post file space allocation */ + /* for self referential FSMs */ + haddr_t eoa_post_mdci_fsalloc; /* eoa past file space allocation */ + /* for metadata cache image, or */ + /* HADDR_UNDEF if no cache image. */ + + /* Free-space aggregation info */ unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ - H5F_fs_state_t fs_state[H5FD_MEM_NTYPES]; /* State of free space manager for each type */ - haddr_t fs_addr[H5FD_MEM_NTYPES]; /* Address of free space manager info for each type */ - H5FS_t *fs_man[H5FD_MEM_NTYPES]; /* Free space manager for each file space type */ - H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ - H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info */ - /* (if aggregating metadata allocations) */ - H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info */ - /* (if aggregating "small data" allocations) */ + H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ + H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info (if aggregating metadata allocations) */ + H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info (if aggregating "small data" allocations) */ + + /* Paged aggregation info */ + hsize_t fs_page_size; /* File space page size */ + size_t pgend_meta_thres; /* Do not track page end meta section <= this threshold */ /* Metadata accumulator information */ H5F_meta_accum_t accum; /* Metadata accumulator info */ @@ -383,7 +397,7 @@ H5FL_EXTERN(H5F_file_t); /* General routines */ H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); -herr_t H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush); +H5_DLL herr_t H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush); H5_DLL herr_t H5F__flush(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing); H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t meta_dxpl_id, hid_t raw_dxpl_id); H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); @@ -433,9 +447,16 @@ H5_DLL herr_t H5F_efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F_efc_destroy(H5F_efc_t *efc); H5_DLL herr_t H5F_efc_try_close(H5F_t *f); +/* Space allocation routines */ +H5_DLL haddr_t H5F_alloc(H5F_t *f, hid_t dxpl_id, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); +H5_DLL herr_t H5F_free(H5F_t *f, hid_t dxpl_id, H5F_mem_t type, haddr_t addr, hsize_t size); +H5_DLL htri_t H5F_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, + haddr_t blk_end, hsize_t extra_requested); + /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); H5_DLL herr_t H5F__set_base_addr(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5F__set_paged_aggr(const H5F_t *f, hbool_t paged); /* Functions that flush or evict */ H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f, hid_t dxpl_id); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index f980347..886063a 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -315,8 +315,8 @@ #define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL)) #define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) #define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) -#define H5F_USE_TMP_SPACE(F) ((F)->shared->use_tmp_space) -#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->tmp_addr, (ADDR))) +#define H5F_USE_TMP_SPACE(F) ((F)->shared->fs.use_tmp_space) +#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR))) #define H5F_SET_LATEST_FLAGS(F, FL) ((F)->shared->latest_flags = (FL)) #ifdef H5_HAVE_PARALLEL #define H5F_COLL_MD_READ(F) ((F)->coll_md_read) @@ -324,6 +324,12 @@ #define H5F_USE_MDC_LOGGING(F) ((F)->shared->use_mdc_logging) #define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access) #define H5F_MDC_LOG_LOCATION(F) ((F)->shared->mdc_log_location) +#define H5F_ALIGNMENT(F) ((F)->shared->alignment) +#define H5F_THRESHOLD(F) ((F)->shared->threshold) +#define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) +#define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) +#define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) +#define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) #else /* H5F_MODULE */ #define H5F_INTENT(F) (H5F_get_intent(F)) #define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) @@ -375,6 +381,12 @@ #define H5F_USE_MDC_LOGGING(F) (H5F_use_mdc_logging(F)) #define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F)) #define H5F_MDC_LOG_LOCATION(F) (H5F_mdc_log_location(F)) +#define H5F_ALIGNMENT(F) (H5F_get_alignment(F)) +#define H5F_THRESHOLD(F) (H5F_get_threshold(F)) +#define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) +#define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) +#define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) +#define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) #endif /* H5F_MODULE */ @@ -448,7 +460,9 @@ #define H5F_CRT_SHMSG_LIST_MAX_NAME "shmsg_list_max" /* Shared message list maximum size */ #define H5F_CRT_SHMSG_BTREE_MIN_NAME "shmsg_btree_min" /* Shared message B-tree minimum size */ #define H5F_CRT_FILE_SPACE_STRATEGY_NAME "file_space_strategy" /* File space handling strategy */ +#define H5F_CRT_FREE_SPACE_PERSIST_NAME "free_space_persist" /* Free-space persisting status */ #define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */ +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */ @@ -484,6 +498,9 @@ #define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME "core_write_tracking_page_size" /* The page size in kiB when core VFD write tracking is enabled */ #define H5F_ACS_COLL_MD_WRITE_FLAG_NAME "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not */ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ +#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */ /* ======================== File Mount properties ====================*/ #define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ @@ -522,10 +539,34 @@ /* See format specification on version 1 B-trees */ /* Default file space handling strategy */ -#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_ALL +#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR + +/* Default free space section threshold used by free-space managers */ +#define H5F_FREE_SPACE_PERSIST_DEF FALSE + /* Default free space section threshold used by free-space managers */ #define H5F_FREE_SPACE_THRESHOLD_DEF 1 +/* For paged aggregation: default file space page size when not set */ +#define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096 +/* For paged aggregation: minimum value for file space page size */ +#define H5F_FILE_SPACE_PAGE_SIZE_MIN 512 + +/* For paged aggregation: drop free-space with size <= this threshold for small meta section */ +#define H5F_FILE_SPACE_PGEND_META_THRES 10 + +/* Default for threshold for alignment (can be set via H5Pset_alignment()) */ +#define H5F_ALIGN_DEF 1 +/* Default for alignment (can be set via H5Pset_alignment()) */ +#define H5F_ALIGN_THRHD_DEF 1 +/* Default size for meta data aggregation block (can be set via H5Pset_meta_block_size()) */ +#define H5F_META_BLOCK_SIZE_DEF 2048 +/* Default size for small data aggregation block (can be set via H5Pset_small_data_block_size()) */ +#define H5F_SDATA_BLOCK_SIZE_DEF 2048 + +/* Check for file using paged aggregation */ +#define H5F_PAGED_AGGR(F) (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size) + /* Metadata read attempt values */ #define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */ #define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */ @@ -648,6 +689,34 @@ typedef struct H5F_block_t { hsize_t length; /* Length of the block in the file */ } H5F_block_t; +/* Enum for free space manager state */ +typedef enum H5F_fs_state_t { + H5F_FS_STATE_CLOSED = 0, /* Free space manager is closed */ + H5F_FS_STATE_OPEN = 1, /* Free space manager has been opened */ + H5F_FS_STATE_DELETING = 2 /* Free space manager is being deleted */ +} H5F_fs_state_t; + +/* For paged aggregation */ +/* The values 0 to 6 is the same as H5F_mem_t */ +typedef enum H5F_mem_page_t { + H5F_MEM_PAGE_DEFAULT = 0, /* Not used */ + H5F_MEM_PAGE_SUPER = 1, + H5F_MEM_PAGE_BTREE = 2, + H5F_MEM_PAGE_DRAW = 3, + H5F_MEM_PAGE_GHEAP = 4, + H5F_MEM_PAGE_LHEAP = 5, + H5F_MEM_PAGE_OHDR = 6, + H5F_MEM_PAGE_LARGE_SUPER = 7, + H5F_MEM_PAGE_LARGE_BTREE = 8, + H5F_MEM_PAGE_LARGE_DRAW = 9, + H5F_MEM_PAGE_LARGE_GHEAP = 10, + H5F_MEM_PAGE_LARGE_LHEAP = 11, + H5F_MEM_PAGE_LARGE_OHDR = 12, + H5F_MEM_PAGE_NTYPES = 13 /* Sentinel value - must be last */ +} H5F_mem_page_t; + +#define H5F_MEM_PAGE_META H5F_MEM_PAGE_SUPER /* Small-sized meta data */ +#define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */ /*****************************/ /* Library-private Variables */ @@ -682,6 +751,10 @@ H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); H5_DLL hid_t H5F_get_id(H5F_t *file, hbool_t app_ref); H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, hbool_t app_ref, size_t *obj_id_count_ptr); +H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); +H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); +H5_DLL hbool_t H5F_get_first_alloc_dealloc(const H5F_t *f); +H5_DLL hbool_t H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); @@ -712,6 +785,8 @@ H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5F_set_latest_flags(H5F_t *f, unsigned flags); +H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); +H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); #ifdef H5_HAVE_PARALLEL H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f); H5_DLL void H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t flag); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index c57a821..f87aaad 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -182,6 +182,17 @@ typedef enum H5F_libver_t { } H5F_libver_t; /* File space handling strategy */ +typedef enum H5F_fspace_strategy_t { + H5F_FSPACE_STRATEGY_FSM_AGGR = 0, /* Mechanisms: free-space managers, aggregators, and virtual file drivers */ + /* This is the library default when not set */ + H5F_FSPACE_STRATEGY_PAGE = 1, /* Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers */ + H5F_FSPACE_STRATEGY_AGGR = 2, /* Mechanisms: aggregators and virtual file drivers */ + H5F_FSPACE_STRATEGY_NONE = 3, /* Mechanisms: virtual file drivers */ + H5F_FSPACE_STRATEGY_NTYPES /* must be last */ +} H5F_fspace_strategy_t; + +/* Deprecated: File space handling strategy for release 1.10.0 */ +/* They are mapped to H5F_fspace_strategy_t as defined above from release 1.10.1 onwards */ typedef enum H5F_file_space_type_t { H5F_FILE_SPACE_DEFAULT = 0, /* Default (or current) free space strategy setting */ H5F_FILE_SPACE_ALL_PERSIST = 1, /* Persistent free space managers, aggregators, virtual file driver */ @@ -253,6 +264,10 @@ H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging); H5_DLL herr_t H5Fformat_convert(hid_t fid); +H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); +H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], + unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); + #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 14dd655..34fe8f9 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1235,3 +1235,150 @@ H5F_mdc_log_location(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->mdc_log_location) } /* end H5F_mdc_log_location() */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_alignment + * + * Purpose: Retrieve the 'alignment' for the file. + * + * Return: Success: Non-negative, the 'alignment' + * + * Failure: (can't happen) + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +hsize_t +H5F_get_alignment(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->alignment) +} /* end H5F_get_alignment() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_threshold + * + * Purpose: Retrieve the 'threshold' for alignment in the file. + * + * Return: Success: Non-negative, the 'threshold' + * + * Failure: (can't happen) + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +hsize_t +H5F_get_threshold(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->threshold) +} /* end H5F_get_threshold() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_pgend_meta_thres + * + * Purpose: Retrieve the 'page end meta threshold size' for the file. + * + * Return: Success: Non-negative, the 'pgend_meta_thres' + * + * Failure: (can't happen) + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +hsize_t +H5F_get_pgend_meta_thres(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->pgend_meta_thres) +} /* end H5F_get_pgend_meta_thres() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_point_of_no_return + * + * Purpose: Retrieve the 'point of no return' value for the file. + * + * Return: Success: Non-negative, the 'point_of_no_return' + * Failure: (can't happen) + * + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_point_of_no_return(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->point_of_no_return) +} /* end H5F_get_point_of_no_return() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_first_alloc_dealloc + * + * Purpose: Retrieve the 'first alloc / dealloc' value for the file. + * + * Return: Success: Non-negative, the 'first_alloc_dealloc' + * Failure: (can't happen) + * + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_first_alloc_dealloc(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->first_alloc_dealloc) +} /* end H5F_get_first_alloc_dealloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_eoa_pre_fsm_fsalloc + * + * Purpose: Retrieve the 'EOA pre-FSM fsalloc' value for the file. + * + * Return: Success: Non-negative, the 'EOA pre-FSM fsalloc' + * Failure: (can't happen) + * + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->eoa_pre_fsm_fsalloc) +} /* end H5F_get_eoa_pre_fsm_fsalloc() */ + diff --git a/src/H5Fspace.c b/src/H5Fspace.c new file mode 100644 index 0000000..53570f6 --- /dev/null +++ b/src/H5Fspace.c @@ -0,0 +1,226 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Fspace.c + * Dec 30 2013 + * Quincey Koziol + * + * Purpose: Space allocation routines for the file. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5F_alloc + * + * Purpose: Wrapper for H5FD_alloc, to make certain EOA changes are + * reflected in superblock. + * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * + * Return: Success: The format address of the new file memory. + * Failure: The undefined address HADDR_UNDEF + * + * Programmer: Quincey Koziol + * Monday, December 30, 2013 + * + *------------------------------------------------------------------------- + */ +haddr_t +H5F_alloc(H5F_t *f, hid_t dxpl_id, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) +{ + haddr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI(HADDR_UNDEF) + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); + HDassert(size > 0); + + /* Check whether the file can use temporary addresses */ + if(f->shared->use_tmp_space) { + haddr_t eoa; /* Current EOA for the file */ + + /* Get the EOA for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") + + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + } /* end if */ + + /* Call the file driver 'alloc' routine */ + ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, f, size, frag_addr, frag_size); + if(!H5F_addr_defined(ret_value)) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, HADDR_UNDEF, "file driver 'alloc' request failed") + + /* Mark EOA dirty */ + if(H5F_eoa_dirty(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark EOA as dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_alloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_free + * + * Purpose: Wrapper for H5FD_free, to make certain EOA changes are + * reflected in superblock. + * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, December 30, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); + HDassert(size > 0); + + /* Call the file driver 'free' routine */ + if(H5FD_free(f->shared->lf, dxpl_id, type, f, addr, size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "file driver 'free' request failed") + + /* Mark EOA dirty */ + if(H5F_eoa_dirty(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA as dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_try_extend + * + * Purpose: Extend a block at the end of the file, if possible. + * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * + * Return: Success: TRUE(1) - Block was extended + * FALSE(0) - Block could not be extended + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Monday, 30 December, 2013 + * + *------------------------------------------------------------------------- + */ +htri_t +H5F_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); + HDassert(extra_requested > 0); + + /* Extend the object by extending the underlying file */ + if((ret_value = H5FD_try_extend(f->shared->lf, type, f, dxpl_id, blk_end, extra_requested)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTEXTEND, FAIL, "driver try extend request failed") + + /* H5FD_try_extend() updates driver message and marks the superblock + * dirty, so no need to do it again here. + */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_try_extend() */ + diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 3050a28..58ef9bb 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -29,6 +29,7 @@ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -671,32 +672,98 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID, meta_dxpl_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") if(status) { - H5O_fsinfo_t fsinfo; /* Free-space manager info message from superblock extension */ + H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */ + uint8_t flags; /* Message flags */ - /* Retrieve the 'free-space manager info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, meta_dxpl_id)) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message") + /* Get message flags */ + if(H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, meta_dxpl_id, &flags) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to message flags for free-space manager info message") - /* Check for non-default info */ - if(f->shared->fs_strategy != fsinfo.strategy) { - f->shared->fs_strategy = fsinfo.strategy; + /* If message is NOT marked "unknown"--set up file space info */ + if(!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { - /* Set non-default strategy in the property list */ - if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") - } /* end if */ - if(f->shared->fs_threshold != fsinfo.threshold) { - f->shared->fs_threshold = fsinfo.threshold; + /* Retrieve the 'file space info' structure */ + if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, meta_dxpl_id)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message") - /* Set non-default threshold in the property list */ - if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") - } /* end if */ + /* Update changed values */ + if(f->shared->fs_strategy != fsinfo.strategy) { + f->shared->fs_strategy = fsinfo.strategy; + + /* Set non-default strategy in the property list */ + if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") + } /* end if */ + if(f->shared->fs_persist != fsinfo.persist) { + f->shared->fs_persist = fsinfo.persist; + + /* Set non-default strategy in the property list */ + if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &fsinfo.persist) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") + } /* end if */ + if(f->shared->fs_threshold != fsinfo.threshold) { + f->shared->fs_threshold = fsinfo.threshold; + + /* Set non-default threshold in the property list */ + if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") + } /* end if */ + + HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); + HDassert(fsinfo.page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); + if(f->shared->fs_page_size != fsinfo.page_size) { + f->shared->fs_page_size = fsinfo.page_size; + + /* Set file space page size in the property list */ + if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsinfo.page_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space page size") + } /* end if */ + if(f->shared->pgend_meta_thres != fsinfo.pgend_meta_thres) + /* Initialize page end meta threshold */ + f->shared->pgend_meta_thres = fsinfo.pgend_meta_thres; + + if(f->shared->eoa_pre_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc) + f->shared->eoa_pre_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc; + + /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF + * in the absence of persistant free space managers. + */ + HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF)); + HDassert(!f->shared->first_alloc_dealloc); + + if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF) && + (H5F_INTENT(f) & H5F_ACC_RDWR)) + f->shared->first_alloc_dealloc = TRUE; + + f->shared->fs_addr[0] = HADDR_UNDEF; + for(u = 1; u < NELMTS(f->shared->fs_addr); u++) + f->shared->fs_addr[u] = fsinfo.fs_addr[u - 1]; + + if(fsinfo.mapped && (rw_flags & H5AC__READ_ONLY_FLAG) == 0) { - /* Set free-space manager addresses */ - f->shared->fs_addr[0] = HADDR_UNDEF; - for(u = 1; u < NELMTS(f->shared->fs_addr); u++) - f->shared->fs_addr[u] = fsinfo.fs_addr[u-1]; + /* Do the same kluge until we know for sure. VC */ +#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ + /* KLUGE ALERT!! + * + * H5F_super_ext_write_msg() expects f->shared->sblock to + * be set -- verify that it is NULL, and then set it. + * Set it back to NULL when we are done. + */ + HDassert(f->shared->sblock == NULL); + f->shared->sblock = sblock; +#endif /* JRM */ + + if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension") + + if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") +#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ + f->shared->sblock = NULL; +#endif /* JRM */ + + } + } /* end if not marked "unknown" */ } /* end if */ /* Check for the extension having a 'metadata cache image' message */ @@ -796,6 +863,10 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial /* Set the pointer to the pinned superblock */ f->shared->sblock = sblock; + /* Set the page aggregation mode */ + if(H5F__set_paged_aggr(f, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set paged_aggr status for file driver") + done: /* Reset the ring in the DXPL */ if(H5AC_reset_ring(dxpl, orig_ring) < 0) @@ -897,7 +968,9 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) /* Check for non-default free-space settings */ if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF)) + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) non_default_fs_settings = TRUE; /* Bump superblock version if latest superblock version support is enabled */ @@ -906,8 +979,12 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) /* Bump superblock version to create superblock extension for SOHM info */ else if(f->shared->sohm_nindexes > 0) super_vers = HDF5_SUPERBLOCK_VERSION_2; - /* Bump superblock version to create superblock extension for - * non-default file space strategy or non-default free-space threshold + /* + * Bump superblock version to create superblock extension for: + * -- non-default file space strategy or + * -- non-default persisting free-space or + * -- non-default free-space threshold or + * -- non-default page_size */ else if(non_default_fs_settings) super_vers = HDF5_SUPERBLOCK_VERSION_2; @@ -928,6 +1005,9 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") } /* end if */ + if(H5FD_set_paged_aggr(f->shared->lf, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set paged_aggr status for file driver") + /* * The superblock starts immediately after the user-defined * header, which we have already insured is a proper size. The @@ -939,9 +1019,12 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) /* Sanity check the userblock size vs. the file's allocation alignment */ if(userblock_size > 0) { - if(userblock_size < f->shared->alignment) + /* Set up the alignment to use for page or aggr fs */ + hsize_t alignment = H5F_PAGED_AGGR(f) ? f->shared->fs_page_size : f->shared->alignment; + + if(userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment") - if(0 != (userblock_size % f->shared->alignment)) + if(0 != (userblock_size % alignment)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment") } /* end if */ @@ -997,10 +1080,6 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) if(super_vers < HDF5_SUPERBLOCK_VERSION_2) superblock_size += driver_size; - /* Reserve space in the file for the superblock, instead of allocating it */ - if(H5F__set_eoa(f, H5FD_MEM_SUPER, superblock_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for superblock") - /* Set the ring type in the DXPL */ if(H5AC_set_ring(dxpl_id, H5AC_RING_SB, &dxpl, &orig_ring) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set ring value") @@ -1013,6 +1092,10 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) /* Keep a copy of the superblock info */ f->shared->sblock = sblock; + /* Allocate space for the superblock */ + if(HADDR_UNDEF == H5MF_alloc(f, H5FD_MEM_SUPER, dxpl_id, superblock_size)) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock") + /* set the drvinfo filed to NULL -- will overwrite this later if needed */ f->shared->drvinfo = NULL; @@ -1115,17 +1198,23 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) } /* end if */ /* Check for non-default free-space info settings */ - if(non_default_fs_settings) { - H5FD_mem_t type; /* Memory type for iteration */ - H5O_fsinfo_t fsinfo; /* Free space manager info message */ - - /* Write free-space manager info message to superblock extension object header if needed */ - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.threshold = f->shared->fs_threshold; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - fsinfo.fs_addr[type-1] = HADDR_UNDEF; - - if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &fsinfo, dxpl_id) < 0) + if(non_default_fs_settings) { + H5F_mem_page_t ptype; + H5O_fsinfo_t fsinfo; /* Free space manager info message */ + + /* Write free-space manager info message to superblock extension object header if needed */ + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; + fsinfo.mapped = FALSE; + + for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; + + if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &fsinfo, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message") } /* end if */ } /* end if */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 37ff8f4..b113ca1 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -85,14 +85,14 @@ static herr_t H5HF_sect_single_full_dblock(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect); /* 'single' section callbacks */ -static herr_t H5HF_sect_single_add(H5FS_section_info_t *sect, unsigned *flags, +static herr_t H5HF_sect_single_add(H5FS_section_info_t **sect, unsigned *flags, void *udata); static H5FS_section_info_t *H5HF_sect_single_deserialize(const H5FS_section_class_t *cls, hid_t dxpl_id, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); static htri_t H5HF_sect_single_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF_sect_single_merge(H5FS_section_info_t *sect1, +static herr_t H5HF_sect_single_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); static htri_t H5HF_sect_single_can_shrink(const H5FS_section_info_t *sect, void *udata); @@ -121,7 +121,7 @@ static H5FS_section_info_t *H5HF_sect_row_deserialize(const H5FS_section_class_t unsigned *des_flags); static htri_t H5HF_sect_row_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF_sect_row_merge(H5FS_section_info_t *sect1, +static herr_t H5HF_sect_row_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); static htri_t H5HF_sect_row_can_shrink(const H5FS_section_info_t *sect, void *udata); @@ -811,7 +811,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_single_add(H5FS_section_info_t *_sect, unsigned *flags, void *_udata) +H5HF_sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { herr_t ret_value = SUCCEED; /* Return value */ @@ -821,7 +821,7 @@ H5HF_sect_single_add(H5FS_section_info_t *_sect, unsigned *flags, void *_udata) * have already been checked when it was first added */ if(!(*flags & H5FS_ADD_DESERIALIZING)) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Fractal heap free section */ + H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ hid_t dxpl_id = udata->dxpl_id; /* DXPL ID for operation */ @@ -832,14 +832,14 @@ H5HF_sect_single_add(H5FS_section_info_t *_sect, unsigned *flags, void *_udata) /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF_sect_single_full_dblock(hdr, dxpl_id, sect) < 0) + if(H5HF_sect_single_full_dblock(hdr, dxpl_id, (*sect)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") /* Set the "returned space" flag if the single section was changed * into a row section, so the "merging & shrinking" algorithm * gets executed in the free space manager */ - if(sect->sect_info.type != H5HF_FSPACE_SECT_SINGLE) + if((*sect)->sect_info.type != H5HF_FSPACE_SECT_SINGLE) *flags |= H5FS_ADD_RETURNED_SPACE; } /* end if */ @@ -949,10 +949,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_single_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, +H5HF_sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { - H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1; /* Fractal heap free section */ + H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ @@ -963,26 +963,26 @@ H5HF_sect_single_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, /* Check arguments. */ HDassert(sect1); - HDassert(sect1->sect_info.type == H5HF_FSPACE_SECT_SINGLE); + HDassert((*sect1)->sect_info.type == H5HF_FSPACE_SECT_SINGLE); HDassert(sect2); HDassert(sect2->sect_info.type == H5HF_FSPACE_SECT_SINGLE); - HDassert(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)); + HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); /* Add second section's size to first section */ - sect1->sect_info.size += sect2->sect_info.size; + (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ if(H5HF_sect_single_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") /* Check to see if we should revive first section */ - if(sect1->sect_info.state != H5FS_SECT_LIVE) - if(H5HF_sect_single_revive(hdr, dxpl_id, sect1) < 0) + if((*sect1)->sect_info.state != H5FS_SECT_LIVE) + if(H5HF_sect_single_revive(hdr, dxpl_id, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF_sect_single_full_dblock(hdr, dxpl_id, sect1) < 0) + if(H5HF_sect_single_full_dblock(hdr, dxpl_id, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") done: @@ -1771,10 +1771,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_row_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, +H5HF_sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { - H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1; /* Fractal heap free section */ + H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ @@ -1785,7 +1785,7 @@ H5HF_sect_row_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, /* Check arguments. */ HDassert(sect1); - HDassert(sect1->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); + HDassert((*sect1)->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); HDassert(sect2); HDassert(sect2->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); @@ -1802,8 +1802,8 @@ H5HF_sect_row_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, } /* end if */ else { /* Check to see if we should revive first section */ - if(sect1->sect_info.state != H5FS_SECT_LIVE) - if(H5HF_sect_row_revive(hdr, dxpl_id, sect1) < 0) + if((*sect1)->sect_info.state != H5FS_SECT_LIVE) + if(H5HF_sect_row_revive(hdr, dxpl_id, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Check to see if we should revive second section */ @@ -1812,7 +1812,7 @@ H5HF_sect_row_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Merge rows' underlying indirect sections together */ - if(H5HF_sect_indirect_merge_row(hdr, dxpl_id, sect1, sect2) < 0) + if(H5HF_sect_indirect_merge_row(hdr, dxpl_id, (*sect1), sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") } /* end else */ diff --git a/src/H5MF.c b/src/H5MF.c index 36b9386..358e326 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -29,6 +29,7 @@ /****************/ #define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FS_FRIEND /*suppress error about including H5Fpkg */ #include "H5MFmodule.h" /* This source code file is part of the H5MF module */ @@ -38,6 +39,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File access */ #include "H5Iprivate.h" /* IDs */ #include "H5MFpkg.h" /* File memory management */ #include "H5VMprivate.h" /* Vectors and arrays */ @@ -50,11 +52,6 @@ #define H5MF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ #define H5MF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ -/* Map an allocation request type to a free list */ -#define H5MF_ALLOC_TO_FS_TYPE(F, T) ((H5FD_MEM_DEFAULT == (F)->shared->fs_type_map[T]) \ - ? (T) : (F)->shared->fs_type_map[T]) - - /******************/ /* Local Typedefs */ /******************/ @@ -84,11 +81,24 @@ typedef struct { /********************/ /* Allocator routines */ -static herr_t H5MF_alloc_create(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type); -static herr_t H5MF__alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type); -static herr_t H5MF__close_delete(H5F_t *f, hid_t dxpl_id, H5P_genplist_t **dxpl); +static haddr_t H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size); + +/* "File closing" routines */ +static herr_t H5MF__close_aggrfs(H5F_t *f, hid_t dxpl_id); +static herr_t H5MF__close_pagefs(H5F_t *f, hid_t dxpl_id); static herr_t H5MF__close_shrink_eoa(H5F_t *f, hid_t dxpl_id); +/* General routines */ +static herr_t H5MF__get_free_sects(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); +static hbool_t H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type); +static hbool_t H5MF__fsm_is_self_referential(H5F_t *f, H5FS_t *fspace); + +/* Free-space type manager routines */ +static herr_t H5MF__create_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); +static herr_t H5MF__close_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); +static herr_t H5MF__delete_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); +static herr_t H5MF__close_delete_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); + /*********************/ /* Package Variables */ @@ -223,10 +233,54 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF__alloc_open + * Function: H5MF_alloc_to_fs_type + * + * Purpose: Map "alloc_type" to the free-space manager type + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Nov 2016 + * + *------------------------------------------------------------------------- + */ +void +H5MF_alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(fs_type); + + if(H5F_PAGED_AGGR(f)) { /* paged aggregation */ + if(size >= f->shared->fs_page_size) { + if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) { /* multi or split driver */ + /* For non-contiguous address space, map to large size free-space manager for each alloc_type */ + if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[alloc_type]) + *fs_type = (H5F_mem_page_t) (alloc_type + (H5FD_MEM_NTYPES - 1)); + else + *fs_type = (H5F_mem_page_t) (f->shared->fs_type_map[alloc_type] + (H5FD_MEM_NTYPES - 1)); + } /* end if */ + else + /* For contiguous address space, map to generic large size free-space manager */ + *fs_type = H5F_MEM_PAGE_GENERIC; /* H5F_MEM_PAGE_SUPER */ + } /* end if */ + else + *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f, alloc_type); + } /* end if */ + else /* non-paged aggregation */ + *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f, alloc_type); + + FUNC_LEAVE_NOAPI_VOID +} /* end H5MF_alloc_to_fs_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_open_fstype * * Purpose: Open an existing free space manager of TYPE for file by - * creating a free-space structure + * creating a free-space structure. + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * * Return: Success: non-negative * Failure: negative @@ -238,31 +292,48 @@ done: *------------------------------------------------------------------------- */ herr_t -H5MF__alloc_open(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) +H5MF_open_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) { const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE}; - H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t fsm_ring; /* Free space manager ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_FSPACE_SECT_CLS_SIMPLE, + H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE }; + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) /* * Check arguments. */ HDassert(f); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else { + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); + HDassert((H5FD_mem_t)type != H5FD_MEM_NOLIST); + } /* end else */ HDassert(f->shared); - HDassert(type != H5FD_MEM_NOLIST); HDassert(H5F_addr_defined(f->shared->fs_addr[type])); HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); - HDassert(type == H5MF_ALLOC_TO_FS_TYPE(f, type)); + + /* Set up the aligment and threshold to use depending on the manager type */ + if(H5F_PAGED_AGGR(f)) { + alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; + threshold = H5F_ALIGN_THRHD_DEF; + } /* end if */ + else { + alignment = f->shared->alignment; + threshold = f->shared->threshold; + } /* end else */ /* Set the ring type in the DXPL */ - if((type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) + if(H5MF__fsm_type_is_self_referential(f, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -272,7 +343,7 @@ H5MF__alloc_open(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) /* Open an existing free space structure for the file */ if(NULL == (f->shared->fs_man[type] = H5FS_open(f, dxpl_id, f->shared->fs_addr[type], - NELMTS(classes), classes, f, f->shared->alignment, f->shared->threshold))) + NELMTS(classes), classes, f, alignment, threshold))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ @@ -286,14 +357,15 @@ done: HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF__alloc_open() */ +} /* end H5MF_open_fstype() */ /*------------------------------------------------------------------------- - * Function: H5MF_alloc_create + * Function: H5MF__create_fstype * * Purpose: Create free space manager of TYPE for the file by creating - * a free-space structure + * a free-space structure + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * * Return: Success: non-negative * Failure: negative @@ -305,21 +377,34 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_alloc_create(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) +H5MF__create_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) { const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE}; - herr_t ret_value = SUCCEED; /* Return value */ - H5FS_create_t fs_create; /* Free space creation parameters */ + H5MF_FSPACE_SECT_CLS_SIMPLE, + H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE }; + H5FS_create_t fs_create; /* Free space creation parameters */ + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) /* * Check arguments. */ HDassert(f); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else { + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); + HDassert((H5FD_mem_t)type != H5FD_MEM_NOLIST); + } /* end else */ HDassert(f->shared); - HDassert(type != H5FD_MEM_NOLIST); HDassert(!H5F_addr_defined(f->shared->fs_addr[type])); HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); @@ -330,24 +415,48 @@ H5MF_alloc_create(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)f->shared->maxaddr); fs_create.max_sect_size = f->shared->maxaddr; - if(NULL == (f->shared->fs_man[type] = H5FS_create(f, dxpl_id, NULL, - &fs_create, NELMTS(classes), classes, f, f->shared->alignment, f->shared->threshold))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") + /* Set up alignment and threshold to use depending on TYPE */ + if(H5F_PAGED_AGGR(f)) { + alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; + threshold = H5F_ALIGN_THRHD_DEF; + } /* end if */ + else { + alignment = f->shared->alignment; + threshold = f->shared->threshold; + } /* end else */ + + /* Set the ring type in the DXPL */ + if(H5MF__fsm_type_is_self_referential(f, type)) + fsm_ring = H5AC_RING_MDFSM; + else + fsm_ring = H5AC_RING_RDFSM; + if(H5AC_set_ring(dxpl_id, fsm_ring, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + if(NULL == (f->shared->fs_man[type] = H5FS_create(f, dxpl_id, NULL, + &fs_create, NELMTS(classes), classes, f, alignment, threshold))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ if(f->shared->fs_man[type]) f->shared->fs_state[type] = H5F_FS_STATE_OPEN; done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF_alloc_create() */ +} /* end H5MF__create_fstype() */ /*------------------------------------------------------------------------- - * Function: H5MF__alloc_start + * Function: H5MF_start_fstype * - * Purpose: Open or create a free space manager of a given type + * Purpose: Open or create a free space manager of a given TYPE. + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * * Return: Success: non-negative * Failure: negative @@ -359,40 +468,123 @@ done: *------------------------------------------------------------------------- */ herr_t -H5MF__alloc_start(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) +H5MF_start_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) /* * Check arguments. */ HDassert(f); HDassert(f->shared); - HDassert(type != H5FD_MEM_NOLIST); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else { + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); + HDassert((H5FD_mem_t)type != H5FD_MEM_NOLIST); + } /* end else */ /* Check if the free space manager exists already */ if(H5F_addr_defined(f->shared->fs_addr[type])) { /* Open existing free space manager */ - if(H5MF__alloc_open(f, dxpl_id, type) < 0) + if(H5MF_open_fstype(f, dxpl_id, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, FAIL, "can't initialize file free space") } /* end if */ else { /* Create new free space manager */ - if(H5MF_alloc_create(f, dxpl_id, type) < 0) + if(H5MF__create_fstype(f, dxpl_id, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCREATE, FAIL, "can't initialize file free space") } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__alloc_start() */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF_start_fstype() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__delete_fstype + * + * Purpose: Delete the free-space manager as specified by TYPE. + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; April 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__delete_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + + /* check args */ + HDassert(f); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); + HDassert(H5F_addr_defined(f->shared->fs_addr[type])); + + /* Put address into temporary variable and reset it */ + /* (Avoids loopback in file space freeing routine) */ + tmp_fs_addr = f->shared->fs_addr[type]; + f->shared->fs_addr[type] = HADDR_UNDEF; + + /* Shift to "deleting" state, to make certain we don't track any + * file space freed as a result of deleting the free space manager. + */ + f->shared->fs_state[type] = H5F_FS_STATE_DELETING; + + /* Set the ring type in the DXPL */ + if(H5MF__fsm_type_is_self_referential(f, type)) + fsm_ring = H5AC_RING_MDFSM; + else + fsm_ring = H5AC_RING_RDFSM; + if(H5AC_set_ring(dxpl_id, fsm_ring, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Delete free space manager for this type */ + if(H5FS_delete(f, dxpl_id, tmp_fs_addr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't delete free space manager") + + /* Shift [back] to closed state */ + HDassert(f->shared->fs_state[type] == H5F_FS_STATE_DELETING); + f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; + + /* Sanity check that the free space manager for this type wasn't started up again */ + HDassert(!H5F_addr_defined(f->shared->fs_addr[type])); + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF__delete_fstype() */ /*------------------------------------------------------------------------- - * Function: H5MF__alloc_close + * Function: H5MF__close_fstype * - * Purpose: Close an existing free space manager of TYPE for file + * Purpose: Close the free space manager of TYPE for file + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * * Return: Success: non-negative * Failure: negative @@ -402,7 +594,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF__alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) +H5MF__close_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) { herr_t ret_value = SUCCEED; /* Return value */ @@ -412,11 +604,18 @@ H5MF__alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) * Check arguments. */ HDassert(f); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); HDassert(f->shared); - HDassert(type != H5FD_MEM_NOLIST); HDassert(f->shared->fs_man[type]); HDassert(f->shared->fs_state[type] != H5F_FS_STATE_CLOSED); +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + /* Close an existing free space structure for the file */ if(H5FS_close(f, dxpl_id, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free space info") @@ -425,7 +624,158 @@ H5MF__alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) done: FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF__alloc_close() */ +} /* end H5MF__close_fstype() */ + + + +/*------------------------------------------------------------------------- + * Function: H5MF_add_sect + * + * Purpose: To add a section to the specified free-space manager. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; April 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5MF_add_sect(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, H5FS_t *fspace, H5MF_free_section_t *node) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + H5MF_sect_ud_t udata; /* User data for callback */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + + HDassert(f); + HDassert(fspace); + HDassert(node); + + H5MF_alloc_to_fs_type(f, alloc_type, node->sect_info.size, &fs_type); + + /* Construct user data for callbacks */ + udata.f = f; + udata.dxpl_id = dxpl_id; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; + udata.allow_eoa_shrink_only = FALSE; + + /* Set the ring type in the DXPL */ + if(H5MF__fsm_is_self_referential(f, fspace)) + fsm_ring = H5AC_RING_MDFSM; + else + fsm_ring = H5AC_RING_RDFSM; + if(H5AC_set_ring(dxpl_id, fsm_ring, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", FUNC, node->sect_info.addr, node->sect_info.size); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + /* Add the section */ + if(H5FS_sect_add(f, dxpl_id, fspace, (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") + +done: + /* Reset the ring in the DXPL */ + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF_add_sect() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_find_sect + * + * Purpose: To find a section from the specified free-space manager to fulfill the request. + * If found, re-add the left-over space back to the manager. + * + * Return: TRUE if a section is found to fulfill the request + * FALSE if not + * + * Programmer: Vailin Choi; April 2013 + * + *------------------------------------------------------------------------- + */ +htri_t +H5MF_find_sect(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size, H5FS_t *fspace, haddr_t *addr) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + H5MF_free_section_t *node; /* Free space section pointer */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + htri_t ret_value = FAIL; /* Whether an existing free list node was found */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + + HDassert(f); + HDassert(fspace); + + /* Set the ring type in the DXPL */ + if(H5MF__fsm_is_self_referential(f, fspace)) + fsm_ring = H5AC_RING_MDFSM; + else + fsm_ring = H5AC_RING_RDFSM; + if(H5AC_set_ring(dxpl_id, fsm_ring, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + + /* Try to get a section from the free space manager */ + if((ret_value = H5FS_sect_find(f, dxpl_id, fspace, size, (H5FS_section_info_t **)&node)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "error locating free space in file") + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Check for actually finding section */ + if(ret_value) { + /* Sanity check */ + HDassert(node); + + /* Retrieve return value */ + if(addr) + *addr = node->sect_info.addr; + + /* Check for eliminating the section */ + if(node->sect_info.size == size) { +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: freeing node\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Free section node */ + if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") + } /* end if */ + else { + /* Adjust information for section */ + node->sect_info.addr += size; + node->sect_info.size -= size; + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %Hu\n", FUNC, node->sect_info.size); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Re-add the section to the free-space manager */ + if(H5MF_add_sect(f, alloc_type, dxpl_id, fspace, node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") + } /* end else */ + } /* end if */ + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF_find_sect() */ /*------------------------------------------------------------------------- @@ -451,7 +801,7 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size) H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5FD_mem_t fs_type; /* Free space type (mapped from allocation type) */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ hbool_t reset_ring = FALSE; /* Whether the ring was set */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ @@ -466,12 +816,20 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(f->shared->lf); HDassert(size > 0); - /* Get free space type from allocation type */ - fs_type = H5MF_ALLOC_TO_FS_TYPE(f, alloc_type); + if(f->shared->first_alloc_dealloc) { + HDassert(! H5AC_cache_image_pending(f)); + if(H5MF_tidy_self_referential_fsm_hack(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "tidy of self referential fsm hack failed") + } /* end if */ + + H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Check 1.0\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG_MORE */ /* Set the ring type in the DXPL */ - if((fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) + if(H5MF__fsm_type_is_self_referential(f, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -481,74 +839,46 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ /* Check if we are using the free space manager for this file */ if(H5F_HAVE_FREE_SPACE_MANAGER(f)) { + /* We are about to change the contents of the free space manager -- + * notify metadata cache that the associated fsm ring is + * unsettled + */ + if(H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, HADDR_UNDEF, "attempt to notify cache that ring is unsettled failed") + /* Check if the free space manager for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) - if(H5MF__alloc_open(f, dxpl_id, fs_type) < 0) + if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) { + /* Open the free-space manager */ + if(H5MF_open_fstype(f, dxpl_id, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, HADDR_UNDEF, "can't initialize file free space") + HDassert(f->shared->fs_man[fs_type]); + } /* end if */ /* Search for large enough space in the free space manager */ - if(f->shared->fs_man[fs_type]) { - H5MF_free_section_t *node; /* Free space section pointer */ - htri_t node_found = FALSE; /* Whether an existing free list node was found */ - - /* Try to get a section from the free space manager */ - if((node_found = H5FS_sect_find(f, dxpl_id, f->shared->fs_man[fs_type], size, (H5FS_section_info_t **)&node)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "error locating free space in file") -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.5, node_found = %t\n", FUNC, node_found); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - - /* Check for actually finding section */ - if(node_found) { - /* Sanity check */ - HDassert(node); - - /* Retrieve return value */ - ret_value = node->sect_info.addr; - - /* Check for eliminating the section */ - if(node->sect_info.size == size) { -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.6, freeing node\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - /* Free section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free simple section node") - } /* end if */ - else { - H5MF_sect_ud_t udata; /* User data for callback */ - - /* Adjust information for section */ - node->sect_info.addr += size; - node->sect_info.size -= size; - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = dxpl_id; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + if(f->shared->fs_man[fs_type]) + if(H5MF_find_sect(f, alloc_type, dxpl_id, size, f->shared->fs_man[fs_type], &ret_value) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "error locating a node") + } /* end if */ + /* If no space is found from the free-space manager, continue further action */ + if(!H5F_addr_defined(ret_value)) { #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.7, re-adding node, node->sect_info.size = %Hu\n", FUNC, node->sect_info.size); +HDfprintf(stderr, "%s: Check 2.0\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - /* Re-insert section node into file's free space */ - if(H5FS_sect_add(f, dxpl_id, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") - } /* end else */ - - /* Leave now */ - HGOTO_DONE(ret_value) - } /* end if */ + if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { + HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); + if(HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, dxpl_id, size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from paged aggregation") } /* end if */ + else { /* For non-paged aggregation, continue further action */ + if(HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, dxpl_id, size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from aggr/vfd") + } /* end else */ + } /* end if */ + HDassert(H5F_addr_defined(ret_value)); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 2.0\n", FUNC); +HDfprintf(stderr, "%s: Check 3.0\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ - - /* Allocate from the metadata aggregator (or the VFD) */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, dxpl_id, size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from aggr/vfd") done: /* Reset the ring in the DXPL */ @@ -568,22 +898,162 @@ H5MF_sects_dump(f, dxpl_id, stderr); /*------------------------------------------------------------------------- - * Function: H5MF_alloc_tmp - * - * Purpose: Allocate temporary space in the file - * - * Note: The address returned is non-overlapping with any other address - * in the file and suitable for insertion into the metadata - * cache. - * - * The address is _not_ suitable for actual file I/O and will - * cause an error if it is so used. - * - * The space allocated with this routine should _not_ be freed, - * it should just be abandoned. Calling H5MF_xfree() with space - * from this routine will cause an error. + * Function: H5MF__alloc_pagefs + * + * Purpose: Allocate space from either the large or small free-space manager. + * For "large" request: + * Allocate request from VFD + * Determine mis-aligned fragment and return the fragment to the + * appropriate manager + * For "small" request: + * Allocate a page from the large manager + * Determine whether space is available from a mis-aligned fragment + * being returned to the manager + * Return left-over space to the manager after fulfilling request * - * Return: Success: Temporary file address + * Return: Success: The file address of new chunk. + * Failure: HADDR_UNDEF + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size) +{ + H5F_mem_page_t ptype; /* Free-space mananger type */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, HADDR_UNDEF) + +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); +#endif /* H5MF_ALLOC_DEBUG */ + + H5MF_alloc_to_fs_type(f, alloc_type, size, &ptype); + + switch(ptype) { + case H5F_MEM_PAGE_GENERIC: + case H5F_MEM_PAGE_LARGE_BTREE: + case H5F_MEM_PAGE_LARGE_DRAW: + case H5F_MEM_PAGE_LARGE_GHEAP: + case H5F_MEM_PAGE_LARGE_LHEAP: + case H5F_MEM_PAGE_LARGE_OHDR: + { + haddr_t eoa; /* EOA for the file */ + hsize_t frag_size = 0; /* Fragment size */ + + /* Get the EOA for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") + HDassert(!(eoa % f->shared->fs_page_size)); + + H5MF_EOA_MISALIGN(f, (eoa+size), f->shared->fs_page_size, frag_size); + + /* Allocate from VFD */ + if(HADDR_UNDEF == (ret_value = H5F_alloc(f, dxpl_id, alloc_type, size + frag_size, NULL, NULL))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* If there is a mis-aligned fragment at EOA */ + if(frag_size) { + + /* Start up the free-space manager */ + if(!(f->shared->fs_man[ptype])) + if(H5MF_start_fstype(f, dxpl_id, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") + + /* Create free space section for the fragment */ + if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") + + /* Add the fragment to the large free-space manager */ + if(H5MF_add_sect(f, alloc_type, dxpl_id, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + + node = NULL; + } /* end if */ + } + break; + + case H5F_MEM_PAGE_META: + case H5F_MEM_PAGE_DRAW: + case H5F_MEM_PAGE_BTREE: + case H5F_MEM_PAGE_GHEAP: + case H5F_MEM_PAGE_LHEAP: + case H5F_MEM_PAGE_OHDR: + { + haddr_t new_page; /* The address for the new file size page */ + + /* Allocate one file space page */ + if(HADDR_UNDEF == (new_page = H5MF_alloc(f, alloc_type, dxpl_id, f->shared->fs_page_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Start up the free-space manager */ + if(!(f->shared->fs_man[ptype])) + if(H5MF_start_fstype(f, dxpl_id, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") + HDassert(f->shared->fs_man[ptype]); + + if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), (f->shared->fs_page_size - size)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") + + /* Add the remaining space in the page to the manager */ + if(H5MF_add_sect(f, alloc_type, dxpl_id, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + + node = NULL; + + /* Insert the new page into the Page Buffer list of new pages so + we don't read an empty page from disk */ + if(f->shared->page_buf != NULL && H5PB_add_new_page(f, alloc_type, new_page) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't add new page to Page Buffer new page list") + + ret_value = new_page; + } + break; + + case H5F_MEM_PAGE_NTYPES: + case H5F_MEM_PAGE_DEFAULT: + default: + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space: unrecognized type") + break; + } /* end switch */ + +done: +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); +#endif /* H5MF_ALLOC_DEBUG */ +#ifdef H5MF_ALLOC_DEBUG_DUMP +H5MF_sects_dump(f, dxpl_id, stderr); +#endif /* H5MF_ALLOC_DEBUG_DUMP */ + + /* Release section node, if allocated and not added to section list or merged */ + if(node) + if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") + + FUNC_LEAVE_NOAPI_TAG(ret_value, HADDR_UNDEF) +} /* end H5MF__alloc_pagefs() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_alloc_tmp + * + * Purpose: Allocate temporary space in the file + * + * Note: The address returned is non-overlapping with any other address + * in the file and suitable for insertion into the metadata + * cache. + * + * The address is _not_ suitable for actual file I/O and will + * cause an error if it is so used. + * + * The space allocated with this routine should _not_ be freed, + * it should just be abandoned. Calling H5MF_xfree() with space + * from this routine will cause an error. + * + * Return: Success: Temporary file address * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol @@ -646,13 +1116,13 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, haddr_t addr, hsize_t size) { H5F_io_info2_t fio_info; /* I/O info for operation */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ H5MF_free_section_t *node = NULL; /* Free space section pointer */ - H5MF_sect_ud_t udata; /* User data for callback */ + unsigned ctype; /* section class type */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t fsm_ring; /* Free space manager ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of fsm */ hbool_t reset_ring = FALSE; /* Whether the ring was set */ - H5FD_mem_t fs_type; /* Free space type (mapped from allocation type) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) @@ -666,19 +1136,16 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HGOTO_DONE(SUCCEED) HDassert(addr != 0); /* Can't deallocate the superblock :-) */ - /* Check for attempting to free space that's a 'temporary' file address */ - if(H5F_addr_le(f->shared->tmp_addr, addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") + if(f->shared->first_alloc_dealloc) { + HDassert(!H5AC_cache_image_pending(f)); + if(H5MF_tidy_self_referential_fsm_hack(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") + } /* end if */ - /* Get free space type from allocation type */ - fs_type = H5MF_ALLOC_TO_FS_TYPE(f, alloc_type); -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: fs_type = %u\n", FUNC, (unsigned)fs_type); -#endif /* H5MF_ALLOC_DEBUG_MORE */ + H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); /* Set the ring type in the DXPL */ - if((fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) + if(H5MF__fsm_type_is_self_referential(f, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -686,6 +1153,19 @@ HDfprintf(stderr, "%s: fs_type = %u\n", FUNC, (unsigned)fs_type); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") reset_ring = TRUE; + /* we are about to change the contents of the free space manager -- + * notify metadata cache that the associated fsm ring is + * unsettled + */ + /* Only do so for strategies that use free-space managers */ + if(H5F_HAVE_FREE_SPACE_MANAGER(f)) + if(H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, FAIL, "attempt to notify cache that ring is unsettled failed") + + /* Check for attempting to free space that's a 'temporary' file address */ + if(H5F_addr_le(f->shared->tmp_addr, addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") + /* Set up I/O info for operation */ fio_info.f = f; if(H5FD_MEM_DRAW == alloc_type) { @@ -712,7 +1192,7 @@ HDfprintf(stderr, "%s: fs_type = %u\n", FUNC, (unsigned)fs_type); * space is at the end of the file */ #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)fs_type, f->shared->fs_addr[fs_type]); +HDfprintf(stderr, "%s: fs_addr = %a\n", FUNC, f->shared->fs_addr[fs_type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) { htri_t status; /* "can absorb" status for section into */ @@ -736,8 +1216,8 @@ HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, a /* If we are deleting the free space manager, leave now, to avoid * [re-]starting it. - * or if file space strategy type is not using a free space manager - * (H5F_FILE_SPACE_AGGR_VFD or H5F_FILE_SPACE_VFD), drop free space + * or if file space strategy type is not using a free space manager + * (H5F_FSPACE_STRATEGY_AGGR or H5F_FSPACE_STRATEGY_NONE), drop free space * section on the floor. * * Note: this drops the space to free on the floor... @@ -755,38 +1235,42 @@ HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, a * space isn't at the end of the file, so start up (or create) * the file space manager */ - if(H5MF__alloc_start(f, dxpl_id, fs_type) < 0) + if(H5MF_start_fstype(f, dxpl_id, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") } /* end if */ - /* Create free space section for block */ - if(NULL == (node = H5MF_sect_simple_new(addr, size))) + /* Create the free-space section for the freed section */ + ctype = H5MF_SECT_CLASS_TYPE(f, size); + if(NULL == (node = H5MF_sect_new(ctype, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = dxpl_id; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; - - /* If size of section freed is larger than threshold, add it to the free space manager */ + /* If size of the freed section is larger than threshold, add it to the free space manager */ if(size >= f->shared->fs_threshold) { HDassert(f->shared->fs_man[fs_type]); #ifdef H5MF_ALLOC_DEBUG_MORE HDfprintf(stderr, "%s: Before H5FS_sect_add()\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ + /* Add to the free space for the file */ - if(H5FS_sect_add(f, dxpl_id, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space") - node = NULL; + if(H5MF_add_sect(f, alloc_type, dxpl_id, f->shared->fs_man[fs_type], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space") + node = NULL; + #ifdef H5MF_ALLOC_DEBUG_MORE HDfprintf(stderr, "%s: After H5FS_sect_add()\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ else { htri_t merged; /* Whether node was merged */ + H5MF_sect_ud_t udata; /* User data for callback */ + + /* Construct user data for callbacks */ + udata.f = f; + udata.dxpl_id = dxpl_id; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; + udata.allow_eoa_shrink_only = FALSE; /* Try to merge the section that is smaller than threshold */ if((merged = H5FS_sect_try_merge(f, dxpl_id, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) @@ -804,7 +1288,7 @@ done: /* Release section node, if allocated and not added to section list or merged */ if(node) - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) + if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG @@ -821,6 +1305,14 @@ H5MF_sects_dump(f, dxpl_id, stderr); * Function: H5MF_try_extend * * Purpose: Extend a block in the file if possible. + * For non-paged aggregation: + * --try to extend at EOA + * --try to extend into the aggregators + * --try to extend into a free-space section if adjoined + * For paged aggregation: + * --try to extend at EOA + * --try to extend into a free-space section if adjoined + * --try to extend into the page end threshold if a metadata block * * Return: Success: TRUE(1) - Block was extended * FALSE(0) - Block could not be extended @@ -835,14 +1327,16 @@ htri_t H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsize_t extra_requested) { - H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t fsm_ring; /* Free space manager ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - haddr_t end; /* End of block to extend */ - H5FD_mem_t fs_type; /* Memory type of the free space manager */ - H5FD_mem_t map_type; /* Mapped type */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ - htri_t ret_value = FAIL; /* Return value */ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* ring of fsm */ + haddr_t end; /* End of block to extend */ + H5FD_mem_t map_type; /* Mapped type */ + H5F_mem_page_t fs_type; /* free space type */ + htri_t allow_extend = TRUE; /* Possible to extend the block */ + hsize_t frag_size = 0; /* Size of mis-aligned fragment */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG @@ -859,12 +1353,33 @@ HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_r /* Compute end of block to extend */ end = addr + size; + /* For paged aggregation: + * To extend a small block: can only extend if not crossing page boundary + * To extend a large block at EOA: calculate in advance mis-aligned fragment so EOA will still end at page boundary + */ + if(H5F_PAGED_AGGR(f)) { + if(size < f->shared->fs_page_size) { + /* To extend a small block: cannot cross page boundary */ + if((addr / f->shared->fs_page_size) != (((end + extra_requested) - 1) / f->shared->fs_page_size)) + allow_extend = FALSE; + } /* end if */ + else { + haddr_t eoa; /* EOA for the file */ + + /* To extend a large block: calculate in advance the mis-aligned fragment so EOA will end at page boundary if extended */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + HDassert(!(eoa % f->shared->fs_page_size)); + + H5MF_EOA_MISALIGN(f, (eoa+extra_requested), f->shared->fs_page_size, frag_size); + } /* end else */ + } /* end if */ + /* Get free space type from allocation type */ - fs_type = H5MF_ALLOC_TO_FS_TYPE(f, alloc_type); + H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); /* Set the ring type in the DXPL */ - if((fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (fs_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) + if(H5MF__fsm_type_is_self_referential(f, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -872,216 +1387,90 @@ HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_r HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") reset_ring = TRUE; - /* Check if the block is exactly at the end of the file */ - if((ret_value = H5FD_try_extend(f->shared->lf, map_type, f, dxpl_id, end, extra_requested)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - else if(ret_value == FALSE) { - H5F_blk_aggr_t *aggr; /* Aggregator to use */ - - /* Check for test block able to extend aggregation block */ - aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); - if((ret_value = H5MF_aggr_try_extend(f, dxpl_id, aggr, map_type, end, extra_requested)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") - else if(ret_value == FALSE) { - - /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) - if(H5MF__alloc_open(f, dxpl_id, fs_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - - /* Check for test block able to block in free space manager */ - if(f->shared->fs_man[fs_type]) - if((ret_value = H5FS_sect_try_extend(f, dxpl_id, f->shared->fs_man[fs_type], addr, size, extra_requested)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") - } /* end if */ - } /* end else-if */ - -done: - /* Reset the ring in the DXPL */ - if(reset_ring) - if(H5AC_reset_ring(dxpl, orig_ring) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") - -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); -#endif /* H5MF_ALLOC_DEBUG */ -#ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, dxpl_id, stderr); -#endif /* H5MF_ALLOC_DEBUG_DUMP */ - - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF_try_extend() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_get_freespace - * - * Purpose: Retrieve the amount of free space in a file. - * - * Return: Success: Amount of free space in file - * Failure: Negative - * - * Programmer: Quincey Koziol - * Monday, October 6, 2003 - * - * Modifications: - * Vailin Choi; July 2012 - * As the default free-list mapping is changed to H5FD_FLMAP_DICHOTOMY, - * checks are added to account for the last section of each free-space manager - * and the remaining space in the two aggregators are at EOF. - *------------------------------------------------------------------------- - */ -herr_t -H5MF_get_freespace(H5F_t *f, hid_t dxpl_id, hsize_t *tot_space, hsize_t *meta_size) -{ - H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for loop iteration */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - haddr_t eoa; /* End of allocated space in the file */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - hsize_t tot_fs_size = 0; /* Amount of all free space managed */ - hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ - H5FD_mem_t type; /* Memory type for iteration */ - hbool_t fs_started[H5FD_MEM_NTYPES]; /* Indicate whether the free-space manager has been started */ - hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) - - /* check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); - - /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - - /* Set the ring type in the DXPL */ - if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") - reset_ring = TRUE; - curr_ring = H5AC_RING_RDFSM; + if(allow_extend) { + /* Try extending the block at EOA */ + if((ret_value = H5F_try_extend(f, dxpl_id, map_type, end, extra_requested + frag_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: extended = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ - /* Retrieve metadata aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + /* If extending at EOA succeeds: */ + /* for paged aggregation, put the fragment into the large-sized free-space manager */ + if(ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { + H5MF_free_section_t *node = NULL; /* Free space section pointer */ - /* Retrieve 'small data' aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + /* Should be large-sized block */ + HDassert(size >= f->shared->fs_page_size); - /* Iterate over all the free space types that have managers and get each free list's space */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + /* Start up the free-space manager */ + if(!(f->shared->fs_man[fs_type])) + if(H5MF_start_fstype(f, dxpl_id, fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - fs_started[type] = FALSE; + /* Create free space section for the fragment */ + if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") - /* test to see if we need to switch rings -- do so if required */ - if((type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; + /* Add the fragment to the large-sized free-space manager */ + if(H5MF_add_sect(f, alloc_type, dxpl_id, f->shared->fs_man[fs_type], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (2)") - curr_ring = needed_ring; + node = NULL; } /* end if */ - /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { - if(H5MF__alloc_open(f, dxpl_id, type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - HDassert(f->shared->fs_man[type]); - fs_started[type] = TRUE; - } /* end if */ + /* For non-paged aggregation: try to extend into the aggregators */ + if(ret_value == FALSE && (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || + f->shared->fs_strategy == H5F_FSPACE_STRATEGY_AGGR) ) { + H5F_blk_aggr_t *aggr; /* Aggregator to use */ - /* Check if there's free space of this type */ - if(f->shared->fs_man[type]) { - hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ - hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ + /* Check if the block is able to extend into aggregation block */ + aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); + if((ret_value = H5MF_aggr_try_extend(f, dxpl_id, aggr, map_type, end, extra_requested)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") - /* Retrieve free space size from free space manager */ - if(H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") - if(H5FS_size(f, f->shared->fs_man[type], &type_meta_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space metadata stats") +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: H5MF_aggr_try_extend = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + } /* end if */ - /* Increment total free space for types */ - tot_fs_size += type_fs_size; - tot_meta_size += type_meta_size; - } /* end if */ - } /* end for */ + /* If no extension so far, try to extend into a free-space section */ + if(ret_value == FALSE && ((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || + (H5F_PAGED_AGGR(f))) ) { + H5MF_sect_ud_t udata; /* User data */ - /* Iterate until no more EOA shrink occurs */ - do { - eoa_shrank = FALSE; + /* Construct user data for callbacks */ + udata.f = f; + udata.dxpl_id = dxpl_id; + udata.alloc_type = alloc_type; - /* Check the last section of each free-space manager */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - haddr_t sect_addr = HADDR_UNDEF; - hsize_t sect_size = 0; - - if(f->shared->fs_man[type]) { - if(H5FS_sect_query_last_sect(f->shared->fs_man[type], §_addr, §_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query last section on merge list") - - /* Deduct space from previous accumulation if the section is at EOA */ - if(H5F_addr_eq(sect_addr + sect_size, eoa)) { - eoa = sect_addr; - eoa_shrank = TRUE; - tot_fs_size -= sect_size; - } /* end if */ - } /* end if */ - } /* end for */ - - /* Check the metadata and raw data aggregators */ - if(ma_size > 0 && H5F_addr_eq(ma_addr + ma_size, eoa)) { - eoa = ma_addr; - eoa_shrank = TRUE; - ma_size = 0; - } /* end if */ - if(sda_size > 0 && H5F_addr_eq(sda_addr + sda_size, eoa)) { - eoa = sda_addr; - eoa_shrank = TRUE; - sda_size = 0; - } /* end if */ - } while(eoa_shrank); + /* Check if the free space for the file has been initialized */ + if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) + /* Open the free-space manager */ + if(H5MF_open_fstype(f, dxpl_id, fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - /* Close the free-space managers if they were opened earlier in this routine */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - if(fs_started[type]) { + /* Try to extend the block into a free-space section */ + if(f->shared->fs_man[fs_type]) { + if((ret_value = H5FS_sect_try_extend(f, dxpl_id, f->shared->fs_man[fs_type], addr, size, extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + } /* end if */ - /* test to see if we need to switch rings -- do so if required */ - if((type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; + /* For paged aggregation and a metadata block: try to extend into page end threshold */ + if(ret_value == FALSE && H5F_PAGED_AGGR(f) && map_type != H5FD_MEM_DRAW) { + H5MF_EOA_MISALIGN(f, end, f->shared->fs_page_size, frag_size); - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (3)") - curr_ring = needed_ring; + if(frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) + ret_value = TRUE; +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Try to extend into the page end threshold = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ - - if(H5MF__alloc_close(f, dxpl_id, type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space") } /* end if */ - } /* end for */ - - /* Set the value(s) to return */ - /* (The metadata & small data aggregators count as free space now, since they aren't at EOA) */ - if(tot_space) - *tot_space = tot_fs_size + ma_size + sda_size; - if(meta_size) - *meta_size = tot_meta_size; + } /* allow_extend */ done: /* Reset the ring in the DXPL */ @@ -1089,8 +1478,15 @@ done: if(H5AC_reset_ring(dxpl, orig_ring) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG */ +#ifdef H5MF_ALLOC_DEBUG_DUMP +H5MF_sects_dump(f, dxpl_id, stderr); +#endif /* H5MF_ALLOC_DEBUG_DUMP */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF_get_freespace() */ +} /* end H5MF_try_extend() */ /*------------------------------------------------------------------------- @@ -1113,9 +1509,15 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, haddr_t addr, { H5MF_free_section_t *node = NULL; /* Free space section pointer */ H5MF_sect_ud_t udata; /* User data for callback */ - htri_t ret_value = FAIL; /* Return value */ + H5FS_section_class_t *sect_cls; /* Section class */ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of fsm */ + H5F_mem_page_t fs_type; /* Free space type */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)alloc_type, addr, size); #endif /* H5MF_ALLOC_DEBUG */ @@ -1127,8 +1529,24 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HDassert(H5F_addr_defined(addr)); HDassert(size > 0); - /* Create free space section for block */ - if(NULL == (node = H5MF_sect_simple_new(addr, size))) + /* Set up free-space section class information */ + sect_cls = H5MF_SECT_CLS_TYPE(f, size); + HDassert(sect_cls); + + /* Get free space type from allocation type */ + H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + + /* Set the ring type in the DXPL */ + if(H5MF__fsm_type_is_self_referential(f, fs_type)) + fsm_ring = H5AC_RING_MDFSM; + else + fsm_ring = H5AC_RING_RDFSM; + if(H5AC_set_ring(dxpl_id, fsm_ring, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + + /* Create free-space section for block */ + if(NULL == (node = H5MF_sect_new(sect_cls->type, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Construct user data for callbacks */ @@ -1136,56 +1554,650 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN udata.dxpl_id = dxpl_id; udata.alloc_type = alloc_type; udata.allow_sect_absorb = FALSE; /* Force section to be absorbed into aggregator */ - udata.allow_eoa_shrink_only = FALSE; - - /* Call the "can shrink" callback for the section */ - if((ret_value = H5MF_sect_simple_can_shrink((const H5FS_section_info_t *)node, &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check if section can shrink container") - else if(ret_value > 0) { - /* Shrink or absorb the section */ - if(H5MF_sect_simple_shrink((H5FS_section_info_t **)&node, &udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink container") + udata.allow_eoa_shrink_only = FALSE; + + /* Check if the block can shrink the container */ + if(sect_cls->can_shrink) { + if((ret_value = (*sect_cls->can_shrink)((const H5FS_section_info_t *)node, &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check if section can shrink container") + if(ret_value > 0) { + HDassert(sect_cls->shrink); + + if((*sect_cls->shrink)((H5FS_section_info_t **)&node, &udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink container") + } /* end if */ } /* end if */ done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") /* Free section node allocated */ - if(node && H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) + if(node && H5MF_sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5MF_try_shrink() */ /*------------------------------------------------------------------------- - * Function: H5MF__close_shrink_eoa + * Function: H5MF_close * - * Purpose: Shrink the EOA while closing + * Purpose: Close the free space tracker(s) for a file: + * paged or non-paged aggregation * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Saturday, July 7, 2012 + * Programmer: Vailin Choi; Dec 2012 * *------------------------------------------------------------------------- */ -static herr_t +herr_t +H5MF_close(H5F_t *f, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Entering\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + HDassert(f->shared); + + if(H5F_PAGED_AGGR(f)) { + if((ret_value = H5MF__close_pagefs(f, dxpl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'page' file space") + } /* end if */ + else { + if((ret_value = H5MF__close_aggrfs(f, dxpl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'aggr' file space") + } /* end else */ + +done: + +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__close_delete_fstype + * + * Purpose: Common code for closing and deleting the freespace manager + * of TYPE for file. + * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi + * Jan 2016 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__close_delete_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Entering\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + HDassert(f->shared); + if(H5F_PAGED_AGGR(f)) + HDassert(type < H5F_MEM_PAGE_NTYPES); + else + HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* If the free space manager for this type is open, close it */ + if(f->shared->fs_man[type]) + if(H5MF__close_fstype(f, dxpl_id, type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* If there is free space manager info for this type, delete it */ + if(H5F_addr_defined(f->shared->fs_addr[type])) + if(H5MF__delete_fstype(f, dxpl_id, type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't delete the free space manager") + +done: +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* H5MF__close_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_try_close + * + * Purpose: This is called by H5Fformat_convert() to close and delete + * free-space managers when downgrading persistent free-space + * to non-persistent. + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi + * Jan 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +H5MF_try_close(H5F_t *f, hid_t dxpl_id) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Entering\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + + /* If there have been no file space allocations / deallocation so + * far, must call H5MF_tidy_self_referential_fsm_hack() to float + * all self referential FSMs and release file space allocated to + * them. Otherwise, the function will be called after the format + * conversion, and will become very confused. + * + * The situation is further complicated if a cache image exists + * and had not yet been loaded into the metadata cache. In this + * case, call H5AC_force_cache_image_load() instead of + * H5MF_tidy_self_referential_fsm_hack(). H5AC_force_cache_image_load() + * will load the cache image, and then call + * H5MF_tidy_self_referential_fsm_hack() to discard the cache image + * block. + */ + if(f->shared->first_alloc_dealloc) { + if(H5AC_cache_image_pending(f)) { + if(H5AC_force_cache_image_load(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "forced cache image load failed") + } /* end if */ + else { + if(H5MF_tidy_self_referential_fsm_hack(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") + } /* end else */ + } /* end if */ + + /* Set the ring type in the DXPL. In most cases, we will + * need H5AC_RING_RDFSM, so initialy set the ring in + * the DXPL to that value. We will alter this later if + * needed. + */ + if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + curr_ring = H5AC_RING_RDFSM; + + if(H5F_PAGED_AGGR(f)) { + H5F_mem_page_t ptype; /* Memory type for iteration */ + + /* Iterate over all the free space types that have managers and + * get each free list's space + */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) { + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, ptype)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring ) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ + + if(H5MF__close_delete_fstype(f, dxpl_id, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") + } /* end for */ + } /* end if */ + else { + H5FD_mem_t type; /* Memory type for iteration */ + + /* Iterate over all the free space types that have managers and + * get each free list's space + */ + for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + /* test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + curr_ring = needed_ring; + } /* end if */ + + if(H5MF__close_delete_fstype(f, dxpl_id, (H5F_mem_page_t)type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") + } /* end for */ + } /* end else */ + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* H5MF_try_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__close_aggrfs + * + * Purpose: Close the free space tracker(s) for a file: non-paged aggregation + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Tuesday, January 22, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__close_aggrfs(H5F_t *f, hid_t dxpl_id) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5FD_mem_t type; /* Memory type for iteration */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Entering\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(f->shared->sblock); + + /* Set the ring type in the DXPL. In most cases, we will + * need H5AC_RING_RDFSM, so initialy set the ring in + * the DXPL to that value. We will alter this later if + * needed. + */ + if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + curr_ring = H5AC_RING_RDFSM; + + /* Free the space in aggregators */ + /* (for space not at EOA, it may be put into free space managers) */ + if(H5MF_free_aggrs(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") + + /* Trying shrinking the EOA for the file */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + + /* Making free-space managers persistent for superblock version >= 2 */ + if(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 + && f->shared->fs_persist) { + H5O_fsinfo_t fsinfo; /* File space info message */ + haddr_t final_eoa; /* Final eoa -- for sanity check */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + + /* superblock extension and free space manager message should + * exist at this point -- verify at least the former. + */ + HDassert(H5F_addr_defined(f->shared->sblock->ext_addr)); + + /* file space for all non-empty free space managers should be + * allocated at this point, and these free space managers should + * be written to file and thus their headers and section info + * entries in the metadata cache should be clean. + */ + + /* gather data for the free space manager superblock extension message. + * + * In passing, verify that all the free space managers are closed. + */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; + for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) + fsinfo.fs_addr[type-1] = f->shared->fs_addr[type]; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_pre_fsm_fsalloc; + + /* Write the free space manager message -- message must already exist */ + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + + /* Close the free space managers */ + for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + if(f->shared->fs_man[type]) { + /* test to see if we need to switch rings -- do + * so if required + */ + if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ + + HDassert(f->shared->fs_state[type] == H5F_FS_STATE_OPEN); + + if(H5FS_close(f, dxpl_id, f->shared->fs_man[type]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") + f->shared->fs_man[type] = NULL; + f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; + } /* end if */ + f->shared->fs_addr[type] = HADDR_UNDEF; + } /* end for */ + + /* verify that we haven't dirtied any metadata cache entries + * from the metadata free space manager ring out. + */ + HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); + + /* verify that the aggregators are still shutdown. */ + HDassert(f->shared->sdata_aggr.tot_size == 0); + HDassert(f->shared->sdata_aggr.addr == 0); + HDassert(f->shared->sdata_aggr.size == 0); + + HDassert(f->shared->meta_aggr.tot_size == 0); + HDassert(f->shared->meta_aggr.addr == 0); + HDassert(f->shared->meta_aggr.size == 0); + + /* Trying shrinking the EOA for the file */ + /* (in case any free space is now at the EOA) */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + + /* get the eoa, and verify that it has the expected value */ + if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + + /* f->shared->eoa_post_fsm_fsalloc is undefined if there has + * been no file space allocation or deallocation since file + * open. + */ + HDassert((f->shared->first_alloc_dealloc) || (final_eoa == f->shared->eoa_post_fsm_fsalloc)); + } /* end if */ + else { /* super_vers can be 0, 1, 2 */ + for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) + if(H5MF__close_delete_fstype(f, dxpl_id, (H5F_mem_page_t)type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") + } /* end else */ + + /* Free the space in aggregators (again) */ + /* (in case any free space information re-started them) */ + if(H5MF_free_aggrs(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") + + /* Trying shrinking the EOA for the file */ + /* (in case any free space is now at the EOA) */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF__close_aggrfs() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__close_pagefs + * + * Purpose: Close the free space tracker(s) for a file: paged aggregation + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__close_pagefs(H5F_t *f, hid_t dxpl_id) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* ring value needed for this + * iteration. + */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + H5O_fsinfo_t fsinfo; /* File space info message */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Entering\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(f->shared->sblock); + HDassert(f->shared->fs_page_size); + HDassert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); + + /* Set the ring type in the DXPL. In most cases, we will + * need H5AC_RING_RDFSM, so initialy set the ring in + * the DXPL to that value. We will alter this later if + * needed. + */ + if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + curr_ring = H5AC_RING_RDFSM; + + /* Trying shrinking the EOA for the file */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + + /* Set up file space info message */ + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; + + if(f->shared->fs_persist) { + haddr_t final_eoa; /* final eoa -- for sanity check */ + + /* superblock extension and free space manager message should + * exist at this point -- verify at least the former. + */ + HDassert(H5F_addr_defined(f->shared->sblock->ext_addr)); + + /* file space for all non-empty free space managers should be + * allocated at this point, and these free space managers should + * be written to file and thus their headers and section info + * entries in the metadata cache should be clean. + */ + + /* gather data for the free space manager superblock extension message. + * Only need addresses of FSMs and eoa prior to allocation of + * file space for the self referential free space managers. Other + * data was gathered above. + */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + fsinfo.fs_addr[ptype-1] = f->shared->fs_addr[ptype]; + fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_pre_fsm_fsalloc; + + /* Write the free space manager message -- message must already exist */ + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + + /* Close the free space managers */ + /* use H5MF__close_fstype() for this? */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) { + if(f->shared->fs_man[ptype]) { + /* test to see if we need to switch rings -- do + * so if required + */ + if(H5MF__fsm_type_is_self_referential(f, ptype)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ + + HDassert(f->shared->fs_state[ptype] == H5F_FS_STATE_OPEN); + + if(H5FS_close(f, dxpl_id, f->shared->fs_man[ptype]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") + f->shared->fs_man[ptype] = NULL; + f->shared->fs_state[ptype] = H5F_FS_STATE_CLOSED; + } /* end if */ + f->shared->fs_addr[ptype] = HADDR_UNDEF; + } /* end for */ + + /* verify that we haven't dirtied any metadata cache entries + * from the metadata free space manager ring out. + */ + HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); + + /* Trying shrinking the EOA for the file */ + /* (in case any free space is now at the EOA) */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + + /* get the eoa, and verify that it has the expected value */ + if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + + /* f->shared->eoa_post_fsm_fsalloc is undefined if there has + * been no file space allocation or deallocation since file + * open. + * + * If there is a cache image in the file at file open, + * f->shared->first_alloc_dealloc will always be FALSE unless + * the file is opened R/O, as otherwise, the image will have been + * read and discarded by this point. + * + * If a cache image was created on file close, the actual EOA + * should be in f->shared->eoa_post_mdci_fsalloc. Note that in + * this case, it is conceivable that f->shared->first_alloc_dealloc + * will still be TRUE, as the cache image is allocated directly from + * the file driver layer. However, as this possibility seems remote, + * it is ignored in the following assert. + */ + HDassert((f->shared->first_alloc_dealloc) || + (final_eoa == f->shared->eoa_post_fsm_fsalloc) || + ((H5F_addr_defined(f->shared->eoa_post_mdci_fsalloc)) && + (final_eoa == f->shared->eoa_post_mdci_fsalloc))); + } /* end if */ + else { + /* Iterate over all the free space types that have managers + * and get each free list's space + */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + if(H5MF__close_delete_fstype(f, dxpl_id, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") + + /* Write file space info message to superblock extension object header */ + /* Create the superblock extension object header in advance if needed */ + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + } /* end else */ + + /* Trying shrinking the EOA for the file */ + /* (in case any free space is now at the EOA) */ + if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: Leaving\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG */ + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF__close_pagefs() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__close_shrink_eoa + * + * Purpose: Shrink the EOA while closing + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Saturday, July 7, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t H5MF__close_shrink_eoa(H5F_t *f, hid_t dxpl_id) { - H5FD_mem_t type; /* Memory type for iteration */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* ring value needed for this - * iteration. - */ + H5F_mem_t type; + H5F_mem_page_t ptype; /* Memory type for iteration */ hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ htri_t status; /* Status value */ H5MF_sect_ud_t udata; /* User data for callback */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) @@ -1197,53 +2209,367 @@ H5MF__close_shrink_eoa(H5F_t *f, hid_t dxpl_id) /* Construct user data for callbacks */ udata.f = f; udata.dxpl_id = dxpl_id; - udata.allow_sect_absorb = FALSE; - udata.allow_eoa_shrink_only = TRUE; + udata.allow_sect_absorb = FALSE; + udata.allow_eoa_shrink_only = TRUE; - /* Set the ring type in the DXPL. In most cases, we will - * need H5AC_RING_RDFSM, so initialy set the ring type in - * the DXPL to that value. We will alter this later if needed. - */ + /* Set the ring type in the DXPL */ if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value(1)") reset_ring = TRUE; curr_ring = H5AC_RING_RDFSM; - /* Iterate until no more EOA shrinking occurs */ - do { - eoa_shrank = FALSE; + /* Iterate until no more EOA shrinking occurs */ + do { + eoa_shrank = FALSE; + + if(H5F_PAGED_AGGR(f)) { + /* Check the last section of each free-space manager */ + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) { + if(f->shared->fs_man[ptype]) { + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, ptype)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ + + udata.alloc_type = (H5FD_mem_t)((H5FD_mem_t)ptype < H5FD_MEM_NTYPES ? ptype : ((ptype % H5FD_MEM_NTYPES) + 1)); + + if((status = H5FS_sect_try_shrink_eoa(f, dxpl_id, f->shared->fs_man[ptype], &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + else if(status > 0) + eoa_shrank = TRUE; + } /* end if */ + } /* end for */ + } /* end if */ + else { + /* Check the last section of each free-space manager */ + for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + if(f->shared->fs_man[type]) { + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ + + udata.alloc_type = type; + + if((status = H5FS_sect_try_shrink_eoa(f, dxpl_id, f->shared->fs_man[type], &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + else if(status > 0) + eoa_shrank = TRUE; + } /* end if */ + } /* end for */ + + /* check the two aggregators */ + if((status = H5MF_aggrs_try_shrink_eoa(f, dxpl_id)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + else if(status > 0) + eoa_shrank = TRUE; + } /* end else */ + } while(eoa_shrank); + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF__close_shrink_eoa() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_get_freespace + * + * Purpose: Retrieve the amount of free space in the file + * + * Return: Success: Amount of free space in file + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, October 6, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5MF_get_freespace(H5F_t *f, hid_t dxpl_id, hsize_t *tot_space, hsize_t *meta_size) +{ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + hsize_t tot_fs_size = 0; /* Amount of all free space managed */ + hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ + H5FD_mem_t tt; /* Memory type for iteration */ + H5F_mem_page_t type; /* Memory type for iteration */ + H5F_mem_page_t start_type; /* Memory type for iteration */ + H5F_mem_page_t end_type; /* Memory type for iteration */ + htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ + haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + + /* Set the ring type in the DXPL. In most cases, we will + * need H5AC_RING_RDFSM, so initialy set the ring in + * the DXPL to that value. We will alter this later if + * needed. + */ + if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + reset_ring = TRUE; + curr_ring = H5AC_RING_RDFSM; + + /* Determine start/end points for loop */ + if(H5F_PAGED_AGGR(f)) { + start_type = H5F_MEM_PAGE_META; + end_type = H5F_MEM_PAGE_NTYPES; + } /* end if */ + else { + start_type = (H5F_mem_page_t)H5FD_MEM_SUPER; + end_type = (H5F_mem_page_t)H5FD_MEM_NTYPES; + } /* end else */ + + for(tt = H5FD_MEM_SUPER; tt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, tt)) + if(HADDR_UNDEF == (fs_eoa[tt] = H5F_get_eoa(f, tt))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + if(!H5F_PAGED_AGGR(f)) { + /* Retrieve metadata aggregator info, if available */ + if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + + /* Retrieve 'small data' aggregator info, if available */ + if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + } /* end if */ + + /* Iterate over all the free space types that have managers and get each free list's space */ + for(type = start_type; type < end_type; H5_INC_ENUM(H5F_mem_page_t, type)) { + fs_started[type] = FALSE; + + /* Check if the free space for the file has been initialized */ + if(!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { + if(H5MF_open_fstype(f, dxpl_id, type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") + HDassert(f->shared->fs_man[type]); + fs_started[type] = TRUE; + } /* end if */ + + /* test to see if we need to switch rings -- do + * so if required + */ + if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + curr_ring = needed_ring; + } /* end if */ + + /* Check if there's free space of this type */ + if(f->shared->fs_man[type]) { + hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ + hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ + + /* Retrieve free space size from free space manager */ + if(H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") + if(H5FS_size(f, f->shared->fs_man[type], &type_meta_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space metadata stats") + + /* Increment total free space for types */ + tot_fs_size += type_fs_size; + tot_meta_size += type_meta_size; + } /* end if */ + } /* end for */ + + /* Close the free-space managers if they were opened earlier in this routine */ + for(type = start_type; type < end_type; H5_INC_ENUM(H5F_mem_page_t, type)) { + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + curr_ring = needed_ring; + } /* end if */ + + if(fs_started[type]) + if(H5MF__close_fstype(f, dxpl_id, type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space") + } /* end for */ + + /* Set the value(s) to return */ + /* (The metadata & small data aggregators count as free space now, since they aren't at EOA) */ + if(tot_space) + *tot_space = tot_fs_size + ma_size + sda_size; + if(meta_size) + *meta_size = tot_meta_size; + +done: + /* Reset the ring in the DXPL */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5MF_get_freespace() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_get_free_sections() + * + * Purpose: To retrieve free-space section information for + * paged or non-paged aggregation + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5MF_get_free_sections(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) +{ + H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + size_t total_sects = 0; /* Total number of sections */ + H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ + H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ + H5F_mem_page_t ty; /* Memory type for iteration */ + hbool_t reset_ring = FALSE; /* Whether the ring was set */ + ssize_t ret_value = -1; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, -1) + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + + /* H5MF_tidy_self_referential_fsm_hack() will fail if any self + * referential FSM is opened prior to the call to it. Thus call + * it here if necessary and if it hasn't been called already. + * + * The situation is further complicated if a cache image exists + * and had not yet been loaded into the metadata cache. In this + * case, call H5AC_force_cache_image_load() instead of + * H5MF_tidy_self_referential_fsm_hack(). H5AC_force_cache_image_load() + * will load the cache image, and then call + * H5MF_tidy_self_referential_fsm_hack() to discard the cache image + * block. + */ + if(f->shared->first_alloc_dealloc) { + if(H5AC_cache_image_pending(f)) { + if(H5AC_force_cache_image_load(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "forced cache image load failed") + } /* end if */ + else { + if(H5MF_tidy_self_referential_fsm_hack(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") + } /* end else */ + } /* end if */ + + if(type == H5FD_MEM_DEFAULT) { + start_type = H5F_MEM_PAGE_SUPER; + end_type = H5F_MEM_PAGE_NTYPES; + } /* end if */ + else { + start_type = end_type = (H5F_mem_page_t)type; + if(H5F_PAGED_AGGR(f)) /* set to the corresponding LARGE free-space manager */ + end_type = (H5F_mem_page_t)(end_type + H5FD_MEM_NTYPES); + else + H5_INC_ENUM(H5F_mem_page_t, end_type); + } /* end else */ + + /* Set up user data for section iteration */ + sect_udata.sects = sect_info; + sect_udata.sect_count = nsects; + sect_udata.sect_idx = 0; + + /* Set the ring type in the DXPL. In most cases, we will + * need H5AC_RING_RDFSM, so initialy set the ring in + * the DXPL to that value. We will alter this later if + * needed. + */ + if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value(0)") + reset_ring = TRUE; + curr_ring = H5AC_RING_RDFSM; + + /* Iterate over memory types, retrieving the number of sections of each type */ + for(ty = start_type; ty < end_type; H5_INC_ENUM(H5F_mem_page_t, ty)) { + hbool_t fs_started = FALSE; /* The free-space manager is opened or not */ + size_t nums = 0; /* The number of free-space sections */ + + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, ty)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (1)") + curr_ring = needed_ring; + } /* end if */ - /* Check the last section of each free-space manager */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + if(!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { + if(H5MF_open_fstype(f, dxpl_id, ty) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't open the free space manager") + HDassert(f->shared->fs_man[ty]); + fs_started = TRUE; + } /* end if */ - /* test to see if we need to switch rings -- do so if required */ - if((H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; + /* Check if there's free space sections of this type */ + if(f->shared->fs_man[ty]) + if(H5MF__get_free_sects(f, dxpl_id, f->shared->fs_man[ty], §_udata, &nums) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get section info for the free space manager") - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (2)") - curr_ring = needed_ring; - } /* end if */ + /* Increment total # of sections */ + total_sects += nums; - if(f->shared->fs_man[type]) { - udata.alloc_type = type; - if((status = H5FS_sect_try_shrink_eoa(f, dxpl_id, f->shared->fs_man[type], &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) - eoa_shrank = TRUE; - } /* end if */ - } /* end for */ + /* Close the free space manager of this type, if we started it here */ + if(fs_started) + if(H5MF__close_fstype(f, dxpl_id, ty) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, FAIL, "can't close file free space") + if((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) + ty = (H5F_mem_page_t)(ty + H5FD_MEM_NTYPES - 2); + } /* end for */ - /* check the two aggregators */ - if((status = H5MF_aggrs_try_shrink_eoa(f, dxpl_id)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) - eoa_shrank = TRUE; - } while(eoa_shrank); + /* Set return value */ + ret_value = (ssize_t)total_sects; done: /* Reset the ring in the DXPL */ @@ -1251,8 +2577,81 @@ done: if(H5AC_reset_ring(dxpl, orig_ring) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF__close_shrink_eoa() */ + FUNC_LEAVE_NOAPI_TAG(ret_value, -1) +} /* H5MF_get_free_sections() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sects_cb() + * + * Purpose: Iterator callback for each free-space section + * Retrieve address and size into user data + * + * Return: Always succeed + * + * Programmer: Vailin Choi + * July 1st, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF_sects_cb(H5FS_section_info_t *_sect, void *_udata) +{ + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; + H5MF_sect_iter_ud_t *udata = (H5MF_sect_iter_ud_t *)_udata; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(udata->sect_idx < udata->sect_count) { + udata->sects[udata->sect_idx].addr = sect->sect_info.addr; + udata->sects[udata->sect_idx].size = sect->sect_info.size; + udata->sect_idx++; + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5MF_sects_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF__get_free_sects + * + * Purpose: Retrieve section information for the specified free-space manager. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__get_free_sects(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums) +{ + hsize_t hnums = 0; /* # of sections */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(f); + HDassert(sect_udata); + HDassert(nums); + HDassert(fspace); + + /* Query how many sections of this type */ + if(H5FS_sect_stats(fspace, NULL, &hnums) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") + H5_CHECKED_ASSIGN(*nums, size_t, hnums, hsize_t); + + /* Check if we should retrieve the section info */ + if(sect_udata->sects && *nums > 0) + /* Iterate over all the free space sections of this type, adding them to the user's section info */ + if(H5FS_sect_iterate(f, dxpl_id, fspace, H5MF_sects_cb, sect_udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't iterate over sections") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF__get_free_sects() */ /*------------------------------------------------------------------------- @@ -1263,19 +2662,48 @@ done: * and any metadata free space managers that reside in the * raw data free space manager ring. * - * Specifically, any metadata managers that DON'T handle - * space allocation for free space manager header or section - * info will reside in the raw data free space manager ring. - * As of this writing, the plan is to move to only two free space - * managers, one for raw data and one for metadata -- which - * means that only the raw data free space manager will reside - * in the free space manager ring. However, this has not been - * fully implemented yet, so this code must support the - * possibilty of multiple metadata free space managers, at most - * two of which handle free space manager header or section info, - * and thus reside in the metadata free space manager ring. - * - * At present, the task list is: + * Specifically, this means any metadata managers that DON'T + * handle space allocation for free space manager header or + * section info will reside in the raw data free space manager + * ring. + * + * In the absence of page allocation, there is at most one + * free space manager per memory type defined in H5F_mem_t. + * Of these, the one that allocates H5FD_MEM_DRAW will + * always reside in the raw data free space manager ring. + * If there is more than one metadata free space manager, + * all that don't handle H5FD_MEM_FSPACE_HDR or + * H5FD_MEM_FSPACE_SINFO (which map to H5FD_MEM_OHDR and + * H5FD_MEM_LHEAP respectively) will reside in the raw + * data free space manager ring as well + * + * With page allocation, the situation is conceptually + * identical, but more complex in practice. + * + * In the worst case (multi file driver) page allocation + * can result in two free space managers for each memory + * type -- one for small (less than on equal to one page) + * allocations, and one for large (greater than one page) + * allocations. + * + * In the more common one file case, page allocation will + * result in a total of three free space managers -- one for + * small (<= one page) raw data allocations, one for small + * metadata allocations (i.e, all memory types other than + * H5FD_MEM_DRAW), and one for all large (> one page) + * allocations. + * + * Despite these complications, the solution is the same in + * the page allocation case -- free space managers (be they + * small data or large) are assigned to the raw data free + * space manager ring if they don't allocate file space for + * free space managers. Note that in the one file case, the + * large free space manager must be assigned to the metadata + * free space manager ring, as it both allocates pages for + * the metadata free space manager, and allocates space for + * large (> 1 page) metadata cache entries. + * + * At present, the task list for this routine is: * * 1) Reduce the EOA to the extent possible. To do this: * @@ -1330,26 +2758,43 @@ done: herr_t H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) { + int pass_count; + hsize_t alloc_size; + H5F_mem_t mem_type; /* Memory type for iteration */ + H5F_mem_page_t fsm_type; /* FSM type for iteration */ + H5O_fsinfo_t fsinfo; /* Free space manager info message */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ hbool_t reset_ring = FALSE; /* Whether the ring was set */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) - /* check args */ + /* Check args */ HDassert(f); HDassert(f->shared); HDassert(fsm_settled); - /* Only need to settle things if we are persisting the free space info */ - if(f->shared->fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) { - H5O_fsinfo_t fsinfo; /* Free space manager info message */ - H5FD_mem_t type; /* Memory type for iteration */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ - hbool_t fsm_opened[H5FD_MEM_NTYPES]; /* State of FSM */ - hbool_t fsm_visited[H5FD_MEM_NTYPES]; /* State of FSM */ + /* Only need to settle things if we are persisting the free space info + * and allocation/deallocation has occurred. + */ + if(f->shared->fs_persist && !f->shared->first_alloc_dealloc) { + hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ + hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ + + /* Sanity check */ + HDassert(f->shared->sblock); + + /* should only be called if file is opened R/W */ + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + + /* shouldn't be called unless we have a superblock supporting the + * superblock extension. + */ + HDassert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); /* Initialize fsm_opened and fsm_visited */ HDmemset(fsm_opened, 0, sizeof(fsm_opened)); @@ -1366,8 +2811,12 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) * * Note that while the raw data aggregator should not be restarted during * the close process, this need not be the case for the metadata aggregator. + * + * Note also that the aggregators will not exist if page aggregation + * is enabled -- skip this if so. */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) + /* Vailin -- is this correct? */ + if(!H5F_PAGED_AGGR(f) && (H5MF_free_aggrs(f, dxpl_id) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Set the ring type in the DXPL. In most cases, we will @@ -1389,7 +2838,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) * In the case of the raw data free space manager, and any other free * space manager that does not allocate space for free space managers, * allocations should be complete at this point, as all raw data should - * have space allocated and be flushed to file at this point. Thus we + * have space allocated and be flushed to file by now. Thus we * can examine such free space managers and only re-allocate space for * them if they contain free space. Do this later in this function after * the EOA has been reduced to the extent possible. @@ -1400,79 +2849,100 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) * are possible), the matter is more ticklish due to the self- * referential nature of the problem. These FSMs are dealt with in * H5MF_settle_meta_data_fsm(). + * + * Since paged allocation may be enabled, there may be up to two + * free space managers per memory type -- one for small and one for + * large allocation. Hence we must loop over the memory types twice + * setting the allocation size accordingly if paged allocation is + * enabled. */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - H5FS_stat_t fs_stat; /* Information for free-space manager */ - H5FD_mem_t fsm_type; /* File memory type for FSM */ - - /* There is potentially a many-to-one mapping from memory types to - * free space managers. Use the fsm_visited[] array to avoid visiting - * a given FSM more than once. Use fsm_opened[] to track which FSMs - * must be closed at the end of this function. - */ - fsm_type = H5MF_ALLOC_TO_FS_TYPE(f, type); - if(!fsm_visited[fsm_type]) { - fsm_visited[fsm_type] = TRUE; - - /* If there is no active FSM for this type, but such a FSM has - * space allocated in file, open it so that we can free its file - * space. - */ - if(NULL == f->shared->fs_man[fsm_type]) { - if(H5F_addr_defined(f->shared->fs_addr[fsm_type])) { - /* Sanity check */ - HDassert(fsm_opened[fsm_type] == FALSE); - - /* Start up FSM for the file memory type */ - if(H5MF__alloc_open(f, dxpl_id, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - fsm_opened[fsm_type] = TRUE; - } /* end if */ + for(pass_count = 0; pass_count <= 1; pass_count++) { + if(pass_count == 0) + alloc_size = 1; + else if ( H5F_PAGED_AGGR(f) ) + alloc_size = f->shared->fs_page_size + 1; + else /* no need for a second pass */ + break; + + for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5F_mem_t, mem_type)) { + H5MF_alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + + if(pass_count == 0) { /* this is the first pass */ + HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); + HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); } /* end if */ + else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ + HDassert(FALSE); + + if(!fsm_visited[fsm_type]) { + fsm_visited[fsm_type] = TRUE; + + /* If there is no active FSM for this type, but such a FSM has + * space allocated in file, open it so that we can free its file + * space. + */ + if(NULL == f->shared->fs_man[fsm_type]) { + if(H5F_addr_defined(f->shared->fs_addr[fsm_type])) { + /* Sanity check */ + HDassert(fsm_opened[fsm_type] == FALSE); - /* Check for an actual FSM for this type now */ - /* (Possibly opened in previous step) */ - if(f->shared->fs_man[fsm_type]) { - /* Test to see if we need to switch rings -- do so if required */ - if((fsm_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (fsm_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") - curr_ring = needed_ring; + if(H5MF_open_fstype(f, dxpl_id, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") + fsm_opened[fsm_type] = TRUE; + } /* end if */ } /* end if */ - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + if(f->shared->fs_man[fsm_type]) { + /* Test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, fsm_type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; + + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + curr_ring = needed_ring; + } /* end if */ - /* Check if the free space manager has space in the file */ - if(H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { - /* Delete the free space manager in the file. Will - * reallocate later if the free space manager contains - * any free space. - */ - if(H5FS_free(f, f->shared->fs_man[fsm_type], dxpl_id) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") - f->shared->fs_addr[fsm_type] = HADDR_UNDEF; + /* Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + + /* Check if the free space manager has space in the file */ + if(H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { + /* Delete the free space manager in the file. Will + * reallocate later if the free space manager contains + * any free space. + */ + if(H5FS_free(f, f->shared->fs_man[fsm_type], dxpl_id, TRUE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") + f->shared->fs_addr[fsm_type] = HADDR_UNDEF; + } /* end if */ } /* end if */ - } /* end if */ - /* note that we are tracking opened FSM -- we will close them - * at the end of the function. - */ - } /* end if */ + /* note that we are tracking opened FSM -- we will close them + * at the end of the function. + */ + } /* end if */ + } /* end for */ } /* end for */ + /* c) Delete the free space manager superblock extension message * if allocated. * * Must do this since the routine that writes / creates superblock * extension messages will choke if the target message is * unexpectedly either absent or present. + * + * Update: This is probably unecessary, as I gather that the + * file space manager info message is guaranteed to exist. + * Leave it in for now, but consider removing it. */ if(H5F_addr_defined(f->shared->sblock->ext_addr)) if(H5F_super_ext_remove_msg(f, dxpl_id, H5O_FSINFO_ID) < 0) @@ -1496,11 +2966,16 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) * those addresses are unknown. This is OK -- we will write the correct * values to the message at free space manager shutdown. */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - fsinfo.fs_addr[type - 1] = HADDR_UNDEF; + for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, fsm_type)) + fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; fsinfo.threshold = f->shared->fs_threshold; - if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_NO_FLAGS_SET) < 0) + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; + + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") @@ -1524,102 +2999,117 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) */ /* Reinitialize fsm_visited */ - HDmemset(fsm_visited, 0, sizeof(fsm_visited)); - - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - H5FD_mem_t fsm_type; /* File memory type for FSM */ - - fsm_type = H5MF_ALLOC_TO_FS_TYPE(f, type); - - /* test to see if we need to switch rings -- do so if required */ - if((fsm_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (fsm_type == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; - - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring)< 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") - curr_ring = needed_ring; - } /* end if */ - - /* Since there can be a many-to-one mapping from memory types - * to free space managers, ensure that we don't visit any FSM - * more than once. - */ - if(!fsm_visited[fsm_type]) { - fsm_visited[fsm_type] = TRUE; - - if(f->shared->fs_man[fsm_type]) { - /* Only allocate file space if the target free space manager - * doesn't allocate file space for free space managers. Note - * that this is also the deciding factor as to whether a FSM - * in in the raw data FSM ring. - */ - if((fsm_type != H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - && (fsm_type != H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) { - H5FS_stat_t fs_stat; /* Information for free-space manager */ + for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, fsm_type)) + fsm_visited[fsm_type] = FALSE; + + for(pass_count = 0; pass_count <= 1; pass_count++) { + if(pass_count == 0) + alloc_size = 1; + else if(H5F_PAGED_AGGR(f)) + alloc_size = f->shared->fs_page_size + 1; + else /* no need for a second pass */ + break; + + for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5F_mem_t, mem_type)) { + H5MF_alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + + if(pass_count == 0) { /* this is the first pass */ + HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); + HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); + } /* end if */ + else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ + HDassert(FALSE); - /* The current ring should be H5AC_RING_RDFSM */ - HDassert(curr_ring == H5AC_RING_RDFSM); + /* test to see if we need to switch rings -- do so if required */ + if(H5MF__fsm_type_is_self_referential(f, fsm_type)) + needed_ring = H5AC_RING_MDFSM; + else + needed_ring = H5AC_RING_RDFSM; - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0 ) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") + if(needed_ring != curr_ring) { + if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring)< 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") + curr_ring = needed_ring; + } /* end if */ - /* If the free space manager contains section info, - * allocate space for the header and sinfo (note that - * space must not be allocated at present -- verify - * verify this with assertions). + /* Since there can be a many-to-one mapping from memory types + * to free space managers, ensure that we don't visit any FSM + * more than once. + */ + if(!fsm_visited[fsm_type]) { + fsm_visited[fsm_type] = TRUE; + + if(f->shared->fs_man[fsm_type]) { + /* Only allocate file space if the target free space manager + * doesn't allocate file space for free space managers. Note + * that this is also the deciding factor as to whether a FSM + * in in the raw data FSM ring. */ - if(fs_stat.serial_sect_count > 0) { - /* Sanity check */ - HDassert(!H5F_addr_defined(fs_stat.addr)); - - /* Allocate FSM header */ - if(H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], &f->shared->fs_addr[fsm_type], dxpl_id) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocated free-space header") - - /* Allocate FSM section info */ - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.alloc_sect_size == 0); - if(H5FS_alloc_sect(f, f->shared->fs_man[fsm_type], dxpl_id) < 0 ) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate free-space section info") + if(!H5MF__fsm_type_is_self_referential(f, fsm_type)) { + /* The current ring should be H5AC_RING_RDFSM */ + HDassert(curr_ring == H5AC_RING_RDFSM); + + /* Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0 ) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") + + /* If the free space manager contains section info, + * allocate space for the header and sinfo (note that + * space must not be allocated at present -- verify + * verify this with assertions). + */ + if(fs_stat.serial_sect_count > 0) { + /* Sanity check */ + HDassert(!H5F_addr_defined(fs_stat.addr)); + + /* Allocate FSM header */ + if(H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], &f->shared->fs_addr[fsm_type], dxpl_id) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocated free-space header") + + /* Allocate FSM section info */ + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + if(H5FS_alloc_sect(f, f->shared->fs_man[fsm_type], dxpl_id) < 0 ) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate free-space section info") #ifndef NDEBUG - /* Re-Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") - - HDassert(H5F_addr_defined(fs_stat.addr)); - HDassert(H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.serial_sect_count > 0); - HDassert(fs_stat.alloc_sect_size > 0); - HDassert(fs_stat.alloc_sect_size == fs_stat.sect_size); + /* Re-Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + + HDassert(H5F_addr_defined(fs_stat.addr)); + HDassert(H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.serial_sect_count > 0); + HDassert(fs_stat.alloc_sect_size > 0); + HDassert(fs_stat.alloc_sect_size == fs_stat.sect_size); #endif /* NDEBUG */ + } /* end if */ + else { + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.serial_sect_count == 0); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end else */ } /* end if */ - else { - HDassert(!H5F_addr_defined(fs_stat.addr)); - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.serial_sect_count == 0); - HDassert(fs_stat.alloc_sect_size == 0); - } /* end else */ } /* end if */ - } /* end if */ - /* Close any opened FSMs */ - if(fsm_opened[fsm_type]) { - if(H5MF__alloc_close(f, dxpl_id, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space manager") - fsm_opened[fsm_type] = FALSE; + /* Close any opened FSMs */ + if(fsm_opened[fsm_type]) { + if(H5MF__close_fstype(f, dxpl_id, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space manager") + fsm_opened[fsm_type] = FALSE; + } /* end if */ } /* end if */ - } /* end if */ + } /* end for */ } /* end for */ /* verify that all opened FSMs were closed */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - HDassert(!fsm_opened[type]); + for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, fsm_type)) + HDassert(!fsm_opened[fsm_type]); /* Indicate that the FSM was settled successfully */ *fsm_settled = TRUE; @@ -1640,11 +3130,11 @@ done: * * Purpose: If the free space manager is persistent, handle any tasks * required before the metadata cache can serialize or flush - * the metadata free space manager(sI) that handle file space + * the metadata free space manager(s) that handle file space * allocation for free space managers. * * In most cases, there will be only one manager assigned - * to this role. However, since for reason or reason unknown, + * to this role. However, since for reasons unknown, * free space manager headers and section info blocks are * different classes of memory, it is possible that two free * space managers will be involved. @@ -1652,7 +3142,7 @@ done: * On entry to this function, the raw data settle routine * (H5MF_settle_raw_data_fsm()) should have: * - * 1) Freed the accumulators. + * 1) Freed the aggregators. * * 2) Freed all file space allocated to the free space managers. * @@ -1688,9 +3178,12 @@ done: * 1) Verify that the free space manager(s) involved in file * space allocation for free space managers are still floating. * - * 2) Free the accumulators. + * 2) Free the aggregators. * - * 3) Reduce the EOA to the extent possible. + * 3) Reduce the EOA to the extent possible, and make note + * of the resulting value. This value will be stored + * in the fsinfo superblock extension message and be used + * in the subsequent file open. * * 4) Re-allocate space for any free space manager(s) that: * @@ -1724,6 +3217,9 @@ done: * severe time pressure at the moment, the above brute * force solution is attractive. * + * 5) Make note of the EOA -- used for sanity checking on + * FSM shutdown. + * * Return: SUCCEED/FAIL * * Programmer: John Mainzer @@ -1734,10 +3230,23 @@ done: herr_t H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) { + H5F_mem_page_t sm_fshdr_fs_type; /* small fs hdr fsm */ + H5F_mem_page_t sm_fssinfo_fs_type; /* small fs sinfo fsm */ + H5F_mem_page_t lg_fshdr_fs_type; /* large fs hdr fsm */ + H5F_mem_page_t lg_fssinfo_fs_type; /* large fs sinfo fsm */ + H5FS_t *sm_hdr_fspace = NULL; /* ptr to sm FSM hdr alloc FSM */ + H5FS_t *sm_sinfo_fspace = NULL; /* ptr to sm FSM sinfo alloc FSM */ + H5FS_t *lg_hdr_fspace = NULL; /* ptr to lg FSM hdr alloc FSM */ + H5FS_t *lg_sinfo_fspace = NULL; /* ptr to lg FSM sinfo alloc FSM */ + haddr_t eoa_pre_fsm_fsalloc; /* eoa pre file space allocation */ + /* for self referential FSMs */ + haddr_t eoa_post_fsm_fsalloc; /* eoa post file space allocation */ + /* for self referential FSMs */ + H5FS_stat_t fs_stat; /* Information for hdr FSM */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ hbool_t reset_ring = FALSE; /* Whether we set the ring */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) @@ -1746,29 +3255,49 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) HDassert(f->shared); HDassert(fsm_settled); - /* Only need to settle things if we are persisting the free space info */ - if(f->shared->fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) { - H5FS_t *hdr_fspace; /* Ptr to FSM hdr alloc FSM */ - H5FS_t *sinfo_fspace; /* Ptr to FSM sinfo alloc FSM */ - H5FS_stat_t fs_stat; /* Information for FSM */ - H5FD_mem_t hdr_fsm_alloc_type; /* FSM hdr alloc type */ - H5FD_mem_t sinfo_fsm_alloc_type; /* FSM info alloc type */ - - /* Get the file memory types for the FSM header & section info */ - hdr_fsm_alloc_type = H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR); - sinfo_fsm_alloc_type = H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO); - - /* Sanity checks */ - HDassert(hdr_fsm_alloc_type > H5FD_MEM_NOLIST); - HDassert(hdr_fsm_alloc_type < H5FD_MEM_NTYPES); - HDassert(sinfo_fsm_alloc_type > H5FD_MEM_NOLIST); - HDassert(sinfo_fsm_alloc_type < H5FD_MEM_NTYPES); - HDassert(!H5F_addr_defined(f->shared->fs_addr[hdr_fsm_alloc_type])); - HDassert(!H5F_addr_defined(f->shared->fs_addr[sinfo_fsm_alloc_type])); - - /* Note that in most cases, hdr_fspace will equal sinfo_fspace. */ - hdr_fspace = f->shared->fs_man[hdr_fsm_alloc_type]; - sinfo_fspace = f->shared->fs_man[sinfo_fsm_alloc_type]; + /* Only need to settle things if we are persisting the free space info + * and allocation/deallocation has occurred. + */ + if(f->shared->fs_persist && !f->shared->first_alloc_dealloc) { + /* Sanity check */ + HDassert(f->shared->lf); + + /* should only be called if file is opened R/W */ + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); + + HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); + HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); + + HDassert(sm_fssinfo_fs_type > H5F_MEM_PAGE_DEFAULT); + HDassert(sm_fssinfo_fs_type < H5F_MEM_PAGE_LARGE_SUPER); + + HDassert(!H5F_addr_defined(f->shared->fs_addr[sm_fshdr_fs_type])); + HDassert(!H5F_addr_defined(f->shared->fs_addr[sm_fssinfo_fs_type])); + + /* Note that in most cases, sm_hdr_fspace will equal sm_sinfo_fspace. */ + sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; + sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; + + if(H5F_PAGED_AGGR(f)) { + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); + + HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); + + HDassert(lg_fssinfo_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(lg_fssinfo_fs_type < H5F_MEM_PAGE_NTYPES); + + HDassert(!H5F_addr_defined(f->shared->fs_addr[lg_fshdr_fs_type])); + HDassert(!H5F_addr_defined(f->shared->fs_addr[lg_fssinfo_fs_type])); + + /* Note that in most cases, lg_hdr_fspace will equal lg_sinfo_fspace. */ + lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; + lg_sinfo_fspace = f->shared->fs_man[lg_fssinfo_fs_type]; + } /* end if */ /* Set the ring in the dxpl appropriately for subsequent calls */ if(H5AC_set_ring(dxpl_id, H5AC_RING_MDFSM, &dxpl, &orig_ring) < 0) @@ -1776,41 +3305,109 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) reset_ring = TRUE; #ifndef NDEBUG - /* Verify that hdr_fspace is floating if it exists */ - if(hdr_fspace) { + /* Verify that sm_hdr_fspace is floating if it exists */ + if(sm_hdr_fspace) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, hdr_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") + if(H5FS_stat_info(f, sm_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ - /* Verify that sinfo_fspace is floating if it exists */ - if((sinfo_fspace) && (hdr_fspace != sinfo_fspace)) { + /* Verify that sm_sinfo_fspace is floating if it exists and is distinct */ + if((sm_sinfo_fspace) && (sm_hdr_fspace != sm_sinfo_fspace)) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, sinfo_fspace, &fs_stat) < 0) + if(H5FS_stat_info(f, sm_sinfo_fspace, &fs_stat) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ + + if(H5F_PAGED_AGGR(f)) { + /* Verify that lg_hdr_fspace is floating if it exists */ + if(lg_hdr_fspace) { + /* Query free space manager info for this type */ + if(H5FS_stat_info(f, lg_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (3)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + + /* Verify that lg_sinfo_fspace is floating if it + * exists and is distinct + */ + if((lg_sinfo_fspace) && (lg_hdr_fspace != lg_sinfo_fspace)) { + /* Query free space manager info for this type */ + if(H5FS_stat_info(f, lg_sinfo_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (4)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + } /* end if */ #endif /* NDEBUG */ /* Free the space in the metadata aggregator. Do this via the * H5MF_free_aggrs() call. Note that the raw data aggregator must * have already been freed. Sanity checks for this? + * + * Note that the aggregators will not exist if paged aggregation + * is enabled -- don't attempt to free if this is the case. */ + /* Vailin -- is this correct? */ /* (for space not at EOF, it may be put into free space managers) */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) + if((!H5F_PAGED_AGGR(f)) && (H5MF_free_aggrs(f, dxpl_id) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") + /* At this point, the EOA should be set to a value that contains + * the allocation for all user data, all non self referential FSMs, + * the superblock and all superblock extension messages. + * + * Make note of the current EOA. We will store this value in the + * free space manager superblock extension message. Since space for + * everything other than the self referential FSMs (and possibly the + * cache image) has been allocated at this point, this allows us to + * to float the self referential FSMs on the first file space allocation / + * deallocaiton and then set the EOA to this value before we handle + * the allocation / deallocation. (If a cache image exists, the + * first allocation / deallocation will be the deallocation of space + * for the cache image). + * + * WARNING: This approach settling the self referential free space + * managers and allocating space for them in the file will + * not work as currently implemented with the split and + * multi file drivers, as the self referential free space + * manager header and section info can be stored in up to + * two different files -- requiring that up to two EOA's + * be stored in the the free space managers super block + * extension message. + * + * As of this writing, we are solving this problem by + * simply not supporting persistant FSMs with the split + * and multi file drivers. + * + * Current plans are to do away with the multi file + * driver, so this should be a non-issue in this case. + * + * We should be able to support the split file driver + * without a file format change. However, the code to + * do so does not exist at present. + */ + if(HADDR_UNDEF == (eoa_pre_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") + + /* ******************* PROBLEM: ******************** * * If the file has an alignement other than 1, and if @@ -1858,499 +3455,454 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled) * * This is isn't good, but due to schedule pressure, we will just drop * the fragment on the floor for now. - */ - if(hdr_fspace) - if(H5FS_alloc_vfd_alloc_hdr_and_section_info(f, dxpl_id, hdr_fspace, - &(f->shared->fs_addr[hdr_fsm_alloc_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate hdr FSM file space") - - if(sinfo_fspace && (sinfo_fspace != hdr_fspace)) - if(H5FS_alloc_vfd_alloc_hdr_and_section_info(f, dxpl_id, sinfo_fspace, - &(f->shared->fs_addr[sinfo_fsm_alloc_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sinfo FSM file space") - - /* Indicate that the FSM was settled successfully */ - *fsm_settled = TRUE; - } /* end if */ - -done: - if(reset_ring) - if(H5AC_reset_ring(dxpl, orig_ring) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_settle_meta_data_fsm() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__close_delete - * - * Purpose: Common code for closing and deleting freespace managers from - * the file. - * - * Return: SUCCEED/FAIL - * - * Programmer: Vailin Choi - * Jan 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF__close_delete(H5F_t *f, hid_t dxpl_id, H5P_genplist_t **dxpl) -{ - H5FD_mem_t type; /* Memory type for iteration */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* current ring value */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ - - /* check args */ - HDassert(f); - HDassert(f->shared); - - /* Iterate over all the free space types that have managers and get each free list's space */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - H5AC_ring_t needed_ring; /* Ring value needed for this iteration */ - -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - - /* test to see if we need to switch rings -- do so if required */ - if((H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; - - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (4)") - curr_ring = needed_ring; - } /* end if */ - - /* If the free space manager for this type is open, close it */ - if(f->shared->fs_man[type]) { -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - if(H5FS_close(f, dxpl_id, f->shared->fs_man[type]) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free space info") - f->shared->fs_man[type] = NULL; - f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; - } /* end if */ -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - - /* If there is free space manager info for this type, delete it */ - if(H5F_addr_defined(f->shared->fs_addr[type])) { - haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ - - /* Put address into temporary variable and reset it */ - /* (Avoids loopback in file space freeing routine) */ - tmp_fs_addr = f->shared->fs_addr[type]; - f->shared->fs_addr[type] = HADDR_UNDEF; - - /* Shift to "deleting" state, to make certain we don't track any - * file space freed as a result of deleting the free space manager. - */ - f->shared->fs_state[type] = H5F_FS_STATE_DELETING; - -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - - /* Delete free space manager for this type */ - if(H5FS_delete(f, dxpl_id, tmp_fs_addr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't delete free space manager") + */ + if(sm_hdr_fspace) + if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, dxpl_id, sm_hdr_fspace, &(f->shared->fs_addr[sm_fshdr_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm hdr FSM file space") + + if(sm_sinfo_fspace && (sm_sinfo_fspace != sm_hdr_fspace)) + if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, dxpl_id, sm_sinfo_fspace, &(f->shared->fs_addr[sm_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm sinfo FSM file space") + + if(H5F_PAGED_AGGR(f)) { + if(lg_hdr_fspace) + if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, dxpl_id, lg_hdr_fspace, &(f->shared->fs_addr[lg_fshdr_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg hdr FSM file space") + + if(lg_sinfo_fspace && (lg_sinfo_fspace != lg_hdr_fspace)) + if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, dxpl_id, lg_sinfo_fspace, &(f->shared->fs_addr[lg_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg sinfo FSM file space") + } /* end if */ - /* Shift [back] to closed state */ - HDassert(f->shared->fs_state[type] == H5F_FS_STATE_DELETING); - f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; + /* Get the eoa after allocation of file space for the self referential + * free space managers. Assuming no cache image, this should be the + * final EOA of the file. + */ + if(HADDR_UNDEF == (eoa_post_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + + /* All free space managers should have file space allocated for them + * now, and should see no further allocations / deallocations. Store + * the pre and post file space allocaton for self referential FSMs EOA + * for use when we actually write the free space manager superblock + * extension message. + */ + f->shared->eoa_pre_fsm_fsalloc = eoa_pre_fsm_fsalloc; + f->shared->eoa_post_fsm_fsalloc = eoa_post_fsm_fsalloc; - /* Sanity check that the free space manager for this type wasn't started up again */ - HDassert(!H5F_addr_defined(f->shared->fs_addr[type])); - } /* end if */ - } /* end for */ + /* Indicate that the FSM was settled successfully */ + *fsm_settled = TRUE; + } /* end if */ done: -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ + if(reset_ring) + if(H5AC_reset_ring(dxpl, orig_ring) < 0) + HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* H5MF__close_delete() */ +} /* H5MF_settle_meta_data_fsm() */ /*------------------------------------------------------------------------- - * Function: H5MF_try_close + * Function: H5MF__fsm_type_is_self_referential() * - * Purpose: This is called by H5Fformat_convert() to close and delete - * free-space managers when downgrading persistent free-space - * to non-persistent. + * Purpose: Return TRUE if the indicated free space manager allocates + * file space for free space managers. Return FALSE otherwise. * - * Return: SUCCEED/FAIL + * Return: TRUE/FALSE * - * Programmer: Vailin Choi - * Jan 2016 + * Programmer: John Mainzer + * 12/6/16 * *------------------------------------------------------------------------- */ -herr_t -H5MF_try_close(H5F_t *f, hid_t dxpl_id) +hbool_t +H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) { - H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_mem_page_t sm_fshdr_fsm; + H5F_mem_page_t sm_fssinfo_fsm; + H5F_mem_page_t lg_fshdr_fsm; + H5F_mem_page_t lg_fssinfo_fsm; + hbool_t result = FALSE; - FUNC_ENTER_NOAPI(FAIL) -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ + FUNC_ENTER_NOAPI_NOINIT_NOERR - /* check args */ + /* Sanity check */ HDassert(f); + HDassert(f->shared); + HDassert(fsm_type >= H5F_MEM_PAGE_DEFAULT); + HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - /* Set the ring type in the DXPL */ - if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") - reset_ring = TRUE; + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); - /* Close and delete freespace managers from the file */ - if(H5MF__close_delete(f, dxpl_id, &dxpl) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to close delete free-space managers") + if(H5F_PAGED_AGGR(f)) { + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); -done: - /* Reset the ring in the DXPL */ - if(reset_ring) - if(H5AC_reset_ring(dxpl, orig_ring) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) + || (fsm_type == lg_fshdr_fsm) || (fsm_type == lg_fssinfo_fsm); + } /* end if */ + else { + /* In principle, fsm_type should always be less than + * H5F_MEM_PAGE_LARGE_SUPER whenever paged aggregation + * is not enabled. However, since there is code that does + * not observe this prinicple, force the result to FALSE if + * fsm_type is greater than or equal to H5F_MEM_PAGE_LARGE_SUPER. + */ + if(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER) + result = FALSE; + else + result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm); + } /* end else */ -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_try_close() */ + FUNC_LEAVE_NOAPI(result) +} /* H5MF__fsm_type_is_self_referential() */ /*------------------------------------------------------------------------- - * Function: H5MF_close + * Function: H5MF__fsm_is_self_referential() * - * Purpose: Close the free space tracker(s) for a file + * Purpose: Return TRUE if the indicated free space manager allocates + * file space for free space managers. Return FALSE otherwise. * - * Return: SUCCEED/FAIL + * Return: TRUE/FALSE * - * Programmer: Quincey Koziol - * Tuesday, January 22, 2008 + * Programmer: John Mainzer + * 12/6/16 * - * Modifications: - * Vailin Choi; July 2012 - * As the default free-list mapping is changed to H5FD_FLMAP_DICHOTOMY, - * modifications are needed to shrink EOA if the last section of each free-space manager - * and the remaining space in the two aggregators are at EOA. + *------------------------------------------------------------------------- + */ +static hbool_t +H5MF__fsm_is_self_referential(H5F_t *f, H5FS_t *fspace) +{ + H5F_mem_page_t sm_fshdr_fsm; + H5F_mem_page_t sm_fssinfo_fsm; + hbool_t result = FALSE; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + HDassert(fspace); + + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); + + if(H5F_PAGED_AGGR(f)) { + H5F_mem_page_t lg_fshdr_fsm; + H5F_mem_page_t lg_fssinfo_fsm; + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); + + result = (fspace == f->shared->fs_man[sm_fshdr_fsm]) || + (fspace == f->shared->fs_man[sm_fssinfo_fsm]) || + (fspace == f->shared->fs_man[lg_fshdr_fsm]) || + (fspace == f->shared->fs_man[lg_fssinfo_fsm]); + } /* end if */ + else + result = (fspace == f->shared->fs_man[sm_fshdr_fsm]) || + (fspace == f->shared->fs_man[sm_fssinfo_fsm]); + + FUNC_LEAVE_NOAPI(result) +} /* H5MF__fsm_is_self_referential() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_tidy_self_referential_fsm_hack + * + * Purpose: As discussed in the comments of the settle routines above, + * the existence of self referential free space managers + * as currently implemented creates the possibility of + * infinite loops at file close. + * + * As a hack to avoid this, we have added code to settle + * self referential free space managers, and then allocate + * space for them directly from the file driver. + * + * To avoid dropping ever increasing amounts of file space + * on the floor with each subsequent file close/open cycle, + * we need to clean this up on file open. To avoid this, + * this function is called on the first file space allocation + * or deallocation after file open to float the self referential + * free space managers and reduce the EOA to the value it + * had before the direct allocation of space for the self + * referential free space managers. + * + * The function proceeds as follows: + * + * 1) Verify that f->shared->first_alloc_dealloc is TRUE, + * and then set it to FALSE. + * + * 2) Get the current EOA. Verify that it is greater than + * or equal to f->shared->eoa_pre_fsm_fsalloc. If the + * current eoa is equal to f->shared->eoa_pre_fsm_fsalloc, + * no self referential FSMs were stored, and we are done. + * + * NOTE: This will have to be reworked somewhat for + * cache image. + * + * 3) Load the self referential FSMs. In passing verify that + * the lowest address of a FSM header is equal to + * f->shared->eoa_pre_fsm_fsalloc.' + * + * Note that we don't have to use any special I/O for + * this -- we can use the regular I/O methods even if + * paged aggregation and page buffering is enabled. + * + * 4) Float the FSMs. Ensure that the file space is NOT + * released. + * + * 5) Set EOA equal to f->shared->eoa_pre_fsm_fsalloc, + * and then set f->shared->eoa_pre_fsm_fsalloc to + * HADDR_UNDEF. + * + * If page buffering, verify that the new EOA is + * on a page boundary, and expunge any pages in the + * page buffer after the new EOA. + * + * Note that this function is also called from test code + * when it is necessary to startup a self referential + * free space manager prior to the first file space + * allocation / deallocation. Failure to do so will + * result in assertion failures in this function on + * the first file space allocation / deallocation. + * + * Return: SUCCEED/FAIL + * + * Programmer: John Mainzer + * 12/11/16 + * *------------------------------------------------------------------------- */ herr_t -H5MF_close(H5F_t *f, hid_t dxpl_id) +H5MF_tidy_self_referential_fsm_hack(H5F_t *f, hid_t dxpl_id) { + haddr_t eoa; /* EOA of file */ + hsize_t tail_size = 0; /* Size of chunk to free */ H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5FD_mem_t type; /* Memory type for iteration */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + haddr_t first_srfsm_hdr = HADDR_UNDEF; /* Addr of first self referential */ + /* fsm header in file */ + H5FS_stat_t fs_stat; /* Information for hdr FSM */ + H5F_mem_page_t sm_fshdr_fs_type; /* Small fs hdr fsm */ + H5F_mem_page_t sm_fssinfo_fs_type; /* Small fs sinfo fsm */ + H5F_mem_page_t lg_fshdr_fs_type; /* Large fs hdr fsm */ + H5F_mem_page_t lg_fssinfo_fs_type; /* Large fs sinfo fsm */ hbool_t reset_ring = FALSE; /* Whether the ring was set */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ /* check args */ HDassert(f); HDassert(f->shared); - HDassert(f->shared->lf); - HDassert(f->shared->sblock); + HDassert(f->shared->fs_persist); + HDassert(f->shared->first_alloc_dealloc); - /* Set the ring type in the DXPL. In most cases, we will - * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if - * needed. + /* Set the ring type in the DXPL. Since we are only dealing with + * self referential FSMs, we will only need H5AC_RING_MDFSM. */ - if(H5AC_set_ring(dxpl_id, H5AC_RING_RDFSM, &dxpl, &orig_ring) < 0) + if(H5AC_set_ring(dxpl_id, H5AC_RING_MDFSM, &dxpl, &orig_ring) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") reset_ring = TRUE; - curr_ring = H5AC_RING_RDFSM; - /* Free the space in aggregators */ - /* (for space not at EOF, it may be put into free space managers) */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") + /* 1) Verify that f->shared->first_alloc_dealloc is TRUE, + * and then set it to FALSE. + */ + HDassert(f->shared->first_alloc_dealloc); + f->shared->first_alloc_dealloc = FALSE; - /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") - /* Making free-space managers persistent for superblock version >= 2 */ - if(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 - && f->shared->fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) { - H5O_fsinfo_t fsinfo; /* Free space manager info message */ + /* 2) Get the current EOA. Verify that it is greater than + * or equal to f->shared->eoa_pre_fsm_fsalloc. If the + * current eoa is equal to f->shared->eoa_pre_fsm_fsalloc, + * no self referential FSMs were stored, and we are done. + * + * NOTE: This will have to be reworked somewhat for + * cache image. + */ + if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") + HDassert(H5F_addr_le(f->shared->eoa_pre_fsm_fsalloc, eoa)); - /* Superblock extension and free space manager message should - * exist at this point -- verify at least the former. - */ - HDassert(H5F_addr_defined(f->shared->sblock->ext_addr)); + if(H5F_addr_eq(f->shared->eoa_pre_fsm_fsalloc, eoa)) + HGOTO_DONE(SUCCEED) - /* Note that unlike the previous version of this code, we do not - * delete free space managers that have no section to store. - * - * Can't do this, as that would involve freeing file space, which would - * dirty the free space manager in question. - * - * Fortunately, the code doesn't seem to care about this. - */ - /* Gather data for the free space manager superblock extension message. - * - * In passing, verify that all the free space managers are closed. - */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - fsinfo.fs_addr[type - 1] = f->shared->fs_addr[type]; - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.threshold = f->shared->fs_threshold; + /* 3) Load the self referential FSMs. In passing verify that + * the lowest address of a FSM header is equal to + * f->shared->eoa_pre_fsm_fsalloc.' + * + * Note that we don't have to use any special I/O for + * this -- we can use the regular I/O methods even if + * paged aggregation and page buffering is enabled. + */ + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); + HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); + HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); - /* Write the free space manager message -- message must already exist */ - if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + HDassert(sm_fssinfo_fs_type > H5F_MEM_PAGE_DEFAULT); + HDassert(sm_fssinfo_fs_type < H5F_MEM_PAGE_LARGE_SUPER); - /* Final close of free-space managers */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - if(f->shared->fs_man[type]) { - H5AC_ring_t needed_ring; /* Ring value needed for this iteration */ + HDassert(NULL == f->shared->fs_man[sm_fshdr_fs_type]); + HDassert(NULL == f->shared->fs_man[sm_fssinfo_fs_type]); - /* test to see if we need to switch rings -- do so if required */ - if((H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (H5MF_ALLOC_TO_FS_TYPE(f, type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; + if(H5F_addr_defined(f->shared->fs_addr[sm_fshdr_fs_type])) { + first_srfsm_hdr = f->shared->fs_addr[sm_fshdr_fs_type]; - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (3)") - curr_ring = needed_ring; - } /* end if */ + /* open the FSM */ + if(H5MF_open_fstype(f, dxpl_id, sm_fshdr_fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - HDassert(f->shared->fs_state[type] == H5F_FS_STATE_OPEN); - if(H5FS_close(f, dxpl_id, f->shared->fs_man[type]) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") - f->shared->fs_man[type] = NULL; - f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; - } /* end if */ - f->shared->fs_addr[type] = HADDR_UNDEF; - } /* end for */ + HDassert(f->shared->fs_man[sm_fshdr_fs_type]); + } /* end if */ - /* Verify that we haven't dirtied any metadata cache entries - * from the metadata free space manager ring out. - */ - HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); + if((sm_fshdr_fs_type != sm_fssinfo_fs_type) && + (H5F_addr_defined(f->shared->fs_addr[sm_fssinfo_fs_type]))) { - /* Verify that the aggregators are still shutdown. */ - HDassert(f->shared->sdata_aggr.tot_size == 0); - HDassert(f->shared->sdata_aggr.addr == 0); - HDassert(f->shared->sdata_aggr.size == 0); - HDassert(f->shared->meta_aggr.tot_size == 0); - HDassert(f->shared->meta_aggr.addr == 0); - HDassert(f->shared->meta_aggr.size == 0); - } /* end if */ - else { /* super_vers can be 0, 1, 2 */ - /* Close and delete freespace managers from the file */ - if(H5MF__close_delete(f, dxpl_id, &dxpl) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") + if(!H5F_addr_defined(first_srfsm_hdr) || + (H5F_addr_defined(first_srfsm_hdr) && + H5F_addr_lt(f->shared->fs_addr[sm_fssinfo_fs_type], first_srfsm_hdr))) + first_srfsm_hdr = f->shared->fs_addr[sm_fssinfo_fs_type]; - /* moved code that was for both the persistant and non persistant free - * space managers to the non-persistant case. In the persistant - * case, the EOA should already be as shrunked as it can be, and the - * aggregators should alread be shut down. - */ + HDassert(NULL == f->shared->fs_man[sm_fssinfo_fs_type]); - /* Free the space in aggregators (again) */ - /* (in case any free space information re-started them) */ - if(H5MF_free_aggrs(f, dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") + /* open the FSM */ + if(H5MF_open_fstype(f, dxpl_id, sm_fssinfo_fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - /* Trying shrinking the EOA for the file */ - /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f, dxpl_id) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") - } /* end else */ + HDassert(f->shared->fs_man[sm_fssinfo_fs_type]); + } /* end if */ -done: - /* Reset the ring in the DXPL */ - if(reset_ring) - if(H5AC_reset_ring(dxpl, orig_ring) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") + if(H5F_PAGED_AGGR(f)) { + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); + H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); -#endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5MF_close() */ + HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); - -/*------------------------------------------------------------------------- - * Function: H5MF_sects_cb() - * - * Purpose: Iterator callback for each free-space section - * Retrieve address and size into user data - * - * Return: Always succeed - * - * Programmer: Vailin Choi - * July 1st, 2009 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF_sects_cb(H5FS_section_info_t *_sect, void *_udata) -{ - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; - H5MF_sect_iter_ud_t *udata = (H5MF_sect_iter_ud_t *)_udata; + HDassert(lg_fssinfo_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); + HDassert(lg_fssinfo_fs_type < H5F_MEM_PAGE_NTYPES); - FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(NULL == f->shared->fs_man[lg_fshdr_fs_type]); + HDassert(NULL == f->shared->fs_man[lg_fssinfo_fs_type]); - if(udata->sect_idx < udata->sect_count) { - udata->sects[udata->sect_idx].addr = sect->sect_info.addr; - udata->sects[udata->sect_idx].size = sect->sect_info.size; - udata->sect_idx++; - } /* end if */ + if(H5F_addr_defined(f->shared->fs_addr[lg_fshdr_fs_type])) { + if(!H5F_addr_defined(first_srfsm_hdr) || + (H5F_addr_defined(first_srfsm_hdr) && + H5F_addr_lt(f->shared->fs_addr[lg_fshdr_fs_type], first_srfsm_hdr))) + first_srfsm_hdr = f->shared->fs_addr[lg_fshdr_fs_type]; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sects_cb() */ + HDassert(NULL == f->shared->fs_man[lg_fshdr_fs_type]); - -/*------------------------------------------------------------------------- - * Function: H5MF_get_free_sections() - * - * Purpose: To iterate over one or all free-space managers for: - * # of sections - * section info as defined in H5F_sect_info_t - * - * Return: SUCCEED/FAIL - * - * Programmer: Vailin Choi - * July 1st, 2009 - * - *------------------------------------------------------------------------- - */ -ssize_t -H5MF_get_free_sections(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) -{ - size_t total_sects = 0; /* total number of sections */ - H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ - H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5FD_mem_t start_type, end_type; /* Memory types to iterate over */ - H5FD_mem_t ty; /* Memory type for iteration */ - hbool_t reset_ring = FALSE; /* Whether the ring was set */ - ssize_t ret_value = -1; /* Return value */ + /* open the FSM */ + if(H5MF_open_fstype(f, dxpl_id, lg_fshdr_fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") + HDassert(f->shared->fs_man[lg_fshdr_fs_type]); + } /* end if */ - FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__FREESPACE_TAG, FAIL) + if(lg_fshdr_fs_type != lg_fssinfo_fs_type && H5F_addr_defined(f->shared->fs_addr[lg_fssinfo_fs_type])) { + if(!H5F_addr_defined(first_srfsm_hdr) || + (H5F_addr_defined(first_srfsm_hdr) && + H5F_addr_lt(f->shared->fs_addr[lg_fssinfo_fs_type], first_srfsm_hdr))) + first_srfsm_hdr = f->shared->fs_addr[lg_fssinfo_fs_type]; - /* check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); + HDassert(NULL == f->shared->fs_man[lg_fssinfo_fs_type]); - /* Determine start/end points for loop */ - if(type == H5FD_MEM_DEFAULT) { - start_type = H5FD_MEM_SUPER; - end_type = H5FD_MEM_NTYPES; + /* open the FSM */ + if(H5MF_open_fstype(f, dxpl_id, lg_fssinfo_fs_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") + HDassert(f->shared->fs_man[lg_fssinfo_fs_type]); + } /* end if */ + } /* end if */ + HDassert(H5F_addr_eq(first_srfsm_hdr, f->shared->eoa_pre_fsm_fsalloc)); + + /* 4) Float the FSMs. Ensure that the file space is NOT released. */ + if(f->shared->fs_man[sm_fshdr_fs_type]) { + /* Sanity check: Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[sm_fshdr_fs_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + + HDassert(H5F_addr_defined(fs_stat.addr)); + HDassert(H5F_addr_defined(fs_stat.sect_addr)); + if(H5FS_free(f, f->shared->fs_man[sm_fshdr_fs_type], dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") + f->shared->fs_addr[sm_fshdr_fs_type] = HADDR_UNDEF; } /* end if */ - else { - start_type = end_type = type; - H5_INC_ENUM(H5FD_mem_t, end_type); - } /* end else */ - - /* Set up user data for section iteration */ - sect_udata.sects = sect_info; - sect_udata.sect_count = nsects; - sect_udata.sect_idx = 0; - /* Set the ring type in the DXPL. Note that if we are - * scanning a number of different free space managers, - * we may have to change the ring - */ - if((H5MF_ALLOC_TO_FS_TYPE(f, start_type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (H5MF_ALLOC_TO_FS_TYPE(f, start_type) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; - curr_ring = needed_ring; - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &orig_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value") - reset_ring = TRUE; + if(sm_fshdr_fs_type != sm_fssinfo_fs_type && f->shared->fs_man[sm_fssinfo_fs_type]) { + /* Sanity check: Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[sm_fssinfo_fs_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") - /* Iterate over memory types, retrieving the number of sections of each type */ - for(ty = start_type; ty < end_type; H5_INC_ENUM(H5FD_mem_t, ty)) { - hbool_t fs_started = FALSE; + HDassert(H5F_addr_defined(fs_stat.addr)); + HDassert(H5F_addr_defined(fs_stat.sect_addr)); + if(H5FS_free(f, f->shared->fs_man[sm_fssinfo_fs_type], dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") + f->shared->fs_addr[sm_fssinfo_fs_type] = HADDR_UNDEF; + } /* end if */ - /* test to see if we need to switch rings -- do so if required */ - if((H5MF_ALLOC_TO_FS_TYPE(f, ty) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_HDR)) - || (H5MF_ALLOC_TO_FS_TYPE(f, ty) == H5MF_ALLOC_TO_FS_TYPE(f, H5FD_MEM_FSPACE_SINFO))) - needed_ring = H5AC_RING_MDFSM; - else - needed_ring = H5AC_RING_RDFSM; + if(H5F_PAGED_AGGR(f)) { + if(f->shared->fs_man[lg_fshdr_fs_type]) { + /* Sanity check: Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[lg_fshdr_fs_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - if(needed_ring != curr_ring) { - if(H5AC_set_ring(dxpl_id, needed_ring, &dxpl, &curr_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set ring value (2)") - curr_ring = needed_ring; + HDassert(H5F_addr_defined(fs_stat.addr)); + HDassert(H5F_addr_defined(fs_stat.sect_addr)); + if(H5FS_free(f, f->shared->fs_man[lg_fshdr_fs_type], dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't float free-space headers") + f->shared->fs_addr[lg_fshdr_fs_type] = HADDR_UNDEF; } /* end if */ - /* Open free space manager of this type, if it isn't already */ - if(!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { - if(H5MF__alloc_open(f, dxpl_id, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, FAIL, "can't initialize file free space") - HDassert(f->shared->fs_man[ty]); - fs_started = TRUE; - } /* end if */ - - /* Check if f there's free space sections of this type */ - if(f->shared->fs_man[ty]) { - hsize_t hnums = 0; /* Total # of sections */ - size_t nums; /* Total # of sections, cast to a size_t */ - - /* Query how many sections of this type */ - if(H5FS_sect_stats(f->shared->fs_man[ty], NULL, &hnums) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") - H5_CHECKED_ASSIGN(nums, size_t, hnums, hsize_t); - - /* Increment total # of sections */ - total_sects += nums; - - /* Check if we should retrieve the section info */ - if(sect_info && nums > 0) { - /* Iterate over all the free space sections of this type, adding them to the user's section info */ - if(H5FS_sect_iterate(f, dxpl_id, f->shared->fs_man[ty], H5MF_sects_cb, §_udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't iterate over sections") - } /* end if */ + if(lg_fshdr_fs_type != lg_fssinfo_fs_type && f->shared->fs_man[lg_fssinfo_fs_type]) { + /* Sanity check: Query free space manager info for this type */ + if(H5FS_stat_info(f, f->shared->fs_man[lg_fssinfo_fs_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") + + HDassert(H5F_addr_defined(fs_stat.addr)); + HDassert(H5F_addr_defined(fs_stat.sect_addr)); + if(H5FS_free(f, f->shared->fs_man[lg_fssinfo_fs_type], dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't float free-space headers") + f->shared->fs_addr[lg_fssinfo_fs_type] = HADDR_UNDEF; } /* end if */ + } /* end if */ - /* Close the free space manager of this type, if we started it here */ - if(fs_started) - if(H5MF__alloc_close(f, dxpl_id, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, FAIL, "can't close file free space") - } /* end for */ + /* 5) Set EOA equal to f->shared->eoa_pre_fsm_fsalloc, + * and then set f->shared->eoa_pre_fsm_fsalloc to + * HADDR_UNDEF. + * + * If page buffering, verify that the new EOA is + * on a page boundary, and expunge any pages in the + * page buffer after the new EOA. + */ + if(!H5F_PAGED_AGGR(f)) { + /* Verify that the aggregators are still shutdown. */ + HDassert(f->shared->sdata_aggr.tot_size == 0); + HDassert(f->shared->sdata_aggr.addr == 0); + HDassert(f->shared->sdata_aggr.size == 0); - /* Set return value */ - ret_value = (ssize_t)total_sects; + HDassert(f->shared->meta_aggr.tot_size == 0); + HDassert(f->shared->meta_aggr.addr == 0); + HDassert(f->shared->meta_aggr.size == 0); + } /* end if */ + + tail_size = (hsize_t)(eoa - f->shared->eoa_pre_fsm_fsalloc); + + /* Release file space allocated to self referential FSMs */ + if(H5F_free(f, dxpl_id, H5FD_MEM_DEFAULT, f->shared->eoa_pre_fsm_fsalloc, tail_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") + if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") + HDassert(H5F_addr_eq(f->shared->eoa_pre_fsm_fsalloc, eoa)); + + f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; + + HDassert((!H5F_PAGED_AGGR(f)) || (0 == (eoa % f->shared->fs_page_size))); done: /* Reset the ring in the DXPL */ @@ -2359,5 +3911,5 @@ done: HDONE_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "unable to set property value") FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* H5MF_get_free_sections() */ +} /* H5MF_tidy_self_referential_fsm_hack() */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 1510645..de98bf1 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -57,8 +57,10 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, +static herr_t H5MF__aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_aggr_t *aggr); +static haddr_t H5MF__aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, + H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size); /*********************/ @@ -78,86 +80,9 @@ static herr_t H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, /*------------------------------------------------------------------------- - * Function: H5MF_vfd_alloc - * - * Purpose: Allocate SIZE bytes of file memory via H5FD_alloc() and return - * the relative address where that contiguous chunk of file memory - * exists. - * The TYPE argument describes the purpose for which the storage - * is being requested. - * - * Return: Success: The file address of new chunk. - * Failure: HADDR_UNDEF - * - * Programmer: Quincey Koziol - * January 2, 2017 - * - *------------------------------------------------------------------------- - */ -haddr_t -H5MF_vfd_alloc(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, hsize_t size, - hbool_t keep_fragment) -{ - haddr_t eoa; /* Initial EOA for the file */ - haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ - hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ - - FUNC_ENTER_NOAPI(HADDR_UNDEF) -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); -#endif /* H5MF_ALLOC_DEBUG */ - - /* check arguments */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); - HDassert(size > 0); - - /* Get the EOA for the file -- need for sanity check below */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") - - /* Check for overlap into temporary allocation space */ - if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "hdr file space alloc will overlap into 'temporary' file space") - - /* Allocate space for the header */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, f, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space for hdr") - - /* Sanity check for overlapping into file's temporary allocation space */ - HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); - - /* If the file alignment is 1, there should be no eoa fragment */ - HDassert((eoa_frag_size == 0) || (f->shared->alignment != 1)); - - /* Check if fragment was generated and we want to keep it */ - if(keep_fragment && eoa_frag_size > 0) { - /* Sanity check */ - HDassert(H5F_addr_defined(eoa_frag_addr)); - - /* Put fragment on the free list */ - if(H5MF_xfree(f, alloc_type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - } /* end if */ - -done: -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); -#endif /* H5MF_ALLOC_DEBUG */ -#ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, dxpl_id, stderr); -#endif /* H5MF_ALLOC_DEBUG_DUMP */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_vfd_alloc() */ - - -/*------------------------------------------------------------------------- * Function: H5MF_aggr_vfd_alloc * - * Purpose: Allocate SIZE bytes of file memory via H5MF_aggr_alloc() + * Purpose: Allocate SIZE bytes of file memory via H5MF__aggr_alloc() * and return the relative address where that contiguous chunk * of file memory exists. * The TYPE argument describes the purpose for which the storage @@ -177,9 +102,9 @@ H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) -#ifdef H5MF_ALLOC_DEBUG +#ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); -#endif /* H5MF_ALLOC_DEBUG */ +#endif /* H5MF_AGGR_DEBUG */ /* check arguments */ HDassert(f); @@ -190,12 +115,12 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ /* Couldn't find anything from the free space manager, go allocate some */ if(alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { /* Handle metadata differently from "raw" data */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) + if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, dxpl_id, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") } /* end if */ else { /* Allocate "raw" data: H5FD_MEM_DRAW and H5FD_MEM_GHEAP */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), H5FD_MEM_DRAW, size))) + if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), H5FD_MEM_DRAW, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") } /* end else */ @@ -203,19 +128,16 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); done: -#ifdef H5MF_ALLOC_DEBUG +#ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); -#endif /* H5MF_ALLOC_DEBUG */ -#ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, dxpl_id, stderr); -#endif /* H5MF_ALLOC_DEBUG_DUMP */ +#endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_vfd_alloc() */ /*------------------------------------------------------------------------- - * Function: H5MF_aggr_alloc + * Function: H5MF__aggr_alloc * * Purpose: Try to allocate SIZE bytes of memory from an aggregator * block if possible. @@ -228,8 +150,8 @@ H5MF_sects_dump(f, dxpl_id, stderr); * *------------------------------------------------------------------------- */ -haddr_t -H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, +static haddr_t +H5MF__aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ @@ -237,7 +159,7 @@ H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI(HADDR_UNDEF) + FUNC_ENTER_STATIC #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5MF_AGGR_DEBUG */ @@ -257,11 +179,11 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") /* - * If the aggregation feature is enabled for this file and strategy is not H5F_FILE_SPACE_VFD, + * If the aggregation feature is enabled for this file and strategy is not H5F_FILE_SPACE_NONE, * allocate "generic" space and sub-allocate out of that, if possible. - * Otherwise just allocate through H5FD_alloc(). + * Otherwise just allocate through H5F_alloc(). */ - if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FILE_SPACE_VFD) { + if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE) { haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */ hsize_t alignment; /* Alignment of this section */ @@ -273,12 +195,12 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz #endif /* H5MF_AGGR_DEBUG */ /* Turn off alignment if allocation < threshold */ - alignment = f->shared->alignment; - if(!((alignment > 1) && (size >= f->shared->threshold))) + alignment = H5F_ALIGNMENT(f); + if(!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) alignment = 0; /* no alignment */ /* Generate fragment if aggregator is mis-aligned */ - if(alignment && aggr->addr > 0 && (aggr_mis_align = (aggr->addr + H5FD_get_base_addr(f->shared->lf)) % alignment)) { + if(alignment && H5F_addr_gt(aggr->addr, 0) && (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { aggr_frag_addr = aggr->addr; aggr_frag_size = alignment - aggr_mis_align; } /* end if */ @@ -288,7 +210,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz /* Check if the space requested is larger than the space left in the block */ if((size + aggr_frag_size) > aggr->size) { - htri_t was_extended = FALSE; /* Whether the file was extended */ + htri_t extended = FALSE; /* Whether the file was extended */ /* Check if the block asked for is too large for 'normal' aggregator block */ if(size >= aggr->alloc_size) { @@ -298,32 +220,27 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if((aggr->addr > 0) && (was_extended = H5FD_try_extend(f->shared->lf, alloc_type, f, dxpl_id, aggr->addr + aggr->size, ext_size)) < 0) + if((aggr->addr > 0) && (extended = H5F_try_extend(f, dxpl_id, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(was_extended) { + else if (extended) { /* aggr->size is unchanged */ ret_value = aggr->addr + aggr_frag_size; aggr->addr += ext_size; aggr->tot_size += ext_size; - } /* end else-if */ - else { - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - + } else { /* Release "other" aggregator, if it exists, is at the end of the allocated space, * has allocated more than one block and the unallocated space is greater than its * allocation block size. */ if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF_aggr_free(f, dxpl_id, other_alloc_type, other_aggr) < 0) + if(H5MF__aggr_free(f, dxpl_id, other_alloc_type, other_aggr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") } /* end if */ /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, f, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") + if(HADDR_UNDEF == (ret_value = H5F_alloc(f, dxpl_id, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") } /* end else */ } /* end if */ else { @@ -341,9 +258,9 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if((aggr->addr > 0) && (was_extended = H5FD_try_extend(f->shared->lf, alloc_type, f, dxpl_id, aggr->addr + aggr->size, ext_size)) < 0) + if((aggr->addr > 0) && (extended = H5F_try_extend(f, dxpl_id, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(was_extended) { + else if(extended) { aggr->addr += aggr_frag_size; aggr->size += (ext_size - aggr_frag_size); aggr->tot_size += ext_size; @@ -351,23 +268,19 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); else { haddr_t new_space; /* Address of new space allocated */ - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((eoa + aggr->alloc_size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - /* Release "other" aggregator, if it exists, is at the end of the allocated space, * has allocated more than one block and the unallocated space is greater than its * allocation block size. */ if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF_aggr_free(f, dxpl_id, other_alloc_type, other_aggr) < 0) + if(H5MF__aggr_free(f, dxpl_id, other_alloc_type, other_aggr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") } /* end if */ /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, f, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") + if(HADDR_UNDEF == (new_space = H5F_alloc(f, dxpl_id, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Return the unused portion of the block to a free list */ if(aggr->size > 0) @@ -408,7 +321,7 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") /* Freeing any possible fragment due to alignment in the block after extension */ - if(was_extended && aggr_frag_size) + if(extended && aggr_frag_size) if(H5MF_xfree(f, alloc_type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") } /* end if */ @@ -425,12 +338,8 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); } /* end else */ } /* end if */ else { - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - /* Allocate data from the file */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, f, size, &eoa_frag_addr, &eoa_frag_size))) + if(HADDR_UNDEF == (ret_value = H5F_alloc(f, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Check if fragment was generated */ @@ -444,15 +353,15 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); /* Post-condition sanity check */ - if(f->shared->alignment && size >= f->shared->threshold) - HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % f->shared->alignment)); + if(H5F_ALIGNMENT(f) && size >= H5F_THRESHOLD(f)) + HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % H5F_ALIGNMENT(f))); done: #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_aggr_alloc() */ +} /* end H5MF__aggr_alloc() */ /*------------------------------------------------------------------------- @@ -524,7 +433,7 @@ H5MF_aggr_try_extend(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, else { hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; - if((ret_value = H5FD_try_extend(f->shared->lf, type, f, dxpl_id, (aggr->addr + aggr->size), extra)) < 0) + if((ret_value = H5F_try_extend(f, dxpl_id, type, (aggr->addr + aggr->size), extra)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") else if(ret_value == TRUE) { /* Shift the aggregator block by the extra requested */ @@ -905,7 +814,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_aggr_free + * Function: H5MF__aggr_free * * Purpose: Free the aggregator's space in the file. * @@ -919,11 +828,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_aggr_t *aggr) +H5MF__aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_aggr_t *aggr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -936,7 +845,7 @@ H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_aggr_t *aggr) HDassert(f->shared->feature_flags & aggr->feature_flag); /* Free the remaining space at EOA in the aggregator */ - if(H5FD_free(f->shared->lf, dxpl_id, type, f, aggr->addr, aggr->size) < 0) + if(H5F_free(f, dxpl_id, type, aggr->addr, aggr->size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregation block") /* Reset the aggregator */ @@ -946,7 +855,7 @@ H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_aggr_t *aggr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_aggr_free() */ +} /* H5MF__aggr_free() */ /*------------------------------------------------------------------------- @@ -978,13 +887,13 @@ H5MF_aggrs_try_shrink_eoa(H5F_t *f, hid_t dxpl_id) if((ma_status = H5MF_aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") if(ma_status > 0) - if(H5MF_aggr_free(f, dxpl_id, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) + if(H5MF__aggr_free(f, dxpl_id, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") if((sda_status = H5MF_aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") if(sda_status > 0) - if(H5MF_aggr_free(f, dxpl_id, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) + if(H5MF__aggr_free(f, dxpl_id, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") ret_value = (ma_status || sda_status); diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index 57bac9e..817ea00 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -116,7 +116,9 @@ H5MF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) /* Print generic section information */ HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, "Section type:", - (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE ? "simple" : "unknown")); + (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE ? "simple" : + (sect->sect_info.type == H5MF_FSPACE_SECT_SMALL ? "small" : + (sect->sect_info.type == H5MF_FSPACE_SECT_LARGE ? "large" : "unknown")))); HDfprintf(udata->stream, "%*s%-*s %a\n", udata->indent, "", udata->fwidth, "Section address:", sect->sect_info.addr); @@ -171,7 +173,7 @@ H5MF_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, FILE *stream, int ind for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) if(H5F_addr_eq(f->shared->fs_addr[type], fs_addr)) { if(!f->shared->fs_man[type]) - if(H5MF__alloc_open(f, dxpl_id, type) < 0) + if(H5MF_open_fstype(f, dxpl_id, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") if(f->shared->fs_man[type]) { @@ -217,11 +219,6 @@ herr_t H5MF_sects_dump(H5F_t *f, hid_t dxpl_id, FILE *stream) { haddr_t eoa; /* End of allocated space in the file */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - H5FD_mem_t type; /* Memory type for iteration */ int indent = 0; /* Amount to indent */ int fwidth = 50; /* Field width */ herr_t ret_value = SUCCEED; /* Return value */ @@ -244,56 +241,90 @@ HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); #endif /* H5MF_ALLOC_DEBUG */ - /* Retrieve metadata aggregator info, if available */ - H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); -#endif /* H5MF_ALLOC_DEBUG */ + if(H5F_PAGED_AGGR(f)) { /* File space paging */ + H5F_mem_page_t ptype; /* Memory type for iteration -- page fs */ - /* Retrieve 'small data' aggregator info, if available */ - H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); -#ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); -#endif /* H5MF_ALLOC_DEBUG */ - - /* Iterate over all the free space types that have managers and dump each free list's space */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { - /* Print header for type */ - HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)type); - - /* Check for this type being mapped to another type */ - if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[type] || - type == f->shared->fs_type_map[type]) { - /* Retrieve the 'eoa' for this file memory type */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "eoa:", eoa); + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) { + /* Print header for type */ + HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)ptype); /* Print header for sections */ HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs_man[type]) { + if(f->shared->fs_man[ptype]) { H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ - udata.fspace = f->shared->fs_man[type]; + udata.fspace = f->shared->fs_man[ptype]; udata.stream = stream; udata.indent = indent + 6; udata.fwidth = MAX(0, fwidth - 6); /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, dxpl_id, f->shared->fs_man[type], H5MF_sects_debug_cb, &udata) < 0) + if(H5FS_sect_iterate(f, dxpl_id, f->shared->fs_man[ptype], H5MF_sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") } /* end if */ else /* No sections of this type */ HDfprintf(stream, "%*s\n", indent + 6, ""); - } /* end if */ - else - HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", (unsigned)f->shared->fs_type_map[type]); + } /* end for */ + } /* end if */ + else { /* not file space paging */ + H5FD_mem_t atype; /* Memory type for iteration -- aggr fs */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + + /* Retrieve metadata aggregator info, if available */ + H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); +#endif /* H5MF_ALLOC_DEBUG */ + + /* Retrieve 'small data' aggregator info, if available */ + H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); +#endif /* H5MF_ALLOC_DEBUG */ - } /* end for */ + /* Iterate over all the free space types that have managers and dump each free list's space */ + for(atype = H5FD_MEM_DEFAULT; atype < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, atype)) { + /* Print header for type */ + HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)atype); + + /* Check for this type being mapped to another type */ + if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[atype] || atype == f->shared->fs_type_map[atype]) { + /* Retrieve the 'eoa' for this file memory type */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, atype))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "eoa:", eoa); + + /* Print header for sections */ + HDfprintf(stream, "%*sSections:\n", indent + 3, ""); + + /* If there is a free space manager for this type, iterate over them */ + if(f->shared->fs.aggr.fs_man[atype]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + + /* Prepare user data for section iteration callback */ + udata.fspace = f->shared->fs_man[atype]; + udata.stream = stream; + udata.indent = indent + 6; + udata.fwidth = MAX(0, fwidth - 6); + + /* Iterate over all the free space sections */ + if(H5FS_sect_iterate(f, dxpl_id, f->shared->fs_man[atype], H5MF_sects_debug_cb, &udata) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") + } /* end if */ + else /* No sections of this type */ + HDfprintf(stream, "%*s\n", indent + 6, ""); + } /* end if */ + else + HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", (unsigned)f->shared->fs_type_map[atype]); + } /* end for */ + } /* end else */ done: HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 43fc1cd..c4a0819 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -51,9 +51,38 @@ /* Define this to dump free space tracker contents after they've been modified */ /* #define H5MF_ALLOC_DEBUG_DUMP */ -/* Free space section types for file */ +/* Free-space section types for file */ /* (values stored in free space data structures in file) */ -#define H5MF_FSPACE_SECT_SIMPLE 0 /* Section is a range of actual bytes in file */ +#define H5MF_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file */ +#define H5MF_FSPACE_SECT_SMALL 1 /* For paged aggregation: "small" meta/raw data section which is < fsp_size) */ +#define H5MF_FSPACE_SECT_LARGE 2 /* For paged aggregation: "large" Section which is >= fsp_size) */ + +/* For non-paged aggregation: map allocation request type to tracked free-space type */ +/* F -- pointer to H5F_t; T -- H5FD_mem_t */ +#define H5MF_ALLOC_TO_FS_AGGR_TYPE(F, T) \ + ((H5FD_MEM_DEFAULT == (F)->shared->fs_type_map[T]) ? (T) : (F)->shared->fs_type_map[T]) + +/* Get section class type based on size */ +#define H5MF_SECT_CLASS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) ? \ + ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_LARGE : H5MF_FSPACE_SECT_SMALL) : H5MF_FSPACE_SECT_SIMPLE) + +/* Get section class cls */ +#define H5MF_SECT_CLS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) ? \ + ((S >= (F)->shared->fs_page_size) ? \ + H5MF_FSPACE_SECT_CLS_LARGE : H5MF_FSPACE_SECT_CLS_SMALL) : H5MF_FSPACE_SECT_CLS_SIMPLE) + +/* Calculate the mis-aligned fragment */ +#define H5MF_EOA_MISALIGN(F, E, A, FR) \ +{ \ + hsize_t m; \ + \ + if(H5F_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ + (FR) = (A) - m; \ + else \ + (FR) = 0; \ +} /****************************/ @@ -129,6 +158,15 @@ typedef struct H5MF_sect_ud_t { H5F_blk_aggr_t *aggr; /* Aggregator block to operate on */ } H5MF_sect_ud_t; +/* Information about the current free-space manager to use */ +typedef struct H5MF_fs_t { + H5F_fs_state_t *fs_state; + haddr_t *fs_addr; + H5FS_t **fs_man; + hsize_t align_thres; /* Threshold for alignment */ + hsize_t alignment; /* Alignment */ +} H5MF_fs_t; + /*****************************/ /* Package Private Variables */ @@ -136,6 +174,8 @@ typedef struct H5MF_sect_ud_t { /* H5MF single section inherits serializable properties from H5FS_section_class_t */ H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; +H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; +H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; /******************************/ @@ -143,22 +183,23 @@ H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; /******************************/ /* Allocator routines */ -H5_DLL herr_t H5MF__alloc_start(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type); -H5_DLL herr_t H5MF__alloc_open(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type); +H5_DLL herr_t H5MF_open_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); +H5_DLL herr_t H5MF_start_fstype(H5F_t *f, hid_t dxpl_id, H5F_mem_page_t type); + +H5_DLL htri_t H5MF_find_sect(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size, H5FS_t *fspace, haddr_t *addr); +H5_DLL herr_t H5MF_add_sect(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, H5FS_t *fspace, H5MF_free_section_t *node); + H5_DLL herr_t H5MF_sects_dump(H5F_t *f, hid_t dxpl_id, FILE *stream); -/* 'simple' section routines */ -H5_DLL H5MF_free_section_t *H5MF_sect_simple_new(haddr_t sect_off, +H5_DLL void H5MF_alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type); + +/* 'simple/small/large' section routines */ +H5_DLL H5MF_free_section_t *H5MF_sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size); -H5_DLL htri_t H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -H5_DLL herr_t H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, - void *udata); -H5_DLL herr_t H5MF_sect_simple_free(H5FS_section_info_t *sect); +H5_DLL herr_t H5MF_sect_free(H5FS_section_info_t *sect); + /* Block aggregator routines */ -H5_DLL haddr_t H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, - H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size); H5_DLL htri_t H5MF_aggr_try_extend(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t abs_blk_end, hsize_t extra_requested); H5_DLL htri_t H5MF_aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index e258677..70322c3 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -58,8 +58,6 @@ H5_DLL herr_t H5MF_try_close(H5F_t *f, hid_t dxpl_id); /* File space allocation routines */ H5_DLL haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); H5_DLL haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -H5_DLL haddr_t H5MF_vfd_alloc(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, - hsize_t size, hbool_t keep_fragment); H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL herr_t H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, @@ -80,6 +78,14 @@ H5_DLL htri_t H5MF_aggrs_try_shrink_eoa(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5MF_settle_raw_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled); H5_DLL herr_t H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled); +/* This function has to be declared in H5MFprivate.h as it is needed + * in our test code to allow us to manually start a self referential + * free space manager prior to the first file space allocations / + * deallocation without causing assertion failures on the first + * file space allocation / deallocation. + */ +H5_DLL herr_t H5MF_tidy_self_referential_fsm_hack(H5F_t *f, hid_t dxpl_id); + /* Debugging routines */ #ifdef H5MF_DEBUGGING H5_DLL herr_t H5MF_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, diff --git a/src/H5MFsection.c b/src/H5MFsection.c index e5a0cf0..617cb59 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -57,18 +57,47 @@ /* Local Prototypes */ /********************/ -/* 'simple' section callbacks */ -static H5FS_section_info_t *H5MF_sect_simple_deserialize(const H5FS_section_class_t *cls, +/* 'simple/small/large' section callbacks */ +static H5FS_section_info_t *H5MF_sect_deserialize(const H5FS_section_class_t *cls, hid_t dxpl_id, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); +static herr_t H5MF_sect_valid(const H5FS_section_class_t *cls, + const H5FS_section_info_t *sect, hid_t dxpl_id); +static H5FS_section_info_t *H5MF_sect_split(H5FS_section_info_t *sect, + hsize_t frag_size); + + +/* 'simple' section callbacks */ static htri_t H5MF_sect_simple_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF_sect_simple_merge(H5FS_section_info_t *sect1, +static herr_t H5MF_sect_simple_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF_sect_simple_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect, hid_t dxpl_id); -static H5FS_section_info_t *H5MF_sect_simple_split(H5FS_section_info_t *sect, - hsize_t frag_size); +static htri_t H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, + void *udata); +static herr_t H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, + void *udata); + + +/* 'small' section callbacks */ +static herr_t H5MF_sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata); +static htri_t H5MF_sect_small_can_merge(const H5FS_section_info_t *sect1, + const H5FS_section_info_t *sect2, void *udata); +static herr_t H5MF_sect_small_merge(H5FS_section_info_t **sect1, + H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF_sect_small_can_shrink(const H5FS_section_info_t *_sect, + void *udata); +static herr_t H5MF_sect_small_shrink(H5FS_section_info_t **_sect, + void *udata); + +/* 'large' section callbacks */ +static htri_t H5MF_sect_large_can_merge(const H5FS_section_info_t *sect1, + const H5FS_section_info_t *sect2, void *udata); +static herr_t H5MF_sect_large_merge(H5FS_section_info_t **sect1, + H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF_sect_large_can_shrink(const H5FS_section_info_t *_sect, + void *udata); +static herr_t H5MF_sect_large_shrink(H5FS_section_info_t **_sect, + void *udata); /*********************/ /* Package Variables */ @@ -89,17 +118,68 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Object methods */ NULL, /* Add section */ NULL, /* Serialize section */ - H5MF_sect_simple_deserialize, /* Deserialize section */ + H5MF_sect_deserialize, /* Deserialize section */ H5MF_sect_simple_can_merge, /* Can sections merge? */ H5MF_sect_simple_merge, /* Merge sections */ H5MF_sect_simple_can_shrink, /* Can section shrink container?*/ H5MF_sect_simple_shrink, /* Shrink container w/section */ - H5MF_sect_simple_free, /* Free section */ - H5MF_sect_simple_valid, /* Check validity of section */ - H5MF_sect_simple_split, /* Split section node for alignment */ + H5MF_sect_free, /* Free section */ + H5MF_sect_valid, /* Check validity of section */ + H5MF_sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; +/* Class info for "small" free space sections */ +H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ + /* Class variables */ + H5MF_FSPACE_SECT_SMALL, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ + + /* Class methods */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ + + /* Object methods */ + H5MF_sect_small_add, /* Add section */ + NULL, /* Serialize section */ + H5MF_sect_deserialize, /* Deserialize section */ + H5MF_sect_small_can_merge, /* Can sections merge? */ + H5MF_sect_small_merge, /* Merge sections */ + H5MF_sect_small_can_shrink, /* Can section shrink container?*/ + H5MF_sect_small_shrink, /* Shrink container w/section */ + H5MF_sect_free, /* Free section */ + H5MF_sect_valid, /* Check validity of section */ + H5MF_sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ +}}; + +/* Class info for "large" free space sections */ +H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ + /* Class variables */ + H5MF_FSPACE_SECT_LARGE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ + + /* Class methods */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ + + /* Object methods */ + NULL, /* Add section */ + NULL, /* Serialize section */ + H5MF_sect_deserialize, /* Deserialize section */ + H5MF_sect_large_can_merge, /* Can sections merge? */ + H5MF_sect_large_merge, /* Merge sections */ + H5MF_sect_large_can_shrink, /* Can section shrink container?*/ + H5MF_sect_large_shrink, /* Shrink container w/section */ + H5MF_sect_free, /* Free section */ + H5MF_sect_valid, /* Check validity of section */ + H5MF_sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ +}}; /*****************************/ /* Library Private Variables */ @@ -113,12 +193,15 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Declare a free list to manage the H5MF_free_section_t struct */ H5FL_DEFINE(H5MF_free_section_t); +/* + * "simple/small/large" section callbacks + */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_new + * Function: H5MF_sect_new * - * Purpose: Create a new 'simple' section and return it to the caller + * Purpose: Create a new section of "ctype" and return it to the caller * * Return: Pointer to new section on success/NULL on failure * @@ -129,9 +212,9 @@ H5FL_DEFINE(H5MF_free_section_t); *------------------------------------------------------------------------- */ H5MF_free_section_t * -H5MF_sect_simple_new(haddr_t sect_off, hsize_t sect_size) +H5MF_sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) { - H5MF_free_section_t *sect = NULL; /* 'Simple' free space section to add */ + H5MF_free_section_t *sect; /* 'Simple' free space section to add */ H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -148,7 +231,7 @@ H5MF_sect_simple_new(haddr_t sect_off, hsize_t sect_size) sect->sect_info.size = sect_size; /* Set the section's class & state */ - sect->sect_info.type = H5MF_FSPACE_SECT_SIMPLE; + sect->sect_info.type = ctype; sect->sect_info.state = H5FS_SECT_LIVE; /* Set return value */ @@ -156,13 +239,43 @@ H5MF_sect_simple_new(haddr_t sect_off, hsize_t sect_size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_sect_simple_new() */ +} /* end H5MF_sect_new() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_deserialize + * Function: H5MF_sect_free * - * Purpose: Deserialize a buffer into a "live" single section + * Purpose: Free a 'simple/small/large' section node + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Tuesday, January 8, 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5MF_sect_free(H5FS_section_info_t *_sect) +{ + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments. */ + HDassert(sect); + + /* Release the section */ + sect = H5FL_FREE(H5MF_free_section_t, sect); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5MF_sect_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_deserialize + * + * Purpose: Deserialize a buffer into a "live" section * * Return: Success: non-negative * Failure: negative @@ -173,7 +286,7 @@ done: *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5MF_sect_simple_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, +H5MF_sect_deserialize(const H5FS_section_class_t *cls, hid_t H5_ATTR_UNUSED dxpl_id, const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { @@ -183,11 +296,12 @@ H5MF_sect_simple_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, FUNC_ENTER_NOAPI_NOINIT /* Check arguments. */ + HDassert(cls); HDassert(H5F_addr_defined(sect_addr)); HDassert(sect_size); /* Create free space section for block */ - if(NULL == (sect = H5MF_sect_simple_new(sect_addr, sect_size))) + if(NULL == (sect = H5MF_sect_new(cls->type, sect_addr, sect_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set return value */ @@ -195,10 +309,80 @@ H5MF_sect_simple_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_simple_deserialize() */ +} /* H5MF_sect_deserialize() */ /*------------------------------------------------------------------------- + * Function: H5MF_sect_valid + * + * Purpose: Check the validity of a section + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Tuesday, January 8, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF_sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, + const H5FS_section_info_t +#ifdef NDEBUG + H5_ATTR_UNUSED +#endif /* NDEBUG */ + *_sect, hid_t H5_ATTR_UNUSED dxpl_id) +{ +#ifndef NDEBUG + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ +#endif /* NDEBUG */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments. */ + HDassert(sect); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5MF_sect_valid() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_split + * + * Purpose: Split SECT into 2 sections: fragment for alignment & the aligned section + * SECT's addr and size are updated to point to the aligned section + * + * Return: Success: the fragment for aligning sect + * Failure: null + * + * Programmer: Vailin Choi, July 29, 2008 + * + *------------------------------------------------------------------------- + */ +static H5FS_section_info_t * +H5MF_sect_split(H5FS_section_info_t *sect, hsize_t frag_size) +{ + H5MF_free_section_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Allocate space for new section */ + if(NULL == (ret_value = H5MF_sect_new(sect->type, sect->addr, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") + + /* Set new section's info */ + sect->addr += frag_size; + sect->size -= frag_size; + +done: + FUNC_LEAVE_NOAPI((H5FS_section_info_t *)ret_value) +} /* end H5MF_sect_split() */ + +/* + * "simple" section callbacks + */ + +/*------------------------------------------------------------------------- * Function: H5MF_sect_simple_can_merge * * Purpose: Can two sections of this type merge? @@ -252,10 +436,10 @@ H5MF_sect_simple_can_merge(const H5FS_section_info_t *_sect1, *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_simple_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, +H5MF_sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { - H5MF_free_section_t *sect1 = (H5MF_free_section_t *)_sect1; /* File free section */ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ herr_t ret_value = SUCCEED; /* Return value */ @@ -263,16 +447,16 @@ H5MF_sect_simple_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, /* Check arguments. */ HDassert(sect1); - HDassert(sect1->sect_info.type == H5MF_FSPACE_SECT_SIMPLE); + HDassert((*sect1)->sect_info.type == H5MF_FSPACE_SECT_SIMPLE); HDassert(sect2); HDassert(sect2->sect_info.type == H5MF_FSPACE_SECT_SIMPLE); - HDassert(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)); + HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); /* Add second section's size to first section */ - sect1->sect_info.size += sect2->sect_info.size; + (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)sect2) < 0) + if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: @@ -293,7 +477,7 @@ done: * *------------------------------------------------------------------------- */ -htri_t +static htri_t H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ @@ -392,7 +576,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ @@ -411,8 +595,8 @@ H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) /* Sanity check */ HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); - /* Release section's space at EOA with file driver */ - if(H5FD_free(udata->f->shared->lf, udata->dxpl_id, udata->alloc_type, udata->f, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + /* Release section's space at EOA */ + if(H5F_free(udata->f, udata->dxpl_id, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ else { @@ -427,7 +611,7 @@ H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) /* Check for freeing section */ if(udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { /* Free section */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)*sect) < 0) + if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -438,100 +622,474 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF_sect_simple_shrink() */ +/* + * "small" section callbacks + */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_small_add + * + * Purpose: Perform actions on a small "meta" action before adding it to the free space manager: + * 1) Drop the section if it is at page end and its size <= page end threshold + * 2) Adjust section size to include page end threshold if + * (section size + threshold) is at page end + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF_sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) +{ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* Fractal heap free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t sect_end; + hsize_t rem, prem; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Do not adjust the section raw data or global heap data */ + if(udata->alloc_type == H5FD_MEM_DRAW || udata->alloc_type == H5FD_MEM_GHEAP) + HGOTO_DONE(ret_value); + + sect_end = (*sect)->sect_info.addr + (*sect)->sect_info.size; + rem = sect_end % udata->f->shared->fs_page_size; + prem = udata->f->shared->fs_page_size - rem; + + /* Drop the section if it is at page end and its size is <= pgend threshold */ + if(!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && (*flags & H5FS_ADD_RETURNED_SPACE)) { + if(H5MF_sect_free((H5FS_section_info_t *)(*sect)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") + *sect = NULL; + *flags &= (unsigned)~H5FS_ADD_RETURNED_SPACE; + *flags |= H5FS_PAGE_END_NO_ADD; +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: section is dropped\n", FUNC); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + } /* end if */ + /* Adjust the section if it is not at page end but its size + pgend threshold is at page end */ + else + if(prem <= H5F_PGEND_META_THRES(udata->f)) { + (*sect)->sect_info.size += prem; +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_small_add() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_small_can_shrink + * + * Purpose: Can this section shrink the container? + * + * Note: A small section is allowed to shrink only at closing. + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5MF_sect_small_can_shrink(const H5FS_section_info_t *_sect, void *_udata) +{ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t eoa; /* End of address space in the file */ + haddr_t end; /* End of section to extend */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments. */ + HDassert(sect); + HDassert(udata); + HDassert(udata->f); + + /* Retrieve the end of the file's address space */ + if(HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + /* Compute address of end of section to check */ + end = sect->sect_info.addr + sect->sect_info.size; + + /* Check if the section is exactly at the end of the allocated space in the file */ + if(H5F_addr_eq(end, eoa) && sect->sect_info.size == udata->f->shared->fs_page_size) { + udata->shrink = H5MF_SHRINK_EOA; + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, sect->sect_info.size, eoa); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + /* Indicate shrinking can occur */ + HGOTO_DONE(TRUE) + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_small_can_shrink() */ + /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_free + * Function: H5MF_sect_small_shrink * - * Purpose: Free a 'single' section node + * Purpose: Shrink container with section * * Return: Success: non-negative - * Failure: negative + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 * - * Programmer: Quincey Koziol - * Tuesday, January 8, 2008 + *------------------------------------------------------------------------- + */ +static herr_t +H5MF_sect_small_shrink(H5FS_section_info_t **_sect, void *_udata) +{ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments. */ + HDassert(sect); + HDassert((*sect)->sect_info.type == H5MF_FSPACE_SECT_SMALL); + HDassert(udata); + HDassert(udata->f); + HDassert(udata->shrink == H5MF_SHRINK_EOA); + HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); + + /* Release section's space at EOA */ + if(H5F_free(udata->f, udata->dxpl_id, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") + + /* Free section */ + if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") + + /* Mark section as freed, for free space manager */ + *sect = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_small_shrink() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_small_can_merge + * + * Purpose: Can two sections of this type merge? + * + * Note: Second section must be "after" first section + * The "merged" section cannot cross page boundary. + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 * *------------------------------------------------------------------------- */ -herr_t -H5MF_sect_simple_free(H5FS_section_info_t *_sect) +static htri_t +H5MF_sect_small_can_merge(const H5FS_section_info_t *_sect1, + const H5FS_section_info_t *_sect2, void *_udata) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ + const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ + const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check arguments. */ - HDassert(sect); + HDassert(sect1); + HDassert(sect2); + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); - /* Release the section */ - sect = H5FL_FREE(H5MF_free_section_t, sect); + /* Check if second section adjoins first section */ + ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); + if(ret_value > 0) + /* If they are on different pages, couldn't merge */ + if((sect1->sect_info.addr / udata->f->shared->fs_page_size) != (((sect2->sect_info.addr + sect2->sect_info.size - 1) / udata->f->shared->fs_page_size))) + ret_value = FALSE; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sect_simple_free() */ +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_small_can_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_valid + * Function: H5MF_sect_small_merge * - * Purpose: Check the validity of a section + * Purpose: Merge two sections of this type + * + * Note: Second section always merges into first node. + * If the size of the "merged" section is equal to file space page size, + * free the section. * * Return: Success: non-negative * Failure: negative * - * Programmer: Quincey Koziol - * Tuesday, January 8, 2008 + * Programmer: Vailin Choi; Dec 2012 * *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_simple_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, - const H5FS_section_info_t -#ifdef NDEBUG - H5_ATTR_UNUSED -#endif /* NDEBUG */ - *_sect, hid_t H5_ATTR_UNUSED dxpl_id) +H5MF_sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, + void *_udata) { -#ifndef NDEBUG - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ -#endif /* NDEBUG */ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ + H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments. */ + HDassert(sect1); + HDassert((*sect1)->sect_info.type == H5MF_FSPACE_SECT_SMALL); + HDassert(sect2); + HDassert(sect2->sect_info.type == H5MF_FSPACE_SECT_SMALL); + HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); + + /* Add second section's size to first section */ + (*sect1)->sect_info.size += sect2->sect_info.size; + + if((*sect1)->sect_info.size == udata->f->shared->fs_page_size) { + if(H5MF_xfree(udata->f, udata->alloc_type, udata->dxpl_id, (*sect1)->sect_info.addr, (*sect1)->sect_info.size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") + + /* Need to free possible metadata page in the PB cache */ + /* This is in response to the data corruption bug from fheap.c with page buffering + page strategy */ + /* Note: Large metadata page bypasses the PB cache */ + /* Note: Update of raw data page (large or small sized) is handled by the PB cache */ + if(udata->f->shared->page_buf != NULL && udata->alloc_type != H5FD_MEM_DRAW) + if(H5PB_remove_entry(udata->f, (*sect1)->sect_info.addr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") + + if(H5MF_sect_free((H5FS_section_info_t *)(*sect1)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") + *sect1 = NULL; + } /* end if */ + + /* Get rid of second section */ + if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_small_merge() */ + +/* + * "Large" section callbacks + */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_large_can_merge (same as H5MF_sect_simple_can_merge) + * + * Purpose: Can two sections of this type merge? + * + * Note: Second section must be "after" first section + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5MF_sect_large_can_merge(const H5FS_section_info_t *_sect1, + const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +{ + const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ + const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check arguments. */ + HDassert(sect1); + HDassert(sect2); + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); + + ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); + +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_large_can_merge() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_large_merge (same as H5MF_sect_simple_merge) + * + * Purpose: Merge two sections of this type + * + * Note: Second section always merges into first node + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5MF_sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) +{ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ + H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments. */ + HDassert(sect1); + HDassert((*sect1)->sect_info.type == H5MF_FSPACE_SECT_LARGE); + HDassert(sect2); + HDassert(sect2->sect_info.type == H5MF_FSPACE_SECT_LARGE); + HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); + + /* Add second section's size to first section */ + (*sect1)->sect_info.size += sect2->sect_info.size; + + /* Get rid of second section */ + if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_large_merge() */ + + +/*------------------------------------------------------------------------- + * Function: H5MF_sect_large_can_shrink + * + * Purpose: Can this section shrink the container? + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi; Dec 2012 + * + *------------------------------------------------------------------------- + */ +static htri_t +H5MF_sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) +{ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t eoa; /* End of address space in the file */ + haddr_t end; /* End of section to extend */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments. */ HDassert(sect); + HDassert(sect->sect_info.type == H5MF_FSPACE_SECT_LARGE); + HDassert(udata); + HDassert(udata->f); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sect_simple_valid() */ + /* Retrieve the end of the file's address space */ + if(HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + /* Compute address of end of section to check */ + end = sect->sect_info.addr + sect->sect_info.size; + + /* Check if the section is exactly at the end of the allocated space in the file */ + if(H5F_addr_eq(end, eoa) && sect->sect_info.size >= udata->f->shared->fs_page_size) { + /* Set the shrinking type */ + udata->shrink = H5MF_SHRINK_EOA; +#ifdef H5MF_ALLOC_DEBUG_MORE +HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, sect->sect_info.size, eoa); +#endif /* H5MF_ALLOC_DEBUG_MORE */ + /* Indicate shrinking can occur */ + HGOTO_DONE(TRUE) + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_large_can_shrink() */ + /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_split + * Function: H5MF_sect_large_shrink * - * Purpose: Split SECT into 2 sections: fragment for alignment & the aligned section - * SECT's addr and size are updated to point to the aligned section + * Purpose: Shrink a large-sized section * - * Return: Success: the fragment for aligning sect - * Failure: null + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi, July 29, 2008 + * Programmer: Vailin Choi; Dec 2012 * *------------------------------------------------------------------------- */ -static H5FS_section_info_t * -H5MF_sect_simple_split(H5FS_section_info_t *sect, hsize_t frag_size) +static herr_t +H5MF_sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5MF_free_section_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + hsize_t frag_size = 0; /* Fragment size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - /* Allocate space for new section */ - if(NULL == (ret_value = H5MF_sect_simple_new(sect->addr, frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") + /* Check arguments. */ + HDassert(sect); + HDassert((*sect)->sect_info.type == H5MF_FSPACE_SECT_LARGE); + HDassert(udata); + HDassert(udata->f); + HDassert(udata->shrink == H5MF_SHRINK_EOA); + HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); + HDassert(H5F_PAGED_AGGR(udata->f)); - /* Set new section's info */ - sect->addr += frag_size; - sect->size -= frag_size; + /* Calculate possible mis-aligned fragment */ + H5MF_EOA_MISALIGN(udata->f, (*sect)->sect_info.addr, udata->f->shared->fs_page_size, frag_size); + + /* Free full pages from EOA */ + /* Retain partial page in the free-space manager so as to keep EOA at page boundary */ + if(H5F_free(udata->f, udata->dxpl_id, udata->alloc_type, (*sect)->sect_info.addr+frag_size, (*sect)->sect_info.size-frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") + + if(frag_size) /* Adjust section size for the partial page */ + (*sect)->sect_info.size = frag_size; + else { + /* Free section */ + if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") + + /* Mark section as freed, for free space manager */ + *sect = NULL; + } /* end else */ done: - FUNC_LEAVE_NOAPI((H5FS_section_info_t *)ret_value) -} /* end H5MF_sect_simple_split() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5MF_sect_large_shrink() */ diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 4f98cfa..40c9c38 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -2023,6 +2023,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) /* Second message has been merged, delete it */ if(merged_msg) { H5O_chunk_proxy_t *curr_chk_proxy; /* Chunk that message is in */ + htri_t result; /* Release any information/memory for second message */ H5O_msg_free_mesg(curr_msg2); @@ -2050,6 +2051,13 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) /* (Don't bother reducing size of message array for now -QAK) */ oh->nmesgs--; + /* The merge null message might span the entire chunk: scan for empty chunk to remove */ + if((result = H5O_remove_empty_chunks(f, dxpl_id, oh)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") + else if(result > 0) + /* Get out of loop */ + break; + /* If the merged message is too large, shrink the chunk */ if(curr_msg->raw_size >= H5O_MESG_MAX_SIZE) if(H5O_alloc_shrink_chunk(f, dxpl_id, oh, curr_msg->chunkno) < 0) diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index 65f6aa2..bea99a2 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -33,6 +33,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Opkg.h" /* Object headers */ #include "H5MFprivate.h" /* File space management */ @@ -290,9 +291,50 @@ H5O__mdci_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) HDassert(mesg); /* Free file space for cache image */ - if(H5F_addr_defined(mesg->addr)) - if(H5MF_xfree(f, H5FD_MEM_SUPER, dxpl_id, mesg->addr, mesg->size) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") + if(H5F_addr_defined(mesg->addr)) { + /* The space for the cache image block was allocated directly + * from the VFD layer at the end of file. As this was the + * last file space allocation before shutdown, the cache image + * should still be the last item in the file. + * + * If the hack to work around the self referential free space + * manager issue is in use, file space for the non-empty self + * referential free space managers was also allocated from VFD + * layer at the end of file. Since these allocations directly + * preceeded the cache image allocation they should be directly + * adjacent to the cache image block at the end of file. + * + * In this case, just call H5MF_tidy_self_referential_fsm_hack(). + * + * That routine will float the self referential free space + * managers, and reduce the eoa to its value just prior to + * allocation of space for same. Since the cache image appears + * just after the self referential free space managers, this + * will release the file space for the cache image as well. + * + * Note that in this case, there must not have been any file + * space allocations / deallocations prior to the free of the + * cache image. Verify this to the extent possible. + * + * If the hack to work around the persistant self referential + * free space manager issue is NOT in use, just call H5MF_xfree() + * to release the cache iamge. In principle, we should be able + * to just reduce the EOA to the base address of the cache + * image block, as there shouldn't be any file space allocation + * before the first metadata cache access. However, given + * time constraints, I don't want to go there now. + */ + if(H5F_FIRST_ALLOC_DEALLOC(f)) { + HDassert(HADDR_UNDEF !=H5F_EOA_PRE_FSM_FSALLOC(f)); + HDassert(H5F_addr_ge(mesg->addr, H5F_EOA_PRE_FSM_FSALLOC(f))); + if(H5MF_tidy_self_referential_fsm_hack(f, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") + } /* end if */ + else { + if(H5MF_xfree(f, H5FD_MEM_SUPER, dxpl_id, mesg->addr, mesg->size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") + } /* end else */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index 938d319..37ec627 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -23,12 +23,13 @@ * *------------------------------------------------------------------------- */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "H5Omodule.h" /* This source code file is part of the H5O module */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5Opkg.h" /* Object headers */ @@ -66,7 +67,8 @@ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ }}; /* Current version of free-space manager info information */ -#define H5O_FSINFO_VERSION 0 +#define H5O_FSINFO_VERSION_0 0 +#define H5O_FSINFO_VERSION_1 1 /* Declare a free list to manage the H5O_fsinfo_t struct */ H5FL_DEFINE_STATIC(H5O_fsinfo_t); @@ -85,12 +87,13 @@ H5FL_DEFINE_STATIC(H5O_fsinfo_t); *------------------------------------------------------------------------- */ static void * -H5O_fsinfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, +H5O_fsinfo_decode(H5F_t *f, hid_t dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p) { - H5O_fsinfo_t *fsinfo = NULL; /* free-space manager info */ - H5FD_mem_t type; /* Memory type for iteration */ - void *ret_value = NULL; /* Return value */ + H5O_fsinfo_t *fsinfo = NULL; /* File space info message */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + unsigned vers; /* message version */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -98,26 +101,83 @@ H5O_fsinfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * HDassert(f); HDassert(p); - /* Version of message */ - if(*p++ != H5O_FSINFO_VERSION) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") - /* Allocate space for message */ if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fsinfo->strategy = (H5F_file_space_type_t)*p++; /* file space strategy */ - H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* free space section size threshold */ + for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; - /* Addresses of free space managers: only exist for H5F_FILE_SPACE_ALL_PERSIST */ - if(fsinfo->strategy == H5F_FILE_SPACE_ALL_PERSIST) { - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type-1])); - } /* end if */ - else { - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - fsinfo->fs_addr[type-1] = HADDR_UNDEF; - } /* end else */ + /* Version of message */ + vers = *p++; + + if(vers == H5O_FSINFO_VERSION_0) { + H5F_file_space_type_t strategy; /* Strategy */ + hsize_t threshold; /* Threshold */ + H5FD_mem_t type; /* Memory type for iteration */ + + fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; + fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; + fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; + fsinfo->eoa_pre_fsm_fsalloc = HADDR_UNDEF; + + strategy = (H5F_file_space_type_t)*p++; /* File space strategy */ + H5F_DECODE_LENGTH(f, p, threshold); /* Free-space section threshold */ + + /* Map version 0 (deprecated) to version 1 message */ + switch(strategy) { + + case H5F_FILE_SPACE_ALL_PERSIST: + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->persist = TRUE; + fsinfo->threshold = threshold; + if(HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT)) ) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file size") + for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type-1])); + break; + + case H5F_FILE_SPACE_ALL: + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->threshold = threshold; + break; + + case H5F_FILE_SPACE_AGGR_VFD: + fsinfo->strategy = H5F_FSPACE_STRATEGY_AGGR; + break; + + case H5F_FILE_SPACE_VFD: + fsinfo->strategy = H5F_FSPACE_STRATEGY_NONE; + break; + + case H5F_FILE_SPACE_NTYPES: + case H5F_FILE_SPACE_DEFAULT: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file space strategy") + } /* end switch */ + + fsinfo->mapped = TRUE; + + } else { + HDassert(vers == H5O_FSINFO_VERSION_1); + + fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ + fsinfo->persist = *p++; /* Free-space persist or not */ + H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ + + H5F_DECODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ + UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metdata threshold */ + H5F_addr_decode(f, &p, &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ + + /* Decode addresses of free space managers, if persisting */ + if(fsinfo->persist) { + for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); + } /* end if */ + + fsinfo->mapped = FALSE; + } /* Set return value */ ret_value = fsinfo; @@ -145,7 +205,7 @@ static herr_t H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5FD_mem_t type; /* Memory type for iteration */ + H5F_mem_page_t ptype; /* Memory type for iteration */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -154,14 +214,20 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c HDassert(p); HDassert(fsinfo); - *p++ = H5O_FSINFO_VERSION; /* message version */ - *p++ = fsinfo->strategy; /* file space strategy */ - H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* free-space section size threshold */ + *p++ = H5O_FSINFO_VERSION_1; /* message version */ + *p++ = fsinfo->strategy; /* File space strategy */ + *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ + H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ + + H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ + UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ + H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ - /* Addresses of free space managers: only exist for H5F_FILE_SPACE_ALL_PERSIST */ - if(fsinfo->strategy == H5F_FILE_SPACE_ALL_PERSIST) { - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - H5F_addr_encode(f, &p, fsinfo->fs_addr[type-1]); + /* Store addresses of free-space managers, if persisting */ + if(fsinfo->persist) { + /* Addresses of free-space managers */ + for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -224,19 +290,19 @@ static size_t H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - size_t fs_addr_size = 0; size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Addresses of free-space managers exist only for H5F_FILE_SPACE_ALL_PERSIST type */ - if(H5F_FILE_SPACE_ALL_PERSIST == fsinfo->strategy) - fs_addr_size = (H5FD_MEM_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); - - ret_value = 2 /* Version & strategy */ - + (size_t)H5F_SIZEOF_SIZE(f) /* Threshold */ - + fs_addr_size; /* Addresses of free-space managers */ + ret_value = 3 /* Version, strategy & persist */ + + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ + + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ + + 2 /* Page end meta threshold */ + + (size_t)H5F_SIZEOF_ADDR(f); + + /* Free-space manager addresses */ + if(fsinfo->persist) + ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_size() */ @@ -282,7 +348,7 @@ H5O_fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const vo int indent, int fwidth) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *) _mesg; - H5FD_mem_t type; /* Memory type for iteration */ + H5F_mem_page_t ptype; /* Free-space types for iteration */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -293,16 +359,48 @@ H5O_fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const vo HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "File space strategy:", fsinfo->strategy); + HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "File space strategy:"); + switch(fsinfo->strategy) { + case H5F_FSPACE_STRATEGY_FSM_AGGR: + HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_FSM_AGGR"); + break; + + case H5F_FSPACE_STRATEGY_PAGE: + HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_PAGE"); + break; + + case H5F_FSPACE_STRATEGY_AGGR: + HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_AGGR"); + break; + + case H5F_FSPACE_STRATEGY_NONE: + HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_NONE"); + break; + + case H5F_FSPACE_STRATEGY_NTYPES: + default: + HDfprintf(stream, "%s\n", "unknown"); + } /* end switch */ + + HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, + "Free-space persist:", fsinfo->persist); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Free space section threshold:", fsinfo->threshold); + "Free-space section threshold:", fsinfo->threshold); + + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "File space page size:", fsinfo->page_size); + + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Page end metadata threshold:", fsinfo->pgend_meta_thres); + + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "eoa_pre_fsm_fsalloc:", fsinfo->eoa_pre_fsm_fsalloc); - if(fsinfo->strategy == H5F_FILE_SPACE_ALL_PERSIST) { - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Free space manager address:", fsinfo->fs_addr[type-1]); + if(fsinfo->persist) { + for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Free space manager address:", fsinfo->fs_addr[ptype-1]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 376c888..7e6463a 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -2253,3 +2253,55 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_flush_msgs() */ + +/*------------------------------------------------------------------------- + * Function: H5O_msg_get_flags + * + * Purpose: Queries a message's message flags in the object header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin; Jan 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id, uint8_t *flags) +{ + H5O_t *oh = NULL; /* Object header to use */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + H5O_mesg_t *idx_msg; /* Pointer to message to modify */ + unsigned idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(loc); + HDassert(loc->file); + HDassert(H5F_addr_defined(loc->addr)); + HDassert(type_id < NELMTS(H5O_msg_class_g)); + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + HDassert(type); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + + /* Locate message of correct type */ + for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if(type == idx_msg->type) + break; + + if(idx == oh->nmesgs) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") + + /* Set return value */ + *flags = idx_msg->flags; + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_msg_get_flags() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 71c512c..f0fbe72 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -791,9 +791,16 @@ typedef unsigned H5O_unknown_t; /* Original message type ID */ * (Data structure in memory) */ typedef struct H5O_fsinfo_t { - H5F_file_space_type_t strategy; /* File space strategy */ - hsize_t threshold; /* Free space section threshold */ - haddr_t fs_addr[H5FD_MEM_NTYPES-1]; /* Addresses of free space managers */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persisting free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + hsize_t page_size; /* For paged aggregation: file space page size */ + size_t pgend_meta_thres; /* For paged aggregation: page end metadata threshold */ + haddr_t eoa_pre_fsm_fsalloc; /* For paged aggregation: the eoa before free-space headers & sinfo */ + haddr_t fs_addr[H5F_MEM_PAGE_NTYPES - 1]; /* 13 addresses of free-space managers */ + /* For non-paged aggregation: only 6 addresses are used */ + hbool_t mapped; /* Not stored */ + /* Indicate the message is mapped from version 0 to version 1 */ } H5O_fsinfo_t; /* @@ -920,6 +927,7 @@ H5_DLL void* H5O_msg_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned type_id, const unsigned char *buf); H5_DLL herr_t H5O_msg_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned type_id, void *mesg); +H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id, uint8_t *flags); /* Object metadata flush/refresh routines */ H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id, hid_t dxpl_id); diff --git a/src/H5PB.c b/src/H5PB.c new file mode 100644 index 0000000..c67ae59 --- /dev/null +++ b/src/H5PB.c @@ -0,0 +1,1533 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5PB.c + * + * Purpose: Page Buffer routines. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5PBmodule.h" /* This source code file is part of the H5PB module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5PBpkg.h" /* File access */ +#include "H5SLprivate.h" /* Skip List */ + + +/****************/ +/* Local Macros */ +/****************/ +#define H5PB__PREPEND(page_ptr, head_ptr, tail_ptr, len) { \ + if((head_ptr) == NULL) { \ + (head_ptr) = (page_ptr); \ + (tail_ptr) = (page_ptr); \ + } /* end if */ \ + else { \ + (head_ptr)->prev = (page_ptr); \ + (page_ptr)->next = (head_ptr); \ + (head_ptr) = (page_ptr); \ + } /* end else */ \ + (len)++; \ +} /* H5PB__PREPEND() */ + +#define H5PB__REMOVE(page_ptr, head_ptr, tail_ptr, len) { \ + if((head_ptr) == (page_ptr)) { \ + (head_ptr) = (page_ptr)->next; \ + if((head_ptr) != NULL) \ + (head_ptr)->prev = NULL; \ + } /* end if */ \ + else \ + (page_ptr)->prev->next = (page_ptr)->next; \ + if((tail_ptr) == (page_ptr)) { \ + (tail_ptr) = (page_ptr)->prev; \ + if((tail_ptr) != NULL) \ + (tail_ptr)->next = NULL; \ + } /* end if */ \ + else \ + (page_ptr)->next->prev = (page_ptr)->prev; \ + page_ptr->next = NULL; \ + page_ptr->prev = NULL; \ + (len)--; \ +} + +#define H5PB__INSERT_LRU(page_buf, page_ptr) { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* insert the entry at the head of the list. */ \ + H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, \ + (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ +} + +#define H5PB__REMOVE_LRU(page_buf, page_ptr) { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* remove the entry from the list. */ \ + H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, \ + (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ +} + +#define H5PB__MOVE_TO_TOP_LRU(page_buf, page_ptr) { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* Remove entry and insert at the head of the list. */ \ + H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, \ + (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ + H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, \ + (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ +} + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Iteration context for destroying page buffer */ +typedef struct { + H5PB_t *page_buf; + hbool_t actual_slist; +} H5PB_ud1_t; + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry); +static htri_t H5PB__make_space(const H5F_io_info2_t *fio_info, H5PB_t *page_buf, H5FD_mem_t inserted_type); +static herr_t H5PB__write_entry(const H5F_io_info2_t *fio_info, H5PB_entry_t *page_entry); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ +/* Declare a free list to manage the H5PB_t struct */ +H5FL_DEFINE_STATIC(H5PB_t); + +/* Declare a free list to manage the H5PB_entry_t struct */ +H5FL_DEFINE_STATIC(H5PB_entry_t); + + + +/*------------------------------------------------------------------------- + * Function: H5PB_reset_stats + * + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * Reset statistics collected for the page buffer layer. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_reset_stats(H5PB_t *page_buf) +{ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(page_buf); + + page_buf->accesses[0] = 0; + page_buf->accesses[1] = 0; + page_buf->hits[0] = 0; + page_buf->hits[1] = 0; + page_buf->misses[0] = 0; + page_buf->misses[1] = 0; + page_buf->evictions[0] = 0; + page_buf->evictions[1] = 0; + page_buf->bypasses[0] = 0; + page_buf->bypasses[1] = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5PB_reset_stats() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_get_stats + * + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * Retrieve statistics collected about page accesses for the page buffer layer. + * --accesses: the number of metadata and raw data accesses to the page buffer layer + * --hits: the number of metadata and raw data hits in the page buffer layer + * --misses: the number of metadata and raw data misses in the page buffer layer + * --evictions: the number of metadata and raw data evictions from the page buffer layer + * --bypasses: the number of metadata and raw data accesses that bypass the page buffer layer + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +{ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(page_buf); + + accesses[0] = page_buf->accesses[0]; + accesses[1] = page_buf->accesses[1]; + hits[0] = page_buf->hits[0]; + hits[1] = page_buf->hits[1]; + misses[0] = page_buf->misses[0]; + misses[1] = page_buf->misses[1]; + evictions[0] = page_buf->evictions[0]; + evictions[1] = page_buf->evictions[1]; + bypasses[0] = page_buf->bypasses[0]; + bypasses[1] = page_buf->bypasses[1]; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5PB_get_stats */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_print_stats() + * + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * Print out statistics collected for the page buffer layer. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_print_stats(const H5PB_t *page_buf) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(page_buf); + + printf("PAGE BUFFER STATISTICS:\n"); + + printf("******* METADATA\n"); + printf("\t Total Accesses: %u\n", page_buf->accesses[0]); + printf("\t Hits: %u\n", page_buf->hits[0]); + printf("\t Misses: %u\n", page_buf->misses[0]); + printf("\t Evictions: %u\n", page_buf->evictions[0]); + printf("\t Bypasses: %u\n", page_buf->bypasses[0]); + printf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[0]/(page_buf->accesses[0] - page_buf->bypasses[0]))*100); + printf("*****************\n\n"); + + printf("******* RAWDATA\n"); + printf("\t Total Accesses: %u\n", page_buf->accesses[1]); + printf("\t Hits: %u\n", page_buf->hits[1]); + printf("\t Misses: %u\n", page_buf->misses[1]); + printf("\t Evictions: %u\n", page_buf->evictions[1]); + printf("\t Bypasses: %u\n", page_buf->bypasses[1]); + printf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[1]/(page_buf->accesses[1]-page_buf->bypasses[0]))*100); + printf("*****************\n\n"); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5PB_print_stats */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_create + * + * Purpose: Create and setup the PB on the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_create(H5F_t *f, size_t size, unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc) +{ + H5PB_t *page_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + + /* Check args */ + if(f->shared->fs_strategy != H5F_FSPACE_STRATEGY_PAGE) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "Enabling Page Buffering requires PAGE file space strategy") + /* round down the size if it is larger than the page size */ + else if(size > f->shared->fs_page_size) { + hsize_t temp_size; + + temp_size = (size / f->shared->fs_page_size) * f->shared->fs_page_size; + H5_CHECKED_ASSIGN(size, size_t, temp_size, hsize_t); + } /* end if */ + else if(0 != size % f->shared->fs_page_size) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, "Page Buffer size must be >= to the page size") + + /* Allocate the new page buffering structure */ + if(NULL == (page_buf = H5FL_CALLOC(H5PB_t))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") + + page_buf->max_size = size; + H5_CHECKED_ASSIGN(page_buf->page_size, size_t, f->shared->fs_page_size, hsize_t); + page_buf->min_meta_perc = page_buf_min_meta_perc; + page_buf->min_raw_perc = page_buf_min_raw_perc; + + /* Calculate the minimum page count for metadata and raw data + * based on the fractions provided + */ + page_buf->min_meta_count = (unsigned)((size * page_buf_min_meta_perc) / (f->shared->fs_page_size * 100)); + page_buf->min_raw_count = (unsigned)((size * page_buf_min_raw_perc) / (f->shared->fs_page_size * 100)); + + if(NULL == (page_buf->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCREATE, FAIL, "can't create skip list") + if(NULL == (page_buf->mf_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCREATE, FAIL, "can't create skip list") + + if(NULL == (page_buf->page_fac = H5FL_fac_init(page_buf->page_size))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, "can't create page factory") + + f->shared->page_buf = page_buf; + +done: + if(ret_value < 0) { + if(page_buf != NULL) { + if(page_buf->slist_ptr != NULL) + H5SL_close(page_buf->slist_ptr); + if(page_buf->mf_slist_ptr != NULL) + H5SL_close(page_buf->mf_slist_ptr); + if(page_buf->page_fac != NULL) + H5FL_fac_term(page_buf->page_fac); + page_buf = H5FL_FREE(H5PB_t, page_buf); + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB_create */ + + +/*------------------------------------------------------------------------- + * Function: H5PB__flush_cb + * + * Purpose: Callback to flush PB skiplist entries. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +static herr_t +H5PB__flush_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) +{ + H5PB_entry_t *page_entry = (H5PB_entry_t *)item; /* Pointer to page entry node */ + const H5F_io_info2_t *fio_info = (const H5F_io_info2_t *)_op_data; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(page_entry); + HDassert(fio_info); + + /* Flush the page if it's dirty */ + if(page_entry->is_dirty) + if(H5PB__write_entry(fio_info, page_entry) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB__flush_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_flush + * + * Purpose: Flush/Free all the PB entries to the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_flush(const H5F_io_info2_t *fio_info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(fio_info->meta_dxpl); + HDassert(fio_info->raw_dxpl); + + /* Flush all the entries in the PB skiplist, if we have write access on the file */ + if(fio_info->f->shared->page_buf && (H5F_ACC_RDWR & H5F_INTENT(fio_info->f))) { + H5PB_t *page_buf = fio_info->f->shared->page_buf; + + /* Iterate over all entries in page buffer skip list */ + if(H5SL_iterate(page_buf->slist_ptr, H5PB__flush_cb, (void *)fio_info)) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADITER, FAIL, "can't flush page buffer skip list") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB_flush */ + + +/*------------------------------------------------------------------------- + * Function: H5PB__dest_cb + * + * Purpose: Callback to free PB skiplist entries. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +static herr_t +H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) +{ + H5PB_entry_t *page_entry = (H5PB_entry_t *)item; /* Pointer to page entry node */ + H5PB_ud1_t *op_data = (H5PB_ud1_t *)_op_data; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checking */ + HDassert(page_entry); + HDassert(op_data); + HDassert(op_data->page_buf); + + /* Remove entry from LRU list */ + if(op_data->actual_slist) { + H5PB__REMOVE_LRU(op_data->page_buf, page_entry) + page_entry->page_buf_ptr = H5FL_FAC_FREE(op_data->page_buf->page_fac, page_entry->page_buf_ptr); + } /* end if */ + + /* Free page entry */ + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5PB__dest_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_dest + * + * Purpose: destroy the PB on the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_dest(H5F_t *f) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + + /* Destroy page buffer info, if there is any */ + if(f->shared->page_buf) { + H5PB_t *page_buf = f->shared->page_buf; + H5PB_ud1_t op_data; /* Iteration context */ + + /* Set up context info */ + op_data.page_buf = page_buf; + + /* Destroy the skip list containing all the entries in the PB */ + op_data.actual_slist = TRUE; + if(H5SL_destroy(page_buf->slist_ptr, H5PB__dest_cb, &op_data)) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCLOSEOBJ, FAIL, "can't destroy page buffer skip list") + + /* Destroy the skip list containing the new entries */ + op_data.actual_slist = FALSE; + if(H5SL_destroy(page_buf->mf_slist_ptr, H5PB__dest_cb, &op_data)) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCLOSEOBJ, FAIL, "can't destroy page buffer skip list") + + /* Destroy the page factory */ + if(H5FL_fac_term(page_buf->page_fac) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTRELEASE, FAIL, "can't destroy page buffer page factory") + +#ifdef QAK +H5PB_print_stats(page_buf); +#endif /* QAK */ + + f->shared->page_buf = H5FL_FREE(H5PB_t, page_buf); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB_dest */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_add_new_page + * + * Purpose: Add a new page to the new page skip list. This is called + * from the MF layer when a new page is allocated to + * indicate to the page buffer layer that a read of the page + * from the file is not necessary since it's an empty page. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_add_new_page(H5F_t *f, H5FD_mem_t type, haddr_t page_addr) +{ + H5PB_t *page_buf = f->shared->page_buf; + H5PB_entry_t *page_entry = NULL; /* pointer to the corresponding page entry */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(page_buf); + + /* If there is an existing page, this means that at some point the + * file free space manager freed and re-allocated a page at the same + * address. No need to do anything here then... + */ + /* MSC - to be safe, might want to dig in the MF layer and remove + * the page when it is freed from this list if it still exists and + * remove this check + */ + if(NULL == H5SL_search(page_buf->mf_slist_ptr, &(page_addr))) { + /* Create the new PB entry */ + if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize page fields */ + page_entry->addr = page_addr; + page_entry->type = (H5F_mem_page_t)type; + page_entry->is_dirty = FALSE; + + /* Insert entry in skip list */ + if(H5SL_insert(page_buf->mf_slist_ptr, page_entry, &(page_entry->addr)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "Can't insert entry in skip list") + } /* end if */ + +done: + if(ret_value < 0) + if(page_entry) + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB_add_new_page */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_update_entry + * + * Purpose: In PHDF5, entries that are written by other processes and just + * marked clean by this process have to have their corresponding + * pages updated if they exist in the page buffer. + * This routine checks and update the pages. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) +{ + H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ + haddr_t page_addr; + + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(page_buf); + HDassert(size <= page_buf->page_size); + HDassert(buf); + + /* calculate the aligned address of the first page */ + page_addr = (addr / page_buf->page_size) * page_buf->page_size; + + /* search for the page and update if found */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&page_addr)); + if(page_entry) { + haddr_t offset; + + HDassert(addr + size <= page_addr + page_buf->page_size); + offset = addr - page_addr; + HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, size); + + /* move to top of LRU list */ + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5PB_update_entry */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_remove_entry + * + * Purpose: Remove possible metadata entry with ADDR from the PB cache. + * This is in response to the data corruption bug from fheap.c + * with page buffering + page strategy. + * Note: Large metadata page bypasses the PB cache. + * Note: Update of raw data page (large or small sized) is handled by the PB cache. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Feb 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_remove_entry(const H5F_t *f, haddr_t addr) +{ + H5PB_t *page_buf = f->shared->page_buf; + H5PB_entry_t *page_entry = NULL; /* pointer to the page entry being searched */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(page_buf); + + /* Search for address in the skip list */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&addr)); + + /* If found, remove the entry from the PB cache */ + if(page_entry) { + HDassert(page_entry->type != H5F_MEM_PAGE_DRAW); + if(NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Page Entry is not in skip list") + + /* Remove from LRU list */ + H5PB__REMOVE_LRU(page_buf, page_entry) + HDassert(H5SL_count(page_buf->slist_ptr) == page_buf->LRU_list_len); + + page_buf->meta_count--; + + page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5PB_remove_entry */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_read + * + * Purpose: Reads in the data from the page containing it if it exists + * in the PB cache; otherwise reads in the page through the VFD. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_read(const H5F_io_info2_t *fio_info, H5FD_mem_t type, haddr_t addr, + size_t size, void *buf/*out*/) +{ + H5PB_t *page_buf; /* Page buffering info for this file */ + H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ + haddr_t first_page_addr, last_page_addr; /* Addresses of the first and last pages covered by I/O */ + haddr_t offset; + haddr_t search_addr; /* Address of current page */ + hsize_t num_touched_pages; /* Number of pages accessed */ + size_t access_size; + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hsize_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(fio_info); + + /* Get pointer to page buffer info for this file */ + page_buf = fio_info->f->shared->page_buf; + +#ifdef H5_HAVE_PARALLEL + if(H5F_HAS_FEATURE(fio_info->f, H5FD_FEAT_HAS_MPI)) { +#if 1 + bypass_pb = TRUE; +#else + /* MSC - why this stopped working ? */ + int mpi_size; + + if((mpi_size = H5F_mpi_get_size(fio_info->f)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") + if(1 != mpi_size) + bypass_pb = TRUE; +#endif + } /* end if */ +#endif + + /* If page buffering is disabled, or the I/O size is larger than that of a + * single page, or if this is a parallel raw data access, bypass page + * buffering. + */ + if(NULL == page_buf || size >= page_buf->page_size || + (bypass_pb && H5FD_MEM_DRAW == type)) { + if(H5F__accum_read(fio_info, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "read through metadata accumulator failed") + + /* Update statistics */ + if(page_buf) { + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->bypasses[1] ++; + else + page_buf->bypasses[0] ++; + } /* end if */ + + /* If page buffering is disabled, or if this is a large metadata access, + * or if this is parallel raw data access, we are done here + */ + if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || + (bypass_pb && H5FD_MEM_DRAW == type)) + HGOTO_DONE(SUCCEED) + } /* end if */ + + /* Update statistics */ + if(page_buf) { + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->accesses[1]++; + else + page_buf->accesses[0]++; + } /* end if */ + + /* Calculate the aligned address of the first page */ + first_page_addr = (addr / page_buf->page_size) * page_buf->page_size; + + /* For Raw data calculate the aligned address of the last page and + * the number of pages accessed if more than 1 page is accessed + */ + if(H5FD_MEM_DRAW == type) { + last_page_addr = ((addr + size - 1) / page_buf->page_size) * page_buf->page_size; + + /* How many pages does this write span */ + num_touched_pages = (last_page_addr / page_buf->page_size + 1) - + (first_page_addr / page_buf->page_size); + if(first_page_addr == last_page_addr) { + HDassert(1 == num_touched_pages); + last_page_addr = HADDR_UNDEF; + } /* end if */ + } /* end if */ + /* Otherwise set last page addr to HADDR_UNDEF */ + else { + num_touched_pages = 1; + last_page_addr = HADDR_UNDEF; + } /* end else */ + + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + + /* Copy raw data from dirty pages into the read buffer if the read + request spans pages in the page buffer*/ + if(H5FD_MEM_DRAW == type && size >= page_buf->page_size) { + H5SL_node_t *node; + + /* For each touched page in the page buffer, check if it + * exists in the page Buffer and is dirty. If it does, we + * update the buffer with what's in the page so we get the up + * to date data into the buffer after the big read from the file. + */ + node = H5SL_find(page_buf->slist_ptr, (void *)(&first_page_addr)); + for(i = 0; i < num_touched_pages; i++) { + search_addr = i*page_buf->page_size + first_page_addr; + + /* if we still haven't located a starting page, search again */ + if(!node && i!=0) + node = H5SL_find(page_buf->slist_ptr, (void *)(&search_addr)); + + /* if the current page is in the Page Buffer, do the updates */ + if(node) { + page_entry = (H5PB_entry_t *)H5SL_item(node); + + HDassert(page_entry); + + /* If the current page address falls out of the access + block, then there are no more pages to go over */ + if(page_entry->addr >= addr + size) + break; + + HDassert(page_entry->addr == search_addr); + + if(page_entry->is_dirty) { + /* special handling for the first page if it is not a full page access */ + if(i == 0 && first_page_addr != addr) { + offset = addr - first_page_addr; + HDassert(page_buf->page_size > offset); + + HDmemcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset, + page_buf->page_size - (size_t)offset); + + /* move to top of LRU list */ + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + } /* end if */ + /* special handling for the last page if it is not a full page access */ + else if(num_touched_pages > 1 && i == num_touched_pages-1 && search_addr < addr+size) { + offset = (num_touched_pages-2)*page_buf->page_size + + (page_buf->page_size - (addr - first_page_addr)); + + HDmemcpy((uint8_t *)buf + offset, page_entry->page_buf_ptr, + (size_t)((addr + size) - last_page_addr)); + + /* move to top of LRU list */ + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + } /* end else-if */ + /* copy the entire fully accessed pages */ + else { + offset = i*page_buf->page_size; + + HDmemcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr, + page_buf->page_size); + } /* end else */ + } /* end if */ + node = H5SL_next(node); + } /* end if */ + } /* end for */ + } /* end if */ + else { + /* A raw data access could span 1 or 2 PB entries at this point so + we need to handle that */ + HDassert(1 == num_touched_pages || 2 == num_touched_pages); + for(i = 0 ; i < num_touched_pages; i++) { + haddr_t buf_offset; + + /* Calculate the aligned address of the page to search for it in the skip list */ + search_addr = (0==i ? first_page_addr : last_page_addr); + + /* Calculate the access size if the access spans more than 1 page */ + if(1 == num_touched_pages) + access_size = size; + else + access_size = (0 == i ? (size_t)((first_page_addr + page_buf->page_size) - addr) : (size - access_size)); + + /* Lookup the page in the skip list */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); + + /* if found */ + if(page_entry) { + offset = (0 == i ? addr - page_entry->addr : 0); + buf_offset = (0 == i ? 0 : size - access_size); + + /* copy the requested data from the page into the input buffer */ + HDmemcpy((uint8_t *)buf + buf_offset, (uint8_t *)page_entry->page_buf_ptr + offset, access_size); + + /* Update LRU */ + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + + /* Update statistics */ + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->hits[1]++; + else + page_buf->hits[0]++; + } /* end if */ + /* if not found */ + else { + void *new_page_buf = NULL; + size_t page_size = page_buf->page_size; + haddr_t eoa; + + /* make space for new entry */ + if((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { + htri_t can_make_space; + + /* check if we can make space in page buffer */ + if((can_make_space = H5PB__make_space(fio_info, page_buf, type)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "make space in Page buffer Failed") + + /* if make_space returns 0, then we can't use the page + buffer for this I/O and we need to bypass */ + if(0 == can_make_space) { + /* make space can't return FALSE on second touched page since the first is of the same type */ + HDassert(0 == i); + + /* read entire block from VFD and return */ + if(H5FD_read(&fdio_info, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") + + /* Break out of loop */ + break; + } /* end if */ + } /* end if */ + + /* Read page from VFD */ + if(NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + + /* Read page through the VFD layer, but make sure we don't read past the EOA. */ + + /* Retrieve the 'eoa' for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(fio_info->f, type))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + /* If the entire page falls outside the EOA, then fail */ + if(search_addr > eoa) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "reading an entire page that is outside the file EOA") + + /* Adjust the read size to not go beyond the EOA */ + if(search_addr + page_size > eoa) + page_size = (size_t)(eoa - search_addr); + + /* Read page from VFD */ + if(H5FD_read(&fdio_info, type, search_addr, page_size, new_page_buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") + + /* Copy the requested data from the page into the input buffer */ + offset = (0 == i ? addr - search_addr : 0); + buf_offset = (0 == i ? 0 : size - access_size); + HDmemcpy((uint8_t *)buf + buf_offset, (uint8_t *)new_page_buf + offset, access_size); + + /* Create the new PB entry */ + if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") + + page_entry->page_buf_ptr = new_page_buf; + page_entry->addr = search_addr; + page_entry->type = (H5F_mem_page_t)type; + page_entry->is_dirty = FALSE; + + /* Insert page into PB */ + if(H5PB__insert_entry(page_buf, page_entry) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTSET, FAIL, "error inserting new page in page buffer") + + /* Update statistics */ + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->misses[1]++; + else + page_buf->misses[0]++; + } /* end else */ + } /* end for */ + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PB_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB_write + * + * Purpose: Write data into the Page Buffer. If the page exists in the + * cache, update it; otherwise read it from disk, update it, and + * insert into cache. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +herr_t +H5PB_write(const H5F_io_info2_t *fio_info, H5FD_mem_t type, haddr_t addr, + size_t size, const void *buf) +{ + H5PB_t *page_buf; /* Page buffering info for this file */ + H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ + haddr_t first_page_addr, last_page_addr; /* Addresses of the first and last pages covered by I/O */ + haddr_t offset; + haddr_t search_addr; /* Address of current page */ + hsize_t num_touched_pages; /* Number of pages accessed */ + size_t access_size; + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hsize_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(fio_info); + HDassert(fio_info->f); + + /* Get pointer to page buffer info for this file */ + page_buf = fio_info->f->shared->page_buf; + +#ifdef H5_HAVE_PARALLEL + if(H5F_HAS_FEATURE(fio_info->f, H5FD_FEAT_HAS_MPI)) { +#if 1 + bypass_pb = TRUE; +#else + /* MSC - why this stopped working ? */ + int mpi_size; + + if((mpi_size = H5F_mpi_get_size(fio_info->f)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") + if(1 != mpi_size) + bypass_pb = TRUE; +#endif + } /* end if */ +#endif + + /* If page buffering is disabled, or the I/O size is larger than that of a + * single page, or if this is a parallel raw data access, bypass page + * buffering. + */ + if(NULL == page_buf || size >= page_buf->page_size || bypass_pb) { + if(H5F__accum_write(fio_info, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "write through metadata accumulator failed") + + /* Update statistics */ + if(page_buf) { + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->bypasses[1]++; + else + page_buf->bypasses[0]++; + } /* end if */ + + /* If page buffering is disabled, or if this is a large metadata access, + * or if this is a parallel raw data access, we are done here + */ + if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || + (bypass_pb && H5FD_MEM_DRAW == type)) + HGOTO_DONE(SUCCEED) + +#ifdef H5_HAVE_PARALLEL + if(bypass_pb) { + if(H5PB_update_entry(page_buf, addr, size, buf) > 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTUPDATE, FAIL, "failed to update PB with metadata cache") + HGOTO_DONE(SUCCEED) + } /* end if */ +#endif + } /* end if */ + + /* Update statistics */ + if(page_buf) { + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->accesses[1]++; + else + page_buf->accesses[0]++; + } /* end if */ + + /* Calculate the aligned address of the first page */ + first_page_addr = (addr / page_buf->page_size) * page_buf->page_size; + + /* For raw data calculate the aligned address of the last page and + * the number of pages accessed if more than 1 page is accessed + */ + if(H5FD_MEM_DRAW == type) { + last_page_addr = (addr + size - 1) / page_buf->page_size * page_buf->page_size; + + /* how many pages does this write span */ + num_touched_pages = (last_page_addr/page_buf->page_size + 1) - + (first_page_addr / page_buf->page_size); + if(first_page_addr == last_page_addr) { + HDassert(1 == num_touched_pages); + last_page_addr = HADDR_UNDEF; + } /* end if */ + } /* end if */ + /* Otherwise set last page addr to HADDR_UNDEF */ + else { + num_touched_pages = 1; + last_page_addr = HADDR_UNDEF; + } /* end else */ + + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + + /* Check if existing pages for raw data need to be updated since raw data access is not atomic */ + if(H5FD_MEM_DRAW == type && size >= page_buf->page_size) { + /* For each touched page, check if it exists in the page buffer, and + * update it with the data in the buffer to keep it up to date + */ + for(i = 0; i < num_touched_pages; i++) { + search_addr = i * page_buf->page_size + first_page_addr; + + /* Special handling for the first page if it is not a full page update */ + if(i == 0 && first_page_addr != addr) { + /* Lookup the page in the skip list */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); + if(page_entry) { + offset = addr - first_page_addr; + HDassert(page_buf->page_size > offset); + + /* Update page's data */ + HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, page_buf->page_size - (size_t)offset); + + /* Mark page dirty and push to top of LRU */ + page_entry->is_dirty = TRUE; + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + } /* end if */ + } /* end if */ + /* Special handling for the last page if it is not a full page update */ + else if(num_touched_pages > 1 && i == (num_touched_pages - 1) && + (search_addr + page_buf->page_size) != (addr + size)) { + HDassert(search_addr+page_buf->page_size > addr+size); + + /* Lookup the page in the skip list */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); + if(page_entry) { + offset = (num_touched_pages - 2) * page_buf->page_size + + (page_buf->page_size - (addr - first_page_addr)); + + /* Update page's data */ + HDmemcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset, + (size_t)((addr + size) - last_page_addr)); + + /* Mark page dirty and push to top of LRU */ + page_entry->is_dirty = TRUE; + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + } /* end if */ + } /* end else-if */ + /* Discard all fully written pages from the page buffer */ + else { + page_entry = (H5PB_entry_t *)H5SL_remove(page_buf->slist_ptr, (void *)(&search_addr)); + if(page_entry) { + /* Remove from LRU list */ + H5PB__REMOVE_LRU(page_buf, page_entry) + + /* Decrement page count of appropriate type */ + if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + page_buf->raw_count--; + else + page_buf->meta_count--; + + /* Free page info */ + page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + } /* end if */ + } /* end else */ + } /* end for */ + } /* end if */ + else { + /* An access could span 1 or 2 PBs at this point so we need to handle that */ + HDassert(1 == num_touched_pages || 2 == num_touched_pages); + for(i = 0; i < num_touched_pages; i++) { + haddr_t buf_offset; + + /* Calculate the aligned address of the page to search for it in the skip list */ + search_addr = (0 == i ? first_page_addr : last_page_addr); + + /* Calculate the access size if the access spans more than 1 page */ + if(1 == num_touched_pages) + access_size = size; + else + access_size = (0 == i ? (size_t)(first_page_addr + page_buf->page_size - addr) : (size - access_size)); + + /* Lookup the page in the skip list */ + page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); + + /* If found */ + if(page_entry) { + offset = (0 == i ? addr - page_entry->addr : 0); + buf_offset = (0 == i ? 0 : size - access_size); + + /* Copy the requested data from the input buffer into the page */ + HDmemcpy((uint8_t *)page_entry->page_buf_ptr + offset, (const uint8_t *)buf + buf_offset, access_size); + + /* Mark page dirty and push to top of LRU */ + page_entry->is_dirty = TRUE; + H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) + + /* Update statistics */ + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->hits[1]++; + else + page_buf->hits[0]++; + } /* end if */ + /* If not found */ + else { + void *new_page_buf; + size_t page_size = page_buf->page_size; + + /* Make space for new entry */ + if((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { + htri_t can_make_space; + + /* Check if we can make space in page buffer */ + if((can_make_space = H5PB__make_space(fio_info, page_buf, type)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "make space in Page buffer Failed") + + /* If make_space returns 0, then we can't use the page + * buffer for this I/O and we need to bypass + */ + if(0 == can_make_space) { + HDassert(0 == i); + + /* Write to VFD and return */ + if(H5FD_write(&fdio_info, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "driver write request failed") + + /* Break out of loop */ + break; + } /* end if */ + } /* end if */ + + /* Don't bother searching if there is no write access */ + if(H5F_ACC_RDWR & H5F_INTENT(fio_info->f)) + /* Lookup & remove the page from the new skip list page if + * it exists to see if this is a new page from the MF layer + */ + page_entry = (H5PB_entry_t *)H5SL_remove(page_buf->mf_slist_ptr, (void *)(&search_addr)); + + /* Calculate offset into the buffer of the page and the user buffer */ + offset = (0 == i ? addr - search_addr : 0); + buf_offset = (0 == i ? 0 : size - access_size); + + /* If found, then just update the buffer pointer to the newly allocate buffer */ + if(page_entry) { + /* Allocate space for the page buffer */ + if(NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + HDmemset(new_page_buf, 0, (size_t)offset); + HDmemset((uint8_t *)new_page_buf + offset + access_size, 0, page_size - ((size_t)offset + access_size)); + + page_entry->page_buf_ptr = new_page_buf; + + /* Update statistics */ + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->hits[1]++; + else + page_buf->hits[0]++; + } /* end if */ + /* Otherwise read page through the VFD layer, but make sure we don't read past the EOA. */ + else { + haddr_t eoa, eof = HADDR_UNDEF; + + /* Allocate space for the page buffer */ + if(NULL == (new_page_buf = H5FL_FAC_CALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + + /* Create the new loaded PB entry */ + if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed") + + page_entry->page_buf_ptr = new_page_buf; + page_entry->addr = search_addr; + page_entry->type = (H5F_mem_page_t)type; + + /* Retrieve the 'eoa' for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(fio_info->f, type))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + /* If the entire page falls outside the EOA, then fail */ + if(search_addr > eoa) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "writing to a page that is outside the file EOA") + + /* Retrieve the 'eof' for the file - The MPI-VFD EOF + * returned will most likely be HADDR_UNDEF, so skip + * that check. + */ + if(!H5F_HAS_FEATURE(fio_info->f, H5FD_FEAT_HAS_MPI)) + if(HADDR_UNDEF == (eof = H5FD_get_eof(fio_info->f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eof request failed") + + /* Adjust the read size to not go beyond the EOA */ + if(search_addr + page_size > eoa) + page_size = (size_t)(eoa - search_addr); + + if(search_addr < eof) { + if(H5FD_read(&fdio_info, type, search_addr, page_size, new_page_buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") + + /* Update statistics */ + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + page_buf->misses[1]++; + else + page_buf->misses[0]++; + } /* end if */ + } /* end else */ + + /* Copy the requested data from the page into the input buffer */ + HDmemcpy((uint8_t *)new_page_buf + offset, (const uint8_t *)buf+buf_offset, access_size); + + /* Page is dirty now */ + page_entry->is_dirty = TRUE; + + /* Insert page into PB, evicting other pages as necessary */ + if(H5PB__insert_entry(page_buf, page_entry) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTSET, FAIL, "error inserting new page in page buffer") + } /* end else */ + } /* end for */ + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PB_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB__insert_entry() + * + * Purpose: ??? + * + * This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * Insert the supplied page into the page buffer, both the + * skip list and the LRU. + * + * As best I can tell, this function imposes no limit on the + * number of entries in the page buffer beyond an assertion + * failure it the page count exceeds the limit. + * + * JRM -- 12/22/16 + * + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +static herr_t +H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Insert entry in skip list */ + if(H5SL_insert(page_buf->slist_ptr, page_entry, &(page_entry->addr)) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINSERT, FAIL, "can't insert entry in skip list") + HDassert(H5SL_count(page_buf->slist_ptr) * page_buf->page_size <= page_buf->max_size); + + /* Increment appropriate page count */ + if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + page_buf->raw_count++; + else + page_buf->meta_count++; + + /* Insert entry in LRU */ + H5PB__INSERT_LRU(page_buf, page_entry) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PB__insert_entry() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB__make_space() + * + * Purpose: ??? + * + * This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * If necessary and if possible, evict a page from the page + * buffer to make space for the supplied page. Depending on + * the page buffer configuration and contents, and the page + * supplied this may or may not be possible. + * + * JRM -- 12/22/16 + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +static htri_t +H5PB__make_space(const H5F_io_info2_t *fio_info, H5PB_t *page_buf, + H5FD_mem_t inserted_type) +{ + H5PB_entry_t *page_entry; /* Pointer to page eviction candidate */ + htri_t ret_value = TRUE; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(fio_info); + HDassert(page_buf); + + /* Get oldest entry */ + page_entry = page_buf->LRU_tail_ptr; + + if(H5FD_MEM_DRAW == inserted_type) { + /* If threshould is 100% metadata and page buffer is full of + metadata, then we can't make space for raw data */ + if(0 == page_buf->raw_count && page_buf->min_meta_count == page_buf->meta_count) { + HDassert(page_buf->meta_count * page_buf->page_size == page_buf->max_size); + HGOTO_DONE(FALSE) + } /* end if */ + + /* check the metadata threshold before evicting metadata items */ + while(1) { + if(page_entry->prev && H5F_MEM_PAGE_META == page_entry->type && + page_buf->min_meta_count >= page_buf->meta_count) + page_entry = page_entry->prev; + else + break; + } /* end while */ + } /* end if */ + else { + /* If threshould is 100% raw data and page buffer is full of + raw data, then we can't make space for meta data */ + if(0 == page_buf->meta_count && page_buf->min_raw_count == page_buf->raw_count) { + HDassert(page_buf->raw_count * page_buf->page_size == page_buf->max_size); + HGOTO_DONE(FALSE) + } /* end if */ + + /* check the raw data threshold before evicting raw data items */ + while(1) { + if(page_entry->prev && (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) && + page_buf->min_raw_count >= page_buf->raw_count) + page_entry = page_entry->prev; + else + break; + } /* end while */ + } /* end else */ + + /* Remove from page index */ + if(NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "Tail Page Entry is not in skip list") + + /* Remove entry from LRU list */ + H5PB__REMOVE_LRU(page_buf, page_entry) + HDassert(H5SL_count(page_buf->slist_ptr) == page_buf->LRU_list_len); + + /* Decrement appropriate page type counter */ + if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + page_buf->raw_count--; + else + page_buf->meta_count--; + + /* Flush page if dirty */ + if(page_entry->is_dirty) + if(H5PB__write_entry(fio_info, page_entry) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") + + /* Update statistics */ + if(page_entry->type == H5F_MEM_PAGE_DRAW || H5F_MEM_PAGE_GHEAP == page_entry->type) + page_buf->evictions[1]++; + else + page_buf->evictions[0]++; + + /* Release page */ + page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PB__make_space() */ + + +/*------------------------------------------------------------------------- + * Function: H5PB__write_entry() + * + * Purpose: ??? + * + * This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. + * + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ +static herr_t +H5PB__write_entry(const H5F_io_info2_t *fio_info, H5PB_entry_t *page_entry) +{ + haddr_t eoa; /* Current EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(page_entry); + + /* Retrieve the 'eoa' for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(fio_info->f, page_entry->type))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") + + /* If the starting address of the page is larger than + * the EOA, then the entire page is discarded without writing. + */ + if(page_entry->addr <= eoa) { + H5FD_io_info_t fdio_info; /* File driver I/O info */ + size_t page_size = fio_info->f->shared->page_buf->page_size; + + /* Adjust the page length if it exceeds the EOA */ + if((page_entry->addr + page_size) > eoa) + page_size = (size_t)(eoa - page_entry->addr); + + /* Translate to file driver I/O info object */ + fdio_info.file = fio_info->f->shared->lf; + fdio_info.meta_dxpl = fio_info->meta_dxpl; + fdio_info.raw_dxpl = fio_info->raw_dxpl; + + if(H5FD_write(&fdio_info, page_entry->type, page_entry->addr, page_size, page_entry->page_buf_ptr) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") + } /* end if */ + + page_entry->is_dirty = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PB__write_entry() */ + diff --git a/src/H5PBmodule.h b/src/H5PBmodule.h new file mode 100644 index 0000000..35da3f6 --- /dev/null +++ b/src/H5PBmodule.h @@ -0,0 +1,34 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol + * Saturday, September 12, 2015 + * + * Purpose: This file contains declarations which define macros for the + * H5PB package. Including this header means that the source file + * is part of the H5PB package. + */ +#ifndef _H5PBmodule_H +#define _H5PBmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5PB_MODULE +#define H5_MY_PKG H5PB +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO + +#endif /* _H5PBmodule_H */ diff --git a/src/H5PBpkg.h b/src/H5PBpkg.h new file mode 100644 index 0000000..976f18d --- /dev/null +++ b/src/H5PBpkg.h @@ -0,0 +1,60 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#if !(defined H5PB_FRIEND || defined H5PB_MODULE) +#error "Do not include this file outside the H5PB package!" +#endif + +#ifndef _H5PBpkg_H +#define _H5PBpkg_H + +/* Get package's private header */ +#include "H5PBprivate.h" + +/* Other private headers needed by this file */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +typedef struct H5PB_entry_t { + void *page_buf_ptr; /* Pointer to the buffer containing the data */ + haddr_t addr; /* Address of the page in the file */ + H5F_mem_page_t type; /* Type of the page entry (H5F_MEM_PAGE_RAW/META) */ + hbool_t is_dirty; /* Flag indicating whether the page has dirty data or not */ + + /* Fields supporting replacement policies */ + struct H5PB_entry_t *next; /* next pointer in the LRU list */ + struct H5PB_entry_t *prev; /* previous pointer in the LRU list */ +} H5PB_entry_t; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + + +#endif /* _H5PBpkg_H */ + diff --git a/src/H5PBprivate.h b/src/H5PBprivate.h new file mode 100644 index 0000000..3b5dcae --- /dev/null +++ b/src/H5PBprivate.h @@ -0,0 +1,108 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5PBprivate.h + * June 2014 + * Mohamad Chaarawi + * + *------------------------------------------------------------------------- + */ + +#ifndef _H5PBprivate_H +#define _H5PBprivate_H + +/* Include package's public header */ +#ifdef NOT_YET +#include "H5PBpublic.h" +#endif /* NOT_YET */ + +/* Private headers needed by this header */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5SLprivate.h" /* Skip List */ + + +/**************************/ +/* Library Private Macros */ +/**************************/ + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* Forward declaration for a page buffer entry */ +struct H5PB_entry_t; + +/* Typedef for the main structure for the page buffer */ +typedef struct H5PB_t { + size_t max_size; /* The total page buffer size */ + size_t page_size; /* Size of a single page */ + unsigned min_meta_perc; /* Minimum ratio of metadata entries required before evicting meta entries */ + unsigned min_raw_perc; /* Minimum ratio of raw data entries required before evicting raw entries */ + unsigned meta_count; /* Number of entries for metadata */ + unsigned raw_count; /* Number of entries for raw data */ + unsigned min_meta_count; /* Minimum # of entries for metadata */ + unsigned min_raw_count; /* Minimum # of entries for raw data */ + + H5SL_t *slist_ptr; /* Skip list with all the active page entries */ + H5SL_t *mf_slist_ptr; /* Skip list containing newly allocated page entries inserted from the MF layer */ + + size_t LRU_list_len; /* Number of entries in the LRU (identical to slist_ptr count) */ + struct H5PB_entry_t *LRU_head_ptr; /* Head pointer of the LRU */ + struct H5PB_entry_t *LRU_tail_ptr; /* Tail pointer of the LRU */ + + H5FL_fac_head_t *page_fac; /* Factory for allocating pages */ + + /* Statistics */ + unsigned accesses[2]; + unsigned hits[2]; + unsigned misses[2]; + unsigned evictions[2]; + unsigned bypasses[2]; +} H5PB_t; + +/*****************************/ +/* Library-private Variables */ +/*****************************/ + + +/***************************************/ +/* Library-private Function Prototypes */ +/***************************************/ + +/* General routines */ +H5_DLL herr_t H5PB_create(H5F_t *file, size_t page_buffer_size, unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc); +H5_DLL herr_t H5PB_flush(const H5F_io_info2_t *fio_info); +H5_DLL herr_t H5PB_dest(H5F_t *file); +H5_DLL herr_t H5PB_add_new_page(H5F_t *f, H5FD_mem_t type, haddr_t page_addr); +H5_DLL herr_t H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5PB_remove_entry(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5PB_read(const H5F_io_info2_t *fio_info, H5FD_mem_t type, + haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5PB_write(const H5F_io_info2_t *f, H5FD_mem_t type, haddr_t addr, + size_t size, const void *buf); + +/* Statistics routines */ +H5_DLL herr_t H5PB_reset_stats(H5PB_t *page_buf); +H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], + unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); +H5_DLL herr_t H5PB_print_stats(const H5PB_t *page_buf); + +#endif /* !_H5PBprivate_H */ + diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index ecf2bea..d225dfa 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -488,5 +488,135 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_version() */ +/*------------------------------------------------------------------------- + * Function: H5Pset_file_space + * + * Purpose: It is mapped to H5Pset_file_space_strategy(). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Jan 2017 + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold) +{ + + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */ + hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */ + H5F_file_space_type_t in_strategy = strategy; /* Input strategy */ + hsize_t in_threshold = threshold; /* Input threshold */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iFfh", plist_id, strategy, threshold); + + if((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") + /* + * For 1.10.0 H5Pset_file_space: + * If strategy is zero, the property is not changed; + * the existing strategy is retained. + * If threshold is zero, the property is not changed; + * the existing threshold is retained. + */ + if(!in_strategy) + H5Pget_file_space(plist_id, &in_strategy, NULL); + if(!in_threshold) + H5Pget_file_space(plist_id, NULL, &in_threshold); + + switch(in_strategy) { + case H5F_FILE_SPACE_ALL_PERSIST: + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_persist = TRUE; + new_threshold = in_threshold; + break; + + case H5F_FILE_SPACE_ALL: + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_threshold = in_threshold; + break; + + case H5F_FILE_SPACE_AGGR_VFD: + new_strategy = H5F_FSPACE_STRATEGY_AGGR; + break; + + case H5F_FILE_SPACE_VFD: + new_strategy = H5F_FSPACE_STRATEGY_NONE; + break; + + case H5F_FILE_SPACE_NTYPES: + case H5F_FILE_SPACE_DEFAULT: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file space strategy") + } + + if(H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pset_file_space() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_file_space + * + * Purpose: It is mapped to H5Pget_file_space_strategy(). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Jan 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold) +{ + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist; /* Persisting free-space or not */ + hsize_t new_threshold; /* Free-space section threshold */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*Ff*h", plist_id, strategy, threshold); + + /* Get current file space info */ + if(H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") + + /* Get value(s) */ + if(strategy) { + switch(new_strategy) { + + case H5F_FSPACE_STRATEGY_FSM_AGGR: + if(new_persist) + *strategy = H5F_FILE_SPACE_ALL_PERSIST; + else + *strategy = H5F_FILE_SPACE_ALL; + break; + + case H5F_FSPACE_STRATEGY_AGGR: + *strategy = H5F_FILE_SPACE_AGGR_VFD; + break; + + case H5F_FSPACE_STRATEGY_NONE: + *strategy = H5F_FILE_SPACE_VFD; + break; + + case H5F_FSPACE_STRATEGY_PAGE: + case H5F_FSPACE_STRATEGY_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file space strategy") + } + } + + if(threshold) + *threshold = new_threshold; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pget_file_space() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 7ea0fe0..7865fdf 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -80,18 +80,18 @@ #define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definition for threshold for alignment */ #define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_THRHD_DEF 1 +#define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF #define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t #define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t /* Definition for alignment */ #define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_DEF 1 +#define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF #define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t #define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t /* Definition for minimum metadata allocation block size (when aggregating metadata allocations. */ #define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_META_BLOCK_SIZE_DEF 2048 +#define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF #define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t #define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for maximum sieve buffer size (when data sieving @@ -103,7 +103,7 @@ /* Definition for minimum "small data" allocation block size (when aggregating "small" raw data allocations. */ #define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_SDATA_BLOCK_SIZE_DEF 2048 +#define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF #define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t #define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for garbage-collect references */ @@ -231,6 +231,21 @@ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC H5P__facc_cache_image_config_enc #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC H5P__facc_cache_image_config_dec #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP H5P__facc_cache_image_config_cmp +/* Definition for total size of page buffer(bytes) */ +#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0 +#define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t +/* Definition for minimum metadata size of page buffer(bytes) */ +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned +/* Definition for minimum raw data size of page buffer(bytes) */ +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned /******************/ @@ -359,6 +374,9 @@ static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = H5F_ACS_COLL_ static const hbool_t H5F_def_coll_md_write_flag_g = H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */ #endif /* H5_HAVE_PARALLEL */ static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */ +static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */ +static const unsigned H5F_def_page_buf_min_meta_perc_g = H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */ +static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer minumum raw data size */ /*------------------------------------------------------------------------- @@ -574,6 +592,22 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the size of the page buffer size */ + if(H5P_register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE, &H5F_def_page_buf_size_g, + NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC, H5F_ACS_PAGE_BUFFER_SIZE_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the size of the page buffer minimum metadata size */ + if(H5P_register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, + NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the size of the page buffer minimum raw data size */ + if(H5P_register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, + NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ @@ -4681,3 +4715,93 @@ done: } /* end H5Pget_coll_metadata_write() */ #endif /* H5_HAVE_PARALLEL */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_page_buffer_size + * + * Purpose: Set the maximum page buffering size. This has to be a + * multiple of the page allocation size which must be enabled; + * otherwise file create/open will fail. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * June 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "izIuIu", plist_id, buf_size, min_meta_perc, min_raw_perc); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(min_meta_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum metadata fractions must be between 0 and 100 inclusive") + if(min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum rawdata fractions must be between 0 and 100 inclusive") + + if(min_meta_perc + min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Sum of minimum metadata and raw data fractions can't be bigger than 100"); + + /* Set size */ + if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set page buffer size") + if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min metadata entries") + if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min rawdata entries") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_page_buffer_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_page_buffer_size + * + * Purpose: Retrieves the maximum page buffer size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * June 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*z*Iu*Iu", plist_id, buf_size, min_meta_perc, min_raw_perc); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get size */ + + if(buf_size) + if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer size") + if(min_meta_perc) + if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum metadata percent") + if(min_raw_perc) + if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum raw data percent") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_page_buffer_size() */ + diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index d451982..c778801 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -97,14 +97,23 @@ #define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned #define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned /* Definitions for file space handling strategy */ -#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(unsigned) -#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF -#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__encode_unsigned -#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__decode_unsigned -#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF -#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t +#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) +#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF +#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc +#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec +#define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(hbool_t) +#define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF +#define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_hbool_t +#define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_hbool_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF +#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t +/* Definitions for file space page size in support of level-2 page caching */ +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t /******************/ @@ -131,6 +140,8 @@ static herr_t H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, siz static herr_t H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *value); static herr_t H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *value); +static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value); /*********************/ @@ -178,8 +189,10 @@ static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; -static const unsigned H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; +static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; +static const hbool_t H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; +static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; @@ -267,12 +280,24 @@ H5P_fcrt_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the free-space persist flag */ + if(H5P_register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, &H5F_def_free_space_persist_g, + NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, H5F_CRT_FREE_SPACE_PERSIST_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the free space section threshold */ if(H5P_register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, &H5F_def_free_space_threshold_g, NULL, NULL, NULL, H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the file space page size */ + if(H5P_register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, &H5F_def_file_space_page_size_g, + NULL, NULL, NULL, H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fcrt_reg_prop() */ @@ -1246,15 +1271,13 @@ H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *mi if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - /* Get value */ - if (max_list) { + /* Get value(s) */ + if(max_list) if(H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get list maximum"); - } - if (min_btree) { + if(min_btree) if(H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get SOHM information"); - } done: FUNC_LEAVE_API(ret_value) @@ -1262,15 +1285,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pset_file_space + * Function: H5Pset_file_space_strategy * - * Purpose: Sets the strategy that the library employs in managing file space. - * If strategy is zero, the property is not changed; the existing - * strategy is retained. - * Sets the threshold value that the file's free space - * manager(s) will use to track free space sections. - * If threshold is zero, the property is not changed; the existing - * threshold is retained. + * Purpose: Sets the "strategy" that the library employs in managing file space + * Sets the "persist" value as to persist free-space or not + * Sets the "threshold" value that the free space manager(s) will use to track free space sections. + * Ignore "persist" and "threshold" for strategies that do not use free-space managers * * Return: Non-negative on success/Negative on failure * @@ -1279,15 +1299,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold) +H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "iFfh", plist_id, strategy, threshold); + H5TRACE4("e", "iFfbh", plist_id, strategy, persist, threshold); - if((unsigned)strategy >= H5F_FILE_SPACE_NTYPES) + /* Check arguments */ + if(strategy >= H5F_FSPACE_STRATEGY_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") /* Get the plist structure */ @@ -1295,24 +1316,28 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value(s), if non-zero */ - if(strategy) - if(H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set file space strategy") - if(threshold) - if(H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set free-space threshold") + if(H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") + + /* Ignore persist and threshold settings for strategies that do not use FSM */ + if(strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { + if(H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space persisting status") + + if(H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space threshold") + } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pset_file_space() */ +} /* H5Pset_file_space_strategy() */ /*------------------------------------------------------------------------- - * Function: H5Pget_file_space + * Function: H5Pget_file_space_strategy * - * Purpose: Retrieves the strategy that the library uses in managing file space. - * Retrieves the threshold value that the file's free space - * managers use to track free space sections. + * Purpose: Retrieves the strategy, persist, and threshold that the library + * uses in managing file space. * * Return: Non-negative on success/Negative on failure * @@ -1321,13 +1346,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold) +H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*Ff*h", plist_id, strategy, threshold); + H5TRACE4("e", "i*Ff*b*h", plist_id, strategy, persist, threshold); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) @@ -1337,11 +1362,158 @@ H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *thre if(strategy) if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") + if(persist) + if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space persisting status") if(threshold) if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold") done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_file_space() */ +} /* H5Pget_file_space_strategy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__fcrt_fspace_strategy_enc + * + * Purpose: Callback routine which is called whenever the free-space + * strategy property in the file creation property list + * is encoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, December 27, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) +{ + const H5F_fspace_strategy_t *strategy = (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ + uint8_t **pp = (uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(strategy); + HDassert(size); + + if(NULL != *pp) + /* Encode free-space strategy */ + *(*pp)++ = (uint8_t)*strategy; + + /* Size of free-space strategy */ + (*size)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__fcrt_fspace_strategy_enc() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__fcrt_fspace_strategy_dec + * + * Purpose: Callback routine which is called whenever the free-space + * strategy property in the file creation property list + * is decoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, December 27, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) +{ + H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ + const uint8_t **pp = (const uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(pp); + HDassert(*pp); + HDassert(strategy); + + /* Decode free-space strategy */ + *strategy = (H5F_fspace_strategy_t)*(*pp)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__fcrt_fspace_strategy_dec() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_file_space_page_size + * + * Purpose: Sets the file space page size for paged aggregation. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; August 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ih", plist_id, fsp_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "cannot set file space page size to less than 512") + + /* Set the value*/ + if(H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set file space page size") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pset_file_space_page_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_file_space_page_size + * + * Purpose: Retrieves the file space page size for aggregating small metadata + * or raw data in the parameter "fsp_size". + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; August 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*h", plist_id, fsp_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get value */ + if(fsp_size) + if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space page size") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pget_file_space_page_size() */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 5aa8301..50b9eb0 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -300,8 +300,10 @@ H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsig H5_DLL herr_t H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, unsigned *min_mesg_size); H5_DLL herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree); H5_DLL herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree); -H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); -H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); +H5_DLL herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold); +H5_DLL herr_t H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold); +H5_DLL herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size); +H5_DLL herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size); /* File access property list (FAPL) routines */ H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, @@ -367,6 +369,8 @@ H5_DLL herr_t H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective) #endif /* H5_HAVE_PARALLEL */ H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); +H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); +H5_DLL herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_per, unsigned *min_raw_per); /* Dataset creation property list (DCPL) routines */ H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); @@ -534,6 +538,8 @@ H5_DLL herr_t H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/, unsigned *freelist/*out*/, unsigned *stab/*out*/, unsigned *shhdr/*out*/); +H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); +H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus diff --git a/src/H5err.txt b/src/H5err.txt index 44c5a93..ffa9315 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -77,6 +77,7 @@ MAJOR, H5E_SOHM, Shared Object Header Messages MAJOR, H5E_EARRAY, Extensible Array MAJOR, H5E_FARRAY, Fixed Array MAJOR, H5E_PLUGIN, Plugin for dynamically loaded library +MAJOR, H5E_PAGEBUF, Page Buffering MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) diff --git a/src/H5trace.c b/src/H5trace.c index 44b2ed5..48c357a 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -895,32 +895,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "NULL"); } /* end if */ else { - H5F_file_space_type_t fs_type = (H5F_file_space_type_t)va_arg(ap, int); + H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)va_arg(ap, int); - switch(fs_type) { - case H5F_FILE_SPACE_DEFAULT: - fprintf(out, "H5F_FILE_SPACE_DEFAULT"); + switch(fs_strategy) { + case H5F_FSPACE_STRATEGY_FSM_AGGR: + fprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; - case H5F_FILE_SPACE_ALL_PERSIST: - fprintf(out, "H5F_FILE_SPACE_ALL_PERSIST"); + case H5F_FSPACE_STRATEGY_PAGE: + fprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); break; - case H5F_FILE_SPACE_ALL: - fprintf(out, "H5F_FILE_SPACE_ALL"); + case H5F_FSPACE_STRATEGY_AGGR: + fprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); break; - case H5F_FILE_SPACE_AGGR_VFD: - fprintf(out, "H5F_FILE_SPACE_AGGR_VFD"); + case H5F_FSPACE_STRATEGY_NONE: + fprintf(out, "H5F_FSPACE_STRATEGY_NONE"); break; - case H5F_FILE_SPACE_VFD: - fprintf(out, "H5F_FILE_SPACE_VFD"); - break; - - case H5F_FILE_SPACE_NTYPES: + case H5F_FSPACE_STRATEGY_NTYPES: default: - fprintf(out, "%ld", (long)fs_type); + fprintf(out, "%ld", (long)fs_strategy); break; } /* end switch */ } /* end else */ @@ -1003,6 +999,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ break; + case 't': + if(ptr) { + if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + break; + case 'v': if(ptr) { if(vp) diff --git a/src/Makefile.am b/src/Makefile.am index 69b54b4..59df4c2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,7 +60,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5F.c H5Fint.c H5Faccum.c H5Fcwfs.c \ H5Fdbg.c H5Fdeprec.c H5Fefc.c H5Ffake.c H5Fio.c \ H5Fmount.c H5Fquery.c \ - H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ + H5Fsfile.c H5Fspace.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ @@ -98,6 +98,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ H5Pgcpl.c H5Pint.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ + H5PB.c \ H5PL.c \ H5R.c H5Rdeprec.c \ H5UC.c \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9657971..d7965cb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -246,6 +246,7 @@ set (H5_TESTS cross_read freespace mf + page_buffer vds file_image unregister diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index fc8587b..f372acf 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -170,6 +170,7 @@ endforeach () #-- Copy all the HDF5 files from the test directory into the source directory # -------------------------------------------------------------------- set (HDF5_REFERENCE_TEST_FILES + aggr.h5 bad_compound.h5 be_data.h5 be_extlink1.h5 @@ -187,7 +188,15 @@ set (HDF5_REFERENCE_TEST_FILES filespace_1_8.h5 fill_old.h5 filter_error.h5 + fsm_aggr_nopersist.h5 + fsm_aggr_persist.h5 group_old.h5 + h5fc_ext1_i.h5 + h5fc_ext1_f.h5 + h5fc_ext2_if.h5 + h5fc_ext2_sf.h5 + h5fc_ext3_isf.h5 + h5fc_ext_none.h5 le_data.h5 le_extlink1.h5 le_extlink2.h5 @@ -195,6 +204,9 @@ set (HDF5_REFERENCE_TEST_FILES multi_file_v16-r.h5 multi_file_v16-s.h5 noencoder.h5 + none.h5 + paged_nopersist.h5 + paged_persist.h5 specmetaread.h5 tarrold.h5 tbad_msg_count.h5 @@ -618,6 +630,7 @@ set (H5TEST_TESTS cross_read freespace mf + page_buffer vds file_image unregister @@ -1288,7 +1301,6 @@ if (HDF5_BUILD_GENERATORS) gen_cross gen_deflate gen_filters - gen_idx gen_new_array gen_new_fill gen_new_group diff --git a/test/Makefile.am b/test/Makefile.am index 98cfc42..a64cd0e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -54,7 +54,7 @@ check_SCRIPTS = $(TEST_SCRIPT) TEST_PROG= testhdf5 \ cache cache_api cache_image cache_tagging lheap ohdr stab gheap \ evict_on_close farray earray btree2 fheap \ - pool accum hyperslab istore bittests dt_arith \ + pool accum hyperslab istore bittests dt_arith page_buffer \ dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \ twriteorder big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\ @@ -91,7 +91,7 @@ endif # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \ +BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \ gen_sizes_lheap gen_file_image gen_plist diff --git a/test/aggr.h5 b/test/aggr.h5 new file mode 100644 index 0000000..b24365d Binary files /dev/null and b/test/aggr.h5 differ diff --git a/test/cache.c b/test/cache.c index c381776..ba6fb0e 100644 --- a/test/cache.c +++ b/test/cache.c @@ -97,19 +97,19 @@ struct move_entry_test_spec /* private function declarations: */ -static unsigned smoke_check_1(int express_test); -static unsigned smoke_check_2(int express_test); -static unsigned smoke_check_3(int express_test); -static unsigned smoke_check_4(int express_test); -static unsigned smoke_check_5(int express_test); -static unsigned smoke_check_6(int express_test); -static unsigned smoke_check_7(int express_test); -static unsigned smoke_check_8(int express_test); -static unsigned smoke_check_9(int express_test); -static unsigned smoke_check_10(int express_test); -static unsigned write_permitted_check(int express_test); -static unsigned check_insert_entry(void); -static unsigned check_flush_cache(void); +static unsigned smoke_check_1(int express_test, unsigned paged); +static unsigned smoke_check_2(int express_test, unsigned paged); +static unsigned smoke_check_3(int express_test, unsigned paged); +static unsigned smoke_check_4(int express_test, unsigned paged); +static unsigned smoke_check_5(int express_test, unsigned paged); +static unsigned smoke_check_6(int express_test, unsigned paged); +static unsigned smoke_check_7(int express_test, unsigned paged); +static unsigned smoke_check_8(int express_test, unsigned paged); +static unsigned smoke_check_9(int express_test, unsigned paged); +static unsigned smoke_check_10(int express_test, unsigned paged); +static unsigned write_permitted_check(int express_test, unsigned paged); +static unsigned check_insert_entry(unsigned paged); +static unsigned check_flush_cache(unsigned paged); static void check_flush_cache__empty_cache(H5F_t * file_ptr); static void check_flush_cache__multi_entry(H5F_t * file_ptr); static void check_flush_cache__multi_entry_test(H5F_t * file_ptr, @@ -159,48 +159,49 @@ static void check_flush_cache__flush_op_test(H5F_t * file_ptr, int check_size, struct fo_flush_entry_check check[]); static void check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr); -static unsigned check_get_entry_status(void); -static unsigned check_expunge_entry(void); -static unsigned check_multiple_read_protect(void); -static unsigned check_move_entry(void); +static unsigned check_get_entry_status(unsigned paged); +static unsigned check_expunge_entry(unsigned paged); +static unsigned check_multiple_read_protect(unsigned paged); +static unsigned check_move_entry(unsigned paged); static void check_move_entry__run_test(H5F_t * file_ptr, unsigned test_num, struct move_entry_test_spec * spec_ptr); -static unsigned check_pin_protected_entry(void); -static unsigned check_resize_entry(void); -static unsigned check_evictions_enabled(void); -static unsigned check_flush_protected_err(void); -static unsigned check_destroy_pinned_err(void); -static unsigned check_destroy_protected_err(void); -static unsigned check_duplicate_insert_err(void); -static unsigned check_double_pin_err(void); -static unsigned check_double_unpin_err(void); -static unsigned check_pin_entry_errs(void); -static unsigned check_double_protect_err(void); -static unsigned check_double_unprotect_err(void); -static unsigned check_mark_entry_dirty_errs(void); -static unsigned check_expunge_entry_errs(void); -static unsigned check_move_entry_errs(void); -static unsigned check_resize_entry_errs(void); -static unsigned check_unprotect_ro_dirty_err(void); -static unsigned check_protect_ro_rw_err(void); -static unsigned check_check_evictions_enabled_err(void); -static unsigned check_auto_cache_resize(hbool_t cork_ageout); -static unsigned check_auto_cache_resize_disable(void); -static unsigned check_auto_cache_resize_epoch_markers(void); -static unsigned check_auto_cache_resize_input_errs(void); -static unsigned check_auto_cache_resize_aux_fcns(void); -static unsigned check_metadata_blizzard_absence(hbool_t fill_via_insertion); -static unsigned check_flush_deps(void); -static unsigned check_flush_deps_err(void); -static unsigned check_flush_deps_order(void); -static unsigned check_notify_cb(void); -static unsigned check_metadata_cork(hbool_t fill_via_insertion); -static unsigned check_entry_deletions_during_scans(void); +static unsigned check_pin_protected_entry(unsigned paged); +static unsigned check_resize_entry(unsigned paged); +static unsigned check_evictions_enabled(unsigned paged); +static unsigned check_flush_protected_err(unsigned paged); +static unsigned check_destroy_pinned_err(unsigned paged); +static unsigned check_destroy_protected_err(unsigned paged); +static unsigned check_duplicate_insert_err(unsigned paged); +static unsigned check_double_pin_err(unsigned paged); +static unsigned check_double_unpin_err(unsigned paged); +static unsigned check_pin_entry_errs(unsigned paged); +static unsigned check_double_protect_err(unsigned paged); +static unsigned check_double_unprotect_err(unsigned paged); +static unsigned check_mark_entry_dirty_errs(unsigned paged); +static unsigned check_expunge_entry_errs(unsigned paged); +static unsigned check_move_entry_errs(unsigned paged); +static unsigned check_resize_entry_errs(unsigned paged); +static unsigned check_unprotect_ro_dirty_err(unsigned paged); +static unsigned check_protect_ro_rw_err(unsigned paged); +static unsigned check_protect_retries(unsigned paged); +static unsigned check_check_evictions_enabled_err(unsigned paged); +static unsigned check_auto_cache_resize(hbool_t cork_ageout, unsigned paged); +static unsigned check_auto_cache_resize_disable(unsigned paged); +static unsigned check_auto_cache_resize_epoch_markers(unsigned paged); +static unsigned check_auto_cache_resize_input_errs(unsigned paged); +static unsigned check_auto_cache_resize_aux_fcns(unsigned paged); +static unsigned check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged); +static unsigned check_flush_deps(unsigned paged); +static unsigned check_flush_deps_err(unsigned paged); +static unsigned check_flush_deps_order(unsigned paged); +static unsigned check_notify_cb(unsigned paged); +static unsigned check_metadata_cork(hbool_t fill_via_insertion, unsigned paged); +static unsigned check_entry_deletions_during_scans(unsigned paged); static void cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr); static void cedds__H5C_make_space_in_cache(H5F_t * file_ptr); static void cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr); static void cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr); -static unsigned check_stats(void); +static unsigned check_stats(unsigned paged); #if H5C_COLLECT_CACHE_STATS static void check_stats__smoke_check_1(H5F_t * file_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ @@ -228,7 +229,7 @@ static void check_stats__smoke_check_1(H5F_t * file_ptr); */ static unsigned -smoke_check_1(int express_test) +smoke_check_1(int express_test, unsigned paged) { hbool_t show_progress = FALSE; int dirty_unprotects = FALSE; @@ -239,7 +240,10 @@ smoke_check_1(int express_test) int mile_stone = 1; H5F_t * file_ptr = NULL; - TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache"); + if(paged) + TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache, paged aggregation") + else + TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache") switch (express_test) { @@ -274,8 +278,7 @@ smoke_check_1(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), - (size_t)(2 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); if(show_progress) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -427,7 +430,7 @@ smoke_check_1(int express_test) */ static unsigned -smoke_check_2(int express_test) +smoke_check_2(int express_test, unsigned paged) { hbool_t show_progress = FALSE; int dirty_unprotects = TRUE; @@ -438,7 +441,10 @@ smoke_check_2(int express_test) int mile_stone = 1; H5F_t * file_ptr = NULL; - TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache"); + if(paged) + TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache, paged aggregation") + else + TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache") switch (express_test) { @@ -473,8 +479,7 @@ smoke_check_2(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), - (size_t)(2 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); if(show_progress) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -625,7 +630,7 @@ smoke_check_2(int express_test) */ static unsigned -smoke_check_3(int express_test) +smoke_check_3(int express_test, unsigned paged) { hbool_t show_progress = FALSE; int dirty_unprotects = FALSE; @@ -636,7 +641,10 @@ smoke_check_3(int express_test) int mile_stone = 1; H5F_t * file_ptr = NULL; - TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache"); + if(paged) + TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache, paged aggregation") + else + TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache") switch (express_test) { @@ -671,8 +679,7 @@ smoke_check_3(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); if(show_progress) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -824,7 +831,7 @@ smoke_check_3(int express_test) */ static unsigned -smoke_check_4(int express_test) +smoke_check_4(int express_test, unsigned paged) { hbool_t show_progress = FALSE; int dirty_unprotects = TRUE; @@ -835,7 +842,10 @@ smoke_check_4(int express_test) int mile_stone = 1; H5F_t * file_ptr = NULL; - TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache"); + if(paged) + TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache, paged aggregation") + else + TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache") switch (express_test) { @@ -870,8 +880,7 @@ smoke_check_4(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); if(show_progress) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -1023,7 +1032,7 @@ smoke_check_4(int express_test) */ static unsigned -smoke_check_5(int express_test) +smoke_check_5(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -1082,7 +1091,10 @@ smoke_check_5(int express_test) /* double empty_reserve = */ 0.5f }; - TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1"); + if(paged) + TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1, paged aggregation") + else + TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1") switch (express_test) { @@ -1117,8 +1129,7 @@ smoke_check_5(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(pass) { @@ -1259,7 +1270,7 @@ smoke_check_5(int express_test) */ static unsigned -smoke_check_6(int express_test) +smoke_check_6(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -1318,7 +1329,10 @@ smoke_check_6(int express_test) /* double empty_reserve = */ 0.05f }; - TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1"); + if(paged) + TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1, paged aggregation") + else + TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1") pass = TRUE; @@ -1353,8 +1367,7 @@ smoke_check_6(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(pass) { @@ -1495,7 +1508,7 @@ smoke_check_6(int express_test) */ static unsigned -smoke_check_7(int express_test) +smoke_check_7(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -1555,7 +1568,10 @@ smoke_check_7(int express_test) /* double empty_reserve = */ 0.1f }; - TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2"); + if(paged) + TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2, paged aggregation") + else + TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2") switch (express_test) { @@ -1590,8 +1606,7 @@ smoke_check_7(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(pass) { @@ -1732,7 +1747,7 @@ smoke_check_7(int express_test) */ static unsigned -smoke_check_8(int express_test) +smoke_check_8(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -1792,7 +1807,10 @@ smoke_check_8(int express_test) /* double empty_reserve = */ 0.1f }; - TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2"); + if(paged) + TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2, paged aggregation") + else + TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2") switch (express_test) { @@ -1827,7 +1845,7 @@ smoke_check_8(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(pass) { @@ -1975,7 +1993,7 @@ smoke_check_8(int express_test) */ static unsigned -smoke_check_9(int express_test) +smoke_check_9(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -1989,7 +2007,10 @@ smoke_check_9(int express_test) H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; - TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked"); + if(paged) + TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked, paged aggregation") + else + TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked") switch (express_test) { @@ -2024,8 +2045,7 @@ smoke_check_9(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), - (size_t)(2 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; /* disable evictions */ @@ -2295,7 +2315,7 @@ smoke_check_9(int express_test) */ static unsigned -smoke_check_10(int express_test) +smoke_check_10(int express_test, unsigned paged) { herr_t result; hbool_t show_progress = FALSE; @@ -2309,7 +2329,10 @@ smoke_check_10(int express_test) H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; - TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked"); + if(paged) + TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked, paged aggregation") + else + TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked") switch (express_test) { @@ -2344,8 +2367,7 @@ smoke_check_10(int express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), - (size_t)(2 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(show_progress) /* 3 */ @@ -2609,7 +2631,7 @@ write_permitted_check(int #if !H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS H5_ATTR_UNUSED #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -express_test) +express_test, unsigned paged) { #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS @@ -2623,7 +2645,10 @@ express_test) #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - TESTING("write permitted check -- 1/0 MB cache"); + if(paged) + TESTING("write permitted check -- 1/0 MB cache, paged aggregation") + else + TESTING("write permitted check -- 1/0 MB cache") #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS @@ -2660,8 +2685,7 @@ express_test) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(1 * 1024 * 1024), - (size_t)(0)); + file_ptr = setup_cache((size_t)(1 * 1024 * 1024), (size_t)0, paged); if(show_progress) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -2823,7 +2847,7 @@ express_test) */ static unsigned -check_insert_entry(void) +check_insert_entry(unsigned paged) { int entry_type = PICO_ENTRY_TYPE; int i; @@ -2839,8 +2863,10 @@ check_insert_entry(void) test_entry_t * entry_ptr; struct H5C_cache_entry_t * search_ptr; - - TESTING("H5C_insert_entry() functionality"); + if(paged) + TESTING("H5C_insert_entry() functionality (paged aggregation)") + else + TESTING("H5C_insert_entry() functionality") pass = TRUE; @@ -2858,8 +2884,7 @@ check_insert_entry(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -3115,11 +3140,14 @@ check_insert_entry(void) */ static unsigned -check_flush_cache(void) +check_flush_cache(unsigned paged) { H5F_t * file_ptr = NULL; - TESTING("H5C_flush_cache() functionality"); + if(paged) + TESTING("H5C_flush_cache() functionality (paged aggregation)") + else + TESTING("H5C_flush_cache() functionality") pass = TRUE; @@ -3132,8 +3160,7 @@ check_flush_cache(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } /* first test behaviour on an empty cache. Can't do much sanity @@ -12751,7 +12778,7 @@ check_flush_cache__pinned_single_entry_test(H5F_t * file_ptr, */ static unsigned -check_get_entry_status(void) +check_get_entry_status(unsigned paged) { static char msg[128]; herr_t result; @@ -12764,7 +12791,10 @@ check_get_entry_status(void) test_entry_t * base_addr = NULL; test_entry_t * entry_ptr = NULL; - TESTING("H5C_get_entry_status() functionality"); + if(paged) + TESTING("H5C_get_entry_status() functionality (paged aggregation)") + else + TESTING("H5C_get_entry_status() functionality") pass = TRUE; @@ -12772,8 +12802,7 @@ check_get_entry_status(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); if(file_ptr == NULL) { @@ -12980,7 +13009,7 @@ check_get_entry_status(void) */ static unsigned -check_expunge_entry(void) +check_expunge_entry(unsigned paged) { static char msg[128]; herr_t result; @@ -12993,7 +13022,10 @@ check_expunge_entry(void) test_entry_t * base_addr; test_entry_t * entry_ptr; - TESTING("H5C_expunge_entry() functionality"); + if(paged) + TESTING("H5C_expunge_entry() functionality (paged aggregation)") + else + TESTING("H5C_expunge_entry() functionality") pass = TRUE; @@ -13001,8 +13033,7 @@ check_expunge_entry(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); base_addr = entries[0]; entry_ptr = &(base_addr[0]); @@ -13289,7 +13320,7 @@ check_expunge_entry(void) *------------------------------------------------------------------------- */ static unsigned -check_multiple_read_protect(void) +check_multiple_read_protect(unsigned paged) { H5F_t * file_ptr = NULL; #if H5C_COLLECT_CACHE_STATS @@ -13297,7 +13328,10 @@ check_multiple_read_protect(void) #endif /* H5C_COLLECT_CACHE_STATS */ test_entry_t * entry_ptr; - TESTING("multiple read only protects on a single entry"); + if(paged) + TESTING("multiple read only protects on a single entry (paged aggregation)") + else + TESTING("multiple read only protects on a single entry") pass = TRUE; @@ -13326,8 +13360,7 @@ check_multiple_read_protect(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); #if H5C_COLLECT_CACHE_STATS cache_ptr = file_ptr->shared->cache; #endif /* H5C_COLLECT_CACHE_STATS */ @@ -13711,7 +13744,7 @@ check_multiple_read_protect(void) */ static unsigned -check_move_entry(void) +check_move_entry(unsigned paged) { unsigned u; H5F_t * file_ptr = NULL; @@ -13743,7 +13776,10 @@ check_move_entry(void) }, }; - TESTING("H5C_move_entry() functionality"); + if(paged) + TESTING("H5C_move_entry() functionality (paged aggregation)") + else + TESTING("H5C_move_entry() functionality") pass = TRUE; @@ -13776,8 +13812,7 @@ check_move_entry(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } u = 0; @@ -14003,7 +14038,7 @@ check_move_entry__run_test(H5F_t * file_ptr, */ static unsigned -check_pin_protected_entry(void) +check_pin_protected_entry(unsigned paged) { static char msg[128]; herr_t result; @@ -14011,7 +14046,10 @@ check_pin_protected_entry(void) test_entry_t * base_addr; test_entry_t * entry_ptr; - TESTING("H5C_pin_protected_entry() functionality"); + if(paged) + TESTING("H5C_pin_protected_entry() functionality (paged aggregation)") + else + TESTING("H5C_pin_protected_entry() functionality") pass = TRUE; @@ -14024,8 +14062,7 @@ check_pin_protected_entry(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); if(file_ptr == NULL) { @@ -14102,7 +14139,7 @@ check_pin_protected_entry(void) */ static unsigned -check_resize_entry(void) +check_resize_entry(unsigned paged) { static char msg[128]; herr_t result; @@ -14117,7 +14154,10 @@ check_resize_entry(void) test_entry_t * base_addr; test_entry_t * entry_ptr = NULL; - TESTING("entry resize functionality"); + if(paged) + TESTING("entry resize functionality (paged aggregation)") + else + TESTING("entry resize functionality") /* Setup a cache and verify that it is empty. * @@ -14156,8 +14196,8 @@ check_resize_entry(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); + if(file_ptr == NULL) { pass = FALSE; @@ -15097,7 +15137,7 @@ check_resize_entry(void) */ static unsigned -check_evictions_enabled(void) +check_evictions_enabled(unsigned paged) { static char msg[128]; herr_t result; @@ -15111,7 +15151,10 @@ check_evictions_enabled(void) test_entry_t * base_addr = NULL; test_entry_t * entry_ptr; - TESTING("evictions enabled/disabled functionality"); + if(paged) + TESTING("evictions enabled/disabled functionality (paged aggregation)") + else + TESTING("evictions enabled/disabled functionality") /* Setup a cache and verify that it is empty. * @@ -15159,8 +15202,8 @@ check_evictions_enabled(void) reset_entries(); - file_ptr = setup_cache((size_t)(1 * 1024 * 1024), - (size_t)( 512 * 1024)); + file_ptr = setup_cache((size_t)(1 * 1024 * 1024), (size_t)(512 * 1024), paged); + if(file_ptr == NULL) { pass = FALSE; @@ -15830,11 +15873,14 @@ check_evictions_enabled(void) */ static unsigned -check_flush_protected_err(void) +check_flush_protected_err(unsigned paged) { H5F_t * file_ptr = NULL; - TESTING("flush cache with protected entry error"); + if(paged) + TESTING("flush cache with protected entry error (paged aggregation)") + else + TESTING("flush cache with protected entry error") pass = TRUE; @@ -15847,8 +15893,7 @@ check_flush_protected_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -15904,11 +15949,14 @@ check_flush_protected_err(void) *------------------------------------------------------------------------- */ static unsigned -check_destroy_pinned_err(void) +check_destroy_pinned_err(unsigned paged) { H5F_t * file_ptr = NULL; - TESTING("destroy cache with permanently pinned entry error"); + if(paged) + TESTING("destroy cache with permanently pinned entry error (paged aggregation)") + else + TESTING("destroy cache with permanently pinned entry error") pass = TRUE; @@ -15920,8 +15968,7 @@ check_destroy_pinned_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); @@ -15985,11 +16032,14 @@ check_destroy_pinned_err(void) */ static unsigned -check_destroy_protected_err(void) +check_destroy_protected_err(unsigned paged) { H5F_t * file_ptr = NULL; - TESTING("destroy cache with protected entry error"); + if(paged) + TESTING("destroy cache with protected entry error (paged aggregation)") + else + TESTING("destroy cache with protected entry error") pass = TRUE; @@ -16002,8 +16052,7 @@ check_destroy_protected_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); /* Note: normally this call would go just before the series of * flushes prior to file close -- in particular, all entries @@ -16075,14 +16124,17 @@ check_destroy_protected_err(void) */ static unsigned -check_duplicate_insert_err(void) +check_duplicate_insert_err(unsigned paged) { herr_t result = -1; H5F_t * file_ptr = NULL; test_entry_t * base_addr; test_entry_t * entry_ptr; - TESTING("duplicate entry insertion error"); + if(paged) + TESTING("duplicate entry insertion error (paged aggregation)") + else + TESTING("duplicate entry insertion error") pass = TRUE; @@ -16095,8 +16147,7 @@ check_duplicate_insert_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16155,13 +16206,16 @@ check_duplicate_insert_err(void) */ static unsigned -check_double_pin_err(void) +check_double_pin_err(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("pin a pinned entry error"); + if(paged) + TESTING("pin a pinned entry error (paged aggregation)") + else + TESTING("pin a pinned entry error") pass = TRUE; @@ -16175,8 +16229,7 @@ check_double_pin_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16241,13 +16294,16 @@ check_double_pin_err(void) */ static unsigned -check_double_unpin_err(void) +check_double_unpin_err(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("unpin an unpinned entry error"); + if(paged) + TESTING("unpin an unpinned entry error (paged aggregation)") + else + TESTING("unpin an unpinned entry error") pass = TRUE; @@ -16263,8 +16319,7 @@ check_double_unpin_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16338,13 +16393,16 @@ check_double_unpin_err(void) */ static unsigned -check_pin_entry_errs(void) +check_pin_entry_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("pin entry related errors"); + if(paged) + TESTING("pin entry related errors (paged aggregation)") + else + TESTING("pin entry related errors") pass = TRUE; @@ -16364,8 +16422,7 @@ check_pin_entry_errs(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16444,13 +16501,16 @@ check_pin_entry_errs(void) */ static unsigned -check_double_protect_err(void) +check_double_protect_err(unsigned paged) { H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; H5C_cache_entry_t * cache_entry_ptr; - TESTING("protect a protected entry error"); + if(paged) + TESTING("protect a protected entry error (paged aggregation)") + else + TESTING("protect a protected entry error") pass = TRUE; @@ -16463,8 +16523,7 @@ check_double_protect_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16522,13 +16581,16 @@ check_double_protect_err(void) */ static unsigned -check_double_unprotect_err(void) +check_double_unprotect_err(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("unprotect an unprotected entry error"); + if(paged) + TESTING("unprotect an unprotected entry error (paged aggregation)") + else + TESTING("unprotect an unprotected entry error") pass = TRUE; @@ -16541,8 +16603,7 @@ check_double_unprotect_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16600,13 +16661,16 @@ check_double_unprotect_err(void) */ static unsigned -check_mark_entry_dirty_errs(void) +check_mark_entry_dirty_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("mark entry dirty related errors"); + if(paged) + TESTING("mark entry dirty related errors (paged aggregation)") + else + TESTING("mark entry dirty related errors") pass = TRUE; @@ -16620,8 +16684,7 @@ check_mark_entry_dirty_errs(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); @@ -16680,13 +16743,16 @@ check_mark_entry_dirty_errs(void) */ static unsigned -check_expunge_entry_errs(void) +check_expunge_entry_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("expunge entry related errors"); + if(paged) + TESTING("expunge entry related errors (paged aggregation)") + else + TESTING("expunge entry related errors") pass = TRUE; @@ -16706,8 +16772,7 @@ check_expunge_entry_errs(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); entry_ptr = &((entries[0])[0]); @@ -16798,7 +16863,7 @@ check_expunge_entry_errs(void) *------------------------------------------------------------------------- */ static unsigned -check_move_entry_errs(void) +check_move_entry_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; @@ -16808,7 +16873,10 @@ check_move_entry_errs(void) test_entry_t * entry_0_1_ptr; test_entry_t * entry_1_0_ptr; - TESTING("move entry related errors"); + if(paged) + TESTING("move entry related errors (paged aggregation)") + else + TESTING("move entry related errors") pass = TRUE; @@ -16820,7 +16888,7 @@ check_move_entry_errs(void) if(pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -16863,8 +16931,7 @@ check_move_entry_errs(void) if(pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); - + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -16914,13 +16981,16 @@ check_move_entry_errs(void) */ static unsigned -check_resize_entry_errs(void) +check_resize_entry_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("resize entry related errors"); + if(paged) + TESTING("resize entry related errors (paged aggregation)") + else + TESTING("resize entry related errors") pass = TRUE; @@ -16939,8 +17009,7 @@ check_resize_entry_errs(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); entry_ptr = &((entries[0])[0]); @@ -17015,13 +17084,16 @@ check_resize_entry_errs(void) */ static unsigned -check_unprotect_ro_dirty_err(void) +check_unprotect_ro_dirty_err(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; - TESTING("unprotect a read only entry dirty error"); + if(paged) + TESTING("unprotect a read only entry dirty error (paged aggregation)") + else + TESTING("unprotect a read only entry dirty error") pass = TRUE; @@ -17034,8 +17106,7 @@ check_unprotect_ro_dirty_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry_ro(file_ptr, 0, 0); @@ -17076,8 +17147,7 @@ check_unprotect_ro_dirty_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry_ro(file_ptr, 0, 0); protect_entry_ro(file_ptr, 0, 0); @@ -17142,13 +17212,16 @@ check_unprotect_ro_dirty_err(void) */ static unsigned -check_protect_ro_rw_err(void) +check_protect_ro_rw_err(unsigned paged) { H5F_t * file_ptr = NULL; test_entry_t * entry_ptr; void * thing_ptr = NULL; - TESTING("protect a read only entry rw error"); + if(paged) + TESTING("protect a read only entry rw error (paged aggregation)") + else + TESTING("protect a read only entry rw error") pass = TRUE; @@ -17162,8 +17235,7 @@ check_protect_ro_rw_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry_ro(file_ptr, 0, 0); @@ -17219,7 +17291,7 @@ check_protect_ro_rw_err(void) *------------------------------------------------------------------------- */ static unsigned -check_protect_retries(void) +check_protect_retries(unsigned paged) { H5F_t * file_ptr = NULL; H5C_t *cache_ptr = NULL; @@ -17229,7 +17301,10 @@ check_protect_retries(void) int32_t type; int32_t idx; - TESTING("protect an entry to verify retries"); + if(paged) + TESTING("protect an entry to verify retries (paged aggregation)") + else + TESTING("protect an entry to verify retries") pass = TRUE; @@ -17238,8 +17313,7 @@ check_protect_retries(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); /* Set up read attempts for verifying checksum */ file_ptr->shared->read_attempts = 10; @@ -17354,14 +17428,17 @@ check_protect_retries(void) */ static unsigned -check_check_evictions_enabled_err(void) +check_check_evictions_enabled_err(unsigned paged) { herr_t result; hbool_t evictions_enabled; H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; - TESTING("get/set evictions enabled errors"); + if(paged) + TESTING("get/set evictions enabled errors (paged aggregation)") + else + TESTING("get/set evictions enabled errors") pass = TRUE; @@ -17382,8 +17459,7 @@ check_check_evictions_enabled_err(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -17506,7 +17582,7 @@ static void test_rpt_fcn(H5_ATTR_UNUSED H5C_t * cache_ptr, } static unsigned -check_auto_cache_resize(hbool_t cork_ageout) +check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) { hbool_t show_progress = FALSE; herr_t result; @@ -17560,7 +17636,10 @@ check_auto_cache_resize(hbool_t cork_ageout) /* double empty_reserve = */ 0.05f }; - TESTING("automatic cache resizing"); + if(paged) + TESTING("automatic cache resizing (paged aggregation)") + else + TESTING("automatic cache resizing") pass = TRUE; @@ -17574,7 +17653,7 @@ check_auto_cache_resize(hbool_t cork_ageout) if(pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -21576,7 +21655,7 @@ check_auto_cache_resize(hbool_t cork_ageout) */ static unsigned -check_auto_cache_resize_disable(void) +check_auto_cache_resize_disable(unsigned paged) { hbool_t show_progress = FALSE; herr_t result; @@ -21630,7 +21709,10 @@ check_auto_cache_resize_disable(void) /* double empty_reserve = */ 0.05f }; - TESTING("automatic cache resize disable"); + if(paged) + TESTING("automatic cache resize disable (paged aggregation)") + else + TESTING("automatic cache resize disable") pass = TRUE; @@ -21645,8 +21727,7 @@ check_auto_cache_resize_disable(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); if(file_ptr == NULL) { @@ -24301,7 +24382,7 @@ check_auto_cache_resize_disable(void) */ static unsigned -check_auto_cache_resize_epoch_markers(void) +check_auto_cache_resize_epoch_markers(unsigned paged) { hbool_t show_progress = FALSE; herr_t result; @@ -24356,7 +24437,10 @@ check_auto_cache_resize_epoch_markers(void) /* double empty_reserve = */ 0.05f }; - TESTING("automatic cache resize epoch marker management"); + if(paged) + TESTING("automatic cache resize epoch marker management (paged aggregation)") + else + TESTING("automatic cache resize epoch marker management") pass = TRUE; @@ -24366,8 +24450,7 @@ check_auto_cache_resize_epoch_markers(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -25010,7 +25093,7 @@ check_auto_cache_resize_epoch_markers(void) */ static unsigned -check_auto_cache_resize_input_errs(void) +check_auto_cache_resize_input_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; @@ -25064,7 +25147,10 @@ check_auto_cache_resize_input_errs(void) H5C_auto_size_ctl_t invalid_auto_size_ctl; H5C_auto_size_ctl_t test_auto_size_ctl; - TESTING("automatic cache resize input errors"); + if(paged) + TESTING("automatic cache resize input errors (paged aggregation)") + else + TESTING("automatic cache resize input errors") pass = TRUE; @@ -25078,8 +25164,7 @@ check_auto_cache_resize_input_errs(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -27417,7 +27502,7 @@ check_auto_cache_resize_input_errs(void) */ static unsigned -check_auto_cache_resize_aux_fcns(void) +check_auto_cache_resize_aux_fcns(unsigned paged) { herr_t result; int32_t i; @@ -27478,7 +27563,10 @@ check_auto_cache_resize_aux_fcns(void) }; - TESTING("automatic cache resize auxilary functions"); + if(paged) + TESTING("automatic cache resize auxilary functions (paged aggregation)") + else + TESTING("automatic cache resize auxilary functions") pass = TRUE; @@ -27489,8 +27577,7 @@ check_auto_cache_resize_aux_fcns(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } @@ -27962,7 +28049,7 @@ check_auto_cache_resize_aux_fcns(void) */ static unsigned -check_metadata_blizzard_absence(hbool_t fill_via_insertion) +check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) { int entry_type = HUGE_ENTRY_TYPE; size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */ @@ -28142,13 +28229,17 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion) reset_entries(); if(fill_via_insertion) { - - TESTING("to ensure metadata blizzard absence when inserting"); - - } else { - - TESTING("to ensure metadata blizzard absence on protect/unprotect"); - } + if(paged) + TESTING("to ensure metadata blizzard absence when inserting (paged aggregation)") + else + TESTING("to ensure metadata blizzard absence when inserting") + } /* end if */ + else { + if(paged) + TESTING("to ensure metadata blizzard absence on protect/unprotect (paged aggregation)") + else + TESTING("to ensure metadata blizzard absence on protect/unprotect") + } /* end else */ if(show_progress) /* 0 */ HDfprintf(stdout, "\n%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); @@ -28160,8 +28251,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion) * The max_cache_size should have room for 50 entries. * The min_clean_size is half of that, or 25 entries. */ - file_ptr = setup_cache((size_t)(50 * entry_size), /* max_cache_size */ - (size_t)(25 * entry_size)); /* min_clean_size */ + file_ptr = setup_cache((size_t)(50 * entry_size), (size_t)(25 * entry_size), paged); if(file_ptr == NULL) { @@ -28805,7 +28895,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion) */ static unsigned -check_flush_deps(void) +check_flush_deps(unsigned paged) { H5F_t * file_ptr = NULL; /* File for this test */ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ @@ -28823,7 +28913,10 @@ check_flush_deps(void) { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} }; - TESTING("flush dependencies"); + if(paged) + TESTING("flush dependencies (paged aggregation)") + else + TESTING("flush dependencies") pass = TRUE; @@ -28832,7 +28925,7 @@ check_flush_deps(void) */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; base_addr = entries[entry_type]; @@ -30541,13 +30634,16 @@ done: */ static unsigned -check_flush_deps_err(void) +check_flush_deps_err(unsigned paged) { H5F_t * file_ptr = NULL; /* File for this test */ int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ unsigned test_count; /* Test iteration variable */ - TESTING("flush dependency errors"); + if(paged) + TESTING("flush dependency errors (paged aggregation)") + else + TESTING("flush dependency errors") pass = TRUE; @@ -30560,7 +30656,7 @@ check_flush_deps_err(void) /* Allocate a cache */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); if(!pass) CACHE_ERROR("setup_cache failed") /* Insert entries to work with into the cache */ @@ -30762,7 +30858,7 @@ done: */ static unsigned -check_flush_deps_order(void) +check_flush_deps_order(unsigned paged) { H5F_t * file_ptr = NULL; /* File for this test */ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ @@ -30780,7 +30876,10 @@ check_flush_deps_order(void) }; unsigned flush_order; /* Index for tracking flush order */ - TESTING("flush dependencies flush order"); + if(paged) + TESTING("flush dependencies flush order (paged aggregation)") + else + TESTING("flush dependencies flush order") pass = TRUE; @@ -30789,7 +30888,7 @@ check_flush_deps_order(void) */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; if(!pass) CACHE_ERROR("setup_cache failed") @@ -33330,7 +33429,7 @@ done: */ static unsigned -check_notify_cb(void) +check_notify_cb(unsigned paged) { H5F_t * file_ptr = NULL; /* File for this test */ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ @@ -33349,7 +33448,10 @@ check_notify_cb(void) { NOTIFY_ENTRY_TYPE, 4, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} }; - TESTING("'notify' callback"); + if(paged) + TESTING("'notify' callback (paged)") + else + TESTING("'notify' callback") pass = TRUE; @@ -33358,7 +33460,7 @@ check_notify_cb(void) */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); if(!file_ptr) CACHE_ERROR("setup_cache returned NULL") cache_ptr = file_ptr->shared->cache; base_addr = entries[entry_type]; @@ -33531,7 +33633,7 @@ done: *------------------------------------------------------------------------- */ static unsigned -check_metadata_cork(hbool_t fill_via_insertion) +check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) { const char * fcn_name = "check_metadata_cork"; int entry_type = HUGE_ENTRY_TYPE; @@ -33727,8 +33829,7 @@ check_metadata_cork(hbool_t fill_via_insertion) * The max_cache_size should have room for 50 entries. * The min_clean_size is half of that, or 25 entries. */ - file_ptr = setup_cache((size_t)(50 * entry_size), /* max_cache_size */ - (size_t)(25 * entry_size)); /* min_clean_size */ + file_ptr = setup_cache((size_t)(50 * entry_size), (size_t)(25 * entry_size), paged); if(file_ptr == NULL) { @@ -34277,11 +34378,14 @@ check_metadata_cork(hbool_t fill_via_insertion) *------------------------------------------------------------------------- */ static unsigned -check_entry_deletions_during_scans(void) +check_entry_deletions_during_scans(unsigned paged) { H5F_t * file_ptr = NULL; - TESTING("entry deletion during list scan detection and adaption"); + if(paged) + TESTING("entry deletion during list scan detection and adaption (paged aggregation)") + else + TESTING("entry deletion during list scan detection and adaption") pass = TRUE; @@ -34294,8 +34398,7 @@ check_entry_deletions_during_scans(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } /* run the tests. This set of tests is somewhat eclectic, as @@ -35769,7 +35872,7 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) */ static unsigned -check_stats(void) +check_stats(unsigned paged) { #if H5C_COLLECT_CACHE_STATS @@ -35778,7 +35881,10 @@ check_stats(void) #endif /* H5C_COLLECT_CACHE_STATS */ - TESTING("metadata cache statistics collection"); + if(paged) + TESTING("metadata cache statistics collection (paged aggregation)") + else + TESTING("metadata cache statistics collection") #if H5C_COLLECT_CACHE_STATS @@ -35786,8 +35892,7 @@ check_stats(void) reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); if(pass) { @@ -36268,6 +36373,7 @@ int main(void) { unsigned nerrs = 0; + unsigned paged; int express_test; H5open(); @@ -36285,61 +36391,63 @@ main(void) return EXIT_FAILURE; } /* end if */ - nerrs += smoke_check_1(express_test); - nerrs += smoke_check_2(express_test); - nerrs += smoke_check_3(express_test); - nerrs += smoke_check_4(express_test); - nerrs += smoke_check_5(express_test); - nerrs += smoke_check_6(express_test); - nerrs += smoke_check_7(express_test); - nerrs += smoke_check_8(express_test); - nerrs += smoke_check_9(express_test); - nerrs += smoke_check_10(express_test); - - nerrs += write_permitted_check(express_test); - - nerrs += check_insert_entry(); - nerrs += check_flush_cache(); - nerrs += check_get_entry_status(); - nerrs += check_expunge_entry(); - nerrs += check_multiple_read_protect(); - nerrs += check_move_entry(); - nerrs += check_pin_protected_entry(); - nerrs += check_resize_entry(); - nerrs += check_evictions_enabled(); - nerrs += check_flush_protected_err(); - nerrs += check_destroy_pinned_err(); - nerrs += check_destroy_protected_err(); - nerrs += check_duplicate_insert_err(); - nerrs += check_double_pin_err(); - nerrs += check_double_unpin_err(); - nerrs += check_pin_entry_errs(); - nerrs += check_double_protect_err(); - nerrs += check_double_unprotect_err(); - nerrs += check_mark_entry_dirty_errs(); - nerrs += check_expunge_entry_errs(); - nerrs += check_move_entry_errs(); - nerrs += check_resize_entry_errs(); - nerrs += check_unprotect_ro_dirty_err(); - nerrs += check_protect_ro_rw_err(); - nerrs += check_protect_retries(); - nerrs += check_check_evictions_enabled_err(); - nerrs += check_auto_cache_resize(FALSE); - nerrs += check_auto_cache_resize(TRUE); - nerrs += check_auto_cache_resize_disable(); - nerrs += check_auto_cache_resize_epoch_markers(); - nerrs += check_auto_cache_resize_input_errs(); - nerrs += check_auto_cache_resize_aux_fcns(); - nerrs += check_metadata_blizzard_absence(TRUE); - nerrs += check_metadata_blizzard_absence(FALSE); - nerrs += check_flush_deps(); - nerrs += check_flush_deps_err(); - nerrs += check_flush_deps_order(); - nerrs += check_notify_cb(); - nerrs += check_metadata_cork(TRUE); - nerrs += check_metadata_cork(FALSE); - nerrs += check_entry_deletions_during_scans(); - nerrs += check_stats(); + /* Test with paged aggregation enabled or not */ + /* Each test will call setup_cache() which set up the file space strategy according to "paged" */ + for(paged = FALSE; paged <= TRUE; paged++) { + nerrs += smoke_check_1(express_test, paged); + nerrs += smoke_check_2(express_test, paged); + nerrs += smoke_check_3(express_test, paged); + nerrs += smoke_check_4(express_test, paged); + nerrs += smoke_check_5(express_test, paged); + nerrs += smoke_check_6(express_test, paged); + nerrs += smoke_check_7(express_test, paged); + nerrs += smoke_check_8(express_test, paged); + nerrs += smoke_check_9(express_test, paged); + nerrs += smoke_check_10(express_test, paged); + nerrs += write_permitted_check(express_test, paged); + nerrs += check_insert_entry(paged); + nerrs += check_flush_cache(paged); + nerrs += check_get_entry_status(paged); + nerrs += check_expunge_entry(paged); + nerrs += check_multiple_read_protect(paged); + nerrs += check_move_entry(paged); + nerrs += check_pin_protected_entry(paged); + nerrs += check_resize_entry(paged); + nerrs += check_evictions_enabled(paged); + nerrs += check_flush_protected_err(paged); + nerrs += check_destroy_pinned_err(paged); + nerrs += check_destroy_protected_err(paged); + nerrs += check_duplicate_insert_err(paged); + nerrs += check_double_pin_err(paged); + nerrs += check_double_unpin_err(paged); + nerrs += check_pin_entry_errs(paged); + nerrs += check_double_protect_err(paged); + nerrs += check_double_unprotect_err(paged); + nerrs += check_mark_entry_dirty_errs(paged); + nerrs += check_expunge_entry_errs(paged); + nerrs += check_move_entry_errs(paged); + nerrs += check_resize_entry_errs(paged); + nerrs += check_unprotect_ro_dirty_err(paged); + nerrs += check_protect_ro_rw_err(paged); + nerrs += check_protect_retries(paged); + nerrs += check_check_evictions_enabled_err(paged); + nerrs += check_auto_cache_resize(FALSE, paged); + nerrs += check_auto_cache_resize(TRUE, paged); + nerrs += check_auto_cache_resize_disable(paged); + nerrs += check_auto_cache_resize_epoch_markers(paged); + nerrs += check_auto_cache_resize_input_errs(paged); + nerrs += check_auto_cache_resize_aux_fcns(paged); + nerrs += check_metadata_blizzard_absence(TRUE, paged); + nerrs += check_metadata_blizzard_absence(FALSE, paged); + nerrs += check_flush_deps(paged); + nerrs += check_flush_deps_err(paged); + nerrs += check_flush_deps_order(paged); + nerrs += check_notify_cb(paged); + nerrs += check_metadata_cork(TRUE, paged); + nerrs += check_metadata_cork(FALSE, paged); + nerrs += check_entry_deletions_during_scans(paged); + nerrs += check_stats(paged); + } /* end for */ /* can't fail, returns void */ free_entry_arrays(); diff --git a/test/cache_api.c b/test/cache_api.c index 710e38f..867f055 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -30,12 +30,12 @@ /* private function declarations: */ -static hbool_t check_fapl_mdc_api_calls(void); -static hbool_t check_file_mdc_api_calls(void); -static hbool_t mdc_api_call_smoke_check(int express_test); +static hbool_t check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id); +static hbool_t check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id); +static hbool_t mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id); static H5AC_cache_config_t * init_invalid_configs(void); static hbool_t check_fapl_mdc_api_errs(void); -static hbool_t check_file_mdc_api_errs(void); +static hbool_t check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id); @@ -64,7 +64,7 @@ static hbool_t check_file_mdc_api_errs(void); *------------------------------------------------------------------------- */ static hbool_t -check_fapl_mdc_api_calls(void) +check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) { char filename[512]; herr_t result; @@ -113,7 +113,10 @@ check_fapl_mdc_api_calls(void) H5C_auto_size_ctl_t default_auto_size_ctl; H5C_auto_size_ctl_t mod_auto_size_ctl; - TESTING("MDC/FAPL related API calls"); + if(paged) + TESTING("MDC/FAPL related API calls for paged aggregation strategy") + else + TESTING("MDC/FAPL related API calls") pass = TRUE; @@ -217,7 +220,7 @@ check_fapl_mdc_api_calls(void) /* create the file using the default FAPL */ if ( pass ) { - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); if ( file_id < 0 ) { @@ -365,7 +368,7 @@ check_fapl_mdc_api_calls(void) /* create the file using the modified FAPL */ if ( pass ) { - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); if ( file_id < 0 ) { @@ -517,7 +520,7 @@ check_fapl_mdc_api_calls(void) *------------------------------------------------------------------------- */ static hbool_t -check_file_mdc_api_calls(void) +check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) { char filename[512]; hid_t file_id = -1; @@ -669,7 +672,10 @@ check_file_mdc_api_calls(void) H5AC__DEFAULT_METADATA_WRITE_STRATEGY }; - TESTING("MDC/FILE related API calls"); + if(paged) + TESTING("MDC/FILE related API calls for paged aggregation strategy") + else + TESTING("MDC/FILE related API calls") pass = TRUE; @@ -695,7 +701,7 @@ check_file_mdc_api_calls(void) /* create the file using the default FAPL */ if ( pass ) { - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); if ( file_id < 0 ) { @@ -874,7 +880,7 @@ check_file_mdc_api_calls(void) #define NUM_RANDOM_ACCESSES 200000 static hbool_t -mdc_api_call_smoke_check(int express_test) +mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) { char filename[512]; hbool_t valid_chunk; @@ -1003,7 +1009,10 @@ mdc_api_call_smoke_check(int express_test) H5AC__DEFAULT_METADATA_WRITE_STRATEGY }; - TESTING("MDC API smoke check"); + if(paged) + TESTING("MDC API smoke check for paged aggregation strategy") + else + TESTING("MDC API smoke check") pass = TRUE; @@ -1038,7 +1047,7 @@ mdc_api_call_smoke_check(int express_test) /* create the file using the default FAPL */ if ( pass ) { - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); if ( file_id < 0 ) { @@ -1921,7 +1930,7 @@ check_fapl_mdc_api_errs(void) *------------------------------------------------------------------------- */ static hbool_t -check_file_mdc_api_errs(void) +check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) { char filename[512]; static char msg[128]; @@ -1937,7 +1946,10 @@ check_file_mdc_api_errs(void) H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; H5AC_cache_config_t scratch; - TESTING("MDC/FILE related API input errors"); + if(paged) + TESTING("MDC/FILE related API input errors for paged aggregation strategy") + else + TESTING("MDC/FILE related API input errors") pass = TRUE; @@ -1968,7 +1980,7 @@ check_file_mdc_api_errs(void) HDfprintf(stdout, "%s: calling H5Fcreate().\n", FUNC); } - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); if ( file_id < 0 ) { @@ -2267,6 +2279,9 @@ main(void) { unsigned nerrs = 0; int express_test; + hid_t fcpl_id = -1; + hid_t fcpl2_id = -1; + unsigned paged; H5open(); @@ -2281,42 +2296,64 @@ main(void) /* Initialize invalid configurations. */ invalid_configs = init_invalid_configs(); - if ( NULL == invalid_configs ) { - failure_mssg = "Unable to allocate memory for invalid configs."; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; - } + } /* end if */ - if ( !check_fapl_mdc_api_calls() ) { + if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) { + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); + return EXIT_FAILURE; + } /* end if */ - nerrs += 1; - } + /* Set file space strategy to default or paged aggregation strategy */ + if((fcpl2_id = H5Pcopy(fcpl_id)) < 0) { + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); + return EXIT_FAILURE; + } /* end if */ - if ( !check_file_mdc_api_calls() ) { + if(H5Pset_file_space_strategy(fcpl2_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) { + failure_mssg = "H5Pset_file_space_strategy() failed.\n"; + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); + return EXIT_FAILURE; + } /* end if */ - nerrs += 1; - } + /* Test with paged aggregation enabled or not */ + /* The "my_fcpl" passed to each test has the paged or non-paged strategy set up accordinly */ + for(paged = FALSE; paged <= TRUE; paged++) { + hid_t my_fcpl = fcpl_id; - if ( !mdc_api_call_smoke_check(express_test) ) { + if(paged) + my_fcpl = fcpl2_id; - nerrs += 1; - } + if(!check_fapl_mdc_api_calls(paged, my_fcpl)) + nerrs += 1; - if ( !check_fapl_mdc_api_errs() ) { + if(!check_file_mdc_api_calls(paged, my_fcpl)) + nerrs += 1; - nerrs += 1; - } + if(!mdc_api_call_smoke_check(express_test, paged, my_fcpl)) + nerrs += 1; - if ( !check_file_mdc_api_errs() ) { + if(!check_file_mdc_api_errs(paged, my_fcpl)) + nerrs += 1; + } /* end for paged */ + if(!check_fapl_mdc_api_errs()) nerrs += 1; - } if(invalid_configs) HDfree(invalid_configs); + if(H5Pclose(fcpl_id) < 0 ) { + failure_mssg = "H5Pclose() failed.\n"; + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); + return EXIT_FAILURE; + } /* end if */ + if(nerrs > 0) return EXIT_FAILURE; else diff --git a/test/cache_common.c b/test/cache_common.c index d1bbf10..52dbb52 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -39,6 +39,12 @@ hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between * close. */ +hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between + * cache setup and takedown. Note + * that if saved_fcpl_id == H5P_DEFAULT, + * we assume that there is no fcpl to + * close. + */ hid_t saved_fid = -1; /* store the file id here between cache setup * and takedown. */ @@ -1632,9 +1638,12 @@ free_icr(test_entry_t *entry, int32_t entry_type) HDassert(entry->cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert((entry->header.destroy_in_progress) || (entry->header.addr == entry->addr)); + HDassert(entry->header.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); HDassert(entry->header.size == entry->size); HDassert((entry->type == VARIABLE_ENTRY_TYPE) || (entry->size == entry_sizes[entry->type])); + HDassert(entry->header.tl_next == NULL); + HDassert(entry->header.tl_prev == NULL); if(entry->num_pins > 0) { int i; @@ -3165,7 +3174,8 @@ verify_unprotected(void) H5F_t * setup_cache(size_t max_cache_size, - size_t min_clean_size) + size_t min_clean_size, + unsigned paged) { char filename[512]; hbool_t show_progress = FALSE; @@ -3177,6 +3187,7 @@ setup_cache(size_t max_cache_size, H5F_t * ret_val = NULL; haddr_t actual_base_addr; hid_t fapl_id = H5P_DEFAULT; + hid_t fcpl_id = H5P_DEFAULT; if(show_progress) /* 1 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -3184,6 +3195,36 @@ setup_cache(size_t max_cache_size, saved_fid = -1; + if(pass) { + if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; + } + } + + if(pass && paged) { + /* Set up paged aggregation strategy */ + if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_strategy() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass && paged) { + /* Set up file space page size to BASE_ADDR */ + if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_page_size() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass) + saved_fcpl_id = fcpl_id; + /* setup the file name */ if(pass) { if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { @@ -3207,7 +3248,7 @@ setup_cache(size_t max_cache_size, pass = FALSE; failure_mssg = "H5P_set_fapl_core() failed.\n"; } - else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) { + else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { core_file_driver_failed = TRUE; if(verbose) @@ -3226,8 +3267,8 @@ setup_cache(size_t max_cache_size, * If this fails, we are cooked. */ if(pass && fid < 0) { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - saved_fid = fid; + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + saved_fid = fid; if(fid < 0) { pass = FALSE; @@ -3438,6 +3479,11 @@ takedown_cache(H5F_t * file_ptr, saved_fapl_id = H5P_DEFAULT; } + if ( saved_fcpl_id != H5P_DEFAULT ) { + H5Pclose(saved_fcpl_id); + saved_fcpl_id = H5P_DEFAULT; + } + if ( saved_fid != -1 ) { if ( H5F_addr_defined(saved_actual_base_addr) ) { diff --git a/test/cache_common.h b/test/cache_common.h index f003189..f17c16b 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -643,7 +643,7 @@ H5TEST_DLL void resize_entry(H5F_t * file_ptr, size_t new_size, hbool_t in_cache); -H5TEST_DLL H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size); +H5TEST_DLL H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); H5TEST_DLL void row_major_scan_forward(H5F_t * file_ptr, int32_t max_index, diff --git a/test/cache_image.c b/test/cache_image.c index 0e7928a..f49f7b3 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -59,6 +59,9 @@ static unsigned cache_image_smoke_check_6(void); static unsigned cache_image_api_error_check_1(void); static unsigned cache_image_api_error_check_2(void); static unsigned cache_image_api_error_check_3(void); +static unsigned cache_image_api_error_check_4(void); + +static unsigned get_free_sections_test(void); /****************************************************************************/ @@ -664,12 +667,10 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, } if ( ( pass ) && ( config_fsm ) ) { - - if ( H5Pset_file_space(fcpl_id, H5F_FILE_SPACE_ALL_PERSIST, 1) < 0 ) { - - pass = FALSE; - failure_mssg = "H5Pset_file_space() failed."; - } + if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_strategy() failed."; + } } if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); @@ -5091,11 +5092,14 @@ cache_image_smoke_check_5(void) * 13) Close the file. * * 14) Get the size of the file. Verify that it is less - * than 1 KB. Without deletions and persistant free + * than 20 KB. Without deletions and persistant free * space managers, size size is about 167 MB, so this * is sufficient to verify that the persistant free * space managers are more or less doing their job. * + * Note that in the absence of paged allocation, file + * size gets below 1 KB. + * * 15) Delete the file. * * Return: void @@ -5408,20 +5412,24 @@ cache_image_smoke_check_6(void) /* 14) Get the size of the file. Verify that it is less - * than 1 KB. Without deletions and persistant free + * than 20 KB. Without deletions and persistant free * space managers, size size is about 167 MB, so this * is sufficient to verify that the persistant free * space managers are more or less doing their job. + * + * Note that in the absence of paged allocation, file + * size gets below 1 KB, but since this test is run both + * with and without paged allocation, we must leave some + * extra space for the paged allocation case. */ - if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { - - pass = FALSE; - failure_mssg = "h5_get_file_size() failed.\n"; - - } else if ( file_size > 1024 ) { - - pass = FALSE; - failure_mssg = "unexpectedly large file size.\n"; + if(pass) { + if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { + pass = FALSE; + failure_mssg = "h5_get_file_size() failed.\n"; + } else if(file_size > 20 * 1024) { + pass = FALSE; + failure_mssg = "unexpectedly large file size.\n"; + } } if ( show_progress ) @@ -7069,6 +7077,494 @@ cache_image_api_error_check_4(void) return !pass; } /* cache_image_api_error_check_4() */ + + +/*------------------------------------------------------------------------- + * Function: get_free_sections_test() + * + * Purpose: It is possible that H5Fget_free_sections() to be + * called before any activity on the metadata cache. + * This is a potential problem, as satisfying the + * H5Fget_free_sections() call requires access to all + * free space managers. When persistant free space + * managers are enabled, this will require calling + * H5MF_tidy_self_referential_fsm_hack(). This is a + * non issue in the absence of a cache image. However, + * this is a problem if a cache image exists, as + * the call to H5MF_tidy_self_referential_fsm_hack() + * will free the file space allocated to the cache + * image. + * + * The objective of this test is to create a test file + * with both non-empty self referential presistant + * free space managers, and a cache image, and then + * verify that this situation is handled correctly if + * H5Fget_free_sections() is called before the metadata + * cache image is loaded. + * + * The test is set up as follows: + * + * 1) Create a HDF5 file with a cache image requested + * and persistant free space managers enabled. + * + * 2) Create some data sets, and then delete some of + * of those near the beginning of the file. + * + * 3) Close the file. + * + * 4) Open the file read only. + * + * 5) Verify that a cache image exists, and has not + * been loaded. + * + * 6) Verify that one or more self referential FSMs + * have been stored at the end of the file just + * before the cache image. + * + * 7) Call H5Fget_free_sections(). + * + * 8) Verify that the cache image has been loaded and + * that the self referential FSMs have been floated. + * + * 9) Verify that the remaining data sets contain the + * expected data. + * + * 10) Close the file. + * + * 11) Open the file R/W. + * + * 12) Verify that a cache image exists, and has not + * been loaded. + * + * 13) Verify that one or more self referential FSMs + * have been stored at the end of the file just + * before the cache image. + * + * 14) Call H5Fget_free_sections(). + * + * 15) Verify that the cache image has been loaded and + * that the self referential FSMs have been floated. + * + * 16) Verify that the remaining data sets contain the + * expected data. + * + * 17) Delete the remaining data sets. + * + * 18) Close the file. + * + * 19) Verify that file space has been reclaimed. + * + * 20) Discard the file. + * + * Return: void + * + * Programmer: John Mainzer + * 1/10/17 + * + *------------------------------------------------------------------------- + */ +static unsigned +get_free_sections_test(void) +{ + const char * fcn_name = "get_free_sections_test()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + h5_stat_size_t file_size; + int cp = 0; + + TESTING("Cache image / H5Fget_free_sections() interaction"); + + pass = TRUE; + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 1) Create a HDF5 file with a cache image requested + * and persistant free space managers enabled. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ TRUE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ TRUE, + /* config_fsm */ TRUE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Create some data sets, and then delete some of + * of those near the beginning of the file. + */ + + if ( pass ) { + + create_datasets(file_id, 1, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + verify_datasets(file_id, 1, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + delete_datasets(file_id, 1, 5); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 3) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed (1).\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 4) Open the file read only. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 5) Verify that a cache image exists, and has not been loaded. */ + + if ( pass ) { + + if ( ( ! file_ptr->shared->cache->load_image ) || + ( file_ptr->shared->cache->image_loaded ) ) { + + pass = FALSE; + failure_mssg = "unexpected cache image status.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 6) Verify that one or more self referential FSMs + * have been stored at the end of the file just + * before the cache image. + */ + + if ( pass ) { + + /* file_ptr->shared->first_alloc_dealloc is set to FALSE if the + * file is opened R/O. + */ + if ( ( file_ptr->shared->first_alloc_dealloc ) || + ( ! H5F_addr_defined(file_ptr->shared->eoa_pre_fsm_fsalloc) ) || + ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) || + ( H5F_addr_gt(file_ptr->shared->eoa_pre_fsm_fsalloc, + file_ptr->shared->cache->image_addr) ) ) { + + pass = FALSE; + failure_mssg = "unexpected cache image status (1).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 7) Call H5Fget_free_sections(). */ + + if ( pass ) { + + if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) + < 0 ){ + + pass = FALSE; + failure_mssg = "H5Fget_free_sections() failed (1).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 8) Verify that the cache image has been loaded and + * that the self referential FSMs have been floated. + */ + if ( pass ) { + + if ( ! file_ptr->shared->cache->image_loaded ) { + + pass = FALSE; + failure_mssg = "cache image not loaded (1).\n"; + + } else if ( file_ptr->shared->first_alloc_dealloc ) { + + pass = FALSE; + failure_mssg = "self referential FSMs not floated (1).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 9) Verify that the remaining data sets contain the expected data. */ + + if ( pass ) { + + verify_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 10) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed (2).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Open the file R/W. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 12) Verify that a cache image exists, and has not been loaded. */ + + if ( pass ) { + + if ( ( ! file_ptr->shared->cache->load_image ) || + ( file_ptr->shared->cache->image_loaded ) ) { + + pass = FALSE; + failure_mssg = "unexpected cache image status.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 13) Verify that one or more self referential FSMs + * have been stored at the end of the file just + * before the cache image. + */ + if ( pass ) { + + if ( ( ! file_ptr->shared->first_alloc_dealloc ) || + ( ! H5F_addr_defined(file_ptr->shared->eoa_pre_fsm_fsalloc) ) || + ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) || + ( H5F_addr_gt(file_ptr->shared->eoa_pre_fsm_fsalloc, + file_ptr->shared->cache->image_addr) ) ) { + + pass = FALSE; + failure_mssg = "unexpected cache image status (2).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 14) Call H5Fget_free_sections(). */ + + if ( pass ) { + + if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) + < 0 ){ + + pass = FALSE; + failure_mssg = "H5Fget_free_sections() failed (2).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 15) Verify that the cache image has been loaded and + * that the self referential FSMs have been floated. + */ + if ( pass ) { + + if ( ! file_ptr->shared->cache->image_loaded ) { + + pass = FALSE; + failure_mssg = "cache image not loaded (2).\n"; + + } else if ( file_ptr->shared->first_alloc_dealloc ) { + + pass = FALSE; + failure_mssg = "self referential FSMs not floated (2).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 16) Verify that the remaining data sets contain the expected data. */ + + if ( pass ) { + + verify_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 17) Delete the remaining data sets. */ + + if ( pass ) { + + delete_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 18) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed (3).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 19) Verify that file space has been reclaimed. */ + + if ( pass ) { + + if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { + + pass = FALSE; + failure_mssg = "h5_get_file_size() failed.\n"; + + } else if ( file_size > 20 * 1024 ) { + + pass = FALSE; + failure_mssg = "unexpectedly large file size.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 20) Discard the file. */ + + if ( pass ) { + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "HDremove() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + FUNC, failure_mssg); + + return !pass; + +} /* get_free_sections_test() */ + + /*------------------------------------------------------------------------- * Function: main * @@ -7117,6 +7613,8 @@ main(void) nerrs += cache_image_api_error_check_3(); nerrs += cache_image_api_error_check_4(); + nerrs += get_free_sections_test(); + return(nerrs > 0); } /* main() */ diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 8901468..957187b 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -1514,6 +1514,7 @@ check_attribute_rename_tags(hid_t fcpl, int type) haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ + hbool_t persistant_fsms = FALSE; /* Testing Macro */ TESTING("tag application during attribute renaming"); @@ -1522,6 +1523,10 @@ check_attribute_rename_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* check to see if the FCPL specified persistant free space managers */ + if(H5Pget_file_space_strategy(fcpl, NULL, &persistant_fsms, NULL) < 0) + TEST_ERROR; + /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; @@ -1612,9 +1617,18 @@ check_attribute_rename_tags(hid_t fcpl, int type) * 3 calls to verify_tag() for verifying free space: * one freespace header tag for H5FD_MEM_DRAW manager, * one freespace header tag for H5FD_MEM_SUPER manager + * one freespace section info tag for H5FD_MEM_SUPER manager */ if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; + + /* If the free space managers are persistant, the + * H5MF_tidy_self_referential_fsm_hack() must have been run. + * Since this function floats all self referential free space + * managers, the H5FD_MEM_SUPER FSM will not be in the metadata + * cache. + */ + if(!persistant_fsms && verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0) TEST_ERROR; + if(!persistant_fsms && verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__FREESPACE_TAG) < 0) TEST_ERROR; /* verify btree header and leaf node belonging to group */ if ( verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0 ) TEST_ERROR; @@ -1679,6 +1693,7 @@ check_attribute_delete_tags(hid_t fcpl, int type) haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ + hbool_t persistant_fsms = FALSE; /* Testing Macro */ TESTING("tag application during attribute delete"); @@ -1687,6 +1702,10 @@ check_attribute_delete_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* check to see if the FCPL specified persistant free space managers */ + if ( H5Pget_file_space_strategy(fcpl, NULL, &persistant_fsms, NULL) < 0 ) + TEST_ERROR; + /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; @@ -1752,12 +1771,26 @@ check_attribute_delete_tags(hid_t fcpl, int type) if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; /* - * 2 calls to verify_tag() for verifying free space: - * one freespace header tag for H5FD_MEM_DRAW manager, - * one freespace header tag for H5FD_MEM_SUPER manager - */ - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; + * 2 calls to verify_tag() for verifying free space: + * one freespace header tag for free-space header, + * one freespace header tag for free-space section info + */ + if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) + TEST_ERROR; + if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__FREESPACE_TAG) < 0 ) + TEST_ERROR; + +#if 0 + /* If the free space managers are persistant, the + * H5MF_tidy_self_referential_fsm_hack() must have been run. + * Since this function floats all self referential free space + * managers, the H5FD_MEM_SUPER FSM will not be in the metadata + * cache. + */ + if ( ( ! persistant_fsms ) && + ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) ) + TEST_ERROR; +#endif } /* end if */ @@ -3699,7 +3732,7 @@ main(void) fcpl_shmesg_all = H5Pcreate(H5P_FILE_CREATE); H5Pset_shared_mesg_nindexes(fcpl_shmesg_all, 1); H5Pset_shared_mesg_index(fcpl_shmesg_all, 0, H5O_SHMESG_ALL_FLAG, 20); - H5Pset_file_space(fcpl_shmesg_all, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + H5Pset_file_space_strategy(fcpl_shmesg_all, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)0); /* ========= */ /* Run Tests */ diff --git a/test/dsets.c b/test/dsets.c index 39b7c22..c090174 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -633,7 +633,7 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_userblock_offset(const char *env_h5_drvr, hid_t fapl) +test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { char filename[FILENAME_BUF_SIZE]; hid_t file = -1, fcpl = -1, dataset = -1, space = -1; @@ -651,6 +651,9 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error; + if(new_format) + if(H5Pset_file_space_page_size(fcpl, (hsize_t)USER_BLOCK) < 0) + goto error; if((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; @@ -12658,18 +12661,24 @@ main(void) { char filename[FILENAME_BUF_SIZE]; hid_t file, grp, fapl, fapl2; + hid_t fcpl = -1, fcpl2 = -1; unsigned new_format; + unsigned paged; int mdc_nelmts; size_t rdcc_nelmts; size_t rdcc_nbytes; double rdcc_w0; int nerrors = 0; const char *envval; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ /* Don't run this test using certain file drivers */ envval = HDgetenv("HDF5_DRIVER"); if(envval == NULL) - envval = "sec2"; + envval = "nomatch"; + + /* Current VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(envval, "split") && HDstrcmp(envval, "multi")); /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -12691,101 +12700,136 @@ main(void) /* Set the "use the latest version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + /* create a file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR + + /* Set file space strategy to paged aggregation and persisting free-space */ + if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + TEST_ERROR + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; + /* Test with paged aggregation enabled or not */ + for(paged = FALSE; paged <= TRUE; paged++) { - /* Set the FAPL for the type of format */ - if(new_format) { - puts("\nTesting with new file format:"); - my_fapl = fapl2; - } /* end if */ - else { - puts("Testing with old file format:"); - my_fapl = fapl; - } /* end else */ + /* Temporary: skip testing for multi/split drivers: + fail file create when persisting free-space or using paged aggregation strategy */ + if(!contig_addr_vfd && paged) + continue; - /* Create the file for this test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - goto error; + /* Test with old & new format groups */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl, my_fcpl; + + /* Set the FAPL for the type of format */ + if(new_format) { + my_fapl = fapl2; + if(paged) { + my_fcpl = fcpl2; + puts("\nTesting with new file format and paged aggregation"); + } else { + my_fcpl = fcpl; + puts("\nTesting with new file format and non-paged aggregation"); + } + } /* end if */ + else { + my_fapl = fapl; + if(paged) { + my_fcpl = fcpl2; + puts("Testing with old file format and paged aggregation:"); + } else { + my_fcpl = fcpl; + puts("Testing with old file format and non-paged aggregation:"); + } + } /* end else */ - /* Cause the library to emit initial messages */ - if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) - goto error; - if(H5Gclose(grp) < 0) - goto error; + /* Create the file for this test */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0) + goto error; + + /* Cause the library to emit initial messages */ + if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) + goto error; + if(H5Gclose(grp) < 0) + goto error; + + nerrors += (test_create(file) < 0 ? 1 : 0); + nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); + nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_tconv(file) < 0 ? 1 : 0); + nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); + nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); + nerrors += (test_missing_filter(file) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_filter_delete(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); + nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_create(file) < 0 ? 1 : 0); - nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); - nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); - nerrors += (test_tconv(file) < 0 ? 1 : 0); - nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); - nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); - nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); - nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); - nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += (test_deprec(file) < 0 ? 1 : 0); + nerrors += (test_deprec(file) < 0 ? 1 : 0); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); - nerrors += (test_idx_compatible() < 0 ? 1 : 0); - nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); - nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); - - if(H5Fclose(file) < 0) - goto error; - } /* end for */ - /* Close 2nd FAPL */ + nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); + nerrors += (test_idx_compatible() < 0 ? 1 : 0); + nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); + + nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + + if(H5Fclose(file) < 0) + goto error; + } /* end for new_format */ + } /* end for paged */ + + /* Close property lists */ if(H5Pclose(fapl2) < 0) TEST_ERROR + if(H5Pclose(fcpl) < 0) TEST_ERROR + if(H5Pclose(fcpl2) < 0) TEST_ERROR /* Tests that do not use files */ nerrors += (test_scatter() < 0 ? 1 : 0); diff --git a/test/fheap.c b/test/fheap.c index 82859d2..f08c0f8 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -26,6 +26,10 @@ #define H5HF_TESTING #include "H5HFpkg.h" /* Fractal heaps */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" + /* Other private headers that this test requires */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -126,6 +130,7 @@ typedef struct fheap_test_param_t { fheap_test_fill_t fill; /* How to "bulk" fill heap blocks */ size_t actual_id_len; /* The actual length of heap IDs for a test */ fheap_test_comp_t comp; /* Whether to compress the blocks or not */ + hid_t my_fcpl; /* File creation property list with file space strategy setting */ } fheap_test_param_t; /* Heap state information */ @@ -642,7 +647,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam, h5_fixname(FILENAME[0], fapl, filename, (size_t)FHEAP_FILENAME_LEN); /* Create the file to work on */ - if((*file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((*file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Check for deleting the entire heap */ @@ -1827,7 +1832,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED *tparam) +test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { hid_t file = -1; /* File ID */ char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ @@ -1844,7 +1849,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ @@ -1944,7 +1949,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED *tparam) +test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { hid_t file = -1; /* File ID */ char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ @@ -1956,12 +1961,13 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED h5_stat_size_t file_size; /* File size, after deleting heap */ size_t id_len; /* Size of fractal heap IDs */ fheap_heap_state_t state; /* State of fractal heap */ + hbool_t page = FALSE; /* Paged aggregation strategy or not */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ @@ -1980,6 +1986,9 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED if(NULL == (f = (H5F_t *)H5I_object(file))) STACK_ERROR + if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) + page = TRUE; + /* Ignore metadata tags in the file's cache */ if (H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR @@ -2058,8 +2067,9 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR + if(!page || (page && !tparam->reopen_heap)) + if(file_size != empty_size) + TEST_ERROR /* All tests passed */ PASSED() @@ -2090,7 +2100,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED *tparam) +test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { hid_t file = -1; /* File ID */ hid_t file2 = -1; /* File ID */ @@ -2105,12 +2115,13 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UN h5_stat_size_t file_size; /* File size, after deleting heap */ size_t id_len; /* Size of fractal heap IDs */ fheap_heap_state_t state; /* State of fractal heap */ + hbool_t page = FALSE; /* Paged aggregation strategy or not */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ @@ -2129,6 +2140,9 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UN if(NULL == (f = (H5F_t *)H5I_object(file))) STACK_ERROR + if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) + page = TRUE; + /* Ignore metadata tags in the file's cache */ if (H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR @@ -2226,8 +2240,9 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UN TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR + if(!page || (page && !tparam->reopen_heap)) + if(file_size != empty_size) + TEST_ERROR /* All tests passed */ PASSED() @@ -2262,7 +2277,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_UNUSED *tparam) +test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { hid_t file = -1; /* File ID */ char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ @@ -2280,7 +2295,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5_ATTR_U h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ @@ -2433,7 +2448,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_id_limits(hid_t fapl, H5HF_create_t *cparam) +test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { hid_t file = -1; /* File ID */ hid_t dxpl = H5AC_ind_read_dxpl_id; /* DXPL to use */ @@ -2451,7 +2466,7 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -2778,7 +2793,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_filtered_create(hid_t fapl, H5HF_create_t *cparam) +test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { hid_t file = -1; /* File ID */ hid_t dxpl = H5AC_ind_read_dxpl_id; /* DXPL to use */ @@ -2794,7 +2809,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -2901,7 +2916,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_size(hid_t fapl, H5HF_create_t *cparam) +test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { hid_t file = -1; /* File ID */ hid_t dxpl = H5AC_ind_read_dxpl_id; /* DXPL to use */ @@ -2917,7 +2932,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -3045,7 +3060,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) +test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { hid_t file1 = -1; /* File ID */ hid_t file2 = -2; /* File ID */ @@ -3060,7 +3075,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -3199,7 +3214,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -3309,7 +3324,7 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -3410,7 +3425,7 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -3507,7 +3522,7 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -3606,7 +3621,7 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -3712,7 +3727,7 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -3819,7 +3834,7 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -3930,7 +3945,7 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4026,7 +4041,7 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4129,7 +4144,7 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4230,7 +4245,7 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4341,7 +4356,7 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4438,7 +4453,7 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4534,7 +4549,7 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4636,7 +4651,7 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4746,7 +4761,7 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4849,7 +4864,7 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -4960,7 +4975,7 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5068,7 +5083,7 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5166,7 +5181,7 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5275,7 +5290,7 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5378,7 +5393,7 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5488,7 +5503,7 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5599,7 +5614,7 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5706,7 +5721,7 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5814,7 +5829,7 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -5929,7 +5944,7 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6049,7 +6064,7 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6161,7 +6176,7 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6276,7 +6291,7 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6410,7 +6425,7 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6563,7 +6578,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6727,7 +6742,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -6920,7 +6935,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -7089,7 +7104,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -7333,7 +7348,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ @@ -7632,7 +7647,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -16353,6 +16368,8 @@ main(void) H5HF_create_t small_cparam; /* Creation parameters for "small" heap */ H5HF_create_t large_cparam; /* Creation parameters for "large" heap */ hid_t fapl = -1; /* File access property list for data files */ + hid_t fcpl = -1; /* File creation property list for data files */ + hid_t fcpl2 = -1; /* File creation property list for data files */ fheap_test_type_t curr_test; /* Current test being worked on */ unsigned u; /* Local index variable */ unsigned nerrors = 0; /* Cumulative error count */ @@ -16375,6 +16392,16 @@ main(void) shared_wobj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); shared_robj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); + /* create a file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR + + /* Set file space strategy and persisting free-space */ + /* This will be modified later on to run the test with different file space strategy setting */ + if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1) < 0) + TEST_ERROR + /* Initialize the shared write buffer for objects */ for(u = 0; u < shared_obj_size_g; u++) shared_wobj_g[u] = (unsigned char)u; @@ -16385,6 +16412,9 @@ main(void) HDmemset(&tparam, 0, sizeof(fheap_test_param_t)); tparam.actual_id_len = HEAP_ID_LEN; + /* This will be modified later on to run the test with different file space strategy setting */ + tparam.my_fcpl = fcpl2; + /* Set appropriate testing parameters for each test */ switch(curr_test) { /* "Normal" testing parameters */ @@ -16409,10 +16439,11 @@ main(void) nerrors += test_reopen(fapl, &small_cparam, &tparam); nerrors += test_open_twice(fapl, &small_cparam, &tparam); nerrors += test_delete_open(fapl, &small_cparam, &tparam); - nerrors += test_id_limits(fapl, &small_cparam); - nerrors += test_filtered_create(fapl, &small_cparam); - nerrors += test_size(fapl, &small_cparam); - nerrors += test_reopen_hdr(fapl, &small_cparam); + + nerrors += test_id_limits(fapl, &small_cparam, tparam.my_fcpl); + nerrors += test_filtered_create(fapl, &small_cparam, tparam.my_fcpl); + nerrors += test_size(fapl, &small_cparam, tparam.my_fcpl); + nerrors += test_reopen_hdr(fapl, &small_cparam, tparam.my_fcpl); { fheap_test_fill_t fill; /* Size of objects to fill heap blocks with */ @@ -16732,6 +16763,9 @@ main(void) H5MM_xfree(shared_lens_g); H5MM_xfree(shared_offs_g); + if(H5Pclose(fcpl) < 0) TEST_ERROR + if(H5Pclose(fcpl2) < 0) TEST_ERROR + /* Clean up file used */ #ifndef QAK h5_cleanup(FILENAME, fapl); diff --git a/test/filespace_1_8.h5 b/test/filespace_1_8.h5 index 85138b0..3fa2822 100644 Binary files a/test/filespace_1_8.h5 and b/test/filespace_1_8.h5 differ diff --git a/test/freespace.c b/test/freespace.c index 181e6a1..2bf9111 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -86,7 +86,7 @@ typedef struct TEST_free_section_t { static herr_t TEST_sect_init_cls(H5FS_section_class_t *, void *); static herr_t TEST_sect_free(H5FS_section_info_t *_sect); static herr_t TEST_sect_can_merge(const H5FS_section_info_t *, const H5FS_section_info_t *, void H5_ATTR_UNUSED *); -static herr_t TEST_sect_merging(H5FS_section_info_t *, H5FS_section_info_t *, void H5_ATTR_UNUSED *); +static herr_t TEST_sect_merging(H5FS_section_info_t **, H5FS_section_info_t *, void H5_ATTR_UNUSED *); static herr_t TEST_sect_can_shrink(const H5FS_section_info_t *, void *); static herr_t TEST_sect_shrinking(H5FS_section_info_t **, void *); @@ -245,26 +245,26 @@ TEST_sect_can_merge(const H5FS_section_info_t *_sect1, * Merge the two sections (second section is merged into the first section) */ static herr_t -TEST_sect_merging(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2, +TEST_sect_merging(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { - TEST_free_section_t *sect1 = (TEST_free_section_t *)_sect1; + TEST_free_section_t **sect1 = (TEST_free_section_t **)_sect1; TEST_free_section_t *sect2 = (TEST_free_section_t *)_sect2; herr_t ret_value = SUCCEED; /* Return value */ /* Check arguments. */ HDassert(sect1); - HDassert((sect1->sect_info.type == TEST_FSPACE_SECT_TYPE) || - (sect1->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || - (sect1->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); + HDassert(((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE) || + ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || + ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); HDassert(sect2); HDassert((sect2->sect_info.type == TEST_FSPACE_SECT_TYPE) || (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); - HDassert(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)); + HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); /* Add second section's size to first section */ - sect1->sect_info.size += sect2->sect_info.size; + (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ if(TEST_sect_free((H5FS_section_info_t *)sect2) < 0) @@ -2540,7 +2540,7 @@ test_fs_sect_extend(hid_t fapl) TEST_ERROR /* Extend a block by requested-size */ - if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_SIZE80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE40)) < 0) + if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_SIZE80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) FAIL_STACK_ERROR if(FALSE == status) TEST_ERROR @@ -2616,7 +2616,7 @@ test_fs_sect_extend(hid_t fapl) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE50)) < 0) + if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE50, 0, NULL)) < 0) FAIL_STACK_ERROR if(TRUE == status) TEST_ERROR @@ -2689,7 +2689,7 @@ test_fs_sect_extend(hid_t fapl) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE30)) < 0) + if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE30, 0, NULL)) < 0) TEST_ERROR if(FALSE == status) TEST_ERROR @@ -2763,7 +2763,7 @@ test_fs_sect_extend(hid_t fapl) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE15, (hsize_t)TEST_SECT_SIZE40)) < 0) + if((status = H5FS_sect_try_extend(f, dxpl_id, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE15, (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) TEST_ERROR if(TRUE == status) TEST_ERROR diff --git a/test/fsm_aggr_nopersist.h5 b/test/fsm_aggr_nopersist.h5 new file mode 100644 index 0000000..159e7f7 Binary files /dev/null and b/test/fsm_aggr_nopersist.h5 differ diff --git a/test/fsm_aggr_persist.h5 b/test/fsm_aggr_persist.h5 new file mode 100644 index 0000000..1a837dd Binary files /dev/null and b/test/fsm_aggr_persist.h5 differ diff --git a/test/gen_filespace.c b/test/gen_filespace.c index e0c42e8..52715ae 100644 --- a/test/gen_filespace.c +++ b/test/gen_filespace.c @@ -14,69 +14,105 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" +#include #define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ -#define TEST_THRESHOLD2 2 /* Free space section threshold */ const char *FILENAMES[] = { - "filespace_persist.h5", /* H5F_FILE_SPACE_ALL_PERSIST */ - "filespace_default.h5", /* H5F_FILE_SPACE_ALL */ - "filespace_aggr_vfd.h5", /* H5F_FILE_SPACE_AGGR_VFD */ - "filespace_vfd.h5", /* H5F_FILE_SPACE_VFD */ - "filespace_threshold.h5" /* H5F_FILE_SPACE_ALL, non-default threshold */ + "fsm_aggr_nopersist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + not persisting free-space */ + "fsm_aggr_persist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + persisting free-space */ + "paged_nopersist.h5", /* H5F_FSPACE_STRATEGY_PAGE + not persisting free-space */ + "paged_persist.h5", /* H5F_FSPACE_STRATEGY_PAGE + persisting free-space */ + "aggr.h5", /* H5F_FSPACE_STRATEGY_AGGR */ + "none.h5" /* H5F_FSPACE_STRATEGY_NONE */ }; #define DATASET "dset" #define NUM_ELMTS 100 +#define FALSE 0 +#define TRUE 1 +#define INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1)) /* - * Compile and run this program in file-space branch to generate - * HDF5 files with different kinds of file space strategies - * Move the HDF5 files to the 1.6 and 1.8 branch for compatibility - * testing:test_filespace_compatible() will use the files + * Compile and run this program in the trunk to generate + * HDF5 files with combinations of 4 file space strategies + * and persist/not persist free-space. + * The library creates the file space info message with "mark if unknown" + * in these files. + * + * Move these files to 1.8 branch for compatibility testing: + * test_filespace_compatible() in test/tfile.c will use these files. + * + * Copy these files from the 1.8 branch back to the trunk for + * compatibility testing via test_filespace_round_compatible() in test/tfile.c. + * */ -static void gen_file(void) -{ - hid_t fid; - hid_t fcpl; - hid_t dataset, space; - hsize_t dim[1]; - int data[NUM_ELMTS]; - size_t j; /* Local index variable */ - int i; /* Local index variable */ - H5F_file_space_type_t fs_type; /* File space handling strategy */ - - for(j = 0, fs_type = H5F_FILE_SPACE_ALL_PERSIST; j < NELMTS(FILENAMES); j++, fs_type = (H5F_file_space_type_t)(fs_type + 1)) { - /* Get a copy of the default file creation property */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - - if(fs_type == H5F_FILE_SPACE_NTYPES) /* last file */ - /* Set default strategy but non-default threshold */ - H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL, (hsize_t)TEST_THRESHOLD2); - else - /* Set specified file space strategy and free space section threshold */ - H5Pset_file_space(fcpl, fs_type, (hsize_t)0); - - /* Create the file with the file space info */ - fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); - - dim[0] = NUM_ELMTS; - space = H5Screate_simple(1, dim, NULL); - dataset = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < NUM_ELMTS; i++) - data[i] = i; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - H5Dclose(dataset); - H5Sclose(space); - H5Fclose(fid); - } -} - int main(void) { - gen_file(); + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int i, j; /* Local index variables */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + unsigned fs_persist; /* Persisting free-space or not */ + + j = 0; + for(fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; INC_ENUM(H5F_fspace_strategy_t, fs_strategy)) { + for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + + if(fs_persist && fs_strategy >= H5F_FSPACE_STRATEGY_AGGR) + continue; + + /* Get a copy of the default file creation property */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + if(H5Pset_file_space_strategy(fcpl, fs_strategy, fs_persist, (hsize_t)1) < 0) + goto error; + + /* Create the file with the file space info */ + if((fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + goto error; + + /* Create the dataset */ + dim[0] = NUM_ELMTS; + if((sid = H5Screate_simple(1, dim, NULL)) < 0) + goto error; + if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + for(i = 0; i < NUM_ELMTS; i++) + data[i] = i; + + /* Write the dataset */ + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto error; + + /* Closing */ + if(H5Dclose(did) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + ++j; + } + } + assert(j == NELMTS(FILENAMES)); return 0; + +error: + H5E_BEGIN_TRY { + H5Sclose(sid); + H5Sclose(did); + H5Pclose(fcpl); + H5Fclose(fid); + } H5E_END_TRY; + return -1; } diff --git a/test/gen_idx.c b/test/gen_idx.c deleted file mode 100644 index 8c24198..0000000 --- a/test/gen_idx.c +++ /dev/null @@ -1,126 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: This program is run to generate an HDF5 data file with datasets - * that use Fixed Array indexing method. - * - * To test compatibility, compile and run this program - * which will generate a file called "fixed_idx.h5". - * Move it to the test directory in the HDF5 v1.6/1.8 source tree. - * The test: test_idx_compatible() in dsets.c will read it. - */ -#include -#include "hdf5.h" - -const char *FILENAME[1] = { - "fixed_idx.h5" /* file with datasets that use Fixed Array indexing method */ -}; - -#define DSET "dset" -#define DSET_FILTER "dset_filter" - -/* - * Function: gen_idx_file - * - * Purpose: Create a file with datasets that use Fixed Array indexing: - * one dataset: fixed dimension, chunked layout, w/o filters - * one dataset: fixed dimension, chunked layout, w/ filters - * - */ -static void gen_idx_file(void) -{ - hid_t fapl; /* file access property id */ - hid_t fid; /* file id */ - hid_t sid; /* space id */ - hid_t dcpl; /* dataset creation property id */ - hid_t did, did2; /* dataset id */ - hsize_t dims[1] = {10}; /* dataset dimension */ - hsize_t c_dims[1] = {2}; /* chunk dimension */ - herr_t status; /* return status */ - int i; /* local index variable */ - int buf[10]; /* data buffer */ - - - /* Get a copy of the file aaccess property */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - assert(fapl >= 0); - - /* Set the "use the latest format" bounds for creating objects in the file */ - status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - assert(status >= 0); - - /* Create dataset */ - fid = H5Fcreate(FILENAME[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - assert(fid >= 0); - - /* Create data */ - for(i = 0; i < 10; i++) - buf[i] = i; - - /* Set chunk */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - assert(dcpl >= 0); - status = H5Pset_chunk(dcpl, 1, c_dims); - assert(status >= 0); - - sid = H5Screate_simple(1, dims, NULL); - assert(sid >= 0); - - /* Create a 1D dataset */ - did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(did >= 0); - - /* Write to the dataset */ - status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - assert(status >= 0); - -#if defined (H5_HAVE_FILTER_DEFLATE) - /* set deflate data */ - status = H5Pset_deflate(dcpl, 9); - assert(status >= 0); - - /* Create and write the dataset */ - did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(did2 >= 0); - - status = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - assert(status >= 0); - - /* Close the dataset */ - status = H5Dclose(did2); - assert(status >= 0); -#endif - - /* closing */ - status = H5Dclose(did); - assert(status >= 0); - status = H5Sclose(sid); - assert(status >= 0); - status = H5Pclose(dcpl); - assert(status >= 0); - status = H5Pclose(fapl); - assert(status >= 0); - status = H5Fclose(fid); - assert(status >= 0); -} /* gen_idx_file() */ - -int main(void) -{ - gen_idx_file(); - - return 0; -} - diff --git a/test/gen_plist.c b/test/gen_plist.c index 8cb6c00..5c54ce8 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -403,6 +403,12 @@ main(void) if((ret = H5Pset_sizes(fcpl1, 8, 4) < 0)) assert(ret > 0); + if((ret = H5Pset_file_space_strategy(fcpl1, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1)) < 0) + assert(ret > 0); + + if((ret = H5Pset_file_space_page_size(fcpl1, (hsize_t)4096)) < 0) + assert(ret > 0); + if((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/fcpl_")) < 0) assert(ret > 0); diff --git a/test/h5fc_ext1_f.h5 b/test/h5fc_ext1_f.h5 new file mode 100644 index 0000000..b5c5867 Binary files /dev/null and b/test/h5fc_ext1_f.h5 differ diff --git a/test/h5fc_ext1_i.h5 b/test/h5fc_ext1_i.h5 new file mode 100644 index 0000000..960a8d5 Binary files /dev/null and b/test/h5fc_ext1_i.h5 differ diff --git a/test/h5fc_ext2_if.h5 b/test/h5fc_ext2_if.h5 new file mode 100644 index 0000000..88e42e7 Binary files /dev/null and b/test/h5fc_ext2_if.h5 differ diff --git a/test/h5fc_ext2_sf.h5 b/test/h5fc_ext2_sf.h5 new file mode 100644 index 0000000..c59a3ca Binary files /dev/null and b/test/h5fc_ext2_sf.h5 differ diff --git a/test/h5fc_ext3_isf.h5 b/test/h5fc_ext3_isf.h5 new file mode 100644 index 0000000..d00fc55 Binary files /dev/null and b/test/h5fc_ext3_isf.h5 differ diff --git a/test/h5fc_ext_none.h5 b/test/h5fc_ext_none.h5 new file mode 100644 index 0000000..b1b1553 Binary files /dev/null and b/test/h5fc_ext_none.h5 differ diff --git a/test/links.c b/test/links.c index 3364c7e..e3bbdb2 100644 --- a/test/links.c +++ b/test/links.c @@ -11102,6 +11102,8 @@ corder_delete(hid_t fapl) for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* Creating file with latest format will enable paged aggregation with persistent fs */ if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ diff --git a/test/mf.c b/test/mf.c index f56c7ab..160fb92 100644 --- a/test/mf.c +++ b/test/mf.c @@ -20,6 +20,7 @@ * test_mf_aggr_*() tests for file memory that interact with the aggregators * test_mf_align_*() tests for file memory with alignment setting * test_filespace_*() tests for file space management + * test_page_*() tests for file space paging */ #include "h5test.h" @@ -38,41 +39,63 @@ #include "H5Iprivate.h" #include "H5VMprivate.h" -#define FILENAME_LEN 1024 - -#define TEST_BLOCK_SIZE1 1 -#define TEST_BLOCK_SIZE2 2 -#define TEST_BLOCK_SIZE3 3 -#define TEST_BLOCK_SIZE4 4 -#define TEST_BLOCK_SIZE5 5 -#define TEST_BLOCK_SIZE6 6 -#define TEST_BLOCK_SIZE7 7 -#define TEST_BLOCK_SIZE8 8 -#define TEST_BLOCK_SIZE20 20 -#define TEST_BLOCK_SIZE30 30 -#define TEST_BLOCK_SIZE40 40 -#define TEST_BLOCK_SIZE50 50 -#define TEST_BLOCK_SIZE80 80 -#define TEST_BLOCK_SIZE200 200 -#define TEST_BLOCK_SIZE600 600 -#define TEST_BLOCK_SIZE700 700 -#define TEST_BLOCK_SIZE1034 1034 -#define TEST_BLOCK_SIZE1970 1970 -#define TEST_BLOCK_SIZE2058 2058 -#define TEST_BLOCK_SIZE8000 8000 -#define TEST_BLOCK_SIZE2048 2048 - -#define TEST_BLOCK_ADDR70 70 -#define TEST_BLOCK_ADDR100 100 - -#define TEST_ALIGN1024 1024 -#define TEST_ALIGN4096 4096 - -#define TEST_THRESHOLD10 10 -#define TEST_THRESHOLD3 3 - -#define CORE_INCREMENT 1024 -#define FAMILY_SIZE 1024 +#define FILENAME_LEN 1024 + +#define TBLOCK_SIZE1 1 +#define TBLOCK_SIZE2 2 +#define TBLOCK_SIZE3 3 +#define TBLOCK_SIZE4 4 +#define TBLOCK_SIZE5 5 +#define TBLOCK_SIZE6 6 +#define TBLOCK_SIZE7 7 +#define TBLOCK_SIZE8 8 +#define TBLOCK_SIZE10 10 +#define TBLOCK_SIZE11 11 +#define TBLOCK_SIZE20 20 +#define TBLOCK_SIZE30 30 +#define TBLOCK_SIZE36 36 +#define TBLOCK_SIZE40 40 +#define TBLOCK_SIZE50 50 +#define TBLOCK_SIZE80 80 +#define TBLOCK_SIZE90 90 +#define TBLOCK_SIZE98 98 +#define TBLOCK_SIZE100 100 +#define TBLOCK_SIZE150 150 +#define TBLOCK_SIZE200 200 +#define TBLOCK_SIZE600 600 +#define TBLOCK_SIZE700 700 +#define TBLOCK_SIZE1034 1034 +#define TBLOCK_SIZE1970 1970 +#define TBLOCK_SIZE2048 2048 +#define TBLOCK_SIZE2058 2058 +#define TBLOCK_SIZE2192 2192 +#define TBLOCK_SIZE3080 3080 +#define TBLOCK_SIZE3088 3088 +#define TBLOCK_SIZE3198 3198 +#define TBLOCK_SIZE3286 3286 +#define TBLOCK_SIZE3248 3248 +#define TBLOCK_SIZE3900 3900 +#define TBLOCK_SIZE4020 4020 +#define TBLOCK_SIZE4086 4086 +#define TBLOCK_SIZE4096 4096 +#define TBLOCK_SIZE4106 4106 +#define TBLOCK_SIZE5000 5000 +#define TBLOCK_SIZE6000 6000 +#define TBLOCK_SIZE8000 8000 +#define TBLOCK_SIZE8100 8100 +#define TBLOCK_SIZE8192 8192 +#define TBLOCK_SIZE8190 8190 +#define TBLOCK_SIZE12000 12000 + +#define TBLOCK_ADDR70 70 +#define TBLOCK_ADDR100 100 + +#define TEST_ALIGN16 16 +#define TEST_ALIGN1024 1024 +#define TEST_ALIGN4096 4096 + +#define TEST_THRESHOLD10 10 +#define TEST_THRESHOLD3 3 const char *FILENAME[] = { "mf", @@ -80,24 +103,17 @@ const char *FILENAME[] = { }; typedef enum { - TEST_NORMAL, /* size of aggregator is >= alignment size */ - TEST_AGGR_SMALL, /* size of aggregator is smaller than alignment size */ - TEST_NTESTS /* The number of test types, must be last */ + TEST_NORMAL, /* size of aggregator is >= alignment size */ + TEST_AGGR_SMALL, /* size of aggregator is smaller than alignment size */ + TEST_NTESTS /* The number of test types, must be last */ } test_type_t; -typedef struct frspace_state_t { - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ -} frspace_state_t; +static int check_stats(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *state); - -static int check_stats(const H5F_t *, const H5FS_t *, frspace_state_t *); static unsigned test_mf_eoa(const char *env_h5_drvr, hid_t fapl); static unsigned test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl); static unsigned test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl); -static unsigned test_mf_tmp(const char *env_h5_drvr, hid_t fapl); +static unsigned test_dichotomy(hid_t fapl); static unsigned test_mf_fs_start(hid_t fapl); static unsigned test_mf_fs_alloc_free(hid_t fapl); static unsigned test_mf_fs_extend(hid_t fapl); @@ -119,21 +135,27 @@ static unsigned test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t static unsigned test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl); static unsigned test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl); static unsigned test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl); -static unsigned test_mf_fs_persist(hid_t fapl_new, hid_t fcpl); -static unsigned test_mf_fs_gone(hid_t fapl_new, hid_t fcpl); -static unsigned test_mf_fs_split(hid_t fapl_new, hid_t fcpl); -static unsigned test_mf_fs_multi(hid_t fapl, hid_t fcpl); -static unsigned test_mf_fs_drivers(hid_t fapl); +static unsigned test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format); +static unsigned test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format); +static unsigned test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format); +static unsigned test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format); +static unsigned test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format); +static unsigned test_mf_fs_persist_split(void); +static unsigned test_mf_fs_persist_multi(void); +static unsigned test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_small(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_large(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_large_try_extend(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_try_shrink(const char *env_h5_drvr, hid_t fapl); +static unsigned test_page_alignment(const char *env_h5_drvr, hid_t fapl); /* * Verify statistics for the free-space manager * - * Modifications: - * Vailin Choi; July 2012 - * To ensure "f" and "frsp" are valid pointers */ static int -check_stats(const H5F_t *f, const H5FS_t *frsp, frspace_state_t *state) +check_stats(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *state) { H5FS_stat_t frspace_stats; /* Statistics about the heap */ @@ -146,22 +168,22 @@ check_stats(const H5F_t *f, const H5FS_t *frsp, frspace_state_t *state) if(frspace_stats.tot_space != state->tot_space) { HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n", - frspace_stats.tot_space, state->tot_space); + frspace_stats.tot_space, state->tot_space); TEST_ERROR } /* end if */ if(frspace_stats.tot_sect_count != state->tot_sect_count) { HDfprintf(stdout, "frspace_stats.tot_sect_count = %Hu, state->tot_sect_count = %Hu\n", - frspace_stats.tot_sect_count, state->tot_sect_count); + frspace_stats.tot_sect_count, state->tot_sect_count); TEST_ERROR } /* end if */ if(frspace_stats.serial_sect_count != state->serial_sect_count) { HDfprintf(stdout, "frspace_stats.serial_sect_count = %Hu, state->serial_sect_count = %Hu\n", - frspace_stats.serial_sect_count, state->serial_sect_count); + frspace_stats.serial_sect_count, state->serial_sect_count); TEST_ERROR } /* end if */ if(frspace_stats.ghost_sect_count != state->ghost_sect_count) { HDfprintf(stdout, "frspace_stats.ghost_sect_count = %Hu, state->ghost_sect_count = %Hu\n", - frspace_stats.ghost_sect_count, state->ghost_sect_count); + frspace_stats.ghost_sect_count, state->ghost_sect_count); TEST_ERROR } /* end if */ @@ -173,13 +195,15 @@ error: } /* check_stats() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from file allocation * * Set up: - * Turn off using meta/small data aggregator - * There is nothing in free-space manager + * Turn off using meta/small data aggregator + * There is nothing in free-space manager * * Allocate two blocks which should be from file allocation + *------------------------------------------------------------------------- */ static unsigned test_mf_eoa(const char *env_h5_drvr, hid_t fapl) @@ -234,7 +258,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* nothing should be changed in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); @@ -244,7 +268,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) if (addr1 < (haddr_t)file_size) TEST_ERROR - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* nothing should be changed in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); @@ -262,7 +286,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)) + if (new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50)) TEST_ERROR /* Re-open the file */ @@ -273,8 +297,8 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -308,6 +332,7 @@ error: } /* test_mf_eoa() */ /* + *------------------------------------------------------------------------- * To verify that an allocated block from file allocation is shrunk. * * Set up: @@ -323,6 +348,7 @@ error: * Test 4: Allocate a block of 30 from file allocation * H5MF_try_shrink() the block by 20 from the end: succeed * + *------------------------------------------------------------------------- */ static unsigned test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) @@ -377,7 +403,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); if (addr < (haddr_t)file_size) TEST_ERROR @@ -395,7 +421,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) + if (new_file_size != (file_size+TBLOCK_SIZE30)) TEST_ERROR /* Re-open the file */ @@ -409,7 +435,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should succeed */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30) <= 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30) <= 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -453,13 +479,13 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); if (addr < (haddr_t)file_size) TEST_ERROR /* should not succeed in shrinking */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30 - 10) > 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30 - 10) > 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -475,7 +501,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR PASSED() @@ -503,7 +529,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should not succeed in shrinking */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30 + 10) > 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30 + 10) > 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -519,7 +545,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR PASSED() @@ -546,7 +572,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should succeed in shrinking */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr+10, (hsize_t)(TEST_BLOCK_SIZE30 - 10)) <= 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr+10, (hsize_t)(TBLOCK_SIZE30 - 10)) <= 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -588,6 +614,7 @@ error: } /* test_mf_eoa_shrink() */ /* + *------------------------------------------------------------------------- * To verify that an allocated block from file allocation is extended. * * Set up: @@ -599,6 +626,7 @@ error: * * Test 2: Allocate a block of 30 * H5MF_try_extend() the block of size 20 by 50: fail + *------------------------------------------------------------------------- */ static unsigned test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) @@ -656,7 +684,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); if (addr < (haddr_t)file_size) TEST_ERROR @@ -673,7 +701,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR /* Re-open the file */ @@ -685,7 +713,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* should succeed */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)TEST_BLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr, (hsize_t)TBLOCK_SIZE30, (hsize_t)TBLOCK_SIZE50); if(was_extended <= 0) TEST_ERROR @@ -703,7 +731,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)) + if(new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR PASSED() @@ -734,7 +762,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); if(addr < (haddr_t)file_size) TEST_ERROR @@ -744,7 +772,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if(new_ma_addr != ma_addr) TEST_ERROR - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)(TEST_BLOCK_SIZE50)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr, (hsize_t)(TBLOCK_SIZE30-10), (hsize_t)(TBLOCK_SIZE50)); /* should not succeed */ if(was_extended > 0) @@ -763,7 +791,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size + TEST_BLOCK_SIZE30) + if(new_file_size != file_size + TBLOCK_SIZE30) TEST_ERROR if(H5Pclose(fapl_new) < 0) @@ -787,6 +815,7 @@ error: } /* test_mf_eoa_extend() */ /* + *------------------------------------------------------------------------- * To verify that temporary blocks are allocated correctly * * Set up: @@ -806,13 +835,19 @@ error: * space fails * - Check that allocating another 1/2 of the file as normal address * space fails + *------------------------------------------------------------------------- */ static unsigned -test_mf_tmp(const char *env_h5_drvr, hid_t fapl) +test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ + hid_t file = -1; /* File ID */ + hid_t fapl2 = -1; /* File access property list */ + hid_t fcpl = -1; /* File creation property list */ - TESTING("'temporary' file space allocation"); + if(new_format) + TESTING("'temporary' file space allocation with new library format") + else + TESTING("'temporary' file space allocation with old library format") /* Can't run this test with multi-file VFDs */ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { @@ -829,8 +864,22 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) /* Set the filename to use for this test */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + if(new_format) { + /* Copy the file access property list */ + if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + + /* Set the "use the latest version of the format" bounds for creating objects in the file */ + if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + } /* end if */ + /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, new_format?fapl2:fapl)) < 0) FAIL_STACK_ERROR /* Close file */ @@ -855,13 +904,13 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Allocate some temporary address space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TEST_BLOCK_SIZE30))) + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TBLOCK_SIZE30))) FAIL_STACK_ERROR /* Check if temporary file address is valid */ if(!H5F_IS_TMP_ADDR(f, tmp_addr)) TEST_ERROR - if(tmp_addr < (haddr_t)(maxaddr - TEST_BLOCK_SIZE30)) + if(tmp_addr < (haddr_t)(maxaddr - TBLOCK_SIZE30)) TEST_ERROR /* Reading & writing with a temporary address value should fail */ @@ -878,7 +927,7 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) /* Freeing a temporary address value should fail */ H5E_BEGIN_TRY { - status = H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, tmp_addr, (hsize_t)TEST_BLOCK_SIZE30); + status = H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, tmp_addr, (hsize_t)TBLOCK_SIZE30); } H5E_END_TRY; if(status >= 0) TEST_ERROR @@ -963,10 +1012,12 @@ error: } /* test_mf_tmp() */ /* + *------------------------------------------------------------------------- * To verify that the free-space manager is created or opened * * Set up: * Turn off using meta/small data aggregator + *------------------------------------------------------------------------- */ static unsigned test_mf_fs_start(hid_t fapl) @@ -976,11 +1027,10 @@ test_mf_fs_start(hid_t fapl) char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; - frspace_state_t state; + H5FS_stat_t state; - TESTING("H5MF_alloc_create()/H5MF__alloc_open() of free-space manager"); + TESTING("H5MF_create_fstype()/H5MF_open_fstype() of free-space manager"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -1011,20 +1061,18 @@ test_mf_fs_start(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Start up free-space manager */ - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR - - HDmemset(&state, 0, sizeof(frspace_state_t)); + HDmemset(&state, 0, sizeof(H5FS_stat_t)); - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR if(H5Fclose(file) < 0) @@ -1055,6 +1103,7 @@ error: /* + *------------------------------------------------------------------------- * To verify that a block is allocated/freed from/to the free-space manager * * Set up: @@ -1078,10 +1127,7 @@ error: * The block is allocated from file allocation * Deallocate the block which will be returned to free-space manager * (the space is shrunk and freed since it is at end of file) - * - * Modifications: - * Vailin Choi; July 2012 - * Initialize the new field "allow_eoa_shrink_only" for user data. + *------------------------------------------------------------------------- */ static unsigned test_mf_fs_alloc_free(hid_t fapl) @@ -1091,12 +1137,10 @@ test_mf_fs_alloc_free(hid_t fapl) char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; H5MF_free_section_t *sect_node = NULL; - haddr_t addr; - frspace_state_t state; - H5MF_sect_ud_t udata; - H5FS_section_info_t *node; + haddr_t addr; + haddr_t tmp; + H5FS_stat_t state; TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 1"); @@ -1129,69 +1173,59 @@ test_mf_fs_alloc_free(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space */ - if (addr != TEST_BLOCK_ADDR70) + if(addr != TBLOCK_ADDR70) TEST_ERROR - state.tot_space -= TEST_BLOCK_SIZE30; + state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); - state.tot_space += TEST_BLOCK_SIZE30; + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR - /* Free the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(tmp != TBLOCK_ADDR70) + TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1216,67 +1250,57 @@ test_mf_fs_alloc_free(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; - - /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + /* Add section A to free-space manager */ + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 20 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE20)); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE20)); /* Verify that the allocated block is section A in free-space manager */ - if (addr != TEST_BLOCK_ADDR70) + if(addr != TBLOCK_ADDR70) TEST_ERROR /* should still have 1 section of size 10 left in free-space manager */ - state.tot_space -= (TEST_BLOCK_SIZE20); + state.tot_space -= (TBLOCK_SIZE20); - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space manager */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE20)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE20)); /* Still 1 section in free-space because of merging */ - state.tot_space += TEST_BLOCK_SIZE20; - if(check_stats(f, f->shared->fs_man[type], &state)) + state.tot_space += TBLOCK_SIZE20; + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - /* Remove section A from free-space manager */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0) - FAIL_STACK_ERROR + /* Remove section A from free-space */ + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR - /* Free the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(tmp != TBLOCK_ADDR70) + TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1301,36 +1325,28 @@ test_mf_fs_alloc_free(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* @@ -1338,38 +1354,37 @@ test_mf_fs_alloc_free(hid_t fapl) * Since free-space manager cannot fulfull the request, * the block is obtained from file allocation */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE40)); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE40)); /* Verify that the allocated block is not section A in free-space */ - if (addr == TEST_BLOCK_ADDR70) - TEST_ERROR + if(addr == TBLOCK_ADDR70) + TEST_ERROR /* free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0) - FAIL_STACK_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR - /* Free the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + /* Verify that the block is section A in free-space */ + if(tmp != TBLOCK_ADDR70) + TEST_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, f->shared->fs_man[type], &state)) + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block of size 40 to free-space */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE40)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE40)); /* * Free-space info is the same. * The block is returned to free-space. * It is shrunk and freed because it is at end of file. */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR if(H5Fclose(file) < 0) @@ -1400,6 +1415,7 @@ error: /* + *------------------------------------------------------------------------- * To verify that a block allocated from the free-space manager can be extended * * Set up: @@ -1435,10 +1451,7 @@ error: * Try to extend the allocated block by 50 from the free-space_manager: * Fail: section A does not adjoin section B (70+20 != address of section B) even though * the requested-size (50) equal to size of section B (50) - * - * Modifications: - * Vailin Choi; July 2012 - * Initialize the new field "allow_eoa_shrink_only" for user data. + *------------------------------------------------------------------------- */ static unsigned test_mf_fs_extend(hid_t fapl) @@ -1448,13 +1461,11 @@ test_mf_fs_extend(hid_t fapl) char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; H5MF_free_section_t *sect_node1 = NULL, *sect_node2=NULL; - haddr_t addr; - frspace_state_t state; /* State of free space*/ - H5MF_sect_ud_t udata; - H5FS_section_info_t *node; - htri_t was_extended; + haddr_t addr; + haddr_t tmp; + H5FS_stat_t state; /* State of free space*/ + htri_t was_extended; TESTING("H5MF_try_extend() of free-space manager:test 1"); @@ -1487,101 +1498,91 @@ test_mf_fs_extend(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node1 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if (addr != TEST_BLOCK_ADDR70) - TEST_ERROR + if(addr != TBLOCK_ADDR70) + TEST_ERROR - state.tot_space -= TEST_BLOCK_SIZE30; + state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ - sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50); + sect_node2 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + FAIL_STACK_ERROR - state.tot_space += TEST_BLOCK_SIZE50; + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)TEST_BLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)TBLOCK_SIZE50); /* should succeed */ if(was_extended <= 0) TEST_ERROR /* Section B is removed from free-space manager */ - state.tot_space -= TEST_BLOCK_SIZE50; + state.tot_space -= TBLOCK_SIZE50; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the extended block to free-space manager */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); /* Verify that the extended block is back into free-space */ - state.tot_space += TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50; + state.tot_space += (TBLOCK_SIZE30+TBLOCK_SIZE50); state.tot_sect_count = 1; state.serial_sect_count = 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the extended block */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0) - TEST_ERROR - - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR + if(tmp != TBLOCK_ADDR70) + TEST_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1605,95 +1606,84 @@ test_mf_fs_extend(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node1 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); - /* Add section A to free-space */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + /* Add section A to free-space manager */ + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if (addr != TEST_BLOCK_ADDR70) - TEST_ERROR + if(addr != TBLOCK_ADDR70) + TEST_ERROR - state.tot_space -= TEST_BLOCK_SIZE30; + state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ - sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50); + sect_node2 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + FAIL_STACK_ERROR - state.tot_space += TEST_BLOCK_SIZE50; + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)(TEST_BLOCK_SIZE50+10)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)(TBLOCK_SIZE50+10)); /* Should not be able to extend the allocated block */ if(was_extended) TEST_ERROR /* free-space info should remain the same */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the allocated block A to free-space */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); /* the returned section A is merged with section B in free-space */ /* rest of the info remains the same */ - state.tot_space += TEST_BLOCK_SIZE30; + state.tot_space += TBLOCK_SIZE30; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the merged sections A & B from free-space */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(tmp != addr) TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1718,95 +1708,84 @@ test_mf_fs_extend(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node1 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); - /* Add section A to free-space */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + /* Add section A to free-space manager */ + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE30; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if (addr != TEST_BLOCK_ADDR70) - TEST_ERROR + if(addr != TBLOCK_ADDR70) + TEST_ERROR - state.tot_space -= TEST_BLOCK_SIZE30; + state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ - sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50); + sect_node2 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + FAIL_STACK_ERROR - state.tot_space += TEST_BLOCK_SIZE50; + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)(TEST_BLOCK_SIZE40)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)(TBLOCK_SIZE40)); /* Should succeed in extending the allocated block */ if(was_extended <=0) TEST_ERROR /* Should have 1 section of size=10 left in free-space manager */ - state.tot_space -= (TEST_BLOCK_SIZE40); - if(check_stats(f, f->shared->fs_man[type], &state)) + state.tot_space -= (TBLOCK_SIZE40); + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the extended block */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE40)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE40)); /* rest info is same, the extended section returned is merged with the section in free-space */ - state.tot_space += (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE40); + state.tot_space += (TBLOCK_SIZE30+TBLOCK_SIZE40); - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the merged sections A & B from free-space */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0) - TEST_ERROR - - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR + + if(tmp != addr) TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1831,104 +1810,88 @@ test_mf_fs_extend(hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR /* Create section A */ - sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)(TEST_BLOCK_SIZE30-10)); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node1 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30-10)); /* Add section A of size=20 to free-space */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += (TEST_BLOCK_SIZE30-10); + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += (TBLOCK_SIZE30-10); state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of size=20 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE30-10)); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30-10)); /* Verify that the allocated block is section A in free-space manager */ - if (addr != TEST_BLOCK_ADDR70) - TEST_ERROR + if(addr != TBLOCK_ADDR70) + TEST_ERROR - state.tot_space -= (TEST_BLOCK_SIZE30-10); + state.tot_space -= (TBLOCK_SIZE30-10); state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ - sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50); + sect_node2 = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + FAIL_STACK_ERROR - state.tot_space += TEST_BLOCK_SIZE50; + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)TEST_BLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30-10), (hsize_t)TBLOCK_SIZE50); /* Should not succeed in extending the allocated block */ if(was_extended) TEST_ERROR /* Free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the allocated block */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE30-10)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE30-10)); - state.tot_space += (TEST_BLOCK_SIZE30-10); + state.tot_space += (TBLOCK_SIZE30-10); state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space manger */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)(TEST_BLOCK_SIZE30-10), (H5FS_section_info_t **)&node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30-10), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(tmp != addr) TEST_ERROR /* Remove section B from free-space manager */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE50, (H5FS_section_info_t **)&node) < 0) - TEST_ERROR - - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -1957,6 +1920,7 @@ error: } /* test_mf_fs_extend() */ /* + *------------------------------------------------------------------------- * To verify that an aggregator is absorbed into a section. * * Test 1: To aborb the aggregator onto the beginning of the section @@ -1979,25 +1943,20 @@ error: * which will absorb meta_aggr to the section: * section size + remaining size of aggregator is > aggr->alloc_size, * section is allowed to absorb an aggregator (allow_sect_absorb is true) - * - * Modifications: - * Vailin Choi; July 2012 - * Initialize the new field "allow_eoa_shrink_only" for user data. + *------------------------------------------------------------------------- */ static unsigned test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype; - haddr_t addr, saddr; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr, saddr; + haddr_t tmp; + haddr_t ma_addr=HADDR_UNDEF; + hsize_t ma_size=0; H5MF_free_section_t *sect_node=NULL; - H5MF_sect_ud_t udata; - H5FS_section_info_t *node; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("A free-space section absorbs an aggregator: test 1"); @@ -2023,53 +1982,39 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; - - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) - TEST_ERROR + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Allocate a section from meta_aggr */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - /* Add a section to free-space that adjoins end of the aggregator */ - sect_node = H5MF_sect_simple_new((haddr_t)(ma_addr+ma_size), (hsize_t)TEST_BLOCK_SIZE2048); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + /* Create a section */ + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)(ma_addr+ma_size), (hsize_t)TBLOCK_SIZE2048); - /* When adding, meta_aggr is absorbed onto the beginning of the section */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + /* Add a section to free-space that adjoins end of the aggregator */ + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR /* Verify that the section did absorb the aggregator */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE2048, (H5FS_section_info_t **)&node) < 0) + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(ma_addr+ma_size), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if (node->addr != ma_addr) TEST_ERROR - if (node->size != (ma_size + TEST_BLOCK_SIZE2048)) TEST_ERROR - - /* Remove the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if(tmp != ma_addr) TEST_ERROR /* Restore info for aggregator */ f->shared->meta_aggr.addr = ma_addr; f->shared->meta_aggr.size = ma_size; /* Remove section from meta_aggr */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2093,48 +2038,34 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; - - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) - TEST_ERROR + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Allocate a section from meta_aggr */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* Allocate a section from sdata_aggr */ - stype = H5FD_MEM_DRAW; - saddr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Add a section to free-space that adjoins the beginning of meta_aggr */ - sect_node = H5MF_sect_simple_new((haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE30); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)addr, (hsize_t)TBLOCK_SIZE30); /* When adding, meta_aggr is absorbed onto the end of the section */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR /* Verify that the section did absorb the aggregator */ - if(H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)(ma_size+TEST_BLOCK_SIZE30), (H5FS_section_info_t **)&node) < 0) + if(H5MF_find_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(ma_size+TBLOCK_SIZE30), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if ((node->addr + TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR - if (node->size != (ma_size + TEST_BLOCK_SIZE30)) TEST_ERROR - - /* free the free-space section node */ - if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0) + if((tmp + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* restore info to meta_aggr */ @@ -2142,9 +2073,9 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) f->shared->meta_aggr.size = ma_size; /* Remove section from meta_aggr */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); /* Remove section from sdata_aggr */ - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2166,6 +2097,7 @@ error: } /* test_mf_fs_absorb() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr: (nothing in the aggregator) @@ -2180,6 +2112,7 @@ error: * Result: * The second block of 50 is allocated from meta_aggr * There is space of 1968 left in meta_aggr + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) @@ -2187,6 +2120,7 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) hid_t file = -1; /* File ID */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ + hid_t fcpl; /* File creation property list */ h5_stat_size_t file_size, new_file_size; /* file size */ H5FD_mem_t type; haddr_t addr1, addr2; @@ -2202,13 +2136,21 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + + /* Set to H5F_FSPACE_STRATEGY_AGGR strategy */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + TEST_ERROR + /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + TEST_ERROR /* Get the size of a file */ if((file_size = h5_get_file_size(filename, fapl)) < 0) @@ -2216,54 +2158,58 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) /* Re-open the file */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + TEST_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR + TEST_ERROR /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + if((addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30)) == HADDR_UNDEF) + TEST_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + if((addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50)) == HADDR_UNDEF) + TEST_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2+TEST_BLOCK_SIZE50) != ma_addr) + if((addr2+TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + TEST_ERROR /* Get the size of the file */ if((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)) + if(new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50)) TEST_ERROR /* Re-open the file */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + TEST_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR + TEST_ERROR - /* Free the two blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); + /* Free the two blocks: order matters because of H5F_FSPACE_STRATEGY_AGGR strategy */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50) < 0) + TEST_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30) < 0) + TEST_ERROR if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + TEST_ERROR /* Get the size of the file */ if((new_file_size = h5_get_file_size(filename, fapl)) < 0) @@ -2273,6 +2219,9 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) if (new_file_size != file_size) TEST_ERROR + if(H5Pclose(fcpl) < 0) + TEST_ERROR + PASSED() } /* end if */ else { @@ -2285,11 +2234,13 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) error: H5E_BEGIN_TRY { H5Fclose(file); + H5Pclose(fcpl); } H5E_END_TRY; return(1); } /* test_mf_aggr_alloc1() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr: (nothing in the aggregator) @@ -2311,6 +2262,7 @@ error: * A block of request-size is extended via file allocation and is merged with meta_aggr * The block of 2058 is allocated out of meta_aggr * There is space of 1968 left in meta_aggr + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) @@ -2354,29 +2306,29 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2+TEST_BLOCK_SIZE50) != ma_addr) + if((addr2+TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2058); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2058); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr3+TEST_BLOCK_SIZE2058) != ma_addr) + if((addr3+TBLOCK_SIZE2058) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR if(H5Fclose(file) < 0) @@ -2388,7 +2340,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) /* Verify the file is the correct size */ /* Unused space is freed from the end of the file */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50+TEST_BLOCK_SIZE2058)) + if(new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50+TBLOCK_SIZE2058)) TEST_ERROR /* Re-open the file */ @@ -2399,7 +2351,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50+TEST_BLOCK_SIZE2058); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30+TBLOCK_SIZE50+TBLOCK_SIZE2058); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2429,6 +2381,7 @@ error: } /* test_mf_aggr_alloc2() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr : (nothing in the aggregator) @@ -2463,6 +2416,7 @@ error: * Result: * The fourth block of 50 is allocated from what is left in meta_aggr * There is space of 1968 left in meta_aggr + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) @@ -2509,55 +2463,55 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if ((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2+TEST_BLOCK_SIZE50) != ma_addr) + if((addr2+TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) + if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR - if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR + if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate third block, which is from file allocation not from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE2058)); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE2058)); H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); /* info for meta_aggr shouldn't be changed */ - if (addr3 != (sdata_addr+sdata_size)) TEST_ERROR - if ((addr3+TEST_BLOCK_SIZE2058) == new_ma_addr) TEST_ERROR - if ((new_ma_addr != ma_addr) || (new_ma_size != ma_size)) TEST_ERROR + if(addr3 != (sdata_addr+sdata_size)) TEST_ERROR + if((addr3+TBLOCK_SIZE2058) == new_ma_addr) TEST_ERROR + if((new_ma_addr != ma_addr) || (new_ma_size != ma_size)) TEST_ERROR /* Allocate fourth block, which should be from meta_aggr */ - addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr4+TEST_BLOCK_SIZE50) != ma_addr) + if((addr4+TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50 + TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50 + TBLOCK_SIZE50))) TEST_ERROR /* Free all the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE2058); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE2058); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2567,7 +2521,7 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR PASSED() @@ -2588,6 +2542,7 @@ error: /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr: (nothing in the aggregator) @@ -2626,6 +2581,7 @@ error: * The new block's address is returned * The block does not adjoin meta_aggr * meta_aggr's info is unchanged + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) @@ -2670,59 +2626,59 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) + if(ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) + if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate second block from sdata_aggr */ - saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)); + saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE2048 - TBLOCK_SIZE30)); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (saddr2+(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30) != sdata_addr) + if(saddr2+(TBLOCK_SIZE2048 - TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate third block from sdata_aggr */ - saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr3+TEST_BLOCK_SIZE50) != sdata_addr) + if((saddr3+TBLOCK_SIZE50) != sdata_addr) TEST_ERROR - if(sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE50)) + if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE50)) TEST_ERROR /* Allocate second block of 2058, which is from file allocation, not from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2058); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2058); - if (addr2 != sdata_addr) + if(addr2 != sdata_addr) TEST_ERROR /* sdata_aggr is reset 0 */ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((sdata_addr != 0) && (sdata_size != 0)) + if((sdata_addr != 0) && (sdata_size != 0)) TEST_ERROR /* info is unchanged in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if ((new_ma_addr != ma_addr) && (new_ma_size != ma_size)) + if((new_ma_addr != ma_addr) && (new_ma_size != ma_size)) TEST_ERROR /* Free all the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE2058); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr2, (hsize_t)TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE2058); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr2, (hsize_t)TBLOCK_SIZE2048 - TBLOCK_SIZE30); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2732,7 +2688,7 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR PASSED() @@ -2752,6 +2708,7 @@ error: } /* test_mf_aggr_alloc4() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr: (nothing in the aggregator) @@ -2772,6 +2729,7 @@ error: * The block of 1970 is allocated from there * There is space of 2046 left in meta_aggr * + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) @@ -2816,34 +2774,34 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (addr2+TEST_BLOCK_SIZE50 != ma_addr) + if(addr2+TBLOCK_SIZE50 != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30+TBLOCK_SIZE50))) TEST_ERROR /* Allocate third block from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1970); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1970); H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (addr3 != ma_addr) TEST_ERROR - if ((addr3+TEST_BLOCK_SIZE1970) != new_ma_addr) TEST_ERROR - if (new_ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE1970 - ma_size))) + if(addr3 != ma_addr) TEST_ERROR + if((addr3+TBLOCK_SIZE1970) != new_ma_addr) TEST_ERROR + if(new_ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE1970 - ma_size))) TEST_ERROR /* Free all the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE1970); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE1970); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2853,7 +2811,7 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR PASSED() @@ -2873,6 +2831,7 @@ error: } /* test_mf_aggr_alloc5() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * * Allocate first block (30) from meta_aggr: (nothing in the aggregator) @@ -2903,6 +2862,7 @@ error: * sdata_aggr is untouched * meta_aggr's unused space of [880, 1968] is freed to free-space * meta_aggr is updated to point to the new block + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) @@ -2915,7 +2875,7 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) haddr_t addr1, addr2, addr3, saddr1; haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, new_ma_size=0, sdata_size=0; - frspace_state_t state; + H5FS_stat_t state; hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 6"); @@ -2949,44 +2909,44 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) type = H5FD_MEM_SUPER; /* Allocate first block from meta_aggr */ - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (addr2+TEST_BLOCK_SIZE50 != ma_addr) + if(addr2+TBLOCK_SIZE50 != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) TEST_ERROR - if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR + if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR + if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate third block from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1970); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1970); H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if ((addr3+TEST_BLOCK_SIZE1970) != new_ma_addr) TEST_ERROR - if (addr3 != (sdata_addr+sdata_size)) TEST_ERROR + if((addr3+TBLOCK_SIZE1970) != new_ma_addr) TEST_ERROR + if(addr3 != (sdata_addr+sdata_size)) TEST_ERROR - if ((ma_addr+TEST_BLOCK_SIZE1970) == new_ma_addr) TEST_ERROR - if (new_ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE1970)) + if((ma_addr+TBLOCK_SIZE1970) == new_ma_addr) TEST_ERROR + if(new_ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) TEST_ERROR /* Verify that meta_aggr's unused space of 1968 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)); + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += (TBLOCK_SIZE2048 - (TBLOCK_SIZE30+TBLOCK_SIZE50)); state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -2994,10 +2954,10 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Free all the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE1970); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE1970); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3007,7 +2967,7 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR PASSED() @@ -3027,13 +2987,14 @@ error: } /* test_mf_aggr_alloc6() */ /* + *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator * - * Allocate first block (30) from meta_aggr: (nothing in meta_aggr) - * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size - * Result: - * A block of meta_aggr->alloc_size is obtained via file allocation - * The first block of 30 is allocated from there + * Allocate first block (30) from meta_aggr: (nothing in meta_aggr) + * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size + * Result: + * A block of meta_aggr->alloc_size is obtained via file allocation + * The first block of 30 is allocated from there * * Allocate second block (50) from meta_aggr: * request-size is <= what is left in meta_aggr @@ -3068,6 +3029,7 @@ error: * The block does not adjoin meta_aggr * meta_aggr's unused space of [880, 1968] is freed to free-space * meta_aggr is updated to point to the new block + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) @@ -3080,7 +3042,7 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) haddr_t addr1, addr2, addr3, saddr1, saddr2, saddr3; haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, sdata_size=0; - frspace_state_t state; + H5FS_stat_t state; hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 7"); @@ -3113,51 +3075,51 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) /* Allocate the first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if ((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate the second block from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (addr2+TEST_BLOCK_SIZE50 != ma_addr) + if (addr2+TBLOCK_SIZE50 != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate the first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) + if ((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate the second block from sdata_aggr */ - saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30); + saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2048 - TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr2+(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) != sdata_addr) + if ((saddr2+(TBLOCK_SIZE2048 - TBLOCK_SIZE30)) != sdata_addr) TEST_ERROR if (sdata_size != 0) TEST_ERROR /* Allocate the third block from sdata_aggr */ - saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr3+TEST_BLOCK_SIZE50) != sdata_addr) + if ((saddr3+TBLOCK_SIZE50) != sdata_addr) TEST_ERROR - if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE50)) + if (sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE50)) TEST_ERROR /* Allocate the third block from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1970); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1970); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); if (addr3 != sdata_addr) TEST_ERROR - if ((addr3 + TEST_BLOCK_SIZE1970) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE1970)) TEST_ERROR + if ((addr3 + TBLOCK_SIZE1970) != ma_addr) TEST_ERROR + if (ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) TEST_ERROR /* sdata_aggr info is reset to 0 */ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); @@ -3165,8 +3127,8 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) if (sdata_size != 0) TEST_ERROR /* Verify that meta_aggr's unused space of 1968 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)); + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50)); state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -3174,12 +3136,12 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Free all the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE1970); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr2, (hsize_t)(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE1970); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr2, (hsize_t)(TBLOCK_SIZE2048 - TBLOCK_SIZE30)); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3209,6 +3171,7 @@ error: } /* test_mf_aggr_alloc7() */ /* + *------------------------------------------------------------------------- * To verify that a block can be extended from the aggregator * * Test 1: Allocate block A from meta_aggr which is at end of file @@ -3229,6 +3192,7 @@ error: * Allocate block B from sdata_aggr so that meta_aggr is not at end of file * Try to extend a block which adjoins meta_aggr but meta_aggr cannot fulfill the extended-request * H5MF_try_extend() fails + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) @@ -3274,9 +3238,9 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) /* Allocate the first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr+TEST_BLOCK_SIZE30) != ma_addr) + if((addr+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3286,7 +3250,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) new_addr = addr - 10; /* Try to extend the block by an amount < (% * aggr->alloc_size) */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); /* should succeed */ if(!was_extended) @@ -3294,15 +3258,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != (addr+TEST_BLOCK_SIZE50)) + if(new_ma_addr != (addr+TBLOCK_SIZE50)) TEST_ERROR - if (new_ma_size != (f->shared->meta_aggr.alloc_size - TEST_BLOCK_SIZE50)) TEST_ERROR + if(new_ma_size != (f->shared->meta_aggr.alloc_size - TBLOCK_SIZE50)) TEST_ERROR /* Free the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE50); /* Try to extend the block by an amount > (% * aggr->alloc_size) but amount < aggr->alloc_size */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE700)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE700)); /* should succeed */ if(!was_extended) @@ -3310,15 +3274,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != (addr + TEST_BLOCK_SIZE700)) + if(new_ma_addr != (addr + TBLOCK_SIZE700)) TEST_ERROR - if (new_ma_size != (f->shared->meta_aggr.alloc_size * 2 - TEST_BLOCK_SIZE700)) TEST_ERROR + if(new_ma_size != (f->shared->meta_aggr.alloc_size * 2 - TBLOCK_SIZE700)) TEST_ERROR /* Free the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE700); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE700); /* Try to extend the block by an amount > (% * aggr->alloc_size) but amount > aggr->alloc_size */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE2058)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE2058)); /* should succeed */ if(!was_extended) @@ -3326,12 +3290,12 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != (addr + TEST_BLOCK_SIZE2058)) + if (new_ma_addr != (addr + TBLOCK_SIZE2058)) TEST_ERROR if (new_ma_size != f->shared->meta_aggr.size) TEST_ERROR /* Free the allocated blocks */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE2058); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE2058); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3365,16 +3329,16 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) /* Allocate the first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr+TEST_BLOCK_SIZE30) != ma_addr) + if((addr+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate the first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr+TEST_BLOCK_SIZE50) != sdata_addr) + if((saddr+TBLOCK_SIZE50) != sdata_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3384,24 +3348,24 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) new_addr = addr - 10; /* should be able to fulfill request from the aggreqator itself */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); if(!was_extended) TEST_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != (addr+TEST_BLOCK_SIZE50)) + if(new_ma_addr != (addr+TBLOCK_SIZE50)) TEST_ERROR - if (new_ma_size != (f->shared->meta_aggr.alloc_size-TEST_BLOCK_SIZE50)) + if(new_ma_size != (f->shared->meta_aggr.alloc_size-TBLOCK_SIZE50)) TEST_ERROR /* Restore info for meta_aggr */ f->shared->meta_aggr.addr = ma_addr; f->shared->meta_aggr.size = ma_size; - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3411,7 +3375,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (file_size != empty_size) + if(file_size != empty_size) TEST_ERROR PASSED() @@ -3435,16 +3399,16 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr+TEST_BLOCK_SIZE30) != ma_addr) + if ((addr+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate first block from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr+TEST_BLOCK_SIZE50) != sdata_addr) + if((saddr+TBLOCK_SIZE50) != sdata_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3454,7 +3418,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) new_addr = addr - 10; /* unable to fulfill request from the aggreqator itself */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50)); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); if(was_extended) TEST_ERROR @@ -3468,8 +3432,8 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) f->shared->meta_aggr.addr = ma_addr; f->shared->meta_aggr.size = ma_size; - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3479,7 +3443,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (file_size != empty_size) + if(file_size != empty_size) TEST_ERROR PASSED() @@ -3499,6 +3463,7 @@ error: } /* test_mf_aggr_extend() */ /* + *------------------------------------------------------------------------- * To verify that a block is absorbed into an aggregator * * MF_try_shrink() only allows blocks to be absorbed into an aggregator @@ -3517,10 +3482,7 @@ error: * H5MF_alloc() block C from meta_aggr * H5MF_try_shrink() block B should fail since it does not adjoin the * beginning nor the end of meta_aggr - * - * Modifications: - * Vailin Choi; July 2012 - * Changes due to the switch to H5FD_FLMAP_DICHOTOMY + *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) @@ -3567,20 +3529,20 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) /* Allocate block A from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - ma_addr = new_ma_addr - TEST_BLOCK_SIZE30; + ma_addr = new_ma_addr - TBLOCK_SIZE30; - if((addr1 + TEST_BLOCK_SIZE30) != new_ma_addr) + if((addr1 + TBLOCK_SIZE30) != new_ma_addr) TEST_ERROR /* should succeed */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30) <= 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30) <= 0) TEST_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR + if(new_ma_addr != ma_addr) TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3590,7 +3552,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (file_size != empty_size) + if(file_size != empty_size) TEST_ERROR PASSED() @@ -3614,32 +3576,32 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) /* Allocate block A from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR - if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR + if(ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate block B from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->sdata_aggr), NULL, &sdata_size); /* should succeed */ - if(H5MF_try_shrink(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0) + if(H5MF_try_shrink(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE50) <= 0) TEST_ERROR H5MF_aggr_query(f, &(f->shared->sdata_aggr), &new_sdata_addr, &new_sdata_size); - if (new_sdata_addr != saddr1) TEST_ERROR - if (new_sdata_size != sdata_size + TEST_BLOCK_SIZE50) TEST_ERROR + if(new_sdata_addr != saddr1) TEST_ERROR + if(new_sdata_size != sdata_size + TBLOCK_SIZE50) TEST_ERROR /* meta_aggr info should be updated because the block is absorbed into the meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); if (new_ma_addr != ma_addr) TEST_ERROR if (new_ma_size != (ma_size)) TEST_ERROR - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3649,7 +3611,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (file_size != empty_size) + if(file_size != empty_size) TEST_ERROR PASSED() @@ -3673,35 +3635,35 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) /* Allocate block A from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate block B from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2+TEST_BLOCK_SIZE50) != ma_addr) + if((addr2+TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* Allocate block C from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr3+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50) != ma_addr) + if((addr3+TBLOCK_SIZE30+TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* should not succeed */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50) > 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50) > 0) TEST_ERROR /* aggregator info should be the same as before */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR + if(new_ma_addr != ma_addr) TEST_ERROR - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3711,7 +3673,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (file_size != empty_size) + if(file_size != empty_size) TEST_ERROR PASSED() @@ -3731,6 +3693,7 @@ error: } /* test_mf_aggr_absorb() */ /* + *------------------------------------------------------------------------- * To verify that a block allocated from file allocation is aligned, can be shrunk and extended * * Alignment = 1024 or 4096 @@ -3759,6 +3722,7 @@ error: * Allocate a block which should be from file allocation * The return address should be aligned * H5MF_try_extend() the block with aligned address should succeed + *------------------------------------------------------------------------- */ static unsigned test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -3773,7 +3737,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr=HADDR_UNDEF; hsize_t ma_size=0; htri_t was_extended; - frspace_state_t state; + H5FS_stat_t state; hsize_t alignment=0, mis_align=0, tmp=0, accum=0; hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ @@ -3819,23 +3783,23 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; - accum = mis_align + TEST_BLOCK_SIZE30; + accum = mis_align + TBLOCK_SIZE30; /* Allocate a block of 30 from file allocation */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* there should be nothing in the aggregator */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (ma_addr || ma_size) TEST_ERROR + if(ma_addr || ma_size) TEST_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); + HDmemset(&state, 0, sizeof(H5FS_stat_t)); if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; @@ -3848,18 +3812,18 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) mis_align = 0; if ((tmp = ((hsize_t)file_size + accum) % alignment)) mis_align = alignment - tmp; - accum += (mis_align + TEST_BLOCK_SIZE50); + accum += (mis_align + TBLOCK_SIZE50); - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ if (addr2 % alignment) TEST_ERROR /* there should be nothing in the aggregator */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (ma_addr || ma_size) TEST_ERROR + if(ma_addr || ma_size) TEST_ERROR - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -3867,8 +3831,8 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TEST_ERROR } - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3902,7 +3866,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* allocate a block of 50 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* address should be aligned */ if (addr1 % alignment) TEST_ERROR @@ -3923,7 +3887,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* shrink the block */ - if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0) + if(H5MF_try_shrink(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE50) <= 0) TEST_ERROR if(H5Fclose(file) < 0) @@ -3932,7 +3896,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if((new_file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR - if (new_file_size != (file_size-TEST_BLOCK_SIZE50)) TEST_ERROR + if (new_file_size != (file_size-TBLOCK_SIZE50)) TEST_ERROR PASSED() } /* end if */ @@ -3957,10 +3921,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* allocate a block of 50 */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* address should be aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* Close file */ if(H5Fclose(file) < 0) @@ -3978,9 +3942,9 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* try to extend the block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr1, (hsize_t)TEST_BLOCK_SIZE50, (hsize_t)TEST_BLOCK_SIZE30); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE50, (hsize_t)TBLOCK_SIZE30); - if (was_extended <=0) TEST_ERROR + if(was_extended <=0) TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -3988,7 +3952,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if((new_file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR - if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) TEST_ERROR + if (new_file_size != (file_size+TBLOCK_SIZE30)) TEST_ERROR PASSED() } /* end if */ @@ -4007,6 +3971,7 @@ error: } /* test_mf_align_eoa() */ /* + *------------------------------------------------------------------------- * To verify that a block allocated from the free-space manager is aligned * * Alignment = 1024 or 4096 @@ -4035,10 +4000,7 @@ error: * Allocate a block of size=40 * The free-space manager is unable to fulfill the request * The block is allocated from file allocation and should be aligned - * - * Modifications: - * Vailin Choi; July 2012 - * Initialize the new field "allow_eoa_shrink_only" for user data. + *------------------------------------------------------------------------- */ static unsigned test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -4047,12 +4009,10 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) char filename[FILENAME_LEN]; /* Filename to use */ h5_stat_size_t file_size; H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; H5MF_free_section_t *sect_node = NULL; haddr_t addr; - frspace_state_t state; - H5MF_sect_ud_t udata; - htri_t was_extended; + H5FS_stat_t state; + htri_t was_extended; hsize_t alignment=0, tmp=0, mis_align=0; hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ @@ -4081,58 +4041,51 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; - - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) - TEST_ERROR - - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - sect_node = H5MF_sect_simple_new((haddr_t)alignment, (hsize_t)TEST_BLOCK_SIZE50); + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + TEST_ERROR - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + /* Create section A */ + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)alignment, (hsize_t)TBLOCK_SIZE50); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE50; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 50 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is section A in free-space */ - if (addr != (haddr_t)alignment) TEST_ERROR - if (addr % alignment) TEST_ERROR + if(addr != (haddr_t)alignment) TEST_ERROR + if(addr % alignment) TEST_ERROR - state.tot_space -= TEST_BLOCK_SIZE50; + state.tot_space -= TBLOCK_SIZE50; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)TBLOCK_SIZE50); - state.tot_space += TEST_BLOCK_SIZE50; + state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR if(H5Fclose(file) < 0) @@ -4151,70 +4104,63 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) - TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR - - sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE8000); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + /* Create section A */ + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE8000); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE8000; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE8000; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 600 */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE600); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE600); /* Verify that the allocated block is aligned */ if (addr % alignment) TEST_ERROR /* should have 1 more section in free-space */ - state.tot_space -= TEST_BLOCK_SIZE600; + state.tot_space -= TBLOCK_SIZE600; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* try to extend the block */ - was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, type, (haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE600, (hsize_t)TEST_BLOCK_SIZE200); + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_SUPER, (haddr_t)addr, (hsize_t)TBLOCK_SIZE600, (hsize_t)TBLOCK_SIZE200); - if (was_extended <=0) TEST_ERROR + if(was_extended <=0) TEST_ERROR /* space should be decreased by 200, # of sections remain the same */ - state.tot_space -= TEST_BLOCK_SIZE200; + state.tot_space -= TBLOCK_SIZE200; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space manager */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TEST_BLOCK_SIZE600+TEST_BLOCK_SIZE200)); + H5MF_xfree(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, addr, (hsize_t)(TBLOCK_SIZE600+TBLOCK_SIZE200)); /* only 1 section in free-space because of merging */ - state.tot_space += (TEST_BLOCK_SIZE600+TEST_BLOCK_SIZE200); + state.tot_space += (TBLOCK_SIZE600+TBLOCK_SIZE200); state.tot_sect_count = 1; state.serial_sect_count = 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR if(H5Fclose(file) < 0) @@ -4241,45 +4187,38 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; - - if(H5MF__alloc_start(f, H5AC_ind_read_dxpl_id, type) < 0) - TEST_ERROR + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_start_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + FAIL_STACK_ERROR - if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN) + if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID) + if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR - sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE700); - - /* Construct user data for callbacks */ - udata.f = f; - udata.dxpl_id = H5AC_ind_read_dxpl_id; - udata.alloc_type = type; - udata.allow_sect_absorb = TRUE; - udata.allow_eoa_shrink_only = FALSE; + /* Create section A */ + sect_node = H5MF_sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE700); /* Add section A to free-space manager */ - if (H5FS_sect_add(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata)) - FAIL_STACK_ERROR + if(H5MF_add_sect(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE700; + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + state.tot_space += TBLOCK_SIZE700; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* * Allocate a block of 40 * Since free-space manager cannot fulfull the request because of alignment, * the block is obtained from file allocation */ - addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)(TEST_BLOCK_SIZE40)); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)(TBLOCK_SIZE40)); /* Verify that the allocated block is aligned */ - if (addr % alignment) + if(addr % alignment) TEST_ERROR /* verify that the allocated block is from file allocation, not section A in free-space */ @@ -4296,7 +4235,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } /* free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR if(H5Fclose(file) < 0) @@ -4319,6 +4258,7 @@ error: } /* test_mf_align_fs() */ /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 1024 aggr->alloc_size = 2048 @@ -4413,6 +4353,7 @@ error: * Fragment from alignment of aggregator allocation is freed to free-space:[12368, 4016] * There is space of 2018 left in meta_aggr * EOA is at 20372 + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -4424,7 +4365,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5FD_mem_t type; haddr_t addr1, addr2, addr3, addr4; - frspace_state_t state; + H5FS_stat_t state; haddr_t ma_addr=HADDR_UNDEF; hsize_t ma_size=0, mis_align=0; hsize_t alignment=0, tmp=0; @@ -4467,19 +4408,19 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4487,22 +4428,22 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 50 */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if(addr2 % alignment) TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4510,7 +4451,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr) + if((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 80 */ @@ -4518,13 +4459,13 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE80); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if (addr3 % alignment) TEST_ERROR + if(addr3 % alignment) TEST_ERROR /* fragment for alignment of block 80 is freed to free-space */ - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4532,22 +4473,22 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr3 + TEST_BLOCK_SIZE80) != ma_addr) + if((addr3 + TBLOCK_SIZE80) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 1970 */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 1970 from meta_aggr */ - addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1970); + addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1970); /* Verify that the allocated block is aligned */ - if (addr4 % alignment) TEST_ERROR + if(addr4 % alignment) TEST_ERROR /* fragment for alignment of block 1970 is freed to free-space */ - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4555,17 +4496,17 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr4 + TEST_BLOCK_SIZE1970) != ma_addr) + if((addr4 + TBLOCK_SIZE1970) != ma_addr) TEST_ERROR /* Verify total size of free space after all the allocations */ if(check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE80); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE1970); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE80); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE1970); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -4587,6 +4528,7 @@ error: } /* test_mf_align_alloc1() */ /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 1024 aggr->alloc_size = 2048 @@ -4669,10 +4611,7 @@ error: * The third block of 80 is allocated from the aggregator and should be aligned * There is space of 1968 left in meta_aggr * EOA is at 18432 - * - * Modifications: - * Vailin Choi; July 2012 - * Changes due to the switch to H5FD_FLMAP_DICHOTOMY + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -4683,7 +4622,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) h5_stat_size_t file_size; /* File size */ H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, saddr1; - frspace_state_t state[H5FD_MEM_NTYPES]; + H5FS_stat_t state[H5FD_MEM_NTYPES]; haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, sdata_size=0, mis_align=0; hsize_t alignment=0, tmp=0; @@ -4725,19 +4664,19 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t) * H5FD_MEM_NTYPES); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4745,21 +4684,21 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr) + if((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if(addr2 % alignment) TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4767,7 +4706,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr) + if((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* @@ -4782,17 +4721,17 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) + if((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; @@ -4804,7 +4743,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (sdata_addr != (saddr1 + TEST_BLOCK_SIZE30)) TEST_ERROR + if(sdata_addr != (saddr1 + TBLOCK_SIZE30)) TEST_ERROR /* * Calculate fragment for the allocation of block 80 from meta_aggr: @@ -4816,19 +4755,19 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) + if((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = ((sdata_addr + sdata_size) % alignment))) mis_align = alignment - tmp; /* Allocate a block of 80 from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE80); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ if (addr3 % alignment) TEST_ERROR /* fragment for alignment of block 80 is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4836,7 +4775,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr3 + TEST_BLOCK_SIZE80) != ma_addr) + if((addr3 + TBLOCK_SIZE80) != ma_addr) TEST_ERROR /* Verify total size of free space after all the allocations */ @@ -4850,10 +4789,10 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TEST_ERROR } - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE50); - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE80); - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE50); + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE80); + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -4875,6 +4814,7 @@ error: } /* test_mf_align_alloc2() */ /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 1024 aggr->alloc_size = 2048 @@ -5008,11 +4948,7 @@ error: * The meta_aggr is updated to point to the new space * The block of 1034 is allocated from the new block and should be aligned * There is space of 1014 left in meta_aggr - * - * Modifications: - * Vailin Choi; July 2012 - * Changes due to the switch to H5FD_FLMAP_DICHOTOMY - * + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -5024,7 +4960,7 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3; haddr_t saddr1, saddr2, saddr3; - frspace_state_t state[H5FD_MEM_NTYPES]; + H5FS_stat_t state[H5FD_MEM_NTYPES]; haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, sdata_size=0, mis_align=0; hsize_t alignment=0, tmp=0; @@ -5067,48 +5003,48 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t) * H5FD_MEM_NTYPES); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 50 */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if(addr2 % alignment) TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr) + if((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* @@ -5123,84 +5059,84 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) + if((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (saddr1 % alignment) TEST_ERROR + if(saddr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr1+TEST_BLOCK_SIZE30)) TEST_ERROR + if(sdata_addr != (saddr1+TBLOCK_SIZE30)) TEST_ERROR /* calculate fragment for alignment of block 50 in sdata_aggr */ mis_align = 0; - if ((tmp = sdata_addr % alignment)) + if((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from sdata_aggr */ - saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (saddr2 % alignment) TEST_ERROR + if(saddr2 % alignment) TEST_ERROR /* fragment for alignment of block 50 for sdata_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr2 + TEST_BLOCK_SIZE50)) TEST_ERROR + if(sdata_addr != (saddr2 + TBLOCK_SIZE50)) TEST_ERROR /* calculate fragment for alignment of block 80 in sdata_aggr */ mis_align = 0; - if ((tmp = sdata_addr % alignment)) + if((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 80 from sdata_aggr */ - saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE80); + saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if (saddr3 % alignment) TEST_ERROR + if(saddr3 % alignment) TEST_ERROR /* fragment for alignment of block 80 for sdata_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr3 + TEST_BLOCK_SIZE80) != sdata_addr) + if ((saddr3 + TBLOCK_SIZE80) != sdata_addr) TEST_ERROR /* calculate fragment for alignment of block 1034 */ mis_align = 0; - if ((tmp = sdata_addr % alignment)) + if((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 1034 for meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1034); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1034); /* Verify that the allocated block is aligned */ - if (addr3 % alignment) TEST_ERROR + if(addr3 % alignment) TEST_ERROR /* fragment for alignment of block 1034 for meta_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5208,11 +5144,11 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate unused space in meta_aggr that is freed to free-space after block 1034 */ mis_align = 0; - if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) + if((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; /* fragment for unused space in meta_aggr after block 1034 is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5220,7 +5156,7 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr3 + TEST_BLOCK_SIZE1034) != ma_addr) + if((addr3 + TBLOCK_SIZE1034) != ma_addr) TEST_ERROR /* Verify total size of free space after all allocations */ @@ -5255,6 +5191,7 @@ error: /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 4096 aggr->alloc_size = 2048 @@ -5317,6 +5254,7 @@ error: * Fragment from alignment of aggregator allocation is freed to free-space:[10250, 2038] * There is space of 2023 left in meta_aggr * + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -5327,7 +5265,7 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) h5_stat_size_t file_size; H5FD_mem_t type; haddr_t addr1, addr2, addr3; - frspace_state_t state; + H5FS_stat_t state; haddr_t ma_addr=HADDR_UNDEF; hsize_t ma_size=0, saved_ma_size=0; hsize_t alignment=0, mis_align=0, tmp=0; @@ -5370,19 +5308,19 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t)); + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -5390,21 +5328,21 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); saved_ma_size = ma_size; - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR + if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 2058 */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 2058 from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2058); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if(addr2 % alignment) TEST_ERROR /* fragment for alignment of block 2058 is freed to free-space */ - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -5412,28 +5350,28 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr2 + TEST_BLOCK_SIZE2058) != ma_addr) TEST_ERROR + if((addr2 + TBLOCK_SIZE2058) != ma_addr) TEST_ERROR /* meta_aggr->size remains the same */ - if (ma_size != saved_ma_size) TEST_ERROR + if(ma_size != saved_ma_size) TEST_ERROR /* calculate fragment for alignment of block 5 from meta_aggr */ mis_align = 0; - if ((tmp = ma_addr % alignment)) + if((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 5 from meta_aggr */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5); + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5); /* fragment for alignment of block 5 is freed to free-space */ - if (mis_align) { + if(mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; } /* Verify that the allocated block is aligned */ - if (addr3 % alignment) TEST_ERROR + if(addr3 % alignment) TEST_ERROR /* Verify total size of free space after all allocations */ if(f->shared->fs_man[type]) { @@ -5461,6 +5399,7 @@ error: } /* test_mf_align_alloc4() */ /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 1024 aggr->alloc_size = 2048 @@ -5525,10 +5464,7 @@ error: * sdata_aggr is reset to 0 * EOA is 14346 * meta_aggr and sdata_aggr are all 0 - * - * Modifications: - * Vailin Choi; July 2012 - * Changes due to the switch to H5FD_FLMAP_DICHOTOMY + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -5539,7 +5475,7 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) h5_stat_size_t file_size; H5FD_mem_t type, stype; haddr_t addr1, addr2, saddr1; - frspace_state_t state[H5FD_MEM_NTYPES]; + H5FS_stat_t state[H5FD_MEM_NTYPES]; haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; haddr_t sdata_addr=HADDR_UNDEF, new_sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, new_ma_size=0, sdata_size=0, new_sdata_size=0; @@ -5583,23 +5519,23 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if(addr1 % alignment) TEST_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR + if((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t) * H5FD_MEM_NTYPES); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5607,39 +5543,39 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate fragment for alignment of block 30 from sdata_aggr */ mis_align = 0; - if ((tmp = (ma_addr + ma_size) % alignment)) + if((tmp = (ma_addr + ma_size) % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (saddr1 % alignment) TEST_ERROR + if(saddr1 % alignment) TEST_ERROR /* fragment of alignment for block 30 in sdata_aggr is freed to free-space */ - if (mis_align) { + if(mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) TEST_ERROR + if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* calculate fragment for alignment of block 2058 from meta_aggr */ mis_align = 0; - if ((tmp = (sdata_addr + sdata_size) % alignment)) + if((tmp = (sdata_addr + sdata_size) % alignment)) mis_align = alignment - tmp; /* Allocate a block of 2058 from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2058); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ if (addr2 % alignment) TEST_ERROR /* fragment for alignment of block 2058 is freed to free-space */ - if (mis_align) { + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5687,6 +5623,7 @@ error: /* + *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned * * Alignment = 1024 aggr->alloc_size = 2048 @@ -5792,10 +5729,7 @@ error: * Fragment from alignment of file allocation is freed to free-space:[16464, 4016] * EOA is at 22538 * meta_aggr is unchanged - * - * Modifications: - * Vailin Choi; July 2012 - * Changes due to the switch to H5FD_FLMAP_DICHOTOMY + *------------------------------------------------------------------------- */ static unsigned test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) @@ -5807,7 +5741,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5FD_mem_t type, stype; haddr_t addr1, addr2; haddr_t saddr1, saddr2, saddr3; - frspace_state_t state[H5FD_MEM_NTYPES]; + H5FS_stat_t state[H5FD_MEM_NTYPES]; haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; hsize_t ma_size=0, new_ma_size=0, sdata_size=0; hsize_t alignment=0, mis_align=0, tmp=0; @@ -5849,26 +5783,26 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if ((tmp = (hsize_t)file_size % alignment)) + if((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ if (addr1 % alignment) TEST_ERROR /* fragment for alignment of block 30 in meta_aggr is freed to free-space */ - HDmemset(&state, 0, sizeof(frspace_state_t) * H5FD_MEM_NTYPES); - if (mis_align) { + HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); + if(mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) + if ((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 30 in sdata_aggr */ @@ -5878,7 +5812,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* Allocate a block of 30 from sdata_aggr */ stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ if (saddr1 % alignment) TEST_ERROR @@ -5891,7 +5825,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr1+TEST_BLOCK_SIZE30)) TEST_ERROR + if (sdata_addr != (saddr1+TBLOCK_SIZE30)) TEST_ERROR /* calculate fragment for alignment of block 50 in sdata_aggr */ mis_align = 0; @@ -5899,7 +5833,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) mis_align = alignment - tmp; /* Allocate a block of 50 from sdata_aggr */ - saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); + saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ if (saddr2 % alignment) TEST_ERROR @@ -5912,7 +5846,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr2+TEST_BLOCK_SIZE50)) TEST_ERROR + if (sdata_addr != (saddr2+TBLOCK_SIZE50)) TEST_ERROR /* calculate fragment for alignment of block 80 in sdata_aggr */ mis_align = 0; @@ -5920,7 +5854,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) mis_align = alignment - tmp; /* Allocate a block of 80 from sdata_aggr */ - saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE80); + saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ if (saddr3 % alignment) TEST_ERROR @@ -5933,7 +5867,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr3+TEST_BLOCK_SIZE80)) TEST_ERROR + if (sdata_addr != (saddr3+TBLOCK_SIZE80)) TEST_ERROR /* calculate fragment for alignment of block 2058 */ /* remaining space in sdata_aggr is freed and shrunk */ @@ -5942,7 +5876,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) mis_align = alignment - tmp; /* Allocate a block of 2058 from meta_aggr */ - addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2058); + addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ if (addr2 % alignment) TEST_ERROR @@ -5993,7 +5927,6 @@ error: return(1); } /* test_mf_align_alloc6() */ - /* * Test a bug that occurs when an allocator with zero size left and an unaligned * endpoint is extended to allocate an aligned object @@ -6156,253 +6089,269 @@ error: return(1); } /* test_mf_bug1() */ - /* - * Verify that the file's free-space manager persists where there are free sections in the manager + * Verify that the file's free-space manager(s) are persistent for a split-file + *------------------------------------------------------------------------- */ static unsigned -test_mf_fs_persist(hid_t fapl_new, hid_t fcpl) +test_mf_fs_persist_split(void) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - haddr_t tmp_addr; /* Temporary variable for address */ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype, btype; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ + haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_DRAW */ + haddr_t baddr5, baddr6, baddr7, baddr8; /* File address for H5FD_MEM_BTREE */ + haddr_t tmp_addr; /* temporary variable for address */ + + TESTING("File's free-space managers are persistent for split-file"); + + /* for now, we don't support persistant free space managers + * with the split file driver. + */ + SKIPPED(); + HDfprintf(stdout, " Persistant FSMs disabled in multi file driver.\n"); + return 0; /* <========== note return */ + + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + + /* for now, we don't support persistant free space managers + * with the split file driver. + */ + SKIPPED(); + HDfprintf(stdout, " Persistant FSMs disabled in multi file driver.\n"); + return 0; /* <========== note return */ + + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Set up split driver */ + if(H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) + FAIL_STACK_ERROR - TESTING("file's free-space manager is persistent"); + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Allocate 6 blocks */ + /* Allocate 4 blocks of type H5FD_MEM_SUPER */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE6))) - FAIL_STACK_ERROR - - /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + + /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + + /* Allocate 4 blocks of type H5FD_MEM_DRAW */ + stype = H5FD_MEM_DRAW; + if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + + /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */ + if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that H5FD_MEM_SUPER free-space manager is there */ + /* Verify that the H5FD_MEM_SUPER free-space manager is there */ if(!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR - /* Get info for free-space manager */ + /* Get free-space info */ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3+TEST_BLOCK_SIZE5)) - TEST_ERROR - - if(fs_stat.serial_sect_count < 3) - TEST_ERROR - - /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(tmp_addr != addr3) - TEST_ERROR + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + TEST_ERROR + if(fs_stat.serial_sect_count < 2) + TEST_ERROR - /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR + /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #3 still in free-space */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR if(tmp_addr != addr1) - TEST_ERROR + TEST_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + /* Verify that the free-space manager for H5FD_MEM_DRAW is there */ + if(!H5F_addr_defined(f->shared->fs_addr[stype])) + TEST_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + + /* Start up H5FD_MEM_DRAW free-space manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)stype) < 0) FAIL_STACK_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) FAIL_STACK_ERROR - /* Verify that H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + /* Verify free-space info */ + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) TEST_ERROR - - /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - if(tmp_addr != addr5) + if(fs_stat.serial_sect_count < 2) TEST_ERROR - if(H5Fclose(file) < 0) + /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR + if(tmp_addr != saddr1) + TEST_ERROR - PASSED() - - return(0); - -error: - H5E_BEGIN_TRY { - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_mf_fs_persist() */ - -/* - * Verify that the free-space manager goes away - */ -static unsigned -test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) -{ - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ - - TESTING("file's free-space manager is going away"); - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR + if(tmp_addr != saddr3) + TEST_ERROR + /* H5FD_MEM_DRAW free-space manager is going away at closing */ + /* works for this one because the freeing of sect_addr is to H5FD_MEM_SUPER fs, not against itself */ - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + /* Allocate 4 blocks of type H5FD_MEM_BTREE */ + btype = H5FD_MEM_BTREE; + if(HADDR_UNDEF == (baddr5 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - - /* Allocate 4 blocks */ - type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR - - /* Put block #1, #3 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR - - /* Retrieve block #1, #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - - if(H5Fclose(file) < 0) + if(HADDR_UNDEF == (baddr6 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE6))) FAIL_STACK_ERROR - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if(HADDR_UNDEF == (baddr7 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE7))) FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(HADDR_UNDEF == (baddr8 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8))) FAIL_STACK_ERROR - /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ - if(H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR - - /* Put block #3 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) + /* Put block #5 & #7 into H5FD_MEM_BTREE free-space manager */ + if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr5, (hsize_t)TBLOCK_SIZE5) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr7, (hsize_t)TBLOCK_SIZE7) < 0) FAIL_STACK_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that H5FD_MEM_SUPER free-space manager is there */ + /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ + if(H5F_addr_defined(f->shared->fs_addr[stype])) + TEST_ERROR + + /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ if(!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR - /* Get info for H5FD_MEM_SUPER free-space manager */ + /* Get free-space info */ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(!H5F_addr_defined(fs_stat.addr) || !H5F_addr_defined(fs_stat.sect_addr)) + if(fs_stat.tot_space < (TBLOCK_SIZE3+TBLOCK_SIZE5+TBLOCK_SIZE7)) + TEST_ERROR + + /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(tmp_addr != addr3) TEST_ERROR - if(fs_stat.tot_space < TEST_BLOCK_SIZE3) - TEST_ERROR - /* Put block #4 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TEST_BLOCK_SIZE4) < 0) + /* Retrieve block #7 from H5FD_MEM_BTREE free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE7))) FAIL_STACK_ERROR + if(tmp_addr != baddr7) + TEST_ERROR - /* The H5FD_MEM_SUPER free-space manager will go away at H5MF_close() */ + /* There should still be block #5 of H5FD_MEM_BTREE in H5FD_MEM_BTREE free-space manager */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ - if(H5F_addr_defined(f->shared->fs_addr[type])) + /* Verify that the H5FD_MEM_SUPER free-space manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[type])) + TEST_ERROR + + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) + FAIL_STACK_ERROR + + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + FAIL_STACK_ERROR + + /* Verify free-space info */ + if(fs_stat.tot_space < TBLOCK_SIZE5) TEST_ERROR + /* Closing */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR PASSED() @@ -6410,35 +6359,113 @@ test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(file); + H5Pclose(fcpl); + H5Pclose(fapl); } H5E_END_TRY; return(1); -} /* test_mf_fs_gone() */ - +} /* test_mf_fs_persist_split() */ + +#define MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) { \ + H5FD_mem_t mt; \ + HDmemset(memb_map, 0, sizeof memb_map); \ + HDmemset(memb_fapl, 0, sizeof memb_fapl); \ + HDmemset(memb_name, 0, sizeof memb_name); \ + HDmemset(memb_addr, 0, sizeof memb_addr); \ + HDmemset(sv, 0, sizeof sv); \ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { \ + memb_map[mt] = H5FD_MEM_SUPER; \ + memb_fapl[mt] = H5P_DEFAULT; \ + } \ + memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; \ + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \ + memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \ + memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \ + sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \ + memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \ + memb_addr[H5FD_MEM_SUPER] = 0; \ + sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \ + memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \ + memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6; \ + sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \ + memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \ + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3; \ + sprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \ + memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \ + memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2; \ + sprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \ + memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \ + memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3; \ + sprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \ + memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \ + memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6; \ +} /* - * Verify that the file's free-space manager(s) are persistent for a split-file + *------------------------------------------------------------------------- + * Verify that the file's free-space manager(s) are persistent for a multi-file + *------------------------------------------------------------------------- */ static unsigned -test_mf_fs_split(hid_t fapl_new, hid_t fcpl) +test_mf_fs_persist_multi(void) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype, btype; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ - haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_DRAW */ - haddr_t baddr5, baddr6, baddr7, baddr8; /* File address for H5FD_MEM_BTREE */ - haddr_t tmp_addr; /* temporary variable for address */ - - TESTING("file's free-space managers are persistent for split-file"); + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype, btype, gtype; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4; /* File allocation type */ + haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_SUPER */ + haddr_t baddr1, baddr2, baddr3, baddr4; /* File address for H5FD_MEM_DRAW */ + haddr_t gaddr1, gaddr2; /* File address for H5FD_MEM_GHEAP */ + haddr_t tmp_addr; /* Temporary variable for address */ + H5FS_section_info_t *node; /* Free space section node */ + htri_t node_found = FALSE; /* Indicate section is in free-space */ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ + hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ + char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ + const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ + haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ + + + TESTING("File's free-space managers are persistent for multi-file"); + + /* for now, we don't support persistant free space managers + * with the multi file driver. + */ + SKIPPED(); + HDfprintf(stdout, " Persistant FSMs disabled in multi file driver.\n"); + return 0; /* <========== note return */ + + /* for now, we don't support persistant free space managers + * with the multi file driver. + */ + SKIPPED(); + HDfprintf(stdout, " Persistant FSMs disabled in multi file driver.\n"); + return 0; /* <========== note return */ + + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + FAIL_STACK_ERROR + + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + + MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) + + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) + TEST_ERROR; /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -6447,43 +6474,43 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) /* Allocate 4 blocks of type H5FD_MEM_SUPER */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_DRAW */ stype = H5FD_MEM_DRAW; - if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */ - if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR + if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -6495,7 +6522,7 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ @@ -6503,23 +6530,23 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3)) - TEST_ERROR + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + TEST_ERROR if(fs_stat.serial_sect_count < 2) - TEST_ERROR + TEST_ERROR - /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #2 still in free-space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR + /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #3 still in free-space */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR if(tmp_addr != addr1) - TEST_ERROR + TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is there */ if(!H5F_addr_defined(f->shared->fs_addr[stype])) TEST_ERROR /* Start up H5FD_MEM_DRAW free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, stype) < 0) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)stype) < 0) FAIL_STACK_ERROR /* Get free-space info */ @@ -6527,63 +6554,57 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3)) - TEST_ERROR + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + TEST_ERROR if(fs_stat.serial_sect_count < 2) - TEST_ERROR + TEST_ERROR /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR if(tmp_addr != saddr1) - TEST_ERROR + TEST_ERROR /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR if(tmp_addr != saddr3) - TEST_ERROR - /* H5FD_MEM_DRAW free-space manager is going away at closing */ - /* works for this one because the freeing of sect_addr is to H5FD_MEM_SUPER fs, not against itself */ + TEST_ERROR /* Allocate 4 blocks of type H5FD_MEM_BTREE */ btype = H5FD_MEM_BTREE; - if(HADDR_UNDEF == (baddr5 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr6 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE6))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr7 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE7))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr8 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE8))) - FAIL_STACK_ERROR - - /* Put block #5 & #7 into H5FD_MEM_BTREE free-space manager */ - if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr5, (hsize_t)TEST_BLOCK_SIZE5) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr7, (hsize_t)TEST_BLOCK_SIZE7) < 0) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (baddr1 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (baddr2 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (baddr3 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (baddr4 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + + /* Put block #1 & #3 into H5FD_MEM_BTREE free-space manager */ + if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ - if(H5F_addr_defined(f->shared->fs_addr[stype])) - TEST_ERROR - /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ if(!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ @@ -6591,51 +6612,99 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE3+TEST_BLOCK_SIZE5+TEST_BLOCK_SIZE7)) - TEST_ERROR + if(fs_stat.tot_space < TBLOCK_SIZE3) + TEST_ERROR /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR if(tmp_addr != addr3) - TEST_ERROR + TEST_ERROR - /* Retrieve block #7 from H5FD_MEM_BTREE free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE7))) - FAIL_STACK_ERROR - if(tmp_addr != baddr7) - TEST_ERROR + /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ + if(H5F_addr_defined(f->shared->fs_addr[stype])) + TEST_ERROR + + /* Verify that the free-space manager for H5FD_MEM_BTREE is there */ + if(!H5F_addr_defined(f->shared->fs_addr[btype])) + TEST_ERROR + + /* Start up H5FD_MEM_BTREE free-space manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)btype) < 0) + FAIL_STACK_ERROR + + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[btype], &fs_stat) < 0) + FAIL_STACK_ERROR + + /* Verify free-space info */ + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + TEST_ERROR + if(fs_stat.serial_sect_count < 2) + TEST_ERROR + + /* Allocate 2 blocks of type H5FD_MEM_GHEAP */ + gtype = H5FD_MEM_GHEAP; + if(HADDR_UNDEF == (gaddr2 = H5MF_alloc(f, gtype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (gaddr1 = H5MF_alloc(f, gtype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + + /* Put block #2 into H5FD_MEM_GHEAP free-space manager */ + if(H5MF_xfree(f, gtype, H5AC_ind_read_dxpl_id, gaddr2, (hsize_t)TBLOCK_SIZE2) < 0) + FAIL_STACK_ERROR - /* There should still be block #5 of H5FD_MEM_BTREE in H5FD_MEM_BTREE free-space manager */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that the H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR + /* If H5FD_MEM_SUPER is there, should not find block #1 & #3 */ + if(H5F_addr_defined(f->shared->fs_addr[type])) { + /* Start up H5FD_MEM_SUPER free-space manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)type) < 0) + FAIL_STACK_ERROR - /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) + if((node_found = H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], + (hsize_t)TBLOCK_SIZE1, (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR + if(node_found) TEST_ERROR + + if((node_found = H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], + (hsize_t)TBLOCK_SIZE3, (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR + if(node_found) TEST_ERROR + } + + /* Verify that the H5FD_MEM_GHEAP free-space manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[gtype])) + TEST_ERROR + + /* Start up H5FD_MEM_GHEAP free-space manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)gtype) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if(H5FS_stat_info(f, f->shared->fs_man[gtype], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < TEST_BLOCK_SIZE5) - TEST_ERROR + if(fs_stat.tot_space < TBLOCK_SIZE2) + TEST_ERROR + /* Closing */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR PASSED() @@ -6643,268 +6712,812 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(file); + H5Pclose(fcpl); + H5Pclose(fapl); } H5E_END_TRY; return(1); -} /* test_mf_fs_split() */ +} /* test_mf_fs_persist_multi() */ /* - * Verify that the file's free-space manager(s) are persistent for a multi-file + *------------------------------------------------------------------------- + * Verify that the file's free-space persists where there are free sections in the manager + *------------------------------------------------------------------------- */ static unsigned -test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) +test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype, btype, gtype; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File allocation type */ - haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_SUPER */ - haddr_t baddr1, baddr2, baddr3, baddr4; /* File address for H5FD_MEM_DRAW */ - haddr_t gaddr1, gaddr2; /* File address for H5FD_MEM_GHEAP */ - haddr_t tmp_addr; /* Temporary variable for address */ - H5FS_section_info_t *node; /* Free space section node */ - htri_t node_found = FALSE; /* Indicate section is in free-space */ - - TESTING("file's free-space managers are persistent for multi-file"); - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) - FAIL_STACK_ERROR + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl2 = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + haddr_t tmp_addr; /* Temporary variable for address */ + + if(new_format) + TESTING("File's free-space is persistent with new library format") + else + TESTING("File's free-space is persistent with old library format") + + if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")) { + + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Copy the file access property list */ + if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + + if(new_format) { + /* Latest format */ + if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + /* Set to paged aggregation and persisting free-space */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + TEST_ERROR + } else { + /* Setting: aggregation with persisting free-space */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + TEST_ERROR + } - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - /* Allocate 4 blocks of type H5FD_MEM_SUPER */ - type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + FAIL_STACK_ERROR - /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR - /* Allocate 4 blocks of type H5FD_MEM_DRAW */ - stype = H5FD_MEM_DRAW; - if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR + /* Allocate 6 blocks */ + type = H5FD_MEM_SUPER; + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE6))) + FAIL_STACK_ERROR - /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */ - if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR + /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + FAIL_STACK_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) - FAIL_STACK_ERROR + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR - /* Verify that the H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR + H5MF_alloc_to_fs_type(f, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); - /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) - FAIL_STACK_ERROR + /* Verify that H5FD_MEM_SUPER free-space manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[tt])) + TEST_ERROR - /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) - FAIL_STACK_ERROR + /* Since we are about to open a self referential free space + * manager prior to the first file space allocation / deallocation + * call H5MF_tidy_self_referential_fsm_hack() first so as to avoid + * assertion failures on the first file space alloc / dealloc. + */ + if((f->shared->first_alloc_dealloc) && + (SUCCEED != + H5MF_tidy_self_referential_fsm_hack(f, H5AC_ind_read_dxpl_id))) + FAIL_STACK_ERROR - /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3)) - TEST_ERROR - if(fs_stat.serial_sect_count < 2) - TEST_ERROR + /* Start up H5FD_MEM_SUPER free-space manager */ + if(!(f->shared->fs_man[tt])) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)tt) < 0) + FAIL_STACK_ERROR - /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #2 still in free-space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(tmp_addr != addr1) - TEST_ERROR + /* Get info for free-space manager */ + if(H5FS_stat_info(f, f->shared->fs_man[tt], &fs_stat) < 0) + FAIL_STACK_ERROR - /* Verify that the free-space manager for H5FD_MEM_DRAW is there */ - if(!H5F_addr_defined(f->shared->fs_addr[stype])) - TEST_ERROR + /* Verify free-space info */ + if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3+TBLOCK_SIZE5)) + TEST_ERROR - /* Start up H5FD_MEM_DRAW free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, stype) < 0) - FAIL_STACK_ERROR + if(fs_stat.serial_sect_count < 3) + TEST_ERROR - /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) - FAIL_STACK_ERROR + /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(tmp_addr != addr3) + TEST_ERROR - /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3)) - TEST_ERROR - if(fs_stat.serial_sect_count < 2) - TEST_ERROR + /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(tmp_addr != addr1) + TEST_ERROR - /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(tmp_addr != saddr1) - TEST_ERROR + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR - /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(tmp_addr != saddr3) - TEST_ERROR + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - /* Allocate 4 blocks of type H5FD_MEM_BTREE */ - btype = H5FD_MEM_BTREE; - if(HADDR_UNDEF == (baddr1 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr2 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr3 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr4 = H5MF_alloc(f, btype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR - /* Put block #1 & #3 into H5FD_MEM_BTREE free-space manager */ - if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, btype, H5AC_ind_read_dxpl_id, baddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR + /* Verify that H5FD_MEM_SUPER free-space manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[tt])) + TEST_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */ + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5))) + FAIL_STACK_ERROR + if(tmp_addr != addr5) + TEST_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) - FAIL_STACK_ERROR + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR + PASSED() - /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR + } else { + SKIPPED(); + puts(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); + } - /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) - FAIL_STACK_ERROR + return(0); - /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) - FAIL_STACK_ERROR +error: + H5E_BEGIN_TRY { + H5Fclose(file); + H5Pclose(fcpl); + H5Pclose(fapl2); + } H5E_END_TRY; + return(1); +} /* test_mf_fs_persist() */ - /* Verify free-space info */ - if(fs_stat.tot_space < TEST_BLOCK_SIZE3) - TEST_ERROR +/* + *------------------------------------------------------------------------- + * Verify free-space are merged/shrunk away + *------------------------------------------------------------------------- + */ +static unsigned +test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) +{ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fapl2 = -1; /* File access property list */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ + H5FD_mem_t fs_type; + hbool_t contig_addr_vfd; + hbool_t ran_H5MF_tidy_self_referential_fsm_hack = FALSE; + + if(new_format) + TESTING("File's free-space is going away with new library format") + else + TESTING("File's free-space is going away with old library format") + + /* Current VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(tmp_addr != addr3) - TEST_ERROR + if(contig_addr_vfd) { - /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ - if(H5F_addr_defined(f->shared->fs_addr[stype])) - TEST_ERROR + /* File creation property list template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Verify that the free-space manager for H5FD_MEM_BTREE is there */ - if(!H5F_addr_defined(f->shared->fs_addr[btype])) - TEST_ERROR + /* Copy the file access property list */ + if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - /* Start up H5FD_MEM_BTREE free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, btype) < 0) - FAIL_STACK_ERROR + if(new_format) + if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR - /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[btype], &fs_stat) < 0) - FAIL_STACK_ERROR + /* Set to aggregation and persisting free-space */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + FAIL_STACK_ERROR - /* Verify free-space info */ - if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3)) - TEST_ERROR - if(fs_stat.serial_sect_count < 2) - TEST_ERROR + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - /* Allocate 2 blocks of type H5FD_MEM_GHEAP */ - gtype = H5FD_MEM_GHEAP; - if(HADDR_UNDEF == (gaddr2 = H5MF_alloc(f, gtype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (gaddr1 = H5MF_alloc(f, gtype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + FAIL_STACK_ERROR - /* Put block #2 into H5FD_MEM_GHEAP free-space manager */ - if(H5MF_xfree(f, gtype, H5AC_ind_read_dxpl_id, gaddr2, (hsize_t)TEST_BLOCK_SIZE2) < 0) - FAIL_STACK_ERROR + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + /* Allocate 4 blocks */ + type = H5FD_MEM_SUPER; + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + + /* Put block #1, #3 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + + /* Retrieve block #1, #3 from H5FD_MEM_SUPER free-space manager */ + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + H5MF_alloc_to_fs_type(f, type, TBLOCK_SIZE4, (H5F_mem_page_t *)&fs_type); + + /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ + if(H5F_addr_defined(f->shared->fs_addr[fs_type])) + TEST_ERROR + + /* Put block #3 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Verify that H5FD_MEM_SUPER free-space manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + TEST_ERROR + + /* Since we are about to open a self referential free space + * manager prior to the first file space allocation / deallocation + * call H5MF_tidy_self_referential_fsm_hack() first so as to avoid + * assertion failures on the first file space alloc / dealloc. + */ + if(f->shared->first_alloc_dealloc){ + if(SUCCEED!=H5MF_tidy_self_referential_fsm_hack(f,H5AC_ind_read_dxpl_id)) + FAIL_STACK_ERROR + ran_H5MF_tidy_self_referential_fsm_hack = TRUE; + } + + /* Start up H5FD_MEM_SUPER free-space manager */ + if(!(f->shared->fs_man[fs_type])) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, (H5F_mem_page_t)fs_type) < 0) + FAIL_STACK_ERROR + + /* Get info for H5FD_MEM_SUPER free-space manager */ + if(H5FS_stat_info(f, f->shared->fs_man[fs_type], &fs_stat) < 0) + FAIL_STACK_ERROR + + /* if we ran H5MF_tidy_self_referential_fsm_hack(), the + * H5FD_MEM_SUPER free space manager must be floating. + * Thus fs_stat.addr must be undefined. + */ + if((!ran_H5MF_tidy_self_referential_fsm_hack) && + (!H5F_addr_defined(fs_stat.addr))) + TEST_ERROR + + if(fs_stat.tot_space < TBLOCK_SIZE3) + TEST_ERROR + + /* Put block #4 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TBLOCK_SIZE4) < 0) + FAIL_STACK_ERROR + + /* The H5FD_MEM_SUPER free-space manager will go away at H5MF_close() */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ + if(H5F_addr_defined(f->shared->fs_addr[fs_type])) + TEST_ERROR + + /* Closing */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support persistent free-space manager"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(file); + H5Pclose(fcpl); + H5Pclose(fapl2); + } H5E_END_TRY; + return(1); +} /* test_mf_fs_gone() */ + +/* + *------------------------------------------------------------------------- + * Verify that free-space persist with combinations of + * file space strategy and free space threshold as specified. + *------------------------------------------------------------------------- + */ +static unsigned +test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) +{ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list template */ + hid_t fapl2 = -1; /* File access property list template */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + H5F_fspace_strategy_t fs_type; /* File space handling strategy */ + hsize_t fs_threshold; /* Free-space section threshold */ + unsigned fs_persist; /* To persist free-space or not */ + hbool_t contig_addr_vfd; + + if(new_format) + TESTING("File space strategy/persisting/threshold with new library format") + else + TESTING("File space strategy/persisting/threshold with old library format") + + /* Current VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Copy the file access property list */ + if((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR + + if(new_format) + if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Test with TRUE or FALSE for persisting free-space */ + for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + + for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { + + /* Testing for H5F_FSPACE_STRATEGY_FSM_AGGR and H5F_FSPACE_STRATEGY_PAGE strategies only */ + for(fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; H5_INC_ENUM(H5F_fspace_strategy_t, fs_type)) { + + if(!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) + continue; + + /* Create file-creation template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set default file space information */ + if(H5Pset_file_space_strategy(fcpl, fs_type, (hbool_t)fs_persist, fs_threshold) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Allocate 6 blocks */ + type = H5FD_MEM_SUPER; + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE6))) + FAIL_STACK_ERROR + + /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + FAIL_STACK_ERROR + + + /* Close the file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + H5MF_alloc_to_fs_type(f, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + if(f->shared->fs_persist) { + hssize_t nsects; /* # of free-space sections */ + int i; /* local index variable */ + H5F_sect_info_t *sect_info; /* array to hold the free-space information */ + + /* Get the # of free-space sections in the file */ + if((nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL)) < 0) + FAIL_STACK_ERROR + + /* Verify no free-space sections */ + /* paged aggregation has 1 section for last_small */ + if(fs_threshold > TBLOCK_SIZE5 && nsects && fs_type != H5F_FSPACE_STRATEGY_PAGE) + TEST_ERROR + + if(nsects) { + /* Allocate storage for the free space section information */ + sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)); + + H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); + + /* Verify the size of free-space sections */ + for(i = 0; i < nsects; i++) + if(sect_info[i].size < fs_threshold) + TEST_ERROR + if(sect_info) + HDfree(sect_info); + } + } else { + if(H5F_addr_defined(f->shared->fs_addr[tt])) + TEST_ERROR + } + + /* Closing */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + } /* end for fs_type */ + } /* end for fs_threshold */ + } /* end for fs_persist */ + + if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + PASSED() + + return(0); + +error: + H5E_BEGIN_TRY { + H5Pclose(fcpl); + H5Pclose(fapl2); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_mf_strat_thres_persist() */ + +/* + *------------------------------------------------------------------------- + * Verify free-space are merged/shrunk away with file space settings: + * --strategy, persist/not persist file space + *------------------------------------------------------------------------- + */ +static unsigned +test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) +{ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list template */ + hid_t fapl2 = -1; /* File access property list template */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + H5F_fspace_strategy_t fs_type; /* File space handling strategy */ + unsigned fs_persist; /* To persist free-space or not */ + H5FS_stat_t fs_state; /* Information for free-space manager */ + H5FS_stat_t fs_state_zero; /* Information for free-space manager */ + hbool_t contig_addr_vfd; + + if(new_format) + TESTING("File space merge/shrink for section size < threshold with new library format") + else + TESTING("File space merge/shrink for section size < threshold with old library format") + + /* Current VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + HDmemset(&fs_state_zero, 0, sizeof(H5FS_stat_t)); + + /* Copy the file access property list */ + if((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR + + if(new_format) + if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Test with TRUE or FALSE for persisting free-space */ + for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + /* Testing for H5F_FSPACE_STRATEGY_FSM_AGGR and H5F_FSPACE_STRATEGY_PAGE strategies only */ + for(fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; H5_INC_ENUM(H5F_fspace_strategy_t, fs_type)) { + + /* Skip for multi/split driver: persisting free-space or paged aggregation strategy */ + if(!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) + continue; + + /* Clear out free-space statistics */ + HDmemset(&fs_state, 0, sizeof(H5FS_stat_t)); + + /* Create file-creation template */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set default file space information */ + if(H5Pset_file_space_strategy(fcpl, fs_type, fs_persist, (hsize_t)TEST_THRESHOLD3) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Allocate 6 blocks */ + type = H5FD_MEM_SUPER; + if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE2))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5))) + FAIL_STACK_ERROR + if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE6))) + FAIL_STACK_ERROR + + H5MF_alloc_to_fs_type(f, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); + + /* For paged aggregation, the section in the page at EOF for small meta fs is not shrunk away */ + if(fs_type == H5F_FSPACE_STRATEGY_PAGE) { + if(H5FS_stat_info(f, f->shared->fs_man[tt], &fs_state) < 0) + FAIL_STACK_ERROR + } + + /* Put block #3, #5 to H5FD_MEM_SUPER free-space manager */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + FAIL_STACK_ERROR + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + FAIL_STACK_ERROR + + fs_state.tot_space += TBLOCK_SIZE3 + TBLOCK_SIZE5; + fs_state.tot_sect_count += 2; + fs_state.serial_sect_count += 2; + + if(check_stats(f, f->shared->fs_man[tt], &fs_state)) + TEST_ERROR + + /* section #2 is less than threshold but is merged into section #3 */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE2) < 0) + FAIL_STACK_ERROR + + fs_state.tot_space += TBLOCK_SIZE2; + if(check_stats(f, f->shared->fs_man[tt], &fs_state)) + TEST_ERROR + + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TBLOCK_SIZE4) < 0) + FAIL_STACK_ERROR + + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr6, (hsize_t)TBLOCK_SIZE6) < 0) + FAIL_STACK_ERROR + + /* For paged aggregation, the sections in the page at EOF for small meta fs are merged but are not shrunk away */ + if(fs_type == H5F_FSPACE_STRATEGY_PAGE) { + fs_state.tot_sect_count = fs_state.serial_sect_count = 1; + fs_state.tot_space += (TBLOCK_SIZE4 + TBLOCK_SIZE6); + } + + /* For old format: the sections at EOF are shrunk away */ + if(check_stats(f, f->shared->fs_man[tt], (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state:&fs_state_zero)) + TEST_ERROR + + /* section #1 is less than threshold but is shrunk away */ + if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + FAIL_STACK_ERROR + + /* For paged aggregation, the section in the page at EOF for small meta fs is not shrunk away */ + if(fs_type == H5F_FSPACE_STRATEGY_PAGE) + fs_state.tot_space += TBLOCK_SIZE1; + + /* For old format: the sections at EOF are shrunk away */ + if(check_stats(f, f->shared->fs_man[tt], (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state : &fs_state_zero)) + TEST_ERROR + + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Free-space manager should be empty */ + if(!(fs_type == H5F_FSPACE_STRATEGY_PAGE && fs_persist)) + if(H5F_addr_defined(f->shared->fs_addr[tt])) + TEST_ERROR + + /* Closing */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + } /* end for fs_type */ + } /* end for fs_persist */ + + if(H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR + + PASSED() + + return(0); + +error: + H5E_BEGIN_TRY { + H5Pclose(fcpl); + H5Pclose(fapl2); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_mf_strat_thres_gone() */ + +/* + *------------------------------------------------------------------------- + * To verify that file space is allocated from the corresponding free-space manager + * because H5FD_FLMAP_DICHOTOMY is used as the default free-list mapping. + * + * (1) Allocate the first block (size 30) of type H5FD_MEM_SUPER + * (2) Allocate the second block (size 50) of type H5FD_MEM_SUPER + * + * (3) Allocate the first block (size 30) of type H5FD_MEM_DRAW + * + * (4) Free the first block (size 30) of type H5FD_MEM_SUPER + * + * (5) Allocate the second block (size 30) of type H5FD_MEM_DRAW + * (6) Verify that this second block is not the freed block from (3) + * + * (7) Allocate the second block (size 30) of type H5FD_MEM_DRAW + * (8) Free the first block (size 30) of type H5FD_MEM_DRAW + * + * (9) Allocate the third block (size 30) of type H5FD_MEM_SUPER + * (10) Verify that this third block is not freed block from (8) + *------------------------------------------------------------------------- + */ +static unsigned +test_dichotomy(hid_t fapl) +{ + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype; + haddr_t addr1, addr3, saddr1, saddr2; + + TESTING("Allocation from raw or metadata free-space manager"); + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* If H5FD_MEM_SUPER is there, should not find block #1 & #3 */ - if(H5F_addr_defined(f->shared->fs_addr[type])) { - /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) - FAIL_STACK_ERROR - - if((node_found = H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE1, (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR - if(node_found) TEST_ERROR - - if((node_found = H5FS_sect_find(f, H5AC_ind_read_dxpl_id, f->shared->fs_man[type], - (hsize_t)TEST_BLOCK_SIZE3, (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR - if(node_found) TEST_ERROR - } + /* Allocate the first block of type H5FD_MEM_SUPER */ + type = H5FD_MEM_SUPER; + addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); - /* Verify that the H5FD_MEM_GHEAP free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[gtype])) - TEST_ERROR + /* Allocate the second block of type H5FD_MEM_SUPER */ + H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); - /* Start up H5FD_MEM_GHEAP free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, gtype) < 0) - FAIL_STACK_ERROR + /* Allocate the first block of type H5FD_MEM_DRAW */ + stype = H5FD_MEM_DRAW; + saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); - /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[gtype], &fs_stat) < 0) - FAIL_STACK_ERROR + /* Free the first block of type H5FD_MEM_SUPER */ + H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE30); - /* Verify free-space info */ - if(fs_stat.tot_space < TEST_BLOCK_SIZE2) - TEST_ERROR + /* Allocate the second block of type H5FD_MEM_DRAW */ + saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + + /* Verify that saddr1 is not addr1 */ + if(saddr2 == addr1) TEST_ERROR + + /* Free the first block of type H5FD_MEM_DRAW */ + H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); + + /* Allocate the third block of type H5FD_MEM_SUPER */ + addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + + /* Verify that addr3 is not saddr1 */ + if(addr3 == saddr1) TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -6915,695 +7528,1326 @@ test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_dichotomy() */ + +/* + *------------------------------------------------------------------------- + * set_multi_split(): + * Internal routine to set up page-aligned address space for multi/split driver + * when testing paged aggregation. + *------------------------------------------------------------------------- + */ +static int +set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t multi, hbool_t split) +{ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char *memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; + + HDassert(multi || split); + + HDmemset(memb_name, 0, sizeof memb_name); + + /* Get current split settings */ + if(H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + TEST_ERROR + + if(split) { + /* Set memb_addr aligned */ + memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + pagesize - 1) / pagesize) * pagesize; + memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; + } else { + /* Set memb_addr aligned */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + memb_addr[mt] = ((memb_addr[mt] + pagesize - 1) / pagesize) * pagesize; + } /* end else */ + + /* Set multi driver with new FAPLs */ + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + TEST_ERROR + + /* Free memb_name */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + free(memb_name[mt]); + + return 0; + +error: + return(-1); +} /* set_multi_split() */ + +/*------------------------------------------------------------------------- + * Function: test_page_alloc_xfree + * + * Purpose: To verify allocations and de-allocations for large/small + * sections are done properly when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) +{ + + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fapl_new = -1; /* File access property list ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr2, addr3; /* Addresses for small meta data blocks */ + haddr_t saddr1; /* Addresses for small raw data blocks */ + haddr_t gaddr1; /* Addresses for large data blocks */ + hbool_t split = FALSE, multi = FALSE; + char filename[FILENAME_LEN]; /* Filename to use */ + haddr_t found_addr; /* Address of the found section */ + unsigned fs_persist; /* To persist free-space or not */ + + TESTING("Paged aggregation for file space: H5MF_alloc/H5MF_xfree"); + + /* Check for split or multi driver */ + if(!HDstrcmp(env_h5_drvr, "split")) + split = TRUE; + else if(!HDstrcmp(env_h5_drvr, "multi")) + multi = TRUE; + + if(!multi && !split) { + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + + if(multi || split) + if(set_multi_split(fapl_new, 4096, multi, split) < 0) + TEST_ERROR; + + /* Test with TRUE or FALSE for persisting free-space */ + for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + H5F_mem_page_t fs_type; + + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, fs_persist, (hsize_t)1) < 0) + TEST_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + TEST_ERROR + + /* Allocate 3 small meta data blocks: addr1, addr2, addr3 */ + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + addr2 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1034); + addr3 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); + + /* Free the block with addr2 */ + H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE1034); + + if(!fs_persist) { + + H5MF_alloc_to_fs_type(f, H5FD_MEM_OHDR, TBLOCK_SIZE1034, (H5F_mem_page_t *)&fs_type); + + /* Verify that the freed block with addr2 is found from the small meta data manager */ + if(H5MF_find_sect(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1034, f->shared->fs_man[fs_type], &found_addr) < 0) + TEST_ERROR + if(found_addr != addr2) + TEST_ERROR + } /* end if */ + + /* Allocate 2 small raw data blocks: saddr1, saddr2 */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE1034); + + /* Free the block with saddr1 */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); + + if(!fs_persist) { + /* Verify that the freed block with saddr1 is found from the small raw data manager */ + if(H5MF_find_sect(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) + TEST_ERROR + if(found_addr != saddr1) + TEST_ERROR + } /* end if */ + + /* Allocate 2 large data blocks: gaddr1, gaddr2 */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); + H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8000); + + /* Free the block with gaddr1 */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr1, (hsize_t)TBLOCK_SIZE5000); + + if(!fs_persist) { + + H5MF_alloc_to_fs_type(f, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); + + /* Verify that the freed block with gaddr1 is found from the large data manager */ + if(H5MF_find_sect(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], &found_addr) < 0) + TEST_ERROR + if(found_addr != gaddr1) + TEST_ERROR + } /* end if */ + + /* Close file */ + if(H5Fclose(fid) < 0) + TEST_ERROR + + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + TEST_ERROR + + if(fs_persist) { + /* Re-open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + TEST_ERROR + + /* Verify that the large generic manager is there */ + H5MF_alloc_to_fs_type(f, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); + if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + TEST_ERROR + + /* Verify that the small meta data manager is there */ + H5MF_alloc_to_fs_type(f, H5FD_MEM_OHDR, f->shared->fs_page_size - 1, (H5F_mem_page_t *)&fs_type); + if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + TEST_ERROR + + /* Since we are about to open a self referential free space + * manager prior to the first file space allocation / deallocation + * call H5MF_tidy_self_referential_fsm_hack() first so as to avoid + * assertion failures on the first file space alloc / dealloc. + */ + if(f->shared->first_alloc_dealloc){ + if(SUCCEED!=H5MF_tidy_self_referential_fsm_hack(f,H5AC_ind_read_dxpl_id)) + FAIL_STACK_ERROR + } + + /* Set up to use the small meta data manager */ + if(!(f->shared->fs_man[fs_type])) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, fs_type) < 0) + TEST_ERROR + + /* Verify that the freed block with addr2 is found from the small meta data manager */ + if(H5MF_find_sect(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)(f->shared->fs_page_size-(addr3+TBLOCK_SIZE50)), f->shared->fs_man[fs_type], &found_addr) < 0) + TEST_ERROR + + if(found_addr != (addr3+TBLOCK_SIZE50)) + TEST_ERROR + + /* Verify that the small raw data manager is there */ + if(!H5F_addr_defined(f->shared->fs_addr[H5F_MEM_PAGE_DRAW])) + TEST_ERROR + + /* Set up to use the small raw data manager */ + if(!(f->shared->fs_man[H5F_MEM_PAGE_DRAW])) + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, H5F_MEM_PAGE_DRAW) < 0) + TEST_ERROR + + /* Verify that the freed block with saddr1 is found from the small raw data manager */ + if(H5MF_find_sect(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) + TEST_ERROR + if(found_addr != saddr1) + TEST_ERROR + + H5MF_alloc_to_fs_type(f, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); + + if(!(f->shared->fs_man[fs_type])) + /* Set up to use the large data manager */ + if(H5MF_open_fstype(f, H5AC_ind_read_dxpl_id, fs_type) < 0) + TEST_ERROR + + /* Verify that the freed block with gaddr1 is found from the large data manager */ + if(H5MF_find_sect(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], &found_addr) < 0) + TEST_ERROR + if(found_addr != gaddr1) + TEST_ERROR + + /* Close file */ + if(H5Fclose(fid) < 0) + TEST_ERROR + } /* end if fs_persist */ + } /* end for */ + + if(H5Pclose(fapl_new) < 0) + TEST_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fcpl); + H5Pclose(fapl_new); + } H5E_END_TRY; + return(1); + +} /* test_page_alloc_xfree() */ + +/*------------------------------------------------------------------------- + * Function: test_page_try_shrink + * + * Purpose: To verify that shrinking via H5MF_try_shrink() work properly + * when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_page_try_shrink(const char *env_h5_drvr, hid_t fapl) +{ + + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr1; /* Address for small meta data block */ + haddr_t saddr1; /* Address for small raw data block */ + haddr_t gaddr1; /* Address for large data block */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + htri_t status; /* status from shrinking */ + h5_stat_size_t file_size; /* File size */ + char filename[FILENAME_LEN]; /* Filename to use */ + + TESTING("Paged aggregation for file space: H5MF_try_shrink()"); + + /* Current VFD that does not support continuous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") ); + + if(contig_addr_vfd) { + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + FAIL_STACK_ERROR + + /* Allocate a small meta data block with addr1 */ + addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); + + /* Try to shrink the block with addr1 */ + if((status = H5MF_try_shrink(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE50)) < 0) + FAIL_STACK_ERROR + + /* Couldn't shrink due to the section (remaining space in the page) is in the small meta data free-space manager */ + if(status == TRUE) TEST_ERROR + + /* Allocate a small raw data block with saddr1 */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); + + /* Try to shrink the block with saddr1 */ + if((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE50)) < 0) + FAIL_STACK_ERROR + + /* Couldn't shrink due to the section (remaining space in the page) is in the small raw data free-space manager */ + if(status == TRUE) TEST_ERROR + + /* Allocate a large data block with gaddr1 */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); + + /* Try to shrink the block with gaddr1 */ + if((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr1, (hsize_t)TBLOCK_SIZE5000)) < 0) + FAIL_STACK_ERROR + + /* Couldn't shrink due to the section (remaining space in the page) is in the large-sized free-space manager */ + if(status == TRUE) TEST_ERROR + + /* Free the block with saddr1--merge to become 1 page, then return to the large manager */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE50); + + /* Merge all 3 sections and shrunk */ + H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, gaddr1, (hsize_t)TBLOCK_SIZE5000); + + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Get the size of the file */ + if((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + + /* Should be on page boundary */ + if(file_size % TBLOCK_SIZE4096) + TEST_ERROR + + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support paged aggregation"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fcpl); + } H5E_END_TRY; + return(1); + +} /* test_page_try_shrink() */ + +/*------------------------------------------------------------------------- + * Function: test_page_small_try_extend + * + * Purpose: To verify that extending a small block via H5MF_try_extend() works + * properly when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) +{ + + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr1, addr2, addr3; /* Addresses for small meta data blocks */ + haddr_t saddr1; /* Address for small raw data block */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + htri_t was_extended; /* Whether the block can be extended or not */ + char filename[FILENAME_LEN]; /* Filename to use */ + + TESTING("Paged aggregation for file space: H5MF_try_extend() a small block"); + + /* Current VFD that does not support continuous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); + + if(contig_addr_vfd) { + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + FAIL_STACK_ERROR + + /* Allocate a small meta data block with addr1 */ + addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE98); + + /* Try extending the block with addr1 at EOF not crossing page boundary */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE98, (hsize_t)3100); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* Allocate 2 small meta data blocks with addr2 and addr3--will be on another meta data page */ + addr2 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE100); + addr3 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE150); + + /* The block with addr2 should be page aligned */ + /* The block with addr3 resides right next to the block with addr2 */ + if(addr2 % TBLOCK_SIZE4096) + TEST_ERROR + if(addr3 != (addr2 + TBLOCK_SIZE100)) + TEST_ERROR + + /* Free the block with addr2 */ + H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TBLOCK_SIZE100); + + /* Try extending the block with addr1 that will cross to the next page where the freed block with addr2 resides */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, (hsize_t)TBLOCK_SIZE100); + /* Shouldn't succeed--should not cross page boundary */ + if(was_extended == TRUE) TEST_ERROR + + /* Try extending the block with addr1 into the free-space section that is big enough to fulfill the request */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, (hsize_t)TBLOCK_SIZE50); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* Free the block with addr1 */ + H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TBLOCK_SIZE3248); + + /* Allocate a new meta data block with addr1 */ + /* There is a page end threshold of size H5F_FILE_SPACE_PGEND_META_THRES at the end of the block */ + /* The block is right next to the threshold */ + addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3286); + + /* Try extending the block into the threshold with size > H5F_FILE_SPACE_PGEND_META_THRES */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, (hsize_t)TBLOCK_SIZE11); + /* Shouldn't succeed */ + if(was_extended == TRUE) TEST_ERROR + + /* Try extending the block into the threshold with size < H5F_FILE_SPACE_PGEND_META_THRES */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, (hsize_t)TBLOCK_SIZE2); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* Free the block with addr3--will merge with the remaining sections to become a page and then free the page */ + H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TBLOCK_SIZE150); + + /* Allocate a small raw data block with saddr1 */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4086); + + /* Try extending the block crossing the page boundary */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, (hsize_t)TBLOCK_SIZE11); + /* Shouldn't succeed */ + if(was_extended == TRUE) TEST_ERROR + + /* Try extending the block not crossing page boundary */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, (hsize_t)TBLOCK_SIZE10); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* The extended block is now "large" in size */ + /* Try extending the block */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4096, (hsize_t)TBLOCK_SIZE10); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* Try extending the large-sized block */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4106, (hsize_t)TBLOCK_SIZE5000); + /* Should not succeed because the mis-aligned fragment in the page is in the large-sized free-space manager */ + if(was_extended == TRUE) TEST_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support paged aggregation"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fcpl); + } H5E_END_TRY; + return(1); + +} /* test_page_small_try_extend() */ + +/*------------------------------------------------------------------------- + * Function: test_page_large_try_extend + * + * Purpose: To verify that extending a large block via H5MF_try_extend() + * is done properly when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_page_large_try_extend(const char *env_h5_drvr, hid_t fapl) +{ + + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t gaddr1, gaddr2, gaddr3, gaddr4; /* Addresses for large data blocks */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + htri_t was_extended; /* Whether the block can be extended or not */ + char filename[FILENAME_LEN]; /* Filename to use */ + + TESTING("Paged aggregation for file space: H5MF_try_extend() a large block"); + + /* Current VFD that does not support continuous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + + if(contig_addr_vfd) { + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + FAIL_STACK_ERROR + + /* Allocate a large data block with gaddr1 */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)6000); + + /* Should be page aligned */ + if(gaddr1 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Extending the block with gaddr1 at EOF to become 2 pages */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE6000, (hsize_t)TBLOCK_SIZE2192); + /* Should succeed */ + if(was_extended != TRUE) TEST_ERROR + + /* Allocate a large data block with gaddr2 */ + gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8000); + /* Should be page aligned */ + if(gaddr2 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Try extending the block with gaddr1 */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE8192, (hsize_t)TBLOCK_SIZE50); + /* Should not succeed */ + if(was_extended == TRUE) TEST_ERROR + + /* Allocate a large data block with gaddr3 */ + gaddr3 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8000); + /* Should be page aligned */ + if(gaddr3 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the request */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8000, (hsize_t)TBLOCK_SIZE100); + /* Should succeed */ + if(was_extended == FALSE) TEST_ERROR + + /* Try extending the block with gaddr2--there is no free-space section big enough to fulfill the request */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, (hsize_t)TBLOCK_SIZE100); + /* Should not succeed */ + if(was_extended == TRUE) TEST_ERROR + + /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the request */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, (hsize_t)TBLOCK_SIZE90); + /* Should succeed */ + if(was_extended == FALSE) TEST_ERROR + + /* Try extending the block with gaddr2 */ + /* There is no free-space section big enough to fulfill the request (request is < H5F_FILE_SPACE_PGEND_META_THRES) */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, (hsize_t)TBLOCK_SIZE5); + /* Should not succeed */ + if(was_extended == TRUE) TEST_ERROR + + /* Allocate a large data block with gaddr4 */ + gaddr4 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); + /* Should be page aligned */ + if(gaddr4 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Free the block with gaddr3--will merge with remaining free space to become 2 pages + section (size 2) in previous page */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr3, (hsize_t)TBLOCK_SIZE8000); + + /* Try extending the block with gaddr2 crossing page boundary--there is free-space section big enough to fulfill the request */ + was_extended = H5MF_try_extend(f, H5AC_ind_read_dxpl_id, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, (hsize_t)TBLOCK_SIZE5); + /* Should succeed */ + if(was_extended == FALSE) TEST_ERROR + + /* Close file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support paged aggregation strategy"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fcpl); + } H5E_END_TRY; + return(1); + +} /* test_page_large_try_extend() */ + +/*------------------------------------------------------------------------- + * Function: test_page_large + * + * Purpose: To verify that allocations and de-allocations for large data + * are done properly when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_page_large(const char *env_h5_drvr, hid_t fapl) +{ + + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t gaddr1, gaddr2, gaddr3, gaddr4; /* Addresses for blocks */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + h5_stat_size_t file_size; /* File size */ + char filename[FILENAME_LEN]; /* Filename to use */ + + TESTING("Paged aggregation for file space: large allocations and de-allocations"); + + /* Current VFD that does not support continuous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + + if(contig_addr_vfd) { + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + FAIL_STACK_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + FAIL_STACK_ERROR + + /* Allocate a large data block with gaddr1 */ + /* 1 page + 1904 bytes; 2192 bytes in free-space manager */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE6000); + + /* Should be page aligned */ + if(gaddr1 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Allocate a large data block with gaddr2--should be on another page */ + /* Allocate 1 page + 3904 bytes; 192 bytes in free-space manager */ + gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8000); + /* Should be page aligned */ + if(gaddr2 % TBLOCK_SIZE4096) + TEST_ERROR + + /* Allocate a large data block with gaddr3--should be on another page */ + /* Allocate 2 pages + 3808 bytes; 288 bytes in free-space manager */ + gaddr3 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE12000); + if(!H5F_addr_defined(gaddr3)) + TEST_ERROR + + /* Free the block with gaddr2 */ + /* Merged sections: 2192 + 8000 + 192 = 10384 */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr2, (hsize_t)TBLOCK_SIZE8000); + + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + FAIL_STACK_ERROR + + /* Verify that the manager contains 2 free-space sections: 10384 and 288 */ + if(fs_stat.tot_sect_count != 2) + TEST_ERROR + if(fs_stat.tot_space != (10384+288)) + TEST_ERROR + + /* Allocate a large data block with gaddr4--there is a free-space section able to fulfill the request */ + /* Free-space sections: 2192 + 3192 + 288 = 5672 bytes */ + gaddr4 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); + + /* Should be page aligned */ + if(gaddr4 % TBLOCK_SIZE4096) + TEST_ERROR + if(gaddr4 != gaddr2) + TEST_ERROR + + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + FAIL_STACK_ERROR + /* Verify that that there are 3 free-space sections */ + if(fs_stat.tot_sect_count != 3) + TEST_ERROR + if(fs_stat.tot_space != (2192+3192+288)) + TEST_ERROR + + /* Free the two blocks with gaddr1 and gaddr4 */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr1, (hsize_t)TBLOCK_SIZE6000); + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, gaddr4, (hsize_t)TBLOCK_SIZE5000); + + /* Get free-space info */ + if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + FAIL_STACK_ERROR + /* Verify that that there are 2 free-space sections: 16384 (4 pages) + 288 */ + if(fs_stat.tot_sect_count != 2) + TEST_ERROR + if(fs_stat.tot_space != (16384+288)) + TEST_ERROR + + /* Close file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR + + /* Get the size of the file */ + if((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + + /* Verify that file size end on a page boundary */ + if(file_size % TBLOCK_SIZE4096) + TEST_ERROR + + PASSED() + + } else { + SKIPPED(); + puts(" Current VFD doesn't support paged aggregation strategy"); + } + + return(0); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); } H5E_END_TRY; return(1); -} /* test_mf_fs_multi() */ - -#define MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) { \ - H5FD_mem_t mt; \ - HDmemset(memb_map, 0, sizeof memb_map); \ - HDmemset(memb_fapl, 0, sizeof memb_fapl); \ - HDmemset(memb_name, 0, sizeof memb_name); \ - HDmemset(memb_addr, 0, sizeof memb_addr); \ - HDmemset(sv, 0, sizeof sv); \ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { \ - memb_map[mt] = H5FD_MEM_SUPER; \ - memb_fapl[mt] = H5P_DEFAULT; \ - } \ - memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; \ - memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \ - memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \ - memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \ - sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \ - memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \ - memb_addr[H5FD_MEM_SUPER] = 0; \ - sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \ - memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \ - memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6; \ - sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \ - memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \ - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3; \ - sprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \ - memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \ - memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2; \ - sprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \ - memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \ - memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3; \ - sprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \ - memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \ - memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6; \ -} -/* - * Tests to verify that file's free-space managers are persistent or going away - * for different drivers. +} /* test_page_large() */ + +/*------------------------------------------------------------------------- + * Function: test_page_small + * + * Purpose: To verify allocations and de-allocations for small meta/raw data + * are done properly when paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- */ static unsigned -test_mf_fs_drivers(hid_t fapl) +test_page_small(const char *env_h5_drvr, hid_t fapl) { - hid_t fcpl = -1; /* file creation property list */ - hid_t fapl_new = -1; /* copy of file access property list */ - hid_t fapl2 = -1; /* copy of file access property list */ - unsigned new_format; /* To use new library format or not */ - unsigned ret = 0; /* return value */ - - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ - hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ - char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ - const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ - haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ - - /* Create a non-standard file-creation template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR - if(H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0) < 0) - TEST_ERROR - - /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - TEST_ERROR - - /* Test with old and new format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - - if(new_format) - HDputs("Testing the following tests for free-space managers with new library format..."); - else - HDputs("Testing the following tests for free-space managers with old library format..."); - - /* SEC2 */ - HDputs("Testing free-space manager(s) with sec2 driver"); - - if((fapl_new = H5Pcopy(new_format ? fapl2 : fapl)) < 0) TEST_ERROR - - if(H5Pset_fapl_sec2(fapl_new) < 0) - FAIL_STACK_ERROR - - ret += test_mf_fs_gone(fapl_new, fcpl); - ret += test_mf_fs_persist(fapl_new, fcpl); - - h5_clean_files(FILENAME, fapl_new); + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr2, addr3, addr4, addr5; /* Addresses for blocks */ + haddr_t addr9, addr10, addr11; /* Address for small meta data blocks */ + haddr_t saddr1, saddr2; /* Addresses for small raw data blocks */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + char filename[FILENAME_LEN]; /* Filename to use */ + hbool_t multi= FALSE, split = FALSE, family = FALSE; + + TESTING("Paged aggregation for file space: small allocations and de-allocations"); + if(!HDstrcmp(env_h5_drvr, "split")) + split = TRUE; + else if(!HDstrcmp(env_h5_drvr, "multi")) + multi = TRUE; + else if(!HDstrcmp(env_h5_drvr, "family")) + family = TRUE; + + if(!multi && !split) { - /* STDIO */ - HDputs("Testing free-space managers with stdio driver"); + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_stdio(fapl_new) < 0) - FAIL_STACK_ERROR + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR - ret += test_mf_fs_gone(fapl_new, fcpl); - ret += test_mf_fs_persist(fapl_new, fcpl); + /* Set the strategy to paged aggregation */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + FAIL_STACK_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR - /* CORE */ - HDputs("Testing free-space managers with core driver"); + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + FAIL_STACK_ERROR - /* create fapl to be a "core" file */ - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_core(fapl_new, (size_t)CORE_INCREMENT, TRUE) < 0) - FAIL_STACK_ERROR + /* Allocate 2 small meta data blocks: addr1, addr2 */ + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + addr2 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); - ret += test_mf_fs_gone(fapl_new, fcpl); - ret += test_mf_fs_persist(fapl_new, fcpl); + /* Allocate a small raw data block with saddr1 */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + /* Should be on the second page and page aligned */ + if(saddr1 % TBLOCK_SIZE4096) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Allocate a small raw data block with saddr2 */ + saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); + /* Should not be page aligned */ + if(!(saddr2 % TBLOCK_SIZE4096)) + TEST_ERROR + /* Should be next to the block with saddr1 */ + if(saddr2 != (saddr1 + TBLOCK_SIZE30)) + TEST_ERROR - /* FAMILY */ - HDputs("Testing free-space managers with family driver"); + /* Allocate a small meta data block with addr3--there is no free-space section big enough to fulfill the request */ + addr3 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE4020); + /* Should be on the third page and page aligned */ + if(addr3 % TBLOCK_SIZE4096) + TEST_ERROR - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_family(fapl_new, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR + /* Allocate a small meta data block with addr4--there is a free-space section big enough to fulfill the request */ + addr4 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); + /* Should not be page aligned */ + if(!(addr4 % TBLOCK_SIZE4096)) + TEST_ERROR + /* Should be next to the block with addr2 */ + if(addr4 != (addr2 + TBLOCK_SIZE50)) + TEST_ERROR - ret += test_mf_fs_persist(fapl_new, fcpl); + /* Allocate a small meta data block with addr5--there is a free-space section big enough to fulfill the request */ + addr5 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE40); + /* Should not be page aligned */ + if(!(addr5 % TBLOCK_SIZE4096)) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Should be next to the block with addr3 */ + if(addr5 != (addr3 + TBLOCK_SIZE4020)) + TEST_ERROR - /* SPLIT */ - HDputs("Testing free-space managers with split driver"); + /* Allocate a small meta data block with addr6--taking up the remaining space in the first page */ + if(family) + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3080); + else + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3088); - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_split(fapl_new, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) - FAIL_STACK_ERROR + /* Allocate a small meta data block with addr7--taking up the remaining space in the third page */ + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE36); - ret += test_mf_fs_persist(fapl_new, fcpl); - ret += test_mf_fs_split(fapl_new, fcpl); + /* Allocate 2 small meta data blocks: addr8, addr9--there is no free-space to fulfill the request */ + H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); + addr9 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); - h5_clean_files(FILENAME, fapl_new); + /* Free the block with saddr1 and saddr2--merge with remaining section to become a page which will be returned to the large manager */ + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TBLOCK_SIZE30); + H5MF_xfree(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, saddr2, (hsize_t)TBLOCK_SIZE50); - /* MULTI */ - HDputs("Testing free-space managers with multi driver"); + /* Verify that the large manager does contain a section with file space page size (default is 4096) */ + if(!f->shared->fs_man[H5F_MEM_PAGE_GENERIC]) + TEST_ERROR + if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + FAIL_STACK_ERROR + if(fs_stat.tot_space != TBLOCK_SIZE4096) + TEST_ERROR - MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) + /* Allocate a small meta data block with addr10--there is a free-space section big enough to fulfill the request */ + addr10 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE3900); + /* The block should be next to the block with addr9 */ + if(addr10 != (addr9 + TBLOCK_SIZE80)) + TEST_ERROR - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) - TEST_ERROR; + /* Allocate a small meta data block with addr11 */ + /* The current free-space section is unable to fulfill the request; obtain a page from the large manager */ + addr11 = H5MF_alloc(f, H5FD_MEM_OHDR, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); + /* The address of the block should be the same the freed block with saddr1 */ + if(addr11 != saddr1) + TEST_ERROR - ret += test_mf_fs_multi(fapl_new, fcpl); + /* Close file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Close the property list */ + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR - } /* end for new_format */ + PASSED() - if(H5Pclose(fcpl) < 0) - FAIL_STACK_ERROR - if(H5Pclose(fapl2) < 0) - FAIL_STACK_ERROR + } else { + SKIPPED(); + puts(" Current VFD doesn't support paged aggregation strategy"); + } - return(ret); + return(0); error: H5E_BEGIN_TRY { + H5Fclose(fid); H5Pclose(fcpl); - H5Pclose(fapl2); - H5Pclose(fapl_new); } H5E_END_TRY; return(1); -} /* test_mf_fs_drivers() */ +} /* test_page_small() */ -/* - * Verify that file space management performs according to the - * file space strategy and free space threshold as specified. +/*------------------------------------------------------------------------- + * Function: test_page_alignment + * + * Purpose: To verify the proper alignment is used when H5Pset_alignment() + * is set and paged aggregation is enabled. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Vailin Choi; Jan 2013 + * + *------------------------------------------------------------------------- */ static unsigned -test_filespace_strategy_threshold(hid_t fapl_new) +test_page_alignment(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list template */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - haddr_t tmp_addr; /* Temporary variable for address */ - H5F_file_space_type_t fs_type; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ - hsize_t tot_space, saved_tot_space; /* Total amount of free space */ - hsize_t tot_sect_count, saved_tot_sect_count; /* # of free-space sections */ - - TESTING("file space strategy and threshold"); - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); - - for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { - - for(fs_type = H5F_FILE_SPACE_ALL_PERSIST; fs_type < H5F_FILE_SPACE_NTYPES; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) { - - /* Create file-creation template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR - - /* Set default file space information */ - if(H5Pset_file_space(fcpl, fs_type, fs_threshold) < 0) - FAIL_STACK_ERROR - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* Allocate 6 blocks */ - type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE6))) - FAIL_STACK_ERROR - - /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0) - FAIL_STACK_ERROR - - /* Retrieve the total amount of free space and # of free-space sections */ - if(f->shared->fs_man[type] && - H5FS_sect_stats(f->shared->fs_man[type], &saved_tot_space, &saved_tot_sect_count) < 0) - FAIL_STACK_ERROR - - /* H5F_FILE_SPACE_AGGR_VFD and H5F_FILE_SPACE_VFD: should not have free-space manager */ - if(fs_type > H5F_FILE_SPACE_ALL && f->shared->fs_man[type]) - TEST_ERROR - - /* Close the file */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - switch(fs_type) { - case H5F_FILE_SPACE_ALL_PERSIST: - if(fs_threshold <= TEST_BLOCK_SIZE5) { - if(!H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR - - /* Open the free-space manager */ - if(H5MF__alloc_open(f, H5AC_ind_read_dxpl_id, type) < 0) - FAIL_STACK_ERROR - - /* Retrieve the total amount of free space and # of free-space sections */ - if(H5FS_sect_stats(f->shared->fs_man[type], &tot_space, &tot_sect_count) < 0) - FAIL_STACK_ERROR - - /* Verify that tot_space should be >= saved_tot_space */ - /* Verify that tot_sect_count should be >= saved_tot_sect_count */ - if(tot_space < saved_tot_space || tot_sect_count < saved_tot_sect_count) - TEST_ERROR - - /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == - (tmp_addr = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - - /* Should be the same as before */ - if(tmp_addr != addr5) - TEST_ERROR - } else if(H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR - break; - - case H5F_FILE_SPACE_ALL: - case H5F_FILE_SPACE_AGGR_VFD: - case H5F_FILE_SPACE_VFD: - if(H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR - break; - - case H5F_FILE_SPACE_DEFAULT: - case H5F_FILE_SPACE_NTYPES: - default: - TEST_ERROR - break; - } /* end switch */ - - /* Closing */ - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) - FAIL_STACK_ERROR - } /* end for fs_type */ - } /* end for fs_threshold */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fcpl2 = -1; /* File creation property list ID */ + hid_t fapl_new = -1; /* File access property list ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + haddr_t addr1, addr2; /* Addresses for small meta data blocks */ + haddr_t saddr1, saddr2; /* Addresses for small raw data blocks */ + haddr_t gaddr1, gaddr2; /* Addresses for blocks */ + char filename[FILENAME_LEN]; /* Filename to use */ + hbool_t split = FALSE, multi = FALSE; - PASSED() - - return(0); + TESTING("Paged aggregation and H5Pset_alignment: verify proper alignment is used"); -error: - H5E_BEGIN_TRY { - H5Pclose(fcpl); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_filespace_strategy_threshold() */ + /* Check for split or multi driver */ + if(!HDstrcmp(env_h5_drvr, "split")) + split = TRUE; + else if(!HDstrcmp(env_h5_drvr, "multi")) + multi = TRUE; + + if(!multi && !split) { -/* - * Verify section is merged/shrunk away for - * H5F_FILE_SPACE_ALL_PERSIST and H5F_FILE_SPACE_ALL strategy. - */ -static unsigned -test_filespace_gone(hid_t fapl_new) -{ - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation propertly list template */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - H5F_file_space_type_t fs_type; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ - frspace_state_t state; /* State of free space manager */ - - TESTING("file space merge/shrink for section size < threshold"); + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename)); - - /* Set free-space threshold */ - fs_threshold = TEST_THRESHOLD3; - - for(fs_type = H5F_FILE_SPACE_ALL_PERSIST; fs_type <= H5F_FILE_SPACE_ALL; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) { - /* Create file-creation template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR - - /* Set default file space information */ - if(H5Pset_file_space(fcpl, fs_type, fs_threshold) < 0) - FAIL_STACK_ERROR - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* Allocate 6 blocks */ - type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE1))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE2))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE3))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE4))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE5))) - FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE6))) - FAIL_STACK_ERROR - - /* Put block #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0) - FAIL_STACK_ERROR - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0) - FAIL_STACK_ERROR - - HDmemset(&state, 0, sizeof(frspace_state_t)); - state.tot_space += TEST_BLOCK_SIZE3 + TEST_BLOCK_SIZE5; - state.tot_sect_count += 2; - state.serial_sect_count += 2; - - if(check_stats(f, f->shared->fs_man[type], &state)) - TEST_ERROR - - /* section #2 is less than threshold but is merged into section #3 */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr2, (hsize_t)TEST_BLOCK_SIZE2) < 0) - FAIL_STACK_ERROR - - state.tot_space += TEST_BLOCK_SIZE2; - if(check_stats(f, f->shared->fs_man[type], &state)) - TEST_ERROR - - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TEST_BLOCK_SIZE4) < 0) - FAIL_STACK_ERROR - - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr6, (hsize_t)TEST_BLOCK_SIZE6) < 0) - FAIL_STACK_ERROR - - /* all sections should be shrunk away except section #1 */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, f->shared->fs_man[type], &state)) - TEST_ERROR - - /* section #1 is less than threshold but is shrunk away */ - if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0) - FAIL_STACK_ERROR - - /* free-space manager should be empty */ - HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, f->shared->fs_man[type], &state)) - TEST_ERROR - - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* free-space manager should be empty */ - if(H5F_addr_defined(f->shared->fs_addr[type])) - TEST_ERROR - - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - if(H5Pclose(fcpl) < 0) - FAIL_STACK_ERROR - - } /* end for fs_type */ + /* + * Case 1: Verify that the alignment in use is the default file space + * page size when paged aggregation is enabled. + */ - PASSED() + if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR - return(0); + /* The alignment to use will be the library's default file space page size */ + if(H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR -error: - H5E_BEGIN_TRY { - H5Pclose(fcpl); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_filespace_gone() */ + /* Set alignment value to 16 */ + if(H5Pset_alignment(fapl_new, (hsize_t)0, (hsize_t)TEST_ALIGN16) < 0) + TEST_ERROR -/* - * Tests to verify file space management for different drivers. - */ -static unsigned -test_filespace_drivers(hid_t fapl) -{ - hid_t fapl_new = -1; /* copy of file access property list */ - hid_t fapl2 = -1; /* copy of file access property list */ - unsigned new_format; /* Using library new format or not */ - unsigned ret = 0; /* return value */ + if(split || multi) { + hid_t memb_fapl; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char *memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ - hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ - char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ - const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ - haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ + /* Create fapl */ + if((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR - /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + /* Set alignment */ + if(H5Pset_alignment(memb_fapl, 0, (hsize_t)TEST_ALIGN16) < 0) + TEST_ERROR - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - TEST_ERROR + HDmemset(memb_name, 0, sizeof memb_name); - /* Test with old and new format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + if(split) { + /* Set split driver with new FAPLs */ + if(H5Pset_fapl_split(fapl_new, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) + TEST_ERROR - if(new_format) - HDputs("Testing the following tests for file space management with new library format..."); - else - HDputs("Testing the following tests for file space management with old library format..."); + /* Get current multi settings */ + if(H5Pget_fapl_multi(fapl_new, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + TEST_ERROR - /* SEC2 */ - HDputs("Testing file space management with sec2 driver"); + /* Set memb_addr aligned */ + memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; + memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_sec2(fapl_new) < 0) - FAIL_STACK_ERROR + /* Set split driver with new FAPLs */ + if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + TEST_ERROR - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + } else { + /* Get current multi settings */ + if(H5Pget_fapl_multi(fapl_new, memb_map, NULL, memb_name, memb_addr, &relax) < 0) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Populate memb_fapl_arr */ + /* Set memb_addr aligned */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { + memb_fapl_arr[mt] = memb_fapl; + memb_addr[mt] = ((memb_addr[mt] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; + } - /* STDIO */ - HDputs("Testing file space management with stdio driver"); + /* Set multi driver with new FAPLs */ + if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + TEST_ERROR - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_stdio(fapl_new) < 0) - FAIL_STACK_ERROR + } /* end else */ - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + /* Free memb_name */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + free(memb_name[mt]); - h5_clean_files(FILENAME, fapl_new); + /* Close memb_fapl */ + if(H5Pclose(memb_fapl) < 0) + TEST_ERROR + } /* end if */ - /* CORE */ - HDputs("Testing file space management with core driver"); + /* File creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR - /* create fapl to be a "core" file */ - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_core(fapl_new, (size_t)CORE_INCREMENT, TRUE) < 0) - FAIL_STACK_ERROR + /* Set the strategy to paged aggregation and persisting free space */ + /* The alignment to use will be the library's default file space page size */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + TEST_ERROR + + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + TEST_ERROR - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Allocate 2 small raw data blocks */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); - /* FAMILY */ - HDputs("Testing file space managers with family driver"); + /* Should be on the second page and page aligned on 4096 (default file space page size) */ + if(saddr1 % TBLOCK_SIZE4096) + TEST_ERROR - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_family(fapl_new, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR + /* Should be next to the block with saddr1 */ + if(saddr2 != (saddr1 + TBLOCK_SIZE30)) + TEST_ERROR - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + /* Allocate 2 large raw data blocks */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); + gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE8000); - h5_clean_files(FILENAME, fapl_new); + /* Should be on the 3rd page and page aligned */ + if(gaddr1 % TBLOCK_SIZE4096) + TEST_ERROR + /* Should be on the 4th page and page aligned */ + if(gaddr2 % TBLOCK_SIZE4096) + TEST_ERROR - /* SPLIT */ - HDputs("Testing file space managers with split driver"); + /* Close the file creation property list */ + if(H5Pclose(fcpl) < 0) + TEST_ERROR - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - FAIL_STACK_ERROR - if(H5Pset_fapl_split(fapl_new, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) - FAIL_STACK_ERROR + /* Close file */ + if(H5Fclose(fid) < 0) + TEST_ERROR - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + /* + * Case 2: Verify that the alignment in use is the alignment set + * via H5Pset_alignment when paged aggregation not enabled. + */ + /* fapl_new has latest format and H5Pset_alignment set */ + /* Disable small data block mechanism */ + if(H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) + TEST_ERROR + /* Disable meta data block mechanism */ + if(H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Create the file to work on */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new)) < 0) + TEST_ERROR - /* MULTI */ - HDputs("Testing file space managers with multi driver"); + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(fid))) + TEST_ERROR - MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) + /* Allocate 2 small meta data blocks */ + addr1 = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + addr2 = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); - if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0) - TEST_ERROR - if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) - TEST_ERROR; + /* Should be aligned on 16 */ + if(addr1 % TEST_ALIGN16 || addr2 % TEST_ALIGN16) + TEST_ERROR - ret += test_filespace_strategy_threshold(fapl_new); - ret += test_filespace_gone(fapl_new); + /* addr2 should be right next to the block with addr1 */ + if((addr1 + TBLOCK_SIZE30) % TEST_ALIGN16) + if(addr2 != (((addr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + TEST_ERROR - h5_clean_files(FILENAME, fapl_new); + /* Allocate 2 small raw data blocks */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE80); + saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE100); - } /* end for new_format */ + /* Should be aligned on 16 */ + if(saddr1 % TEST_ALIGN16 || saddr2 % TEST_ALIGN16) + TEST_ERROR - if (H5Pclose(fapl2) < 0) - FAIL_STACK_ERROR + if(!multi && !split) { + /* saddr1 should be right next to the block with addr2 */ + if((addr2 + TBLOCK_SIZE50) % TEST_ALIGN16) + if(saddr1 != (((addr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + TEST_ERROR + } - return(ret); + /* saddr2 should be right next to the block with saddr1 */ + if((saddr1 + TBLOCK_SIZE80) % TEST_ALIGN16) + if(saddr2 != (((saddr1 + TBLOCK_SIZE80) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + TEST_ERROR -error: - H5E_BEGIN_TRY { - H5Pclose(fapl_new); - H5Pclose(fapl2); - } H5E_END_TRY; - return(1); -} /* test_filespace_drivers() */ + /* Close file */ + if(H5Fclose(fid) < 0) + TEST_ERROR -/* - * To verify that file space is allocated from the corresponding free-space manager - * because H5FD_FLMAP_DICHOTOMY is used as the default free-list mapping. - * - * (1) Allocate the first block (size 30) of type H5FD_MEM_SUPER - * (2) Allocate the second block (size 50) of type H5FD_MEM_SUPER - * - * (3) Allocate the first block (size 30) of type H5FD_MEM_DRAW - * - * (4) Free the first block (size 30) of type H5FD_MEM_SUPER - * - * (5) Allocate the second block (size 30) of type H5FD_MEM_DRAW - * (6) Verify that this second block is not the freed block from (3) - * - * (7) Allocate the second block (size 30) of type H5FD_MEM_DRAW - * (8) Free the first block (size 30) of type H5FD_MEM_DRAW - * - * (9) Allocate the third block (size 30) of type H5FD_MEM_SUPER - * (10) Verify that this third block is not freed block from (8) - */ -static unsigned -test_dichotomy(const char *env_h5_drvr, hid_t fapl) -{ - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype; - haddr_t addr1, addr3, saddr1, saddr2; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + /* + * Case 3: Verify that the alignment in use is the alignment set + * via H5Pset_alignment when paged aggregation not enabled. + */ + /* File creation property list */ + if((fcpl2 = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR - TESTING("Allocation from raw or metadata free-space manager"); + /* Set file space page size */ + if(H5Pset_file_space_page_size(fcpl2, (hsize_t)TBLOCK_SIZE8192) < 0) + TEST_ERROR - /* Skip test when using VFDs that don't use the metadata aggregator */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + /* Set strategy to H5F_FSPACE_STRATEGY_AGGR but meta/raw data block is 0 as set in fapl_new */ + if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + TEST_ERROR - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + /* fapl_new has latest format, H5Pset_alignment set, and disable meta/raw block */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl2, fapl_new)) < 0) + TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* Allocate the first block of type H5FD_MEM_SUPER */ - type = H5FD_MEM_SUPER; - addr1 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); - - /* Allocate the second block of type H5FD_MEM_SUPER */ - H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE50); - - /* Allocate the first block of type H5FD_MEM_DRAW */ - stype = H5FD_MEM_DRAW; - saddr1 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + if(NULL == (f = (H5F_t *)H5I_object(fid))) + TEST_ERROR + + /* Allocate 2 small raw data blocks */ + saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE30); + saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE50); - /* Free the first block of type H5FD_MEM_SUPER */ - H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr1, (hsize_t)TEST_BLOCK_SIZE30); + /* Should be aligned on 16 */ + if(saddr1 % TEST_ALIGN16) + TEST_ERROR + if(saddr2 % TEST_ALIGN16) + TEST_ERROR - /* Allocate the second block of type H5FD_MEM_DRAW */ - saddr2 = H5MF_alloc(f, stype, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + /* saddr2 should be right next to the block with saddr1 */ + if((saddr1 + TBLOCK_SIZE30) % TEST_ALIGN16) + if(saddr2 != (((saddr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + TEST_ERROR - /* Verify that saddr1 is not addr1 */ - if(saddr2 == addr1) TEST_ERROR + /* Allocate a large raw data block */ + gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, (hsize_t)TBLOCK_SIZE5000); - /* Free the first block of type H5FD_MEM_DRAW */ - H5MF_xfree(f, stype, H5AC_ind_read_dxpl_id, saddr1, (hsize_t)TEST_BLOCK_SIZE30); + /* Should be aligned on 16 */ + if(gaddr1 % TEST_ALIGN16) + TEST_ERROR - /* Allocate the third block of type H5FD_MEM_SUPER */ - addr3 = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)TEST_BLOCK_SIZE30); + /* gaddr1 is right next to the block with saddr2 */ + if((saddr2 + TBLOCK_SIZE50) % TEST_ALIGN16) + if(gaddr1 != (((saddr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + TEST_ERROR - /* Verify that addr3 is not saddr1 */ - if(addr3 == saddr1) TEST_ERROR + /* There is no free-space manager involved for H5F_FSPACE_STRATEGY_AGGR strategy */ + if(f->shared->fs_man[H5FD_MEM_DRAW] || f->shared->fs_man[H5FD_MEM_SUPER]) + TEST_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + /* Closing */ + if(H5Fclose(fid) < 0) + TEST_ERROR + if(H5Pclose(fcpl2) < 0) + TEST_ERROR + if(H5Pclose(fapl_new) < 0) + TEST_ERROR PASSED() - } /* end if */ - else { - SKIPPED(); - puts(" Current VFD doesn't support metadata aggregator"); - } /* end else */ + + } else { + SKIPPED(); + puts(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); + } return(0); error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); + H5Pclose(fcpl); + H5Pclose(fapl_new); } H5E_END_TRY; return(1); -} /* test_dichotomy() */ + +} /* test_page_alignment() */ int main(void) @@ -7625,33 +8869,21 @@ main(void) /* Make a copy of the FAPL before adjusting the alignment */ if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR - - /* alignment is not set for the following tests */ - if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0) - TEST_ERROR - - /* meta/small data is set to 2048 for the following tests */ - if(H5Pset_meta_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0) - TEST_ERROR - if(H5Pset_small_data_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0) - TEST_ERROR - - /* interaction with file allocation */ + /* For old library format--interaction with file allocation */ nerrors += test_mf_eoa(env_h5_drvr, fapl); nerrors += test_mf_eoa_shrink(env_h5_drvr, fapl); nerrors += test_mf_eoa_extend(env_h5_drvr, fapl); - /* interaction with temporary file space allocation */ - nerrors += test_mf_tmp(env_h5_drvr, fapl); + /* For old library format */ + nerrors += test_dichotomy(new_fapl); - /* interaction with free-space manager */ + /* For old library format--interaction with free-space manager */ nerrors += test_mf_fs_start(fapl); nerrors += test_mf_fs_alloc_free(fapl); nerrors += test_mf_fs_extend(fapl); nerrors += test_mf_fs_absorb(env_h5_drvr, fapl); - nerrors += test_dichotomy(env_h5_drvr, new_fapl); - /* interaction with meta/sdata aggregator */ + /* For old library format--interaction with meta/sdata aggregator */ nerrors += test_mf_aggr_alloc1(env_h5_drvr, fapl); nerrors += test_mf_aggr_alloc2(env_h5_drvr, fapl); nerrors += test_mf_aggr_alloc3(env_h5_drvr, fapl); @@ -7662,7 +8894,7 @@ main(void) nerrors += test_mf_aggr_extend(env_h5_drvr, fapl); nerrors += test_mf_aggr_absorb(env_h5_drvr, fapl); - /* Tests for alignment */ + /* For old library format--tests for alignment */ for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; H5_INC_ENUM(test_type_t, curr_test)) { switch(curr_test) { @@ -7692,11 +8924,54 @@ main(void) nerrors += test_mf_align_alloc6(env_h5_drvr, fapl, new_fapl); } /* end for */ - /* tests to verify that file's free-space managers are persistent */ - nerrors += test_mf_fs_drivers(fapl); + /* For old and new format--interaction with temporary file space allocation */ + nerrors += test_mf_tmp(env_h5_drvr, fapl, FALSE); + nerrors += test_mf_tmp(env_h5_drvr, fapl, TRUE); - /* tests for file space management */ - nerrors += test_filespace_drivers(fapl); + /* For old and new format--free-space merge/shrunk away */ + + /* Temporary: modify to skip testing for multi/split driver: + fail file create when persisting free-space or using paged aggregation strategy */ + nerrors += test_mf_fs_gone(env_h5_drvr, fapl, FALSE); + nerrors += test_mf_fs_gone(env_h5_drvr, fapl, TRUE); + + /* Temporary: modify to skip testing multi/split driver: + fail file create when persisting free-space or using paged aggregation strategy */ + nerrors += test_mf_strat_thres_gone(env_h5_drvr, fapl, FALSE); + nerrors += test_mf_strat_thres_gone(env_h5_drvr, fapl, TRUE); + + /* For old and new format--persisting free-space */ + + /* Temporary: Modify to skip testing for multi/split driver: + fail file create when persisting free-space or using paged aggregation strategy */ + nerrors += test_mf_fs_persist(env_h5_drvr, fapl, FALSE); + nerrors += test_mf_fs_persist(env_h5_drvr, fapl, TRUE); + + /* Temporary: modify to skip testing for multi/split driver: + fail file create when persisting free-space or using paged aggregation strategy */ + nerrors += test_mf_strat_thres_persist(env_h5_drvr, fapl, FALSE); + nerrors += test_mf_strat_thres_persist(env_h5_drvr, fapl, TRUE); + + /* Temporary skipped for multi/split drivers: + fail file create when persisting free-space or using paged aggregation strategy */ +#ifdef PB_OUT + /* Tests specific for multi and split files--persisting free-space */ + nerrors += test_mf_fs_persist_split(); + nerrors += test_mf_fs_persist_multi(); +#endif + + /* + * Tests specific for file space paging + */ + /* Temporary: The following 7 tests are modified to skip testing for multi/split driver: + fail file create when persisting free-space or using paged aggregation strategy */ + nerrors += test_page_small(env_h5_drvr, fapl); + nerrors += test_page_large(env_h5_drvr, fapl); + nerrors += test_page_large_try_extend(env_h5_drvr, fapl); + nerrors += test_page_small_try_extend(env_h5_drvr, fapl); + nerrors += test_page_try_shrink(env_h5_drvr, fapl); + nerrors += test_page_alloc_xfree(env_h5_drvr, fapl); /* can handle multi/split */ + nerrors += test_page_alignment(env_h5_drvr, fapl); /* can handle multi/split */ /* tests for specific bugs */ nerrors += test_mf_bug1(env_h5_drvr, fapl); diff --git a/test/none.h5 b/test/none.h5 new file mode 100644 index 0000000..bb6ff56 Binary files /dev/null and b/test/none.h5 differ diff --git a/test/page_buffer.c b/test/page_buffer.c new file mode 100644 index 0000000..b94ad03 --- /dev/null +++ b/test/page_buffer.c @@ -0,0 +1,2087 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*********************************************************** +* +* Test program: cache_page_buffer +* +* Tests the Page Buffer Feature. +* +*************************************************************/ + +#include "h5test.h" + +#include "H5PBprivate.h" +#include "H5Iprivate.h" + +/* + * This file needs to access private information from the H5F package. + */ +#define H5MF_FRIEND /*suppress error about including H5MFpkg */ +#include "H5MFpkg.h" + +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" + + +#define FILENAME_LEN 1024 +#define NUM_DSETS 5 +#define NX 100 +#define NY 50 + +/* helper routines */ +static unsigned create_file(char *filename, hid_t fcpl, hid_t fapl); +static unsigned open_file(char *filename, hid_t fapl, hsize_t page_size, size_t page_buffer_size); + +/* test routines */ +static unsigned test_args(hid_t fapl, const char *env_h5_drvr); +static unsigned test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr); +static unsigned test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr); +static unsigned test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr); +static unsigned test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr); + +const char *FILENAME[] = { + "filepaged", + NULL +}; + + +/*------------------------------------------------------------------------- + * Function: create_file() + * + * Purpose: The purpose of this function appears to be a smoke check + * intended to exercise the page buffer. + * + * Specifically, the function creates a file, and then goes + * through a loop in which it creates four data sets, write + * data to one of them, verifies the data written, and then + * deletes the three that it didn't write to. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + *------------------------------------------------------------------------- + */ +static unsigned +create_file(char *filename, hid_t fcpl, hid_t fapl) +{ + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t grp_id = -1; + hid_t filespace = -1; + hsize_t dimsf[2] = {NX, NY}; /* dataset dimensions */ + int *data = NULL; /* pointer to data buffer to write */ + hid_t dcpl = -1; + int i; + int num_elements; + int j; + char dset_name[10]; + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + if((grp_id = H5Gcreate2(file_id, "GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + num_elements = NX * NY; + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR + for (i=0; i < (int)num_elements; i++) + data[i] = i; + + if((filespace = H5Screate_simple(2, dimsf, NULL)) < 0) + FAIL_STACK_ERROR; + + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + FAIL_STACK_ERROR; + + for(i=0 ; ishared->page_buf == NULL) + FAIL_STACK_ERROR; + if(f->shared->page_buf->page_size != page_size) + FAIL_STACK_ERROR; + if(f->shared->page_buf->max_size != page_buffer_size) + FAIL_STACK_ERROR; + + if((grp_id = H5Gopen2(file_id, "GROUP", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + num_elements = NX * NY; + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR + + for(i=0 ; i= 0) + TEST_ERROR; + + + /* Test setting a page buffer with a size smaller than a single + * page size - should fail + */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, 512) < 0) + TEST_ERROR; + + if(H5Pset_page_buffer_size(fapl, 511, 0, 0) < 0) + TEST_ERROR; + + H5E_BEGIN_TRY { + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + + if(file_id >= 0) + TEST_ERROR; + + + /* Test setting a page buffer with sum of min meta and raw + * data percentage > 100 - should fail + */ + H5E_BEGIN_TRY { + ret = H5Pset_page_buffer_size(fapl, 512, 50, 51); + } H5E_END_TRY; + + if(ret >= 0) + TEST_ERROR; + + if(set_multi_split(env_h5_drvr, fapl, 512) != 0) + TEST_ERROR; + + /* Test setting a page buffer with a size equal to a single page size */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, 512) < 0) + TEST_ERROR; + + if(H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) + TEST_ERROR; + + if(create_file(filename, fcpl, fapl) != 0) + TEST_ERROR; + + if(open_file(filename, fapl, 512, 512) != 0) + TEST_ERROR; + + + /* Test setting a page buffer with a size slightly larger than a + * single page size + */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, 512) < 0) + TEST_ERROR; + + if(H5Pset_page_buffer_size(fapl, 513, 0, 0) < 0) + TEST_ERROR; + + if(create_file(filename, fcpl, fapl) != 0) + TEST_ERROR; + + if(open_file(filename, fapl, 512, 512) != 0) + TEST_ERROR; + + if(set_multi_split(env_h5_drvr, fapl, 4194304) != 0) + TEST_ERROR; + + + /* Test setting a large page buffer size and page size */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, 4194304) < 0) + TEST_ERROR; + + if(H5Pset_page_buffer_size(fapl, 16777216, 0, 0) < 0) + TEST_ERROR; + + if(create_file(filename, fcpl, fapl) != 0) + TEST_ERROR; + + if(open_file(filename, fapl, 4194304, 16777216) != 0) + TEST_ERROR; + + if(set_multi_split(env_h5_drvr, fapl, 1) != 0) + TEST_ERROR; + + + /* Test setting a 512 byte page buffer size and page size */ + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, 512) < 0) + TEST_ERROR; + if(H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) + TEST_ERROR; + if(create_file(filename, fcpl, fapl) != 0) + TEST_ERROR; + if(open_file(filename, fapl, 512, 512) != 0) + TEST_ERROR; + + + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + + PASSED() + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + } H5E_END_TRY; + return 1; +} /* test_args */ + + +/*------------------------------------------------------------------------- + * Function: test_raw_data_handling() + * + * Purpose: The purpose of this function appears to be a smoke check + * of raw data reads and writes via the page buffer. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + * Changes: Added base_page_cnt field as supporting code. This allows + * the test to adjust to the number of page buffer pages + * accessed during file open / create. + * + * The test for the value of base_page_cnt just after file + * open exists detect changes in library behavior. Assuming + * any such change is not indicative of other issues, these + * tests can be modified to reflect the change. + * + * JRM -- 2/23/17 + * + *------------------------------------------------------------------------- + */ + +/* Changes due to file space page size has a minimum size of 512 */ +static unsigned +test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) +{ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + H5FD_io_info_t fdio_info; + H5P_genplist_t *meta_plist = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id); + H5P_genplist_t *raw_plist = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id); + size_t base_page_cnt; + size_t page_count = 0; + int i, num_elements = 2000; + haddr_t addr = HADDR_UNDEF; + int *data = NULL; + H5F_t *f = NULL; + + TESTING("Raw Data Handling"); + + h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); + + if((fapl = H5Pcopy(orig_fapl)) < 0) + TEST_ERROR + + if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + TEST_ERROR; + + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR; + + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + TEST_ERROR; + if(H5Pset_page_buffer_size(fapl, sizeof(int)*2000, 0, 0) < 0) + TEST_ERROR; + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * Get the number of pages inserted, and verify that it is the + * the expected value. + */ + base_page_cnt = H5SL_count(f->shared->page_buf->slist_ptr); + if(base_page_cnt != 1) + TEST_ERROR; + + /* allocate space for a 2000 elements */ + if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; ishared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* update elements 300 - 450, with values 300 - - this will + bring two more pages into the page buffer. */ + for(i=0 ; i<150 ; i++) + data[i] = i+300; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), sizeof(int)*150, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + page_count += 2; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* update elements 100 - 300, this will go to disk but also update + existing pages in the page buffer. */ + for(i=0 ; i<200 ; i++) + data[i] = i+100; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*100), sizeof(int)*200, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* Update elements 225-300 - this will update an existing page in the PB */ + /* Changes: 450 - 600; 150 */ + for(i=0 ; i<150 ; i++) + data[i] = i+450; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*450), sizeof(int)*150, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* Do a full page write to block 600-800 - should bypass the PB */ + for(i=0 ; i<200 ; i++) + data[i] = i+600; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*600), sizeof(int)*200, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* read elements 800 - 1200, this should not affect the PB, and should read -1s */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*800), sizeof(int)*400, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + for (i=0; i < 400; i++) { + if(data[i] != -1) { + HDfprintf(stderr, "Read different values than written\n"); + FAIL_STACK_ERROR; + } + } + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + FAIL_STACK_ERROR; + + /* read elements 1200 - 1201, this should read -1 and bring in an + * entire page of addr 1200 + */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*1200), sizeof(int)*1, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + for (i=0; i < 1; i++) { + if(data[i] != -1) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + page_count ++; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + + /* read elements 175 - 225, this should use the PB existing pages */ + /* Changes: 350 - 450 */ + /* read elements 175 - 225, this should use the PB existing pages */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*350), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + for (i=0; i < 100; i++) { + if(data[i] != i+350) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + + /* read elements 0 - 800 using the VFD.. this should result in -1s + except for the writes that went through the PB (100-300 & 600-800) */ + fdio_info.file = f->shared->lf; + fdio_info.meta_dxpl = meta_plist; + fdio_info.raw_dxpl = raw_plist; + if(H5FD_read(&fdio_info, H5FD_MEM_DRAW, addr, sizeof(int)*800, data) < 0) + FAIL_STACK_ERROR; + i = 0; + while (i < 800) { + if((i>=100 && i<300) || (i>=600)) { + if(data[i] != i) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + else { + if(data[i] != -1) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + i++; + } + + /* read elements 0 - 800 using the PB.. this should result in all + * what we have written so far and should get the updates from the PB + */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int)*800, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + for (i=0; i < 800; i++) { + if(data[i] != i) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + + /* update elements 400 - 1400 to value 0, this will go to disk but + * also evict existing pages from the PB (page 400 & 1200 that are + * existing). + */ + for(i=0 ; i<1000 ; i++) + data[i] = 0; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*400), sizeof(int)*1000, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + page_count -= 2; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + + /* read elements 0 - 1000.. this should go to disk then update the + * buffer result 200-400 with existing pages + */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int)*1000, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + i=0; + while (i < 1000) { + if(i<400) { + if(data[i] != i) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + else { + if(data[i] != 0) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } + } + i++; + } + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + HDfree(data); + + PASSED() + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Fclose(file_id); + if(data) + HDfree(data); + } H5E_END_TRY; + return 1; +} /* test_raw_data_handling */ + + +/*------------------------------------------------------------------------- + * Function: test_lru_processing() + * + * Purpose: Basic set of tests verifying expected page buffer LRU + * management. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + * Changes: Added base_page_cnt field as supporting code. This allows + * the test to adjust to the number of page buffer pages + * accessed during file open / create. + * + * The test for the value of base_page_cnt just after file + * open exists detect changes in library behavior. Assuming + * any such change is not indicative of other issues, these + * tests can be modified to reflect the change. + * + * JRM -- 2/23/17 + * + * + *------------------------------------------------------------------------- + */ + +static unsigned +test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) +{ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + size_t base_page_cnt; + size_t page_count = 0; + int i; + int num_elements = 2000; + haddr_t addr = HADDR_UNDEF; + haddr_t search_addr = HADDR_UNDEF; + int *data = NULL; + H5F_t *f = NULL; + + TESTING("LRU Processing"); + + h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); + + if((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR + + if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + TEST_ERROR; + + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR; + + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR; + + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + FAIL_STACK_ERROR; + + if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + FAIL_STACK_ERROR; + + /* keep 2 pages at max in the page buffer */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*400, 20, 0) < 0) + FAIL_STACK_ERROR; + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * Get the number of pages inserted, and verify that it is the + * the expected value. + */ + base_page_cnt = H5SL_count(f->shared->page_buf->slist_ptr); + if(base_page_cnt != 1) + TEST_ERROR; + + /* allocate space for a 2000 elements */ + if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; ishared->page_buf->slist_ptr) != page_count + base_page_cnt) + TEST_ERROR; + + /* update elements 300 - 450, with values 300 - 449 - this will + * bring two pages into the page buffer and evict 0. + */ + for(i=0 ; i<150 ; i++) + data[i] = i+300; + + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), sizeof(int)*150, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + page_count = 2; + + /* at this point, the page buffer entry created at file open should + * have been evicted -- thus no further need to consider base_page_cnt. + */ + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* The two pages should be the ones with address 100 and 200; 0 + should have been evicted */ + /* Changes: 200, 400 */ + search_addr = addr; + if(NULL != H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + search_addr = addr + sizeof(int)*200; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + search_addr = addr + sizeof(int)*400; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* update elements 150-151, this will update existing pages in the + page buffer and move it to the top of the LRU. */ + /* Changes: 300 - 301 */ + for(i=0 ; i<1 ; i++) + data[i] = i+300; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), sizeof(int)*1, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* read elements 600 - 601, this should read -1 and bring in an + entire page of addr 600, and evict page 200 */ + /* Changes: 1200 - 1201; 1200, 400 */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*1200), sizeof(int)*1, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + for (i=0; i < 1; i++) { + if(data[i] != -1) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } /* end if */ + } /* end for */ + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* Changes: 400 */ + search_addr = addr + sizeof(int)*400; + if(NULL != H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* Changes: 200 */ + search_addr = addr + sizeof(int)*200; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* Changes: 1200 */ + search_addr = addr + sizeof(int)*1200; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + /* read elements 175 - 225, this should move 100 to the top, evict 600 and bring in 200 */ + /* Changes: 350 - 450; 200, 1200, 400 */ + if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*350), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + for (i=0; i < 100; i++) { + if(data[i] != i+350) { + HDfprintf(stderr, "Read different values than written\n"); + TEST_ERROR; + } /* end if */ + } /* end for */ + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* Changes: 1200 */ + search_addr = addr + sizeof(int)*1200; + if(NULL != H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* Changes: 200 */ + search_addr = addr + sizeof(int)*200; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* Changes: 400 */ + search_addr = addr + sizeof(int)*400; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* update elements 200 - 700 to value 0, this will go to disk but + also discarding existing pages from the PB (page 200). */ + /* Changes: 400 - 1400; 400 */ + for(i=0 ; i<1000 ; i++) + data[i] = 0; + if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*400), sizeof(int)*1000, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + page_count -= 1; + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* Changes: 200 */ + search_addr = addr + sizeof(int)*200; + if(NULL == H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + /* Changes: 400 */ + search_addr = addr + sizeof(int)*400; + if(NULL != H5SL_search(f->shared->page_buf->slist_ptr, &(search_addr))) + FAIL_STACK_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + HDfree(data); + + PASSED() + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Fclose(file_id); + if(data) + HDfree(data); + } H5E_END_TRY; + return 1; +} /* test_lru_processing */ + + +/*------------------------------------------------------------------------- + * Function: test_min_threshold() + * + * Purpose: Tests verifying observation of minimum and maximum + * raw and metadata page counts in the page buffer. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + * Changes: Added the base_raw_cnt and base_meta_cnt fields and + * supporting code. This allows the test to adjust to the + * number of page buffer pages accessed during file open / + * create. + * + * The tests for the values of base_raw_cnt and base_meta_cnt + * just after file open exist detect changes in library + * behavior. Assuming any such change is not indicative of + * other issues, these tests can be modified to reflect the + * change. + * + * JRM -- 2/23/17 + * + *------------------------------------------------------------------------- + */ + +static unsigned +test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) +{ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + size_t base_raw_cnt = 0; + size_t base_meta_cnt = 0; + size_t page_count = 0; + int i; + int num_elements = 1000; + H5PB_t *page_buf; + haddr_t meta_addr = HADDR_UNDEF; + haddr_t raw_addr = HADDR_UNDEF; + int *data = NULL; + H5F_t *f = NULL; + + TESTING("Minimum Metadata threshold Processing"); + HDprintf("\n"); + h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); + + if((fapl = H5Pcopy(orig_fapl)) < 0) + TEST_ERROR + + if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + TEST_ERROR; + + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR; + + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR; + + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + FAIL_STACK_ERROR; + + if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + FAIL_STACK_ERROR; + + HDprintf("\tMinimum metadata threshold = 100%%\n"); + + /* keep 5 pages at max in the page buffer and 5 meta page minimum */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 100, 0) < 0) + FAIL_STACK_ERROR; + + /* create the file */ + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * Get the raw and meta counts now, so we can adjust tests accordingly. + */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->page_buf); + + base_raw_cnt = f->shared->page_buf->raw_count; + base_meta_cnt = f->shared->page_buf->meta_count; + + if(base_raw_cnt != 0) + TEST_ERROR; + + if(base_meta_cnt != 1) + TEST_ERROR; + + page_buf = f->shared->page_buf; + + if(page_buf->min_meta_count != 5) + TEST_ERROR; + + if(page_buf->min_raw_count != 0) + TEST_ERROR; + + if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + /* write all raw data, this would end up in page buffer since there + * is no metadata yet + * + * Not necessarily -- opening the file may may load a metadata page. + */ + for(i=0 ; i<100 ; i++) + data[i] = i; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*400), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*600), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*800), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + page_count += 5; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(page_buf->raw_count != 5 - base_meta_cnt) + TEST_ERROR; + + /* write all meta data, this would end up in page buffer */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(page_buf->meta_count != 5) + TEST_ERROR; + + if(page_buf->raw_count != 0) + TEST_ERROR; + + /* write and read more raw data and make sure that they don't end up in + * page buffer since the minimum metadata is actually the entire + * page buffer + */ + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*350), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*500), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*750), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*900), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(page_buf->meta_count != 5) + TEST_ERROR; + + if(page_buf->raw_count != 0) + TEST_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + + + HDprintf("\tMinimum raw data threshold = 100%%\n"); + + page_count = 0; + + /* keep 5 pages at max in the page buffer and 5 raw page minimum */ + /* Changes: 1000 */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 0, 100) < 0) + TEST_ERROR; + + /* create the file */ + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * Get the raw and meta counts now, so we can adjust tests accordingly. + */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->page_buf); + + base_raw_cnt = f->shared->page_buf->raw_count; + base_meta_cnt = f->shared->page_buf->meta_count; + + if(base_raw_cnt != 0) + TEST_ERROR; + + if(base_meta_cnt != 1) + TEST_ERROR; + + page_buf = f->shared->page_buf; + + if(page_buf->min_meta_count != 0) + TEST_ERROR; + if(page_buf->min_raw_count != 5) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + TEST_ERROR; + + /* write all meta data, this would end up in page buffer since there + * is no raw data yet + */ + for(i=0 ; i<100 ; i++) + data[i] = i; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + page_count += 5; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + if(page_buf->meta_count != 5 - base_raw_cnt) + TEST_ERROR; + + /* write/read all raw data, this would end up in page buffer */ + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*400), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*600), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*800), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(page_buf->raw_count != 5) + TEST_ERROR; + + if(page_buf->meta_count != 0) + TEST_ERROR; + + /* write and read more meta data and make sure that they don't end up in + * page buffer since the minimum metadata is actually the entire + * page buffer + */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*350), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*500), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*750), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*900), sizeof(int)*50, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(page_buf->raw_count != 5) + TEST_ERROR; + + if(page_buf->meta_count != 0) + TEST_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + + + HDprintf("\tMinimum metadata threshold = 40%%, Minimum rawdata threshold = 40%%\n"); + page_count = 0; + /* keep 5 pages at max in the page buffer 2 meta pages, 2 raw pages + * minimum + */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 40, 40) < 0) + TEST_ERROR; + + /* create the file */ + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * + * However, with the current 1 metadata page inserted into the + * the page buffer, it is not necessary to track the base raw and + * metadata entry counts. + */ + + if(base_raw_cnt != 0) + TEST_ERROR; + + if(base_meta_cnt != 1) + TEST_ERROR; + page_buf = f->shared->page_buf; + + if(page_buf->min_meta_count != 2) + TEST_ERROR; + + if(page_buf->min_raw_count != 2) + TEST_ERROR; + + if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; ishared->page_buf->slist_ptr) != page_count) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 5 - base_meta_cnt) + TEST_ERROR; + + /* add 3 meta entries evicting 3 raw entries */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 3) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 2) + TEST_ERROR; + + /* adding more meta entires should replace meta entries since raw data + * is at its minimum + */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 3) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 2) + TEST_ERROR; + + /* bring existing raw entires up the LRU */ + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*750), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + /* adding 2 raw entries (even with 1 call) should only evict 1 meta + * entry and another raw entry + */ + if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*350), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 2) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 3) + TEST_ERROR; + + /* adding 2 meta entries should replace 2 entires at the bottom of the LRU */ + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*98), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*242), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 2) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 3) + TEST_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + + HDprintf("\tMinimum metadata threshold = 20%%\n"); + page_count = 0; + /* keep 5 pages at max in the page buffer and 1 meta page minimum */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 39, 0) < 0) + TEST_ERROR; + /* create the file */ + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + page_buf = f->shared->page_buf; + + if(page_buf->min_meta_count != 1) + TEST_ERROR; + if(page_buf->min_raw_count != 0) + TEST_ERROR; + + if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; ishared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + /* add 2 meta entries evicting 2 raw entries */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 2) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 3) + TEST_ERROR; + + /* bring the rest of the raw entries up the LRU */ + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*500), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*700), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*900), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + /* write one more raw entry which replace one meta entry */ + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 1) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 4) + TEST_ERROR; + + /* write one more raw entry which should replace another raw entry + * keeping min threshold of meta entries + */ + if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*300), sizeof(int)*100, H5AC_rawdata_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 1) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 4) + TEST_ERROR; + + /* write a metadata entry that should replace the metadata entry + * at the bottom of the LRU + */ + if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*500), sizeof(int)*100, H5AC_ind_read_dxpl_id, data) < 0) + FAIL_STACK_ERROR; + + if(H5SL_count(f->shared->page_buf->slist_ptr) != page_count) + FAIL_STACK_ERROR; + + if(f->shared->page_buf->meta_count != 1) + TEST_ERROR; + + if(f->shared->page_buf->raw_count != 4) + TEST_ERROR; + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + + HDfree(data); + + PASSED() + + return 0; + +error: + + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Fclose(file_id); + if(data) + HDfree(data); + } H5E_END_TRY; + + return 1; + +} /* test_min_threshold */ + + +/*------------------------------------------------------------------------- + * Function: test_stats_collection() + * + * Purpose: Tests verifying correct collection of statistics + * by the page buffer. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + * Changes: Added the base_raw_cnt and base_meta_cnt fields and + * supporting code. This allows the test to adjust to the + * number of page buffer pages accessed during file open / + * create. + * + * The tests for the values of base_raw_cnt and base_meta_cnt + * just after file open exist detect changes in library + * behavior. Assuming any such change is not indicative of + * other issues, these tests can be modified to reflect the + * change. + * + * JRM -- 2/23/17 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) +{ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int i; + int num_elements = 1000; + size_t base_raw_cnt = 0; + size_t base_meta_cnt = 0; + haddr_t meta_addr = HADDR_UNDEF; + haddr_t raw_addr = HADDR_UNDEF; + int *data = NULL; + H5F_t *f = NULL; + + TESTING("Statistics Collection"); + + h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); + + if((fapl = H5Pcopy(orig_fapl)) < 0) + TEST_ERROR + + if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + TEST_ERROR; + + if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR + + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; + + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) + TEST_ERROR; + + if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + TEST_ERROR; + + /* keep 5 pages at max in the page buffer */ + if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 20, 0) < 0) + TEST_ERROR; + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file_id))) + FAIL_STACK_ERROR; + + /* opening the file inserts one or more pages into the page buffer. + * Get the raw and meta counts now, so we can adjust the expected + * statistics accordingly. + */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->page_buf); + + base_raw_cnt = f->shared->page_buf->raw_count; + base_meta_cnt = f->shared->page_buf->meta_count; + + if(base_raw_cnt != 0) + TEST_ERROR; + + if(base_meta_cnt != 1) + TEST_ERROR; + + /* reset statistics before we begin the tests */ + if(H5Freset_page_buffering_stats(file_id) < 0) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements))) + FAIL_STACK_ERROR; + + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; ishared->page_buf->accesses[0] != 8) + TEST_ERROR; + if(f->shared->page_buf->accesses[1] != 16) + TEST_ERROR; + + if(f->shared->page_buf->bypasses[0] != 3) + TEST_ERROR; + if(f->shared->page_buf->bypasses[1] != 1) + TEST_ERROR; + + if(f->shared->page_buf->hits[0] != 0) + TEST_ERROR; + if(f->shared->page_buf->hits[1] != 4) + TEST_ERROR; + + if(f->shared->page_buf->misses[0] != 8) + TEST_ERROR; + if(f->shared->page_buf->misses[1] != 11) + TEST_ERROR; + + if(f->shared->page_buf->evictions[0] != 5 + base_meta_cnt) + TEST_ERROR; + if(f->shared->page_buf->evictions[1] != 9 + base_raw_cnt) + TEST_ERROR; + + { + unsigned accesses[2]; + unsigned hits[2]; + unsigned misses[2]; + unsigned evictions[2]; + unsigned bypasses[2]; + + if(H5Fget_page_buffering_stats(file_id, accesses, hits, misses, evictions, bypasses) < 0) + FAIL_STACK_ERROR; + + if(accesses[0] != 8) + TEST_ERROR; + if(accesses[1] != 16) + TEST_ERROR; + if(bypasses[0] != 3) + TEST_ERROR; + if(bypasses[1] != 1) + TEST_ERROR; + if(hits[0] != 0) + TEST_ERROR; + if(hits[1] != 4) + TEST_ERROR; + if(misses[0] != 8) + TEST_ERROR; + if(misses[1] != 11) + TEST_ERROR; + if(evictions[0] != 5 + base_meta_cnt) + TEST_ERROR; + if(evictions[1] != 9 + base_raw_cnt) + TEST_ERROR; + + if(H5Freset_page_buffering_stats(file_id) < 0) + FAIL_STACK_ERROR; + if(H5Fget_page_buffering_stats(file_id, accesses, hits, misses, evictions, bypasses) < 0) + FAIL_STACK_ERROR; + + if(accesses[0] != 0) + TEST_ERROR; + if(accesses[1] != 0) + TEST_ERROR; + if(bypasses[0] != 0) + TEST_ERROR; + if(bypasses[1] != 0) + TEST_ERROR; + if(hits[0] != 0) + TEST_ERROR; + if(hits[1] != 0) + TEST_ERROR; + if(misses[0] != 0) + TEST_ERROR; + if(misses[1] != 0) + TEST_ERROR; + if(evictions[0] != 0) + TEST_ERROR; + if(evictions[1] != 0) + TEST_ERROR; + } /* end block */ + + if(H5Fclose(file_id) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + HDfree(data); + + + PASSED() + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Fclose(file_id); + if(data) + HDfree(data); + } H5E_END_TRY; + + return 1; +} /* test_stats_collection */ + + +/*------------------------------------------------------------------------- + * Function: main() + * + * Purpose: Main function for the page buffer tests. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: unknown + * ?? / ?? / ?? + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + const char *env_h5_drvr = NULL; /* File Driver value from environment */ + +#ifndef H5_HAVE_PARALLEL + + h5_reset(); + + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Temporary skip testing with multi/split drivers: + * Page buffering depends on paged aggregation which is + * currently disabled for multi/split drivers. + */ + if((0 == HDstrcmp(env_h5_drvr, "multi")) || + (0 == HDstrcmp(env_h5_drvr, "split"))) { + + SKIPPED() + HDputs("Skip page buffering test because paged aggregation is disabled for multi/split drivers"); + HDexit(EXIT_SUCCESS); + } /* end if */ + + if((fapl = h5_fileaccess()) < 0) { + nerrors++; + PUTS_ERROR("Can't get VFD-dependent fapl") + } /* end if */ + + nerrors += test_args(fapl, env_h5_drvr); + nerrors += test_raw_data_handling(fapl, env_h5_drvr); + nerrors += test_lru_processing(fapl, env_h5_drvr); + nerrors += test_min_threshold(fapl, env_h5_drvr); + nerrors += test_stats_collection(fapl, env_h5_drvr); + + h5_clean_files(FILENAME, fapl); + + if(nerrors) + goto error; + + HDputs("All Page Buffering tests passed."); + +#else + SKIPPED() + HDputs("Page Buffering is disabled for parallel."); +#endif + + HDexit(EXIT_SUCCESS); + +error: + + HDprintf("***** %d Page Buffering TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + + H5E_BEGIN_TRY { + H5Pclose(fapl); + } H5E_END_TRY; + + HDexit(EXIT_FAILURE); + +} /* main() */ + diff --git a/test/paged_nopersist.h5 b/test/paged_nopersist.h5 new file mode 100644 index 0000000..b6c945a Binary files /dev/null and b/test/paged_nopersist.h5 differ diff --git a/test/paged_persist.h5 b/test/paged_persist.h5 new file mode 100644 index 0000000..f0ae836 Binary files /dev/null and b/test/paged_persist.h5 differ diff --git a/test/set_extent.c b/test/set_extent.c index a992419..17dc6a0 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -139,6 +139,15 @@ int main( void ) unsigned new_format; /* Whether to use the latest file format */ unsigned chunk_cache; /* Whether to enable chunk caching */ int nerrors = 0; + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + + + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + /* Current VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); /* Initialize random number seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -194,12 +203,15 @@ int main( void ) H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Tests which use chunked datasets */ - nerrors += do_ranks( my_fapl, new_format ) < 0 ? 1 : 0; + if(!new_format || (new_format && contig_addr_vfd)) + nerrors += do_ranks( my_fapl, new_format ) < 0 ? 1 : 0; } /* end for */ /* Tests which do not use chunked datasets */ - nerrors += test_external( fapl ) < 0 ? 1 : 0; - nerrors += do_layouts( fapl ) < 0 ? 1 : 0; + if(!new_format || (new_format && contig_addr_vfd)) { + nerrors += test_external( fapl ) < 0 ? 1 : 0; + nerrors += do_layouts( fapl ) < 0 ? 1 : 0; + } } /* end for */ /* Close 2nd FAPL */ diff --git a/test/stab.c b/test/stab.c index f81bb5f..00aee21 100644 --- a/test/stab.c +++ b/test/stab.c @@ -96,7 +96,7 @@ const char *FILENAME[] = { *------------------------------------------------------------------------- */ static int -test_misc(hid_t fapl, hbool_t new_format) +test_misc(hid_t fcpl, hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t g1 = (-1), g2 = (-1), g3 = (-1); @@ -110,7 +110,7 @@ test_misc(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR /* Create initial groups for testing, then close */ if((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -177,7 +177,7 @@ test_misc(hid_t fapl, hbool_t new_format) *------------------------------------------------------------------------- */ static int -test_long(hid_t fapl, hbool_t new_format) +test_long(hid_t fcpl, hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t g1 = (-1), g2 = (-1); @@ -192,7 +192,7 @@ test_long(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR /* Group names */ name1 = (char *)HDmalloc((size_t)LONG_NAME_LEN); @@ -252,7 +252,7 @@ error: *------------------------------------------------------------------------- */ static int -test_large(hid_t fapl, hbool_t new_format) +test_large(hid_t fcpl, hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t cwg = (-1), dir = (-1); /* Group IDs */ @@ -267,7 +267,7 @@ test_large(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR /* * Create a directory that has so many entries that the root @@ -318,7 +318,7 @@ test_large(hid_t fapl, hbool_t new_format) *------------------------------------------------------------------------- */ static int -lifecycle(hid_t fapl2) +lifecycle(hid_t fcpl, hid_t fapl2) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group ID */ @@ -341,7 +341,7 @@ lifecycle(hid_t fapl2) /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR @@ -532,7 +532,7 @@ error: *------------------------------------------------------------------------- */ static int -long_compact(hid_t fapl2) +long_compact(hid_t fcpl, hid_t fapl2) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group ID */ @@ -546,7 +546,7 @@ long_compact(hid_t fapl2) /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR @@ -755,7 +755,7 @@ error: *------------------------------------------------------------------------- */ static int -no_compact(hid_t fapl2) +no_compact(hid_t fcpl, hid_t fapl2) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group ID */ @@ -772,7 +772,7 @@ no_compact(hid_t fapl2) /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR @@ -1165,9 +1165,20 @@ error: int main(void) { - hid_t fapl, fapl2; /* File access property list IDs */ - unsigned new_format; /* Whether to use the new format or not */ - int nerrors = 0; + hid_t fapl, fapl2; /* File access property list IDs */ + hid_t fcpl, fcpl2; /* File creation property list ID */ + unsigned new_format; /* Whether to use the new format or not */ + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + int nerrors = 0; + + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* VFD that does not support contigous address space */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); /* Reset library */ h5_reset(); @@ -1179,20 +1190,42 @@ main(void) /* Set the "use the latest version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + /* Set up file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR + if((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR + + /* Set to use paged aggregation strategy and persisting free-space */ + /* Skip testing for multi/split drivers */ + if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) + TEST_ERROR + /* Loop over using new group format */ for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl = fapl; + hid_t my_fcpl = fcpl; + + if(!contig_addr_vfd) + continue; + + if(new_format) { + my_fapl = fapl2; + my_fcpl = fcpl2; /* Set to use paged aggregation and persisting free-space */ + } + /* Perform basic tests, with old & new style groups */ - nerrors += test_misc((new_format ? fapl2 : fapl), new_format); - nerrors += test_long((new_format ? fapl2 : fapl), new_format); - nerrors += test_large((new_format ? fapl2 : fapl), new_format); + nerrors += test_misc(my_fcpl, my_fapl, new_format); + nerrors += test_long(my_fcpl, my_fapl, new_format); + nerrors += test_large(my_fcpl, my_fapl, new_format); } /* end for */ /* New format group specific tests (require new format features) */ - nerrors += lifecycle(fapl2); - nerrors += long_compact(fapl2); - nerrors += read_old(); - nerrors += no_compact(fapl2); - nerrors += gcpl_on_root(fapl2); + if(contig_addr_vfd) { + nerrors += lifecycle(fcpl2, fapl2); + nerrors += long_compact(fcpl2, fapl2); + nerrors += read_old(); + nerrors += no_compact(fcpl2, fapl2); + nerrors += gcpl_on_root(fapl2); + } /* Old group API specific tests */ nerrors += old_api(fapl); @@ -1200,6 +1233,8 @@ main(void) /* Close 2nd FAPL */ H5Pclose(fapl2); + H5Pclose(fcpl); + H5Pclose(fcpl2); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); diff --git a/test/testfiles/plist_files/def_fcpl_32be b/test/testfiles/plist_files/def_fcpl_32be index 38dec23..9a67dd5 100644 Binary files a/test/testfiles/plist_files/def_fcpl_32be and b/test/testfiles/plist_files/def_fcpl_32be differ diff --git a/test/testfiles/plist_files/def_fcpl_32le b/test/testfiles/plist_files/def_fcpl_32le index 38dec23..9a67dd5 100644 Binary files a/test/testfiles/plist_files/def_fcpl_32le and b/test/testfiles/plist_files/def_fcpl_32le differ diff --git a/test/testfiles/plist_files/def_fcpl_64be b/test/testfiles/plist_files/def_fcpl_64be index 38dec23..9a67dd5 100644 Binary files a/test/testfiles/plist_files/def_fcpl_64be and b/test/testfiles/plist_files/def_fcpl_64be differ diff --git a/test/testfiles/plist_files/def_fcpl_64le b/test/testfiles/plist_files/def_fcpl_64le index 38dec23..9a67dd5 100644 Binary files a/test/testfiles/plist_files/def_fcpl_64le and b/test/testfiles/plist_files/def_fcpl_64le differ diff --git a/test/testfiles/plist_files/fcpl_32be b/test/testfiles/plist_files/fcpl_32be index 3ce8bf4..4a8ac8a 100644 Binary files a/test/testfiles/plist_files/fcpl_32be and b/test/testfiles/plist_files/fcpl_32be differ diff --git a/test/testfiles/plist_files/fcpl_32le b/test/testfiles/plist_files/fcpl_32le index 3ce8bf4..4a8ac8a 100644 Binary files a/test/testfiles/plist_files/fcpl_32le and b/test/testfiles/plist_files/fcpl_32le differ diff --git a/test/testfiles/plist_files/fcpl_64be b/test/testfiles/plist_files/fcpl_64be index 3ce8bf4..4a8ac8a 100644 Binary files a/test/testfiles/plist_files/fcpl_64be and b/test/testfiles/plist_files/fcpl_64be differ diff --git a/test/testfiles/plist_files/fcpl_64le b/test/testfiles/plist_files/fcpl_64le index 3ce8bf4..4a8ac8a 100644 Binary files a/test/testfiles/plist_files/fcpl_64le and b/test/testfiles/plist_files/fcpl_64le differ diff --git a/test/tfile.c b/test/tfile.c index 6987493..295a29c 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -104,13 +104,13 @@ /* Declarations for test_filespace_*() */ #define FILENAME_LEN 1024 /* length of file name */ -#define CORE_INCREMENT 1024 /* core file */ -#define FAMILY_SIZE 1024 /* family file */ #define DSETNAME "dset" /* Name of dataset */ #define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ #define READ_OLD_BUFSIZE 1024 /* Buffer for holding file data */ #define FILE5 "tfile5.h5" /* Test file */ #define TEST_THRESHOLD10 10 /* Free space section threshold */ +#define FSP_SIZE_DEF 4096 /* File space page size default */ +#define FSP_SIZE512 512 /* File space page size */ /* Declaration for test_libver_macros2() */ #define FILE6 "tfile6.h5" /* Test file */ @@ -125,17 +125,30 @@ const char *OLD_FILENAME[] = { "filespace_1_6.h5", /* 1.6 HDF5 file */ "filespace_1_8.h5" /* 1.8 HDF5 file */ }; -const char *FILESPACE_NAME[] = { - "tfilespace", - NULL + +/* Files created in 1.10.0 release --used in test_filespace_1.10.0_compatible() */ +/* These files are copied from release 1.10.0 tools/h5format_convert/testfiles */ +const char *OLD_1_10_0_FILENAME[] = { + "h5fc_ext1_i.h5", /* 0 */ + "h5fc_ext1_f.h5", /* 1 */ + "h5fc_ext2_if.h5", /* 2 */ + "h5fc_ext2_sf.h5", /* 3 */ + "h5fc_ext3_isf.h5", /* 4 */ + "h5fc_ext_none.h5" /* 5 */ }; -const char *FILENAME[] = { - "sec2_tfile", - "split_tfile", - "stdio_tfile", - "core_tfile", - "family_tfile", +/* Files used in test_filespace_round_compatible() */ +const char *FSPACE_FILENAMES[] = { + "fsm_aggr_nopersist.h5", /* H5F_FILE_SPACE_AGGR, not persisting free-space */ + "fsm_aggr_persist.h5", /* H5F_FILE_SPACE_AGGR, persisting free-space */ + "paged_nopersist.h5", /* H5F_FILE_SPACE_PAGE, not persisting free-space */ + "paged_persist.h5", /* H5F_FILE_SPACE_PAGE, persisting free-space */ + "aggr.h5", /* H5F_FILE_SPACE_AGGR */ + "none.h5" /* H5F_FILE_SPACE_NONE */ +}; + +const char *FILESPACE_NAME[] = { + "tfilespace", NULL }; @@ -1538,112 +1551,7 @@ test_file_perm2(void) CHECK(ret, FAIL, "H5Sclose"); } /* end test_file_perm2() */ -/**************************************************************** -** -** test_file_freespace(): low-level file test routine. -** This test checks the free space available in a file in various -** situations. -** -** Modifications: -** Vailin Choi; July 2012 -** Remove datasets in reverse order so that all file spaces are shrunk. -** (A change due to H5FD_FLMAP_DICHOTOMY.) -** -*****************************************************************/ -static void -test_file_freespace(void) -{ - hid_t file; /* File opened with read-write permission */ - h5_stat_size_t empty_filesize; /* Size of file when empty */ - h5_stat_size_t mod_filesize; /* Size of file after being modified */ - hssize_t free_space; /* Amount of free space in file */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - int k; /* Local index variable */ - unsigned u; /* Local index variable */ - char name[32]; /* Dataset name */ - herr_t ret; - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Low-Level File Free Space\n")); - - /* Create an "empty" file */ - file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(file, FAIL, "H5Fcreate"); - - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - /* Get the "empty" file size */ - empty_filesize = h5_get_file_size(FILE1, H5P_DEFAULT); - - /* Re-open the file (with read-write permission) */ - file = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file, "H5Fopen"); - - /* Check that the free space is 0 */ - free_space = H5Fget_freespace(file); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, 0, "H5Fget_freespace"); - - /* Create dataspace for datasets */ - dspace = H5Screate(H5S_SCALAR); - CHECK(dspace, FAIL, "H5Screate"); - - /* Create a dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); - - /* Set the space allocation time to early */ - ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); - CHECK(ret, FAIL, "H5Pset_alloc_time"); - - /* Create datasets in file */ - for(u = 0; u < 10; u++) { - sprintf(name, "Dataset %u", u); - dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(dset, FAIL, "H5Dcreate2"); - - ret = H5Dclose(dset); - CHECK(ret, FAIL, "H5Dclose"); - } /* end for */ - - /* Close dataspace */ - ret = H5Sclose(dspace); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close dataset creation property list */ - ret = H5Pclose(dcpl); - CHECK(ret, FAIL, "H5Pclose"); - - /* Check that there is the right amount of free space in the file */ - free_space = H5Fget_freespace(file); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, 2360, "H5Fget_freespace"); - - /* Delete datasets in file */ - for(k = 9; k >= 0; k--) { - sprintf(name, "Dataset %u", (unsigned)k); - ret = H5Ldelete(file, name, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Ldelete"); - } /* end for */ - - /* Check that there is the right amount of free space in the file */ - free_space = H5Fget_freespace(file); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, 0, "H5Fget_freespace"); - - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); - - /* Get the file size after modifications*/ - mod_filesize = h5_get_file_size(FILE1, H5P_DEFAULT); - /* Check that the file reverted to empty size */ - VERIFY(mod_filesize, empty_filesize, "H5Fget_freespace"); -} /* end test_file_freespace() */ /**************************************************************** ** @@ -3185,314 +3093,453 @@ test_userblock_alignment(void) /**************************************************************** ** -** test_free_sections(): -** This routine does the actual work of checking information for -** free space sections available in a file in various situations. +** test_userblock_alignment_paged(): low-level file test routine. +** This test checks to ensure that files with both a userblock and +** alignment interact properly: +** -- alignment via H5Pset_alignment +** -- alignment via paged aggregation +** +** Programmer: Vailin Choi; March 2013 ** *****************************************************************/ static void -test_free_sections(hid_t fapl, char *fname) +test_userblock_alignment_paged(void) { - hid_t file; /* File ID */ - hid_t fcpl; /* File creation property list template */ - hssize_t free_space; /* Amount of free space in file */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - unsigned u; /* Local index variable */ - char name[32]; /* Dataset name */ - hssize_t nsects; /* # of free-space sections */ - hssize_t saved_nsects; /* saved copy for the # of free-space sections */ - int i; /* local index variable */ - hsize_t total; /* sum of the free-space section sizes */ - hsize_t last_size; /* size of last free-space section */ - H5F_sect_info_t *sect_info; /* array to hold the free-space information */ - H5F_sect_info_t *saved_sect_info; /* array to hold the free-space information */ - herr_t ret; /* return value */ - - /* Create file-creation template */ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t fapl; /* File access property list ID */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing interaction between userblock and alignment (via paged aggregation and H5Pset_alignment)\n")); + + /* + * Case 1: + * Userblock size = 0 + * Alignment in use = 4096 + * Strategy = H5F_FILE_SPACE_PAGE; fsp_size = alignment = 4096 + * Outcome: + * Should succeed: + * userblock is 0 and alignment != 0 + */ + /* Create file creation property list with user block */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)0); + CHECK(ret, FAIL, "H5Pset_userblock"); - /* Set file space strategy and free space section threshold */ - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); - CHECK(ret, FAIL, "H5Pget_file_space"); - - /* Create the file */ - file = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(file, FAIL, "H5Fcreate"); + /* Create file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); - /* Close the FCPL */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Set the "use the latest version of the format" bounds */ + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); - /* Create dataspace for datasets */ - dspace = H5Screate(H5S_SCALAR); - CHECK(dspace, FAIL, "H5Screate"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); - /* Create a dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); - /* Set the space allocation time to early */ - ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); - CHECK(ret, FAIL, "H5Pset_alloc_time"); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Create datasets in file */ - for(u = 0; u < 10; u++) { - sprintf(name, "Dataset %u", u); - dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(dset, FAIL, "H5Dcreate2"); + /* + * Case 2a: + * Userblock size = 1024 + * Alignment in use = 512 + * Strategy = H5F_FILE_SPACE_PAGE; fsp_size = alignment = 512 + * H5Pset_alignment() is 3 + * Outcome: + * Should succeed: + * userblock (1024) is integral mult. of alignment (512) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); - ret = H5Dclose(dset); - CHECK(ret, FAIL, "H5Dclose"); - } /* end for */ + /* Create file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* Close dataspace */ - ret = H5Sclose(dspace); - CHECK(ret, FAIL, "H5Sclose"); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); - /* Close dataset creation property list */ - ret = H5Pclose(dcpl); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Delete odd-numbered datasets in file */ - for(u = 0; u < 10; u++) { - sprintf(name, "Dataset %u", u); - if(u % 2) { - ret = H5Ldelete(file, name, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Ldelete"); - } /* end if */ - } /* end for */ - - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); - - /* Re-open the file with read-only permission */ - file = H5Fopen(fname, H5F_ACC_RDONLY, fapl); - CHECK_I(file, "H5Fopen"); - - /* Get the amount of free space in the file */ - free_space = H5Fget_freespace(file); - CHECK(free_space, FAIL, "H5Fget_freespace"); - - /* Get the # of free-space sections in the file */ - saved_nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL); - CHECK(saved_nsects, FAIL, "H5Fget_free_sections"); - - /* Allocate storage for the free space section information */ - saved_sect_info = (H5F_sect_info_t *)HDcalloc((size_t)saved_nsects, sizeof(H5F_sect_info_t)); - CHECK(saved_sect_info, NULL, "HDcalloc"); - - /* Should return failure when nsects is 0 with a nonnull sect_info */ - nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, saved_sect_info); - VERIFY(nsects, FAIL, "H5Fget_free_sections"); - - /* Verify the correct # of free-space sections */ - nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)saved_nsects, saved_sect_info); - VERIFY(nsects, saved_nsects, "H5Fget_free_sections"); - - /* Verify the amount of free-space is correct */ - total = 0; - for(i = 0; i < nsects; i++) - total += saved_sect_info[i].size; - VERIFY(free_space, total, "H5Fget_free_sections"); - - /* save the last section's size */ - last_size = saved_sect_info[nsects-1].size; - - /* Allocate storage for -1 free space section information */ - sect_info = (H5F_sect_info_t *)HDcalloc((size_t)(saved_nsects - 1), sizeof(H5F_sect_info_t)); - CHECK(sect_info, NULL, "HDcalloc"); - - /* Retrieve free space info for -1 sections */ - nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(saved_nsects - 1), sect_info); - VERIFY(nsects, saved_nsects, "H5Fget_free_sections"); - - /* Verify the amount of free-space is correct */ - total = 0; - for(i = 0; i < (saved_nsects - 1); i++) { - VERIFY(sect_info[i].addr, saved_sect_info[i].addr, "H5Fget_free_sections"); - VERIFY(sect_info[i].size, saved_sect_info[i].size, "H5Fget_free_sections"); - total += sect_info[i].size; - } + /* + * Case 2b: + * Userblock size = 1024 + * Alignment in use = 3 + * Strategy = H5F_FILE_SPACE_AGGR; fsp_size = 512 + * (via default file creation property) + * H5Pset_alignment() is 3 + * Outcome: + * Should fail at file creation: + * userblock (1024) is non-integral mult. of alignment (3) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); - VERIFY(((hsize_t)free_space - last_size), total, "H5Fget_free_sections"); - HDfree(sect_info); + /* Create file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* Allocate storage for +1 free space section information */ - sect_info = (H5F_sect_info_t *)HDcalloc((size_t)(saved_nsects + 1), sizeof(H5F_sect_info_t)); - CHECK(sect_info, NULL, "HDcalloc"); + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); - /* Retrieve free-space info for +1 sections */ - nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(saved_nsects + 1), sect_info); - VERIFY(nsects, saved_nsects, "H5Fget_free_sections"); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Verify free-space info is correct */ - total = 0; - for(i = 0; i < nsects; i++) { - VERIFY(sect_info[i].addr, saved_sect_info[i].addr, "H5Fget_free_sections"); - VERIFY(sect_info[i].size, saved_sect_info[i].size, "H5Fget_free_sections"); - total += sect_info[i].size; - } + /* + * Case 3a: + * Userblock size = 512 + * Alignment in use = 512 + * Strategy is H5F_FILE_SPACE_PAGE; fsp_size = alignment = 512 + * H5Pset_alignment() is 3 + * Outcome: + * Should succeed: + * userblock (512) is equal to alignment (512) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); - VERIFY(sect_info[nsects].addr, 0, "H5Fget_free_sections"); - VERIFY(sect_info[nsects].size, 0, "H5Fget_free_sections"); - VERIFY(free_space, total, "H5Fget_free_sections"); - HDfree(sect_info); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* Verify that there is no free-space section for this type */ - nsects = H5Fget_free_sections(file, H5FD_MEM_BTREE, (size_t)0, NULL); - VERIFY(nsects, 0, "H5Fget_free_sections"); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - HDfree(saved_sect_info); + /* + * Case 3b: + * Userblock size = 512 + * Alignment in use = 3 + * Strategy is H5F_FILE_SPACE_NONE; fsp_size = 512 + * H5Pset_alignment() is 3 + * Outcome: + * Should fail at file creation: + * userblock (512) is non-integral mult. of alignment (3) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); -} /* end test_free_sections() */ + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); -/**************************************************************** -** -** test_filespace_sects(): -** This test checks free space section info for -** files created with sec2 and split drivers. -** -*****************************************************************/ -static void -test_filespace_sects(void) -{ - hid_t fapl_sec2; /* File access property id with sec2 driver */ - hid_t fapl_split; /* File access property id with split driver */ - hid_t fapl_core; /* File access property id with core driver */ - hid_t fapl_stdio; /* File access property id with stdio driver */ - hid_t fapl_family; /* File access property id with family driver */ - char filename[FILENAME_LEN]; /* Filename to use */ - herr_t ret; /* Return value */ + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); - /* SEC2 */ - MESSAGE(5, ("Testing File free space information for a sec2 file\n")); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - fapl_sec2 = H5Pcreate(H5P_FILE_ACCESS); + /* + * Case 4a: + * Userblock size = 1024 + * Alignment in use = 1023 + * Strategy is H5F_FILE_SPACE_PAGE; fsp_size = alignment = 1023 + * H5Pset_alignment() is 16 + * Outcome: + * Should fail at file creation: + * userblock (1024) is non-integral multiple of alignment (1023) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)1023); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); - ret = H5Pset_fapl_sec2(fapl_sec2); - CHECK(ret, FAIL, "H5Pset_fapl_sec2"); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl_sec2, filename, sizeof(filename)); + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); - /* perform free space information test for file with sec2 driver */ - test_free_sections(fapl_sec2, filename); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* close fapl_sec2 and remove the file */ - h5_clean_files(FILENAME, fapl_sec2); + /* + * Case 4b: + * Userblock size = 1024 + * Alignment in use = 16 + * Strategy is H5F_FILE_SPACE_FSM_AGGR; fsp_size = 1023 + * H5Pset_alignment() is 16 + * Outcome: + * Should succeed: + * userblock (512) is integral multiple of alignment (16) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)1023); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* SPLIT */ - MESSAGE(5, ("Testing File free space information for a split file\n")); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); - fapl_split = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl_split, FAIL, "h5_fileaccess"); - - ret = H5Pset_fapl_split(fapl_split, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - CHECK(ret, FAIL, "H5Pset_fapl_split"); - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[1], fapl_split, filename, sizeof(filename)); - - /* perform free space information test for file with split driver */ - test_free_sections(fapl_split, filename); - - /* close fapl and remove the file */ - h5_clean_files(FILENAME, fapl_split); - - - /* STDIO */ - MESSAGE(5, ("Testing File free space information for a stdio file\n")); - - fapl_stdio = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl_stdio, FAIL, "h5_fileaccess"); - - ret = H5Pset_fapl_stdio(fapl_stdio); - CHECK(ret, FAIL, "H5Pset_fapl_split"); - - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[2], fapl_stdio, filename, sizeof(filename)); - - /* perform free space information test for file with stdio driver */ - test_free_sections(fapl_stdio, filename); - - /* close fapl and remove the file */ - h5_clean_files(FILENAME, fapl_stdio); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + /* + * Case 5a: + * Userblock size = 512 + * Alignment in use = 1024 + * Strategy is H5F_FILE_SPACE_PAGE; fsp_size = alignment = 1024 + * H5Pset_alignment() is 16 + * Outcome: + * Should fail at file creation: + * userblock (512) is less than alignment (1024) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); - /* CORE */ - MESSAGE(5, ("Testing File free space information for a core file\n")); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16); + CHECK(ret, FAIL, "H5Pset_alignment"); - fapl_core = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl_core, FAIL, "h5_fileaccess"); + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); - ret = H5Pset_fapl_core(fapl_core, (size_t)CORE_INCREMENT, TRUE); - CHECK(ret, FAIL, "H5Pset_fapl_core"); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[3], fapl_core, filename, sizeof(filename)); + /* + * Case 5b: + * Userblock size = 512 + * Alignment in use = 16 + * Strategy is H5F_FILE_SPACE_NONE; fsp_size = 1024 + * H5Pset_alignment() is 16 + * Outcome: + * Should succed: + * userblock (512) is integral multiple of alignment (16) + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); - /* perform free space information test for file with core driver */ - test_free_sections(fapl_core, filename); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* close fapl_ and remove the file */ - h5_clean_files(FILENAME, fapl_core); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* FAMILY */ - MESSAGE(5, ("Testing File free space information for a family file\n")); + /* + * Case 6: + * Userblock size = 512 + * Alignment in use = 512 + * Strategy is H5F_FILE_SPACE_PAGE; fsp_size = alignment = 512 + * H5Pset_alignment() is 3 + * Reopen the file; H5Pset_alignment() is 1024 + * Outcome: + * Should succed: + * Userblock (512) is the same as alignment (512); + * The H5Pset_alignment() calls have no effect + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); - fapl_family = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl_family, FAIL, "h5_fileaccess"); + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); - ret = H5Pset_fapl_family(fapl_family, (hsize_t)FAMILY_SIZE, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Pset_fapl_family"); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[4], fapl_family, filename, sizeof(filename)); + /* Change alignment in FAPL */ + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* perform free space information test for file with family driver */ - test_free_sections(fapl_family, filename); + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper2(fapl, FALSE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); - /* close fapl and remove the file */ - h5_clean_files(FILENAME, fapl_family); + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); -} /* end test_filespace_sects() */ +} /* end test_userblock_alignment_paged() */ /**************************************************************** ** ** test_filespace_info(): -** Verify that the public routines H5Pget/set_file_space() -** retrieve and set the file space strategy and free space -** section threshold as specified. +** Verify the following public routines retrieve and set file space +** information correctly: +** (1) H5Pget/set_file_space_strategy(): +** Retrieve and set file space strategy, persisting free-space, +** and free-space section threshold as specified +** (2) H5Pget/set_file_space_page_size(): +** Retrieve and set the page size for paged aggregation ** ****************************************************************/ static void -test_filespace_info(void) +test_filespace_info(const char *env_h5_drvr) { - hid_t fid1, fid2; /* HDF5 File IDs */ - hid_t fapl, new_fapl; /* File access property */ - hid_t fcpl, fcpl1, fcpl2; /* File creation property */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_file_space_type_t strategy, fs_type, def_type; /* File space handling strategy */ - hsize_t threshold, fs_size, def_size; /* Free space section threshold */ - unsigned new_format; /* new format or old format */ - herr_t ret; /* return value */ + hid_t fid; /* File IDs */ + hid_t fapl, new_fapl; /* File access property lists */ + hid_t fcpl, fcpl1, fcpl2; /* File creation property lists */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + unsigned new_format; /* New or old format */ + H5F_fspace_strategy_t fs_strategy; /* File space strategy--iteration variable */ + unsigned fs_persist; /* Persist free-space or not--iteration variable */ + hsize_t fs_threshold; /* Free-space section threshold--iteration variable */ + hsize_t fsp_size; /* File space page size */ + char filename[FILENAME_LEN]; /* Filename to use */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + herr_t ret; /* Return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing File Space Management public routines: H5Pget/set_file_space()\n")); + MESSAGE(5, ("Testing file creation public routines: H5Pget/set_file_space_strategy & H5Pget/set_file_space_page_size\n")); + + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); fapl = h5_fileaccess(); h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename); + /* Get a copy of the file access property list */ new_fapl = H5Pcopy(fapl); CHECK(new_fapl, FAIL, "H5Pcopy"); @@ -3500,104 +3547,773 @@ test_filespace_info(void) ret = H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); - /* Create file-creation template */ + /* + * Case (1) + * Check file space information from a default file creation property list. + * Values expected: + * strategy--H5F_FILE_SPACE_AGGR + * persist--FALSE + * threshold--1 + * file space page size--4096 + */ + /* Create file creation property list template */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + + /* Retrieve file space page size */ + ret = H5Pget_file_space_page_size(fcpl, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE_DEF, "H5Pget_file_space_page_size"); + + /* Close property list */ + H5Pclose(fcpl); + + /* + * Case (2) + * File space page size has a minimum size of 512. + * Setting value less than 512 will return an error; + * --setting file space page size to 0 + * --setting file space page size to 511 + */ + /* Create file creation property list template */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); - /* Get default file space information */ - ret = H5Pget_file_space(fcpl, &def_type, &def_size); - CHECK(ret, FAIL, "H5Pget_file_space"); + /* Setting to 0: should fail */ + H5E_BEGIN_TRY { + ret = H5Pset_file_space_page_size(fcpl, 0); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_file_space_page_size"); + + /* Setting to 511: should fail */ + H5E_BEGIN_TRY { + ret = H5Pset_file_space_page_size(fcpl, 511); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_file_space_page_size"); + + /* Setting to 512: should succeed */ + ret = H5Pset_file_space_page_size(fcpl, FSP_SIZE512); + CHECK(ret, FAIL, "H5Pset_file_space_page_size"); + ret = H5Pget_file_space_page_size(fcpl, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE512, "H5Pget_file_space_page_size"); + + /* Close property list */ + H5Pclose(fcpl); + + /* + * Case (3) + * Check file space information when creating a file with default properties. + * Values expected: + * strategy--H5F_FILE_SPACE_AGGR + * persist--FALSE + * threshold--1 + * file space page size--4096 + */ + /* Create a file with default file creation and access property lists */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get the file's creation property list */ + fcpl1 = H5Fget_create_plist(fid); + CHECK(fcpl1, FAIL, "H5Fget_create_plist"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl1, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + + /* Retrieve file space page size */ + ret = H5Pget_file_space_page_size(fcpl1, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE_DEF, "H5Pget_file_space_page_size"); + + /* Close property lists */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Pclose(fcpl1); + CHECK(ret, FAIL, "H5Pclose"); + + /* + * Case (4) + * Check file space information when creating a file with the + * latest library format and default properties. + * Values expected: + * strategy--H5F_FILE_SPACE_AGGR + * persist--FALSE + * threshold--1 + * file space page size--4096 + */ + /* Create a file with the latest library format */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get the file's creation property */ + fcpl1 = H5Fget_create_plist(fid); + CHECK(fcpl1, FAIL, "H5Fget_create_plist"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl1, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + + /* Retrieve file space page size */ + ret = H5Pget_file_space_page_size(fcpl1, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE_DEF, "H5Pget_file_space_page_size"); + + /* Close property lists */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Pclose(fcpl1); + CHECK(ret, FAIL, "H5Pclose"); - /* Test with old & new format groups */ + /* + * Case (5) + * Check file space information with the following combinations: + * Create file with -- + * New or old format + * Persist or not persist free-space + * Different sizes for free-space section threshold (0 to 10) + * The four file space strategies: + * H5F_FSPACE_STRATEGY_FSM_AGGR, H5F_FSPACE_STRATEGY_PAGE, + * H5F_FSPACE_STRATEGY_AGGR, H5F_FSPACE_STRATEGY_NONE + * File space page size: set to 512 + * + */ for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; + hid_t my_fapl; /* Set the FAPL for the type of format */ if(new_format) { - MESSAGE(5, ("Testing with new group format\n")); + MESSAGE(5, ("Testing with new group format\n")); my_fapl = new_fapl; } /* end if */ else { - MESSAGE(5, ("Testing with old group format\n")); + MESSAGE(5, ("Testing with old group format\n")); my_fapl = fapl; } /* end else */ - /* Test with different sized free space section threshold */ - for(fs_size = 0; fs_size <= TEST_THRESHOLD10; fs_size++) { + /* Test with TRUE or FALSE for persisting free-space */ + for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + + /* Test with free-space section threshold size: 0 to 10 */ + for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { + + /* Test with 4 file space strategies */ + for(fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; H5_INC_ENUM(H5F_fspace_strategy_t, fs_strategy)) { + + if(!contig_addr_vfd && (fs_strategy == H5F_FSPACE_STRATEGY_PAGE || fs_persist)) + continue; + + /* Create file creation property list template */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Set file space information */ + ret = H5Pset_file_space_strategy(fcpl, fs_strategy, (hbool_t)fs_persist, fs_threshold); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + + ret = H5Pset_file_space_page_size(fcpl, FSP_SIZE512); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); + + if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + VERIFY(persist, (hbool_t)fs_persist, "H5Pget_file_space_strategy"); + VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); + } else { + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + } + + /* Retrieve and verify file space page size */ + ret = H5Pget_file_space_page_size(fcpl, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE512, "H5Pget_file_space_page_size"); + + /* Create the file with the specified file space info */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get the file's creation property */ + fcpl1 = H5Fget_create_plist(fid); + CHECK(fcpl1, FAIL, "H5Fget_create_plist"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl1, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); + + if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + VERIFY(persist, fs_persist, "H5Pget_file_space_strategy"); + VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); + } else { + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + } + + /* Retrieve and verify file space page size */ + ret = H5Pget_file_space_page_size(fcpl1, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE512, "H5Pget_file_space_page_size"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open the file */ + fid = H5Fopen(filename, H5F_ACC_RDWR, my_fapl); + CHECK(ret, FAIL, "H5Fopen"); + + /* Get the file's creation property */ + fcpl2 = H5Fget_create_plist(fid); + CHECK(fcpl2, FAIL, "H5Fget_create_plist"); + + /* Retrieve file space information */ + ret = H5Pget_file_space_strategy(fcpl2, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Verify file space information */ + VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); + if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + VERIFY(persist, fs_persist, "H5Pget_file_space_strategy"); + VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); + } else { + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + } + + /* Retrieve and verify file space page size */ + ret = H5Pget_file_space_page_size(fcpl2, &fsp_size); + CHECK(ret, FAIL, "H5Pget_file_space_page_size"); + VERIFY(fsp_size, FSP_SIZE512, "H5Pget_file_space_page_size"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Release file creation property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fcpl1); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fcpl2); + CHECK(ret, FAIL, "H5Pclose"); + } /* end for file space strategy type */ + } /* end for free-space section threshold */ + } /* end for fs_persist */ + + /* close fapl_ and remove the file */ + h5_clean_files(FILESPACE_NAME, my_fapl); + } /* end for new_format */ + +} /* test_filespace_info() */ + +/**************************************************************** +** +** set_multi_split(): +** Internal routine to set up page-aligned address space for multi/split driver +** when testing paged aggregation. +** This is used by test_file_freespace() and test_sects_freespace(). +** +*****************************************************************/ +static int +set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t multi, hbool_t split) +{ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char *memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; + + HDassert(split || multi); + + HDmemset(memb_name, 0, sizeof memb_name); + + /* Get current split settings */ + if(H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + TEST_ERROR - /* Test with different file space handling strategies */ - for(fs_type = H5F_FILE_SPACE_DEFAULT; fs_type < H5F_FILE_SPACE_NTYPES; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) { + if(split) { + /* Set memb_addr aligned */ + memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + pagesize - 1) / pagesize) * pagesize; + memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; + } else { + /* Set memb_addr aligned */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + memb_addr[mt] = ((memb_addr[mt] + pagesize - 1) / pagesize) * pagesize; + } /* end else */ - /* Get a copy of the default file creation property */ - fcpl1 = H5Pcopy(fcpl); - CHECK(fcpl1, FAIL, "H5Pcopy"); + /* Set multi driver with new FAPLs */ + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + TEST_ERROR - /* Set file space strategy and free space section threshold */ - ret = H5Pset_file_space(fcpl1, fs_type, fs_size); - CHECK(ret, FAIL, "H5Pget_file_space"); + /* Free memb_name */ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + free(memb_name[mt]); - /* Get the file space info from the creation property */ - ret = H5Pget_file_space(fcpl1, &strategy, &threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); + return 0; - /* A 0 value for strategy retains existing strategy in use */ - VERIFY(strategy, (H5F_file_space_type_t)(fs_type ? fs_type : def_type), "H5Pget_file_space"); - /* A 0 value for threshold retains existing threshold in use */ - VERIFY(threshold, (hsize_t)(fs_size ? fs_size : def_size), "H5Pget_file_space"); +error: + return(-1); + +} /* set_multi_split() */ + +/**************************************************************** +** +** test_file_freespace(): +** This routine checks the free space available in a file as +** returned by the public routine H5Fget_freespace(). +** +** Modifications: +** Vailin Choi; July 2012 +** Remove datasets in reverse order so that all file spaces are shrunk. +** (A change due to H5FD_FLMAP_DICHOTOMY.) +** +** Vailin Choi; Dec 2012 +** Add changes due to paged aggregation via new format: +** the amount of freespace is different. +** +*****************************************************************/ +static void +test_file_freespace(const char *env_h5_drvr) +{ + hid_t file; /* File opened with read-write permission */ + h5_stat_size_t empty_filesize; /* Size of file when empty */ + h5_stat_size_t mod_filesize; /* Size of file after being modified */ + hssize_t free_space; /* Amount of free space in file */ + hid_t fcpl; /* File creation property list */ + hid_t fapl, new_fapl; /* File access property list IDs */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + int k; /* Local index variable */ + unsigned u; /* Local index variable */ + char filename[FILENAME_LEN]; /* Filename to use */ + char name[32]; /* Dataset name */ + unsigned new_format; /* To use old or new format */ + hbool_t split_vfd, multi_vfd; /* Indicate multi/split driver */ + hsize_t expected_freespace; /* Freespace expected */ + hsize_t expected_fs_del; /* Freespace expected after delete */ + herr_t ret; /* Return value */ + + split_vfd = !HDstrcmp(env_h5_drvr, "split"); + multi_vfd = !HDstrcmp(env_h5_drvr, "multi"); + + if(!split_vfd && !multi_vfd) { + fapl = h5_fileaccess(); + h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename); + + new_fapl = H5Pcopy(fapl); + CHECK(new_fapl, FAIL, "H5Pcopy"); + + /* Set the "use the latest version of the format" bounds */ + ret = H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); - /* Create the file with the specified file space info */ - fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl1, my_fapl); - CHECK(fid1, FAIL, "H5Fcreate"); + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Test with old & new format */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl; + + /* Set the FAPL for the type of format */ + if(new_format) { + MESSAGE(5, ("Testing with new group format\n")); + + my_fapl = new_fapl; + + if(multi_vfd || split_vfd) { + ret = set_multi_split(new_fapl, FSP_SIZE_DEF, multi_vfd, split_vfd); + CHECK(ret, FAIL, "set_multi_split"); + } + + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + CHECK(ret, FAIL, "H5P_set_file_space_strategy"); + + expected_freespace = 4534; + if(split_vfd) expected_freespace = 427; + if(multi_vfd) expected_freespace = 248; + expected_fs_del = 0; + } /* end if */ + else { + MESSAGE(5, ("Testing with old group format\n")); + /* Default: non-paged aggregation, non-persistent free-space */ + my_fapl = fapl; + expected_freespace = 2464; + if(split_vfd) expected_freespace = 264; + if(multi_vfd) expected_freespace = 0; + expected_fs_del = 4096; + + } /* end else */ + + /* Create an "empty" file */ + file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl); + CHECK(file, FAIL, "H5Fcreate"); + + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); + + /* Get the "empty" file size */ + empty_filesize = h5_get_file_size(filename, H5P_DEFAULT); + + /* Re-open the file (with read-write permission) */ + file = H5Fopen(filename, H5F_ACC_RDWR, my_fapl); + CHECK_I(file, "H5Fopen"); + + /* Check that the free space is 0 */ + free_space = H5Fget_freespace(file); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, 0, "H5Fget_freespace"); + + /* Create dataspace for datasets */ + dspace = H5Screate(H5S_SCALAR); + CHECK(dspace, FAIL, "H5Screate"); + + /* Create a dataset creation property list */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + + /* Set the space allocation time to early */ + ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); + CHECK(ret, FAIL, "H5Pset_alloc_time"); + + /* Create datasets in file */ + for(u = 0; u < 10; u++) { + sprintf(name, "Dataset %u", u); + dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(dset, FAIL, "H5Dcreate2"); + + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + } /* end for */ - /* Close the file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Close dataspace */ + ret = H5Sclose(dspace); + CHECK(ret, FAIL, "H5Sclose"); - /* Re-open the file */ - fid2 = H5Fopen(filename, H5F_ACC_RDWR, my_fapl); - CHECK(fid2, FAIL, "H5Fopen"); + /* Close dataset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Get the file's creation property */ - fcpl2 = H5Fget_create_plist(fid2); - CHECK(fcpl2, FAIL, "H5Fget_create_plist"); + /* Check that there is the right amount of free space in the file */ + free_space = H5Fget_freespace(file); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, expected_freespace, "H5Fget_freespace"); - strategy = H5F_FILE_SPACE_DEFAULT; - threshold = 0; + /* Delete datasets in file */ + for(k = 9; k >= 0; k--) { + sprintf(name, "Dataset %u", (unsigned)k); + ret = H5Ldelete(file, name, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + } /* end for */ - /* Get the file space info from the creation property list */ - ret = H5Pget_file_space(fcpl2, &strategy, &threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); + /* Check that there is the right amount of free space in the file */ + free_space = H5Fget_freespace(file); + CHECK(free_space, FAIL, "H5Fget_freespace"); + if(new_format) + VERIFY(free_space, expected_fs_del, "H5Fget_freespace"); + else + VERIFY(free_space, expected_fs_del, "H5Fget_freespace"); - VERIFY(strategy, (H5F_file_space_type_t)(fs_type ? fs_type : def_type), "H5Pget_file_space"); - VERIFY(threshold, (hsize_t)(fs_size ? fs_size : def_size), "H5Pget_file_space"); + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); - /* Close the file */ - ret = H5Fclose(fid2); - CHECK(ret, FAIL, "H5Fclose"); + /* Get the file size after modifications*/ + mod_filesize = h5_get_file_size(filename, H5P_DEFAULT); - /* Release file-creation template */ - ret = H5Pclose(fcpl1); - CHECK(ret, FAIL, "H5Pclose"); - ret = H5Pclose(fcpl2); - CHECK(ret, FAIL, "H5Pclose"); - } /* end for file space strategy type */ - } /* end for free space threshold */ + /* Check that the file reverted to empty size */ + VERIFY(mod_filesize, empty_filesize, "H5Fget_freespace"); - h5_clean_files(FILESPACE_NAME, my_fapl); + h5_clean_files(FILESPACE_NAME, my_fapl); - } /* end for new/old format */ + } /* end for */ + } + +} /* end test_file_freespace() */ + +/**************************************************************** +** +** test_sects_freespace(): +** This routine checks free-space section information for the +** file as returned by the public routine H5Fget_free_sections(). +** +*****************************************************************/ +static void +test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) +{ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file; /* File ID */ + hid_t fcpl; /* File creation property list template */ + hid_t fapl; /* File access property list template */ + hssize_t free_space; /* Amount of free-space in the file */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + char name[32]; /* Dataset name */ + hssize_t nsects = 0; /* # of free-space sections */ + hssize_t nall; /* # of free-space sections for all types of data */ + hssize_t nmeta = 0, nraw = 0; /* # of free-space sections for meta/raw/generic data */ + H5F_sect_info_t sect_info[15]; /* Array to hold free-space information */ + H5F_sect_info_t all_sect_info[15]; /* Array to hold free-space information for all types of data */ + H5F_sect_info_t meta_sect_info[15]; /* Array to hold free-space information for metadata */ + H5F_sect_info_t raw_sect_info[15]; /* Array to hold free-space information for raw data */ + hsize_t total = 0; /* sum of the free-space section sizes */ + hsize_t tmp_tot = 0; /* Sum of the free-space section sizes */ + hsize_t last_size; /* Size of last free-space section */ + hsize_t dims[1]; /* Dimension sizes */ + unsigned u; /* Local index variable */ + H5FD_mem_t type; + hbool_t split_vfd = FALSE, multi_vfd = FALSE; + herr_t ret; /* Return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing H5Fget_free_sections()--free-space section info in the file\n")); + + split_vfd = !HDstrcmp(env_h5_drvr, "split"); + multi_vfd = !HDstrcmp(env_h5_drvr, "multi"); + + if(!split_vfd && !multi_vfd) { + + fapl = h5_fileaccess(); + h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename); + + /* Create file-creation template */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + if(new_format) { + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Set to paged aggregation and persistent free-space */ + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + /* Set up paged aligned address space for multi/split driver */ + if(multi_vfd || split_vfd) { + ret = set_multi_split(fapl, FSP_SIZE_DEF, multi_vfd, split_vfd); + CHECK(ret, FAIL, "set_multi_split"); + } + + } else { + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + } + + /* Create the file */ + file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(file, FAIL, "H5Fcreate"); + + /* Create a dataset creation property list */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + + /* Set the space allocation time to early */ + ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); + CHECK(ret, FAIL, "H5Pset_alloc_time"); + + /* Create 1 large dataset */ + dims[0] = 1200; + dspace = H5Screate_simple(1, dims, NULL); + dset = H5Dcreate2(file, "Dataset_large", H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(dset, FAIL, "H5Dcreate2"); + + /* Close dataset */ + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close dataspace */ + ret = H5Sclose(dspace); + CHECK(ret, FAIL, "H5Sclose"); + + /* Create dataspace for datasets */ + dspace = H5Screate(H5S_SCALAR); + CHECK(dspace, FAIL, "H5Screate"); + + /* Create datasets in file */ + for(u = 0; u < 10; u++) { + sprintf(name, "Dataset %u", u); + dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(dset, FAIL, "H5Dcreate2"); + + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + } /* end for */ + + /* Close dataspace */ + ret = H5Sclose(dspace); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close dataset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Delete odd-numbered datasets in file */ + for(u = 0; u < 10; u++) { + sprintf(name, "Dataset %u", u); + if(u % 2) { + ret = H5Ldelete(file, name, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + } /* end if */ + } /* end for */ + + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open the file with read-only permission */ + file = H5Fopen(filename, H5F_ACC_RDONLY, fapl); + CHECK_I(file, "H5Fopen"); + + /* Get the amount of free space in the file */ + free_space = H5Fget_freespace(file); + CHECK(free_space, FAIL, "H5Fget_freespace"); + + /* Get the total # of free-space sections in the file */ + nall = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL); + CHECK(nall, FAIL, "H5Fget_free_sections"); + + /* Should return failure when nsects is 0 with a nonnull sect_info */ + nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, all_sect_info); + VERIFY(nsects, FAIL, "H5Fget_free_sections"); + + /* Retrieve and verify free space info for all the sections */ + HDmemset(all_sect_info, 0, sizeof(all_sect_info)); + nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)nall, all_sect_info); + VERIFY(nsects, nall, "H5Fget_free_sections"); + + /* Verify the amount of free-space is correct */ + for(u = 0; u < nall; u++) + total += all_sect_info[u].size; + VERIFY(free_space, total, "H5Fget_free_sections"); + + /* Save the last section's size */ + last_size = all_sect_info[nall-1].size; + + /* Retrieve and verify free space info for -1 sections */ + HDmemset(sect_info, 0, sizeof(sect_info)); + nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(nall - 1), sect_info); + VERIFY(nsects, nall, "H5Fget_free_sections"); + + /* Verify the amount of free-space is correct */ + total = 0; + for(u = 0; u < (nall - 1); u++) { + VERIFY(sect_info[u].addr, all_sect_info[u].addr, "H5Fget_free_sections"); + VERIFY(sect_info[u].size, all_sect_info[u].size, "H5Fget_free_sections"); + total += sect_info[u].size; + } + VERIFY(((hsize_t)free_space - last_size), total, "H5Fget_free_sections"); + + /* Retrieve and verify free-space info for +1 sections */ + HDmemset(sect_info, 0, sizeof(sect_info)); + nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(nall + 1), sect_info); + VERIFY(nsects, nall, "H5Fget_free_sections"); + + /* Verify amount of free-space is correct */ + total = 0; + for(u = 0; u < nall; u++) { + VERIFY(sect_info[u].addr, all_sect_info[u].addr, "H5Fget_free_sections"); + VERIFY(sect_info[u].size, all_sect_info[u].size, "H5Fget_free_sections"); + total += sect_info[u].size; + } + VERIFY(sect_info[nall].addr, 0, "H5Fget_free_sections"); + VERIFY(sect_info[nall].size, 0, "H5Fget_free_sections"); + VERIFY(free_space, total, "H5Fget_free_sections"); + + HDmemset(meta_sect_info, 0, sizeof(meta_sect_info)); + if(multi_vfd) { + hssize_t ntmp; + + for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) { + if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + continue; + /* Get the # of free-space sections in the file for metadata */ + ntmp = H5Fget_free_sections(file, type, (size_t)0, NULL); + CHECK(ntmp, FAIL, "H5Fget_free_sections"); + + if(ntmp > 0) { + nsects = H5Fget_free_sections(file, type, (size_t)ntmp, &meta_sect_info[nmeta]); + VERIFY(nsects, ntmp, "H5Fget_free_sections"); + nmeta += ntmp; + } + } + } else { + /* Get the # of free-space sections in the file for metadata */ + nmeta = H5Fget_free_sections(file, H5FD_MEM_SUPER, (size_t)0, NULL); + CHECK(nmeta, FAIL, "H5Fget_free_sections"); + + /* Retrieve and verify free-space sections for metadata */ + nsects = H5Fget_free_sections(file, H5FD_MEM_SUPER, (size_t)nmeta, meta_sect_info); + VERIFY(nsects, nmeta, "H5Fget_free_sections"); + } + + /* Get the # of free-space sections in the file for raw data */ + nraw = H5Fget_free_sections(file, H5FD_MEM_DRAW, (size_t)0, NULL); + CHECK(nraw, FAIL, "H5Fget_free_sections"); + + /* Retrieve and verify free-space sections for raw data */ + HDmemset(raw_sect_info, 0, sizeof(raw_sect_info)); + nsects = H5Fget_free_sections(file, H5FD_MEM_DRAW, (size_t)nraw, raw_sect_info); + VERIFY(nsects, nraw, "H5Fget_free_sections"); + + /* Sum all the free-space sections */ + for(u = 0; u < nmeta; u++) + tmp_tot += meta_sect_info[u].size; + + for(u = 0; u < nraw; u++) + tmp_tot += raw_sect_info[u].size; + + /* Verify free-space info */ + VERIFY(nmeta+nraw, nall, "H5Fget_free_sections"); + VERIFY(tmp_tot, total, "H5Fget_free_sections"); + + /* Closing */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Pclose(fcpl); + CHECK(fcpl, FAIL, "H5Pclose"); + + h5_clean_files(FILESPACE_NAME, fapl); + } + +} /* end test_sects_freespace() */ - /* Close the file creation property list */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); -} /* test_filespace_info() */ /**************************************************************** ** ** test_filespace_compatible(): -** Verify that the branch with file space management enhancement +** Verify that the trunk with the latest file space management ** can open, read and modify 1.6 HDF5 file and 1.8 HDF5 file. -** Also verify the correct file space strategy/threshold in use +** Also verify the correct file space handling information ** and the amount of free space. ** ****************************************************************/ @@ -3614,8 +4330,9 @@ test_filespace_compatible(void) ssize_t nread; /* Number of bytes read in */ unsigned i, j; /* Local index variable */ hssize_t free_space; /* Amount of free-space in the file */ + hbool_t persist; /* Persist free-space or not */ hsize_t threshold; /* Free-space section threshold */ - H5F_file_space_type_t strategy; /* File space handling strategy */ + H5F_fspace_strategy_t strategy; /* File space handling strategy */ herr_t ret; /* Return value */ /* Output message about test being performed */ @@ -3655,14 +4372,16 @@ test_filespace_compatible(void) fcpl = H5Fget_create_plist(fid); CHECK(fcpl, FAIL, "H5Fget_create_plist"); - /* Retrieve the file space handling strategy and threshold */ - ret = H5Pget_file_space(fcpl, &strategy, &threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); + /* Retrieve the file space info */ + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); - /* File space handling strategy should be H5F_FILE_SPACE_ALL = 2 */ - /* Free space section threshold should be 1 */ - VERIFY(strategy, 2, "H5Pget_file_space"); - VERIFY(threshold, 1, "H5Pget_file_space"); + /* File space handling strategy should be H5F_FSPACE_STRATEGY_FSM_AGGR */ + /* Persisting free-space should be FALSE */ + /* Free-space section threshold should be 1 */ + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); /* Generate raw data */ for(i = 0; i < 100; i++) @@ -3715,6 +4434,387 @@ test_filespace_compatible(void) /**************************************************************** ** +** test_filespace_1.10.0_compatible(): +** Verify that the latest file space management can open, read and +** modify 1.10.0 HDF5 files : +** h5fc_ext1_i.h5: H5F_FILE_SPACE_ALL, default threshold; has superblock extension but no fsinfo message +** h5fc_ext1_f.h5: H5F_FILE_SPACE_ALL_PERSIST, default threshold; has superblock extension with fsinfo message +** h5fc_ext2_if.h5: H5F_FILE_SPACE_ALL, non-default threshold; has superblock extension with fsinfo message +** h5fc_ext2_sf.h5: H5F_FILE_SPACE_VFD, default threshold; has superblock extension with fsinfo message +** h5fc_ext3_isf.h5: H5F_FILE_SPACE_AGGR_VFD, default threshold; has superblock extension with fsinfo message +** h5fc_ext_none.h5: H5F_FILE_SPACE_ALL, default threshold; without superblock extension +** The above files are copied from release 1.10.0 tools/h5format_convert/testfiles. +** +****************************************************************/ +static void +test_filespace_1_10_0_compatible(void) +{ + hid_t fid = -1; /* File id */ + hid_t did = -1; /* Dataset id */ + hid_t fcpl; /* File creation property list */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + H5F_fspace_strategy_t strategy; /* File space handling strategy */ + int wbuf[24]; /* Buffer for dataset data */ + int rdbuf[24]; /* Buffer for dataset data */ + int status; /* Status from copying the existing file */ + unsigned i, j; /* Local index variable */ + herr_t ret; /* Return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("File space compatibility testing for 1.10.0 files\n")); + + for(j = 0; j < NELMTS(OLD_1_10_0_FILENAME); j++) { + const char *filename = H5_get_srcdir_filename(OLD_1_10_0_FILENAME[j]); /* Corrected test file name */ + + /* Make a copy of the test file */ + status = h5_make_local_copy(filename, FILE5); + CHECK(status, FAIL, "h5_make_local_copy"); + + /* Open the temporary test file */ + fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get the file's file creation property list */ + fcpl = H5Fget_create_plist(fid); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); + + /* Retrieve the file space info */ + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + + switch(j) { + case 0: + VERIFY(strategy, H5F_FILE_SPACE_STRATEGY_DEF, "H5Pget_file_space_strategy"); + VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); + VERIFY(threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/DSET_EA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 1: + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, TRUE, "H5Pget_file_space_strategy"); + VERIFY(threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/DSET_NDATA_BT2", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 2: + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); + VERIFY(threshold, 2, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/DSET_NONE", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 3: + VERIFY(strategy, H5F_FSPACE_STRATEGY_NONE, "H5Pget_file_space_strategy"); + VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); + VERIFY(threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_EA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 4: + VERIFY(strategy, H5F_FSPACE_STRATEGY_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); + VERIFY(threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_FA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + case 5: + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); + VERIFY(threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space_strategy"); + + /* Open the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_NONE", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + for(i = 0; i < 24; i++) + wbuf[i] = (int)j+1; + + /* Write to the dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + default: + break; + } + + /* Close the plist */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-Open the file */ + fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + switch(j) { + case 0: + /* Open and read the dataset */ + did = H5Dopen2(fid, "/DSET_EA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 1: + /* Open and read the dataset */ + did = H5Dopen2(fid, "/DSET_NDATA_BT2", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 2: + /* Open and read the dataset */ + did = H5Dopen2(fid, "/DSET_NONE", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 3: + /* Open and read the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_EA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 4: + + /* Open and read the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_FA", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + case 5: + + /* Open and read the dataset */ + did = H5Dopen2(fid, "/GROUP/DSET_NDATA_NONE", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data read is correct */ + for(i = 0; i < 24; i++) + VERIFY(rdbuf[i], j+1, "test_compatible"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + break; + + default: + break; + } + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ + +} /* test_filespace_1_10_0_compatible */ + +/**************************************************************** +** +** test_filespace_round_compatible(): +** Verify that the trunk can open, read and modify these files-- +** 1) They are initially created (via gen_filespace.c) in the trunk +** with combinations of file space strategies, default/non-default +** threshold, and file spacing paging enabled/disbled. +** The library creates the file space info message with +** "mark if unknown" in these files. +** 2) They are copied to the 1.8 branch, and are opened/read/modified +** there via test_filespace_compatible() in test/tfile.c. +** The 1.8 library marks the file space info message as "unknown" +** in these files. +** 3) They are then copied back from the 1.8 branch to the trunk for +** compatibility testing via this routine. +** 4) Upon encountering the file space info message which is marked +** as "unknown", the library will use the default file space management +** from then on: non-persistent free-space managers, default threshold, +** and non-paging file space. +** +****************************************************************/ +static void +test_filespace_round_compatible(void) +{ + hid_t fid = -1; /* File id */ + hid_t fcpl = -1; /* File creation property list ID */ + unsigned j; /* Local index variable */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + hssize_t free_space; /* Amount of free space in the file */ + int status; /* Status from copying the existing file */ + herr_t ret; /* Return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("File space compatibility testing for files from trunk to 1_8 to trunk\n")); + + for(j = 0; j < NELMTS(FSPACE_FILENAMES); j++) { + const char *filename = H5_get_srcdir_filename(FSPACE_FILENAMES[j]); + + /* Make a copy of the test file */ + status = h5_make_local_copy(filename, FILE5); + CHECK(status, FAIL, "h5_make_local_copy"); + + /* Open the temporary test file */ + fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get the file's creation property list */ + fcpl = H5Fget_create_plist(fid); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); + + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + + /* There should not be any free space in the file */ + free_space = H5Fget_freespace(fid); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); + + /* Closing */ + ret = H5Fclose(fid); + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ + +} /* test_filespace_round_compatible */ + + +/**************************************************************** +** ** test_libver_bounds_real(): ** Verify that a file created and modified with the ** specified libver bounds has the specified object header @@ -3951,6 +5051,9 @@ test_deprec(void) { hid_t file; /* File IDs for old & new files */ hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File creation property list */ + hid_t new_fapl; + hsize_t align; unsigned super; /* Superblock version # */ unsigned freelist; /* Free list version # */ unsigned stab; /* Symbol table entry version # */ @@ -4003,17 +5106,25 @@ test_deprec(void) CHECK(fcpl, FAIL, "H5Pcreate"); /* Set a property in the FCPL that will push the superblock version up */ - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_VFD, (hsize_t)0); - CHECK(ret, FAIL, "H5Pset_file_space"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + + fapl = H5Pcreate(H5P_FILE_ACCESS); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_alignment"); /* Creating a file with the non-default file creation property list should * create a version 2 superblock */ /* Create file with custom file creation property list */ - file= H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + file= H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, fapl); CHECK(file, FAIL, "H5Fcreate"); + new_fapl = H5Fget_access_plist(file); + H5Pget_alignment(new_fapl, NULL, &align); + /* Close FCPL */ ret=H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); @@ -4021,7 +5132,7 @@ test_deprec(void) /* Get the file's version information */ ret = H5Fget_info1(file, &finfo); CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 40,"H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152,"H5Fget_info1"); VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1"); VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1"); VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1"); @@ -4053,7 +5164,7 @@ test_deprec(void) /* Get the file's version information */ ret = H5Fget_info1(file, &finfo); CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 40,"H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152,"H5Fget_info1"); VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1"); VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1"); VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1"); @@ -4077,6 +5188,81 @@ test_deprec(void) /* Close file */ ret=H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); + + { /* Test deprecated H5Pget/set_file_space() */ + + H5F_file_space_type_t old_strategy; + hsize_t old_threshold; + hid_t fid; + hid_t ffcpl; + + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL, "H5Pget_file_space"); + VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); + + /* Set file space strategy and free space section threshold */ + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + CHECK(ret, FAIL, "H5Pget_file_space"); + + /* Get the file space info from the creation property */ + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); + + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_DEFAULT, (hsize_t)3); + CHECK(ret, FAIL, "H5Pget_file_space"); + + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); + + /* Create a file */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + old_strategy = H5F_FILE_SPACE_DEFAULT; + old_threshold = 0; + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); + + /* Close file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + ret = H5Pclose(ffcpl); + CHECK(ret, FAIL, "H5Pclose"); + + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Reopen the file */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + old_strategy = H5F_FILE_SPACE_DEFAULT; + old_threshold = 0; + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); + + ret = H5Pclose(ffcpl); + CHECK(ret, FAIL, "H5Pclose"); + + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + } /* test_deprec */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -4088,9 +5274,16 @@ test_deprec(void) void test_file(void) { + const char *env_h5_drvr; /* File Driver value from environment */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File I/O\n")); + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + test_file_create(); /* Test file creation(also creation templates)*/ test_file_open(); /* Test file opening */ test_file_reopen(); /* Test file reopening */ @@ -4099,7 +5292,6 @@ test_file(void) test_get_obj_ids(); /* Test H5Fget_obj_ids for Jira Issue 8528 */ test_file_perm(); /* Test file access permissions */ test_file_perm2(); /* Test file access permission again */ - test_file_freespace(); /* Test file free space information */ test_file_ishdf5(); /* Test detecting HDF5 files correctly */ test_file_open_dot(); /* Test opening objects with "." for a name */ test_file_open_overlap(); /* Test opening files in an overlapping manner */ @@ -4114,9 +5306,21 @@ test_file(void) test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly */ - test_filespace_sects(); /* Test file free space section information */ - test_filespace_info(); /* Test file creation public routines:H5Pget/set_file_space */ + test_userblock_alignment_paged(); /* Tests files created with a userblock and alignment (via paged aggregation) interact properly */ + test_filespace_info(env_h5_drvr); /* Test file creation public routines: */ + /* H5Pget/set_file_space_strategy() & H5Pget/set_file_space_page_size() */ + /* Skipped testing for multi/split drivers */ + test_file_freespace(env_h5_drvr); /* Test file public routine H5Fget_freespace() */ + /* Skipped testing for multi/split drivers */ + /* Setup for multi/split drivers are there already */ + test_sects_freespace(env_h5_drvr, TRUE); /* Test file public routine H5Fget_free_sections() for new format */ + /* Skipped testing for multi/split drivers */ + /* Setup for multi/split drivers are there already */ + test_sects_freespace(env_h5_drvr, FALSE); /* Test file public routine H5Fget_free_sections() */ + /* Skipped testing for multi/split drivers */ test_filespace_compatible(); /* Test compatibility for file space management */ + test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to trunk */ + test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 */ test_libver_bounds(); /* Test compatibility for file space management */ test_libver_macros(); /* Test the macros for library version comparison */ test_libver_macros2(); /* Test the macros for library version comparison */ diff --git a/test/tmisc.c b/test/tmisc.c index f93500d..6012588 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -1819,8 +1819,9 @@ test_misc11(void) unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ unsigned nindexes; /* Shared message number of indexes */ H5F_info2_t finfo; /* global information about file */ - H5F_file_space_type_t strategy; /* File/free space strategy */ + H5F_fspace_strategy_t strategy; /* File space strategy */ hsize_t threshold; /* Free-space section threshold */ + hbool_t persist; /* To persist free-space or not */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1878,11 +1879,11 @@ test_misc11(void) ret=H5Pset_shared_mesg_nindexes(fcpl,MISC11_NINDEXES); CHECK(ret, FAIL, "H5Pset_shared_mesg"); - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_VFD, (hsize_t)0); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); CHECK(ret, FAIL, "H5Pset_file_space"); /* Creating a file with the non-default file creation property list should - * create a version 1 superblock + * create a version 2 superblock */ /* Create file with custom file creation property list */ @@ -1942,10 +1943,11 @@ test_misc11(void) CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); - ret = H5Pget_file_space(fcpl, &strategy, &threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(strategy, 4, "H5Pget_file_space"); - VERIFY(threshold, 1, "H5Pget_file_space"); + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + VERIFY(strategy, 3, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); /* Close file */ ret=H5Fclose(file); diff --git a/testpar/Makefile.am b/testpar/Makefile.am index 4fe0ba8..3889630 100644 --- a/testpar/Makefile.am +++ b/testpar/Makefile.am @@ -25,7 +25,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test # Test programs. These are our main targets. # -TEST_PROG_PARA=t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_init_term t_shapesame +TEST_PROG_PARA=t_mpi testphdf5 t_cache t_cache_image t_pflush1 t_pflush2 t_pshutdown t_prestart t_init_term t_shapesame check_PROGRAMS = $(TEST_PROG_PARA) diff --git a/testpar/t_cache_image.c b/testpar/t_cache_image.c new file mode 100644 index 0000000..7283fa7 --- /dev/null +++ b/testpar/t_cache_image.c @@ -0,0 +1,2161 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: John Mainzer + * 7/13/15 + * + * This file contains tests specific to the cache image + * feature implemented in H5C.c + */ +#include "h5test.h" +#include "testphdf5.h" +#include "testpar.h" +#include "cache_common.h" +#include "genall5.h" + +#define CHUNK_SIZE 10 +#define DSET_SIZE (40 * CHUNK_SIZE) +#define MAX_NUM_DSETS 256 + + +/* global variable declarations: */ + + +const char *FILENAMES[] = { + "t_cache_image_00", + "t_cache_image_01", + NULL +}; + +/* local utility function declarations */ + +static void create_data_sets(hid_t file_id, int min_dset, int max_dset); +static void delete_data_sets(hid_t file_id, int min_dset, int max_dset); + +static void open_hdf5_file(const hbool_t create_file, + const hbool_t mdci_sbem_expected, const hbool_t read_only, + const hbool_t set_mdci_fapl, const hbool_t config_fsm, + const char * hdf_file_name, const unsigned cache_image_flags, + hid_t * file_id_ptr, H5F_t ** file_ptr_ptr, H5C_t ** cache_ptr_ptr, + MPI_Comm comm, MPI_Info info, int l_facc_type, + const hbool_t all_coll_metadata_ops, const hbool_t coll_metadata_write, + const int md_write_strat); + +static void verify_data_sets(hid_t file_id, int min_dset, int max_dset); + +/* local test function declarations */ + +static hbool_t parse_flags(int argc, char * argv[], hbool_t * setup_ptr, + hbool_t display); +static void usage(void); +static unsigned construct_test_file(int test_file_index); + + +/* top level test function declarations */ +static unsigned verify_cache_image_RW(int file_name_id, + int md_write_strat, int mpi_rank); + + +/****************************************************************************/ +/***************************** Utility Functions ****************************/ +/****************************************************************************/ + +/*------------------------------------------------------------------------- + * Function: construct_test_file() + * + * Purpose: This function attempts to mimic the typical "poor man's + * parallel use case in which the file is passed between + * processes, each of which open the file, write some data, + * close the file, and then pass control on to the next + * process. + * + * In this case, we create one group for each process, and + * populate it with a "zoo" of HDF5 objects selected to + * (ideally) exercise all HDF5 on disk data structures. + * + * The end result is a test file used verify that PHDF5 + * can open a file with a cache image. + * + * Cycle of operation + * + * 1) Create a HDF5 file with the cache image FAPL entry. + * + * Verify that the cache is informed of the cache image + * FAPL entry. + * + * Set all cache image flags, forcing full functionality. + * + * 2) Create a data set in the file. + * + * 3) Close the file. + * + * 4) Open the file. + * + * Verify that the metadata cache is instructed to load + * the metadata cache image. + * + * 5) Create a data set in the file. + * + * 6) Close the file. If enough datasets have been created + * goto 7. Otherwise return to 4. + * + * 7) Open the file R/O. + * + * Verify that the file contains a metadata cache image + * superblock extension message. + * + * 8) Verify all data sets. + * + * Verify that the cache image has been loaded. + * + * 9) close the file. + * + * Return: void + * + * Programmer: John Mainzer + * 1/25/17 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static unsigned +construct_test_file(int test_file_index) +{ + const char * fcn_name = "construct_test_file()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + int cp = 0; + int min_dset = 0; + int max_dset = 0; + MPI_Comm dummy_comm = MPI_COMM_WORLD; + MPI_Info dummy_info = MPI_INFO_NULL; + + pass = TRUE; + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + HDassert(FILENAMES[test_file_index]); + + if ( h5_fixname(FILENAMES[test_file_index], H5P_DEFAULT, + filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 1) Create a HDF5 file with the cache image FAPL entry. + * + * Verify that the cache is informed of the cache image FAPL entry. + * + * Set flags forcing full function of the cache image feature. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ TRUE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ TRUE, + /* config_fsm */ TRUE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr, + /* comm */ dummy_comm, + /* info */ dummy_info, + /* l_facc_type */ 0, + /* all_coll_metadata_ops */ FALSE, + /* coll_metadata_write */ FALSE, + /* md_write_strat */ 0); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Create a data set in the file. */ + + if ( pass ) { + + create_data_sets(file_id, min_dset++, max_dset++); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 3) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) ) + { + + /* 4) Open the file. + * + * Verify that the metadata cache is instructed to load the + * metadata cache image. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ FALSE, + /* set_mdci_fapl */ TRUE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr, + /* comm */ dummy_comm, + /* info */ dummy_info, + /* l_facc_type */ 0, + /* all_coll_metadata_ops */ FALSE, + /* coll_metadata_write */ FALSE, + /* md_write_strat */ 0); + } + + if ( show_progress ) + HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", + fcn_name, cp, max_dset, pass); + + + /* 5) Create a data set in the file. */ + + if ( pass ) { + + create_data_sets(file_id, min_dset++, max_dset++); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded == 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", + fcn_name, cp + 1, max_dset, pass); + + + /* 6) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", + fcn_name, cp + 2, max_dset, pass); + } /* end while */ + cp += 3; + + + /* 7) Open the file R/O. + * + * Verify that the file contains a metadata cache image + * superblock extension message. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr, + /* comm */ dummy_comm, + /* info */ dummy_info, + /* l_facc_type */ 0, + /* all_coll_metadata_ops */ FALSE, + /* coll_metadata_write */ FALSE, + /* md_write_strat */ 0); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 8) Open and close all data sets. + * + * Verify that the cache image has been loaded. + */ + + if ( pass ) { + + verify_data_sets(file_id, 0, max_dset - 1); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded == 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 9) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + return !pass; + +} /* construct_test_file() */ + + +/*------------------------------------------------------------------------- + * Function: create_data_sets() + * + * Purpose: If pass is TRUE on entry, create the specified data sets + * in the indicated file. + * + * Data sets and their contents must be well know, as we + * will verify that they contain the expected data later. + * + * On failure, set pass to FALSE, and set failure_mssg + * to point to an appropriate failure message. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 7/15/15 + * + * Modifications: + * + * Added min_dset and max_dset parameters and supporting + * code. This allows the caller to specify a range of + * datasets to create. + * JRM -- 8/20/15 + * + *------------------------------------------------------------------------- + */ + +static void +create_data_sets(hid_t file_id, int min_dset, int max_dset) +{ + const char * fcn_name = "create_data_sets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t dataspace_id = -1; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hid_t properties = -1; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + hsize_t chunk_size[2]; + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + HDassert(0 <= min_dset); + HDassert(min_dset <= max_dset); + HDassert(max_dset < MAX_NUM_DSETS); + + /* create the datasets */ + + if ( pass ) { + + i = min_dset; + + while ( ( pass ) && ( i <= max_dset ) ) + { + /* create a dataspace for the chunked dataset */ + dims[0] = DSET_SIZE; + dims[1] = DSET_SIZE; + dataspace_id = H5Screate_simple(2, dims, NULL); + + if ( dataspace_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Screate_simple() failed."; + } + + /* set the dataset creation plist to specify that the raw data is + * to be partioned into 10X10 element chunks. + */ + + if ( pass ) { + + chunk_size[0] = CHUNK_SIZE; + chunk_size[1] = CHUNK_SIZE; + properties = H5Pcreate(H5P_DATASET_CREATE); + + if ( properties < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate() failed."; + } + } + + if ( pass ) { + + if ( H5Pset_chunk(properties, 2, chunk_size) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_chunk() failed."; + } + } + + /* create the dataset */ + if ( pass ) { + + sprintf(dset_name, "/dset%03d", i); + dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, + dataspace_id, H5P_DEFAULT, + properties, H5P_DEFAULT); + + if ( dataset_ids[i] < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dcreate() failed."; + } + } + + /* get the file space ID */ + if ( pass ) { + + filespace_ids[i] = H5Dget_space(dataset_ids[i]); + + if ( filespace_ids[i] < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dget_space() failed."; + } + } + + i++; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* create the mem space to be used to read and write chunks */ + if ( pass ) { + + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; + memspace_id = H5Screate_simple(2, dims, NULL); + + if ( memspace_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Screate_simple() failed."; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* select in memory hyperslab */ + if ( pass ) { + + offset[0] = 0; /*offset of hyperslab in memory*/ + offset[1] = 0; + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[1] = CHUNK_SIZE; + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, + a_size, NULL); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sselect_hyperslab() failed."; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* initialize all datasets on a round robin basis */ + i = 0; + while ( ( pass ) && ( i < DSET_SIZE ) ) + { + j = 0; + while ( ( pass ) && ( j < DSET_SIZE ) ) + { + m = min_dset; + while ( ( pass ) && ( m <= max_dset ) ) + { + /* initialize the slab */ + for ( k = 0; k < CHUNK_SIZE; k++ ) + { + for ( l = 0; l < CHUNK_SIZE; l++ ) + { + data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + + (DSET_SIZE * (i + k)) + j + l; + } + } + + /* select on disk hyperslab */ + offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ + offset[1] = (hsize_t)j; + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[1] = CHUNK_SIZE; + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, + offset, NULL, a_size, NULL); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "disk H5Sselect_hyperslab() failed."; + } + + /* write the chunk to file */ + status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, + filespace_ids[m], H5P_DEFAULT, data_chunk); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dwrite() failed."; + } + m++; + } + j += CHUNK_SIZE; + } + + i += CHUNK_SIZE; + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* read data from data sets and validate it */ + i = 0; + while ( ( pass ) && ( i < DSET_SIZE ) ) + { + j = 0; + while ( ( pass ) && ( j < DSET_SIZE ) ) + { + m = min_dset; + while ( ( pass ) && ( m <= max_dset ) ) + { + + /* select on disk hyperslab */ + offset[0] = (hsize_t)i; /* offset of hyperslab in file */ + offset[1] = (hsize_t)j; + a_size[0] = CHUNK_SIZE; /* size of hyperslab */ + a_size[1] = CHUNK_SIZE; + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, + offset, NULL, a_size, NULL); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; + } + + /* read the chunk from file */ + if ( pass ) { + + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, + memspace_id, filespace_ids[m], + H5P_DEFAULT, data_chunk); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; + } + } + + /* validate the slab */ + if ( pass ) { + + valid_chunk = TRUE; + for ( k = 0; k < CHUNK_SIZE; k++ ) + { + for ( l = 0; l < CHUNK_SIZE; l++ ) + { + if ( data_chunk[k][l] + != + ((DSET_SIZE * DSET_SIZE * m) + + (DSET_SIZE * (i + k)) + j + l) ) { + + valid_chunk = FALSE; + + if ( verbose ) { + + HDfprintf(stdout, + "data_chunk[%0d][%0d] = %0d, expect %0d.\n", + k, l, data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, + "m = %d, i = %d, j = %d, k = %d, l = %d\n", + m, i, j, k, l); + } + } + } + } + + if ( ! valid_chunk ) { + + pass = FALSE; + failure_mssg = "slab validation failed."; + + if ( verbose ) { + + fprintf(stdout, + "Chunk (%0d, %0d) in /dset%03d is invalid.\n", + i, j, m); + } + } + } + m++; + } + j += CHUNK_SIZE; + } + i += CHUNK_SIZE; + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* close the file spaces */ + i = min_dset; + while ( ( pass ) && ( i <= max_dset ) ) + { + if ( H5Sclose(filespace_ids[i]) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sclose() failed."; + } + i++; + } + + + /* close the datasets */ + i = min_dset; + while ( ( pass ) && ( i <= max_dset ) ) + { + if ( H5Dclose(dataset_ids[i]) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dclose() failed."; + } + i++; + } + + /* close the mem space */ + if ( pass ) { + + if ( H5Sclose(memspace_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sclose(memspace_id) failed."; + } + } + + return; + +} /* create_data_sets() */ + + +/*------------------------------------------------------------------------- + * Function: delete_data_sets() + * + * Purpose: If pass is TRUE on entry, verify and then delete the + * dataset(s) indicated by min_dset and max_dset in the + * indicated file. + * + * Data sets and their contents must be well know, as we + * will verify that they contain the expected data later. + * + * On failure, set pass to FALSE, and set failure_mssg + * to point to an appropriate failure message. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 10/31/16 + * + * Modifications: + * + * None. + * JRM -- 8/20/15 + * + *------------------------------------------------------------------------- + */ + +static void +delete_data_sets(hid_t file_id, int min_dset, int max_dset) +{ + const char * fcn_name = "delete_data_sets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + int cp = 0; + int i; + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + HDassert(0 <= min_dset); + HDassert(min_dset <= max_dset); + HDassert(max_dset < MAX_NUM_DSETS); + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* first, verify the contents of the target dataset(s) */ + verify_data_sets(file_id, min_dset, max_dset); + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* now delete the target datasets */ + if ( pass ) { + + i = min_dset; + + while ( ( pass ) && ( i <= max_dset ) ) + { + sprintf(dset_name, "/dset%03d", i); + + if ( H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { + + pass = FALSE; + failure_mssg = "H5Ldelete() failed."; + } + + i++; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + return; + +} /* delete_data_sets() */ + + +/*------------------------------------------------------------------------- + * Function: open_hdf5_file() + * + * Purpose: If pass is true on entry, create or open the specified HDF5 + * and test to see if it has a metadata cache image superblock + * extension message. + * + * Set pass to FALSE and issue a suitable failure + * message if either the file contains a metadata cache image + * superblock extension and mdci_sbem_expected is TRUE, or + * vise versa. + * + * If mdci_sbem_expected is TRUE, also verify that the metadata + * cache has been advised of this. + * + * If read_only is TRUE, open the file read only. Otherwise + * open the file read/write. + * + * If set_mdci_fapl is TRUE, set the metadata cache image + * FAPL entry when opening the file, and verify that the + * metadata cache is notified. + * + * If config_fsm is TRUE, setup the persistant free space + * manager. Note that this flag may only be set if + * create_file is also TRUE. + * + * Return pointers to the cache data structure and file data + * structures. + * + * On failure, set pass to FALSE, and set failure_mssg + * to point to an appropriate failure message. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 7/14/15 + * + * Modifications: + * + * Modified function to handle parallel file creates / opens. + * + * JRM -- 2/1/17 + * + *------------------------------------------------------------------------- + */ + +static void +open_hdf5_file(const hbool_t create_file, + const hbool_t mdci_sbem_expected, + const hbool_t read_only, + const hbool_t set_mdci_fapl, + const hbool_t config_fsm, + const char * hdf_file_name, + const unsigned cache_image_flags, + hid_t * file_id_ptr, + H5F_t ** file_ptr_ptr, + H5C_t ** cache_ptr_ptr, + MPI_Comm comm, + MPI_Info info, + int l_facc_type, + const hbool_t all_coll_metadata_ops, + const hbool_t coll_metadata_write, + const int md_write_strat) +{ + const char * fcn_name = "open_hdf5_file()"; + hbool_t show_progress = FALSE; + hbool_t verbose = FALSE; + int cp = 0; + hid_t fapl_id = -1; + hid_t fcpl_id = -1; + hid_t file_id = -1; + herr_t result; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_cache_image_ctl_t image_ctl; + H5AC_cache_image_config_t cache_image_config = { + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, + TRUE, + FALSE, + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + + if ( pass ) + { + /* opening the file both read only and with a cache image + * requested is a contradiction. We resolve it by ignoring + * the cache image request silently. + */ + if ( ( create_file && mdci_sbem_expected ) || + ( create_file && read_only ) || + ( config_fsm && !create_file ) || + ( hdf_file_name == NULL ) || + ( ( set_mdci_fapl ) && ( cache_image_flags == 0 ) ) || + ( ( set_mdci_fapl ) && + ( (cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0 ) ) || + ( file_id_ptr == NULL ) || + ( file_ptr_ptr == NULL ) || + ( cache_ptr_ptr == NULL ) || + ( l_facc_type != (l_facc_type & (FACC_MPIO)) ) ) { + + failure_mssg = + "Bad param(s) on entry to open_hdf5_file().\n"; + + pass = FALSE; + } else if ( verbose ) { + + HDfprintf(stdout, "%s: HDF file name = \"%s\".\n", + fcn_name, hdf_file_name); + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* create a file access propertly list. */ + if ( pass ) { + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + + if ( fapl_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* call H5Pset_libver_bounds() on the fapl_id */ + if ( pass ) { + + if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) + < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_libver_bounds() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get metadata cache image config -- verify that it is the default */ + if ( pass ) { + + result = H5Pget_mdc_image_config(fapl_id, &cache_image_config); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pget_mdc_image_config() failed.\n"; + } + + if ( ( cache_image_config.version != + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || + ( cache_image_config.generate_image != FALSE ) || + ( cache_image_config.save_resize_status != FALSE ) || + ( cache_image_config.entry_ageout != + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ) { + + pass = FALSE; + failure_mssg = "Unexpected default cache image config.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* set metadata cache image fapl entry if indicated */ + if ( ( pass ) && ( set_mdci_fapl ) ) { + + /* set cache image config fields to taste */ + cache_image_config.generate_image = TRUE; + cache_image_config.save_resize_status = FALSE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + + result = H5Pset_mdc_image_config(fapl_id, &cache_image_config); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_mdc_image_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* setup the persistant free space manager if indicated */ + if ( ( pass ) && ( config_fsm ) ) { + + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + + if ( fcpl_id <= 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed."; + } + } + + if ( ( pass ) && ( config_fsm ) ) { + + if ( H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, + TRUE, (hsize_t)1) == FAIL ) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_strategy() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + + /* set Parallel access with communicator */ + if ( H5Pset_fapl_mpio(fapl_id, comm, info) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_fapl_mpio() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + + if (H5Pset_all_coll_metadata_ops(fapl_id, all_coll_metadata_ops) < 0) { + + pass = FALSE; + failure_mssg = "H5Pset_all_coll_metadata_ops() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + + if ( H5Pset_coll_metadata_write(fapl_id, coll_metadata_write) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_coll_metadata_write() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + + /* set the desired parallel metadata write strategy */ + H5AC_cache_config_t mdc_config; + + mdc_config.version = H5C__CURR_AUTO_SIZE_CTL_VER; + + if ( H5Pget_mdc_config(fapl_id, &mdc_config) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pget_mdc_config() failed.\n"; + } + + mdc_config.metadata_write_strategy = md_write_strat; + + if ( H5Pset_mdc_config(fapl_id, &mdc_config) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_mdc_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* open the file */ + if ( pass ) { + + if ( create_file ) { + + if ( fcpl_id != -1 ) + + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, + fcpl_id, fapl_id); + else + + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, + H5P_DEFAULT, fapl_id); + + } else { + + if ( read_only ) + + file_id = H5Fopen(hdf_file_name, H5F_ACC_RDONLY, fapl_id); + + else + + file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR, fapl_id); + } + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fcreate() or H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + if ( verbose ) { + HDfprintf(stdout, "%s: Can't get file_ptr.\n", fcn_name); + } + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* verify expected metadata cache status */ + + /* get the cache image control structure from the cache, and verify + * that it contains the expected values. + * + * Then set the flags in this structure to the specified value. + */ + if ( pass ) { + + if ( H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0 ) { + + pass = FALSE; + failure_mssg = "error returned by H5C_get_cache_image_config()."; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( set_mdci_fapl ) { + + if ( read_only ) { + + if ( ( image_ctl.version != + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || + ( image_ctl.generate_image != FALSE ) || + ( image_ctl.save_resize_status != FALSE ) || + ( image_ctl.entry_ageout != + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || + ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + + pass = FALSE; + failure_mssg = "Unexpected image_ctl values(1).\n"; + } + } else { + + if ( ( image_ctl.version != + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || + ( image_ctl.generate_image != TRUE ) || + ( image_ctl.save_resize_status != FALSE ) || + ( image_ctl.entry_ageout != + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || + ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + + pass = FALSE; + failure_mssg = "Unexpected image_ctl values(2).\n"; + } + } + } else { + + if ( ( image_ctl.version != + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || + ( image_ctl.generate_image != FALSE ) || + ( image_ctl.save_resize_status != FALSE ) || + ( image_ctl.entry_ageout != + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || + ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + + pass = FALSE; + failure_mssg = "Unexpected image_ctl values(3).\n"; + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( ( pass ) && ( set_mdci_fapl ) ) { + + image_ctl.flags = cache_image_flags; + + if ( H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0 ) { + + pass = FALSE; + failure_mssg = "error returned by H5C_set_cache_image_config()."; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( cache_ptr->close_warning_received == TRUE ) { + + pass = FALSE; + failure_mssg = "Unexpected value of close_warning_received.\n"; + } + + if ( mdci_sbem_expected ) { + + if ( read_only ) { + + if ( ( cache_ptr->load_image != TRUE ) || + ( cache_ptr->delete_image != FALSE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message not present?\n"; + } + } else { + + if ( ( cache_ptr->load_image != TRUE ) || + ( cache_ptr->delete_image != TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message not present?\n"; + } + } + } else { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + *file_id_ptr = file_id; + *file_ptr_ptr = file_ptr; + *cache_ptr_ptr = cache_ptr; + } + + if ( show_progress ) { + HDfprintf(stdout, "%s: cp = %d, pass = %d -- exiting.\n", + fcn_name, cp++, pass); + + if ( ! pass ) + HDfprintf(stdout, "%s: failure_mssg = %s\n", + fcn_name, failure_mssg); + } + + return; + +} /* open_hdf5_file() */ + + +/*------------------------------------------------------------------------- + * Function: parse_flags + * + * Purpose: Parse the flags passed to this program, and load the + * values into the supplied field. + * + * Return: Success: 1 + * Failure: 0 + * + * Programmer: J Mainzer + * 4/28/11 + * + *------------------------------------------------------------------------- + */ +hbool_t +parse_flags(int argc, char * argv[], hbool_t * setup_ptr, hbool_t display) +{ + const char * fcn_name = "parse_flags()"; + const char * (ops[]) = {"setup"}; + int success = TRUE; + + if ( setup_ptr == NULL ) { + + success = FALSE; + HDfprintf(stdout, "%s: bad arg(s) on entry.\n", fcn_name); + } + + if ( ( success ) && + ( ( argc < 1 ) || ( argc > 2 ) ) ) { + + success = FALSE; + usage(); + } + + if ( success ) { + + if ( argc == 2 ) { + + if ( strcmp(argv[1], ops[0]) == 0 ) { + + *setup_ptr = TRUE; + + } else { + + success = FALSE; + usage(); + } + } else { + + *setup_ptr = FALSE; + } + } + + if ( ( success ) && ( display ) ) { + + if ( *setup_ptr ) + HDfprintf(stdout, "t_cache_image setup\n"); + else + HDfprintf(stdout, "t_cache_image\n"); + } + + return(success); + +} /* parse_flags() */ + + +/*------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Display a brief message describing the purpose and use + * of the program. + * + * Return: void + * + * Programmer: John Mainzer + * 4/28/11 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +usage(void) +{ + const char * s[] = + { + "\n", + "t_cache_image:\n", + "\n", + "Run the parallel cache image tests. \n" + "\n" + "In general, this program is run via MPI. However, at present, files\n" + "with cache images can only be constructed by serial processes.\n", + "\n", + "To square this circle, one process in the parallel computation \n" + "forks a serial version of the test program to handle this detail.\n", + "The \"setup\" parameter indicates that t_cache_image is being \n", + "invokde for this purpose.\n", + "\n", + "usage: t_cache_image [setup]\n", + "\n", + "where:\n", + "\n", + " setup parameter forces creation of test file\n", + "\n", + "Returns 0 on success, 1 on failure.\n", + "\n", + NULL, + }; + int i = 0; + + while(s[i] != NULL) { + fprintf(stdout, "%s", s[i]); + i++; + } + + return; +} /* usage() */ + + +/*------------------------------------------------------------------------- + * Function: verify_data_sets() + * + * Purpose: If pass is TRUE on entry, verify that the data sets in the + * file exist and contain the expected data. + * + * Note that these data sets were created by + * create_data_sets() above. Thus any changes in that + * function must be reflected in this function, and + * vise-versa. + * + * On failure, set pass to FALSE, and set failure_mssg + * to point to an appropriate failure message. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 7/15/15 + * + * Modifications: + * + * Added min_dset and max_dset parameters and supporting + * code. This allows the caller to specify a range of + * datasets to verify. + * JRM -- 8/20/15 + * + *------------------------------------------------------------------------- + */ + +static void +verify_data_sets(hid_t file_id, int min_dset, int max_dset) +{ + const char * fcn_name = "verify_data_sets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + HDassert(0 <= min_dset); + HDassert(min_dset <= max_dset); + HDassert(max_dset < MAX_NUM_DSETS); + + /* open the datasets */ + + if ( pass ) { + + i = min_dset; + + while ( ( pass ) && ( i <= max_dset ) ) + { + /* open the dataset */ + if ( pass ) { + + sprintf(dset_name, "/dset%03d", i); + dataset_ids[i] = H5Dopen2(file_id, dset_name, H5P_DEFAULT); + + if ( dataset_ids[i] < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dopen2() failed."; + } + } + + /* get the file space ID */ + if ( pass ) { + + filespace_ids[i] = H5Dget_space(dataset_ids[i]); + + if ( filespace_ids[i] < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dget_space() failed."; + } + } + + i++; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* create the mem space to be used to read and write chunks */ + if ( pass ) { + + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; + memspace_id = H5Screate_simple(2, dims, NULL); + + if ( memspace_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Screate_simple() failed."; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* select in memory hyperslab */ + if ( pass ) { + + offset[0] = 0; /*offset of hyperslab in memory*/ + offset[1] = 0; + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[1] = CHUNK_SIZE; + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, + a_size, NULL); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sselect_hyperslab() failed."; + } + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + + /* read data from data sets and validate it */ + i = 0; + while ( ( pass ) && ( i < DSET_SIZE ) ) + { + j = 0; + while ( ( pass ) && ( j < DSET_SIZE ) ) + { + m = min_dset; + while ( ( pass ) && ( m <= max_dset ) ) + { + + /* select on disk hyperslab */ + offset[0] = (hsize_t)i; /* offset of hyperslab in file */ + offset[1] = (hsize_t)j; + a_size[0] = CHUNK_SIZE; /* size of hyperslab */ + a_size[1] = CHUNK_SIZE; + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, + offset, NULL, a_size, NULL); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; + } + + /* read the chunk from file */ + if ( pass ) { + + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, + memspace_id, filespace_ids[m], + H5P_DEFAULT, data_chunk); + + if ( status < 0 ) { + + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; + } + } + + /* validate the slab */ + if ( pass ) { + + valid_chunk = TRUE; + for ( k = 0; k < CHUNK_SIZE; k++ ) + { + for ( l = 0; l < CHUNK_SIZE; l++ ) + { + if ( data_chunk[k][l] + != + ((DSET_SIZE * DSET_SIZE * m) + + (DSET_SIZE * (i + k)) + j + l) ) { + + valid_chunk = FALSE; + + if ( verbose ) { + + HDfprintf(stdout, + "data_chunk[%0d][%0d] = %0d, expect %0d.\n", + k, l, data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, + "m = %d, i = %d, j = %d, k = %d, l = %d\n", + m, i, j, k, l); + } + } + } + } + + if ( ! valid_chunk ) { + + pass = FALSE; + failure_mssg = "slab validation failed."; + + if ( verbose ) { + + fprintf(stdout, + "Chunk (%0d, %0d) in /dset%03d is invalid.\n", + i, j, m); + } + } + } + m++; + } + j += CHUNK_SIZE; + } + i += CHUNK_SIZE; + } + + if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + + /* close the file spaces */ + i = min_dset; + while ( ( pass ) && ( i <= max_dset ) ) + { + if ( H5Sclose(filespace_ids[i]) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sclose() failed."; + } + i++; + } + + + /* close the datasets */ + i = min_dset; + while ( ( pass ) && ( i <= max_dset ) ) + { + if ( H5Dclose(dataset_ids[i]) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Dclose() failed."; + } + i++; + } + + /* close the mem space */ + if ( pass ) { + + if ( H5Sclose(memspace_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Sclose(memspace_id) failed."; + } + } + + return; + +} /* verify_data_sets() */ + + +/****************************************************************************/ +/******************************* Test Functions *****************************/ +/****************************************************************************/ + +/*------------------------------------------------------------------------- + * Function: verify_cache_image_RW() + * + * Purpose: Verify that a HDF5 file containing a cache image is + * opened and read correctly by PHDF5 with the specified + * metadata write strategy. + * + * Basic cycle of operation is as follows: + * + * 1) Open the test file created at the beginning of this + * test. + * + * Verify that the file contains a cache image. + * + * Verify that only process 0 reads the cache image. + * + * Verify that all other processes receive the cache + * image block from process 0. + * + * 2) Verify that the file contains the expected data. + * + * 3) Close the file. + * + * 4) Open the file, and verify that it doesn't contain + * a cache image. + * + * 5) Verify that the file contains the expected data. + * + * 6) Close the file. + * + * 7) Delete the file. + * + * Return: void + * + * Programmer: John Mainzer + * 1/25/17 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static unsigned +verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) +{ + const char * fcn_name = "verify_cache_imageRW()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + int cp = 0; + int i; + + pass = TRUE; + + if ( mpi_rank == 0 ) { + + switch(md_write_strat) { + + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + TESTING("parallel CI load test -- proc0 md write -- R/W"); + break; + + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + TESTING("parallel CI load test -- dist md write -- R/W"); + break; + + default: + TESTING("parallel CI load test -- unknown md write -- R/W"); + pass = FALSE; + break; + } + } + + show_progress = ( ( show_progress ) && ( mpi_rank == 0 ) ); + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + if ( h5_fixname(FILENAMES[file_name_id], H5P_DEFAULT, + filename, sizeof(filename)) == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 1) Open the test file created at the beginning of this test. + * + * Verify that the file contains a cache image. + * + * Verify that only process 0 reads the cache image. + * + * Verify that all other processes receive the cache + * image block from process 0. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr, + /* comm */ MPI_COMM_WORLD, + /* info */ MPI_INFO_NULL, + /* l_facc_type */ FACC_MPIO, + /* all_coll_metadata_ops */ FALSE, + /* coll_metadata_write */ FALSE, + /* md_write_strat */ md_write_strat); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* Verify that only process 0 reads the cache image. */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* Verify that all other processes receive the cache image block + * from process 0. + */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Verify that the file contains the expected data. */ + if ( pass ) { + + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded == 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + + /* 3) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 4) Open the file, and verify that it doesn't contain a cache image. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr, + /* comm */ MPI_COMM_WORLD, + /* info */ MPI_INFO_NULL, + /* l_facc_type */ FACC_MPIO, + /* all_coll_metadata_ops */ FALSE, + /* coll_metadata_write */ FALSE, + /* md_write_strat */ md_write_strat); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 5) Verify that the file contains the expected data. */ + + if ( pass ) { + + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + + /* 6) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 7) Delete the file. */ + + if ( pass ) { + + /* wait for everyone to close the file */ + MPI_Barrier(MPI_COMM_WORLD); + + if ( ( mpi_rank == 0 ) && ( HDremove(filename) < 0 ) ) { + + pass = FALSE; + failure_mssg = "HDremove() failed.\n"; + } + } + + + /* report results */ + if ( mpi_rank == 0 ) { + + if ( pass ) { + + PASSED(); + + } else { + + H5_FAILED(); + + if ( show_progress ) + HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", failure_mssg); + } + } + + + return !pass; + +} /* verify_cache_imageRW() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Run parallel tests on the cache image feature. + * + * At present, cache image is disabled in parallel, and + * thus these tests are restructed to verifying that a + * file with a cache image can be opened in the parallel + * case, and verifying that instructions to create a + * cache image are ignored in the parallel case. + * + * WARNING: This test uses fork() and execve(), and + * therefore will not run on Windows. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: John Mainzer + * 1/25/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +int +main(int argc, char **argv) +{ + hbool_t setup = FALSE; + unsigned nerrs = 0; + int i; + int mpi_size; + int mpi_rank; + + if ( ! parse_flags(argc, argv, &setup, FALSE) ) + exit(1); /* exit now if unable to parse flags */ + + if ( setup ) { /* construct test file and exit */ + + H5open(); + HDfprintf(stdout, "Constructing test files: \n"); + HDfflush(stdout); + + i = 0; + while ( FILENAMES[i] != NULL ) { + + HDfprintf(stdout, " writing %s ... ", FILENAMES[i]); + HDfflush(stdout); + construct_test_file(i); + + if ( pass ) { + + printf("done.\n"); + HDfflush(stdout); + + } else { + + printf("failed.\n"); + exit(1); + } + i++; + } + HDfprintf(stdout, "Test file construction complete.\n"); + exit(0); + } + + HDassert(!setup); + + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + + /* Attempt to turn off atexit post processing so that in case errors + * happen during the test and the process is aborted, it will not get + * hang in the atexit post processing in which it may try to make MPI + * calls. By then, MPI calls may not work. + */ + if (H5dont_atexit() < 0){ + printf("%d:Failed to turn off atexit processing. Continue.\n", + mpi_rank); + }; + + H5open(); + + if ( mpi_rank == 0 ) { + printf("===================================\n"); + printf("Parallel metadata cache image tests\n"); + printf(" mpi_size = %d\n", mpi_size); + printf("===================================\n"); + } + + if ( mpi_size < 2 ) { + + if ( mpi_rank == 0 ) { + + printf(" Need at least 2 processes. Exiting.\n"); + } + goto finish; + } + + if ( mpi_rank == 0 ) { /* create test files */ + + int child_status; + pid_t child_pid; + + child_pid = fork(); + + if ( child_pid == 0 ) { /* this is the child process */ + + /* fun and games to shutup the compiler */ + char param0[32] = "t_cache_image"; + char param1[32] = "setup"; + char * child_argv[] = {param0, param1, NULL}; + + /* we may need to play with the path here */ + if ( execv("t_cache_image", child_argv) == -1 ) { + + HDfprintf(stdout, + "execl() of setup process failed. errno = %d(%s)\n", + errno, strerror(errno)); + exit(1); + } + + } else if ( child_pid != -1 ) { + /* this is the parent process -- wait until child is done */ + if ( -1 == waitpid(child_pid, &child_status, WUNTRACED)) { + + HDfprintf(stdout, "can't wait on setup process.\n"); + + } else if ( ! WIFEXITED(child_status) ) { + + HDfprintf(stdout, "setup process hasn't exitied.\n"); + + } else if ( WEXITSTATUS(child_status) != 0 ) { + + HDfprintf(stdout, "setup process reports failure.\n"); + + } else { + + HDfprintf(stdout, + "testfile construction complete -- proceeding with tests.\n"); + } + } else { /* fork failed */ + + HDfprintf(stdout, "can't create process to construct test file.\n"); + } + } + + /* can't start test until test file exists */ + MPI_Barrier(MPI_COMM_WORLD); + + nerrs += verify_cache_image_RW(0, + H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, mpi_rank); + nerrs += verify_cache_image_RW(1, + H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, mpi_rank); + +finish: + + /* make sure all processes are finished before final report, cleanup + * and exit. + */ + MPI_Barrier(MPI_COMM_WORLD); + + if ( mpi_rank == 0 ) { /* only process 0 reports */ + sleep(10); + printf("===================================\n"); + if ( nerrs > 0 ) { + printf("***metadata cache image tests detected %d failures***\n", + nerrs); + } + else { + printf("metadata cache image tests finished with no failures\n"); + } + printf("===================================\n"); + } + + /* takedown_derived_types(); */ + + /* close HDF5 library */ + H5close(); + + /* MPI_Finalize must be called AFTER H5close which may use MPI calls */ + MPI_Finalize(); + + /* cannot just return (nerrs) because exit code is limited to 1byte */ + return(nerrs > 0); + +} /* main() */ + diff --git a/testpar/t_file.c b/testpar/t_file.c index b2f1d5e..4a923d4 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -19,6 +19,30 @@ #include "testphdf5.h" +#include "H5PBprivate.h" +#include "H5Iprivate.h" + +/* + * This file needs to access private information from the H5F package. + */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#include "H5Cpkg.h" +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ +#include "H5ACpkg.h" +#define H5MF_FRIEND /*suppress error about including H5MFpkg */ +#include "H5MFpkg.h" +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" + +#define NUM_DSETS 5 + +int mpi_size, mpi_rank; + +static int create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_strategy); +static int open_file(const char *filename, hid_t fapl, int metadata_write_strategy, + hsize_t page_size, size_t page_buffer_size); + /* * test file access by communicator besides COMM_WORLD. * Split COMM_WORLD into two, one (even_comm) contains the original @@ -33,7 +57,6 @@ void test_split_comm_access(void) { - int mpi_size, mpi_rank; MPI_Comm comm; MPI_Info info = MPI_INFO_NULL; int is_old, mrc; @@ -95,6 +118,595 @@ test_split_comm_access(void) } void +test_page_buffer_access(void) +{ + hid_t file_id = -1; /* File ID */ + hid_t fcpl, fapl, fapl_self; + hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT; + size_t page_count = 0; + int i, num_elements = 200; + haddr_t raw_addr, meta_addr; + int *data; + H5F_t *f = NULL; + herr_t ret; /* generic return value */ + const char *filename; + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + + filename = (const char *)GetTestParameters(); + + if (VERBOSE_MED) + printf("Page Buffer Usage in Parallel %s\n", filename); + + fapl = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); + VRFY((fapl >= 0), "create_faccess_plist succeeded"); + fcpl = H5Pcreate(H5P_FILE_CREATE); + VRFY((fcpl >= 0), ""); + + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0); + VRFY((ret == 0), ""); + ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*100); + VRFY((ret == 0), ""); + ret = H5Pset_page_buffer_size(fapl, sizeof(int)*100000, 0, 0); + VRFY((ret == 0), ""); + + /* This should fail because collective metadata writes are not supported with page buffering */ + H5E_BEGIN_TRY { + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VRFY((file_id < 0), "H5Fcreate failed"); + + /* disable collective metadata writes for page buffering to work */ + ret = H5Pset_coll_metadata_write(fapl, FALSE); + VRFY((ret >= 0), ""); + + ret = create_file(filename, fcpl, fapl, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); + VRFY((ret == 0), ""); + ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, sizeof(int)*100, sizeof(int)*100000); + VRFY((ret == 0), ""); + + ret = create_file(filename, fcpl, fapl, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); + VRFY((ret == 0), ""); + ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, sizeof(int)*100, sizeof(int)*100000); + VRFY((ret == 0), ""); + + ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*100); + VRFY((ret == 0), ""); + + data = (int *) HDmalloc(sizeof(int)*(size_t)num_elements); + + /* intialize all the elements to have a value of -1 */ + for(i=0 ; i= 0), ""); + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_self); + VRFY((file_id >= 0), ""); + + /* Get a pointer to the internal file object */ + f = (H5F_t *)H5I_object(file_id); + + VRFY((f->shared->page_buf != NULL), "Page Buffer created with 1 process"); + + /* allocate space for 200 raw elements */ + raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements); + VRFY((raw_addr != HADDR_UNDEF), ""); + + /* allocate space for 200 metadata elements */ + meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements); + VRFY((meta_addr != HADDR_UNDEF), ""); + + page_count = 0; + + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, H5AC_ind_read_dxpl_id, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*(size_t)num_elements, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update the first 50 elements */ + for(i=0 ; i<50 ; i++) + data[i] = i; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + H5Eprint2(H5E_DEFAULT, stderr); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + page_count += 2; + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update the second 50 elements */ + for(i=0 ; i<50 ; i++) + data[i] = i+50; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*50), sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*50), sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update 100 - 200 */ + for(i=0 ; i<100 ; i++) + data[i] = i+100; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), sizeof(int)*100, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*100, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + ret = H5PB_flush(f, dxpl_id, FALSE); + VRFY((ret == 0), ""); + + /* read elements 0 - 200 */ + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*200, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 200; i++) + VRFY((data[i] == i), "Read different values than written"); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*200, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 200; i++) + VRFY((data[i] == i), "Read different values than written"); + + /* read elements 0 - 50 */ + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == i), "Read different values than written"); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == i), "Read different values than written"); + + /* close the file */ + ret = H5Fclose(file_id); + VRFY((ret >= 0), "H5Fclose succeeded"); + ret = H5Pclose(fapl_self); + VRFY((ret>=0), "H5Pclose succeeded"); + } +#endif + + MPI_Barrier(MPI_COMM_WORLD); + + if(mpi_size > 1) { + ret = H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 0, 0); + VRFY((ret == 0), ""); + /* collective metadata writes do not work with page buffering */ + ret = H5Pset_coll_metadata_write(fapl, FALSE); + VRFY((ret >= 0), ""); + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + VRFY((file_id >= 0), ""); + + /* Get a pointer to the internal file object */ + f = (H5F_t *)H5I_object(file_id); + + VRFY((f->shared->page_buf != NULL), "Page Buffer created with 1 process"); + + /* allocate space for 200 raw elements */ + raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements); + VRFY((raw_addr != HADDR_UNDEF), ""); + /* allocate space for 200 metadata elements */ + meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, H5AC_ind_read_dxpl_id, sizeof(int)*(size_t)num_elements); + VRFY((meta_addr != HADDR_UNDEF), ""); + + page_count = 0; + + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*(size_t)num_elements, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update the first 50 elements */ + for(i=0 ; i<50 ; i++) + data[i] = i; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update the second 50 elements */ + for(i=0 ; i<50 ; i++) + data[i] = i+50; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*50), sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*50), sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* update 100 - 200 */ + for(i=0 ; i<100 ; i++) + data[i] = i+100; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), sizeof(int)*100, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*100, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + VRFY((ret == 0), ""); + + /* read elements 0 - 200 */ + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*200, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 200; i++) + VRFY((data[i] == i), "Read different values than written"); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*200, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 200; i++) + VRFY((data[i] == i), "Read different values than written"); + + /* read elements 0 - 50 */ + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == i), "Read different values than written"); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + page_count += 1; + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == i), "Read different values than written"); + + MPI_Barrier(MPI_COMM_WORLD); + /* reset the first 50 elements to -1*/ + for(i=0 ; i<50 ; i++) + data[i] = -1; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + + /* read elements 0 - 50 */ + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, H5AC_rawdata_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == -1), "Read different values than written"); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, H5AC_ind_read_dxpl_id, data); + VRFY((ret == 0), ""); + VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); + for (i=0; i < 50; i++) + VRFY((data[i] == -1), "Read different values than written"); + + /* close the file */ + ret = H5Fclose(file_id); + VRFY((ret >= 0), "H5Fclose succeeded"); + } + + ret = H5Pclose(fapl); + VRFY((ret>=0), "H5Pclose succeeded"); + ret = H5Pclose(fcpl); + VRFY((ret>=0), "H5Pclose succeeded"); + + HDfree(data); + data = NULL; + MPI_Barrier(MPI_COMM_WORLD); +} + +static int +create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_strategy) +{ + hid_t file_id, dset_id, grp_id; + hid_t sid, mem_dataspace; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + DATATYPE *data_array = NULL; + hsize_t dims[RANK], i; + hsize_t num_elements; + int k; + char dset_name[10]; + H5F_t *f = NULL; + H5C_t *cache_ptr = NULL; + H5AC_cache_config_t config; + herr_t ret; + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + VRFY((file_id >= 0), ""); + + ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + VRFY((ret == 0), ""); + + f = (H5F_t *)H5I_object(file_id); + VRFY((f != NULL), ""); + + cache_ptr = f->shared->cache; + VRFY((cache_ptr->magic == H5C__H5C_T_MAGIC), ""); + + cache_ptr->ignore_tags = TRUE; + H5C_stats__reset(cache_ptr); + config.version = H5AC__CURR_CACHE_CONFIG_VERSION; + + ret = H5AC_get_cache_auto_resize_config(cache_ptr, &config); + VRFY((ret == 0), ""); + + config.metadata_write_strategy = metadata_write_strategy; + + ret = H5AC_set_cache_auto_resize_config(cache_ptr, &config); + VRFY((ret == 0), ""); + + grp_id = H5Gcreate2(file_id, "GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((grp_id >= 0), ""); + + dims[0] = ROW_FACTOR*mpi_size; + dims[1] = COL_FACTOR*mpi_size; + sid = H5Screate_simple (RANK, dims, NULL); + VRFY((sid >= 0), "H5Screate_simple succeeded"); + + /* Each process takes a slabs of rows. */ + block[0] = dims[0]/mpi_size; + block[1] = dims[1]; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = mpi_rank*block[0]; + start[1] = 0; + + num_elements = block[0] * block[1]; + /* allocate memory for data buffer */ + data_array = (DATATYPE *)HDmalloc(num_elements*sizeof(DATATYPE)); + VRFY((data_array != NULL), "data_array HDmalloc succeeded"); + /* put some trivial data in the data_array */ + for(i=0 ; i= 0), "H5Sset_hyperslab succeeded"); + + /* create a memory dataspace independently */ + mem_dataspace = H5Screate_simple (1, &num_elements, NULL); + VRFY((mem_dataspace >= 0), ""); + + for(k=0 ; k= 0), ""); + ret = H5Dclose(dset_id); + VRFY((ret == 0), ""); + + sprintf(dset_name, "D2dset%d", k); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((dset_id >= 0), ""); + ret = H5Dclose(dset_id); + VRFY((ret == 0), ""); + + sprintf(dset_name, "D3dset%d", k); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((dset_id >= 0), ""); + ret = H5Dclose(dset_id); + VRFY((ret == 0), ""); + + sprintf(dset_name, "dset%d", k); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((dset_id >= 0), ""); + + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); + VRFY((ret == 0), ""); + + ret = H5Dclose(dset_id); + VRFY((ret == 0), ""); + + HDmemset(data_array, 0, num_elements*sizeof(DATATYPE)); + dset_id = H5Dopen2(grp_id, dset_name, H5P_DEFAULT); + VRFY((dset_id >= 0), ""); + + ret = H5Dread(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); + VRFY((ret == 0), ""); + + ret = H5Dclose(dset_id); + VRFY((ret == 0), ""); + + for (i=0; i < num_elements; i++) + VRFY((data_array[i] == mpi_rank+1), "Dataset Verify failed"); + + sprintf(dset_name, "D1dset%d", k); + ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); + VRFY((ret == 0), ""); + sprintf(dset_name, "D2dset%d", k); + ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); + VRFY((ret == 0), ""); + sprintf(dset_name, "D3dset%d", k); + ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); + VRFY((ret == 0), ""); + } + + ret = H5Gclose(grp_id); + VRFY((ret == 0), ""); + ret = H5Fclose(file_id); + VRFY((ret == 0), ""); + ret = H5Sclose(sid); + VRFY((ret == 0), ""); + ret = H5Sclose(mem_dataspace); + VRFY((ret == 0), ""); + + MPI_Barrier(MPI_COMM_WORLD); + HDfree(data_array); + return 0; +} /* create_file */ + +static int +open_file(const char *filename, hid_t fapl, int metadata_write_strategy, + hsize_t page_size, size_t page_buffer_size) +{ + hid_t file_id, dset_id, grp_id, grp_id2; + hid_t sid, mem_dataspace; + DATATYPE *data_array = NULL; + hsize_t dims[RANK]; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + int i, k, ndims; + hsize_t num_elements; + char dset_name[10]; + H5F_t *f = NULL; + H5C_t *cache_ptr = NULL; + H5AC_cache_config_t config; + herr_t ret; + + config.version = H5AC__CURR_CACHE_CONFIG_VERSION; + ret = H5Pget_mdc_config(fapl, &config); + VRFY((ret == 0), ""); + + config.metadata_write_strategy = metadata_write_strategy; + + ret = H5Pget_mdc_config(fapl, &config); + VRFY((ret == 0), ""); + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl); + H5Eprint2(H5E_DEFAULT, stderr); + VRFY((file_id >= 0), ""); + + ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + VRFY((ret == 0), ""); + + f = (H5F_t *)H5I_object(file_id); + VRFY((f != NULL), ""); + + cache_ptr = f->shared->cache; + VRFY((cache_ptr->magic == H5C__H5C_T_MAGIC), ""); + + MPI_Barrier(MPI_COMM_WORLD); + + VRFY((f->shared->page_buf != NULL), ""); + VRFY((f->shared->page_buf->page_size == page_size), ""); + VRFY((f->shared->page_buf->max_size == page_buffer_size), ""); + + grp_id = H5Gopen2(file_id, "GROUP", H5P_DEFAULT); + VRFY((grp_id >= 0), ""); + + dims[0] = ROW_FACTOR*mpi_size; + dims[1] = COL_FACTOR*mpi_size; + + /* Each process takes a slabs of rows. */ + block[0] = dims[0]/mpi_size; + block[1] = dims[1]; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = mpi_rank*block[0]; + start[1] = 0; + + num_elements = block[0] * block[1]; + /* allocate memory for data buffer */ + data_array = (DATATYPE *)HDmalloc(num_elements*sizeof(DATATYPE)); + VRFY((data_array != NULL), "data_array HDmalloc succeeded"); + + /* create a memory dataspace independently */ + mem_dataspace = H5Screate_simple (1, &num_elements, NULL); + VRFY((mem_dataspace >= 0), ""); + + for(k=0 ; k= 0), ""); + + sid = H5Dget_space(dset_id); + VRFY((dset_id >= 0), "H5Dget_space succeeded"); + + ndims = H5Sget_simple_extent_dims(sid, dims, NULL); + VRFY((ndims == 2), "H5Sget_simple_extent_dims succeeded"); + VRFY(dims[0] == ROW_FACTOR*mpi_size, "Wrong dataset dimensions"); + VRFY(dims[1] == COL_FACTOR*mpi_size, "Wrong dataset dimensions"); + + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); + + ret = H5Dread(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); + VRFY((ret >= 0), ""); + + ret = H5Dclose(dset_id); + VRFY((ret >= 0), ""); + ret = H5Sclose(sid); + VRFY((ret == 0), ""); + + for (i=0; i < num_elements; i++) + VRFY((data_array[i] == mpi_rank+1), "Dataset Verify failed"); + } + + grp_id2 = H5Gcreate2(file_id, "GROUP/GROUP2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((grp_id2 >= 0), ""); + ret = H5Gclose(grp_id2); + VRFY((ret == 0), ""); + + ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + VRFY((ret == 0), ""); + + MPI_Barrier(MPI_COMM_WORLD); + /* flush invalidate each ring, starting from the outermost ring and + * working inward. + */ + for ( i = 0; i < H5C__HASH_TABLE_LEN; i++ ) { + H5C_cache_entry_t * entry_ptr = NULL; + + entry_ptr = cache_ptr->index[i]; + + while ( entry_ptr != NULL ) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->is_dirty == FALSE); + + if(!entry_ptr->is_pinned && !entry_ptr->is_protected) { + ret = H5AC_expunge_entry(f, H5AC_ind_read_dxpl_id, entry_ptr->type, entry_ptr->addr, 0); + VRFY((ret == 0), ""); + } + + entry_ptr = entry_ptr->ht_next; + } + } + MPI_Barrier(MPI_COMM_WORLD); + + grp_id2 = H5Gopen2(file_id, "GROUP/GROUP2", H5P_DEFAULT); + H5Eprint2(H5E_DEFAULT, stderr); + VRFY((grp_id2 >= 0), ""); + ret = H5Gclose(grp_id2); + H5Eprint2(H5E_DEFAULT, stderr); + VRFY((ret == 0), ""); + + ret = H5Gclose(grp_id); + VRFY((ret == 0), ""); + ret = H5Fclose(file_id); + VRFY((ret == 0), ""); + ret = H5Sclose(mem_dataspace); + VRFY((ret == 0), ""); + HDfree(data_array); + + return nerrors; +} + +void test_file_properties(void) { hid_t fid; /* HDF5 file ID */ @@ -103,7 +715,6 @@ test_file_properties(void) const char *filename; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; - int mpi_size, mpi_rank; herr_t ret; /* Generic return value */ filename = (const char *)GetTestParameters(); diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c index 7077081..39cfbbc 100644 --- a/testpar/t_mdset.c +++ b/testpar/t_mdset.c @@ -510,7 +510,7 @@ void big_dataset(void) /* Check that file of the correct size was created */ file_size = h5_get_file_size(filename, fapl); - VRFY((file_size == 2147485792ULL), "File is correct size(~2GB)"); + VRFY((file_size == 2147485696ULL), "File is correct size(~2GB)"); /* * Create >4GB HDF5 file @@ -539,7 +539,7 @@ void big_dataset(void) /* Check that file of the correct size was created */ file_size = h5_get_file_size(filename, fapl); - VRFY((file_size == 4294969440ULL), "File is correct size(~4GB)"); + VRFY((file_size == 4294969344ULL), "File is correct size(~4GB)"); /* * Create >8GB HDF5 file @@ -568,7 +568,7 @@ void big_dataset(void) /* Check that file of the correct size was created */ file_size = h5_get_file_size(filename, fapl); - VRFY((file_size == 8589936736ULL), "File is correct size(~8GB)"); + VRFY((file_size == 8589936640ULL), "File is correct size(~8GB)"); /* Close fapl */ ret = H5Pclose(fapl); diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index c54cb5e..a58452e 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -351,6 +351,11 @@ int main(int argc, char **argv) AddTest("split", test_split_comm_access, NULL, "dataset using split communicators", PARATESTFILE); +#ifdef PB_OUT /* temporary: disable page buffering when parallel */ + AddTest("page_buffer", test_page_buffer_access, NULL, + "page buffer usage in parallel", PARATESTFILE); +#endif + AddTest("props", test_file_properties, NULL, "Coll Metadata file property settings", PARATESTFILE); diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 9838673..0cf5857 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -246,6 +246,7 @@ void collective_group_write(void); void independent_group_read(void); void test_fapl_mpio_dup(void); void test_split_comm_access(void); +void test_page_buffer_access(void); void dataset_atomicity(void); void dataset_writeInd(void); void dataset_writeAll(void); diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 182d570..c78f325 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -1186,9 +1186,11 @@ dump_fcpl(hid_t fid) hsize_t userblock; /* userblock size retrieved from FCPL */ size_t off_size; /* size of offsets in the file */ size_t len_size; /* size of lengths in the file */ - H5F_file_space_type_t fs_strategy; /* file space strategy */ - hsize_t fs_threshold; /* free-space section threshold */ - H5F_info2_t finfo; /* file information */ + H5F_fspace_strategy_t fs_strategy; /* file space strategy */ + hbool_t fs_persist; /* Persisting free-space or not */ + hsize_t fs_threshold; /* free-space section threshold */ + hsize_t fsp_size; /* file space page size */ + H5F_info2_t finfo; /* file information */ #ifdef SHOW_FILE_DRIVER hid_t fapl; /* file access property list ID */ hid_t fdriver; /* file driver */ @@ -1204,7 +1206,8 @@ dump_fcpl(hid_t fid) H5Pget_sizes(fcpl,&off_size,&len_size); H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); H5Pget_istore_k(fcpl,&istore_ik); - H5Pget_file_space(fcpl, &fs_strategy, &fs_threshold); + H5Pget_file_space_strategy(fcpl, &fs_strategy, &fs_persist, &fs_threshold); + H5Pget_file_space_page_size(fcpl, &fsp_size); H5Pclose(fcpl); #ifdef SHOW_FILE_DRIVER fapl=h5_fileaccess(); @@ -1265,18 +1268,22 @@ dump_fcpl(hid_t fid) PRINTSTREAM(rawoutstream, "%s %u\n","ISTORE_K", istore_ik); indentation(dump_indent + COL); - if(fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL_PERSIST"); - } else if(fs_strategy == H5F_FILE_SPACE_ALL) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL"); - } else if(fs_strategy == H5F_FILE_SPACE_AGGR_VFD) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_AGGR_VFD"); - } else if(fs_strategy == H5F_FILE_SPACE_VFD) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_VFD"); + if(fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) { + PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_FSM_AGGR"); + } else if(fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { + PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_PAGE"); + } else if(fs_strategy == H5F_FSPACE_STRATEGY_AGGR) { + PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_AGGR"); + } else if(fs_strategy == H5F_FSPACE_STRATEGY_NONE) { + PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_NONE"); } else PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy"); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_THRESHOLD", fs_threshold); + PRINTSTREAM(rawoutstream, "%s %s\n","FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE"); + indentation(dump_indent + COL); + PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_SECTION_THRESHOLD", fs_threshold); + indentation(dump_indent + COL); + PRINTSTREAM(rawoutstream, "%s %Hu\n","FILE_SPACE_PAGE_SIZE", fsp_size); /*------------------------------------------------------------------------- * USER_BLOCK diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index c79db1c..c09dee6 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -78,8 +78,7 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { *------------------------------------------------------------------------- */ int -h5repack_init(pack_opt_t *options, int verbose, hbool_t latest, - H5F_file_space_type_t strategy, hsize_t threshold) +h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) { int k, n; @@ -96,9 +95,6 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest, options->filter_g[n].cd_values[k] = 0; } - options->fs_strategy = strategy; - options->fs_threshold = threshold; - return (options_table_init(&(options->op_tbl))); } diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h index d2ab923..5ad0b80 100644 --- a/tools/src/h5repack/h5repack.h +++ b/tools/src/h5repack/h5repack.h @@ -30,6 +30,13 @@ #define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ #define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ +/* File space default information */ +#define FS_PAGESIZE_DEF 4096 +#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR +#define FS_PERSIST_DEF FALSE +#define FS_THRESHOLD_DEF 1 + + /*------------------------------------------------------------------------- * data structures for command line options *------------------------------------------------------------------------- @@ -115,8 +122,10 @@ typedef struct { hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ hsize_t threshold; /* alignment threshold for H5Pset_alignment */ hsize_t alignment; /* alignment for H5Pset_alignment */ - H5F_file_space_type_t fs_strategy; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + int fs_persist; /* Free space section threshold */ + long fs_threshold; /* Free space section threshold */ + long long fs_pagesize; /* File space page size */ } pack_opt_t; @@ -138,8 +147,7 @@ extern "C" { int h5repack(const char* infile, const char* outfile, pack_opt_t *options); int h5repack_addfilter(const char* str, pack_opt_t *options); int h5repack_addlayout(const char* str, pack_opt_t *options); -int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest, - H5F_file_space_type_t strategy, hsize_t threshold); +int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest); int h5repack_end(pack_opt_t *options); int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options); int h5repack_cmp_pl(const char *fname1, const char *fname2); diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 1519053..45d52bf 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -96,6 +96,14 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) hsize_t ub_size = 0; /* size of user block */ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ hid_t fapl = H5P_DEFAULT; /* file access property list ID */ + H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */ + hbool_t set_persist; /* Persist free-space status to be set in output file */ + hsize_t set_threshold; /* Free-space section threshold to be set in output file */ + hsize_t set_pagesize; /* File space page size to be set in output file */ + H5F_fspace_strategy_t in_strategy; /* Strategy from input file */ + hbool_t in_persist; /* Persist free-space status from input file */ + hsize_t in_threshold; /* Free-space section threshold from input file */ + hsize_t in_pagesize; /* File space page size from input file */ /*------------------------------------------------------------------------- * open input file @@ -106,7 +114,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); } - /* get user block size and file space strategy/threshold */ + /* get user block size and file space strategy/persist/threshold */ { hid_t fcpl_in; /* file creation property list ID for input file */ @@ -120,19 +128,17 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); } - if (!options->fs_strategy) { - if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) { - error_msg("failed to retrieve file space strategy\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - } + /* If the -S option is not set, get "strategy" from the input file */ + if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) { + error_msg("failed to retrieve file space strategy\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); } - if (!options->fs_threshold) { - if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) { - error_msg("failed to retrieve file space threshold\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - } - } + /* If the -G option is not set, get "pagesize" from the input file */ + if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) { + error_msg("failed to retrieve file space threshold\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + } if (H5Pclose(fcpl_in) < 0) { error_msg("failed to close property list\n"); @@ -291,9 +297,9 @@ print_user_block(fnamein, fidin); } /*------------------------------------------------------------------------- - * set free-space strategy options - *------------------------------------------------------------------------- - */ + * Set file space information + *------------------------------------------------------------------------- + */ /* either use the FCPL already created or create a new one */ if (fcpl == H5P_DEFAULT) { @@ -304,12 +310,44 @@ print_user_block(fnamein, fidin); } } - /* set file space strategy and free space threshold */ - if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) { - error_msg("failed to set file space strategy & threshold \n"); + /* Set file space info to those from input file */ + set_strategy = in_strategy; + set_persist = in_persist; + set_threshold = in_threshold; + set_pagesize = in_pagesize; + + if(options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */ + set_strategy = FS_STRATEGY_DEF; + else if(options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */ + set_strategy = options->fs_strategy; + + if(options->fs_persist == -1) /* A default "persist" is specified by user */ + set_persist = FS_PERSIST_DEF; + else if(options->fs_persist != 0) /* Set "persist" as specified by user */ + set_persist = (hbool_t)options->fs_persist; + + if(options->fs_threshold == -1) /* A "0" threshold is specified by user */ + set_threshold = (hsize_t)0; + else if(options->fs_threshold != 0) /* Set threshold as specified by user */ + set_threshold = (hsize_t)options->fs_threshold; + + /* Set file space information as specified */ + if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) { + error_msg("failed to set file space strategy\n"); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); } + if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */ + set_pagesize = (hsize_t)0; + else if(options->fs_pagesize != 0) /* Set file space page size as specified by user */ + set_pagesize = (hsize_t)options->fs_pagesize; + + if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */ + if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) { + error_msg("failed to set file space page size\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + } + /*------------------------------------------------------------------------- * create the output file *------------------------------------------------------------------------- diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 1807056..a8b4cfe 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -33,7 +33,7 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:T:E"; +static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:P:T:G:E"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "version", no_arg, 'V' }, @@ -55,7 +55,9 @@ static struct long_options l_opts[] = { { "infile", require_arg, 'i' }, /* -i for backward compability */ { "outfile", require_arg, 'o' }, /* -o for backward compability */ { "fs_strategy", require_arg, 'S' }, + { "fs_persist", require_arg, 'P' }, { "fs_threshold", require_arg, 'T' }, + { "fs_pagesize", require_arg, 'G' }, { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; @@ -92,8 +94,10 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n"); PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n"); PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n"); - PRINTVALSTREAM(rawoutstream, " -S FS_STRGY, --fs_strategy=FS_STRGY File space management strategy\n"); - PRINTVALSTREAM(rawoutstream, " -T FS_THRD, --fs_threshold=FS_THRD Free-space section threshold\n"); + PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0) \n"); PRINTVALSTREAM(rawoutstream, " E - is a filename.\n"); @@ -109,18 +113,27 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); PRINTVALSTREAM(rawoutstream, " occur.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_STRGY is the file space management strategy to use for the output file.\n"); - PRINTVALSTREAM(rawoutstream, " It is a string as listed below:\n"); - PRINTVALSTREAM(rawoutstream, " ALL_PERSIST - Use persistent free-space managers, aggregators and virtual file driver\n"); - PRINTVALSTREAM(rawoutstream, " for file space allocation\n"); - PRINTVALSTREAM(rawoutstream, " ALL - Use non-persistent free-space managers, aggregators and virtual file driver\n"); - PRINTVALSTREAM(rawoutstream, " for file space allocation\n"); - PRINTVALSTREAM(rawoutstream, " AGGR_VFD - Use aggregators and virtual file driver for file space allocation\n"); - PRINTVALSTREAM(rawoutstream, " VFD - Use virtual file driver for file space allocation\n"); + PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); + PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " PAGE:\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " AGGR:\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " NONE:\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-space.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_THRD is the free-space section threshold to use for the output file.\n"); - PRINTVALSTREAM(rawoutstream, " It is the minimum size (in bytes) of free-space sections to be tracked\n"); - PRINTVALSTREAM(rawoutstream, " by the the library's free-space managers.\n"); + PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n"); + PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n"); + PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library.\n"); + PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n"); + PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used.\n"); + PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -521,25 +534,45 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) char strategy[MAX_NC_NAME]; HDstrcpy(strategy, opt_arg); - if(!HDstrcmp(strategy, "ALL_PERSIST")) - options->fs_strategy = H5F_FILE_SPACE_ALL_PERSIST; - else if(!HDstrcmp(strategy, "ALL")) - options->fs_strategy = H5F_FILE_SPACE_ALL; - else if(!HDstrcmp(strategy, "AGGR_VFD")) - options->fs_strategy = H5F_FILE_SPACE_AGGR_VFD; - else if(!HDstrcmp(strategy, "VFD")) - options->fs_strategy = H5F_FILE_SPACE_VFD; + if(!HDstrcmp(strategy, "FSM_AGGR")) + options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + else if(!HDstrcmp(strategy, "PAGE")) + options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE; + else if(!HDstrcmp(strategy, "AGGR")) + options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + else if(!HDstrcmp(strategy, "NONE")) + options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; else { error_msg("invalid file space management strategy\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; } + if(options->fs_strategy == (H5F_fspace_strategy_t)0) + /* To distinguish the "specified" zero value */ + options->fs_strategy = (H5F_fspace_strategy_t)-1; } break; + case 'P': + options->fs_persist = HDatoi( opt_arg ); + if(options->fs_persist == 0) + /* To distinguish the "specified" zero value */ + options->fs_persist = -1; + break; + case 'T': - options->fs_threshold = (hsize_t) HDatol( opt_arg ); + options->fs_threshold = HDatol( opt_arg ); + if(options->fs_threshold == 0) + /* To distinguish the "specified" zero value */ + options->fs_threshold = -1; + break; + + case 'G': + options->fs_pagesize = HDatoll( opt_arg ); + if(options->fs_pagesize == 0) + /* To distinguish the "specified" zero value */ + options->fs_pagesize = -1; break; case 'E': @@ -611,7 +644,7 @@ int main(int argc, const char **argv) } /* initialize options */ - h5repack_init(&options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t) 0); + h5repack_init(&options, 0, FALSE); if (parse_command_line(argc, argv, &options) < 0) goto done; diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index 58dea03..1022d7a 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -58,8 +58,10 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options int ok = 1; hid_t fcpl_in = -1; /* file creation property for input file */ hid_t fcpl_out = -1; /* file creation property for output file */ - H5F_file_space_type_t in_strat, out_strat; /* file space handling strategy for in/output file */ - hsize_t in_thresh, out_thresh; /* free space section threshold for in/output file */ + H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */ + hbool_t in_persist, out_persist; /* free-space persist status for in/output file */ + hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */ + hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */ /* open the output file */ if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) @@ -196,8 +198,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options } /*------------------------------------------------------------------------- - * Verify that file space strategy and free space threshold - * are set as expected + * Verify that file space info are set as expected *------------------------------------------------------------------------- */ @@ -211,12 +212,18 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } - /* Get file space management info for input file */ - if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) { + /* Get file space info for input file */ + if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) { error_msg("failed to retrieve file space strategy & threshold\n"); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed"); } + /* Get file space page size for input file */ + if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) { + error_msg("failed to retrieve file space page size\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); + } + /* Output file is already opened */ /* Get file creation property list for output file */ if((fcpl_out = H5Fget_create_plist(fidout)) < 0) { @@ -224,45 +231,84 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } - /* Get file space management info for output file */ - if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) { + /* Get file space info for output file */ + if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) { error_msg("failed to retrieve file space strategy & threshold\n"); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed"); } + /* Get file space page size for output file */ + if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) { + error_msg("failed to retrieve file space page size\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); + } + /* - * If the strategy option is not set, - * file space handling strategy should be the same for both - * input & output files. - * If the strategy option is set, - * the output file's file space handling strategy should be the same - * as what is set via the strategy option + * If -S option is set, the file space handling strategy should be set as specified. + * If -S option is not set, the file space handling strategy should be + * the same as the input file's strategy. */ - if(!options->fs_strategy && out_strat != in_strat) { - error_msg("file space strategy not set as unexpected\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); - + if(options->fs_strategy) { + if(out_strategy != (options->fs_strategy == (-1) ? 0 : options->fs_strategy)) { + error_msg("file space strategy not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } + } else { + if(out_strategy != in_strategy) { + error_msg("file space strategy not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } } - else if(options->fs_strategy && out_strat!= options->fs_strategy) { - error_msg("file space strategy not set as unexpected\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + + /* + * If the -P option is set, the free-space persist status should be set as specified. + * If the -P option is not set, the free-space persist status should be + * the same as the input file's free-space persist status + */ + if(options->fs_persist) { + if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) { + error_msg("free-space persist status is not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } + } else { + if(out_persist != in_persist) { + error_msg("free-space persist status is not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } } /* - * If the threshold option is not set, - * the free space section threshold should be the same for both - * input & output files. - * If the threshold option is set, - * the output file's free space section threshold should be the same - * as what is set via the threshold option. + * If the -T option is set, the threshold size should be set as specified. + * If the -T option is not set, the threshold should be the same as the + * input file's threshold size. */ - if(!options->fs_threshold && out_thresh != in_thresh) { - error_msg("free space threshold not set as unexpected\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected"); + if(options->fs_threshold) { + if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) { + error_msg("threshold is not set as unexpectec\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } + } else { + if(out_threshold != in_threshold) { + error_msg("threshold is not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } } - else if(options->fs_threshold && out_thresh != options->fs_threshold) { - error_msg("free space threshold not set as unexpected\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected"); + + /* + * If the -G option is set, the file space page size should be set as specified. + * If the -G option is not set, the file space page size should be + * the same as the input file's file space page size. + */ + if(options->fs_pagesize) { + if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) { + error_msg("file space page size is not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } + } else { /* "-G" is not set */ + if(out_pagesize != in_pagesize) { + error_msg("file space page size is not set as unexpected\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + } } /* Closing */ diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index a331014..f99bab0 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -40,11 +40,11 @@ /* File space management strategies: see H5Fpublic.h for declarations */ const char *FS_STRATEGY_NAME[] = { + "H5F_FSPACE_STRATEGY_FSM_AGGR", + "H5F_FSPACE_STRATEGY_PAGE", + "H5F_FSPACE_STRATEGY_AGGR", + "H5F_FSPACE_STRATEGY_NONE", "unknown", - "H5F_FILE_SPACE_ALL_PERSIST", - "H5F_FILE_SPACE_ALL", - "H5F_FILE_SPACE_AGGR_VFD", - "H5F_FILE_SPACE_VFD", NULL }; @@ -106,10 +106,12 @@ typedef struct iter_t { hsize_t super_size; /* superblock size */ hsize_t super_ext_size; /* superblock extension size */ hsize_t ublk_size; /* user block size (if exists) */ - H5F_file_space_type_t fs_strategy; /* File space management strategy */ + H5F_fspace_strategy_t fs_strategy; /* File space management strategy */ + hbool_t fs_persist; /* Free-space persist or not */ hsize_t fs_threshold; /* Free-space section threshold */ - hsize_t free_space; /* amount of freespace in the file */ - hsize_t free_hdr; /* size of free space manager metadata in the file */ + hsize_t fsp_size; /* File space page size */ + hsize_t free_space; /* Amount of freespace in the file */ + hsize_t free_hdr; /* Size of free space manager metadata in the file */ unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */ unsigned sect_nbins; /* Number of bins for free-space section sizes */ unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */ @@ -1501,6 +1503,7 @@ print_freespace_info(const iter_t *iter) unsigned long total; /* Total count for various statistics */ unsigned u; /* Local index variable */ + HDfprintf(stdout, "Free-space persist: %s\n", iter->fs_persist ? "TRUE" : "FALSE"); HDfprintf(stdout, "Free-space section threshold: %Hu bytes\n", iter->fs_threshold); printf("Small size free-space sections (< %u bytes):\n", (unsigned)SIZE_SMALL_SECTS); total = 0; @@ -1551,6 +1554,7 @@ print_storage_summary(const iter_t *iter) double percent = 0.0f; HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]); + HDfprintf(stdout, "File space page size: %Hu bytes\n", iter->fsp_size); printf("Summary of file space information:\n"); total_meta = iter->super_size + iter->super_ext_size + iter->ublk_size + @@ -1772,9 +1776,12 @@ main(int argc, const char *argv[]) if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) warn_msg("Unable to retrieve userblock size\n"); - if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0) + if(H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0) warn_msg("Unable to retrieve file space information\n"); - HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES); + HDassert(iter.fs_strategy >= 0 && iter.fs_strategy < H5F_FSPACE_STRATEGY_NTYPES); + + if(H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0) + warn_msg("Unable to retrieve file space page size\n"); /* get information for free-space sections */ if(freespace_stats(fid, &iter) < 0) diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c index 481c6db..b6c6ea3 100644 --- a/tools/src/misc/h5clear.c +++ b/tools/src/misc/h5clear.c @@ -14,11 +14,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: - * - * Purpose: + * Purpose: A tool to clear the status_flags field from the file's superblock via -s option. + * A tool to remove cache image from the file via -m option. + * */ - #include "hdf5.h" #include "H5private.h" #include "h5tools.h" @@ -30,59 +29,171 @@ /* Make this private property (defined in H5Fprivate.h) available to h5clear. */ #define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" +static char *fname_g = NULL; +static hbool_t clear_status_flags = FALSE; +static hbool_t remove_cache_image = FALSE; + +/* + * Command-line options: The user can specify short or long-named + * parameters. + */ +static const char *s_opts = "hVsm"; +static struct long_options l_opts[] = { + { "help", no_arg, 'h' }, + { "hel", no_arg, 'h'}, + { "he", no_arg, 'h'}, + { "version", no_arg, 'V' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, + { "status", no_arg, 's' }, + { "statu", no_arg, 's' }, + { "stat", no_arg, 's' }, + { "sta", no_arg, 's' }, + { "st", no_arg, 's' }, + { "image", no_arg, 'm' }, + { "imag", no_arg, 'm' }, + { "ima", no_arg, 'm' }, + { "im", no_arg, 'm' }, + { NULL, 0, '\0' } +}; + + + /*------------------------------------------------------------------------- - * Function: leave + * Function: usage * - * Purpose: Close the tools library and exit + * Purpose: Prints a usage message * - * Return: Does not return + * Return: void * *------------------------------------------------------------------------- */ -static void -leave(int ret) +static void usage(const char *prog) { - h5tools_close(); - HDexit(ret); -} /* leave() */ + HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " -h, --help Print a usage message and exit\n"); + HDfprintf(stdout, " -V, --version Print version number and exit\n"); + HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n"); + HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "Examples of use:\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "h5clear -s file_name\n"); + HDfprintf(stdout, " Clear the status_flags field in the superblock of the HDF5 file .\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "h5clear -m file_name\n"); + HDfprintf(stdout, " Remove the metadata cache image from the HDF5 file .\n"); +} /* usage() */ + /*------------------------------------------------------------------------- - * Function: usage + * Function: parse_command_line * - * Purpose: Prints a usage message + * Purpose: Parses command line and sets up global variable to control output + * + * Return: Success: 0 * - * Return: void + * Failure: -1 * *------------------------------------------------------------------------- */ -static void -usage(void) +static int +parse_command_line(int argc, const char **argv) { - HDfprintf(stdout, "usage: h5clear filename\n"); + int opt; -} /* usage() */ + /* no arguments */ + if (argc == 1) { + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + + /* parse command line options */ + while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch((char)opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto done; + + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto done; + + case 's': + clear_status_flags = TRUE; + break; + + case 'm': + remove_cache_image = TRUE; + break; + + default: + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } /* end switch */ + } /* end while */ + + /* check for file name to be processed */ + if(argc <= opt_ind) { + error_msg("missing file name\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } /* end if */ + + fname_g = HDstrdup(argv[opt_ind]); + +done: + return(0); + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close the tools library and exit + * + * Return: Does not return + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); +} /* leave() */ /*------------------------------------------------------------------------- * Function: main * - * Purpose: - * - * Return: Success: - * Failure: + * Purpose: To clear the status_flags field in the file's superblock (-s option). + * To remove the cache image from the file (-m option). * - * Programmer: + * Return: Success: 0 + * Failure: 1 * *------------------------------------------------------------------------- */ int -main (int argc, char *argv[]) +main (int argc, const char *argv[]) { - char *fname; /* File name */ - hbool_t clear = TRUE; /* To clear the status_flags in the file's superblock */ - hid_t fapl = -1; /* File access property list */ + char *fname = NULL; /* File name */ + hid_t fapl = -1; /* File access property list */ hid_t fid = -1; /* File ID */ + haddr_t image_addr; + hsize_t image_len; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -93,46 +204,80 @@ main (int argc, char *argv[]) /* initialize h5tools lib */ h5tools_init(); - /* Check for the # of arguments */ - if(argc != 2) { - usage(); - leave(EXIT_FAILURE); + /* Parse command line options */ + if(parse_command_line(argc, argv) < 0) + goto done; + + if(fname_g == NULL) + goto done; + + if(!clear_status_flags && !remove_cache_image) { + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto done; } + /* Duplicate the file name */ + fname = HDstrdup(fname_g); + /* Get a copy of the file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("H5Pcreate\n"); - leave(EXIT_FAILURE); - } + h5tools_setstatus(EXIT_FAILURE); + goto done; + } - /* Set to clear the status_flags in the file's superblock */ - /* This is a private property used by h5clear only */ - if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) { - error_msg("H5Pset\n"); - leave(EXIT_FAILURE); + /* -s option */ + if(clear_status_flags) { + /* Set to clear the status_flags in the file's superblock */ + /* This is a private property used by h5clear only */ + if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) { + error_msg("H5Pset\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } } - /* Duplicate the file name */ - fname = HDstrdup(argv[opt_ind]); - if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) { error_msg("h5tools_fopen\n"); - HDfree(fname); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } - HDfree(fname); - /* Close the file */ - if(H5Fclose(fid) < 0) { - error_msg("H5Fclose\n"); - leave(EXIT_FAILURE); - } + /* -m option */ + if(remove_cache_image) { + H5AC_cache_image_config_t config; - /* CLose the property list */ - if(H5Pclose(fapl) < 0) { - error_msg("H5Pclose\n"); - leave(EXIT_FAILURE); - } + /* Retrieve cache image config */ + if((fapl = H5Fget_access_plist(fid)) < 0) { + error_msg("H5Fget_access_plist\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; + if(H5Pget_mdc_image_config(fapl, &config) < 0) { + error_msg("H5Pget_mdc_image_config\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + + /* Check for image */ + if(!config.generate_image) + warn_msg("No cache image in the file\n"); + } + + h5tools_setstatus(EXIT_SUCCESS); + +done: + if(fname) + HDfree(fname); + if(fname_g) + HDfree(fname_g); + + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY leave(h5tools_getstatus()); } /* main() */ diff --git a/tools/test/h5copy/testfiles/h5copy_extlinks_src.out.ls b/tools/test/h5copy/testfiles/h5copy_extlinks_src.out.ls index 0134714..af499a5 100644 --- a/tools/test/h5copy/testfiles/h5copy_extlinks_src.out.ls +++ b/tools/test/h5copy/testfiles/h5copy_extlinks_src.out.ls @@ -8,7 +8,7 @@ Opened "./testfiles/h5copy_extlinks_src.out.h5" with sec2 driver. Storage:
Type: 32-bit little-endian integer /copy1_group Group - Location: 1:4696 + Location: 1:4600 Links: 1 /copy1_group/extlink_datatype External Link {h5copy_extlinks_trg.h5//datatype} /copy1_group/extlink_dset External Link {h5copy_extlinks_trg.h5//simple} @@ -16,24 +16,24 @@ Opened "./testfiles/h5copy_extlinks_src.out.h5" with sec2 driver. /copy1_group/extlink_notyet1 External Link {h5copy_extlinks_trg.h5//notyet} /copy1_group/extlink_notyet2 External Link {notyet_file.h5//notyet} /copy2_dset Dataset {6/6} - Location: 1:4216 + Location: 1:4120 Links: 1 Storage:
Type: 32-bit little-endian integer /copy2_group Group - Location: 1:5128 + Location: 1:5032 Links: 1 /copy2_group/extlink_datatype Type - Location: 1:6328 + Location: 1:6232 Links: 1 - Type: shared-1:6328 32-bit little-endian integer + Type: shared-1:6232 32-bit little-endian integer /copy2_group/extlink_dset Dataset {6/6} - Location: 1:5496 + Location: 1:5400 Links: 1 Storage:
Type: 32-bit little-endian integer /copy2_group/extlink_grp Group - Location: 1:6288 + Location: 1:6192 Links: 1 /copy2_group/extlink_notyet1 External Link {h5copy_extlinks_trg.h5//notyet} /copy2_group/extlink_notyet2 External Link {notyet_file.h5//notyet} diff --git a/tools/test/h5copy/testfiles/h5copy_ref.out.ls b/tools/test/h5copy/testfiles/h5copy_ref.out.ls index d685af2..f5b31a7 100644 --- a/tools/test/h5copy/testfiles/h5copy_ref.out.ls +++ b/tools/test/h5copy/testfiles/h5copy_ref.out.ls @@ -11,21 +11,21 @@ Opened "./testfiles/h5copy_ref.out.h5" with sec2 driver. Storage:
Type: 32-bit little-endian integer /COPY/Dset2 Dataset {3/3, 16/16} - Location: 1:1960 + Location: 1:4096 Links: 3 Storage:
Type: 8-bit integer /COPY/Dset_OBJREF Dataset {2/2} - Location: 1:5184 + Location: 1:5224 Links: 1 Storage:
Type: object reference /COPY/Dset_REGREF Dataset {2/2} - Location: 1:5304 + Location: 1:5344 Links: 1 Storage:
Type: dataset region reference /COPY/Group Group - Location: 1:2096 + Location: 1:1960 Links: 3 -/~obj_pointed_by_2096 Group, same as /COPY/Group +/~obj_pointed_by_1960 Group, same as /COPY/Group diff --git a/tools/test/h5copy/testfiles/h5copytst.h5 b/tools/test/h5copy/testfiles/h5copytst.h5 index 1d1cbf1..474c3da 100644 Binary files a/tools/test/h5copy/testfiles/h5copytst.h5 and b/tools/test/h5copy/testfiles/h5copytst.h5 differ diff --git a/tools/test/h5copy/testfiles/h5copytst.out.ls b/tools/test/h5copy/testfiles/h5copytst.out.ls index 4044aaf..629915e 100644 --- a/tools/test/h5copy/testfiles/h5copytst.out.ls +++ b/tools/test/h5copy/testfiles/h5copytst.out.ls @@ -3,57 +3,57 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. Location: 1:96 Links: 1 /A Group - Location: 1:84304 + Location: 1:84208 Links: 1 /A/B1 Group - Location: 1:85008 + Location: 1:84912 Links: 1 /A/B1/simple Dataset {6/6} - Location: 1:84176 + Location: 1:84080 Links: 1 Storage:
Type: 32-bit little-endian integer /A/B2 Group - Location: 1:88544 + Location: 1:88448 Links: 1 /A/B2/simple2 Dataset {6/6} - Location: 1:88416 + Location: 1:88320 Links: 1 Storage:
Type: 32-bit little-endian integer /C Group - Location: 1:91752 + Location: 1:91656 Links: 1 /C/D Group - Location: 1:92456 + Location: 1:92360 Links: 1 /C/D/simple Dataset {6/6} - Location: 1:91624 + Location: 1:91528 Links: 1 Storage:
Type: 32-bit little-endian integer /E Group - Location: 1:106368 + Location: 1:106272 Links: 1 /E/F Group - Location: 1:107072 + Location: 1:106976 Links: 1 /E/F/grp_dsets Group - Location: 1:94568 + Location: 1:94472 Links: 1 /E/F/grp_dsets/chunk Dataset {6/6} - Location: 1:98752 + Location: 1:98656 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /E/F/grp_dsets/compact Dataset {6/6} - Location: 1:99208 + Location: 1:99112 Links: 1 Storage:
Type: 32-bit little-endian integer /E/F/grp_dsets/compound Dataset {2/2} - Location: 1:99344 + Location: 1:99248 Links: 1 Storage:
Type: struct { @@ -61,60 +61,60 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /E/F/grp_dsets/compressed Dataset {6/6} - Location: 1:101656 + Location: 1:101560 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /E/F/grp_dsets/named_vl Dataset {2/2} - Location: 1:105920 + Location: 1:105824 Links: 1 Storage:
- Type: shared-1:106048 variable length of + Type: shared-1:105952 variable length of 32-bit little-endian integer /E/F/grp_dsets/nested_vl Dataset {2/2} - Location: 1:106096 + Location: 1:106000 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /E/F/grp_dsets/simple Dataset {6/6} - Location: 1:106240 + Location: 1:106144 Links: 1 Storage:
Type: 32-bit little-endian integer /E/F/grp_dsets/vl Type - Location: 1:106048 + Location: 1:105952 Links: 2 - Type: shared-1:106048 variable length of + Type: shared-1:105952 variable length of 32-bit little-endian integer /G Group - Location: 1:122016 + Location: 1:121920 Links: 1 /G/H Group - Location: 1:122720 + Location: 1:122624 Links: 1 /G/H/grp_nested Group - Location: 1:109096 + Location: 1:109000 Links: 1 /G/H/grp_nested/grp_dsets Group - Location: 1:109888 + Location: 1:109792 Links: 1 /G/H/grp_nested/grp_dsets/chunk Dataset {6/6} - Location: 1:114072 + Location: 1:113976 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compact Dataset {6/6} - Location: 1:114528 + Location: 1:114432 Links: 1 Storage:
Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compound Dataset {2/2} - Location: 1:114664 + Location: 1:114568 Links: 1 Storage:
Type: struct { @@ -122,48 +122,48 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /G/H/grp_nested/grp_dsets/compressed Dataset {6/6} - Location: 1:116976 + Location: 1:116880 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/named_vl Dataset {2/2} - Location: 1:121240 + Location: 1:121144 Links: 1 Storage:
- Type: shared-1:121368 variable length of + Type: shared-1:121272 variable length of 32-bit little-endian integer /G/H/grp_nested/grp_dsets/nested_vl Dataset {2/2} - Location: 1:121416 + Location: 1:121320 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /G/H/grp_nested/grp_dsets/simple Dataset {6/6} - Location: 1:121560 + Location: 1:121464 Links: 1 Storage:
Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/vl Type - Location: 1:121368 + Location: 1:121272 Links: 2 - Type: shared-1:121368 variable length of + Type: shared-1:121272 variable length of 32-bit little-endian integer /chunk Dataset {6/6} - Location: 1:6312 + Location: 1:6216 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /compact Dataset {6/6} - Location: 1:6440 + Location: 1:6344 Links: 1 Storage:
Type: 32-bit little-endian integer /compound Dataset {2/2} - Location: 1:8624 + Location: 1:8528 Links: 1 Storage:
Type: struct { @@ -171,28 +171,28 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /compressed Dataset {6/6} - Location: 1:12984 + Location: 1:12888 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_dsets Group - Location: 1:28128 + Location: 1:28032 Links: 1 /grp_dsets/chunk Dataset {6/6} - Location: 1:32312 + Location: 1:32216 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /grp_dsets/compact Dataset {6/6} - Location: 1:32768 + Location: 1:32672 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_dsets/compound Dataset {2/2} - Location: 1:32904 + Location: 1:32808 Links: 1 Storage:
Type: struct { @@ -200,62 +200,62 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_dsets/compressed Dataset {6/6} - Location: 1:35216 + Location: 1:35120 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_dsets/named_vl Dataset {2/2} - Location: 1:39480 + Location: 1:39384 Links: 1 Storage:
- Type: shared-1:39608 variable length of + Type: shared-1:39512 variable length of 32-bit little-endian integer /grp_dsets/nested_vl Dataset {2/2} - Location: 1:39656 + Location: 1:39560 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /grp_dsets/simple Dataset {6/6} - Location: 1:39800 + Location: 1:39704 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_dsets/simple_group Dataset {6/6} - Location: 1:55912 + Location: 1:55816 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_dsets/vl Type - Location: 1:39608 + Location: 1:39512 Links: 2 - Type: shared-1:39608 variable length of + Type: shared-1:39512 variable length of 32-bit little-endian integer /grp_empty Group - Location: 1:27336 + Location: 1:27240 Links: 1 /grp_nested Group - Location: 1:40592 + Location: 1:40496 Links: 1 /grp_nested/grp_dsets Group - Location: 1:41384 + Location: 1:41288 Links: 1 /grp_nested/grp_dsets/chunk Dataset {6/6} - Location: 1:45568 + Location: 1:45472 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /grp_nested/grp_dsets/compact Dataset {6/6} - Location: 1:46024 + Location: 1:45928 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_nested/grp_dsets/compound Dataset {2/2} - Location: 1:46160 + Location: 1:46064 Links: 1 Storage:
Type: struct { @@ -263,51 +263,51 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_nested/grp_dsets/compressed Dataset {6/6} - Location: 1:48472 + Location: 1:48376 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_nested/grp_dsets/named_vl Dataset {2/2} - Location: 1:52736 + Location: 1:52640 Links: 1 Storage:
- Type: shared-1:52864 variable length of + Type: shared-1:52768 variable length of 32-bit little-endian integer /grp_nested/grp_dsets/nested_vl Dataset {2/2} - Location: 1:52912 + Location: 1:52816 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /grp_nested/grp_dsets/simple Dataset {6/6} - Location: 1:53056 + Location: 1:52960 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_nested/grp_dsets/vl Type - Location: 1:52864 + Location: 1:52768 Links: 2 - Type: shared-1:52864 variable length of + Type: shared-1:52768 variable length of 32-bit little-endian integer /grp_rename Group - Location: 1:57120 + Location: 1:57024 Links: 1 /grp_rename/chunk Dataset {6/6} - Location: 1:61304 + Location: 1:61208 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /grp_rename/compact Dataset {6/6} - Location: 1:61760 + Location: 1:61664 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_rename/compound Dataset {2/2} - Location: 1:61896 + Location: 1:61800 Links: 1 Storage:
Type: struct { @@ -315,28 +315,28 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_rename/compressed Dataset {6/6} - Location: 1:64208 + Location: 1:64112 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_rename/grp_dsets Group - Location: 1:70000 + Location: 1:69904 Links: 1 /grp_rename/grp_dsets/chunk Dataset {6/6} - Location: 1:74184 + Location: 1:74088 Links: 1 Chunks: {2} 8 bytes Storage:
Type: 32-bit little-endian integer /grp_rename/grp_dsets/compact Dataset {6/6} - Location: 1:74640 + Location: 1:74544 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_rename/grp_dsets/compound Dataset {2/2} - Location: 1:74776 + Location: 1:74680 Links: 1 Storage:
Type: struct { @@ -344,73 +344,73 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_rename/grp_dsets/compressed Dataset {6/6} - Location: 1:77088 + Location: 1:76992 Links: 1 Chunks: {2} 8 bytes Storage:
Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_rename/grp_dsets/named_vl Dataset {2/2} - Location: 1:81352 + Location: 1:81256 Links: 1 Storage:
- Type: shared-1:81480 variable length of + Type: shared-1:81384 variable length of 32-bit little-endian integer /grp_rename/grp_dsets/nested_vl Dataset {2/2} - Location: 1:81528 + Location: 1:81432 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /grp_rename/grp_dsets/simple Dataset {6/6} - Location: 1:81672 + Location: 1:81576 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_rename/grp_dsets/vl Type - Location: 1:81480 + Location: 1:81384 Links: 2 - Type: shared-1:81480 variable length of + Type: shared-1:81384 variable length of 32-bit little-endian integer /grp_rename/named_vl Dataset {2/2} - Location: 1:68472 + Location: 1:68376 Links: 1 Storage:
- Type: shared-1:68600 variable length of + Type: shared-1:68504 variable length of 32-bit little-endian integer /grp_rename/nested_vl Dataset {2/2} - Location: 1:68648 + Location: 1:68552 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /grp_rename/simple Dataset {6/6} - Location: 1:68792 + Location: 1:68696 Links: 1 Storage:
Type: 32-bit little-endian integer /grp_rename/vl Type - Location: 1:68600 + Location: 1:68504 Links: 2 - Type: shared-1:68600 variable length of + Type: shared-1:68504 variable length of 32-bit little-endian integer /named_vl Dataset {2/2} - Location: 1:17280 + Location: 1:17184 Links: 1 Storage:
- Type: shared-1:17408 variable length of + Type: shared-1:17312 variable length of 32-bit little-endian integer /nested_vl Dataset {2/2} - Location: 1:21760 + Location: 1:21664 Links: 1 Storage:
Type: variable length of variable length of 32-bit little-endian integer /rename Dataset {2/2} - Location: 1:26128 + Location: 1:26032 Links: 1 Storage:
Type: struct { @@ -423,7 +423,7 @@ Opened "./testfiles/h5copytst.out.h5" with sec2 driver. Storage:
Type: 32-bit little-endian integer /simple_top Dataset {6/6} - Location: 1:23952 + Location: 1:23856 Links: 1 Storage:
Type: 32-bit little-endian integer diff --git a/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 b/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 deleted file mode 100644 index 3252303..0000000 Binary files a/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 and /dev/null differ diff --git a/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 b/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 deleted file mode 100644 index db7584d..0000000 Binary files a/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 and /dev/null differ diff --git a/tools/test/h5diff/testfiles/h5diff_idx.txt b/tools/test/h5diff/testfiles/h5diff_idx.txt deleted file mode 100644 index 754d3ea..0000000 --- a/tools/test/h5diff/testfiles/h5diff_idx.txt +++ /dev/null @@ -1,14 +0,0 @@ - -file1 file2 ---------------------------------------- - x x / - x x /dset - x x /dset_filter - -group : and -0 differences found -dataset: and -0 differences found -dataset: and -0 differences found -EXIT CODE: 0 diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index bf9a698..afcf405 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -289,8 +289,9 @@ typedef struct s1_t { #define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) /* File 65 macros */ -#define STRATEGY H5F_FILE_SPACE_AGGR_VFD /* File space handling strategy */ -#define THRESHOLD10 10 /* Free space section threshold */ +#define STRATEGY H5F_FSPACE_STRATEGY_NONE /* File space handling strategy */ +#define THRESHOLD10 10 /* Free-space section threshold */ +#define FSPACE_PAGE_SIZE 8192 /* File space page size */ /* "FILE66" macros and for FILE69 */ #define F66_XDIM 8 @@ -7042,8 +7043,9 @@ gent_extlinks(void) /*------------------------------------------------------------------------- * Function: gent_fs_strategy_threshold * - * Purpose: Generate a file with non-default file space strategy and - * non-default free-space section threshold. + * Purpose: Generate a file with non-default file space strategy, + * non-default free-space section threshold, + * non-default file space page size. *------------------------------------------------------------------------- */ static void @@ -7056,7 +7058,8 @@ gent_fs_strategy_threshold(void) fcpl = H5Pcreate(H5P_FILE_CREATE); /* Set file space information */ - H5Pset_file_space(fcpl, STRATEGY, (hsize_t)THRESHOLD10); + H5Pset_file_space_strategy(fcpl, STRATEGY, TRUE, (hsize_t)THRESHOLD10); + H5Pset_file_space_page_size(fcpl, (hsize_t)FSPACE_PAGE_SIZE); /* Create the file with the specified strategy and threshold */ fid = H5Fcreate(FILE65, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); diff --git a/tools/test/h5format_convert/h5fc_gentest.c b/tools/test/h5format_convert/h5fc_gentest.c index 9ef8e6e..aea84f8 100644 --- a/tools/test/h5format_convert/h5fc_gentest.c +++ b/tools/test/h5format_convert/h5fc_gentest.c @@ -568,7 +568,7 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) H5Pset_shared_mesg_nindexes(fcpl, 4); break; case 2: - H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); break; case 3: H5Pset_istore_k(fcpl, ISTORE_IK); @@ -576,16 +576,16 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) break; case 4: H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_file_space(fcpl, H5F_FILE_SPACE_DEFAULT, (hsize_t)2); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); break; case 5: H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space(fcpl, H5F_FILE_SPACE_VFD, (hsize_t)0); + H5Pset_file_space_page_size(fcpl, (hsize_t)512); break; case 6: H5Pset_istore_k(fcpl, ISTORE_IK); H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space(fcpl, H5F_FILE_SPACE_AGGR_VFD, (hsize_t)0); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); break; default: break; diff --git a/tools/test/h5format_convert/testfiles/h5fc_edge_v3.h5 b/tools/test/h5format_convert/testfiles/h5fc_edge_v3.h5 index ac7dbd3..6f92057 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_edge_v3.h5 and b/tools/test/h5format_convert/testfiles/h5fc_edge_v3.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_err_level.h5 b/tools/test/h5format_convert/testfiles/h5fc_err_level.h5 index a10e8a4..d1aecc2 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_err_level.h5 and b/tools/test/h5format_convert/testfiles/h5fc_err_level.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_f.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext1_f.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext1_f.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext1_f.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_f.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext1_f.h5 index 68ba2ac..5f2a01a 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext1_f.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext1_f.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_i.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext1_i.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext1_i.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext1_i.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_i.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext1_i.h5 index 1a58089..df86faf 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext1_i.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext1_i.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_s.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext1_s.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext1_s.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext1_s.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext1_s.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext1_s.h5 index 26e9b25..e41f51a 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext1_s.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext1_s.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_if.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext2_if.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext2_if.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext2_if.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_if.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext2_if.h5 index e5c5e25..af2cb15 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext2_if.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext2_if.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_is.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext2_is.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext2_is.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext2_is.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_is.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext2_is.h5 index 0e3eca7..5e99ddf 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext2_is.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext2_is.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.h5 index cb15f03..8996bf0 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext2_sf.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.ddl b/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.h5 index d46cef4..df1db97 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext3_isf.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_ext_none.h5 b/tools/test/h5format_convert/testfiles/h5fc_ext_none.h5 index defbcb3..c498ead 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_ext_none.h5 and b/tools/test/h5format_convert/testfiles/h5fc_ext_none.h5 differ diff --git a/tools/test/h5format_convert/testfiles/h5fc_non_v3.h5 b/tools/test/h5format_convert/testfiles/h5fc_non_v3.h5 index 58a340d..2f0f063 100644 Binary files a/tools/test/h5format_convert/testfiles/h5fc_non_v3.h5 and b/tools/test/h5format_convert/testfiles/h5fc_non_v3.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.h5 index 3cbc7f4..b71b31e 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_f.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.ddl index d1768c8..d9cc0b7 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.h5 index a2c9187..6a8e5eb 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_i.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.h5 index fdf4f33..ebc6919 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext1_s.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.h5 index 6bf0a2f..a4178b3 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_if.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.h5 index c0c7ecc..b5cd60a 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_is.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.ddl index dae9284..db00a99 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.h5 index 055cabf..8e63726 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext2_sf.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.ddl b/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.ddl index 8ec4656..4be6d90 100644 --- a/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.ddl +++ b/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 64 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.h5 index f4caaf4..d581e3c 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext3_isf.h5 differ diff --git a/tools/test/h5format_convert/testfiles/old_h5fc_ext_none.h5 b/tools/test/h5format_convert/testfiles/old_h5fc_ext_none.h5 index d0bf344..0e02ca1 100644 Binary files a/tools/test/h5format_convert/testfiles/old_h5fc_ext_none.h5 and b/tools/test/h5format_convert/testfiles/old_h5fc_ext_none.h5 differ diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index abdda08..69e576d 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -79,6 +79,20 @@ #define FNAME18 "h5repack_layout2.h5" +/* Files for testing file space paging */ +#define FSPACE_OUT "h5repack_fspace_OUT.h5" /* The output file */ +#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ +const char *H5REPACK_FSPACE_FNAMES[] = { + "h5repack_latest.h5", /* 0 */ + "h5repack_default.h5", /* 1 */ + "h5repack_page_persist.h5", /* 2 */ + "h5repack_fsm_aggr_persist.h5", /* 3 */ + "h5repack_page_threshold.h5", /* 4 */ + "h5repack_fsm_aggr_threshold.h5", /* 5 */ + "h5repack_aggr.h5", /* 6 */ + "h5repack_none.h5" /* 7 */ +}; + #define FNAME_UB "ublock.bin" /* obj and region references */ @@ -169,8 +183,10 @@ int main (void) { pack_opt_t pack_options; diff_opt_t diff_options; - hsize_t fs_size = 0; /* free space section threshold */ - H5F_file_space_type_t fs_type = H5F_FILE_SPACE_DEFAULT; /* file space handling strategy */ + + unsigned j; /* Local index variable for testing file space */ + const char *fname; /* File name for testing file space */ + h5_stat_t file_stat; h5_stat_size_t fsize1, fsize2; /* file sizes */ #if defined (H5_HAVE_FILTER_SZIP) @@ -203,8 +219,161 @@ int main (void) * 2) use the h5diff function to compare the input and output file *------------------------------------------------------------------------- */ + /*------------------------------------------------------------------------- + * Testing file space info setting + *------------------------------------------------------------------------- + */ + TESTING(" files with file space info setting--no options (-S, -P, -T, -G) are set"); + j = 0; /* #0 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + TESTING(" files with file space info setting--all options -S, -P, -T, -G are set"); + ++j; /* #1 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 8192; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + + TESTING(" files with file space info setting--options -S and -T are set"); + ++j; /* #2 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.fs_strategy = -1; /* "FSM_AGGR" specified via -S FSM_AGGR */ + pack_options.fs_threshold = -1; /* "0" specified via -T 0 */ + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + + TESTING(" files with file space info setting-- options -S and -P are set & -L"); + ++j; /* #3 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ + pack_options.fs_persist = TRUE; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + TESTING(" files with file space info setting-- options -P and -T are set & -L"); + ++j; /* #4 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 2; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + TESTING(" files with file space info setting-- options -S and -G are set & -L"); + ++j; /* #5 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; + pack_options.fs_pagesize = 8192; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); + ++j; /* #6 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 8192; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); + ++j; /* #7 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if(h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 4096; + if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(fname, FSPACE_OUT, &pack_options)<=0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + /*------------------------------------------------------------------------- * file with fill values *------------------------------------------------------------------------- @@ -212,8 +381,7 @@ int main (void) TESTING(" copy of datasets (fill values)"); - /* fs_type = 0; fs_size = 0 */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME0,FNAME0OUT,&pack_options) < 0) GOERROR; @@ -233,7 +401,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" copy of datasets (all datatypes)"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME1,FNAME1OUT,&pack_options) < 0) GOERROR; @@ -253,7 +421,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" copy of datasets (attributes)"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME2,FNAME2OUT,&pack_options) < 0) GOERROR; @@ -272,7 +440,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" copy of datasets (hardlinks)"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME3,FNAME3OUT,&pack_options) < 0) GOERROR; @@ -292,7 +460,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" copy of allocation early file"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME5,FNAME5OUT,&pack_options) < 0) GOERROR; @@ -322,7 +490,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset1:GZIP=9",&pack_options) < 0) GOERROR; @@ -349,7 +517,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, TRUE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, TRUE) < 0) GOERROR; if (h5repack_addfilter("dset1:GZIP=9",&pack_options) < 0) GOERROR; @@ -377,7 +545,7 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("GZIP=1",&pack_options) < 0) GOERROR; @@ -415,7 +583,7 @@ int main (void) */ if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset2:SZIP=8,EC",&pack_options) < 0) GOERROR; @@ -447,7 +615,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("SZIP=8,NN",&pack_options) < 0) GOERROR; @@ -476,7 +644,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset1:SHUF",&pack_options) < 0) GOERROR; @@ -500,8 +668,7 @@ int main (void) TESTING(" addding shuffle filter to all"); - /* fs_type = H5F_FILE_SPACE_ALL_PERSIST; fs_size = 1 */ - if (h5repack_init (&pack_options, 0, FALSE, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("SHUF",&pack_options) < 0) GOERROR; @@ -526,7 +693,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset1:FLET",&pack_options) < 0) GOERROR; @@ -551,7 +718,7 @@ int main (void) TESTING(" adding checksum filter to all"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("FLET",&pack_options) < 0) GOERROR; @@ -576,7 +743,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options) < 0) GOERROR; @@ -616,7 +783,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset1:CHUNK=20x10",&pack_options) < 0) GOERROR; @@ -638,7 +805,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, TRUE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, TRUE) < 0) GOERROR; if (h5repack_addlayout("dset1:CHUNK=20x10",&pack_options) < 0) GOERROR; @@ -658,7 +825,7 @@ int main (void) */ TESTING(" adding layout chunked to all"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("CHUNK=20x10",&pack_options) < 0) GOERROR; @@ -679,7 +846,7 @@ int main (void) * test an individual object option *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset1:CONTI",&pack_options) < 0) GOERROR; @@ -700,7 +867,7 @@ int main (void) * test all objects option *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("CONTI",&pack_options) < 0) GOERROR; @@ -717,7 +884,7 @@ int main (void) * do the same test for a file with filters (chunked) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("CONTI",&pack_options) < 0) GOERROR; @@ -739,7 +906,7 @@ int main (void) *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset1:COMPA",&pack_options) < 0) GOERROR; @@ -760,8 +927,7 @@ int main (void) *------------------------------------------------------------------------- */ - /* fs_type = H5F_FILE_SPACE_ALL; fs_size = 2 */ - if (h5repack_init (&pack_options, 0, FALSE, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("COMPA",&pack_options) < 0) GOERROR; @@ -783,7 +949,7 @@ int main (void) * layout compact to contiguous conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_compact:CONTI",&pack_options) < 0) GOERROR; @@ -803,7 +969,7 @@ int main (void) * layout compact to chunk conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_compact:CHUNK=2x5",&pack_options) < 0) GOERROR; @@ -823,7 +989,7 @@ int main (void) * layout compact to compact conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_compact:COMPA",&pack_options) < 0) GOERROR; @@ -842,7 +1008,7 @@ int main (void) * layout contiguous to compact conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_contiguous:COMPA",&pack_options) < 0) GOERROR; @@ -861,7 +1027,7 @@ int main (void) * layout contiguous to chunk conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_contiguous:CHUNK=3x6",&pack_options) < 0) GOERROR; @@ -881,7 +1047,7 @@ int main (void) * layout contiguous to contiguous conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_contiguous:CONTI",&pack_options) < 0) GOERROR; @@ -900,7 +1066,7 @@ int main (void) * layout chunked to compact conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_chunk:COMPA",&pack_options) < 0) GOERROR; @@ -920,7 +1086,7 @@ int main (void) * layout chunked to contiguous conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_chunk:CONTI",&pack_options) < 0) GOERROR; @@ -939,7 +1105,7 @@ int main (void) * layout chunked to chunked conversion *------------------------------------------------------------------------- */ - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addlayout("dset_chunk:CHUNK=18x13",&pack_options) < 0) GOERROR; @@ -969,8 +1135,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { - /* fs_type = H5F_FILE_SPACE_AGGR_VFD; fs_size = 3 */ - if (h5repack_init (&pack_options, 0, FALSE, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME7,FNAME7OUT,&pack_options) < 0) GOERROR; @@ -995,7 +1160,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_szip:NONE",&pack_options) < 0) GOERROR; @@ -1020,7 +1185,7 @@ int main (void) TESTING(" copy of deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME8,FNAME8OUT,&pack_options) < 0) GOERROR; @@ -1040,7 +1205,7 @@ int main (void) TESTING(" removing deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE - if (h5repack_init (&pack_options, 0, FALSE, fs_type, ++fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_deflate:NONE",&pack_options) < 0) GOERROR; @@ -1062,7 +1227,7 @@ int main (void) TESTING(" copy of shuffle filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME9,FNAME9OUT,&pack_options) < 0) GOERROR; @@ -1078,7 +1243,7 @@ int main (void) TESTING(" removing shuffle filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_shuffle:NONE",&pack_options) < 0) GOERROR; @@ -1096,7 +1261,7 @@ int main (void) TESTING(" copy of fletcher filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME10,FNAME10OUT,&pack_options) < 0) GOERROR; @@ -1112,7 +1277,7 @@ int main (void) TESTING(" removing fletcher filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_fletcher32:NONE",&pack_options) < 0) GOERROR; @@ -1130,7 +1295,7 @@ int main (void) TESTING(" copy of nbit filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME12,FNAME12OUT,&pack_options) < 0) GOERROR; @@ -1146,7 +1311,7 @@ int main (void) TESTING(" removing nbit filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_nbit:NONE",&pack_options) < 0) GOERROR; @@ -1164,7 +1329,7 @@ int main (void) TESTING(" adding nbit filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_int31:NBIT",&pack_options) < 0) GOERROR; @@ -1182,7 +1347,7 @@ int main (void) TESTING(" copy of scaleoffset filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME13,FNAME13OUT,&pack_options) < 0) GOERROR; @@ -1198,7 +1363,7 @@ int main (void) TESTING(" removing scaleoffset filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_scaleoffset:NONE",&pack_options) < 0) GOERROR; @@ -1216,7 +1381,7 @@ int main (void) TESTING(" adding scaleoffset filter"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_none:SOFF=31,IN",&pack_options) < 0) GOERROR; @@ -1248,8 +1413,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { - /* fs_type = H5F_FILE_SPACE_VFD; fs_size = 4 */ - if (h5repack_init (&pack_options, 0, FALSE, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_deflate:SZIP=8,NN",&pack_options) < 0) GOERROR; @@ -1275,7 +1439,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset_szip:GZIP=1",&pack_options) < 0) GOERROR; @@ -1306,7 +1470,7 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("NONE",&pack_options) < 0) GOERROR; @@ -1330,7 +1494,7 @@ int main (void) */ TESTING(" big file"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME14,FNAME14OUT,&pack_options) < 0) GOERROR; @@ -1347,7 +1511,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" external datasets"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack(FNAME15,FNAME15OUT,&pack_options) < 0) GOERROR; @@ -1364,7 +1528,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" file with userblock"); - if(h5repack_init(&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; if(h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) GOERROR; @@ -1383,7 +1547,7 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" latest file format options"); - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; pack_options.latest=1; pack_options.grp_compact=10; @@ -1413,7 +1577,7 @@ int main (void) #if defined (H5_HAVE_FILTER_DEFLATE) - if (h5repack_init (&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if (h5repack_init (&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("GZIP=1",&pack_options) < 0) GOERROR; @@ -1442,7 +1606,7 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for a user block size and user block filename */ @@ -1475,7 +1639,7 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for aligment */ @@ -1529,7 +1693,7 @@ int main (void) */ TESTING(" file with committed datatypes"); - if(h5repack_init(&pack_options, 0, FALSE, fs_type, fs_size) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; if(h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) @@ -1556,7 +1720,7 @@ int main (void) /* First run without metadata option. No need to verify the correctness */ /* since this has been verified by earlier tests. Just record the file */ /* size of the output file. */ - if(h5repack_init(&pack_options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t)0) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; @@ -1567,7 +1731,7 @@ int main (void) GOERROR; /* run it again with metadata option */ - if(h5repack_init(&pack_options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t)0) < 0) + if(h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; pack_options.meta_block_size = 8192; if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) @@ -1625,6 +1789,9 @@ static int make_testfiles(void) { hid_t fid; + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File access property list */ + unsigned j; /* Local index variable */ /*------------------------------------------------------------------------- * create a file for general copy test @@ -1865,6 +2032,173 @@ int make_testfiles(void) if(H5Fclose(fid) < 0) return -1; + /*------------------------------------------------------------------------- + * create 8 files with combinations ??? + *------------------------------------------------------------------------- */ + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + return -1; + + /* Set to use latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + return -1; + + /* + * #0 -- h5repack_latest.h5 + * default: strategy=FSM_AGGR, persist=FALSE, threshold=1 + * default: inpage=4096 + */ + j = 0; + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[j], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + + /* + * #1 -- h5repack_default.h5 + * default: strategy=FSM_AGGR, persist=FALSE, threshold=1 + * default: inpage=4096 + */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + + /* + * #2 -- h5repack_page_persist.h5 + * Setting: + * strategy=PAGE, persist=TRUE, threshold=1 + * inpage=512 + * latest format + */ + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + + /* + * #3 -- h5repack_fsm_aggr_persist.h5 + * Setting: + * strategy=FSM_AGGR, persist=TRUE, threshold=1 + * default: inpage=4096 + */ + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + + /* + * #4 -- h5repack_page_threshold.h5 + * Setting: + * strategy=PAGE, persist=FALSE, threshold=3 + * inpage=8192 + * latest format + */ + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) + return -1; + if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + /* + * #5 -- h5repack_fsm_aggr_threshold.h5 + * Setting: + * strategy=FSM_AGGR, persist=FALSE, threshold=3 + * inpage=4096 + */ + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) + return -1; + if(H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + /* + * #6 -- h5repack_aggr.h5 + * Setting: + * strategy=AGGR, persist=FALSE, threshold=1 + * latest format + */ + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + /* + * #7 -- h5repack_none.h5 + * Setting: + * strategy=NONE, persist=FALSE, threshold=1 + * inpage=8192 + */ + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1) < 0) + return -1; + if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if(H5Fclose(fid) < 0) + return -1; + if(H5Pclose(fcpl) < 0) + return -1; + + if(H5Pclose(fapl) < 0) + return -1; + return 0; out: diff --git a/tools/test/h5repack/testfiles/4_vds.h5-vds_conti-v.ddl b/tools/test/h5repack/testfiles/4_vds.h5-vds_conti-v.ddl index c499b35..54bf26c 100644 --- a/tools/test/h5repack/testfiles/4_vds.h5-vds_conti-v.ddl +++ b/tools/test/h5repack/testfiles/4_vds.h5-vds_conti-v.ddl @@ -5,7 +5,7 @@ DATASET "vds_dset" { STORAGE_LAYOUT { CONTIGUOUS SIZE 576 - OFFSET 2144 + OFFSET 2048 } FILTERS { NONE diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 049e27d..69b1644 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -19,8 +19,10 @@ usage: h5repack [OPTIONS] file1 file2 -a A, --alignment=A Alignment value for H5Pset_alignment -f FILT, --filter=FILT Filter type -l LAYT, --layout=LAYT Layout type - -S FS_STRGY, --fs_strategy=FS_STRGY File space management strategy - -T FS_THRD, --fs_threshold=FS_THRD Free-space section threshold + -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy + -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy + -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy + -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size M - is an integer greater than 1, size of dataset in bytes (default is 0) E - is a filename. @@ -36,18 +38,27 @@ usage: h5repack [OPTIONS] file1 file2 --enable-error-stack Prints messages from the HDF5 error stack as they occur. - FS_STRGY is the file space management strategy to use for the output file. - It is a string as listed below: - ALL_PERSIST - Use persistent free-space managers, aggregators and virtual file driver - for file space allocation - ALL - Use non-persistent free-space managers, aggregators and virtual file driver - for file space allocation - AGGR_VFD - Use aggregators and virtual file driver for file space allocation - VFD - Use virtual file driver for file space allocation - - FS_THRD is the free-space section threshold to use for the output file. - It is the minimum size (in bytes) of free-space sections to be tracked - by the the library's free-space managers. + FS_STRATEGY is a string indicating the file space strategy used: + FSM_AGGR: + The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver. + PAGE: + The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver. + AGGR: + The mechanisms used in managing file space are aggregators and virtual file driver. + NONE: + The mechanisms used in managing file space are virtual file driver. + The default strategy when not set is FSM_AGGR without persisting free-space. + + FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space. + The default when not set is not persisting free-space. + The value is ignored for AGGR and NONE strategies. + + FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library. + The default when not set is 1. + The value is ignored for AGGR and NONE strategies. + + FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used. + The default when not set is 4096. FILT - is a string with the format: diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index f6735d5..ea602ba 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -25,7 +25,6 @@ h5stat_newgrat.ddl h5stat_newgrat-UG.ddl h5stat_newgrat-UA.ddl - h5stat_idx.ddl h5stat_err1_links.ddl h5stat_links1.ddl h5stat_links2.ddl @@ -46,7 +45,6 @@ h5stat_filters.h5 h5stat_tsohm.h5 h5stat_newgrat.h5 - h5stat_idx.h5 h5stat_threshold.h5 ) @@ -196,8 +194,6 @@ ADD_H5_TEST (h5stat_newgrat 0 h5stat_newgrat.h5) ADD_H5_TEST (h5stat_newgrat-UG 0 -G h5stat_newgrat.h5) ADD_H5_TEST (h5stat_newgrat-UA 0 -A h5stat_newgrat.h5) -# h5stat_idx.h5 is generated by h5stat_gentest.c - ADD_H5_TEST (h5stat_idx 0 h5stat_idx.h5) # # Tests for -l (--links) option on h5stat_threshold.h5: # -l 0 (incorrect threshold value) diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index b1ab168..804f418 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.c @@ -77,7 +77,7 @@ gen_newgrat_file(const char *fname) goto error; /* Set file space handling strategy */ - if(H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0) < 0) + if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) goto error; /* Create file */ diff --git a/tools/test/h5stat/testfiles/h5stat_filters.ddl b/tools/test/h5stat/testfiles/h5stat_filters.ddl index 1a4fd72..9f9e146 100644 --- a/tools/test/h5stat/testfiles/h5stat_filters.ddl +++ b/tools/test/h5stat/testfiles/h5stat_filters.ddl @@ -82,12 +82,14 @@ Small # of attributes (objects with 1 to 10 attributes): Attribute bins: Total # of objects with attributes: 0 Max. # of attributes to objects: 0 +Free-space persist: FALSE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): Total # of small size sections: 0 Free-space section bins: Total # of sections: 0 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 37312 bytes Raw data: 8659 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_idx.ddl b/tools/test/h5stat/testfiles/h5stat_idx.ddl index b26f1a4..1b6ae0c 100644 --- a/tools/test/h5stat/testfiles/h5stat_idx.ddl +++ b/tools/test/h5stat/testfiles/h5stat_idx.ddl @@ -79,15 +79,17 @@ Small # of attributes (objects with 1 to 10 attributes): Attribute bins: Total # of objects with attributes: 0 Max. # of attributes to objects: 0 +Free-space persist: FALSE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): Total # of small size sections: 0 Free-space section bins: Total # of sections: 0 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 965 bytes Raw data: 110 bytes Amount/Percent of tracked free space: 0 bytes/0.0% - Unaccounted space: 1131 bytes -Total space: 2206 bytes + Unaccounted space: 1083 bytes +Total space: 2158 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_idx.h5 b/tools/test/h5stat/testfiles/h5stat_idx.h5 index 303d1f8..83ebcdb 100644 Binary files a/tools/test/h5stat/testfiles/h5stat_idx.h5 and b/tools/test/h5stat/testfiles/h5stat_idx.h5 differ diff --git a/tools/test/h5stat/testfiles/h5stat_links2.ddl b/tools/test/h5stat/testfiles/h5stat_links2.ddl index 4622884..9fc82cd 100644 --- a/tools/test/h5stat/testfiles/h5stat_links2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_links2.ddl @@ -91,12 +91,14 @@ Attribute bins: # of objects with 10 - 99 attributes: 3 Total # of objects with attributes: 5 Max. # of attributes to objects: 25 +Free-space persist: FALSE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): Total # of small size sections: 0 Free-space section bins: Total # of sections: 0 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 16128 bytes Raw data: 0 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_newgrat.ddl b/tools/test/h5stat/testfiles/h5stat_newgrat.ddl index e305f58..130fe2f 100644 --- a/tools/test/h5stat/testfiles/h5stat_newgrat.ddl +++ b/tools/test/h5stat/testfiles/h5stat_newgrat.ddl @@ -9,7 +9,7 @@ File information Max. # of objects in group: 35001 File space information for file metadata (in bytes): Superblock: 48 - Superblock extension: 119 + Superblock extension: 186 User block: 0 Object headers: (total/unused) Groups: 5145147/3220092 @@ -78,6 +78,7 @@ Attribute bins: # of objects with 100 - 999 attributes: 1 Total # of objects with attributes: 1 Max. # of attributes to objects: 100 +Free-space persist: TRUE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): # of sections of size 1: 1 @@ -86,10 +87,11 @@ Free-space section bins: # of sections of size 1 - 9: 1 # of sections of size 10 - 99: 4 Total # of sections: 5 -File space management strategy: H5F_FILE_SPACE_ALL_PERSIST +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: - File metadata: 6362036 bytes + File metadata: 6362103 bytes Raw data: 0 bytes Amount/Percent of tracked free space: 132 bytes/0.0% Unaccounted space: 0 bytes -Total space: 6362168 bytes +Total space: 6362235 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_newgrat.h5 b/tools/test/h5stat/testfiles/h5stat_newgrat.h5 index c919b71..0d68e79 100644 Binary files a/tools/test/h5stat/testfiles/h5stat_newgrat.h5 and b/tools/test/h5stat/testfiles/h5stat_newgrat.h5 differ diff --git a/tools/test/h5stat/testfiles/h5stat_numattrs1.ddl b/tools/test/h5stat/testfiles/h5stat_numattrs1.ddl index fb5568d..af53776 100644 --- a/tools/test/h5stat/testfiles/h5stat_numattrs1.ddl +++ b/tools/test/h5stat/testfiles/h5stat_numattrs1.ddl @@ -8,7 +8,8 @@ Attribute bins: # of objects with 10 - 99 attributes: 3 Total # of objects with attributes: 5 Max. # of attributes to objects: 25 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 16128 bytes Raw data: 0 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_numattrs2.ddl b/tools/test/h5stat/testfiles/h5stat_numattrs2.ddl index ccb23c1..638781b 100644 --- a/tools/test/h5stat/testfiles/h5stat_numattrs2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_numattrs2.ddl @@ -91,12 +91,14 @@ Attribute bins: # of objects with 10 - 99 attributes: 3 Total # of objects with attributes: 5 Max. # of attributes to objects: 25 +Free-space persist: FALSE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): Total # of small size sections: 0 Free-space section bins: Total # of sections: 0 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 16128 bytes Raw data: 0 bytes diff --git a/tools/test/h5stat/testfiles/h5stat_tsohm.ddl b/tools/test/h5stat/testfiles/h5stat_tsohm.ddl index 4cf33fc..9369950 100644 --- a/tools/test/h5stat/testfiles/h5stat_tsohm.ddl +++ b/tools/test/h5stat/testfiles/h5stat_tsohm.ddl @@ -76,12 +76,14 @@ Small # of attributes (objects with 1 to 10 attributes): Attribute bins: Total # of objects with attributes: 0 Max. # of attributes to objects: 0 +Free-space persist: FALSE Free-space section threshold: 1 bytes Small size free-space sections (< 10 bytes): Total # of small size sections: 0 Free-space section bins: Total # of sections: 0 -File space management strategy: H5F_FILE_SPACE_ALL +File space management strategy: H5F_FSPACE_STRATEGY_FSM_AGGR +File space page size: 4096 bytes Summary of file space information: File metadata: 3850 bytes Raw data: 0 bytes diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt index 029d7a9..97a6f0c 100644 --- a/tools/test/misc/CMakeLists.txt +++ b/tools/test/misc/CMakeLists.txt @@ -39,4 +39,6 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) target_link_libraries (clear_open_chk ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (clear_open_chk PROPERTIES FOLDER tools) - include (CMakeTests.cmake) + include (CMakeTestsRepart.cmake) + include (CMakeTestsClear.cmake) + include (CMakeTestsMkgrp.cmake) diff --git a/tools/test/misc/CMakeTests.cmake b/tools/test/misc/CMakeTests.cmake deleted file mode 100644 index 9ecdeae..0000000 --- a/tools/test/misc/CMakeTests.cmake +++ /dev/null @@ -1,340 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - # -------------------------------------------------------------------- - # Copy all the HDF5 files from the source directory into the test directory - # -------------------------------------------------------------------- - set (HDF5_REFERENCE_TEST_FILES - family_file00000.h5 - family_file00001.h5 - family_file00002.h5 - family_file00003.h5 - family_file00004.h5 - family_file00005.h5 - family_file00006.h5 - family_file00007.h5 - family_file00008.h5 - family_file00009.h5 - family_file00010.h5 - family_file00011.h5 - family_file00012.h5 - family_file00013.h5 - family_file00014.h5 - family_file00015.h5 - family_file00016.h5 - family_file00017.h5 - ) - - foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) - HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5repart_files") - endforeach () - add_custom_target(h5repart_files ALL COMMENT "Copying files needed by h5repart tests" DEPENDS ${h5repart_files_list}) - - set (HDF5_MKGRP_TEST_FILES - #h5mkgrp_help.txt - #h5mkgrp_version - h5mkgrp_single.ls - h5mkgrp_single_v.ls - h5mkgrp_single_p.ls - h5mkgrp_single_l.ls - h5mkgrp_several.ls - h5mkgrp_several_v.ls - h5mkgrp_several_p.ls - h5mkgrp_several_l.ls - h5mkgrp_nested_p.ls - h5mkgrp_nested_lp.ls - h5mkgrp_nested_mult_p.ls - h5mkgrp_nested_mult_lp.ls - ) - - # make test dir - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - - foreach (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) - HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_mkgrp_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_mkgrp_file}" "h5mkgrp_files") - endforeach () - - HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_help.txt" "${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_help.txt" "h5mkgrp_files") - add_custom_target(h5mkgrp_files ALL COMMENT "Copying files needed by h5mkgrp tests" DEPENDS ${h5mkgrp_files_list}) - - configure_file (${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_version.txt.in ${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_version.txt @ONLY) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - macro (ADD_H5_TEST resultfile resultcode resultoption) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5MKGRP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.h5 - ) - set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - endif () - - add_test ( - NAME H5MKGRP-${resultfile} - COMMAND $ ${resultoption} ${resultfile}.h5 ${ARGN} - ) - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (HDF5_ENABLE_USING_MEMCHECKER) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - else () - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS H5MKGRP-${resultfile}-clear-objects) - add_test ( - NAME H5MKGRP-${resultfile}-h5ls - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=-v;-r;${resultfile}.h5" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_MASK_MOD=true" - -D "TEST_REFERENCE=${resultfile}.ls" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5MKGRP-${resultfile}-h5ls PROPERTIES DEPENDS H5MKGRP-${resultfile}) - endif () - endmacro () - - macro (ADD_H5_CMP resultfile resultcode) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND $ ${ARGN}) - else () - add_test ( - NAME H5MKGRP_CMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.h5 - ) - set_tests_properties (H5MKGRP_CMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - add_test ( - NAME H5MKGRP_CMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.txt" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects) - endif () - endmacro () - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - - ###################### H5REPART ######################### - # Remove any output file left over from previous test run - add_test ( - NAME H5REPART-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - fst_family00000.h5 - scd_family00000.h5 - scd_family00001.h5 - scd_family00002.h5 - scd_family00003.h5 - family_to_sec2.h5 - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPART-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPART-clearall-objects") - - # repartition family member size to 20,000 bytes. - add_test (NAME H5REPART-h5repart_20K COMMAND $ -m 20000 family_file%05d.h5 fst_family%05d.h5) - set_tests_properties (H5REPART-h5repart_20K PROPERTIES DEPENDS H5REPART-clearall-objects) - - # repartition family member size to 5 KB. - add_test (NAME H5REPART-h5repart_5K COMMAND $ -m 5k family_file%05d.h5 scd_family%05d.h5) - set_tests_properties (H5REPART-h5repart_5K PROPERTIES DEPENDS H5REPART-clearall-objects) - - # convert family file to sec2 file of 20,000 bytes - add_test (NAME H5REPART-h5repart_sec2 COMMAND $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5) - set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES DEPENDS H5REPART-clearall-objects) - - # test the output files repartitioned above. - add_test (NAME H5REPART-h5repart_test COMMAND $) - set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS "H5REPART-clearall-objects;H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_sec2") - - set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} - h5repart_test - ) - - ###################### H5CLEAR ######################### - # Remove any output file left over from previous test run - add_test ( - NAME H5CLEAR-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5clear_log_v3.h5 - h5clear_sec2_v0.h5 - h5clear_sec2_v2.h5 - h5clear_sec2_v3.h5 - latest_h5clear_log_v3.h5 - latest_h5clear_sec2_v3.h5 - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-clearall-objects") - - # create the output files to be used. - add_test (NAME H5CLEAR-h5clear_gentest COMMAND $) - set_tests_properties (H5CLEAR-h5clear_gentest PROPERTIES DEPENDS "H5CLEAR-clearall-objects") - - # Initial file open fails - add_test (NAME H5CLEAR-clear_open_chk-sec2_v3_F COMMAND $ h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3_F PROPERTIES WILL_FAIL "true") - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-sec2_v3 COMMAND $ h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-h5clear-sec2_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v3_F) - add_test (NAME H5CLEAR-clear_open_chk-sec2_v3 COMMAND $ h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v3) - - # Initial file open fails - add_test (NAME H5CLEAR-clear_open_chk-log_v3_F COMMAND $ h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-log_v3_F PROPERTIES WILL_FAIL "true") - set_tests_properties (H5CLEAR-clear_open_chk-log_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-log_v3 COMMAND $ h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-h5clear-log_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-log_v3_F) - add_test (NAME H5CLEAR-clear_open_chk-log_v3 COMMAND $ h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-log_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-log_v3) - - # Initial file open fails - add_test (NAME H5CLEAR-clear_open_chk-latest_sec2_v3_F COMMAND $ latest_h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3_F PROPERTIES WILL_FAIL "true") - set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-latest_sec2_v3 COMMAND $ latest_h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-h5clear-latest_sec2_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-latest_sec2_v3_F) - add_test (NAME H5CLEAR-clear_open_chk-latest_sec2_v3 COMMAND $ latest_h5clear_sec2_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-latest_sec2_v3) - - # Initial file open fails - add_test (NAME H5CLEAR-clear_open_chk-latest_log_v3_F COMMAND $ latest_h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3_F PROPERTIES WILL_FAIL "true") - set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-latest_log_v3 COMMAND $ latest_h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-h5clear-latest_log_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-latest_log_v3_F) - add_test (NAME H5CLEAR-clear_open_chk-latest_log_v3 COMMAND $ latest_h5clear_log_v3.h5) - set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-latest_log_v3) - - # - # File open succeeds because the library does not check status_flags for file with < v3 superblock - add_test (NAME H5CLEAR-clear_open_chk-sec2_v0_P COMMAND $ h5clear_sec2_v0.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v0_P PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-sec2_v0 COMMAND $ h5clear_sec2_v0.h5) - set_tests_properties (H5CLEAR-h5clear-sec2_v0 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v0_P) - add_test (NAME H5CLEAR-clear_open_chk-sec2_v0 COMMAND $ h5clear_sec2_v0.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v0 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v0) - - # - # File open succeeds because the library does not check status_flags for file with < v3 superblock - add_test (NAME H5CLEAR-clear_open_chk-sec2_v2_P COMMAND $ h5clear_sec2_v2.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v2_P PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) - # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clear-sec2_v2 COMMAND $ h5clear_sec2_v2.h5) - set_tests_properties (H5CLEAR-h5clear-sec2_v2 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v2_P) - add_test (NAME H5CLEAR-clear_open_chk-sec2_v2 COMMAND $ h5clear_sec2_v2.h5) - set_tests_properties (H5CLEAR-clear_open_chk-sec2_v2 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v2) - - set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} - h5clear_gentest - ) - - ###################### H5MKGRP ######################### - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5MKGRP-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5mkgrp_help.out - h5mkgrp_help.out.err - h5mkgrp_version.out - h5mkgrp_version.out.err - h5mkgrp_single.h5 - h5mkgrp_single.out - h5mkgrp_single.out.err - h5mkgrp_single_v.h5 - h5mkgrp_single_v.out - h5mkgrp_single_v.out.err - h5mkgrp_single_p.h5 - h5mkgrp_single_p.out - h5mkgrp_single_p.out.err - h5mkgrp_single_l.h5 - h5mkgrp_single_l.out - h5mkgrp_single_l.out.err - h5mkgrp_several.h5 - h5mkgrp_several.out - h5mkgrp_several.out.err - h5mkgrp_several_v.h5 - h5mkgrp_several_v.out - h5mkgrp_several_v.out.err - h5mkgrp_several_p.h5 - h5mkgrp_several_p.out - h5mkgrp_several_p.out.err - h5mkgrp_several_l.h5 - h5mkgrp_several_l.out - h5mkgrp_several_l.out.err - h5mkgrp_nested_p.h5 - h5mkgrp_nested_p.out - h5mkgrp_nested_p.out.err - h5mkgrp_nested_lp.h5 - h5mkgrp_nested_lp.out - h5mkgrp_nested_lp.out.err - h5mkgrp_nested_mult_p.h5 - h5mkgrp_nested_mult_p.out - h5mkgrp_nested_mult_p.out.err - h5mkgrp_nested_mult_lp.h5 - h5mkgrp_nested_mult_lp.out - h5mkgrp_nested_mult_lp.out.err - ) - set_tests_properties (H5MKGRP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5MKGRP-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5MKGRP-clearall-objects") - endif () - - # Check that help & version is displayed properly - ADD_H5_CMP (h5mkgrp_help 0 "-h") - ADD_H5_CMP (h5mkgrp_version 0 "-V") - - # Create single group at root level - ADD_H5_TEST (h5mkgrp_single 0 "" single) - ADD_H5_TEST (h5mkgrp_single_v 0 "-v" single) - ADD_H5_TEST (h5mkgrp_single_p 0 "-p" single) - ADD_H5_TEST (h5mkgrp_single_l 0 "-l" latest) - - # Create several groups at root level - ADD_H5_TEST (h5mkgrp_several 0 "" one two) - ADD_H5_TEST (h5mkgrp_several_v 0 "-v" one two) - ADD_H5_TEST (h5mkgrp_several_p 0 "-p" one two) - ADD_H5_TEST (h5mkgrp_several_l 0 "-l" one two) - - # Create various nested groups - ADD_H5_TEST (h5mkgrp_nested_p 0 "-p" /one/two) - ADD_H5_TEST (h5mkgrp_nested_lp 0 "-lp" /one/two) - ADD_H5_TEST (h5mkgrp_nested_mult_p 0 "-p" /one/two /three/four) - ADD_H5_TEST (h5mkgrp_nested_mult_lp 0 "-lp" /one/two /three/four) diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake new file mode 100644 index 0000000..a92d523 --- /dev/null +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -0,0 +1,197 @@ + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + # -------------------------------------------------------------------- + # Copy all the HDF5 files from the source directory into the test directory + # -------------------------------------------------------------------- + set (HDF5_REFERENCE_TEST_FILES + h5clear_usage.ddl + h5clear_open_fail.ddl + h5clear_missing_file.ddl + h5clear_no_mdc_image.ddl + orig_h5clear_sec2_v0.h5 + orig_h5clear_sec2_v2.h5 + orig_h5clear_sec2_v3.h5 + mod_h5clear_mdc_image.h5 + ) + + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) + HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5clear_files") + endforeach () + # make second copy of mod_h5clear_mdc_image.h5 + HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/mod_h5clear_mdc_image.h5" "${PROJECT_BINARY_DIR}/testfiles/mod_h5clear_mdc_image2.h5" "h5clear_files") + add_custom_target(h5clear_files ALL COMMENT "Copying files needed by h5clear tests" DEPENDS ${h5clear_files_list}) + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_H5_CMP testname resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_CMP-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${testname}.out + ${testname}.out.err + ) + add_test ( + NAME H5CLEAR_CMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + endif () + endmacro () + + macro (ADD_H5_RETTEST testname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_RET-${testname} + COMMAND $ ${ARGN} + ) + set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WILL_FAIL "${resultcode}") + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5CLEAR_RET-${testname}") + endif () + endmacro () + + macro (ADD_H5_TEST testname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + # Initial file open fails OR + # File open succeeds because the library does not check status_flags for file with < v3 superblock + add_test (NAME H5CLEAR-clear_open_chk-${testname}_${resultcode} COMMAND $ ${testname}.h5) + set_tests_properties (H5CLEAR-clear_open_chk-${testname}_${resultcode} PROPERTIES WILL_FAIL "${resultcode}") + set_tests_properties (H5CLEAR-clear_open_chk-${testname}_${resultcode} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR-clear_open_chk-${testname}_${resultcode} PROPERTIES DEPENDS ${last_test}) + endif () + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-${testname} COMMAND $ -s ${testname}.h5) + set_tests_properties (H5CLEAR-h5clear-${testname} PROPERTIES DEPENDS H5CLEAR-clear_open_chk-${testname}_${resultcode}) + set_tests_properties (H5CLEAR-h5clear-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + add_test (NAME H5CLEAR-clear_open_chk-${testname} COMMAND $ ${testname}.h5) + set_tests_properties (H5CLEAR-clear_open_chk-${testname} PROPERTIES DEPENDS H5CLEAR-h5clear-${testname}) + set_tests_properties (H5CLEAR-clear_open_chk-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + set (last_test "H5CLEAR-clear_open_chk-${testname}") + endif () + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## +# +# +# +# The following are tests to verify the status_flags field is cleared properly: + # Remove any output file left over from previous test run + add_test ( + NAME H5CLEAR-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + h5clear_log_v3.h5 + h5clear_mdc_image.h5 + h5clear_sec2_v0.h5 + h5clear_sec2_v2.h5 + h5clear_sec2_v3.h5 + latest_h5clear_log_v3.h5 + latest_h5clear_sec2_v3.h5 + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5CLEAR-clearall-objects") + + # create the output files to be used. + add_test (NAME H5CLEAR-h5clear_gentest COMMAND $) + set_tests_properties (H5CLEAR-h5clear_gentest PROPERTIES DEPENDS "H5CLEAR-clearall-objects") + set_tests_properties (H5CLEAR-h5clear_gentest PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + set (last_test "H5CLEAR-h5clear_gentest") + +# +# +# +# The following are tests to verify the expected output from h5clear +# "h5clear -h" +# "h5clear" (no options, no file) +# "h5clear junk.h5" (no options, nonexisting file) +# "h5clear orig_h5clear_sec2_v3.h5" (no options, existing file) +# "h5clear -m" (valid 1 option, no file) +# "h5clear -s junk.h5" (valid 1 option, nonexisting file) +# "h5clear -m -s junk.h5" (valid 2 options, no file) +# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file) +# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image) +# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image) + ADD_H5_CMP (h5clear_usage_h h5clear_usage 0 "-h") + ADD_H5_CMP (h5clear_usage h5clear_usage 1 "") + ADD_H5_CMP (h5clear_usage_junk h5clear_usage 1 "" junk.h5) + ADD_H5_CMP (h5clear_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) + ADD_H5_CMP (h5clear_missing_file_m h5clear_missing_file 1 "-m") + ADD_H5_CMP (h5clear_open_fail_s h5clear_open_fail 1 "-s" junk.h5) + ADD_H5_CMP (h5clear_missing_file_ms h5clear_missing_file 1 "-m" "-s") + ADD_H5_CMP (h5clear_open_fail_ms h5clear_open_fail 1 "-m" "-s" junk.h5) + ADD_H5_CMP (h5clear_no_mdc_image_m h5clear_no_mdc_image 0 "-m" orig_h5clear_sec2_v2.h5) + ADD_H5_CMP (h5clear_no_mdc_image_ms h5clear_no_mdc_image 0 "-m" "-s" orig_h5clear_sec2_v0.h5) +# +# +# +# The following are tests to verify the expected exit code from h5clear: +# "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code) +# "h5clear --vers" (valid option, version #, succeed exit code) +# "h5clear -k" (invalid 1 option, no file, fail exit code) +# "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code) +# "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code) +# "h5clear -m -k" (valid/invalid 2 options, nofile, fail exit code) +# "h5clear -l -m" (invalid/valid 2 options, nofile, fail exit code) +# "h5clear -m -k junk.h5" (valid/invalid 2 options, nonexisting file, fail exit code) +# "h5clear -l -m junk.h5" (invalid/valid 2 options, nonexisting file, fail exit code) +# "h5clear -m -k h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code) +# "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code) + ADD_H5_RETTEST (h5clear_mdc_image "false" "-m" h5clear_mdc_image.h5) + ADD_H5_RETTEST (h5clear_vers "false" "--vers") + ADD_H5_RETTEST (h5clear_k "true" "-k") + ADD_H5_RETTEST (h5clear_k_junk "true" "-k" junk.h5) + ADD_H5_RETTEST (h5clear_l_sec2 "true" "-l" h5clear_sec2_v2.h5) + ADD_H5_RETTEST (h5clear_mk "true" "-m" "-k") + ADD_H5_RETTEST (h5clear_lm "true" "-l" "-m") + ADD_H5_RETTEST (h5clear_ml_junk "true" "-m" "-l" junk.h5) + ADD_H5_RETTEST (h5clear_lm_junk "true" "-l" "-m" junk.h5) + ADD_H5_RETTEST (h5clear_ml_sec2 "true" "-m" "-l" h5clear_sec2_v2.h5) + ADD_H5_RETTEST (h5clear_lm_sec2 "true" "-l" "-m" h5clear_sec2_v2.h5) +# +# +# +# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear: + ADD_H5_CMP (h5clear_mdc_image_m h5clear_no_mdc_image 0 "-m" mod_h5clear_mdc_image.h5) + ADD_H5_CMP (h5clear_mdc_image_sm h5clear_no_mdc_image 0 "-m" "-s" mod_h5clear_mdc_image2.h5) +# +# +# +# The following are tests to verify the status_flags field is cleared properly: + ADD_H5_TEST (h5clear_sec2_v3 "true") + ADD_H5_TEST (h5clear_log_v3 "true") + ADD_H5_TEST (latest_h5clear_sec2_v3 "true") + ADD_H5_TEST (latest_h5clear_log_v3 "true") + ADD_H5_TEST (h5clear_sec2_v0 "false") + ADD_H5_TEST (h5clear_sec2_v2 "false") + + set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + h5clear_gentest + ) diff --git a/tools/test/misc/CMakeTestsMkgrp.cmake b/tools/test/misc/CMakeTestsMkgrp.cmake new file mode 100644 index 0000000..2a54a0e --- /dev/null +++ b/tools/test/misc/CMakeTestsMkgrp.cmake @@ -0,0 +1,188 @@ + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + # -------------------------------------------------------------------- + # Copy all the HDF5 files from the source directory into the test directory + # -------------------------------------------------------------------- + set (HDF5_MKGRP_TEST_FILES + #h5mkgrp_help.txt + #h5mkgrp_version + h5mkgrp_single.ls + h5mkgrp_single_v.ls + h5mkgrp_single_p.ls + h5mkgrp_single_l.ls + h5mkgrp_several.ls + h5mkgrp_several_v.ls + h5mkgrp_several_p.ls + h5mkgrp_several_l.ls + h5mkgrp_nested_p.ls + h5mkgrp_nested_lp.ls + h5mkgrp_nested_mult_p.ls + h5mkgrp_nested_mult_lp.ls + ) + + # make test dir + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + + foreach (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_mkgrp_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_mkgrp_file}" "h5mkgrp_files") + endforeach () + + HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_help.txt" "${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_help.txt" "h5mkgrp_files") + add_custom_target(h5mkgrp_files ALL COMMENT "Copying files needed by h5mkgrp tests" DEPENDS ${h5mkgrp_files_list}) + + configure_file (${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_version.txt.in ${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_version.txt @ONLY) + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_H5_TEST resultfile resultcode resultoption) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5MKGRP-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.h5 + ) + set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + endif () + + add_test ( + NAME H5MKGRP-${resultfile} + COMMAND $ ${resultoption} ${resultfile}.h5 ${ARGN} + ) + set_tests_properties (H5MKGRP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if (HDF5_ENABLE_USING_MEMCHECKER) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () + else (HDF5_ENABLE_USING_MEMCHECKER) + set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS H5MKGRP-${resultfile}-clear-objects) + add_test ( + NAME H5MKGRP-${resultfile}-h5ls + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;-r;${resultfile}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_MASK_MOD=true" + -D "TEST_REFERENCE=${resultfile}.ls" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5MKGRP-${resultfile}-h5ls PROPERTIES DEPENDS H5MKGRP-${resultfile}) + endif () + endmacro () + + macro (ADD_H5_CMP resultfile resultcode) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND $ ${ARGN}) + else () + add_test ( + NAME H5MKGRP_CMP-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.h5 + ) + set_tests_properties (H5MKGRP_CMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + add_test ( + NAME H5MKGRP_CMP-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.txt" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects) + endif () + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5MKGRP-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + h5mkgrp_help.out + h5mkgrp_help.out.err + h5mkgrp_version.out + h5mkgrp_version.out.err + h5mkgrp_single.h5 + h5mkgrp_single.out + h5mkgrp_single.out.err + h5mkgrp_single_v.h5 + h5mkgrp_single_v.out + h5mkgrp_single_v.out.err + h5mkgrp_single_p.h5 + h5mkgrp_single_p.out + h5mkgrp_single_p.out.err + h5mkgrp_single_l.h5 + h5mkgrp_single_l.out + h5mkgrp_single_l.out.err + h5mkgrp_several.h5 + h5mkgrp_several.out + h5mkgrp_several.out.err + h5mkgrp_several_v.h5 + h5mkgrp_several_v.out + h5mkgrp_several_v.out.err + h5mkgrp_several_p.h5 + h5mkgrp_several_p.out + h5mkgrp_several_p.out.err + h5mkgrp_several_l.h5 + h5mkgrp_several_l.out + h5mkgrp_several_l.out.err + h5mkgrp_nested_p.h5 + h5mkgrp_nested_p.out + h5mkgrp_nested_p.out.err + h5mkgrp_nested_lp.h5 + h5mkgrp_nested_lp.out + h5mkgrp_nested_lp.out.err + h5mkgrp_nested_mult_p.h5 + h5mkgrp_nested_mult_p.out + h5mkgrp_nested_mult_p.out.err + h5mkgrp_nested_mult_lp.h5 + h5mkgrp_nested_mult_lp.out + h5mkgrp_nested_mult_lp.out.err + ) + set_tests_properties (H5MKGRP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5MKGRP-clearall-objects PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5MKGRP-clearall-objects") + endif () + + # Check that help & version is displayed properly + ADD_H5_CMP (h5mkgrp_help 0 "-h") + ADD_H5_CMP (h5mkgrp_version 0 "-V") + + # Create single group at root level + ADD_H5_TEST (h5mkgrp_single 0 "" single) + ADD_H5_TEST (h5mkgrp_single_v 0 "-v" single) + ADD_H5_TEST (h5mkgrp_single_p 0 "-p" single) + ADD_H5_TEST (h5mkgrp_single_l 0 "-l" latest) + + # Create several groups at root level + ADD_H5_TEST (h5mkgrp_several 0 "" one two) + ADD_H5_TEST (h5mkgrp_several_v 0 "-v" one two) + ADD_H5_TEST (h5mkgrp_several_p 0 "-p" one two) + ADD_H5_TEST (h5mkgrp_several_l 0 "-l" one two) + + # Create various nested groups + ADD_H5_TEST (h5mkgrp_nested_p 0 "-p" /one/two) + ADD_H5_TEST (h5mkgrp_nested_lp 0 "-lp" /one/two) + ADD_H5_TEST (h5mkgrp_nested_mult_p 0 "-p" /one/two /three/four) + ADD_H5_TEST (h5mkgrp_nested_mult_lp 0 "-lp" /one/two /three/four) diff --git a/tools/test/misc/CMakeTestsRepart.cmake b/tools/test/misc/CMakeTestsRepart.cmake new file mode 100644 index 0000000..a1549ec --- /dev/null +++ b/tools/test/misc/CMakeTestsRepart.cmake @@ -0,0 +1,85 @@ + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + # -------------------------------------------------------------------- + # Copy all the HDF5 files from the source directory into the test directory + # -------------------------------------------------------------------- + set (HDF5_REFERENCE_TEST_FILES + family_file00000.h5 + family_file00001.h5 + family_file00002.h5 + family_file00003.h5 + family_file00004.h5 + family_file00005.h5 + family_file00006.h5 + family_file00007.h5 + family_file00008.h5 + family_file00009.h5 + family_file00010.h5 + family_file00011.h5 + family_file00012.h5 + family_file00013.h5 + family_file00014.h5 + family_file00015.h5 + family_file00016.h5 + family_file00017.h5 + ) + + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5repart_files") + endforeach () + add_custom_target(h5repart_files ALL COMMENT "Copying files needed by h5repart tests" DEPENDS ${h5repart_files_list}) + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + + # Remove any output file left over from previous test run + add_test ( + NAME H5REPART-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + fst_family00000.h5 + scd_family00000.h5 + scd_family00001.h5 + scd_family00002.h5 + scd_family00003.h5 + family_to_sec2.h5 + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5REPART-clearall-objects PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5REPART-clearall-objects") + + # repartition family member size to 20,000 bytes. + add_test (NAME H5REPART-h5repart_20K COMMAND $ -m 20000 family_file%05d.h5 fst_family%05d.h5) + set_tests_properties (H5REPART-h5repart_20K PROPERTIES DEPENDS H5REPART-clearall-objects) + + # repartition family member size to 5 KB. + add_test (NAME H5REPART-h5repart_5K COMMAND $ -m 5k family_file%05d.h5 scd_family%05d.h5) + set_tests_properties (H5REPART-h5repart_5K PROPERTIES DEPENDS H5REPART-clearall-objects) + + # convert family file to sec2 file of 20,000 bytes + add_test (NAME H5REPART-h5repart_sec2 COMMAND $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5) + set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES DEPENDS H5REPART-clearall-objects) + + # test the output files repartitioned above. + add_test (NAME H5REPART-h5repart_test COMMAND $) + set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS "H5REPART-clearall-objects;H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_sec2") + + set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + h5repart_test + ) diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 0f20c35..f8b6a70 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -25,6 +25,103 @@ const char *FILENAME[] = { #define KB 1024U +#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5" +#define DSET "DSET" + +/*------------------------------------------------------------------------- + * Function: gen_cache_image_file + * + * Purpose: To create a file with cache image feature enabled. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; March 2017 + * + *------------------------------------------------------------------------- + */ +static int +gen_cache_image_file(const char *fname) +{ + hid_t fid = -1; /* File ID */ + hid_t did = -1, sid = -1; /* Dataset ID, dataspace ID */ + hid_t fapl = -1; /* File access property list */ + hid_t dcpl = -1; /* Dataset creation property list */ + hsize_t dims[2]; /* Dimension sizes */ + hsize_t chunks[2]; /* Chunked dimension sizes */ + int buf[50][100]; /* Buffer for data to write */ + int i, j; /* Local index variables */ + H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ + { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, + TRUE, FALSE, + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + + /* Create a copy of file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Enable latest format in fapl */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Enable metadata cache image in fapl */ + if(H5Pset_mdc_image_config(fapl, &cache_image_config) < 0) + goto error; + + /* Create the file */ + if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + + /* Create dataspace */ + dims[0] = 50; + dims[1] = 100; + if((sid = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + + /* Initialize buffer for writing to dataset */ + for(i = 0; i < 50; i++) + for(j = 0; j < 100; j++) + buf[i][j] = i * j; + + /* Set up to create a chunked dataset */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + chunks[0] = 5; + chunks[1] = 10; + if(H5Pset_chunk(dcpl, 2, chunks) < 0) + goto error; + if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + + /* Write to the dataset */ + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Closing */ + if(H5Dclose(did) < 0) + goto error; + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Pclose(fapl) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); + H5Pclose(fapl); + H5Pclose(dcpl); + } H5E_END_TRY; + return 1; +} + /*------------------------------------------------------------------------- * Function: main * @@ -60,6 +157,14 @@ main(void) char fname[512]; /* File name */ unsigned new_format; /* To use latest library format or not */ + /* Generate a file with cache image feature enabled */ + if(gen_cache_image_file(CACHE_IMAGE_FILE) < 0) + goto error; + + /* + * Generate files with invalid status_flags + */ + /* Create a copy of the file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl new file mode 100644 index 0000000..1e5150c --- /dev/null +++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl @@ -0,0 +1,15 @@ +usage: h5clear [OPTIONS] file_name + OPTIONS + -h, --help Print a usage message and exit + -V, --version Print version number and exit + -s, --status Clear the status_flags field in the file's superblock + -m, --image Remove the metadata cache image from the file + +Examples of use: + +h5clear -s file_name + Clear the status_flags field in the superblock of the HDF5 file . + +h5clear -m file_name + Remove the metadata cache image from the HDF5 file . +h5clear error: missing file name diff --git a/tools/test/misc/testfiles/h5clear_no_mdc_image.ddl b/tools/test/misc/testfiles/h5clear_no_mdc_image.ddl new file mode 100644 index 0000000..f5acd71 --- /dev/null +++ b/tools/test/misc/testfiles/h5clear_no_mdc_image.ddl @@ -0,0 +1 @@ +h5clear warning: No cache image in the file diff --git a/tools/test/misc/testfiles/h5clear_open_fail.ddl b/tools/test/misc/testfiles/h5clear_open_fail.ddl new file mode 100644 index 0000000..895ecd4 --- /dev/null +++ b/tools/test/misc/testfiles/h5clear_open_fail.ddl @@ -0,0 +1 @@ +h5clear error: h5tools_fopen diff --git a/tools/test/misc/testfiles/h5clear_usage.ddl b/tools/test/misc/testfiles/h5clear_usage.ddl new file mode 100644 index 0000000..a399ae7 --- /dev/null +++ b/tools/test/misc/testfiles/h5clear_usage.ddl @@ -0,0 +1,14 @@ +usage: h5clear [OPTIONS] file_name + OPTIONS + -h, --help Print a usage message and exit + -V, --version Print version number and exit + -s, --status Clear the status_flags field in the file's superblock + -m, --image Remove the metadata cache image from the file + +Examples of use: + +h5clear -s file_name + Clear the status_flags field in the superblock of the HDF5 file . + +h5clear -m file_name + Remove the metadata cache image from the HDF5 file . diff --git a/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 b/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 new file mode 100644 index 0000000..310134b Binary files /dev/null and b/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 differ diff --git a/tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 b/tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 new file mode 100644 index 0000000..571fd46 Binary files /dev/null and b/tools/test/misc/testfiles/orig_h5clear_sec2_v0.h5 differ diff --git a/tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 b/tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 new file mode 100644 index 0000000..92833e6 Binary files /dev/null and b/tools/test/misc/testfiles/orig_h5clear_sec2_v2.h5 differ diff --git a/tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 b/tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 new file mode 100644 index 0000000..9f1e6ce Binary files /dev/null and b/tools/test/misc/testfiles/orig_h5clear_sec2_v3.h5 differ diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in index a6836d4..71d5cad 100644 --- a/tools/test/misc/testh5clear.sh.in +++ b/tools/test/misc/testh5clear.sh.in @@ -20,11 +20,19 @@ TESTNAME=h5clear EXIT_SUCCESS=0 EXIT_FAILURE=1 -H5CLEAR=../../src/misc/h5clear -H5CLEAR_BIN=`pwd`/$H5CLEAR # The path of the tool binary +H5CLEAR=../../src/misc/h5clear # The tool name +H5CLEAR_BIN=`pwd`/$H5CLEAR # The path of the tool binary -OPENCHK=clear_open_chk # Try opening the test file -OPENCHK_BIN=`pwd`/$OPENCHK # The path to the binary +OPENCHK=clear_open_chk # Program to check whether the file can be opened +OPENCHK_BIN=`pwd`/$OPENCHK # The path to the binary + +RM='rm -rf' +CMP='cmp -s' +DIFF='diff -c' +CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' SUCCEED=0 FAIL=1 @@ -32,6 +40,83 @@ FAIL=1 nerrors=0 verbose=yes +# source dirs +SRC_TOOLS="$srcdir/../.." + +SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" +# testfiles source dirs for tools +SRC_H5CLEAR_TESTFILES="$SRC_TOOLS/test/misc/testfiles" + +TESTDIR=./testh5clear +test -d $TESTDIR || mkdir -p $TESTDIR + +###################################################################### +# test files +# -------------------------------------------------------------------- +# All the test files copy from source directory to test directory +# NOTE: Keep this framework to add/remove test files. +# Any test files from other tools can be used in this framework. +# This list are also used for checking exist. +# Comment '#' without space can be used. +# -------------------------------------------------------------------- + +# +# copy test files and expected output files from source dirs to test dir +# +COPY_TESTFILES=" +$SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl +$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.ddl +$SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl +$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.ddl +$SRC_H5CLEAR_TESTFILES/orig_h5clear_sec2_v0.h5 +$SRC_H5CLEAR_TESTFILES/orig_h5clear_sec2_v2.h5 +$SRC_H5CLEAR_TESTFILES/orig_h5clear_sec2_v3.h5 +$SRC_H5CLEAR_TESTFILES/mod_h5clear_mdc_image.h5 +" + +COPY_TESTFILES_TO_TESTDIR() +{ + # copy test files. Used -f to make sure get a new copy + for tstfile in $COPY_TESTFILES + do + # ignore '#' comment + echo $tstfile | tr -d ' ' | grep '^#' > /dev/null + RET=$? + if [ $RET -eq 1 ]; then + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi + fi + fi + done +} + +CLEAN_TESTFILES_AND_TESTDIR() +{ + # skip rm if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=$SRC_H5CLEAR_TESTFILES + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $RM $TESTDIR + fi +} + +# +# # Print a line-line message left justified in a field of 70 characters # beginning with the word "Testing". # @@ -40,68 +125,197 @@ TESTING() { echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' } +# $1 is the expected output +# $2 is the output from testing +COMPARE_OUT() { + if $CMP $1 $2; then + echo "PASSED" + else + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi +} + +# +# +# +# Run h5clear and verify the expected output +# $1: the test file name +# $2: option 1 passed to the tool +# $3: option 2 passed to the tool +# $4: the expected output +TOOLTEST_OUT() { + fname=$1 + option1=$2 + option2=$3 + expected=$4 + # Prepare expected and actual output + expect="$TESTDIR/$expected" + actual="$TESTDIR/`basename $expected .ddl`.out" + actual_err="$TESTDIR/`basename $expected .ddl`.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + + # Run test. + TESTING $H5CLEAR $option1 $option2 $fname + ( + $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname + ) >$actual 2>$actual_err + cp $actual $actual_sav + cp $actual_err $actual_err_sav + cat $actual_err >> $actual + + # Compare output + COMPARE_OUT $expect $actual + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + $RM $actual $actual_err $actual_sav $actual_err_sav + fi +} -# (1)Use "clear_open_chk" to check if the file open succeeds or fails # $1 is the filename to open -# $2 is the expected return from "clear_open_chk" -# (2) Use "h5clear" to clear the status_flags in the test file -# (3) Open the test file via "clear_open_chk" -TOOLTEST() { +# $2 is the expected return from the open/check program +OPEN_CHK() { fname=$1 expected=$2 - # (1) $OPENCHK_BIN $fname 2>/dev/null actual=$? if test $actual -ne $expected; then - echo "Unexpected return from $OPENCHK" - nerrors=`expr $nerrors + 1` + echo "Unexpected return from $OPENCHK" + nerrors=`expr $nerrors + 1` fi - # (2) - TESTING $H5CLEAR $1 +} + +# Run h5clear and verify the expected exit code +# $1 is the filename to open +# $2 is option 1 +# $3 is option 2 +# $4 is the expected exit code from the tool +TOOLTEST() { fname=$1 - # Use "h5clear" to clear the status_flags in the test file - $RUNSERIAL $H5CLEAR_BIN $fname - if test $? -ne $SUCCEED; then - echo ".....$H5CLEAR: should succeed" - nerrors=`expr $nerrors + 1` - else - # (3) Open the test file via "clear_open_chk" - $OPENCHK_BIN $fname - if test $? -ne $SUCCEED; then - echo "......$OPENCHK: should succeed" + option1=$2 + option2=$3 + ret_expected=$4 + # + TESTING $H5CLEAR $option1 $option2 $fname + fname=$1 + # h5clear $option1 $option2 $fname + $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname 2>/dev/null 1>/dev/null + if test $? -ne $ret_expected; then + echo "*FAILED*" nerrors=`expr $nerrors + 1` else echo "PASSED" fi - fi } ############################################################################## ############################################################################## -### T H E T E S T S ### +### T H E T E S T S ### ############################################################################## ############################################################################## +# prepare for testing +COPY_TESTFILES_TO_TESTDIR +# +# +# +# The following are tests to verify the expected output from h5clear +# "h5clear -h" +# "h5clear" (no options, no file) +# "h5clear junk.h5" (no options, nonexisting file) +# "h5clear orig_h5clear_sec2_v3.h5" (no options, existing file) +# "h5clear -m" (valid 1 option, no file) +# "h5clear -s junk.h5" (valid 1 option, nonexisting file) +# "h5clear -m -s junk.h5" (valid 2 options, no file) +# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file) +# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image) +# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image) +TOOLTEST_OUT "" -h "" h5clear_usage.ddl +TOOLTEST_OUT "" "" "" h5clear_usage.ddl +TOOLTEST_OUT junk.h5 "" "" h5clear_usage.ddl +TOOLTEST_OUT $TESTDIR/orig_h5clear_sec2_v3.h5 "" "" h5clear_usage.ddl +TOOLTEST_OUT "" -m "" h5clear_missing_file.ddl +TOOLTEST_OUT junk.h5 -s "" h5clear_open_fail.ddl +TOOLTEST_OUT "" -m -s h5clear_missing_file.ddl +TOOLTEST_OUT junk.h5 -m -s h5clear_open_fail.ddl +TOOLTEST_OUT $TESTDIR/orig_h5clear_sec2_v2.h5 -m "" h5clear_no_mdc_image.ddl +TOOLTEST_OUT $TESTDIR/orig_h5clear_sec2_v0.h5 -s -m h5clear_no_mdc_image.ddl # -# Initial file open fails -# After "h5clear" the file, the subsequent file open succeeds -TOOLTEST h5clear_sec2_v3.h5 $FAIL # -TOOLTEST h5clear_log_v3.h5 $FAIL # -TOOLTEST latest_h5clear_sec2_v3.h5 $FAIL +# The following are tests to verify the expected exit code from h5clear: +# "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code) +# "h5clear --vers" (valid option, version #, succeed exit code) +# "h5clear -k" (invalid 1 option, no file, fail exit code) +# "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code) +# "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code) +# "h5clear -m -k" (valid/invalid 2 options, nofile, fail exit code) +# "h5clear -l -m" (invalid/valid 2 options, nofile, fail exit code) +# "h5clear -m -k junk.h5" (valid/invalid 2 options, nonexisting file, fail exit code) +# "h5clear -l -m junk.h5" (invalid/valid 2 options, nonexisting file, fail exit code) +# "h5clear -m -k h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code) +# "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code) +TOOLTEST h5clear_mdc_image.h5 -m "" $SUCCEED +TOOLTEST "" --vers "" $SUCCEED +TOOLTEST "" -k "" $FAIL +TOOLTEST junk.h5 -k "" $FAIL +TOOLTEST h5clear_sec2_v2.h5 -l "" $FAIL +TOOLTEST "" -m -k $FAIL +TOOLTEST "" -l -m $FAIL +TOOLTEST junk.h5 -m -l $FAIL +TOOLTEST junk.h5 -l -m $FAIL +TOOLTEST h5clear_sec2_v0.h5 -m -l $FAIL +TOOLTEST h5clear_sec2_v0.h5 -l -m $FAIL # -TOOLTEST latest_h5clear_log_v3.h5 $FAIL # # -# File open succeeds because the library does not check status_flags for file with < v3 superblock -TOOLTEST h5clear_sec2_v0.h5 $SUCCEED -TOOLTEST h5clear_sec2_v2.h5 $SUCCEED +# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear: +TOOLTEST_OUT $TESTDIR/mod_h5clear_mdc_image.h5 -m "" h5clear_no_mdc_image.ddl +TOOLTEST_OUT $TESTDIR/mod_h5clear_mdc_image.h5 -s -m h5clear_no_mdc_image.ddl +# +# +# +# The following are tests to verify the status_flags field is cleared properly: +OPEN_CHK h5clear_sec2_v3.h5 $FAIL +TOOLTEST h5clear_sec2_v3.h5 -s "" $SUCCEED +OPEN_CHK h5clear_sec2_v3.h5 $SUCCEED +# +OPEN_CHK h5clear_log_v3.h5 $FAIL +TOOLTEST h5clear_log_v3.h5 -s "" $SUCCEED +OPEN_CHK h5clear_log_v3.h5 $SUCCEED +# +OPEN_CHK latest_h5clear_sec2_v3.h5 $FAIL +TOOLTEST latest_h5clear_sec2_v3.h5 -s "" $SUCCEED +OPEN_CHK latest_h5clear_sec2_v3.h5 $SUCCEED +# +OPEN_CHK latest_h5clear_log_v3.h5 $FAIL +TOOLTEST latest_h5clear_log_v3.h5 -s "" $SUCCEED +OPEN_CHK latest_h5clear_log_v3.h5 $SUCCEED +# +# File open succeeds for the following 2 test files because the +# library does not check status_flags for files with < v3 superblock: +OPEN_CHK h5clear_sec2_v0.h5 $SUCCEED +TOOLTEST h5clear_sec2_v0.h5 -s "" $SUCCEED +OPEN_CHK h5clear_sec2_v0.h5 $SUCCEED +# +OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED +TOOLTEST h5clear_sec2_v2.h5 -s "" $SUCCEED +OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED +# +# # # Clean up test files if test -z "$HDF5_NOCLEANUP"; then rm -f h5clear_*.h5 latest_h5clear*.h5 fi +# +# +# +# Clean up temporary files/directories +CLEAN_TESTFILES_AND_TESTDIR if test $nerrors -eq 0 ; then echo "All $TESTNAME tests passed." diff --git a/tools/test/perform/sio_engine.c b/tools/test/perform/sio_engine.c index abf1fa6..2a5efb6 100644 --- a/tools/test/perform/sio_engine.c +++ b/tools/test/perform/sio_engine.c @@ -1064,6 +1064,7 @@ done: do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) { int ret_code = SUCCESS; + hid_t fcpl; switch (param->io_type) { case POSIXIO: @@ -1088,9 +1089,17 @@ do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags) GOTOERROR(FAIL); } + fcpl = H5Pcreate(H5P_FILE_CREATE); + if(param->page_size) { + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1); + H5Pset_file_space_page_size(fcpl, param->page_size); + if(param->page_buffer_size) + H5Pset_page_buffer_size(fapl, param->page_buffer_size, 0, 0); + } + /* create the parallel file */ if (flags & (SIO_CREATE | SIO_WRITE)) { - fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); } else { fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl); } diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c index 5bae832..2201b99 100644 --- a/tools/test/perform/sio_perf.c +++ b/tools/test/perform/sio_perf.c @@ -100,7 +100,7 @@ static const char *progname = "h5perf_serial"; * It seems that only the options that accept additional information * such as dataset size (-e) require the colon next to it. */ -static const char *s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; +static const char *s_opts = "a:A:B:b:c:Cd:D:e:F:G:ghi:Imno:p:P:r:stT:v:wx:X:"; static struct long_options l_opts[] = { { "align", require_arg, 'a' }, { "alig", require_arg, 'a' }, @@ -292,7 +292,8 @@ struct options { int h5_extendable; /* Perform the write tests only */ int verify; /* Verify data correctness */ vfdtype vfd; /* File driver */ - + size_t page_buffer_size; + size_t page_size; }; typedef struct _minmax { @@ -401,6 +402,8 @@ run_test_loop(struct options *opts) parms.h5_write_only = opts->h5_write_only; parms.verify = opts->verify; parms.vfd = opts->vfd; + parms.page_buffer_size = opts->page_buffer_size; + parms.page_size = opts->page_size; /* load multidimensional options */ parms.num_bytes = 1; @@ -865,6 +868,16 @@ report_parameters(struct options *opts) recover_size_and_print((long long)opts->buf_size[i], " "); HDfprintf(output, "\n"); + if(opts->page_size) { + HDfprintf(output, "Page Aggregation Enabled. Page size = %ld\n", opts->page_size); + if(opts->page_buffer_size) + HDfprintf(output, "Page Buffering Enabled. Page Buffer size = %ld\n", opts->page_buffer_size); + else + HDfprintf(output, "Page Buffering Disabled\n"); + } + else + HDfprintf(output, "Page Aggregation Disabled\n"); + HDfprintf(output, "Dimension access order="); for (i=0; iorder[i], " "); @@ -941,6 +954,9 @@ parse_command_line(int argc, char *argv[]) cl_opts = (struct options *)HDmalloc(sizeof(struct options)); + cl_opts->page_buffer_size = 0; + cl_opts->page_size = 0; + cl_opts->output_file = NULL; cl_opts->io_types = 0; /* will set default after parsing options */ cl_opts->num_iters = 1; @@ -975,6 +991,12 @@ parse_command_line(int argc, char *argv[]) case 'a': cl_opts->h5_alignment = parse_size_directive(opt_arg); break; + case 'G': + cl_opts->page_size = parse_size_directive(opt_arg); + break; + case 'b': + cl_opts->page_buffer_size = parse_size_directive(opt_arg); + break; case 'A': { const char *end = opt_arg; diff --git a/tools/test/perform/sio_perf.h b/tools/test/perform/sio_perf.h index 7a7d708..5d9358d 100644 --- a/tools/test/perform/sio_perf.h +++ b/tools/test/perform/sio_perf.h @@ -67,6 +67,8 @@ typedef struct parameters_ { int h5_extendable; /* Make HDF5 dataset chunked */ int h5_write_only; /* Perform the write tests only */ int verify; /* Verify data correctness */ + size_t page_size; + size_t page_buffer_size; } parameters; typedef struct results_ { diff --git a/tools/testfiles/file_space.ddl b/tools/testfiles/file_space.ddl index bed5349..6b8aa47 100644 --- a/tools/testfiles/file_space.ddl +++ b/tools/testfiles/file_space.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_AGGR_VFD - FREE_SPACE_THRESHOLD 10 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_NONE + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 8192 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/testfiles/file_space.h5 b/tools/testfiles/file_space.h5 index 425d0c2..d9e2890 100644 Binary files a/tools/testfiles/file_space.h5 and b/tools/testfiles/file_space.h5 differ diff --git a/tools/testfiles/tboot1.ddl b/tools/testfiles/tboot1.ddl index 4758948..73ae4e5 100644 --- a/tools/testfiles/tboot1.ddl +++ b/tools/testfiles/tboot1.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/testfiles/tboot2.ddl b/tools/testfiles/tboot2.ddl index d83b92b..504a634 100644 --- a/tools/testfiles/tboot2.ddl +++ b/tools/testfiles/tboot2.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/testfiles/tboot2A.ddl b/tools/testfiles/tboot2A.ddl index d83b92b..504a634 100644 --- a/tools/testfiles/tboot2A.ddl +++ b/tools/testfiles/tboot2A.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/testfiles/tboot2B.ddl b/tools/testfiles/tboot2B.ddl index d83b92b..504a634 100644 --- a/tools/testfiles/tboot2B.ddl +++ b/tools/testfiles/tboot2B.ddl @@ -9,8 +9,10 @@ SUPER_BLOCK { BTREE_RANK 16 BTREE_LEAF 4 ISTORE_K 32 - FILE_SPACE_STRATEGY H5F_FILE_SPACE_ALL - FREE_SPACE_THRESHOLD 1 + FILE_SPACE_STRATEGY H5F_FSPACE_STRATEGY_FSM_AGGR + FREE_SPACE_PERSIST FALSE + FREE_SPACE_SECTION_THRESHOLD 1 + FILE_SPACE_PAGE_SIZE 4096 USER_BLOCK { USERBLOCK_SIZE 0 } diff --git a/tools/testfiles/tdset_idx.ddl b/tools/testfiles/tdset_idx.ddl deleted file mode 100644 index 65d9f44..0000000 --- a/tools/testfiles/tdset_idx.ddl +++ /dev/null @@ -1,61 +0,0 @@ -############################# -Expected output for 'h5dump -p -H tdset_idx.h5' -############################# -HDF5 "tdset_idx.h5" { -GROUP "/" { - DATASET "dset_btree" { - DATATYPE H5T_STD_I32LE - DATASPACE SIMPLE { ( 20, 10 ) / ( 200, 100 ) } - STORAGE_LAYOUT { - CHUNKED ( 5, 5 ) - SIZE 800 - } - FILTERS { - NONE - } - FILLVALUE { - FILL_TIME H5D_FILL_TIME_IFSET - VALUE 0 - } - ALLOCATION_TIME { - H5D_ALLOC_TIME_INCR - } - } - DATASET "dset_filter" { - DATATYPE H5T_STD_I32LE - DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } - STORAGE_LAYOUT { - CHUNKED ( 5, 5 ) - SIZE 200 (4.000:1 COMPRESSION) - } - FILTERS { - COMPRESSION DEFLATE { LEVEL 9 } - } - FILLVALUE { - FILL_TIME H5D_FILL_TIME_IFSET - VALUE 0 - } - ALLOCATION_TIME { - H5D_ALLOC_TIME_INCR - } - } - DATASET "dset_fixed" { - DATATYPE H5T_STD_I32LE - DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } - STORAGE_LAYOUT { - CHUNKED ( 5, 5 ) - SIZE 800 - } - FILTERS { - NONE - } - FILLVALUE { - FILL_TIME H5D_FILL_TIME_IFSET - VALUE 0 - } - ALLOCATION_TIME { - H5D_ALLOC_TIME_INCR - } - } -} -} -- cgit v0.12 From 2687321987f6ded4f85f138f8572abe96ce90264 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 14 Mar 2017 12:14:44 -0500 Subject: HDFFV-10138 Merge app framework to examples --- CMakeInstallation.cmake | 24 ++- MANIFEST | 2 + config/cmake/CTestScript.cmake | 152 ++++++++++++++++ config/cmake/HDF5_Examples.cmake.in | 197 +++++---------------- config/cmake/HDF5_Examples_options.cmake | 48 +++++ config/cmake/scripts/CTestScript.cmake | 6 +- config/cmake/scripts/HDF5config.cmake | 292 +++++++++++++++---------------- config/cmake/scripts/HDF5options.cmake | 2 +- 8 files changed, 409 insertions(+), 314 deletions(-) create mode 100755 config/cmake/CTestScript.cmake create mode 100755 config/cmake/HDF5_Examples_options.cmake diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 3f0f7ca..37f3f70 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -174,13 +174,25 @@ if (HDF5_PACK_EXAMPLES) USE_SOURCE_PERMISSIONS COMPONENT hdfdocuments ) - install ( - FILES - ${HDF5_SOURCE_DIR}/release_docs/USING_CMake_Examples.txt - DESTINATION ${HDF5_INSTALL_DATA_DIR} - COMPONENT hdfdocuments - ) endif () + install ( + FILES + ${HDF5_SOURCE_DIR}/release_docs/USING_CMake_Examples.txt + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) + install ( + FILES + ${HDF_RESOURCES_DIR}/CTestScript.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) + install ( + FILES + ${HDF_RESOURCES_DIR}/HDF5_Examples_options.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR} + COMPONENT hdfdocuments + ) endif () #----------------------------------------------------------------------------- diff --git a/MANIFEST b/MANIFEST index 95c9bbd..e011a2a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3129,6 +3129,8 @@ ./tools/test/perform/CMakeTests.cmake # CMake-specific User Scripts +./config/cmake/CTestScript.cmake +./config/cmake/HDF5_Examples_options.cmake ./config/cmake/scripts/CTestScript.cmake ./config/cmake/scripts/HDF5config.cmake ./config/cmake/scripts/HDF5options.cmake diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake new file mode 100755 index 0000000..d53d7a4 --- /dev/null +++ b/config/cmake/CTestScript.cmake @@ -0,0 +1,152 @@ +cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) +######################################################## +# For any comments please contact cdashhelp@hdfgroup.org +# +######################################################## +# ----------------------------------------------------------- +# -- Get environment +# ----------------------------------------------------------- +if (NOT SITE_OS_NAME) + ## machine name not provided - attempt to discover with uname + ## -- set hostname + ## -------------------------- + find_program (HOSTNAME_CMD NAMES hostname) + exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) + set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") + find_program (UNAME NAMES uname) + macro (getuname name flag) + exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") + endmacro () + + getuname (osname -s) + getuname (osrel -r) + getuname (cpu -m) + message (STATUS "Dashboard script uname output: ${osname}-${osrel}-${cpu}\n") + + set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") + if (SITE_BUILDNAME_SUFFIX) + set (CTEST_BUILD_NAME "${SITE_BUILDNAME_SUFFIX}-${CTEST_BUILD_NAME}") + endif () + set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS}") +else () + ## machine name provided + ## -------------------------- + if (CMAKE_HOST_UNIX) + set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") + else () + set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") + endif () + if (SITE_BUILDNAME_SUFFIX) + set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}") + endif () + set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") +endif () + +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if (APPLE) + # Compiler choice + execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set (ENV{CC} "${XCODE_CC}") + set (ENV{CXX} "${XCODE_CXX}") + + if (NOT NO_MAC_FORTRAN) + # Shared fortran is not supported, build static + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + else () + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") + endif () + + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif () + +#----------------------------------------------------------------------------- +set (NEED_REPOSITORY_CHECKOUT 0) +set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +if (CTEST_USE_TAR_SOURCE) + ## Uncompress source if tar or zip file provided + ## -------------------------- + if (WIN32) + message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip]") + execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) + else () + message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar]") + execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) + endif () + + if (NOT rv EQUAL 0) + message (STATUS "extracting... [error-(${rv}) clean up]") + file (REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") + message (FATAL_ERROR "error: extract of ${CTEST_USE_TAR_SOURCE} failed") + endif () +endif () + +#----------------------------------------------------------------------------- +## Clear the build directory +## -------------------------- +set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) +if (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY}) +else () + file (MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +endif () + +# Use multiple CPU cores to build +include (ProcessorCount) +ProcessorCount (N) +if (NOT N EQUAL 0) + if (NOT WIN32) + set (CTEST_BUILD_FLAGS -j${N}) + endif () + set (ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +endif () + +#----------------------------------------------------------------------------- +# Initialize the CTEST commands +#------------------------------ +set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" +) +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +## -- set output to english +set ($ENV{LC_MESSAGES} "en_EN") + +#----------------------------------------------------------------------------- + configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) + ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") +#----------------------------------------------------------------------------- + ## NORMAL process + ## -- LOCAL_SUBMIT reports to CDash server + ## -------------------------- + ctest_start (Experimental) + ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + if (LOCAL_SUBMIT) + ctest_submit (PARTS Configure Notes) + endif () + if (${res} LESS 0 OR ${res} GREATER 0) + file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Configure: ${res}\n") + endif () + + ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND RETURN_VALUE res NUMBER_ERRORS errval) + if (LOCAL_SUBMIT) + ctest_submit (PARTS Build) + endif () + if (${res} LESS 0 OR ${res} GREATER 0 OR ${errval} GREATER 0) + file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed ${errval} Build: ${res}\n") + endif () + + ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) + if (LOCAL_SUBMIT) + ctest_submit (PARTS Test) + endif() + if (${res} LESS 0 OR ${res} GREATER 0) + file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Tests: ${res}\n") + endif () + if (${res} LESS 0 OR ${res} GREATER 0) + message (FATAL_ERROR "tests FAILED") + endif () +#----------------------------------------------------------------------------- diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in index eadff5f..04f72a0 100644 --- a/config/cmake/HDF5_Examples.cmake.in +++ b/config/cmake/HDF5_Examples.cmake.in @@ -5,102 +5,75 @@ cmake_minimum_required(VERSION 3.2.2 FATAL_ERROR) # ctest -S HDF5_Examples.cmake,OPTION=VALUE -C Release -V -O test.log ############################################################################################################### -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) +set (CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set (CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) # handle input parameters to script. #INSTALLDIR - HDF5 root folder #CTEST_CONFIGURATION_TYPE - Release, Debug, RelWithDebInfo -#CTEST_SOURCE_NAME - name of source folder; HDF4Examples -#STATIC_ONLY - Default is YES -#FORTRAN_LIBRARIES - Default is NO -#JAVA_LIBRARIES - Default is NO -##NO_MAC_FORTRAN - set to TRUE to allow shared libs on a Mac) +#CTEST_SOURCE_NAME - name of source folder; HDF5Examples if (DEFINED CTEST_SCRIPT_ARG) - # transform ctest script arguments of the form - # script.ctest,var1=value1,var2=value2 - # to variables with the respective names set to the respective values - string (REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") - foreach (current_var ${script_args}) - if ("${current_var}" MATCHES "^([^=]+)=(.+)$") - set ("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") - endif () - endforeach () -endif () -if (NOT DEFINED INSTALLDIR) - set (INSTALLDIR "@CMAKE_INSTALL_PREFIX@") + # transform ctest script arguments of the form + # script.ctest,var1=value1,var2=value2 + # to variables with the respective names set to the respective values + string (REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") + foreach (current_var ${script_args}) + if ("${current_var}" MATCHES "^([^=]+)=(.+)$") + set ("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + endif () + endforeach () endif () + +################################################################### +### Following Line is one of [Release, RelWithDebInfo, Debug] ##### +set (CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") if (NOT DEFINED CTEST_CONFIGURATION_TYPE) - set (CTEST_CONFIGURATION_TYPE "Release") -endif () -if (NOT DEFINED CTEST_SOURCE_NAME) - set (CTEST_SOURCE_NAME "HDF5Examples") + set (CTEST_CONFIGURATION_TYPE "Release") endif () -if (NOT DEFINED STATIC_ONLY) - set (STATICONLYLIBRARIES "YES") -else () - set (STATICONLYLIBRARIES "NO") -endif () -if (NOT DEFINED FORTRAN_LIBRARIES) - set (FORTRANLIBRARIES "NO") -else () - set (FORTRANLIBRARIES "YES") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCTEST_CONFIGURATION_TYPE:STRING=${CTEST_CONFIGURATION_TYPE}") +################################################################## + +if (NOT DEFINED INSTALLDIR) + set (INSTALLDIR "@CMAKE_INSTALL_PREFIX@") endif () -if (NOT DEFINED JAVA_LIBRARIES) - set (JAVALIBRARIES "NO") -else () - set (JAVALIBRARIES "YES") + +if (NOT DEFINED CTEST_SOURCE_NAME) + set (CTEST_SOURCE_NAME "HDF5Examples") endif () + if (NOT DEFINED HDF_LOCAL) - set (CDASH_LOCAL "NO") + set (CDASH_LOCAL "NO") else () - set (CDASH_LOCAL "YES") + set (CDASH_LOCAL "YES") endif () if(NOT DEFINED CTEST_SITE) - set (CTEST_SITE "local") + set (CTEST_SITE "local") endif () -if(NOT DEFINED CTEST_BUILD_NAME) - set (CTEST_BUILD_NAME "examples") +if (NOT DEFINED CTEST_BUILD_NAME) + set (CTEST_BUILD_NAME "examples") endif () set (BUILD_OPTIONS "${BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") #TAR_SOURCE - name of tarfile #if (NOT DEFINED TAR_SOURCE) -# set (CTEST_USE_TAR_SOURCE "HDF5Examples-1.10.1-Source") +# set (CTEST_USE_TAR_SOURCE "HDF5Examples-1.10.5-Source") #endif () ############################################################################################################### -# Adjust the following SET Commands as needed -############################################################################################################### if (WIN32) - if (${STATICONLYLIBRARIES}) - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") - endif () + set (SITE_OS_NAME "Windows") set (ENV{HDF5_DIR} "${INSTALLDIR}/cmake") set (CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}\\build) set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") else () - if (${STATICONLYLIBRARIES}) - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") - endif () set (ENV{HDF5_DIR} "${INSTALLDIR}/share/cmake") set (ENV{LD_LIBRARY_PATH} "${INSTALLDIR}/lib") set (CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}/build) set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") endif () -if (${FORTRANLIBRARIES}) - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") -else () - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=OFF") -endif () -if(${JAVALIBRARIES}) - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_JAVA:BOOL=ON") -else () - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_JAVA:BOOL=OFF") -endif () -if(${CDASH_LOCAL}) +if (${CDASH_LOCAL}) set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCDASH_LOCAL:BOOL=ON") endif () set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF5_PACKAGE_NAME:STRING=@HDF5_PACKAGE@@HDF_PACKAGE_EXT@") @@ -110,102 +83,10 @@ set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF5_PACKAGE_NAME:STRING=@HDF5_PACKAGE@@H # ############################################################################################################### -#----------------------------------------------------------------------------- -# MAC machines need special option -#----------------------------------------------------------------------------- -if (APPLE) - # Compiler choice - execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) - set (ENV{CC} "${XCODE_CC}") - set (ENV{CXX} "${XCODE_CXX}") - if (NOT NO_MAC_FORTRAN) - # Shared fortran is not supported, build static - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") - else () - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=OFF") - endif () - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") -endif () - -#----------------------------------------------------------------------------- -set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") -## -------------------------- -if (CTEST_USE_TAR_SOURCE) - ## Uncompress source if tar or zip file provided - ## -------------------------- - if (WIN32) - message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip]") - execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) - else () - message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") - execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) - endif () - - if (NOT rv EQUAL 0) - message (STATUS "extracting... [error-(${rv}) clean up]") - file (REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") - message (FATAL_ERROR "error: extract of ${CTEST_SOURCE_NAME} failed") - endif () -endif() - -#----------------------------------------------------------------------------- -## Clear the build directory -## -------------------------- -set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) -if (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") - ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY}) +if (WIN32) + include (${CTEST_SCRIPT_DIRECTORY}\\HDF5_Examples_options.cmake) + include (${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) else () - file (MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") -endif () - -# Use multiple CPU cores to build -include (ProcessorCount) -ProcessorCount (N) -if (NOT N EQUAL 0) - if (NOT WIN32) - set (CTEST_BUILD_FLAGS -j${N}) - endif () - set (ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) -endif () -set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" -) - -#----------------------------------------------------------------------------- -## -- set output to english -set ($ENV{LC_MESSAGES} "en_EN") - -#----------------------------------------------------------------------------- -configure_file (${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) -ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") -## NORMAL process -## -------------------------- -ctest_start (Experimental) -ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -if (${res} LESS 0 OR ${res} GREATER 0) - file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Configure: ${res}\n") -endif () -if (LOCAL_SUBMIT) - ctest_submit (PARTS Configure Notes) -endif () -ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND APPEND RETURN_VALUE res NUMBER_ERRORS errval) -if (${res} LESS 0 OR ${res} GREATER 0 OR ${errval} GREATER 0) - file(APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed ${errval} Build: ${res}\n") -endif () -if (LOCAL_SUBMIT) - ctest_submit (PARTS Build) -endif () -ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) -if (${res} LESS 0 OR ${res} GREATER 0) - file(APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Tests: ${res}\n") -endif () -if (LOCAL_SUBMIT) - ctest_submit (PARTS Test) -endif () -if (${res} LESS 0 OR ${res} GREATER 0) - message (FATAL_ERROR "tests FAILED") + include (${CTEST_SCRIPT_DIRECTORY}/HDF_Examples_options.cmake) + include (${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) endif () -#----------------------------------------------------------------------------- -############################################################################################################## -message (STATUS "DONE") diff --git a/config/cmake/HDF5_Examples_options.cmake b/config/cmake/HDF5_Examples_options.cmake new file mode 100755 index 0000000..a8f0c8e --- /dev/null +++ b/config/cmake/HDF5_Examples_options.cmake @@ -0,0 +1,48 @@ +############################################################################################# +#### Change default configuration of options in config/cmake/cacheinit.cmake file ### +#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### +#### DEFAULT: ### +#### BUILD_SHARED_LIBS:BOOL=OFF ### +#### HDF_BUILD_C:BOOL=ON ### +#### HDF_BUILD_CXX:BOOL=OFF ### +#### HDF_BUILD_FORTRAN:BOOL=OFF ### +#### HDF_BUILD_JAVA:BOOL=OFF ### +#### BUILD_TESTING:BOOL=OFF ### +#### HDF_ENABLE_PARALLEL:BOOL=OFF ### +#### HDF_ENABLE_THREADSAFE:BOOL=OFF ### +############################################################################################# + +### uncomment/comment and change the following lines for other configuration options +### build with shared libraries +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=ON") + +############################################################################################# +#### languages #### +### disable C builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_C:BOOL=OFF") + +### enable C++ builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_CXX:BOOL=ON") + +### enable Fortran builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") + +### enable JAVA builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_JAVA:BOOL=ON") + +############################################################################################# +### enable parallel program builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_ENABLE_PARALLEL:BOOL=ON") + + +############################################################################################# +### enable threadsafe program builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_ENABLE_THREADSAFE:BOOL=ON") + + +############################################################################################# +### enable test program builds, requires reference files in testfiles subdirectory +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=ON") +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCOMPARE_TESTING:BOOL=ON") + +############################################################################################# diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index dca9631..d24eb44 100755 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -33,12 +33,12 @@ else () ## machine name provided ## -------------------------- if (CMAKE_HOST_UNIX) - set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") + set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") else () - set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") + set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") endif () if (SITE_BUILDNAME_SUFFIX) - set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}") + set (CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}") endif () set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") endif () diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index 55fecfb..f9dada9 100755 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -4,7 +4,7 @@ ### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201264 -C Release -VV -O hdf5.log ### ############################################################################################# -cmake_minimum_required(VERSION 3.2.2 FATAL_ERROR) +cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) ############################################################################ # Usage: # ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log @@ -27,8 +27,8 @@ cmake_minimum_required(VERSION 3.2.2 FATAL_ERROR) # NO_MAC_FORTRAN - Yes to be SHARED on a Mac ############################################################################## -set(CTEST_SOURCE_VERSION 1.10.1) -set(CTEST_SOURCE_VERSEXT "") +set (CTEST_SOURCE_VERSION 1.10.1) +set (CTEST_SOURCE_VERSEXT "") ############################################################################## # handle input parameters to script. @@ -40,139 +40,139 @@ set(CTEST_SOURCE_VERSEXT "") #FORTRAN_LIBRARIES - Default is NO #JAVA_LIBRARIES - Default is NO #NO_MAC_FORTRAN - set to TRUE to allow shared libs on a Mac -if(DEFINED CTEST_SCRIPT_ARG) +if (DEFINED CTEST_SCRIPT_ARG) # transform ctest script arguments of the form # script.ctest,var1=value1,var2=value2 # to variables with the respective names set to the respective values - string(REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") - foreach(current_var ${script_args}) + string (REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") + foreach (current_var ${script_args}) if ("${current_var}" MATCHES "^([^=]+)=(.+)$") - set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + set ("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") endif () endforeach () endif () # build generator must be defined -if(NOT DEFINED BUILD_GENERATOR) - message(FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") +if (NOT DEFINED BUILD_GENERATOR) + message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") else () - if(${BUILD_GENERATOR} STREQUAL "Unix") - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") - elseif(${BUILD_GENERATOR} STREQUAL "VS2015") - set(CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") - elseif(${BUILD_GENERATOR} STREQUAL "VS201564") - set(CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") - elseif(${BUILD_GENERATOR} STREQUAL "VS2013") - set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") - elseif(${BUILD_GENERATOR} STREQUAL "VS201364") - set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") - elseif(${BUILD_GENERATOR} STREQUAL "VS2012") - set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") - elseif(${BUILD_GENERATOR} STREQUAL "VS201264") - set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") + if (${BUILD_GENERATOR} STREQUAL "Unix") + set (CTEST_CMAKE_GENERATOR "Unix Makefiles") + elseif (${BUILD_GENERATOR} STREQUAL "VS2015") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") + elseif (${BUILD_GENERATOR} STREQUAL "VS201564") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") + elseif (${BUILD_GENERATOR} STREQUAL "VS2013") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") + elseif (${BUILD_GENERATOR} STREQUAL "VS201364") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") + elseif (${BUILD_GENERATOR} STREQUAL "VS2012") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") + elseif (${BUILD_GENERATOR} STREQUAL "VS201264") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") else () - message(FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") + message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") endif () endif () ################################################################### ### Following Line is one of [Release, RelWithDebInfo, Debug] ##### -set(CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") +set (CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") ################################################################### -if(NOT DEFINED INSTALLDIR) - if(WIN32) - set(INSTALLDIR "C:/Program Files/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") +if (NOT DEFINED INSTALLDIR) + if (WIN32) + set (INSTALLDIR "C:/Program Files/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") else () - set(INSTALLDIR "${CTEST_SCRIPT_DIRECTORY}/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") + set (INSTALLDIR "${CTEST_SCRIPT_DIRECTORY}/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") endif () endif () -if(NOT DEFINED CTEST_CONFIGURATION_TYPE) - set(CTEST_CONFIGURATION_TYPE "Release") +if (NOT DEFINED CTEST_CONFIGURATION_TYPE) + set (CTEST_CONFIGURATION_TYPE "Release") endif () -if(NOT DEFINED CTEST_SOURCE_NAME) - set(CTEST_SOURCE_NAME "hdf5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") +if (NOT DEFINED CTEST_SOURCE_NAME) + set (CTEST_SOURCE_NAME "hdf5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") endif () -if(NOT DEFINED STATIC_ONLY) - set(STATICONLYLIBRARIES "YES") +if (NOT DEFINED STATIC_ONLY) + set (STATICONLYLIBRARIES "YES") else () - set(STATICONLYLIBRARIES "NO") + set (STATICONLYLIBRARIES "NO") endif () -if(NOT DEFINED FORTRAN_LIBRARIES) - set(FORTRANLIBRARIES "NO") +if (NOT DEFINED FORTRAN_LIBRARIES) + set (FORTRANLIBRARIES "NO") else () - set(FORTRANLIBRARIES "YES") + set(FORTRANLIBRARIES "YES") endif () -if(NOT DEFINED JAVA_LIBRARIES) - set(JAVALIBRARIES "NO") +if (NOT DEFINED JAVA_LIBRARIES) + set (JAVALIBRARIES "NO") else () - set(JAVALIBRARIES "YES") + set (JAVALIBRARIES "YES") endif () -set(CTEST_BINARY_NAME "build") -set(CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") -if(WIN32) - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") +set (CTEST_BINARY_NAME "build") +set (CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") +if (WIN32) + set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") + set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") else () - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") + set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") + set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") endif () ################################################################### ######### Following describes compiler ############ -if(WIN32) - set(SITE_OS_NAME "Windows") - set(SITE_OS_VERSION "WIN7") - if(${BUILD_GENERATOR} STREQUAL "VS201564") - set(SITE_OS_BITS "64") - set(SITE_COMPILER_NAME "vs2015") - set(SITE_COMPILER_VERSION "14") - elseif(${BUILD_GENERATOR} STREQUAL "VS2015") - set(SITE_OS_BITS "32") - set(SITE_COMPILER_NAME "vs2015") - set(SITE_COMPILER_VERSION "14") - elseif(${BUILD_GENERATOR} STREQUAL "VS201364") - set(SITE_OS_BITS "64") - set(SITE_COMPILER_NAME "vs2013") - set(SITE_COMPILER_VERSION "12") - elseif(${BUILD_GENERATOR} STREQUAL "VS2013") - set(SITE_OS_BITS "32") - set(SITE_COMPILER_NAME "vs2013") - set(SITE_COMPILER_VERSION "12") - elseif(${BUILD_GENERATOR} STREQUAL "VS201264") - set(SITE_OS_BITS "64") - set(SITE_COMPILER_NAME "vs2012") - set(SITE_COMPILER_VERSION "11") - elseif(${BUILD_GENERATOR} STREQUAL "VS2012") - set(SITE_OS_BITS "32") - set(SITE_COMPILER_NAME "vs2012") - set(SITE_COMPILER_VERSION "11") +if (WIN32) + set (SITE_OS_NAME "Windows") + set (SITE_OS_VERSION "WIN7") + if (${BUILD_GENERATOR} STREQUAL "VS201564") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS2015") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS201364") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS2013") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS201264") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2012") + set (SITE_COMPILER_VERSION "11") + elseif (${BUILD_GENERATOR} STREQUAL "VS2012") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2012") + set (SITE_COMPILER_VERSION "11") endif () ## Set the following to unique id your computer ## - set(CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") + set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") else () - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + set (CTEST_CMAKE_GENERATOR "Unix Makefiles") ## Set the following to unique id your computer ## - if(APPLE) - set(CTEST_SITE "MAC.XXXX") + if (APPLE) + set (CTEST_SITE "MAC.XXXX") else () - set(CTEST_SITE "LINUX.XXXX") + set (CTEST_SITE "LINUX.XXXX") endif () - if(APPLE) - execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ENV{CC} "${XCODE_CC}") - set(ENV{CXX} "${XCODE_CXX}") - set(CTEST_USE_LAUNCHERS 1) - set(RR_WARNINGS_COMMON "-Wno-format-nonliteral -Wno-cast-align -Wno-unused -Wno-unused-variable -Wno-unused-function -Wno-self-assign -Wno-unused-parameter -Wno-sign-compare") - set(RR_WARNINGS_C "${RR_WARNINGS_COMMON} -Wno-deprecated-declarations -Wno-uninitialized") - set(RR_WARNINGS_CXX "${RR_WARNINGS_COMMON} -Woverloaded-virtual -Wshadow -Wwrite-strings -Wc++11-compat") - set(RR_FLAGS_COMMON "-g -O0 -fstack-protector-all -D_FORTIFY_SOURCE=2") - set(RR_FLAGS_C "${RR_FLAGS_COMMON}") - set(RR_FLAGS_CXX "${RR_FLAGS_COMMON}") - set(ENV{CFLAGS} "${RR_WARNINGS_C} ${RR_FLAGS_C}") - set(ENV{CXXFLAGS} "${RR_WARNINGS_CXX} ${RR_FLAGS_CXX}") + if (APPLE) + execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set (ENV{CC} "${XCODE_CC}") + set (ENV{CXX} "${XCODE_CXX}") + set (CTEST_USE_LAUNCHERS 1) + set (RR_WARNINGS_COMMON "-Wno-format-nonliteral -Wno-cast-align -Wno-unused -Wno-unused-variable -Wno-unused-function -Wno-self-assign -Wno-unused-parameter -Wno-sign-compare") + set (RR_WARNINGS_C "${RR_WARNINGS_COMMON} -Wno-deprecated-declarations -Wno-uninitialized") + set (RR_WARNINGS_CXX "${RR_WARNINGS_COMMON} -Woverloaded-virtual -Wshadow -Wwrite-strings -Wc++11-compat") + set (RR_FLAGS_COMMON "-g -O0 -fstack-protector-all -D_FORTIFY_SOURCE=2") + set (RR_FLAGS_C "${RR_FLAGS_COMMON}") + set (RR_FLAGS_CXX "${RR_FLAGS_COMMON}") + set (ENV{CFLAGS} "${RR_WARNINGS_C} ${RR_FLAGS_C}") + set (ENV{CXXFLAGS} "${RR_WARNINGS_CXX} ${RR_FLAGS_CXX}") endif () endif () ################################################################### @@ -180,99 +180,99 @@ endif () ################################################################### ######### Following is for submission to CDash ############ ################################################################### -set(MODEL "Experimental") +set (MODEL "Experimental") ################################################################### ################################################################### ##### Following controls CDash submission ##### -#set(LOCAL_SUBMIT "TRUE") +#set (LOCAL_SUBMIT "TRUE") ##### Following controls test process ##### -#set(LOCAL_SKIP_TEST "TRUE") -#set(LOCAL_MEMCHECK_TEST "TRUE") -#set(LOCAL_COVERAGE_TEST "TRUE") +#set (LOCAL_SKIP_TEST "TRUE") +#set (LOCAL_MEMCHECK_TEST "TRUE") +#set (LOCAL_COVERAGE_TEST "TRUE") ##### Following controls cpack command ##### -#set(LOCAL_NO_PACKAGE "TRUE") +#set (LOCAL_NO_PACKAGE "TRUE") ##### Following controls source update ##### -#set(LOCAL_UPDATE "TRUE") -set(REPOSITORY_URL "https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5.git") -set(REPOSITORY_BRANCH "develop") +#set (LOCAL_UPDATE "TRUE") +set (REPOSITORY_URL "https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5.git") +set (REPOSITORY_BRANCH "develop") #uncomment to use a compressed source file: *.tar on linux or mac *.zip on windows #set(CTEST_USE_TAR_SOURCE "${CTEST_SOURCE_VERSION}") ################################################################### ################################################################### -if(${STATICONLYLIBRARIES}) - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") +if (${STATICONLYLIBRARIES}) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") ######### Following describes computer ############ ## following is optional to describe build ## - set(SITE_BUILDNAME_SUFFIX "STATIC") + set (SITE_BUILDNAME_SUFFIX "STATIC") endif () ################################################################### #### fortran #### -if(${FORTRANLIBRARIES}) - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON") +if (${FORTRANLIBRARIES}) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON") ### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=ON") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=ON") else () - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") ### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=OFF") endif () #### java #### -if(${JAVALIBRARIES}) - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON") +if (${JAVALIBRARIES}) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON") else () - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") endif () ### change install prefix -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCTEST_CONFIGURATION_TYPE:STRING=$ENV{CMAKE_CONFIG_TYPE}") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCTEST_CONFIGURATION_TYPE:STRING=$ENV{CMAKE_CONFIG_TYPE}") ################################################################### -if(WIN32) - set(BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}") - include(${CTEST_SCRIPT_DIRECTORY}\\HDF5options.cmake) - include(${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe") - file(COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) +if (WIN32) + set (BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}") + include (${CTEST_SCRIPT_DIRECTORY}\\HDF5options.cmake) + include (${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) + if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe") + file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi") - file(COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi") + file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip") - file(COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip") + file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () else () - set(BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") - include(${CTEST_SCRIPT_DIRECTORY}/HDF5options.cmake) - include(${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) - if(APPLE) - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + set (BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") + include (${CTEST_SCRIPT_DIRECTORY}/HDF5options.cmake) + include (${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) + if (APPLE) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () else () - if(CYGWIN) - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (CYGWIN) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () else () - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () - if(EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz") + file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) endif () endif () endif () diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake index a1bf88d..6239f1f 100755 --- a/config/cmake/scripts/HDF5options.cmake +++ b/config/cmake/scripts/HDF5options.cmake @@ -31,7 +31,7 @@ set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING ### disable packaging #set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_NO_PACKAGES:BOOL=ON") -### Create install package with external libraries (szip, zlib, jpeg) +### Create install package with external libraries (szip, zlib) set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") ############################################################################################# -- cgit v0.12 From ecfdadfb1eff5ae8f18269e33dce3856e22f4bd7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 14 Mar 2017 20:58:21 -0700 Subject: Correct double sourcedir name on copied datafiles. --- test/tfile.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/tfile.c b/test/tfile.c index 295a29c..7edc40c 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -4465,10 +4465,8 @@ test_filespace_1_10_0_compatible(void) MESSAGE(5, ("File space compatibility testing for 1.10.0 files\n")); for(j = 0; j < NELMTS(OLD_1_10_0_FILENAME); j++) { - const char *filename = H5_get_srcdir_filename(OLD_1_10_0_FILENAME[j]); /* Corrected test file name */ - /* Make a copy of the test file */ - status = h5_make_local_copy(filename, FILE5); + status = h5_make_local_copy(OLD_1_10_0_FILENAME[j], FILE5); CHECK(status, FAIL, "h5_make_local_copy"); /* Open the temporary test file */ @@ -4779,10 +4777,8 @@ test_filespace_round_compatible(void) MESSAGE(5, ("File space compatibility testing for files from trunk to 1_8 to trunk\n")); for(j = 0; j < NELMTS(FSPACE_FILENAMES); j++) { - const char *filename = H5_get_srcdir_filename(FSPACE_FILENAMES[j]); - /* Make a copy of the test file */ - status = h5_make_local_copy(filename, FILE5); + status = h5_make_local_copy(FSPACE_FILENAMES[j], FILE5); CHECK(status, FAIL, "h5_make_local_copy"); /* Open the temporary test file */ -- cgit v0.12 From 98567db19290dc07cc86efae720b0dc457ae9f65 Mon Sep 17 00:00:00 2001 From: lrknox Date: Wed, 15 Mar 2017 12:49:19 -0500 Subject: output_filter.sh: Comment added to address HDFFV-8270. The sample ontput in the file's comments are not up-to-date with the scripts in the file that remove output unique to certain systems when running test scripts. This output doesn't match expected output files for the tests, causing them to fail. Ther output_filter.sh file removes such output. Currently we don't have access to these systems to update the comments. testflushrefresh.sh.in: flushrefresh and other SWMR tests have been failing occasionally but regularly since bringing them to the develop branch. The logs and debugging point to unexpected deletion of signal files as the point of failure, and John Mainzer suggests that two such tests running simultaneously in the same directory may lead to the operating system deleting the other test's signal file. Running the flushrefresh test in its own directory seems to solve the problem. --- bin/output_filter.sh | 15 +++++++++++++++ test/testflushrefresh.sh.in | 27 ++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/bin/output_filter.sh b/bin/output_filter.sh index 58f1c48..35af819 100644 --- a/bin/output_filter.sh +++ b/bin/output_filter.sh @@ -17,6 +17,21 @@ # Created Date: 2011/5/3 +# Comment added to address HDFFV-8270: +# As I understand it, the purpose of this file is to remove extraneous messages +# that appear in stdout and stderr on some machines that have been tested outside +# of the HDF Group realm. The purpose of this script is to filter those +# extraneous messages from stdout and stderr so that when the output files are +# compared to the expected output, the extra messages will not cause failures in +# the tests. The system messages in the comments below are out of date, meaning +# I suppose that while the script code to filter messages on the system was +# correct correct when last used, the output in the comments doesn't match the +# script code that follows. I don't currently have access to any of these +# systems to see the current output and the effect of the script code. If using +# this file in the future, please update the comments to match the scripts in use. +# Larry Knox 2017/3/15 + + # Some systems will dump some messages to stdout for various reasons. # Remove them from the stdout result file. # $1 is the file name of the file to be filtered. diff --git a/test/testflushrefresh.sh.in b/test/testflushrefresh.sh.in index 83b7134..e7917a0 100644 --- a/test/testflushrefresh.sh.in +++ b/test/testflushrefresh.sh.in @@ -79,11 +79,22 @@ if [ $rc -ne 0 ] ; then exit 0 fi -# ======================== -# Launch the Test Program. -# ======================== -./flushrefresh & -pid_main=$! +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir -p flushrefresh_test/.libs +cp flushrefresh flushrefresh_test + +# With the --disable-shared option, flushrefresh is built in the test directory, +# otherwise it is in test/.libs with a wrapper script named flushrefresh in +# the test directory. test/flushrefresh should always be copied, +# .libs/flushrefresh should be copied only if it exists. +if [ -f .libs/flushrefresh ]; then + cp .libs/flushrefresh flushrefresh_test/.libs +fi +cd flushrefresh_test # ================================================= # Set up/initialize some variables to be used later @@ -98,6 +109,12 @@ if [ -e $testfile ]; then rm $testfile fi +# ======================== +# Launch the Test Program. +# ======================== +./flushrefresh & +pid_main=$! + # ======================================= # Run flush verification on test program. # ======================================= -- cgit v0.12 From a16d142f80630b11ac45c0bcf00ee2ea5b88f08e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 16 Mar 2017 08:38:24 -0700 Subject: Switch from HDatoll to HDstrtoll, for Windows compatibility. --- tools/src/h5repack/h5repack_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index a8b4cfe..07c2b7d 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -569,7 +569,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'G': - options->fs_pagesize = HDatoll( opt_arg ); + options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0); if(options->fs_pagesize == 0) /* To distinguish the "specified" zero value */ options->fs_pagesize = -1; -- cgit v0.12 From 24b11709aff9e88de172342faed165ec08985e42 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 16 Mar 2017 12:58:49 -0500 Subject: Update cmake pubconf to match autotools and add strtoll checks --- config/cmake/H5pubconf.h.in | 95 +++++++++++++++++++++++------- config/cmake_ext_mod/ConfigureChecks.cmake | 16 +++-- configure.ac | 1 + src/H5private.h | 8 ++- src/H5system.c | 33 ++++++----- src/H5win32defs.h | 16 ++++- 6 files changed, 124 insertions(+), 45 deletions(-) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 5dad4f3..55de8f8 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -41,17 +41,41 @@ /* As FC_FUNC, but for C identifiers containing underscores. */ #define @H5_FC_FUNC_@ -/* Define Fortran Maximum Real Decimal Precision */ -#cmakedefine H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ - -/* Define C Maximum Real Decimal Precision */ -#cmakedefine H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ +/* Define if Fortran C_LONG_DOUBLE is different from C_DOUBLE */ +#cmakedefine H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE @H5_FORTRAN_C_LONG_DOUBLE_IS_UNIQUE@ /* Define if we have Fortran C_LONG_DOUBLE */ #cmakedefine H5_FORTRAN_HAVE_C_LONG_DOUBLE @H5_FORTRAN_HAVE_C_LONG_DOUBLE@ -/* Determine if __float128 is available */ -#cmakedefine H5_HAVE_FLOAT128 @H5_HAVE_FLOAT128@ +/* Define if we have Fortran intrinsic C_SIZEOF */ +#cmakedefine H5_FORTRAN_HAVE_C_SIZEOF @H5_FORTRAN_HAVE_C_SIZEOF@ + +/* Define if we have Fortran intrinsic SIZEOF */ +#cmakedefine H5_FORTRAN_HAVE_SIZEOF @H5_FORTRAN_HAVE_SIZEOF@ + +/* Define if we have Fortran intrinsic STORAGE_SIZE */ +#cmakedefine H5_FORTRAN_HAVE_STORAGE_SIZE @H5_FORTRAN_HAVE_STORAGE_SIZE@ + +/* Determine the size of C long double */ +#cmakedefine H5_FORTRAN_SIZEOF_LONG_DOUBLE @H5_FORTRAN_SIZEOF_LONG_DOUBLE@ + +/* Define Fortran compiler ID */ +#cmakedefine H5_Fortran_COMPILER_ID @H5_Fortran_COMPILER_ID@ + +/* Define valid Fortran INTEGER KINDs */ +#cmakedefine H5_H5CONFIG_F_IKIND @H5_HH5_H5CONFIG_F_NUM_RKIND5CONFIG_F_IKIND@ + +/* Define number of valid Fortran INTEGER KINDs */ +#cmakedefine H5_H5CONFIG_F_NUM_IKIND @H5_H5CONFIG_F_NUM_IKIND@ + +/* Define number of valid Fortran REAL KINDs */ +#cmakedefine H5_H5CONFIG_F_NUM_RKIND @H5_H5CONFIG_F_NUM_RKIND@ + +/* Define valid Fortran REAL KINDs */ +#cmakedefine H5_H5CONFIG_F_RKIND @H5_H5CONFIG_F_RKIND@ + +/* Define valid Fortran REAL KINDs Sizeof */ +#cmakedefine H5_H5CONFIG_F_RKIND_SIZEOF @H5_H5CONFIG_F_RKIND_SIZEOF@ /* Define to 1 if you have the `alarm' function. */ #cmakedefine H5_HAVE_ALARM @H5_HAVE_ALARM@ @@ -81,7 +105,7 @@ /* Define to 1 if you have the `difftime' function. */ #cmakedefine H5_HAVE_DIFFTIME @H5_HAVE_DIFFTIME@ -/* Define if the direct I/O virtual file driver should be compiled */ +/* Define if the direct I/O virtual file driver (VFD) should be compiled */ #cmakedefine H5_HAVE_DIRECT @H5_HAVE_DIRECT@ /* Define to 1 if you have the header file. */ @@ -108,6 +132,9 @@ /* Define if support for szip filter is enabled */ #cmakedefine H5_HAVE_FILTER_SZIP @H5_HAVE_FILTER_SZIP@ +/* Determine if __float128 is available */ +#cmakedefine H5_HAVE_FLOAT128 @H5_HAVE_FLOAT128@ + /* Define to 1 if you have the `flock' function. */ #cmakedefine H5_HAVE_FLOCK @H5_HAVE_FLOCK@ @@ -162,7 +189,7 @@ /* Define if the compiler understands inline */ #cmakedefine H5_HAVE_INLINE @H5_HAVE_INLINE@ -/* Define if library will contain instrumentation to detect correct +/* Define if parallel library will contain instrumentation to detect correct optimization operation */ #cmakedefine H5_HAVE_INSTRUMENTED_LIBRARY @H5_HAVE_INSTRUMENTED_LIBRARY@ @@ -244,8 +271,8 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_PTHREAD_H @H5_HAVE_PTHREAD_H@ -/* Define to 1 if you have the 'InitOnceExecuteOnce' function. */ -#cmakedefine H5_HAVE_WIN_THREADS @H5_HAVE_WIN_THREADS@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_QUADMATH_H @H5_HAVE_QUADMATH_H@ /* Define to 1 if you have the `random' function. */ #cmakedefine H5_HAVE_RANDOM @H5_HAVE_RANDOM@ @@ -254,10 +281,10 @@ #cmakedefine H5_HAVE_RAND_R @H5_HAVE_RAND_R@ /* Define to 1 if you have the `round' function. */ -#cmakedefine H5_HAVE_ROUNDF @H5_HAVE_ROUNDF@ +#cmakedefine H5_HAVE_ROUND @H5_HAVE_ROUND@ /* Define to 1 if you have the `roundf' function. */ -#cmakedefine H5_HAVE_ROUND @H5_HAVE_ROUND@ +#cmakedefine H5_HAVE_ROUNDF @H5_HAVE_ROUNDF@ /* Define to 1 if you have the `setjmp' function. */ #cmakedefine H5_HAVE_SETJMP @H5_HAVE_SETJMP@ @@ -292,6 +319,9 @@ /* Define if `struct stat' has the `st_blocks' field */ #cmakedefine H5_HAVE_STAT_ST_BLOCKS @H5_HAVE_STAT_ST_BLOCKS@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_STDBOOL_H @H5_HAVE_STDBOOL_H@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_STDDEF_H @H5_HAVE_STDDEF_H@ @@ -307,6 +337,12 @@ /* Define to 1 if you have the `strdup' function. */ #cmakedefine H5_HAVE_STRDUP @H5_HAVE_STRDUP@ +/* Define to 1 if you have the `strtoll' function. */ +#cmakedefine H5_HAVE_STRTOLL @H5_HAVE_STRTOLL@ + +/* Define to 1 if you have the `strtoull' function. */ +#cmakedefine H5_HAVE_STRTOULL @H5_HAVE_STRTOULL@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_STRINGS_H @H5_HAVE_STRINGS_H@ @@ -325,6 +361,9 @@ /* Define to 1 if you have the `system' function. */ #cmakedefine H5_HAVE_SYSTEM @H5_HAVE_SYSTEM@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_SYS_FILE_H @H5_HAVE_SYS_FILE_H@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_SYS_IOCTL_H @H5_HAVE_SYS_IOCTL_H@ @@ -379,6 +418,9 @@ /* Define to 1 if you have the `waitpid' function. */ #cmakedefine H5_HAVE_WAITPID @H5_HAVE_WAITPID@ +/* Define to 1 if you have the 'InitOnceExecuteOnce' function. */ +#cmakedefine H5_HAVE_WIN_THREADS @H5_HAVE_WIN_THREADS@ + /* Define if your system has window style path name. */ #cmakedefine H5_HAVE_WINDOW_PATH @H5_HAVE_WINDOW_PATH@ @@ -419,10 +461,12 @@ with special algorithm. */ #cmakedefine H5_LONG_TO_LDOUBLE_SPECIAL @H5_LONG_TO_LDOUBLE_SPECIAL@ -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #cmakedefine H5_LT_OBJDIR @H5_LT_OBJDIR@ +/* Define to enable internal memory allocation sanity checking. */ +/* #cmakedefine H5_MEMORY_ALLOC_SANITY_CHECK @H5_MEMORY_ALLOC_SANITY_CHECK@ ** Define in CMakeLists.txt */ + /* Define if the metadata trace file code is to be compiled in */ #cmakedefine H5_METADATA_TRACE_FILE @H5_METADATA_TRACE_FILE@ @@ -453,9 +497,18 @@ /* Define to the version of this package. */ #define H5_PACKAGE_VERSION "@HDF5_PACKAGE_VERSION_STRING@" +/* Determine the maximum decimal precision in C */ +#define H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ + +/* Define Fortran Maximum Real Decimal Precision */ +#cmakedefine H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ + /* Width for printf() for type `long long' or `__int64', use `ll' */ #cmakedefine H5_PRINTF_LL_WIDTH @H5_PRINTF_LL_WIDTH@ +/* The size of `bool', as computed by sizeof. */ +#cmakedefine H5_SIZEOF_BOOL @H5_SIZEOF_BOOL@ + /* The size of `char', as computed by sizeof. */ #cmakedefine H5_SIZEOF_CHAR @H5_SIZEOF_CHAR@ @@ -589,14 +642,14 @@ /* The size of `unsigned', as computed by sizeof. */ #cmakedefine H5_SIZEOF_UNSIGNED @H5_SIZEOF_UNSIGNED@ -/* The size of `__int64', as computed by sizeof. */ -#define H5_SIZEOF___INT64 @H5_SIZEOF___INT64@ +/* The size of `_Quad', as computed by sizeof. */ +#define H5_SIZEOF__QUAD @H5_SIZEOF__QUAD@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_STDBOOL_H @H5_HAVE_STDBOOL_H@ +/* The size of `__float128', as computed by sizeof. */ +#define H5_SIZEOF___FLOAT128 @H5_SIZEOF___FLOAT128@ -/* The size of `bool', as computed by sizeof. */ -#cmakedefine H5_SIZEOF_BOOL @H5_SIZEOF_BOOL@ +/* The size of `__int64', as computed by sizeof. */ +#define H5_SIZEOF___INT64 @H5_SIZEOF___INT64@ /* Define to 1 if you have the ANSI C header files. */ #cmakedefine H5_STDC_HEADERS @H5_STDC_HEADERS@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 2e99c94..a0ec8e3 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -198,18 +198,19 @@ endmacro () #----------------------------------------------------------------------------- # Check for the existence of certain header files #----------------------------------------------------------------------------- -CHECK_INCLUDE_FILE_CONCAT ("sys/resource.h" ${HDF_PREFIX}_HAVE_SYS_RESOURCE_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H) -CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/file.h" ${HDF_PREFIX}_HAVE_SYS_FILE_H) CHECK_INCLUDE_FILE_CONCAT ("sys/ioctl.h" ${HDF_PREFIX}_HAVE_SYS_IOCTL_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/stat.h" ${HDF_PREFIX}_HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/resource.h" ${HDF_PREFIX}_HAVE_SYS_RESOURCE_H) CHECK_INCLUDE_FILE_CONCAT ("sys/socket.h" ${HDF_PREFIX}_HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/stat.h" ${HDF_PREFIX}_HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H) CHECK_INCLUDE_FILE_CONCAT ("sys/types.h" ${HDF_PREFIX}_HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) -CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H) CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H) +CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) +CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) +CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) # IF the c compiler found stdint, check the C++ as well. On some systems this # file will be found by C but not C++, only do this test IF the C++ compiler @@ -527,6 +528,8 @@ CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK) CHECK_FUNCTION_EXISTS (snprintf ${HDF_PREFIX}_HAVE_SNPRINTF) CHECK_FUNCTION_EXISTS (srandom ${HDF_PREFIX}_HAVE_SRANDOM) CHECK_FUNCTION_EXISTS (strdup ${HDF_PREFIX}_HAVE_STRDUP) +CHECK_FUNCTION_EXISTS (strtoll ${HDF_PREFIX}_HAVE_STRTOLL) +CHECK_FUNCTION_EXISTS (strtoull ${HDF_PREFIX}_HAVE_STRTOULL) CHECK_FUNCTION_EXISTS (symlink ${HDF_PREFIX}_HAVE_SYMLINK) CHECK_FUNCTION_EXISTS (system ${HDF_PREFIX}_HAVE_SYSTEM) @@ -585,6 +588,7 @@ macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) HAVE_UNISTD_H HAVE_SYS_TYPES_H HAVE_SYS_SOCKET_H + HAVE_SYS_FILE_H ) if ("${${HDF_PREFIX}_${def}}") set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") diff --git a/configure.ac b/configure.ac index 2af7988..3e918db 100644 --- a/configure.ac +++ b/configure.ac @@ -1851,6 +1851,7 @@ AC_CHECK_FUNCS([frexpl gethostname getrusage gettimeofday]) AC_CHECK_FUNCS([lstat rand_r random setsysinfo]) AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask]) AC_CHECK_FUNCS([snprintf srandom strdup symlink system]) +AC_CHECK_FUNCS([strtoll strtoull]) AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid]) AC_CHECK_FUNCS([roundf lroundf llroundf round lround llround]) diff --git a/src/H5private.h b/src/H5private.h index 00de96c..61ecc5b 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1386,7 +1386,13 @@ typedef off_t h5_stat_size_t; #ifndef HDstrtol #define HDstrtol(S,R,N) strtol(S,R,N) #endif /* HDstrtol */ -H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); +#ifndef HDstrtoll + #ifdef H5_HAVE_STRTOLL + #define HDstrtoll(S,R,N) strtoll(S,R,N) + #else + H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); + #endif /* H5_HAVE_STRTOLL */ +#endif /* HDstrtoll */ #ifndef HDstrtoul #define HDstrtoul(S,R,N) strtoul(S,R,N) #endif /* HDstrtoul */ diff --git a/src/H5system.c b/src/H5system.c index ac323c0..1f92e19 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -32,10 +32,10 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ /****************/ @@ -474,6 +474,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) * *------------------------------------------------------------------------- */ +#ifndef HDstrtoll int64_t HDstrtoll(const char *s, const char **rest, int base) { @@ -549,7 +550,7 @@ HDstrtoll(const char *s, const char **rest, int base) *rest = s; return acc; } /* end HDstrtoll() */ - +#endif /*------------------------------------------------------------------------- * Function: HDrand/HDsrand @@ -604,7 +605,7 @@ void HDsrand(unsigned int seed) #ifdef H5_HAVE_FCNTL int Pflock(int fd, int operation) { - + struct flock flk; /* Set the lock type */ @@ -649,18 +650,18 @@ Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { /*------------------------------------------------------------------------- - * Function: H5_make_time + * Function: H5_make_time * - * Purpose: Portability routine to abstract converting a 'tm' struct into - * a time_t value. + * Purpose: Portability routine to abstract converting a 'tm' struct into + * a time_t value. * - * Note: This is a little problematic because mktime() operates on - * local times. We convert to local time and then figure out the - * adjustment based on the local time zone and daylight savings - * setting. + * Note: This is a little problematic because mktime() operates on + * local times. We convert to local time and then figure out the + * adjustment based on the local time zone and daylight savings + * setting. * - * Return: Success: The value of timezone - * Failure: -1 + * Return: Success: The value of timezone + * Failure: -1 * * Programmer: Quincey Koziol * November 18, 2015 @@ -1138,7 +1139,7 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) if(NULL == (*full_name = (char *)H5MM_strdup(path2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end if */ + } /* end if */ else if(H5_CHECK_ABS_PATH(path2)) { /* On windows path2 is a path absolute name */ diff --git a/src/H5win32defs.h b/src/H5win32defs.h index b419f06..e005b51 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -23,6 +23,11 @@ * */ +/* + * _MSC_VER = 1900 VS2015 + * _MSC_VER = 1800 VS2013 + * _MSC_VER = 1700 VS2012 + */ #ifdef H5_HAVE_WIN32_API typedef struct _stati64 h5_stat_t; @@ -54,13 +59,22 @@ typedef __int64 h5_stat_size_t; #define HDsleep(S) Sleep(S*1000) #define HDstat(S,B) _stati64(S,B) #define HDstrcasecmp(A,B) _stricmp(A,B) -#define HDstrtoull(S,R,N) _strtoui64(S,R,N) #define HDstrdup(S) _strdup(S) #define HDtzset() _tzset() #define HDunlink(S) _unlink(S) #define HDwrite(F,M,Z) _write(F,M,Z) #ifdef H5_HAVE_VISUAL_STUDIO + +#if (_MSC_VER < 1800) + #ifndef H5_HAVE_STRTOLL + #define HDstrtoll(S,R,N) _strtoi64(S,R,N) + #endif /* H5_HAVE_STRTOLL */ + #ifndef H5_HAVE_STRTOULL + #define HDstrtoull(S,R,N) _strtoui64(S,R,N) + #endif /* H5_HAVE_STRTOULL */ +#endif /* MSC_VER < 1800 */ + /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ -- cgit v0.12 From 4c6f538770f92a09c6be46e44de056ad7ec68426 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 17 Mar 2017 10:36:49 -0500 Subject: Add toolset option to cmake configure --- config/cmake/scripts/CTestScript.cmake | 9 +++++++-- config/cmake/scripts/HDF5options.cmake | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index d24eb44..cb92933 100755 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -185,17 +185,22 @@ endforeach () #----------------------------------------------------------------------------- # Initialize the CTEST commands #------------------------------ +if(CMAKE_GENERATOR_TOOLSET) + set(CTEST_CONFIGURE_TOOLSET "-T${CMAKE_GENERATOR_TOOLSET}") +else () + set(CTEST_CONFIGURE_TOOLSET "") +endif() if (LOCAL_MEMCHECK_TEST) find_program (CTEST_MEMORYCHECK_COMMAND NAMES valgrind) set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\"" ) else () if (LOCAL_COVERAGE_TEST) find_program (CTEST_COVERAGE_COMMAND NAMES gcov) endif () set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\"" ) endif () diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake index 6239f1f..bbbb8dc 100755 --- a/config/cmake/scripts/HDF5options.cmake +++ b/config/cmake/scripts/HDF5options.cmake @@ -6,6 +6,10 @@ ### uncomment/comment and change the following lines for other configuration options ############################################################################################# +#### alternate toolsets #### +#set(CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler 17.0") + +############################################################################################# #### ext libraries #### ### ext libs from tgz -- cgit v0.12 From 50ac3cd6ecc37bb2196bcebe8a202711e315759d Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 17 Mar 2017 11:03:18 -0500 Subject: Description: Miscellaneous clean-up: format and comments Platforms tested: Linux/64 (jelly) Darwin (osx1010test) --- c++/src/H5AbstractDs.h | 6 +- c++/src/H5ArrayType.h | 6 +- c++/src/H5AtomType.h | 6 +- c++/src/H5Attribute.cpp | 2 +- c++/src/H5Attribute.h | 5 +- c++/src/H5CommonFG.cpp | 2 +- c++/src/H5CommonFG.h | 6 +- c++/src/H5CompType.h | 6 +- c++/src/H5DataSet.h | 5 +- c++/src/H5DataSpace.h | 6 +- c++/src/H5DataType.cpp | 1 + c++/src/H5DataType.h | 6 +- c++/src/H5DcreatProp.h | 6 +- c++/src/H5DxferProp.h | 6 +- c++/src/H5EnumType.h | 6 +- c++/src/H5Exception.h | 4 +- c++/src/H5FaccProp.h | 5 +- c++/src/H5FcreatProp.cpp | 2 - c++/src/H5FcreatProp.h | 7 +-- c++/src/H5File.cpp | 143 ++++++++++++++++++++++++----------------------- c++/src/H5File.h | 6 +- c++/src/H5FloatType.h | 6 +- c++/src/H5Group.cpp | 25 +++++---- c++/src/H5Group.h | 5 +- c++/src/H5IdComponent.h | 2 +- c++/src/H5IntType.h | 6 +- c++/src/H5LaccProp.h | 5 +- c++/src/H5Library.h | 5 +- c++/src/H5Location.h | 4 +- c++/src/H5Object.h | 4 +- c++/src/H5OcreatProp.h | 5 +- c++/src/H5PredType.h | 5 +- c++/src/H5PropList.h | 5 +- c++/src/H5StrType.h | 6 +- c++/src/H5VarLenType.h | 6 +- c++/test/titerate.cpp | 6 +- c++/test/trefer.cpp | 24 ++++---- c++/test/tvlstr.cpp | 41 +++++++------- 38 files changed, 219 insertions(+), 183 deletions(-) diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index eaa9d14..f0859c8 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -91,6 +91,8 @@ class H5_DLLCPP AbstractDs { private: // This member function is implemented by DataSet and Attribute - pure virtual. virtual hid_t p_get_type() const = 0; -}; -} + +}; // end of AbstractDs +} // namespace H5 + #endif // __AbstractDs_H diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 15b6bb3..dd9db51 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -60,6 +60,8 @@ class H5_DLLCPP ArrayType : public DataType { // Default constructor ArrayType(); -}; -} + +}; // end of ArrayType +} // namespace H5 + #endif // __H5ArrayType_H diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index a1e0262..f4c70fd 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -78,6 +78,8 @@ class H5_DLLCPP AtomType : public DataType { // Constructor that takes an existing id AtomType(const hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} + +}; // end of AtomType +} // namespace H5 + #endif // __H5AtomType_H diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index c506906..6701f6e 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * +/* All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 0243cd9..6d6df2c 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -101,6 +101,7 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { // Friend function to set Attribute id. For library use only. friend void f_Attribute_setId(Attribute* attr, hid_t new_id); -}; -} +}; // end of Attribute +} // namespace H5 + #endif // __H5Attribute_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 5c01055..f3390aa 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -381,4 +381,4 @@ void f_DataSet_setId(DataSet* dset, hid_t new_id) #endif // DOXYGEN_SHOULD_SKIP_THIS -} +} // end namespace diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 588d49a..0c7b799 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -84,10 +84,8 @@ class H5_DLLCPP CommonFG { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; // end of CommonFG declaration +}; // end of CommonFG +} // namespace H5 -#ifndef H5_NO_NAMESPACE -} -#endif #endif // __CommonFG_H diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 222044d..042b59f 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -115,6 +115,8 @@ class H5_DLLCPP CompType : public DataType { // Contains common code that is used by the member functions // getMemberXxxType hid_t p_get_member_type(unsigned member_num) const; -}; -} + +}; // end of CompType +} // namespace H5 + #endif // __H5CompType_H diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 93f9782..f9e29ff 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -130,6 +130,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { // Friend function to set DataSet id. For library use only. friend void f_DataSet_setId(DataSet* dset, hid_t new_id); -}; -} +}; // end of DataSet +} // namespace H5 + #endif // __H5DataSet_H diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 969e146..281e865 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -149,6 +149,8 @@ class H5_DLLCPP DataSpace : public IdComponent { friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} + +}; // end of DataSpace +} // namespace H5 + #endif // __H5DataSpace_H diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 1cfc259..c88d6eb 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -861,4 +861,5 @@ DataType::~DataType() cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } + } // end namespace diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 6501bb9..c2ea2a3 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -155,6 +155,8 @@ class H5_DLLCPP DataType : public H5Object { friend void f_DataType_setId(DataType* dtype, hid_t new_id); void p_commit(hid_t loc_id, const char* name); -}; -} + +}; // end of DataType +} // namespace H5 + #endif // __H5DataType_H diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 5371e03..f0475eb 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -146,6 +146,8 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { static DSetCreatPropList* getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} + +}; // end of DSetCreatPropList +} // namespace H5 + #endif // __H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index f1c363f..39d3ba8 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -127,6 +127,8 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { static DSetMemXferPropList* getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} + +}; // end of DSetMemXferPropList +} // namespace H5 + #endif // __H5DSetMemXferPropList_H diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 2fbe2cd..cd93eb5 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -78,6 +78,8 @@ class H5_DLLCPP EnumType : public DataType { EnumType(const EnumType& original); virtual ~EnumType(); -}; -} + +}; // end of EnumType +} // namespace H5 + #endif // __H5EnumType_H diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 1f85711..2e68cf0 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -174,8 +174,8 @@ class H5_DLLCPP IdComponentException : public Exception { IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); IdComponentException(); virtual ~IdComponentException() throw(); -}; -} +}; // end of IdComponentException +} // namespace H5 #endif // __H5Exception_H diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 586dcf8..8e488e5 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -162,6 +162,7 @@ class H5_DLLCPP FileAccPropList : public PropList { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of FileAccPropList +} // namespace H5 + #endif // __H5FileAccPropList_H diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index ea69049..c490f26 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -294,7 +294,6 @@ unsigned FileCreatPropList::getIstorek() const return(ik); } -#ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- // Function: FileCreatPropList::setFileSpace ///\brief Sets the strategy and the threshold value that the library @@ -365,7 +364,6 @@ hsize_t FileCreatPropList::getFileSpaceThreshold() const } return(threshold); } -#endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- // Function: FileCreatPropList destructor diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index 1d999cb..7b594a3 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -65,7 +65,6 @@ class H5_DLLCPP FileCreatPropList : public PropList { // indexing chunked datasets. void setIstorek(unsigned ik) const; -#ifndef H5_NO_DEPRECATED_SYMBOLS // Sets the strategy and the threshold value that the library will // will employ in managing file space. void setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const; @@ -76,7 +75,6 @@ class H5_DLLCPP FileCreatPropList : public PropList { // Returns the threshold value that the library uses in tracking free // space sections. hsize_t getFileSpaceThreshold() const; -#endif /* H5_NO_DEPRECATED_SYMBOLS */ ///\brief Returns this class name. virtual H5std_string fromClass() const { return("FileCreatPropList"); } @@ -104,6 +102,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of FileCreatPropList +} // namespace H5 + #endif // __H5FileCreatPropList_H diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index cdb5837..bea4612 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -45,7 +45,7 @@ namespace H5 { using std::endl; //-------------------------------------------------------------------------- -// Function H5File default constructor +// Function H5File default constructor ///\brief Default constructor: creates a stub H5File object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -64,30 +64,30 @@ H5File::H5File() : Group(), id(H5I_INVALID_HID) {} ///\par Description /// Valid values of \a flags include: /// \li \c H5F_ACC_TRUNC - Truncate file, if it already exists, -/// erasing all data previously stored in -/// the file. +/// erasing all data previously stored in +/// the file. /// \li \c H5F_ACC_EXCL - Fail if file already exists. -/// \c H5F_ACC_TRUNC and \c H5F_ACC_EXCL are mutually exclusive +/// \c H5F_ACC_TRUNC and \c H5F_ACC_EXCL are mutually exclusive /// \li \c H5F_ACC_RDONLY - Open file as read-only, if it already -/// exists, and fail, otherwise +/// exists, and fail, otherwise /// \li \c H5F_ACC_RDWR - Open file for read/write, if it already -/// exists, and fail, otherwise +/// exists, and fail, otherwise ///\par /// For info on file creation in the case of an already-open file, /// please refer to the \b Special \b case section in the C layer /// Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Create -// Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file -// could not be caught in the applications. Added try block here -// to catch then re-throw it. -BMR 2013/03/21 +// Notes With a PGI compiler (~2012-2013,) the exception thrown by +// p_get_file could not be caught in the applications. Added try +// block here to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) { try { - p_get_file(name, flags, create_plist, access_plist); + p_get_file(name, flags, create_plist, access_plist); } catch (FileIException& open_file) { - throw open_file; + throw open_file; } } @@ -102,17 +102,17 @@ H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& cr /// FileCreatPropList::DEFAULT ///\param access_plist - IN: File access property list. Default to /// FileAccPropList::DEFAULT -// Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file -// could not be caught in the applications. Added try block here -// to catch then re-throw it. -BMR 2013/03/21 +// Notes With a PGI compiler (~2012-2013,) the exception thrown by +// p_get_file could not be caught in the applications. Added try +// block here to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) { try { - p_get_file(name.c_str(), flags, create_plist, access_plist); + p_get_file(name.c_str(), flags, create_plist, access_plist); } catch (FileIException& open_file) { - throw open_file; + throw open_file; } } @@ -131,23 +131,23 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro // create the file. if (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) { - hid_t create_plist_id = create_plist.getId(); - hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate(name, flags, create_plist_id, access_plist_id); - if (id < 0) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fcreate failed"); - } + hid_t create_plist_id = create_plist.getId(); + hid_t access_plist_id = access_plist.getId(); + id = H5Fcreate(name, flags, create_plist_id, access_plist_id); + if (id < 0) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fcreate failed"); + } } // Open the file if none of the bits above are set. else { - hid_t access_plist_id = access_plist.getId(); - id = H5Fopen(name, flags, access_plist_id); - if (id < 0) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fopen failed"); - } + hid_t access_plist_id = access_plist.getId(); + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fopen failed"); + } } } @@ -157,7 +157,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro ///\param existing_id - IN: Id of an existing file // Programmer Binh-Minh Ribler - 2015 // Description -// Mar 29, 2015 +// Mar 29, 2015 // Added in responding to a request from user Jason Newton. // However, it is not recommended to use the private member "id" // in applications. Unlike other situations, where similar @@ -230,9 +230,9 @@ bool H5File::isHdf5(const H5std_string& name) ///\par Description /// Valid values of \a flags include: /// H5F_ACC_RDWR: Open with read/write access. If the file is -/// currently open for read-only access then it -/// will be reopened. Absence of this flag -/// implies read-only access. +/// currently open for read-only access then it +/// will be reopened. Absence of this flag +/// implies read-only access. /// /// H5F_ACC_RDONLY: Open with read only access. - default /// @@ -251,7 +251,7 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis id = H5Fopen (name, flags, access_plist_id); if (id < 0) // throw an exception when open fails { - throw FileIException("H5File::openFile", "H5Fopen failed"); + throw FileIException("H5File::openFile", "H5Fopen failed"); } } @@ -397,14 +397,14 @@ hssize_t H5File::getFreeSpace() const ///\exception H5::FileIException ///\par Description /// The valid values for \a types include: -/// \li \c H5F_OBJ_FILE - Files only -/// \li \c H5F_OBJ_DATASET - Datasets only -/// \li \c H5F_OBJ_GROUP - Groups only -/// \li \c H5F_OBJ_DATATYPE - Named datatypes only -/// \li \c H5F_OBJ_ATTR - Attributes only +/// \li \c H5F_OBJ_FILE - Files only +/// \li \c H5F_OBJ_DATASET - Datasets only +/// \li \c H5F_OBJ_GROUP - Groups only +/// \li \c H5F_OBJ_DATATYPE - Named datatypes only +/// \li \c H5F_OBJ_ATTR - Attributes only /// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE -/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP -/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR +/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP +/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR ///\par /// Multiple object types can be combined with the logical OR operator (|). // Programmer Binh-Minh Ribler - May 2004 @@ -425,19 +425,19 @@ ssize_t H5File::getObjCount(unsigned types) const /// groups and datatypes) in the same file. ///\param types - Type of object to retrieve the count ///\param max_objs - Maximum number of object identifiers to place -/// into obj_id_list. +/// into obj_id_list. ///\param oid_list - List of open object identifiers ///\exception H5::FileIException ///\par Description /// The valid values for \a types include: -/// \li \c H5F_OBJ_FILE - Files only -/// \li \c H5F_OBJ_DATASET - Datasets only -/// \li \c H5F_OBJ_GROUP - Groups only -/// \li \c H5F_OBJ_DATATYPE - Named datatypes only -/// \li \c H5F_OBJ_ATTR - Attributes only +/// \li \c H5F_OBJ_FILE - Files only +/// \li \c H5F_OBJ_DATASET - Datasets only +/// \li \c H5F_OBJ_GROUP - Groups only +/// \li \c H5F_OBJ_DATATYPE - Named datatypes only +/// \li \c H5F_OBJ_ATTR - Attributes only /// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE -/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP -/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR +/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP +/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR ///\par /// Multiple object types can be combined with the logical OR operator (|). // @@ -459,7 +459,7 @@ void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const /// driver. ///\param fapl - File access property list ///\param file_handle - Pointer to the file handle being used by -/// the low-level virtual file driver +/// the low-level virtual file driver ///\exception H5::FileIException ///\par Description /// For the \c FAMILY or \c MULTI drivers, \a fapl should be @@ -487,10 +487,10 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const // Purpose This is an overloaded member function, kept for backward // compatibility. It differs from the above function in that it // misses const's. This wrapper will be removed in future release. -// Param fapl - File access property list -// Param file_handle - Pointer to the file handle being used by -// the low-level virtual file driver -// Exception H5::FileIException +// Param fapl - File access property list +// Param file_handle - Pointer to the file handle being used by +// the low-level virtual file driver +// Exception H5::FileIException // Programmer Binh-Minh Ribler - May 2004 // Modification // Planned for removal. -BMR, 2014/04/16 @@ -508,7 +508,7 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const /// It differs from the above function only in what arguments it /// accepts. ///\param file_handle - Pointer to the file handle being used by -/// the low-level virtual file driver +/// the low-level virtual file driver ///\exception H5::FileIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- @@ -547,7 +547,7 @@ hsize_t H5File::getFileSize() const ///\brief Get the id of this file ///\return File identifier // Modification -// May 2008 - BMR +// May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDS and Attribute are moved out of H5Object. In // addition, member IdComponent::id is moved into subclasses, and @@ -562,8 +562,8 @@ hid_t H5File::getId() const #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5File::reopen -// Purpose Reopens this file. -// Exception H5::FileIException +// Purpose Reopens this file. +// Exception H5::FileIException // Description // This function is replaced by the above function reOpen. // Programmer Binh-Minh Ribler - 2000 @@ -575,14 +575,15 @@ void H5File::reopen() //-------------------------------------------------------------------------- // Function: H5File::getLocId -// Purpose Get the id of this file +// Purpose Get the id of this file // Description // This function is a redefinition of CommonFG::getLocId. It // is used by CommonFG member functions to get the file id. // Programmer Binh-Minh Ribler - 2000 // Deprecated: -// After HDFFV-9920, the Group's methods can use getId() and getLocId() -// is kept for backward compatibility. Aug 18, 2016 -BMR +// Aug 18, 2016 -BMR +// After HDFFV-9920, the Group's methods can use getId() and +// getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- hid_t H5File::getLocId() const { @@ -626,13 +627,13 @@ void H5File::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Fclose(id); - if (ret_value < 0) - { - throw FileIException("H5File::close", "H5Fclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Fclose(id); + if (ret_value < 0) + { + throw FileIException("H5File::close", "H5Fclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } @@ -643,7 +644,7 @@ void H5File::close() ///\param msg - Message describing the failure ///\exception H5::FileIException // Description -// This function is also used in H5Location implementation so that +// This function is also used in H5Location implementation so that // proper exception can be thrown for file or group. The // "H5File::" will be inserted to indicate the function called is // an implementation of H5File. @@ -669,9 +670,9 @@ void H5File::throwException(const H5std_string& func_name, const H5std_string& m H5File::~H5File() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; + cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 5ac9118..df5cca6 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -17,7 +17,6 @@ #ifndef __H5File_H #define __H5File_H - namespace H5 { /*! \class H5File @@ -123,7 +122,8 @@ class H5_DLLCPP H5File : public Group { // constructors taking a string or a char* void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist); -}; -} +}; // end of H5File +} // namespace H5 + #endif // __H5File_H diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 2c925de..8affa1a 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -75,6 +75,8 @@ class H5_DLLCPP FloatType : public AtomType { // Noop destructor. virtual ~FloatType(); -}; -} + +}; // end of FloatType +} // namespace H5 + #endif // __H5FloatType_H diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 6e5cdaa..bb9e05d 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -113,14 +113,15 @@ void Group::closeObjId(hid_t obj_id) const //-------------------------------------------------------------------------- // Function: Group::getLocId -// Purpose: Get the id of this group +// Purpose: Get the id of this group // Programmer Binh-Minh Ribler - 2000 // Description // This function is a redefinition of CommonFG::getLocId. It // is used by CommonFG member functions to get the file id. // Deprecated: -// After HDFFV-9920, the Group's methods can use getId() and getLocId() -// is kept for backward compatibility. Aug 18, 2016 -BMR +// Aug 18, 2016 -BMR +// After HDFFV-9920, the Group's methods can use getId() and +// getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- hid_t Group::getLocId() const { @@ -227,13 +228,13 @@ void Group::close() { if (p_valid_id(id)) { - herr_t ret_value = H5Gclose(id); - if (ret_value < 0) - { - throwException("Group::close", "H5Gclose failed"); - } - // reset the id - id = H5I_INVALID_HID; + herr_t ret_value = H5Gclose(id); + if (ret_value < 0) + { + throwException("Group::close", "H5Gclose failed"); + } + // reset the id + id = H5I_INVALID_HID; } } @@ -270,10 +271,10 @@ void Group::throwException(const H5std_string& func_name, const H5std_string& ms Group::~Group() { try { - close(); + close(); } catch (Exception& close_error) { - cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; + cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 3118aa7..0f44eb9 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -84,7 +84,8 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { private: hid_t id; // HDF5 group id -}; -} +}; // end of Group +} // namespace H5 + #endif // __Group_H diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index b449d4a..0603e5c 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -123,6 +123,6 @@ class H5_DLLCPP IdComponent { #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end class IdComponent +} // namespace H5 -} #endif // __IdComponent_H diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index ae4b3df..1ce05c8 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -57,6 +57,8 @@ class H5_DLLCPP IntType : public AtomType { // Noop destructor. virtual ~IntType(); -}; -} + +}; // end of IntType +} // namespace H5 + #endif // __H5IntType_H diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index 1cb80f7..f31c3fc 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -69,6 +69,7 @@ class H5_DLLCPP LinkAccPropList : public PropList { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of LinkAccPropList +} // namespace H5 + #endif // __H5LinkAccPropList_H diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 018ba38..76b5f82 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -69,6 +69,7 @@ class H5_DLLCPP H5Library { ~H5Library(); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of H5Library +} // namespace H5 + #endif // __H5Library_H diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 337a2b3..3a0d8ca 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -220,7 +220,7 @@ class H5_DLLCPP H5Location : public IdComponent { // Noop destructor. virtual ~H5Location(); -}; /* end class H5Location */ +}; // end of H5Location +} // namespace H5 -} #endif // __H5Location_H diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index 866d739..53f183e 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -131,7 +131,7 @@ class H5_DLLCPP H5Object : public H5Location { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; /* end class H5Object */ +}; // end of H5Object +} // namespace H5 -} #endif // __H5Object_H diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 4858e07..c9c245a 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -72,6 +72,7 @@ class H5_DLLCPP ObjCreatPropList : public PropList { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of ObjCreatPropList +} // namespace H5 + #endif // __H5ObjCreatPropList_H diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index a8d6e37..2fd8a6b 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -438,6 +438,7 @@ class H5_DLLCPP PredType : public AtomType { #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of PredType +} // namespace H5 + #endif // __H5PredType_H diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index 3977774..0ceaabd 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -135,7 +135,8 @@ class H5_DLLCPP PropList : public IdComponent { friend void f_PropList_setId(PropList* plist, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS -}; -} +}; // end of PropList +} // namespace H5 + #endif // __H5PropList_H diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index 3272ad3..aa87bba 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -69,6 +69,8 @@ class H5_DLLCPP StrType : public AtomType { // Noop destructor. virtual ~StrType(); -}; -} + +}; // end of StrType +} // namespace H5 + #endif // __H5StrType_H diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index a93f44d..4dc0eb5 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -49,6 +49,8 @@ class H5_DLLCPP VarLenType : public DataType { // Default constructor VarLenType(); -}; -} + +}; // end of VarLenType +} // namespace H5 + #endif // __H5VarLenType_H diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index fce42fa..34e6892 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -503,9 +503,9 @@ void test_iterate() FileAccPropList fapl; fapl.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - test_iter_group(fapl); // Test iterating groups - test_HDFFV_9920(); // Test the fix of HDFFV-9920 - //test_iter_attr(fapl); // Test iterating attributes + test_iter_group(fapl); // Test iterating groups + test_HDFFV_9920(); // Test the fix of HDFFV-9920 + //test_iter_attr(fapl); // Test iterating attributes } // test_iterate diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index d8a0d5f..c232809 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -16,7 +16,7 @@ /***************************************************************************** FILE trefer.cpp - HDF5 C++ testing the functionalities associated with the C - Reference interface (H5R) + Reference interface (H5R) ***************************************************************************/ #ifdef OLD_HEADER_FILENAME @@ -93,7 +93,7 @@ test_reference_params(void) file1 = new H5File (FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -172,7 +172,7 @@ test_reference_params(void) catch (Exception& E) { issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -209,7 +209,7 @@ static void test_reference_obj(void) file1 = new H5File (FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create dataset access property list @@ -364,7 +364,7 @@ static void test_reference_obj(void) catch (Exception& E) { issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -493,7 +493,7 @@ test_reference_group(void) catch (Exception& E) { issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + E.getCFuncName(), E.getCDetailMsg()); } if(file1) @@ -523,10 +523,10 @@ test_reference_region_1D(void) SUBTEST("1-D Dataset Region Reference Functions"); try { - hdset_reg_ref_t *wbuf, // buffer to write to disk + hdset_reg_ref_t *wbuf, // buffer to write to disk *rbuf; // buffer read from disk - uint8_t *dwbuf, // Buffer for writing numeric data to disk - *drbuf; // Buffer for reading numeric data from disk + uint8_t *dwbuf, // Buffer for writing numeric data to disk + *drbuf; // Buffer for reading numeric data from disk // Allocate write & read buffers wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); @@ -538,7 +538,7 @@ test_reference_region_1D(void) H5File file1(FILE2, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; + hsize_t dims3[] = {SPACE3_DIM1}; DataSpace sid3(SPACE3_RANK, dims3); // Create dataset access property list @@ -558,7 +558,7 @@ test_reference_region_1D(void) dset3.close(); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset @@ -785,7 +785,7 @@ test_reference_region_1D(void) catch (Exception& E) { issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + E.getCFuncName(), E.getCDetailMsg()); } } /* test_reference_region_1D() */ diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 5dee1a2..859867b 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -57,7 +57,7 @@ static void *test_vlstr_alloc_custom(size_t size, void *info) { void *ret_value=NULL; // Pointer to return size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -91,7 +91,7 @@ static void test_vlstr_free_custom(void *_mem, void *info) { unsigned char *mem; size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -257,7 +257,7 @@ static void test_vlstring_array_dataset() for (ii = 0; ii < SPACE1_DIM1; ii++) { if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); HDfree(string_ds_check[ii]); } @@ -351,23 +351,26 @@ static void test_vlstrings_special() hsize_t ii; // counting variable for (ii=0; ii Date: Fri, 17 Mar 2017 16:20:24 -0500 Subject: Description: Deprecating versions of PropList::setProperty that have arguments that miss "const" Platforms tested: Linux/64 (jelly) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5PropList.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++- c++/src/H5PropList.h | 7 +++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index c4176c2..15e5865 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -565,8 +565,27 @@ size_t PropList::getNumProps() const ///\param name - IN: Name of property to set - \c char pointer ///\param value - IN: Void pointer to the value for the property ///\exception H5::PropListIException +// Description +// Revision svn r29815 changed 'value' to const, hence, deprecated +// the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- +void PropList::setProperty(const char* name, const void* value) const +{ + herr_t ret_value = H5Pset(id, name, value); + if (ret_value < 0) + { + throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief Deprecated dues to missing const in prototype. (1.10.1) +// Programmer: Binh-Minh Ribler - March, 2017 +// Modification +// Planned for removal. -BMR, 2017/03/17 1.10.1 +//-------------------------------------------------------------------------- void PropList::setProperty(const char* name, void* value) const { herr_t ret_value = H5Pset(id, name, value); @@ -575,6 +594,7 @@ void PropList::setProperty(const char* name, void* value) const throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } + //-------------------------------------------------------------------------- // Function: PropList::setProperty ///\brief This is an overloaded member function, provided for convenience. @@ -582,11 +602,14 @@ void PropList::setProperty(const char* name, void* value) const /// accepts. ///\param name - IN: Name of property to set - \c char pointer ///\param charptr - IN: Char pointer to the value for the property +// Description +// Revision svn r29815 changed 'value' to const, hence, deprecated +// the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- void PropList::setProperty(const char* name, const char* charptr) const { - herr_t ret_value = H5Pset(id, name, (void*)charptr); + herr_t ret_value = H5Pset(id, name, (const void*)charptr); if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); @@ -601,6 +624,18 @@ void PropList::setProperty(const char* name, const char* charptr) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- +void PropList::setProperty(const char* name, const H5std_string& strg) const +{ + setProperty(name, strg.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief Deprecated dues to missing const in prototype. (1.10.1) +// Programmer: Binh-Minh Ribler - March, 2017 +// Modification +// Planned for removal. -BMR, 2017/03/17 1.10.1 +//-------------------------------------------------------------------------- void PropList::setProperty(const char* name, H5std_string& strg) const { setProperty(name, strg.c_str()); @@ -615,6 +650,18 @@ void PropList::setProperty(const char* name, H5std_string& strg) const ///\param value - IN: Void pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- +void PropList::setProperty(const H5std_string& name, const void* value) const +{ + setProperty(name.c_str(), value); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief Deprecated dues to missing const in prototype. (1.10.1) +// Programmer: Binh-Minh Ribler - March, 2017 +// Modification +// Planned for removal. -BMR, 2017/03/17 1.10.1 +//-------------------------------------------------------------------------- void PropList::setProperty(const H5std_string& name, void* value) const { setProperty(name.c_str(), value); @@ -629,6 +676,18 @@ void PropList::setProperty(const H5std_string& name, void* value) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- +void PropList::setProperty(const H5std_string& name, const H5std_string& strg) const +{ + setProperty(name.c_str(), strg.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief Deprecated dues to missing const in prototype. (1.10.1) +// Programmer: Binh-Minh Ribler - March, 2017 +// Modification +// Planned for removal. -BMR, 2017/03/17 1.10.1 +//-------------------------------------------------------------------------- void PropList::setProperty(const H5std_string& name, H5std_string& strg) const { setProperty(name.c_str(), strg.c_str()); diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index 0ceaabd..772e96c 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -78,8 +78,13 @@ class H5_DLLCPP PropList : public IdComponent { H5std_string getProperty(const H5std_string& name) const; // Set a property's value in a property list. - void setProperty(const char* name, void* value) const; void setProperty(const char* name, const char* charptr) const; + void setProperty(const char* name, const void* value) const; + void setProperty(const char* name, const H5std_string& strg) const; + void setProperty(const H5std_string& name, const void* value) const; + void setProperty(const H5std_string& name, const H5std_string& strg) const; + // Deprecated after 1.10.1, missing const + void setProperty(const char* name, void* value) const; void setProperty(const char* name, H5std_string& strg) const; void setProperty(const H5std_string& name, void* value) const; void setProperty(const H5std_string& name, H5std_string& strg) const; -- cgit v0.12 From 5acc8b9e169e6416e353433791321bc9c4e7b725 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 17 Mar 2017 16:51:52 -0500 Subject: Description: Fixed typos. Platforms tested: Linux/64 (jelly) --- c++/src/H5PropList.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 15e5865..0df0a9f 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -581,7 +581,7 @@ void PropList::setProperty(const char* name, const void* value) const //-------------------------------------------------------------------------- // Function: PropList::setProperty -///\brief Deprecated dues to missing const in prototype. (1.10.1) +///\brief Deprecated due to missing const in prototype. (1.10.1) // Programmer: Binh-Minh Ribler - March, 2017 // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 @@ -631,7 +631,7 @@ void PropList::setProperty(const char* name, const H5std_string& strg) const //-------------------------------------------------------------------------- // Function: PropList::setProperty -///\brief Deprecated dues to missing const in prototype. (1.10.1) +///\brief Deprecated due to missing const in prototype. (1.10.1) // Programmer: Binh-Minh Ribler - March, 2017 // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 @@ -657,7 +657,7 @@ void PropList::setProperty(const H5std_string& name, const void* value) const //-------------------------------------------------------------------------- // Function: PropList::setProperty -///\brief Deprecated dues to missing const in prototype. (1.10.1) +///\brief Deprecated due to missing const in prototype. (1.10.1) // Programmer: Binh-Minh Ribler - March, 2017 // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 @@ -683,7 +683,7 @@ void PropList::setProperty(const H5std_string& name, const H5std_string& strg) c //-------------------------------------------------------------------------- // Function: PropList::setProperty -///\brief Deprecated dues to missing const in prototype. (1.10.1) +///\brief Deprecated due to missing const in prototype. (1.10.1) // Programmer: Binh-Minh Ribler - March, 2017 // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 -- cgit v0.12 From 34731511da3f3064b0f6e6681516be7b34d0bfbf Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Sat, 18 Mar 2017 23:40:37 -0500 Subject: Purpose: Add new C++ wrappers Description: Because H5Pset_file_space and H5Pget_file_space are deprecated, changed to make wrappers for the new functions instead: H5Ps/get_file_space_strategy H5Ps/get_file_space_page_size New wrappers in FileCreatPropList: // Sets the strategy and the threshold value that the library will // will employ in managing file space. void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; // Returns the strategy that the library uses in managing file space. void getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const; // Sets the file space page size for paged aggregation. void setFileSpacePagesize(hsize_t fsp_psize) const; // Returns the threshold value that the library uses in tracking free // space sections. hsize_t getFileSpacePagesize() const; Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5Attribute.cpp | 2 +- c++/src/H5FcreatProp.cpp | 63 +++++++++++++++++++++++++++--------------------- c++/src/H5FcreatProp.h | 9 ++++--- c++/test/tfile.cpp | 46 +++++++++++++++++++++++------------ 4 files changed, 73 insertions(+), 47 deletions(-) diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 6701f6e..c506906 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * -/* All rights reserved. * + * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index c490f26..893db64 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -295,7 +295,7 @@ unsigned FileCreatPropList::getIstorek() const } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::setFileSpace +// Function: FileCreatPropList::setFileSpaceStrategy ///\brief Sets the strategy and the threshold value that the library /// will employ in managing file space. ///\param strategy - IN: Strategy for file space management @@ -307,62 +307,71 @@ unsigned FileCreatPropList::getIstorek() const /// changed and the existing strategy will be retained. /// If the given threshold value is zero, the property will not be /// changed and the existing threshold will be retained. -/// Valid values of \a libver_low are as follows: -/// \li \c H5F_FILE_SPACE_ALL (Default) -/// \li \c H5F_FILE_SPACE_ALL_PERSIST -/// \li \c H5F_FILE_SPACE_AGGR_VFD -/// \li \c H5F_FILE_SPACE_VFD /// For information, please see the C layer Reference Manual at: /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetFileSpace // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const +void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const { - herr_t ret_value = H5Pset_file_space(id, strategy, threshold); + herr_t ret_value = H5Pset_file_space_strategy(id, strategy, persist, threshold); if (ret_value < 0) { - throw PropListIException("FileCreatPropList::setFileSpace", - "H5Pset_file_space failed"); + throw PropListIException("FileCreatPropList::setFileSpaceStrategy", + "H5Pset_file_space_strategy failed"); } } //-------------------------------------------------------------------------- // Function: FileCreatPropList::getFileSpaceStrategy -///\brief Returns the strategy that the library uses in managing file space. -///\return The strategy value +///\brief Retrieves the strategy, persist, and threshold that the library +/// uses in managing file space. ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -H5F_file_space_type_t FileCreatPropList::getFileSpaceStrategy() const +void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const { - H5F_file_space_type_t strategy = H5F_FILE_SPACE_ALL; - herr_t ret_value = H5Pget_file_space(id, &strategy, NULL); + herr_t ret_value = H5Pget_file_space_strategy(id, &strategy, &persist, &threshold); if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpaceStrategy", - "H5Pget_file_space for strategy failed"); + "H5Pget_file_space_strategy failed"); } - return(strategy); } //-------------------------------------------------------------------------- -// Function: FileCreatPropList::getFileSpaceThreshold -///\brief Returns the threshold value that the library uses in tracking -/// free space sections. -///\return The threshold value +// Function: FileCreatPropList::setFileSpacePagesize +///\brief Sets the file space page size for paged aggregation. ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getFileSpaceThreshold() const +void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const { - hsize_t threshold = 0; - herr_t ret_value = H5Pget_file_space(id, NULL, &threshold); + herr_t ret_value = H5Pset_file_space_page_size(id, fsp_psize); if (ret_value < 0) { - throw PropListIException("FileCreatPropList::getFileSpaceThreshold", - "H5Pget_file_space for threshold failed"); + throw PropListIException("FileCreatPropList::setFileSpacePagesize", + "H5Pset_file_space_page_size failed"); } - return(threshold); +} + +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getFileSpacePagesize +///\brief Returns the file space page size for aggregating small +/// metadata or raw data. +///\return File space page size +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Feb, 2017 +//-------------------------------------------------------------------------- +hsize_t FileCreatPropList::getFileSpacePagesize() const +{ + hsize_t fsp_psize = 0; + herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); + if (ret_value < 0) + { + throw PropListIException("FileCreatPropList::getFileSpacePagesize", + "H5Pget_file_space_page_size failed"); + } + return(fsp_psize); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index 7b594a3..6beac02 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -67,14 +67,17 @@ class H5_DLLCPP FileCreatPropList : public PropList { // Sets the strategy and the threshold value that the library will // will employ in managing file space. - void setFileSpace(H5F_file_space_type_t strategy, hsize_t threshold) const; + void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; // Returns the strategy that the library uses in managing file space. - H5F_file_space_type_t getFileSpaceStrategy() const; + void getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const; + + // Sets the file space page size for paged aggregation. + void setFileSpacePagesize(hsize_t fsp_psize) const; // Returns the threshold value that the library uses in tracking free // space sections. - hsize_t getFileSpaceThreshold() const; + hsize_t getFileSpacePagesize() const; ///\brief Returns this class name. virtual H5std_string fromClass() const { return("FileCreatPropList"); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index eb07657..78fab09 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -812,19 +812,17 @@ const H5std_string FILE7("tfile7.h5"); * *------------------------------------------------------------------------- */ +const hsize_t FSP_SIZE_DEF = 4096; +const hsize_t FSP_SIZE512 = 512; static void test_file_info() { // Output message about test being performed SUBTEST("File general information"); -#ifndef H5_NO_DEPRECATED_SYMBOLS - hsize_t in_threshold = 2; // Free space section threshold to set */ - hsize_t out_threshold = 0; // Free space section threshold to get */ - // File space handling strategy - H5F_file_space_type_t in_strategy = H5F_FILE_SPACE_ALL; + hsize_t out_threshold = 0; // Free space section threshold to get + hbool_t out_persist = FALSE;// Persist free-space read // File space handling strategy - H5F_file_space_type_t out_strategy = H5F_FILE_SPACE_DEFAULT; -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5F_fspace_strategy_t out_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; try { // Create a file using default properties. @@ -843,14 +841,30 @@ static void test_file_info() // Create file creation property list. FileCreatPropList fcpl; + // Retrieve file space information. + fcpl.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); + + // Verify file space information. + verify_val(out_strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(out_persist, FALSE, "H5File::getFileInfo", __LINE__, __FILE__); + verify_val(out_threshold, 1, "H5File::getFileInfo", __LINE__, __FILE__); + + /* Retrieve file space page size */ + hsize_t out_fsp_psize = fcpl.getFileSpacePagesize(); + verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); + // Set various file information. fcpl.setUserblock(F2_USERBLOCK_SIZE); fcpl.setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); fcpl.setIstorek(F2_ISTORE); -#ifndef H5_NO_DEPRECATED_SYMBOLS - fcpl.setFileSpace(in_strategy, in_threshold); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + hsize_t threshold = 5; // Free space section threshold to set + hbool_t persist = TRUE; // Persist free-space to set + H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE; + + fcpl.setFileSpaceStrategy(strategy, persist, threshold); + fcpl.setFileSpacePagesize(FSP_SIZE512); // Creating a file with the non-default file creation property list // should create a version 1 superblock @@ -912,14 +926,14 @@ static void test_file_info() VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); */ -#ifndef H5_NO_DEPRECATED_SYMBOLS // Get and verify the file space info from the creation property list */ - out_strategy = fcpl2.getFileSpaceStrategy(); - verify_val(static_cast(out_strategy), static_cast(in_strategy), "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); + fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); + verify_val(out_strategy, strategy, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); + verify_val(out_persist, persist, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); + verify_val(out_threshold, threshold, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__); - out_threshold = fcpl2.getFileSpaceThreshold(); - verify_val(static_cast(out_threshold), static_cast(in_threshold), "FileCreatPropList::getFileSpaceThreshold", __LINE__, __FILE__); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + out_fsp_psize = fcpl2.getFileSpacePagesize(); + verify_val(out_fsp_psize, FSP_SIZE512, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); PASSED(); } // end of try block -- cgit v0.12 From b6cb20d608aa6f5d9a7d825c1f38cfcea6ff5234 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Sun, 19 Mar 2017 22:57:47 -0500 Subject: Description: Removed "#ifndef H5_NO_DEPRECATED_SYMBOLS" in file space tests, because the wrappers only use the latest functions now. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/test/tfile.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 78fab09..715bb30 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -877,11 +877,7 @@ static void test_file_info() // Get the file's version information. file7.getFileInfo(finfo); -#ifndef H5_NO_DEPRECATED_SYMBOLS verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - verify_val(finfo.super.version, 1, "H5File::getFileInfo", __LINE__, __FILE__); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); @@ -896,11 +892,7 @@ static void test_file_info() // Get the file's version information. file7.getFileInfo(finfo); -#ifndef H5_NO_DEPRECATED_SYMBOLS verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - verify_val(finfo.super.version, 1, "H5File::getFileInfo", __LINE__, __FILE__); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__); -- cgit v0.12