PURIFY
Next-generation radio interferometric imaging
Public Member Functions | List of all members
purify::H5::H5Handler Class Reference

Purify interface class to handle HDF5 input files. More...

#include <h5reader.h>

Public Member Functions

 H5Handler ()=delete
 
 H5Handler (const std::string &filename)
 Default constructor (serial behaviour) More...
 
template<typename T = double>
std::vector< T > read (const std::string &label) const
 Method to read the entire dataset. More...
 
template<typename T = double>
std::vector< T > distread (const std::string &label)
 
template<typename T = double>
std::vector< T > stochread (const std::string &label, size_t batchsize, bool shuffle=false)
 

Detailed Description

Purify interface class to handle HDF5 input files.

Definition at line 48 of file h5reader.h.

Constructor & Destructor Documentation

◆ H5Handler() [1/2]

purify::H5::H5Handler::H5Handler ( )
delete

◆ H5Handler() [2/2]

purify::H5::H5Handler::H5Handler ( const std::string &  filename)
inline

Default constructor (serial behaviour)

Definition at line 55 of file h5reader.h.

56  : _comm(nullptr),
57  _fap(HighFive::FileAccessProps{}),
58  _dtp(HighFive::DataTransferProps{}),
59  _file(filename, HighFive::File::ReadOnly) {
60  _datalen = _slicepos = _slicelen = _batchpos = 0;
61  }

Member Function Documentation

◆ distread()

template<typename T = double>
std::vector<T> purify::H5::H5Handler::distread ( const std::string &  label)
inline

Method to read a dataset slice with slices evenly split across MPI ranks

Definition at line 84 of file h5reader.h.

84  {
85  if (!_comm) throw std::runtime_error("No MPI-collective reading enabled!");
86  _loadDataSet(label);
87  std::vector<T> data;
88  data.reserve(_slicelen);
89  _ds[label].select({_slicepos}, {_slicelen}).read(data, _dtp);
90  return data;
91  }
std::vector< T > read(const std::string &label) const
Method to read the entire dataset.
Definition: h5reader.h:76

References read().

Referenced by TEST_CASE().

◆ read()

template<typename T = double>
std::vector<T> purify::H5::H5Handler::read ( const std::string &  label) const
inline

Method to read the entire dataset.

Definition at line 76 of file h5reader.h.

76  {
77  auto dataset = _file.getDataSet(label);
78  return dataset.read<std::vector<T>>();
79  }

Referenced by distread(), purify::H5::read_visibility(), stochread(), and TEST_CASE().

◆ stochread()

template<typename T = double>
std::vector<T> purify::H5::H5Handler::stochread ( const std::string &  label,
size_t  batchsize,
bool  shuffle = false 
)
inline

Method to stochastically draw a subset from the distributed dataset slice

Definition at line 96 of file h5reader.h.

96  {
97  if (!_comm) throw std::runtime_error("No MPI-collective reading enabled!");
98 
99  _loadDataSet(label);
100  if (shuffle) _shuffle();
101 
102  std::vector<T> data;
103  data.reserve(batchsize);
104  // account for wrap around near
105  // the edges of the slice
106  size_t pos = _batchpos;
107  while (batchsize) {
108  std::vector<T> tmp;
109  size_t len = std::min(batchsize, _slicepos + _slicelen - pos);
110  _ds[label].select({pos}, {len}).read(tmp, _dtp);
111  data.insert(data.end(), std::make_move_iterator(std::begin(tmp)),
112  std::make_move_iterator(std::end(tmp)));
113  pos = _slicepos;
114  batchsize -= len;
115  }
116  return data;
117  }

References read().

Referenced by purify::H5::stochread_visibility(), and TEST_CASE().


The documentation for this class was generated from the following file: