HighFive 2.10.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
h5p_wrapper.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <H5Ipublic.h>
4#include <H5Ppublic.h>
5
6namespace HighFive {
7namespace detail {
8inline hid_t h5p_create(hid_t cls_id) {
9 hid_t plist_id = H5Pcreate(cls_id);
10 if (plist_id == H5I_INVALID_HID) {
11 HDF5ErrMapper::ToException<PropertyException>("Failed to create property list");
12 }
13
14 return plist_id;
15}
16
17#if H5_VERSION_GE(1, 10, 1)
18inline herr_t h5p_set_file_space_strategy(hid_t plist_id,
19 H5F_fspace_strategy_t strategy,
20 hbool_t persist,
21 hsize_t threshold) {
22 herr_t err = H5Pset_file_space_strategy(plist_id, strategy, persist, threshold);
23 if (err < 0) {
24 HDF5ErrMapper::ToException<PropertyException>("Unable to get file space strategy");
25 }
26
27 return err;
28}
29
30inline herr_t h5p_get_file_space_strategy(hid_t plist_id,
31 H5F_fspace_strategy_t* strategy,
32 hbool_t* persist,
33 hsize_t* threshold) {
34 herr_t err = H5Pget_file_space_strategy(plist_id, strategy, persist, threshold);
35 if (err) {
36 HDF5ErrMapper::ToException<PropertyException>("Error setting file space strategy.");
37 }
38
39 return err;
40}
41
42inline herr_t h5p_set_file_space_page_size(hid_t plist_id, hsize_t fsp_size) {
43 herr_t err = H5Pset_file_space_page_size(plist_id, fsp_size);
44 if (err < 0) {
45 HDF5ErrMapper::ToException<PropertyException>("Error setting file space page size.");
46 }
47
48 return err;
49}
50
51inline herr_t h5p_get_file_space_page_size(hid_t plist_id, hsize_t* fsp_size) {
52 herr_t err = H5Pget_file_space_page_size(plist_id, fsp_size);
53 if (err < 0) {
54 HDF5ErrMapper::ToException<PropertyException>("Unable to get file space page size");
55 }
56
57 return err;
58}
59
60#ifndef H5_HAVE_PARALLEL
61inline herr_t h5p_get_page_buffer_size(hid_t plist_id,
62 size_t* buf_size,
63 unsigned* min_meta_perc,
64 unsigned* min_raw_perc) {
65 herr_t err = H5Pget_page_buffer_size(plist_id, buf_size, min_meta_perc, min_raw_perc);
66
67 if (err < 0) {
68 HDF5ErrMapper::ToException<PropertyException>("Error setting page buffer size.");
69 }
70
71 return err;
72}
73
74inline herr_t h5p_set_page_buffer_size(hid_t plist_id,
75 size_t buf_size,
76 unsigned min_meta_per,
77 unsigned min_raw_per) {
78 herr_t err = H5Pset_page_buffer_size(plist_id, buf_size, min_meta_per, min_raw_per);
79 if (err < 0) {
80 HDF5ErrMapper::ToException<PropertyException>("Error setting page buffer size.");
81 }
82
83 return err;
84}
85#endif
86#endif
87
88#ifdef H5_HAVE_PARALLEL
89inline herr_t h5p_set_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) {
90 herr_t err = H5Pset_fapl_mpio(fapl_id, comm, info);
91 if (err < 0) {
92 HDF5ErrMapper::ToException<FileException>("Unable to set-up MPIO Driver configuration");
93 }
94
95 return err;
96}
97
98#if H5_VERSION_GE(1, 10, 0)
99inline herr_t h5p_set_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) {
100 herr_t err = H5Pset_all_coll_metadata_ops(plist_id, is_collective);
101 if (err < 0) {
102 HDF5ErrMapper::ToException<FileException>("Unable to request collective metadata reads");
103 }
104
105 return err;
106}
107
108inline herr_t h5p_get_all_coll_metadata_ops(hid_t plist_id, hbool_t* is_collective) {
109 herr_t err = H5Pget_all_coll_metadata_ops(plist_id, is_collective);
110 if (err < 0) {
111 HDF5ErrMapper::ToException<PropertyException>("Error loading MPI metadata read.");
112 }
113
114 return err;
115}
116
117inline herr_t h5p_set_coll_metadata_write(hid_t plist_id, hbool_t is_collective) {
118 herr_t err = H5Pset_coll_metadata_write(plist_id, is_collective);
119
120 if (err < 0) {
121 HDF5ErrMapper::ToException<FileException>("Unable to request collective metadata writes");
122 }
123
124 return err;
125}
126
127inline herr_t h5p_get_coll_metadata_write(hid_t plist_id, hbool_t* is_collective) {
128 herr_t err = H5Pget_coll_metadata_write(plist_id, is_collective);
129
130 if (err < 0) {
131 HDF5ErrMapper::ToException<PropertyException>("Error loading MPI metadata write.");
132 }
133
134 return err;
135}
136#endif
137#endif
138
139inline herr_t h5p_get_libver_bounds(hid_t plist_id, H5F_libver_t* low, H5F_libver_t* high) {
140 herr_t err = H5Pget_libver_bounds(plist_id, low, high);
141 if (err < 0) {
142 HDF5ErrMapper::ToException<PropertyException>("Unable to access file version bounds");
143 }
144
145 return err;
146}
147
148inline herr_t h5p_set_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) {
149 herr_t err = H5Pset_libver_bounds(plist_id, low, high);
150
151 if (err < 0) {
152 HDF5ErrMapper::ToException<PropertyException>("Error setting file version bounds");
153 }
154
155 return err;
156}
157
158inline herr_t h5p_get_meta_block_size(hid_t fapl_id, hsize_t* size) {
159 herr_t err = H5Pget_meta_block_size(fapl_id, size);
160 if (err < 0) {
161 HDF5ErrMapper::ToException<PropertyException>("Unable to access file metadata block size");
162 }
163
164 return err;
165}
166
167inline herr_t h5p_set_meta_block_size(hid_t fapl_id, hsize_t size) {
168 herr_t err = H5Pset_meta_block_size(fapl_id, size);
169
170 if (err < 0) {
171 HDF5ErrMapper::ToException<PropertyException>("Error setting metadata block size");
172 }
173
174 return err;
175}
176
177inline herr_t h5p_set_est_link_info(hid_t plist_id,
178 unsigned est_num_entries,
179 unsigned est_name_len) {
180 herr_t err = H5Pset_est_link_info(plist_id, est_num_entries, est_name_len);
181 if (err < 0) {
182 HDF5ErrMapper::ToException<PropertyException>("Error setting estimated link info");
183 }
184
185 return err;
186}
187
188inline herr_t h5p_get_est_link_info(hid_t plist_id,
189 unsigned* est_num_entries,
190 unsigned* est_name_len) {
191 herr_t err = H5Pget_est_link_info(plist_id, est_num_entries, est_name_len);
192
193 if (err < 0) {
194 HDF5ErrMapper::ToException<PropertyException>("Unable to access group link size property");
195 }
196
197 return err;
198}
199
200inline herr_t h5p_set_chunk(hid_t plist_id, int ndims, const hsize_t dim[]) {
201 herr_t err = H5Pset_chunk(plist_id, ndims, dim);
202
203 if (err < 0) {
204 HDF5ErrMapper::ToException<PropertyException>("Error setting chunk property");
205 }
206
207 return err;
208}
209
210inline int h5p_get_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]) {
211 int chunk_dims = H5Pget_chunk(plist_id, max_ndims, dim);
212 if (chunk_dims < 0) {
213 HDF5ErrMapper::ToException<PropertyException>("Error getting chunk size");
214 }
215 return chunk_dims;
216}
217
218inline htri_t h5z_filter_avail(H5Z_filter_t id) {
219 htri_t tri = H5Zfilter_avail(id);
220 if (tri < 0) {
221 HDF5ErrMapper::ToException<PropertyException>("Error checking filter availability");
222 }
223 return tri;
224}
225
226inline herr_t h5p_set_deflate(hid_t plist_id, unsigned level) {
227 herr_t err = H5Pset_deflate(plist_id, level);
228 if (err < 0) {
229 HDF5ErrMapper::ToException<PropertyException>("Error setting deflate property");
230 }
231 return err;
232}
233
234inline herr_t h5p_set_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) {
235 herr_t err = H5Pset_szip(plist_id, options_mask, pixels_per_block);
236 if (err < 0) {
237 HDF5ErrMapper::ToException<PropertyException>("Error setting szip property");
238 }
239 return err;
240}
241
242inline herr_t h5p_set_shuffle(hid_t plist_id) {
243 herr_t err = H5Pset_shuffle(plist_id);
244 if (err < 0) {
245 HDF5ErrMapper::ToException<PropertyException>("Error setting shuffle property");
246 }
247 return err;
248}
249
250inline herr_t h5p_get_alloc_time(hid_t plist_id, H5D_alloc_time_t* alloc_time) {
251 herr_t err = H5Pget_alloc_time(plist_id, alloc_time);
252 if (err < 0) {
253 HDF5ErrMapper::ToException<PropertyException>("Error getting allocation time");
254 }
255 return err;
256}
257
258inline herr_t h5p_set_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) {
259 herr_t err = H5Pset_alloc_time(plist_id, alloc_time);
260 if (err < 0) {
261 HDF5ErrMapper::ToException<PropertyException>("Error setting allocation time");
262 }
263 return err;
264}
265
266inline herr_t h5p_get_chunk_cache(hid_t dapl_id,
267 size_t* rdcc_nslots,
268 size_t* rdcc_nbytes,
269 double* rdcc_w0) {
270 herr_t err = H5Pget_chunk_cache(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);
271 if (err < 0) {
272 HDF5ErrMapper::ToException<PropertyException>("Error getting dataset cache parameters");
273 }
274 return err;
275}
276
277inline herr_t h5p_set_chunk_cache(hid_t dapl_id,
278 size_t rdcc_nslots,
279 size_t rdcc_nbytes,
280 double rdcc_w0) {
281 herr_t err = H5Pset_chunk_cache(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);
282 if (err < 0) {
283 HDF5ErrMapper::ToException<PropertyException>("Error setting dataset cache parameters");
284 }
285 return err;
286}
287
288inline herr_t h5p_set_create_intermediate_group(hid_t plist_id, unsigned crt_intmd) {
289 herr_t err = H5Pset_create_intermediate_group(plist_id, crt_intmd);
290 if (err < 0) {
292 "Error setting property for create intermediate groups");
293 }
294 return err;
295}
296
297inline herr_t h5p_get_create_intermediate_group(hid_t plist_id, unsigned* crt_intmd) {
298 herr_t err = H5Pget_create_intermediate_group(plist_id, crt_intmd);
299 if (err < 0) {
301 "Error getting property for create intermediate groups");
302 }
303 return err;
304}
305
306#ifdef H5_HAVE_PARALLEL
307inline herr_t h5p_set_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) {
308 herr_t err = H5Pset_dxpl_mpio(dxpl_id, xfer_mode);
309 if (err < 0) {
310 HDF5ErrMapper::ToException<PropertyException>("Error setting H5Pset_dxpl_mpio.");
311 }
312 return err;
313}
314
315inline herr_t h5p_get_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t* xfer_mode) {
316 herr_t err = H5Pget_dxpl_mpio(dxpl_id, xfer_mode);
317 if (err < 0) {
318 HDF5ErrMapper::ToException<PropertyException>("Error getting H5Pset_dxpl_mpio.");
319 }
320 return err;
321}
322
323inline herr_t h5p_get_mpio_no_collective_cause(hid_t plist_id,
324 uint32_t* local_no_collective_cause,
325 uint32_t* global_no_collective_cause) {
326 herr_t err = H5Pget_mpio_no_collective_cause(plist_id,
327 local_no_collective_cause,
328 global_no_collective_cause);
329 if (err < 0) {
330 HDF5ErrMapper::ToException<PropertyException>("Failed to check mpio_no_collective_cause.");
331 }
332 return err;
333}
334
335#endif
336
337inline herr_t h5p_set_link_creation_order(hid_t plist_id, unsigned crt_order_flags) {
338 herr_t err = H5Pset_link_creation_order(plist_id, crt_order_flags);
339 if (err < 0) {
340 HDF5ErrMapper::ToException<PropertyException>("Error setting LinkCreationOrder.");
341 }
342 return err;
343}
344
345inline herr_t h5p_get_link_creation_order(hid_t plist_id, unsigned* crt_order_flags) {
346 herr_t err = H5Pget_link_creation_order(plist_id, crt_order_flags);
347 if (err < 0) {
349 "Error getting property for link creation order");
350 }
351 return err;
352}
353
354inline herr_t h5p_get_attr_phase_change(hid_t plist_id,
355 unsigned* max_compact,
356 unsigned* min_dense) {
357 herr_t err = H5Pget_attr_phase_change(plist_id, max_compact, min_dense);
358 if (err < 0) {
360 "Error getting property for attribute phase change");
361 }
362 return err;
363}
364
365inline herr_t h5p_set_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) {
366 herr_t err = H5Pset_attr_phase_change(plist_id, max_compact, min_dense);
367 if (err < 0) {
369 "Error getting property for attribute phase change");
370 }
371 return err;
372}
373
374
375} // namespace detail
376} // namespace HighFive
Definition H5_definitions.hpp:22
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:43