1 #ifndef DASH__IO__HDF5__INPUT_STREAM_H__ 2 #define DASH__IO__HDF5__INPUT_STREAM_H__ 4 #ifdef DASH_ENABLE_HDF5 9 #include <dash/Matrix.h> 10 #include <dash/Array.h> 30 std::string _filename;
34 bool _use_cust_conv =
false;
37 std::vector<std::shared_future<void> > _async_ops;
51 : _filename(filename), _dataset(
"data"), _launch_policy(lpolicy) {
55 "Requested ASIO but DART does not support " 56 "multi-threaded access. Blocking IO is used" 83 if (!_async_ops.empty()) {
84 _async_ops.back().wait();
100 DASH_LOG_DEBUG(
"flush input stream", _async_ops.size());
101 if (!_async_ops.empty()) {
102 _async_ops.back().wait();
104 DASH_LOG_DEBUG(
"input stream flushed");
112 is._dataset = tbl._dataset;
130 is._converter = conv;
131 is._use_cust_conv =
true;
136 template <
typename Container_t>
140 template <
typename Container_t>
141 void _load_object_impl(Container_t& container) {
142 if (_use_cust_conv) {
143 StoreHDF::read(container, _filename, _dataset, _foptions, _converter);
149 template <
typename Container_t>
150 void _load_object_impl_async(Container_t& container) {
151 auto pos = _async_ops.size();
154 auto s_filename = _filename;
155 auto s_dataset = _dataset;
156 auto s_foptions = _foptions;
157 auto s_use_cust_conv = _use_cust_conv;
158 type_converter_fun_type s_converter = _converter;
162 std::launch::async, [&, pos, s_filename, s_dataset, s_foptions,
163 s_converter, s_use_cust_conv]() {
166 auto last_task = _async_ops[pos - 1];
167 DASH_LOG_DEBUG(
"waiting for future", pos);
170 DASH_LOG_DEBUG(
"execute async io task");
172 if (s_use_cust_conv) {
178 DASH_LOG_DEBUG(
"execute async io task done");
180 _async_ops.push_back(fut);
188 #include <dash/io/hdf5/internal/InputStream-inl.h> 190 #endif // DASH_ENABLE_HDF5 192 #endif // DASH__IO__HDF5__INPUT_STREAM_H__ bool is_multithreaded()
Check whether DASH has been initialized with support for multi-threaded access.
This class is a simple memory pool which holds allocates elements of size ValueType.
Stream manipulator class to set the dash pattern key of the dataset.
InputStream & flush()
Synchronizes with the data source.
std::string pattern_metadata_key
Metadata attribute key in HDF5 file.
friend InputStream & operator>>(InputStream &is, setpattern_key pk)
set metadata key at which the pattern will be stored
friend InputStream & operator>>(InputStream &is, const type_converter conv)
custom type converter function to convert native type to HDF5 type
bool restore_pattern
Restore pattern from metadata if HDF5 file contains any.
friend InputStream & operator>>(InputStream &is, const dataset tbl)
set name of dataset
InputStream(std::string filename)
Creates an HDF5 input stream using blocking IO.
Stream manipulator class to specify the hdf5 dataset.
InputStream(dash::launch lpolicy, std::string filename)
Creates an HDF5 input stream using a launch policy.
static std::enable_if< _compatible_pattern< typename Container_t::pattern_type >) &&_is_origin_view< Container_t >), void >::type read(Container_t &matrix, std::string filename, std::string datapath, hdf5_options foptions=hdf5_options(), type_converter_fun_type to_h5_dt_converter=get_h5_datatype< typename Container_t::value_type >)
Read an HDF5 dataset into a dash container using parallel IO if the matrix is already allocated...
synchronous launch policy
friend InputStream & operator>>(InputStream &is, restore_pattern rs)
set whether pattern layout should be restored from metadata
Converter function to convert non-POT types and especially structs to HDF5 types. ...
Stream manipulator class to set whether the pattern should be restored from the hdf5 dataset metadata...
Base type for device-specific IO streams.
Options which can be passed to dash::io::StoreHDF::write to specify how existing structures are treat...
Type facade wrapping dash::io::IOSBaseMode and its device-dependent specializations.