16inline hid_t convert_plist_type(
PropertyType propertyType) {
19 switch (propertyType) {
21 return H5P_OBJECT_CREATE;
23 return H5P_FILE_CREATE;
25 return H5P_FILE_ACCESS;
27 return H5P_DATASET_CREATE;
29 return H5P_DATASET_ACCESS;
31 return H5P_DATASET_XFER;
33 return H5P_GROUP_CREATE;
35 return H5P_GROUP_ACCESS;
37 return H5P_DATATYPE_CREATE;
39 return H5P_DATATYPE_ACCESS;
41 return H5P_STRING_CREATE;
43 return H5P_ATTRIBUTE_CREATE;
45 return H5P_OBJECT_COPY;
47 return H5P_LINK_CREATE;
49 return H5P_LINK_ACCESS;
51 HDF5ErrMapper::ToException<PropertyException>(
"Unsupported property list type");
62template <PropertyType T>
64 if (_hid != H5P_DEFAULT) {
67 if ((_hid = H5Pcreate(convert_plist_type(T))) < 0) {
68 HDF5ErrMapper::ToException<PropertyException>(
"Unable to create property list");
72template <PropertyType T>
75 _initializeIfNeeded();
79template <PropertyType T>
80template <
typename F,
typename... Args>
82 this->_initializeIfNeeded();
83 if (funct(this->_hid, args...) < 0) {
84 HDF5ErrMapper::ToException<PropertyException>(
"Error setting raw hdf5 property.");
89#if H5_VERSION_GE(1, 10, 1)
90inline FileSpaceStrategy::FileSpaceStrategy(H5F_fspace_strategy_t strategy,
95 , _threshold(threshold) {}
97inline FileSpaceStrategy::FileSpaceStrategy(
const FileCreateProps& fcpl) {
98 if (H5Pget_file_space_strategy(fcpl.getId(), &_strategy, &_persist, &_threshold) < 0) {
99 HDF5ErrMapper::ToException<PropertyException>(
"Unable to get file space strategy");
103inline void FileSpaceStrategy::apply(
const hid_t list)
const {
104 if (H5Pset_file_space_strategy(list, _strategy, _persist, _threshold) < 0) {
105 HDF5ErrMapper::ToException<PropertyException>(
"Error setting file space strategy.");
109inline H5F_fspace_strategy_t FileSpaceStrategy::getStrategy()
const {
113inline hbool_t FileSpaceStrategy::getPersist()
const {
117inline hsize_t FileSpaceStrategy::getThreshold()
const {
121inline FileSpacePageSize::FileSpacePageSize(hsize_t page_size)
122 : _page_size(page_size) {}
124inline void FileSpacePageSize::apply(
const hid_t list)
const {
125 if (H5Pset_file_space_page_size(list, _page_size) < 0) {
126 HDF5ErrMapper::ToException<PropertyException>(
"Error setting file space page size.");
130inline FileSpacePageSize::FileSpacePageSize(
const FileCreateProps& fcpl) {
131 if (H5Pget_file_space_page_size(fcpl.getId(), &_page_size) < 0) {
132 HDF5ErrMapper::ToException<PropertyException>(
"Unable to get file space page size");
136inline hsize_t FileSpacePageSize::getPageSize()
const {
140#ifndef H5_HAVE_PARALLEL
141inline PageBufferSize::PageBufferSize(
size_t page_buffer_size,
142 unsigned min_meta_percent,
143 unsigned min_raw_percent)
144 : _page_buffer_size(page_buffer_size)
145 , _min_meta(min_meta_percent)
146 , _min_raw(min_raw_percent) {}
149 if (H5Pget_page_buffer_size(plist.getId(), &_page_buffer_size, &_min_meta, &_min_raw) < 0) {
150 HDF5ErrMapper::ToException<PropertyException>(
"Error setting page buffer size.");
154inline void PageBufferSize::apply(
const hid_t list)
const {
155 if (H5Pset_page_buffer_size(list, _page_buffer_size, _min_meta, _min_raw) < 0) {
156 HDF5ErrMapper::ToException<PropertyException>(
"Error setting page buffer size.");
160inline size_t PageBufferSize::getPageBufferSize()
const {
161 return _page_buffer_size;
164inline unsigned PageBufferSize::getMinMetaPercent()
const {
168inline unsigned PageBufferSize::getMinRawPercent()
const {
174#ifdef H5_HAVE_PARALLEL
180inline void MPIOFileAccess::apply(
const hid_t list)
const {
181 if (H5Pset_fapl_mpio(list, _comm, _info) < 0) {
182 HDF5ErrMapper::ToException<FileException>(
"Unable to set-up MPIO Driver configuration");
186inline void MPIOCollectiveMetadata::apply(
const hid_t plist)
const {
187 auto read = MPIOCollectiveMetadataRead{collective_read_};
188 auto write = MPIOCollectiveMetadataWrite{collective_write_};
195 : collective_read_(collective)
196 , collective_write_(collective) {}
204 return collective_read_;
208 return collective_write_;
212inline void MPIOCollectiveMetadataRead::apply(
const hid_t plist)
const {
213 if (H5Pset_all_coll_metadata_ops(plist, collective_) < 0) {
214 HDF5ErrMapper::ToException<FileException>(
"Unable to request collective metadata reads");
223 if (H5Pget_all_coll_metadata_ops(plist.
getId(), &collective_) < 0) {
224 HDF5ErrMapper::ToException<PropertyException>(
"Error loading MPI metadata read.");
229 : collective_(collective) {}
231inline void MPIOCollectiveMetadataWrite::apply(
const hid_t plist)
const {
232 if (H5Pset_coll_metadata_write(plist, collective_) < 0) {
233 HDF5ErrMapper::ToException<FileException>(
"Unable to request collective metadata writes");
242 if (H5Pget_coll_metadata_write(plist.
getId(), &collective_) < 0) {
243 HDF5ErrMapper::ToException<PropertyException>(
"Error loading MPI metadata write.");
248 : collective_(collective) {}
257 if (H5Pget_libver_bounds(fapl.
getId(), &_low, &_high) < 0) {
258 HDF5ErrMapper::ToException<PropertyException>(
"Unable to access file version bounds");
263 return std::make_pair(_low, _high);
266inline void FileVersionBounds::apply(
const hid_t list)
const {
267 if (H5Pset_libver_bounds(list, _low, _high) < 0) {
268 HDF5ErrMapper::ToException<PropertyException>(
"Error setting file version bounds");
276 if (H5Pget_meta_block_size(fapl.
getId(), &_size) < 0) {
277 HDF5ErrMapper::ToException<PropertyException>(
"Unable to access file metadata block size");
281inline void MetadataBlockSize::apply(
const hid_t list)
const {
282 if (H5Pset_meta_block_size(list, _size) < 0) {
283 HDF5ErrMapper::ToException<PropertyException>(
"Error setting metadata block size");
291inline void EstimatedLinkInfo::apply(
const hid_t hid)
const {
292 if (H5Pset_est_link_info(hid, _entries, _length) < 0) {
293 HDF5ErrMapper::ToException<PropertyException>(
"Error setting estimated link info");
302 if (H5Pget_est_link_info(gcpl.
getId(), &_entries, &_length) < 0) {
303 HDF5ErrMapper::ToException<PropertyException>(
"Unable to access group link size property");
315inline void Chunking::apply(
const hid_t hid)
const {
316 if (H5Pset_chunk(hid,
static_cast<int>(_dims.size()), _dims.data()) < 0) {
317 HDF5ErrMapper::ToException<PropertyException>(
"Error setting chunk property");
325 :
Chunking(std::vector<hsize_t>{items}) {}
328 : _dims(max_dims + 1) {
329 auto n_loaded = H5Pget_chunk(plist.
getId(),
static_cast<int>(_dims.size()), _dims.data());
331 HDF5ErrMapper::ToException<PropertyException>(
"Error getting chunk size");
334 if (n_loaded >=
static_cast<int>(_dims.size())) {
335 *
this =
Chunking(plist, 8 * max_dims);
337 _dims.resize(
static_cast<size_t>(n_loaded));
345template <
typename... Args>
347 :
Chunking(std::vector<hsize_t>{item,
static_cast<hsize_t
>(args)...}) {}
349inline void Deflate::apply(
const hid_t hid)
const {
350 if (!H5Zfilter_avail(H5Z_FILTER_DEFLATE) || H5Pset_deflate(hid, _level) < 0) {
351 HDF5ErrMapper::ToException<PropertyException>(
"Error setting deflate property");
358inline void Szip::apply(
const hid_t hid)
const {
359 if (!H5Zfilter_avail(H5Z_FILTER_SZIP)) {
360 HDF5ErrMapper::ToException<PropertyException>(
"Error setting szip property");
363 if (H5Pset_szip(hid, _options_mask, _pixels_per_block) < 0) {
364 HDF5ErrMapper::ToException<PropertyException>(
"Error setting szip property");
368inline Szip::Szip(
unsigned int options_mask,
unsigned int pixels_per_block)
369 : _options_mask(options_mask)
370 , _pixels_per_block(pixels_per_block) {}
373 return _options_mask;
377 return _pixels_per_block;
380inline void Shuffle::apply(
const hid_t hid)
const {
381 if (!H5Zfilter_avail(H5Z_FILTER_SHUFFLE)) {
382 HDF5ErrMapper::ToException<PropertyException>(
"Error setting shuffle property");
385 if (H5Pset_shuffle(hid) < 0) {
386 HDF5ErrMapper::ToException<PropertyException>(
"Error setting shuffle property");
391 : _alloc_time(alloc_time) {}
394 if (H5Pget_alloc_time(dcpl.
getId(), &_alloc_time) < 0) {
395 HDF5ErrMapper::ToException<PropertyException>(
"Error getting allocation time");
399inline void AllocationTime::apply(hid_t dcpl)
const {
400 if (H5Pset_alloc_time(dcpl, _alloc_time) < 0) {
401 HDF5ErrMapper::ToException<PropertyException>(
"Error setting allocation time");
410 if (H5Pget_chunk_cache(dcpl.
getId(), &_numSlots, &_cacheSize, &_w0) < 0) {
411 HDF5ErrMapper::ToException<PropertyException>(
"Error getting dataset cache parameters");
415inline void Caching::apply(
const hid_t hid)
const {
416 if (H5Pset_chunk_cache(hid, _numSlots, _cacheSize, _w0) < 0) {
417 HDF5ErrMapper::ToException<PropertyException>(
"Error setting dataset cache parameters");
422 : _numSlots(numSlots)
423 , _cacheSize(cacheSize)
446inline void CreateIntermediateGroup::apply(
const hid_t hid)
const {
447 if (H5Pset_create_intermediate_group(hid, _create ? 1 : 0) < 0) {
448 HDF5ErrMapper::ToException<PropertyException>(
449 "Error setting property for create intermediate groups");
459 if (H5Pget_create_intermediate_group(hid, &c_bool) < 0) {
460 HDF5ErrMapper::ToException<PropertyException>(
461 "Error getting property for create intermediate groups");
464 _create = bool(c_bool);
471#ifdef H5_HAVE_PARALLEL
475inline void UseCollectiveIO::apply(
const hid_t hid)
const {
476 if (H5Pset_dxpl_mpio(hid, _enable ? H5FD_MPIO_COLLECTIVE : H5FD_MPIO_INDEPENDENT) < 0) {
477 HDF5ErrMapper::ToException<PropertyException>(
"Error setting H5Pset_dxpl_mpio.");
482 H5FD_mpio_xfer_t collective;
484 if (H5Pget_dxpl_mpio(dxpl.
getId(), &collective) < 0) {
485 HDF5ErrMapper::ToException<PropertyException>(
"Error getting H5Pset_dxpl_mpio.");
488 if (collective != H5FD_MPIO_COLLECTIVE && collective != H5FD_MPIO_INDEPENDENT) {
489 throw std::logic_error(
"H5Pget_dxpl_mpio returned something strange.");
492 _enable = collective == H5FD_MPIO_COLLECTIVE;
500 if (H5Pget_mpio_no_collective_cause(dxpl.
getId(), &_local_cause, &_global_cause) < 0) {
501 HDF5ErrMapper::ToException<PropertyException>(
"Failed to check mpio_no_collective_cause.");
506 return _local_cause == 0 && _global_cause == 0;
514 return _global_cause;
518 return {_local_cause, _global_cause};
534inline void LinkCreationOrder::apply(
const hid_t hid)
const {
535 if (H5Pset_link_creation_order(hid, _flags) < 0) {
536 HDF5ErrMapper::ToException<PropertyException>(
"Error setting LinkCreationOrder.");
541 if (H5Pget_link_creation_order(hid, &_flags) < 0) {
542 HDF5ErrMapper::ToException<PropertyException>(
543 "Error getting property for link creation order");
H5D_alloc_time_t getAllocationTime()
Definition H5PropertyList_misc.hpp:405
AllocationTime(H5D_alloc_time_t alloc_time)
Definition H5PropertyList_misc.hpp:390
size_t getNumSlots() const
Definition H5PropertyList_misc.hpp:426
Caching(const size_t numSlots, const size_t cacheSize, const double w0=static_cast< double >(H5D_CHUNK_CACHE_W0_DEFAULT))
Definition H5PropertyList_misc.hpp:421
size_t getCacheSize() const
Definition H5PropertyList_misc.hpp:430
double getW0() const
Definition H5PropertyList_misc.hpp:434
Definition H5PropertyList.hpp:405
const std::vector< hsize_t > & getDimensions() const noexcept
Definition H5PropertyList_misc.hpp:341
Chunking(const std::vector< hsize_t > &dims)
Definition H5PropertyList_misc.hpp:321
Deflate(unsigned level)
Definition H5PropertyList_misc.hpp:355
unsigned getEntries() const
The estimated number of links in a group.
Definition H5PropertyList_misc.hpp:307
EstimatedLinkInfo(unsigned entries, unsigned length)
Create a property with the request parameters.
Definition H5PropertyList_misc.hpp:297
unsigned getNameLength() const
The estimated length of the names of links.
Definition H5PropertyList_misc.hpp:311
std::pair< H5F_libver_t, H5F_libver_t > getVersion() const
Definition H5PropertyList_misc.hpp:262
FileVersionBounds(H5F_libver_t low, H5F_libver_t high)
Definition H5PropertyList_misc.hpp:252
LinkCreationOrder(unsigned flags)
Create the property.
Definition H5PropertyList.hpp:584
void fromPropertyList(hid_t hid)
Definition H5PropertyList_misc.hpp:540
unsigned getFlags() const
Definition H5PropertyList_misc.hpp:530
MPIOFileAccess(MPI_Comm comm, MPI_Info info)
Definition H5PropertyList_misc.hpp:176
uint32_t getGlobalCause() const
The global cause for a non-collective I/O.
Definition H5PropertyList_misc.hpp:513
bool wasCollective() const
Was the datatransfer collective?
Definition H5PropertyList_misc.hpp:505
std::pair< uint32_t, uint32_t > getCause() const
A pair of the local and global cause for non-collective I/O.
Definition H5PropertyList_misc.hpp:517
MpioNoCollectiveCause(const DataTransferProps &dxpl)
Definition H5PropertyList_misc.hpp:499
uint32_t getLocalCause() const
The local cause for a non-collective I/O.
Definition H5PropertyList_misc.hpp:509
Definition H5Object.hpp:54
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:65
PropertyListBase() noexcept
Definition H5PropertyList_misc.hpp:58
HDF5 property Lists.
Definition H5PropertyList.hpp:79
void _initializeIfNeeded()
Definition H5PropertyList_misc.hpp:63
void add(const P &property)
Definition H5PropertyList_misc.hpp:74
void add(const F &funct, const Args &... args)
Definition H5PropertyList_misc.hpp:81
Szip(unsigned options_mask=H5_SZIP_EC_OPTION_MASK, unsigned pixels_per_block=H5_SZIP_MAX_PIXELS_PER_BLOCK)
Definition H5PropertyList_misc.hpp:368
unsigned getPixelsPerBlock() const
Definition H5PropertyList_misc.hpp:376
unsigned getOptionsMask() const
Definition H5PropertyList_misc.hpp:372
bool isCollective() const
Does the property request collective IO?
Definition H5PropertyList_misc.hpp:495
UseCollectiveIO(bool enable=true)
Definition H5PropertyList_misc.hpp:472
Definition H5_definitions.hpp:15
PropertyType
Types of property lists.
Definition H5PropertyList.hpp:28
PropertyList< PropertyType::LINK_CREATE > LinkCreateProps
Definition H5PropertyList.hpp:118
PropertyList< PropertyType::FILE_CREATE > FileCreateProps
Definition H5PropertyList.hpp:106
PropertyList< PropertyType::FILE_ACCESS > FileAccessProps
Definition H5PropertyList.hpp:107