File indexing completed on 2025-04-19 08:55:34
0001 #pragma once
0002
0003 #include <H5Ipublic.h>
0004 #include <H5Ppublic.h>
0005
0006 namespace HighFive {
0007 namespace detail {
0008 inline hid_t h5p_create(hid_t cls_id) {
0009 hid_t plist_id = H5Pcreate(cls_id);
0010 if (plist_id == H5I_INVALID_HID) {
0011 HDF5ErrMapper::ToException<PropertyException>("Failed to create property list");
0012 }
0013
0014 return plist_id;
0015 }
0016
0017 #if H5_VERSION_GE(1, 10, 1)
0018 inline herr_t h5p_set_file_space_strategy(hid_t plist_id,
0019 H5F_fspace_strategy_t strategy,
0020 hbool_t persist,
0021 hsize_t threshold) {
0022 herr_t err = H5Pset_file_space_strategy(plist_id, strategy, persist, threshold);
0023 if (err < 0) {
0024 HDF5ErrMapper::ToException<PropertyException>("Unable to get file space strategy");
0025 }
0026
0027 return err;
0028 }
0029
0030 inline herr_t h5p_get_file_space_strategy(hid_t plist_id,
0031 H5F_fspace_strategy_t* strategy,
0032 hbool_t* persist,
0033 hsize_t* threshold) {
0034 herr_t err = H5Pget_file_space_strategy(plist_id, strategy, persist, threshold);
0035 if (err) {
0036 HDF5ErrMapper::ToException<PropertyException>("Error setting file space strategy.");
0037 }
0038
0039 return err;
0040 }
0041
0042 inline herr_t h5p_set_file_space_page_size(hid_t plist_id, hsize_t fsp_size) {
0043 herr_t err = H5Pset_file_space_page_size(plist_id, fsp_size);
0044 if (err < 0) {
0045 HDF5ErrMapper::ToException<PropertyException>("Error setting file space page size.");
0046 }
0047
0048 return err;
0049 }
0050
0051 inline herr_t h5p_get_file_space_page_size(hid_t plist_id, hsize_t* fsp_size) {
0052 herr_t err = H5Pget_file_space_page_size(plist_id, fsp_size);
0053 if (err < 0) {
0054 HDF5ErrMapper::ToException<PropertyException>("Unable to get file space page size");
0055 }
0056
0057 return err;
0058 }
0059
0060 #ifndef H5_HAVE_PARALLEL
0061 inline herr_t h5p_get_page_buffer_size(hid_t plist_id,
0062 size_t* buf_size,
0063 unsigned* min_meta_perc,
0064 unsigned* min_raw_perc) {
0065 herr_t err = H5Pget_page_buffer_size(plist_id, buf_size, min_meta_perc, min_raw_perc);
0066
0067 if (err < 0) {
0068 HDF5ErrMapper::ToException<PropertyException>("Error setting page buffer size.");
0069 }
0070
0071 return err;
0072 }
0073
0074 inline herr_t h5p_set_page_buffer_size(hid_t plist_id,
0075 size_t buf_size,
0076 unsigned min_meta_per,
0077 unsigned min_raw_per) {
0078 herr_t err = H5Pset_page_buffer_size(plist_id, buf_size, min_meta_per, min_raw_per);
0079 if (err < 0) {
0080 HDF5ErrMapper::ToException<PropertyException>("Error setting page buffer size.");
0081 }
0082
0083 return err;
0084 }
0085 #endif
0086 #endif
0087
0088 #ifdef H5_HAVE_PARALLEL
0089 inline herr_t h5p_set_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) {
0090 herr_t err = H5Pset_fapl_mpio(fapl_id, comm, info);
0091 if (err < 0) {
0092 HDF5ErrMapper::ToException<FileException>("Unable to set-up MPIO Driver configuration");
0093 }
0094
0095 return err;
0096 }
0097
0098 #if H5_VERSION_GE(1, 10, 0)
0099 inline herr_t h5p_set_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) {
0100 herr_t err = H5Pset_all_coll_metadata_ops(plist_id, is_collective);
0101 if (err < 0) {
0102 HDF5ErrMapper::ToException<FileException>("Unable to request collective metadata reads");
0103 }
0104
0105 return err;
0106 }
0107
0108 inline herr_t h5p_get_all_coll_metadata_ops(hid_t plist_id, hbool_t* is_collective) {
0109 herr_t err = H5Pget_all_coll_metadata_ops(plist_id, is_collective);
0110 if (err < 0) {
0111 HDF5ErrMapper::ToException<PropertyException>("Error loading MPI metadata read.");
0112 }
0113
0114 return err;
0115 }
0116
0117 inline herr_t h5p_set_coll_metadata_write(hid_t plist_id, hbool_t is_collective) {
0118 herr_t err = H5Pset_coll_metadata_write(plist_id, is_collective);
0119
0120 if (err < 0) {
0121 HDF5ErrMapper::ToException<FileException>("Unable to request collective metadata writes");
0122 }
0123
0124 return err;
0125 }
0126
0127 inline herr_t h5p_get_coll_metadata_write(hid_t plist_id, hbool_t* is_collective) {
0128 herr_t err = H5Pget_coll_metadata_write(plist_id, is_collective);
0129
0130 if (err < 0) {
0131 HDF5ErrMapper::ToException<PropertyException>("Error loading MPI metadata write.");
0132 }
0133
0134 return err;
0135 }
0136 #endif
0137 #endif
0138
0139 inline herr_t h5p_get_libver_bounds(hid_t plist_id, H5F_libver_t* low, H5F_libver_t* high) {
0140 herr_t err = H5Pget_libver_bounds(plist_id, low, high);
0141 if (err < 0) {
0142 HDF5ErrMapper::ToException<PropertyException>("Unable to access file version bounds");
0143 }
0144
0145 return err;
0146 }
0147
0148 inline herr_t h5p_set_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) {
0149 herr_t err = H5Pset_libver_bounds(plist_id, low, high);
0150
0151 if (err < 0) {
0152 HDF5ErrMapper::ToException<PropertyException>("Error setting file version bounds");
0153 }
0154
0155 return err;
0156 }
0157
0158 inline herr_t h5p_get_meta_block_size(hid_t fapl_id, hsize_t* size) {
0159 herr_t err = H5Pget_meta_block_size(fapl_id, size);
0160 if (err < 0) {
0161 HDF5ErrMapper::ToException<PropertyException>("Unable to access file metadata block size");
0162 }
0163
0164 return err;
0165 }
0166
0167 inline herr_t h5p_set_meta_block_size(hid_t fapl_id, hsize_t size) {
0168 herr_t err = H5Pset_meta_block_size(fapl_id, size);
0169
0170 if (err < 0) {
0171 HDF5ErrMapper::ToException<PropertyException>("Error setting metadata block size");
0172 }
0173
0174 return err;
0175 }
0176
0177 inline herr_t h5p_set_est_link_info(hid_t plist_id,
0178 unsigned est_num_entries,
0179 unsigned est_name_len) {
0180 herr_t err = H5Pset_est_link_info(plist_id, est_num_entries, est_name_len);
0181 if (err < 0) {
0182 HDF5ErrMapper::ToException<PropertyException>("Error setting estimated link info");
0183 }
0184
0185 return err;
0186 }
0187
0188 inline herr_t h5p_get_est_link_info(hid_t plist_id,
0189 unsigned* est_num_entries,
0190 unsigned* est_name_len) {
0191 herr_t err = H5Pget_est_link_info(plist_id, est_num_entries, est_name_len);
0192
0193 if (err < 0) {
0194 HDF5ErrMapper::ToException<PropertyException>("Unable to access group link size property");
0195 }
0196
0197 return err;
0198 }
0199
0200 inline herr_t h5p_set_chunk(hid_t plist_id, int ndims, const hsize_t dim[]) {
0201 herr_t err = H5Pset_chunk(plist_id, ndims, dim);
0202
0203 if (err < 0) {
0204 HDF5ErrMapper::ToException<PropertyException>("Error setting chunk property");
0205 }
0206
0207 return err;
0208 }
0209
0210 inline int h5p_get_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]) {
0211 int chunk_dims = H5Pget_chunk(plist_id, max_ndims, dim);
0212 if (chunk_dims < 0) {
0213 HDF5ErrMapper::ToException<PropertyException>("Error getting chunk size");
0214 }
0215 return chunk_dims;
0216 }
0217
0218 inline htri_t h5z_filter_avail(H5Z_filter_t id) {
0219 htri_t tri = H5Zfilter_avail(id);
0220 if (tri < 0) {
0221 HDF5ErrMapper::ToException<PropertyException>("Error checking filter availability");
0222 }
0223 return tri;
0224 }
0225
0226 inline herr_t h5p_set_deflate(hid_t plist_id, unsigned level) {
0227 herr_t err = H5Pset_deflate(plist_id, level);
0228 if (err < 0) {
0229 HDF5ErrMapper::ToException<PropertyException>("Error setting deflate property");
0230 }
0231 return err;
0232 }
0233
0234 inline herr_t h5p_set_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) {
0235 herr_t err = H5Pset_szip(plist_id, options_mask, pixels_per_block);
0236 if (err < 0) {
0237 HDF5ErrMapper::ToException<PropertyException>("Error setting szip property");
0238 }
0239 return err;
0240 }
0241
0242 inline herr_t h5p_set_shuffle(hid_t plist_id) {
0243 herr_t err = H5Pset_shuffle(plist_id);
0244 if (err < 0) {
0245 HDF5ErrMapper::ToException<PropertyException>("Error setting shuffle property");
0246 }
0247 return err;
0248 }
0249
0250 inline herr_t h5p_get_alloc_time(hid_t plist_id, H5D_alloc_time_t* alloc_time) {
0251 herr_t err = H5Pget_alloc_time(plist_id, alloc_time);
0252 if (err < 0) {
0253 HDF5ErrMapper::ToException<PropertyException>("Error getting allocation time");
0254 }
0255 return err;
0256 }
0257
0258 inline herr_t h5p_set_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) {
0259 herr_t err = H5Pset_alloc_time(plist_id, alloc_time);
0260 if (err < 0) {
0261 HDF5ErrMapper::ToException<PropertyException>("Error setting allocation time");
0262 }
0263 return err;
0264 }
0265
0266 inline herr_t h5p_get_chunk_cache(hid_t dapl_id,
0267 size_t* rdcc_nslots,
0268 size_t* rdcc_nbytes,
0269 double* rdcc_w0) {
0270 herr_t err = H5Pget_chunk_cache(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);
0271 if (err < 0) {
0272 HDF5ErrMapper::ToException<PropertyException>("Error getting dataset cache parameters");
0273 }
0274 return err;
0275 }
0276
0277 inline herr_t h5p_set_chunk_cache(hid_t dapl_id,
0278 size_t rdcc_nslots,
0279 size_t rdcc_nbytes,
0280 double rdcc_w0) {
0281 herr_t err = H5Pset_chunk_cache(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);
0282 if (err < 0) {
0283 HDF5ErrMapper::ToException<PropertyException>("Error setting dataset cache parameters");
0284 }
0285 return err;
0286 }
0287
0288 inline herr_t h5p_set_create_intermediate_group(hid_t plist_id, unsigned crt_intmd) {
0289 herr_t err = H5Pset_create_intermediate_group(plist_id, crt_intmd);
0290 if (err < 0) {
0291 HDF5ErrMapper::ToException<PropertyException>(
0292 "Error setting property for create intermediate groups");
0293 }
0294 return err;
0295 }
0296
0297 inline herr_t h5p_get_create_intermediate_group(hid_t plist_id, unsigned* crt_intmd) {
0298 herr_t err = H5Pget_create_intermediate_group(plist_id, crt_intmd);
0299 if (err < 0) {
0300 HDF5ErrMapper::ToException<PropertyException>(
0301 "Error getting property for create intermediate groups");
0302 }
0303 return err;
0304 }
0305
0306 #ifdef H5_HAVE_PARALLEL
0307 inline herr_t h5p_set_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) {
0308 herr_t err = H5Pset_dxpl_mpio(dxpl_id, xfer_mode);
0309 if (err < 0) {
0310 HDF5ErrMapper::ToException<PropertyException>("Error setting H5Pset_dxpl_mpio.");
0311 }
0312 return err;
0313 }
0314
0315 inline herr_t h5p_get_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t* xfer_mode) {
0316 herr_t err = H5Pget_dxpl_mpio(dxpl_id, xfer_mode);
0317 if (err < 0) {
0318 HDF5ErrMapper::ToException<PropertyException>("Error getting H5Pset_dxpl_mpio.");
0319 }
0320 return err;
0321 }
0322
0323 inline herr_t h5p_get_mpio_no_collective_cause(hid_t plist_id,
0324 uint32_t* local_no_collective_cause,
0325 uint32_t* global_no_collective_cause) {
0326 herr_t err = H5Pget_mpio_no_collective_cause(plist_id,
0327 local_no_collective_cause,
0328 global_no_collective_cause);
0329 if (err < 0) {
0330 HDF5ErrMapper::ToException<PropertyException>("Failed to check mpio_no_collective_cause.");
0331 }
0332 return err;
0333 }
0334
0335 #endif
0336
0337 inline herr_t h5p_set_link_creation_order(hid_t plist_id, unsigned crt_order_flags) {
0338 herr_t err = H5Pset_link_creation_order(plist_id, crt_order_flags);
0339 if (err < 0) {
0340 HDF5ErrMapper::ToException<PropertyException>("Error setting LinkCreationOrder.");
0341 }
0342 return err;
0343 }
0344
0345 inline herr_t h5p_get_link_creation_order(hid_t plist_id, unsigned* crt_order_flags) {
0346 herr_t err = H5Pget_link_creation_order(plist_id, crt_order_flags);
0347 if (err < 0) {
0348 HDF5ErrMapper::ToException<PropertyException>(
0349 "Error getting property for link creation order");
0350 }
0351 return err;
0352 }
0353
0354 inline herr_t h5p_get_attr_phase_change(hid_t plist_id,
0355 unsigned* max_compact,
0356 unsigned* min_dense) {
0357 herr_t err = H5Pget_attr_phase_change(plist_id, max_compact, min_dense);
0358 if (err < 0) {
0359 HDF5ErrMapper::ToException<PropertyException>(
0360 "Error getting property for attribute phase change");
0361 }
0362 return err;
0363 }
0364
0365 inline herr_t h5p_set_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) {
0366 herr_t err = H5Pset_attr_phase_change(plist_id, max_compact, min_dense);
0367 if (err < 0) {
0368 HDF5ErrMapper::ToException<PropertyException>(
0369 "Error getting property for attribute phase change");
0370 }
0371 return err;
0372 }
0373
0374
0375 }
0376 }