|
1 |
| -*Note:* In preparation of `v3` of HighFive, we've started merging breaking |
2 |
| -changes into the main branch. More information and opportunity to comment can |
3 |
| -be found at: |
4 |
| -https://github.com/BlueBrain/HighFive/issues/864 |
| 1 | +> [!WARNING] |
| 2 | +> The BlueBrainProject closed at the end of 2024. This unfortunately required |
| 3 | +> archiving all repositories under `BlueBrain` including HighFive. |
| 4 | +> |
| 5 | +> The development of HighFive will continue at: |
| 6 | +> https://github.com/highfive-devs/highfive |
| 7 | +
|
5 | 8 |
|
6 | 9 | # HighFive - HDF5 header-only C++ Library
|
7 | 10 |
|
8 |
| -[](https://BlueBrain.github.io/HighFive/actions/workflows/gh-pages.yml?query=branch%3Amaster) |
9 |
| -[](https://codecov.io/gh/BlueBrain/HighFive) |
10 |
| -[](https://github.com/BlueBrain/HighFive-testing/actions/workflows/integration.yml) |
11 | 11 | [](https://zenodo.org/doi/10.5281/zenodo.10679422)
|
12 | 12 |
|
13 |
| -Documentation: https://bluebrain.github.io/HighFive/ |
14 |
| - |
15 |
| -## Brief |
16 |
| - |
17 |
| -HighFive is a modern header-only C++14 friendly interface for libhdf5. |
18 |
| - |
19 |
| -HighFive supports STL vector/string, Boost::UBLAS, Boost::Multi-array and Xtensor. It handles C++ from/to HDF5 with automatic type mapping. |
20 |
| -HighFive does not require additional libraries (see dependencies). |
21 |
| - |
22 |
| -It integrates nicely with other CMake projects by defining (and exporting) a HighFive target. |
23 |
| - |
24 |
| -### Design |
25 |
| -- Simple C++-ish minimalist interface |
26 |
| -- Only hard dependency is libhdf5 |
27 |
| -- Zero/low overhead, when possible |
28 |
| -- RAII for opening/closing files, groups, datasets, etc. |
29 |
| -- Written in C++14 |
30 |
| - |
31 |
| -### Feature support |
32 |
| -- create/read/write files, datasets, attributes, groups, dataspaces. |
33 |
| -- automatic memory management / ref counting |
34 |
| -- automatic conversion of `std::vector` and nested `std::vector` from/to any dataset with basic types |
35 |
| -- automatic conversion of `std::string` to/from variable- or fixed-length string dataset |
36 |
| -- selection() / slice support |
37 |
| -- parallel Read/Write operations from several nodes with Parallel HDF5 |
38 |
| -- Advanced types: Compound, Enum, Arrays of Fixed-length strings, References |
39 |
| -- half-precision (16-bit) floating-point datasets |
40 |
| -- `std::byte` in C++17 mode (with `-DCMAKE_CXX_STANDARD=17` or higher) |
41 |
| -- etc... (see [ChangeLog](./CHANGELOG.md)) |
42 |
| - |
43 |
| -### Dependencies |
44 |
| -- HDF5 or pHDF5, including headers |
45 |
| -- boost (optional) |
46 |
| -- eigen3 (optional) |
47 |
| -- xtensor (optional) |
48 |
| -- half (optional) |
49 |
| - |
50 |
| -### Versioning & Code Stability |
51 |
| -We use semantic versioning. Currently, we're preparing `v3` which contains a |
52 |
| -limited set of breaking changes required to eliminate undesireable behaviour or |
53 |
| -modernize outdated patterns. We provide a |
54 |
| -[Migration Guide](https://bluebrain.github.io/HighFive/md__2home_2runner_2work_2_high_five_2_high_five_2doc_2migration__guide.html), |
55 |
| -please report any missing or incorrect information to help others make the |
56 |
| -switch more easily. |
57 |
| - |
58 |
| -- `v2.x.y` are stable and any API breaking changes are considered bugs. There's |
59 |
| - like not going to be very many releases of the `v2` line once `v3` is stable. |
60 |
| - |
61 |
| -- `v3.0.0-beta?` are pre-releases of `v3.0.0`. We predict that one more |
62 |
| - breaking changes might happen: the string handling is confusing to some of the |
63 |
| - maintainers and the default encoding is inconsistent (and will likely be made |
64 |
| - consistent). |
65 |
| - |
66 |
| - For codes that either use `std::string` when dealing with strings, or that |
67 |
| - don't use strings with HDF5 at all, we don't currently have any additional |
68 |
| - breaking changes planned for 3.0.0. |
69 |
| - |
70 |
| - |
71 |
| -### Known flaws |
72 |
| -- 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. |
73 |
| -- Eigen support in core HighFive was broken until v3.0. See https://github.com/BlueBrain/HighFive/issues/532. H5Easy was not |
74 |
| - affected. |
75 |
| -- The support of fixed length strings isn't ideal. |
76 |
| - |
77 |
| - |
78 | 13 | ## Examples
|
79 | 14 |
|
80 |
| -#### Write a std::vector<int> to 1D HDF5 dataset and read it back |
81 |
| - |
82 | 15 | ```c++
|
83 | 16 | #include <highfive/highfive.hpp>
|
84 | 17 |
|
@@ -109,166 +42,6 @@ std::string filename = "/tmp/new_file.h5";
|
109 | 42 | }
|
110 | 43 | ```
|
111 | 44 |
|
112 |
| -**Note:** As of 2.8.0, one can use `highfive/highfive.hpp` to include |
113 |
| -everything HighFive. Prior to 2.8.0 one would include `highfive/H5File.hpp`. |
114 |
| - |
115 |
| -**Note:** For advanced usecases the dataset can be created without immediately |
116 |
| -writing to it. This is common in MPI-IO related patterns, or when growing a |
117 |
| -dataset over the course of a simulation. |
118 |
| - |
119 |
| -#### Write a 2 dimensional C double float array to a 2D HDF5 dataset |
120 |
| - |
121 |
| -See [create_dataset_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_dataset_double.cpp) |
122 |
| - |
123 |
| -#### Write and read a matrix of double float (boost::ublas) to a 2D HDF5 dataset |
124 |
| - |
125 |
| -See [boost_ublas_double.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/boost_ublas_double.cpp) |
126 |
| - |
127 |
| -#### Write and read a subset of a 2D double dataset |
128 |
| - |
129 |
| -See [select_partial_dataset_cpp11.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/select_partial_dataset_cpp11.cpp) |
130 |
| - |
131 |
| -#### Create, write and list HDF5 attributes |
132 |
| - |
133 |
| -See [create_attribute_string_integer.cpp](https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_attribute_string_integer.cpp) |
134 |
| - |
135 |
| -#### And others |
136 |
| - |
137 |
| -See [src/examples/](https://github.com/BlueBrain/HighFive/blob/master/src/examples/) subdirectory for more info. |
138 |
| - |
139 |
| - |
140 |
| -### H5Easy |
141 |
| - |
142 |
| -For several 'standard' use cases the [highfive/H5Easy.hpp](include/highfive/H5Easy.hpp) interface is available. It allows: |
143 |
| - |
144 |
| -* Reading/writing in a single line of: |
145 |
| - |
146 |
| - - scalars (to/from an extendible DataSet), |
147 |
| - - strings, |
148 |
| - - vectors (of standard types), |
149 |
| - - [Eigen::Matrix](http://eigen.tuxfamily.org) (optional), |
150 |
| - - [xt::xarray](https://github.com/QuantStack/xtensor) and [xt::xtensor](https://github.com/QuantStack/xtensor) |
151 |
| - (optional). |
152 |
| - - [cv::Mat_](https://docs.opencv.org/master/df/dfc/classcv_1_1Mat__.html) |
153 |
| - (optional). |
154 |
| - |
155 |
| -* Getting in a single line: |
156 |
| - |
157 |
| - - the size of a DataSet, |
158 |
| - - the shape of a DataSet. |
159 |
| - |
160 |
| -#### Example |
161 |
| - |
162 |
| -```cpp |
163 |
| -#include <highfive/H5Easy.hpp> |
164 |
| - |
165 |
| -int main() { |
166 |
| - H5Easy::File file("example.h5", H5Easy::File::Overwrite); |
167 |
| - |
168 |
| - int A = ...; |
169 |
| - H5Easy::dump(file, "/path/to/A", A); |
170 |
| - |
171 |
| - A = H5Easy::load<int>(file, "/path/to/A"); |
172 |
| -} |
173 |
| -``` |
174 |
| - |
175 |
| -whereby the `int` type of this example can be replaced by any of the above |
176 |
| -types. See [easy_load_dump.cpp](src/examples/easy_load_dump.cpp) for more |
177 |
| -details. |
178 |
| - |
179 |
| -**Note:** Classes such as `H5Easy::File` are just short for the regular |
180 |
| -`HighFive` classes (in this case `HighFive::File`). They can thus be used |
181 |
| -interchangeably. |
182 |
| - |
183 |
| - |
184 |
| -## CMake integration |
185 |
| -There's two common paths of integrating HighFive into a CMake based project. |
186 |
| -The first is to "vendor" HighFive, the second is to install HighFive as a |
187 |
| -normal C++ library. Since HighFive makes choices about how to integrate HDF5, |
188 |
| -sometimes following the third Bailout Approach is needed. |
189 |
| - |
190 |
| -Regular HDF5 CMake variables can be used. Interesting variables include: |
191 |
| - |
192 |
| -* `HDF5_USE_STATIC_LIBRARIES` to link statically against the HDF5 library. |
193 |
| -* `HDF5_PREFER_PARALLEL` to prefer pHDF5. |
194 |
| -* `HDF5_IS_PARALLEL` to check if HDF5 is parallel. |
195 |
| - |
196 |
| -Please consult `tests/cmake_integration` for examples of how to write libraries |
197 |
| -or applications using HighFive. |
198 |
| - |
199 |
| -### Vendoring HighFive |
200 |
| - |
201 |
| -In this approach the HighFive sources are included in a subdirectory of the |
202 |
| -project (typically as a git submodule), for example in `third_party/HighFive`. |
203 |
| - |
204 |
| -The projects `CMakeLists.txt` add the following lines |
205 |
| -```cmake |
206 |
| -add_subdirectory(third_party/HighFive) |
207 |
| -target_link_libraries(foo HighFive) |
208 |
| -``` |
209 |
| - |
210 |
| -**Note:** `add_subdirectory(third_party/HighFive)` will search and "link" HDF5 |
211 |
| -but wont search or link any optional dependencies such as Boost. |
212 |
| - |
213 |
| -### Regular Installation of HighFive |
214 |
| - |
215 |
| -Alternatively, HighFive can be install and "found" like regular software. |
216 |
| - |
217 |
| -The project's `CMakeLists.txt` should add the following: |
218 |
| -```cmake |
219 |
| -find_package(HighFive REQUIRED) |
220 |
| -target_link_libraries(foo HighFive) |
221 |
| -``` |
222 |
| - |
223 |
| -**Note:** `find_package(HighFive)` will search for HDF5. "Linking" to |
224 |
| -`HighFive` includes linking with HDF5. The two commands will not search for or |
225 |
| -"link" to optional dependencies such as Boost. |
226 |
| - |
227 |
| -### Bailout Approach |
228 |
| - |
229 |
| -To prevent HighFive from searching or "linking" to HDF5 the project's |
230 |
| -`CMakeLists.txt` should contain the following: |
231 |
| - |
232 |
| -```cmake |
233 |
| -# Prevent HighFive CMake code from searching for HDF5: |
234 |
| -set(HIGHFIVE_FIND_HDF5 Off) |
235 |
| -
|
236 |
| -# Then "find" HighFive as usual: |
237 |
| -find_package(HighFive REQUIRED) |
238 |
| -# alternatively, when vendoring: |
239 |
| -# add_subdirectory(third_party/HighFive) |
240 |
| -
|
241 |
| -# Finally, use the target `HighFive::Include` which |
242 |
| -# doesn't add a dependency on HDF5. |
243 |
| -target_link_libraries(foo HighFive::Include) |
244 |
| -
|
245 |
| -# Proceed to find and link HDF5 as required. |
246 |
| -``` |
247 |
| - |
248 |
| -### Optional Dependencies |
249 |
| - |
250 |
| -HighFive does not attempt to find or "link" to any optional dependencies, such |
251 |
| -as Boost, Eigen, etc. Any project using HighFive with any of the optional |
252 |
| -dependencies must include the respective header: |
253 |
| -``` |
254 |
| -#include <highfive/boost.hpp> |
255 |
| -#include <highfive/eigen.hpp> |
256 |
| -``` |
257 |
| -and add the required CMake code to find and link against the dependencies. For |
258 |
| -Boost the required lines might be |
259 |
| -``` |
260 |
| -find_package(Boost REQUIRED) |
261 |
| -target_link_libraries(foo PUBLIC Boost::headers) |
262 |
| -``` |
263 |
| - |
264 |
| -# Questions? |
265 |
| - |
266 |
| -Do you have questions on how to use HighFive? Would you like to share an interesting example or |
267 |
| -discuss HighFive features? Head over to the [Discussions](https://github.com/BlueBrain/HighFive/discussions) |
268 |
| -forum and join the community. |
269 |
| - |
270 |
| -For bugs and issues please use [Issues](https://github.com/BlueBrain/HighFive/issues). |
271 |
| - |
272 | 45 | # Funding & Acknowledgment
|
273 | 46 |
|
274 | 47 | 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.
|
|
0 commit comments