Skip to content
Snippets Groups Projects
Commit 22327aeb authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

git subrepo pull packages/HighFive

subrepo:
  subdir:   "packages/HighFive"
  merged:   "dfc06537f"
upstream:
  origin:   "git@github.com:BlueBrain/HighFive.git"
  branch:   "master"
  commit:   "dfc06537f"
git-subrepo:
  version:  "0.4.9"
  origin:   "git@github.com:ingydotnet/git-subrepo.git"
  commit:   "30db3b8"
parent fa321c14
Branches
No related tags found
1 merge request!203git subrepo pull packages/HighFive
Showing
with 314 additions and 282 deletions
...@@ -16,5 +16,10 @@ fi ...@@ -16,5 +16,10 @@ fi
for f in "${examples_dir}"/*_bin for f in "${examples_dir}"/*_bin
do do
echo "-- ${f}" echo "-- ${f}"
if [[ "${f}" == *"parallel_"* ]]
then
mpiexec -np 2 "${f}"
else
"${f}" "${f}"
fi
done done
...@@ -58,6 +58,9 @@ jobs: ...@@ -58,6 +58,9 @@ jobs:
- config: - config:
os: ubuntu-22.04 os: ubuntu-22.04
flags: '-DHIGHFIVE_TEST_BOOST=Off -DCMAKE_CXX_STANDARD=20 -DHIGHFIVE_HAS_CONCEPTS=On' flags: '-DHIGHFIVE_TEST_BOOST=Off -DCMAKE_CXX_STANDARD=20 -DHIGHFIVE_HAS_CONCEPTS=On'
- config:
os: ubuntu-24.04
flags: '-DHIGHFIVE_TEST_BOOST=Off -DCMAKE_CXX_STANDARD=20 -DHIGHFIVE_HAS_CONCEPTS=On'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
...@@ -89,6 +92,9 @@ jobs: ...@@ -89,6 +92,9 @@ jobs:
run: | run: |
! ctest --verbose -C $BUILD_TYPE | grep HDF5-DIAG ! ctest --verbose -C $BUILD_TYPE | grep HDF5-DIAG
- name: Examples
working-directory: ${{github.workspace}}/build/src/examples
run: $GITHUB_WORKSPACE/.github/run_examples.sh
# Job testing several versions of hdf5 # Job testing several versions of hdf5
# =================================================== # ===================================================
...@@ -96,7 +102,7 @@ jobs: ...@@ -96,7 +102,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
hdf5_version : [ hdf5-1_8_23, hdf5-1_10_11, hdf5-1_12_3, hdf5_1.14.4.1 ] hdf5_version : [ hdf5-1_8_23, hdf5-1_10_11, hdf5-1_12_3, hdf5_1.14.5 ]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
...@@ -133,7 +139,6 @@ jobs: ...@@ -133,7 +139,6 @@ jobs:
run: | run: |
! ctest --verbose -C $BUILD_TYPE | grep HDF5-DIAG ! ctest --verbose -C $BUILD_TYPE | grep HDF5-DIAG
- name: Examples - name: Examples
working-directory: ${{github.workspace}}/build/src/examples working-directory: ${{github.workspace}}/build/src/examples
run: $GITHUB_WORKSPACE/.github/run_examples.sh run: $GITHUB_WORKSPACE/.github/run_examples.sh
...@@ -184,13 +189,13 @@ jobs: ...@@ -184,13 +189,13 @@ jobs:
# Job running unit-test with sanitizers # Job running unit-test with sanitizers
# ===================================== # =====================================
Linux_Sanitizers: Linux_Sanitizers:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
env: [ env: [
{CC: clang-12, CXX: clang++-12, HIGHFIVE_SANITIZER: address}, {CC: clang, CXX: clang++, HIGHFIVE_SANITIZER: address},
{CC: clang-12, CXX: clang++-12, HIGHFIVE_SANITIZER: undefined}, {CC: clang, CXX: clang++, HIGHFIVE_SANITIZER: undefined},
{CC: gcc-10, CXX: g++-10, HIGHFIVE_GLIBCXX_ASSERTIONS: On}, {CC: gcc, CXX: g++, HIGHFIVE_GLIBCXX_ASSERTIONS: On},
] ]
steps: steps:
...@@ -201,7 +206,7 @@ jobs: ...@@ -201,7 +206,7 @@ jobs:
- name: "Install libraries" - name: "Install libraries"
run: | run: |
sudo apt-get -qq update sudo apt-get -qq update
sudo apt-get -qq install libboost-all-dev libeigen3-dev libhdf5-dev libsz2 ninja-build sudo apt-get -qq install boost1.83 libeigen3-dev libhdf5-dev libsz2 ninja-build
- name: Build - name: Build
env: ${{matrix.env}} env: ${{matrix.env}}
...@@ -209,6 +214,7 @@ jobs: ...@@ -209,6 +214,7 @@ jobs:
CMAKE_OPTIONS=( CMAKE_OPTIONS=(
-GNinja -GNinja
-DHIGHFIVE_TEST_BOOST:BOOL=ON -DHIGHFIVE_TEST_BOOST:BOOL=ON
-DHIGHFIVE_TEST_BOOST_SPAN:BOOL=ON
-DHIGHFIVE_TEST_EIGEN:BOOL=ON -DHIGHFIVE_TEST_EIGEN:BOOL=ON
-DHIGHFIVE_BUILD_DOCS:BOOL=FALSE -DHIGHFIVE_BUILD_DOCS:BOOL=FALSE
-DHIGHFIVE_GLIBCXX_ASSERTIONS=${HIGHFIVE_GLIBCXX_ASSERTIONS:-OFF} -DHIGHFIVE_GLIBCXX_ASSERTIONS=${HIGHFIVE_GLIBCXX_ASSERTIONS:-OFF}
...@@ -297,9 +303,6 @@ jobs: ...@@ -297,9 +303,6 @@ jobs:
cxxstd: ["14", "17", "20"] cxxstd: ["14", "17", "20"]
include: include:
- os: "macOS-12"
cxxstd: "14"
- os: "macOS-13" - os: "macOS-13"
cxxstd: "20" cxxstd: "20"
......
...@@ -20,18 +20,4 @@ jobs: ...@@ -20,18 +20,4 @@ jobs:
- name: Run clang-format - name: Run clang-format
run: | run: |
clang-format --version bash bin/format.sh
for i in $(git ls-files | grep ".[ch]pp$");
do
clang-format -i "$i" > /dev/null 2>&1;
done
modified_files=$(git diff --name-only)
if [ -n "$modified_files" ];
then
echo "Some files are not well formatted:"
echo $modified_files
echo ""
echo "The diff is:"
git diff
exit 1
fi
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
[subrepo] [subrepo]
remote = git@github.com:BlueBrain/HighFive.git remote = git@github.com:BlueBrain/HighFive.git
branch = master branch = master
commit = 20fbd4c4d328bc18a342eeef5ffd29f17de084e0 commit = dfc06537fdb20f5e572c20bc6febd22dd5d08246
parent = 35908346b20b524d4d2d9f8f6220800c27595413 parent = fa321c14d4206f8183fc9029ee9bd0d216ce700b
method = merge method = merge
cmdver = 0.4.6 cmdver = 0.4.9
# Changes # Changes
## Version 3.0.0-beta2 - 2024-12-04
### New Features
- Support `boost::span`. (#1025)
### Bug Fix
- Fix for not-quite null-terminated, fixed-length strings. (#1056)
- Guard target creation in `*Config.cmake`. (#1053)
## Version 3.0.0-beta1 - 2024-07-16
This version is a major one and is breaking some usage compare to v2.
Read the migration guide from the documentation: https://bluebrain.github.io/HighFive/md__2home_2runner_2work_2_high_five_2_high_five_2doc_2migration__guide.html
The minimum version for C++ has been moved to `C++14`.
### Removed
- Removed `read(T*, ...)`, use explicit `read_raw(T*, ...)` for `Slice` or `Attribute`. (#928)
- Removed `FixedLenStringArray`, use any container with strings instead. (#932)
- Removed `FileDriver` and `MPIOFileDriver`, use file access properties instead. (#949)
- Removed default constructor for `Group` and `DataSet`. (#947, #948)
- Broadcasting have been removed. Use `squeeze` and `reshape` feature instead. (#992)
- `ObjectCreateProps` and `ObjectAccessProps` those don't map well to HighFive and are unused. (#1002)
### New Features
- Added support for `std::span`. (#987)
- Added `squeezeMemSpace` and `reshapeMemSpace` for `Attribute` and `Slice` to reshape the memory space. (#991)
- Added `ProductSet` to select a Cartesian products of (generalized) slices. (#842)
### Improvements
- Optimized chained hyperslab selection. (#1031)
- Type `T[N]` or `T[N][M]` will work better. (#929)
- `DataspaceType` is now an enum class for `dataspace_scalar` or `dataspace_null`. (#900)
- `File::AccessMode` is now an enum class. (#1020)
## Version 2.9.0 - 2024-01-25 ## Version 2.9.0 - 2024-01-25
### New Features ### New Features
- Add named ctors for scalar and null dataspaces. (#899) - Add named ctors for scalar and null dataspaces. (#899)
......
...@@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.13) ...@@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.13)
cmake_policy(VERSION 3.13) cmake_policy(VERSION 3.13)
project(HighFive VERSION 3.0.0) project(HighFive VERSION 3.0.0)
set(HIGHFIVE_VERSION_PRERELEASE 2)
message(WARNING "=================================================================\n"
"HighFive development moved to:\n"
" github.com/highfive-devs/highfive\n"
"=================================================================")
# Configure HighFive # Configure HighFive
# ------------------ # ------------------
...@@ -58,12 +64,13 @@ option(HIGHFIVE_UNIT_TESTS "Compile unit-tests" ${HIGHFIVE_EXTRAS_DEFAULT}) ...@@ -58,12 +64,13 @@ option(HIGHFIVE_UNIT_TESTS "Compile unit-tests" ${HIGHFIVE_EXTRAS_DEFAULT})
option(HIGHFIVE_EXAMPLES "Compile examples" ${HIGHFIVE_EXTRAS_DEFAULT}) option(HIGHFIVE_EXAMPLES "Compile examples" ${HIGHFIVE_EXTRAS_DEFAULT})
option(HIGHFIVE_BUILD_DOCS "Build documentation" ${HIGHFIVE_EXTRAS_DEFAULT}) option(HIGHFIVE_BUILD_DOCS "Build documentation" ${HIGHFIVE_EXTRAS_DEFAULT})
option(HIGHFIVE_TEST_SPAN "Enable std::span testing, requires C++20" ${HIGHFIVE_TEST_SPAN_DEFAULT}) option(HIGHFIVE_TEST_SPAN "Enable testing std::span, requires C++20" ${HIGHFIVE_TEST_SPAN_DEFAULT})
option(HIGHFIVE_TEST_BOOST "Enable Boost testing" OFF) option(HIGHFIVE_TEST_BOOST "Enable testing Boost features" OFF)
option(HIGHFIVE_TEST_EIGEN "Enable Eigen testing" OFF) option(HIGHFIVE_TEST_BOOST_SPAN "Additionally, enable testing `boost::span`" OFF)
option(HIGHFIVE_TEST_OPENCV "Enable OpenCV testing" OFF) option(HIGHFIVE_TEST_EIGEN "Enable testing Eigen" OFF)
option(HIGHFIVE_TEST_XTENSOR "Enable xtensor testing" OFF) option(HIGHFIVE_TEST_OPENCV "Enable testing OpenCV" OFF)
option(HIGHFIVE_TEST_HALF_FLOAT "Enable half-precision floats" OFF) option(HIGHFIVE_TEST_XTENSOR "Enable testing xtensor" OFF)
option(HIGHFIVE_TEST_HALF_FLOAT "Enable testing half-precision floats" OFF)
# TODO remove entirely. # TODO remove entirely.
option(HIGHFIVE_HAS_CONCEPTS "Print readable compiler errors w/ C++20 concepts" OFF) option(HIGHFIVE_HAS_CONCEPTS "Print readable compiler errors w/ C++20 concepts" OFF)
...@@ -155,6 +162,7 @@ install(FILES ...@@ -155,6 +162,7 @@ install(FILES
if(HIGHFIVE_EXAMPLES OR HIGHFIVE_UNIT_TESTS) if(HIGHFIVE_EXAMPLES OR HIGHFIVE_UNIT_TESTS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HighFiveWarnings.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HighFiveWarnings.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HighFiveFlags.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HighFiveOptionalDependencies.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HighFiveOptionalDependencies.cmake)
endif() endif()
......
*Note:* In preparation of `v3` of HighFive, we've started merging breaking > [!WARNING]
changes into the main branch. More information and opportunity to comment can > The Blue Brain Project concluded in December 2024, so the HighFive development is ceased under the BlueBrain GitHub organization.
be found at: >
https://github.com/BlueBrain/HighFive/issues/864 > The development of HighFive will continue at:
> https://github.com/highfive-devs/highfive
# HighFive - HDF5 header-only C++ Library # HighFive - HDF5 header-only C++ Library
[![Doxygen -> gh-pages](https://github.com/BlueBrain/HighFive/workflows/gh-pages/badge.svg?branch=master)](https://BlueBrain.github.io/HighFive/actions/workflows/gh-pages.yml?query=branch%3Amaster)
[![codecov](https://codecov.io/gh/BlueBrain/HighFive/branch/master/graph/badge.svg?token=UBKxHEn7RS)](https://codecov.io/gh/BlueBrain/HighFive)
[![HighFive_Integration_tests](https://github.com/BlueBrain/HighFive-testing/actions/workflows/integration.yml/badge.svg)](https://github.com/BlueBrain/HighFive-testing/actions/workflows/integration.yml)
[![Zenodo](https://zenodo.org/badge/47755262.svg)](https://zenodo.org/doi/10.5281/zenodo.10679422)
Documentation: https://bluebrain.github.io/HighFive/ Documentation: https://bluebrain.github.io/HighFive/
## Brief ## Brief
...@@ -23,15 +19,16 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig ...@@ -23,15 +19,16 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig
### Design ### Design
- Simple C++-ish minimalist interface - Simple C++-ish minimalist interface
- No other dependency than libhdf5 - Only hard dependency is libhdf5
- Zero overhead - Zero/low overhead, when possible
- Support C++14 - RAII for opening/closing files, groups, datasets, etc.
- Written in C++14
### Feature support ### Feature support
- create/read/write files, datasets, attributes, groups, dataspaces. - create/read/write files, datasets, attributes, groups, dataspaces.
- automatic memory management / ref counting - automatic memory management / ref counting
- automatic conversion of `std::vector` and nested `std::vector` from/to any dataset with basic types - automatic conversion of `std::vector` and nested `std::vector` from/to any dataset with basic types
- automatic conversion of `std::string` to/from variable length string dataset - automatic conversion of `std::string` to/from variable- or fixed-length string dataset
- selection() / slice support - selection() / slice support
- parallel Read/Write operations from several nodes with Parallel HDF5 - parallel Read/Write operations from several nodes with Parallel HDF5
- Advanced types: Compound, Enum, Arrays of Fixed-length strings, References - Advanced types: Compound, Enum, Arrays of Fixed-length strings, References
...@@ -41,212 +38,45 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig ...@@ -41,212 +38,45 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig
### Dependencies ### Dependencies
- HDF5 or pHDF5, including headers - HDF5 or pHDF5, including headers
- boost >= 1.41 (recommended) - boost (optional)
- eigen3 (optional) - eigen3 (optional)
- xtensor (optional) - xtensor (optional)
- half (optional) - half (optional)
### Known flaws The releases for versions 2.x.y and two prereleases of v3 can be found at:
- HighFive is not thread-safe. At best it has the same limitations as the HDF5 library. However, HighFive objects modify their members without protecting these writes. Users have reported that HighFive is not thread-safe even when using the threadsafe HDF5 library, e.g., https://github.com/BlueBrain/HighFive/discussions/675. * https://github.com/BlueBrain/HighFive/releases
- Eigen support in core HighFive was broken until v3.0. See https://github.com/BlueBrain/HighFive/issues/532. H5Easy was not * https://zenodo.org/doi/10.5281/zenodo.10679422
affected.
- The support of fixed length strings isn't ideal.
The state of HighFive immediately before preparing it for archival is:
* https://github.com/BlueBrain/HighFive/tree/v3.0.0-beta2
## Examples All future development and new releases can be found at:
* https://github.com/highfive-devs/highfive
#### Write a std::vector<int> to 1D HDF5 dataset and read it back ## Example
```c++ ```c++
#include <highfive/highfive.hpp>
using namespace HighFive; using namespace HighFive;
std::string filename = "/tmp/new_file.h5"; File file("foo.h5", File::Truncate);
{ {
// We create an empty HDF55 file, by truncating an existing
// file if required:
File file(filename, File::Truncate);
std::vector<int> data(50, 1); std::vector<int> data(50, 1);
file.createDataSet("grp/data", data); file.createDataSet("grp/data", data);
} }
{ {
// We open the file as read-only:
File file(filename, File::ReadOnly);
auto dataset = file.getDataSet("grp/data"); auto dataset = file.getDataSet("grp/data");
// Read back, with allocating: // Read back, automatically allocating:
auto data = dataset.read<std::vector<int>>(); auto data = dataset.read<std::vector<int>>();
// Because `data` has the correct size, this will // Alternatively, if `data` has the correct
// not cause `data` to be reallocated: // size, without reallocation:
dataset.read(data); dataset.read(data);
} }
``` ```
**Note:** As of 2.8.0, one can use `highfive/highfive.hpp` to include
everything HighFive. Prior to 2.8.0 one would include `highfive/H5File.hpp`.
**Note:** For advanced usecases the dataset can be created without immediately
writing to it. This is common in MPI-IO related patterns, or when growing a
dataset over the course of a simulation.
#### Write a 2 dimensional C double float array to a 2D HDF5 dataset
See [create_dataset_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_dataset_double.cpp)
#### Write and read a matrix of double float (boost::ublas) to a 2D HDF5 dataset
See [boost_ublas_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/boost_ublas_double.cpp)
#### Write and read a subset of a 2D double dataset
See [select_partial_dataset_cpp11.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/select_partial_dataset_cpp11.cpp)
#### Create, write and list HDF5 attributes
See [create_attribute_string_integer.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_attribute_string_integer.cpp)
#### And others
See [src/examples/](https://github.com/BlueBrain/HighFive/blob/master/src/examples/) subdirectory for more info.
### H5Easy
For several 'standard' use cases the [highfive/H5Easy.hpp](include/highfive/H5Easy.hpp) interface is available. It allows:
* Reading/writing in a single line of:
- scalars (to/from an extendible DataSet),
- strings,
- vectors (of standard types),
- [Eigen::Matrix](http://eigen.tuxfamily.org) (optional),
- [xt::xarray](https://github.com/QuantStack/xtensor) and [xt::xtensor](https://github.com/QuantStack/xtensor)
(optional).
- [cv::Mat_](https://docs.opencv.org/master/df/dfc/classcv_1_1Mat__.html)
(optional).
* Getting in a single line:
- the size of a DataSet,
- the shape of a DataSet.
#### Example
```cpp
#include <highfive/H5Easy.hpp>
int main() {
H5Easy::File file("example.h5", H5Easy::File::Overwrite);
int A = ...;
H5Easy::dump(file, "/path/to/A", A);
A = H5Easy::load<int>(file, "/path/to/A");
}
```
whereby the `int` type of this example can be replaced by any of the above
types. See [easy_load_dump.cpp](src/examples/easy_load_dump.cpp) for more
details.
**Note:** Classes such as `H5Easy::File` are just short for the regular
`HighFive` classes (in this case `HighFive::File`). They can thus be used
interchangeably.
## CMake integration
There's two common paths of integrating HighFive into a CMake based project.
The first is to "vendor" HighFive, the second is to install HighFive as a
normal C++ library. Since HighFive makes choices about how to integrate HDF5,
sometimes following the third Bailout Approach is needed.
Regular HDF5 CMake variables can be used. Interesting variables include:
* `HDF5_USE_STATIC_LIBRARIES` to link statically against the HDF5 library.
* `HDF5_PREFER_PARALLEL` to prefer pHDF5.
* `HDF5_IS_PARALLEL` to check if HDF5 is parallel.
Please consult `tests/cmake_integration` for examples of how to write libraries
or applications using HighFive.
### Vendoring HighFive
In this approach the HighFive sources are included in a subdirectory of the
project (typically as a git submodule), for example in `third_party/HighFive`.
The projects `CMakeLists.txt` add the following lines
```cmake
add_subdirectory(third_party/HighFive)
target_link_libraries(foo HighFive)
```
**Note:** `add_subdirectory(third_party/HighFive)` will search and "link" HDF5
but wont search or link any optional dependencies such as Boost.
### Regular Installation of HighFive
Alternatively, HighFive can be install and "found" like regular software.
The project's `CMakeLists.txt` should add the following:
```cmake
find_package(HighFive REQUIRED)
target_link_libraries(foo HighFive)
```
**Note:** `find_package(HighFive)` will search for HDF5. "Linking" to
`HighFive` includes linking with HDF5. The two commands will not search for or
"link" to optional dependencies such as Boost.
### Bailout Approach
To prevent HighFive from searching or "linking" to HDF5 the project's
`CMakeLists.txt` should contain the following:
```cmake
# Prevent HighFive CMake code from searching for HDF5:
set(HIGHFIVE_FIND_HDF5 Off)
# Then "find" HighFive as usual:
find_package(HighFive REQUIRED)
# alternatively, when vendoring:
# add_subdirectory(third_party/HighFive)
# Finally, use the target `HighFive::Include` which
# doesn't add a dependency on HDF5.
target_link_libraries(foo HighFive::Include)
# Proceed to find and link HDF5 as required.
```
### Optional Dependencies
HighFive does not attempt to find or "link" to any optional dependencies, such
as Boost, Eigen, etc. Any project using HighFive with any of the optional
dependencies must include the respective header:
```
#include <highfive/boost.hpp>
#include <highfive/eigen.hpp>
```
and add the required CMake code to find and link against the dependencies. For
Boost the required lines might be
```
find_package(Boost REQUIRED)
target_link_libraries(foo PUBLIC Boost::headers)
```
# Questions?
Do you have questions on how to use HighFive? Would you like to share an interesting example or
discuss HighFive features? Head over to the [Discussions](https://github.com/BlueBrain/HighFive/discussions)
forum and join the community.
For bugs and issues please use [Issues](https://github.com/BlueBrain/HighFive/issues).
# Funding & Acknowledgment # Funding & Acknowledgment
The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government's ETH Board of the Swiss Federal Institutes of Technology. The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government's ETH Board of the Swiss Federal Institutes of Technology.
...@@ -255,7 +85,7 @@ HighFive releases are uploaded to Zenodo. If you wish to cite HighFive in a ...@@ -255,7 +85,7 @@ HighFive releases are uploaded to Zenodo. If you wish to cite HighFive in a
scientific publication you can use the DOIs for the scientific publication you can use the DOIs for the
[Zenodo records](https://zenodo.org/doi/10.5281/zenodo.10679422). [Zenodo records](https://zenodo.org/doi/10.5281/zenodo.10679422).
Copyright © 2015-2022 Blue Brain Project/EPFL Copyright © 2015-2024 Blue Brain Project/EPFL
### License ### License
......
#!/usr/bin/env bash
set -euo pipefail
clang_format_version="19.1.3"
script_dir="$(dirname "${BASH_SOURCE[0]}")"
venv_dir="$script_dir/../.clang-format-venv"
if [ ! -d "$venv_dir" ]; then
python3 -m venv "$venv_dir"
source "$venv_dir/bin/activate"
pip install clang-format=="$clang_format_version"
deactivate
fi
source "$venv_dir/bin/activate"
# Check if the installed version matches the expected version
installed_version="$(pip show clang-format | grep Version | cut -d ' ' -f 2)"
if [ "$installed_version" != "$clang_format_version" ]; then
echo "Error: clang-format version mismatch. Expected $clang_format_version, got $installed_version"
echo "Please remove the virtual environment and run the script again:"
echo " rm -r \"$venv_dir\" && \"$0\""
exit 1
fi
clang-format --version
for i in $(git ls-files | grep ".[ch]pp$"); do
clang-format -i "$i" > /dev/null 2>&1
done
modified_files=$(git diff --name-only)
if [ -n "$modified_files" ]; then
echo "Some files are not well formatted:"
echo "$modified_files"
echo ""
echo "The diff is:"
git --no-pager diff
echo ""
echo "To correct the formatting run:"
echo " $0"
exit 1
fi
...@@ -8,6 +8,7 @@ if(HIGHFIVE_FIND_HDF5) ...@@ -8,6 +8,7 @@ if(HIGHFIVE_FIND_HDF5)
find_dependency(HDF5) find_dependency(HDF5)
endif() endif()
if(NOT TARGET HighFive)
include("${CMAKE_CURRENT_LIST_DIR}/HighFiveTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/HighFiveTargets.cmake")
if(HDF5_IS_PARALLEL) if(HDF5_IS_PARALLEL)
...@@ -17,3 +18,6 @@ endif() ...@@ -17,3 +18,6 @@ endif()
add_library(HighFive ALIAS HighFive::HighFive) add_library(HighFive ALIAS HighFive::HighFive)
add_library(HighFiveInclude ALIAS HighFive::Include) add_library(HighFiveInclude ALIAS HighFive::Include)
endif()
if(TARGET HighFiveFlags)
# Allow multiple `include(HighFiveWarnings)`, which would
# attempt to redefine `HighFiveWarnings` and fail without
# this check.
return()
endif()
add_library(HighFiveFlags INTERFACE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(HIGHFIVE_MAX_ERRORS)
target_compile_options(HighFiveFlags
INTERFACE
-fmax-errors=${HIGHFIVE_MAX_ERRORS}
)
endif()
endif()
if(HIGHFIVE_GLIBCXX_ASSERTIONS)
target_compile_definitions(HighFiveFlags INTERFACE -D_GLIBCXX_ASSERTIONS)
endif()
if(HIGHFIVE_HAS_FRIEND_DECLARATIONS)
target_compile_definitions(HighFiveFlags INTERFACE -DHIGHFIVE_HAS_FRIEND_DECLARATIONS=1)
endif()
if(HIGHFIVE_SANITIZER)
target_compile_options(HighFiveFlags INTERFACE -fsanitize=${HIGHFIVE_SANITIZER})
target_link_options(HighFiveFlags INTERFACE -fsanitize=${HIGHFIVE_SANITIZER})
endif()
...@@ -7,6 +7,9 @@ if(NOT TARGET HighFiveBoostDependency) ...@@ -7,6 +7,9 @@ if(NOT TARGET HighFiveBoostDependency)
# -DBOOST_ALL_NO_LIB (does something on MSVC). # -DBOOST_ALL_NO_LIB (does something on MSVC).
target_compile_definitions(HighFiveBoostDependency INTERFACE HIGHFIVE_TEST_BOOST=1) target_compile_definitions(HighFiveBoostDependency INTERFACE HIGHFIVE_TEST_BOOST=1)
endif() endif()
if(HIGHFIVE_TEST_BOOST_SPAN)
target_compile_definitions(HighFiveBoostDependency INTERFACE HIGHFIVE_TEST_BOOST_SPAN=1)
endif()
endif() endif()
if(NOT TARGET HighFiveEigenDependency) if(NOT TARGET HighFiveEigenDependency)
......
...@@ -6,7 +6,6 @@ if(TARGET HighFiveWarnings) ...@@ -6,7 +6,6 @@ if(TARGET HighFiveWarnings)
endif() endif()
add_library(HighFiveWarnings INTERFACE) add_library(HighFiveWarnings INTERFACE)
add_library(HighFiveFlags INTERFACE)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
...@@ -48,11 +47,3 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") ...@@ -48,11 +47,3 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(HIGHFIVE_MAX_ERRORS)
target_compile_options(HighFiveFlags
INTERFACE
-fmax-errors=${HIGHFIVE_MAX_ERRORS}
)
endif()
endif()
catch2 @ fa43b774
Subproject commit 4e8d92bf02f7d1c8006a0e7a5ecabd8e62d98502 Subproject commit fa43b77429ba76c462b1898d6cd2f2d7a9416b14
...@@ -41,22 +41,16 @@ tests. ...@@ -41,22 +41,16 @@ tests.
### Code formatting ### Code formatting
The project is formatted using clang-format version 12.0.1 and CI will complain The project is formatted using clang-format version 12.0.1 and CI will complain
if a commit isn't formatted accordingly. The `.clang-format` is at the root of if a commit isn't formatted accordingly. The `.clang-format` is at the root of
the git repository. Conveniently, `clang-format` is available via `pip`: the git repository. Conveniently, `clang-format` is available via `pip`.
Formatting the entire code base can be done with:
```bash ```bash
python -m venv venv bin/format.sh
source venv/bin/activate
pip install clang-format==12.0.1
``` ```
which will install the required version of clang-format in a venv called
`.clang-format-venv`.
The changed lines can be formatted with `git-clang-format`, e.g. to format all lines changed compared to master: To format only the changed files `git-clang-format` can be used.
```bash
git-clang-format master
```
(add `-f` to allow formatting unstaged changes if you trust it to not destroy
your changes.)
## Releasing HighFive ## Releasing HighFive
Before releasing a new version perform the following: Before releasing a new version perform the following:
......
...@@ -805,6 +805,8 @@ html.dark-mode iframe#MSearchResults { ...@@ -805,6 +805,8 @@ html.dark-mode iframe#MSearchResults {
#nav-tree .item { #nav-tree .item {
height: var(--tree-item-height); height: var(--tree-item-height);
line-height: var(--tree-item-height); line-height: var(--tree-item-height);
overflow: hidden;
text-overflow: ellipsis;
} }
#nav-tree .item > a:focus { #nav-tree .item > a:focus {
...@@ -823,6 +825,8 @@ html.dark-mode iframe#MSearchResults { ...@@ -823,6 +825,8 @@ html.dark-mode iframe#MSearchResults {
background-image: none; background-image: none;
background-color: transparent; background-color: transparent;
position: relative; position: relative;
color: var(--primary-color) !important;
font-weight: 500;
} }
#nav-tree .selected::after { #nav-tree .selected::after {
...@@ -1749,7 +1753,7 @@ table.fieldtable th { ...@@ -1749,7 +1753,7 @@ table.fieldtable th {
color: var(--tablehead-foreground); color: var(--tablehead-foreground);
} }
table.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fielddoc, .fieldtable th { table.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fieldinit, .fieldtable td.fielddoc, .fieldtable th {
border-bottom: 1px solid var(--separator-color); border-bottom: 1px solid var(--separator-color);
border-right: 1px solid var(--separator-color); border-right: 1px solid var(--separator-color);
} }
......
...@@ -133,7 +133,7 @@ target_link_libraries(add PUBLIC boost::boost) ...@@ -133,7 +133,7 @@ target_link_libraries(add PUBLIC boost::boost)
# For HighFive there's two options for adding `-I ${HIGHFIVE_DIR}` and the # For HighFive there's two options for adding `-I ${HIGHFIVE_DIR}` and the
# flags for HDF5. # flags for HDF5.
# #
# Option 1: HighFive is install (systemwide) as a regular library: # Option 1: HighFive is installed as a (system-wide) regular library:
find_package(HighFive) find_package(HighFive)
target_link_libraries(app PUBLIC HighFive::HighFive) target_link_libraries(app PUBLIC HighFive::HighFive)
...@@ -169,7 +169,7 @@ of a "file driver". Removing the concept hopefully makes it easier to add a ...@@ -169,7 +169,7 @@ of a "file driver". Removing the concept hopefully makes it easier to add a
better abstraction for the handling of the property lists, when we discover better abstraction for the handling of the property lists, when we discover
such an abstraction. such an abstraction.
## Removal of broadcasting ## Removal of broadcasting.
HighFive v2 had a feature that a dataset (or attribute) of shape `[n, 1]` could HighFive v2 had a feature that a dataset (or attribute) of shape `[n, 1]` could
be read into a one-dimensional array automatically. be read into a one-dimensional array automatically.
...@@ -233,6 +233,32 @@ multi-dimensional array isn't supported, because if we want to support array ...@@ -233,6 +233,32 @@ multi-dimensional array isn't supported, because if we want to support array
with runtime-defined rank, we can't deduce the correct shape, e.g. `[1]` vs. with runtime-defined rank, we can't deduce the correct shape, e.g. `[1]` vs.
`[1, 1, 1]`, when read into an array. `[1, 1, 1]`, when read into an array.
# Removal of `Object*Props`. ## Change to `File::Truncate` and friends.
To out knowledge these could not be used meaningfully. Please create an issue In `v2`, `File::{ReadOnly,Truncate,...}` was an anonymous member enum of
`File`. Effectively it's type was the same as an `int`.
To improve type-safety, we converted it into an `enum class` called
`File::AccessMode`. In order to reduce the migration effort, we retained the
ability to write: `File::ReadOnly`.
Functions that accept a file access mode should be modernized as follows:
```
// old
HighFive::File open(std::string name, int mode) {
return HighFive::File(name, mode);
}
// new
HighFive::File open(std::string name, HighFive::File::AccessMode mode) {
return HighFive::File(name, mode);
}
```
Note: There's a caveat, the short-hand notation `File::ReadOnly` doesn't have
an address. Meaning one can't take it's address or const-references of it
(results in a linker error about missing symbol `File::ReadOnly`). Use
`File::AccessMode::ReadOnly` instead.
## Removal of `Object*Props`.
To our knowledge these could not be used meaningfully. Please create an issue
if you relied on these. if you relied on these.
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
namespace HighFive { namespace HighFive {
namespace detail {
/// @brief Create a HighFive::DataSpace from an HID, without incrementing the id.
///
/// @note This is internal API and subject to change.
/// @internal
DataSpace make_data_space(hid_t hid);
} // namespace detail
/// \brief Class representing the space (dimensions) of a DataSet /// \brief Class representing the space (dimensions) of a DataSet
/// ///
/// \code{.cpp} /// \code{.cpp}
...@@ -254,9 +262,18 @@ class DataSpace: public Object { ...@@ -254,9 +262,18 @@ class DataSpace: public Object {
protected: protected:
DataSpace() = default; DataSpace() = default;
static DataSpace fromId(hid_t hid) {
DataSpace space;
space._hid = hid;
return space;
}
friend class Attribute; friend class Attribute;
friend class File; friend class File;
friend class DataSet; friend class DataSet;
friend DataSpace detail::make_data_space(hid_t hid);
}; };
} // namespace HighFive } // namespace HighFive
......
...@@ -153,16 +153,18 @@ class FixedLengthStringType: public StringType { ...@@ -153,16 +153,18 @@ class FixedLengthStringType: public StringType {
/// UTF8. In particular, a string with `n` UFT8 characters in general /// UTF8. In particular, a string with `n` UFT8 characters in general
/// requires `4*n` bytes. /// requires `4*n` bytes.
/// ///
/// The string padding is subtle, essentially it's just a hint. A /// The string padding is subtle, essentially it's just a hint. While
/// null-terminated string is guaranteed to have one `'\0'` which marks the /// commonly, a null-terminated string is guaranteed to have one `'\0'`
/// semantic end of the string. The length of the buffer must be at least /// which marks the semantic end of the string, this is not enforced by
/// `size` bytes regardless. HDF5 will read or write `size` bytes, /// HDF5. In fact, there are HDF5 files that contain strings that claim to
/// irrespective of the when the `\0` occurs. /// be null-terminated but aren't. The length of the buffer must be at
/// /// least `size` bytes regardless of the padding. HDF5 will read or write
/// Note that when writing passing `StringPadding::NullTerminated` is a /// `size` bytes, irrespective of when (if at all) the `\0` occurs.
///
/// Note that when writing, passing `StringPadding::NullTerminated` is a
/// guarantee to the reader that it contains a `\0`. Therefore, make sure /// guarantee to the reader that it contains a `\0`. Therefore, make sure
/// that the string really is nullterminated. Otherwise prefer a /// that the string really is null-terminated. Otherwise prefer a
/// null-padded string which only means states that the buffer is filled up /// null-padded string. This mearly states that the buffer is filled up
/// with 0 or more `\0`. /// with 0 or more `\0`.
FixedLengthStringType(size_t size, FixedLengthStringType(size_t size,
StringPadding padding, StringPadding padding,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <type_traits>
#include "H5Object.hpp" #include "H5Object.hpp"
#include "H5PropertyList.hpp" #include "H5PropertyList.hpp"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
namespace HighFive { namespace HighFive {
/// ///
/// \brief File class /// \brief File class
/// ///
...@@ -24,25 +26,35 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File> ...@@ -24,25 +26,35 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File>
public: public:
const static ObjectType type = ObjectType::File; const static ObjectType type = ObjectType::File;
enum : unsigned { enum class AccessMode {
None = 0x00u,
/// Open flag: Read only access /// Open flag: Read only access
ReadOnly = 0x00u, ReadOnly = 0x01u,
/// Open flag: Read Write access /// Open flag: Read Write access
ReadWrite = 0x01u, ReadWrite = 0x02u,
/// Open flag: Truncate a file if already existing /// Open flag: Truncate a file if already existing
Truncate = 0x02u, Truncate = 0x04u,
/// Open flag: Open will fail if file already exist /// Open flag: Open will fail if file already exist
Excl = 0x04u, Excl = 0x08u,
/// Open flag: Open in debug mode /// Open flag: Open in debug mode
Debug = 0x08u, Debug = 0x10u,
/// Open flag: Create non existing file /// Open flag: Create non existing file
Create = 0x10u, Create = 0x20u,
/// Derived open flag: common write mode (=ReadWrite|Create|Truncate) /// Derived open flag: common write mode (=ReadWrite|Create|Truncate)
Overwrite = Truncate, Overwrite = Truncate,
/// Derived open flag: Opens RW or exclusively creates /// Derived open flag: Opens RW or exclusively creates
OpenOrCreate = ReadWrite | Create OpenOrCreate = ReadWrite | Create
}; };
constexpr static AccessMode ReadOnly = AccessMode::ReadOnly;
constexpr static AccessMode ReadWrite = AccessMode::ReadWrite;
constexpr static AccessMode Truncate = AccessMode::Truncate;
constexpr static AccessMode Excl = AccessMode::Excl;
constexpr static AccessMode Debug = AccessMode::Debug;
constexpr static AccessMode Create = AccessMode::Create;
constexpr static AccessMode Overwrite = AccessMode::Overwrite;
constexpr static AccessMode OpenOrCreate = AccessMode::OpenOrCreate;
/// ///
/// \brief File /// \brief File
/// \param filename: filepath of the HDF5 file /// \param filename: filepath of the HDF5 file
...@@ -51,7 +63,7 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File> ...@@ -51,7 +63,7 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File>
/// ///
/// Open or create a new HDF5 file /// Open or create a new HDF5 file
explicit File(const std::string& filename, explicit File(const std::string& filename,
unsigned openFlags = ReadOnly, AccessMode openFlags = ReadOnly,
const FileAccessProps& fileAccessProps = FileAccessProps::Default()); const FileAccessProps& fileAccessProps = FileAccessProps::Default());
/// ///
...@@ -63,7 +75,7 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File> ...@@ -63,7 +75,7 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File>
/// ///
/// Open or create a new HDF5 file /// Open or create a new HDF5 file
File(const std::string& filename, File(const std::string& filename,
unsigned openFlags, AccessMode openFlags,
const FileCreateProps& fileCreateProps, const FileCreateProps& fileCreateProps,
const FileAccessProps& fileAccessProps = FileAccessProps::Default()); const FileAccessProps& fileAccessProps = FileAccessProps::Default());
...@@ -131,6 +143,46 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File> ...@@ -131,6 +143,46 @@ class File: public Object, public NodeTraits<File>, public AnnotateTraits<File>
friend class PathTraits; friend class PathTraits;
}; };
inline File::AccessMode operator|(File::AccessMode lhs, File::AccessMode rhs) {
using int_t = std::underlying_type<File::AccessMode>::type;
return static_cast<File::AccessMode>(static_cast<int_t>(lhs) | static_cast<int_t>(rhs));
}
inline File::AccessMode operator&(File::AccessMode lhs, File::AccessMode rhs) {
using int_t = std::underlying_type<File::AccessMode>::type;
return static_cast<File::AccessMode>(static_cast<int_t>(lhs) & static_cast<int_t>(rhs));
}
inline File::AccessMode operator^(File::AccessMode lhs, File::AccessMode rhs) {
using int_t = std::underlying_type<File::AccessMode>::type;
return static_cast<File::AccessMode>(static_cast<int_t>(lhs) ^ static_cast<int_t>(rhs));
}
inline File::AccessMode operator~(File::AccessMode mode) {
using int_t = std::underlying_type<File::AccessMode>::type;
return static_cast<File::AccessMode>(~static_cast<int_t>(mode));
}
inline const File::AccessMode& operator|=(File::AccessMode& lhs, File::AccessMode rhs) {
lhs = lhs | rhs;
return lhs;
}
inline File::AccessMode operator&=(File::AccessMode& lhs, File::AccessMode rhs) {
lhs = lhs & rhs;
return lhs;
}
inline File::AccessMode operator^=(File::AccessMode& lhs, File::AccessMode rhs) {
lhs = lhs ^ rhs;
return lhs;
}
inline bool any(File::AccessMode mode) {
return mode != File::AccessMode::None;
}
} // namespace HighFive } // namespace HighFive
// H5File is the main user constructible -> bring in implementation headers // H5File is the main user constructible -> bring in implementation headers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment