#include <h5cpp/all>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
namespace {
}
template <class Fn> double time_ms(Fn&& fn) {
auto t0 = clock::now();
fn();
auto t1 = clock::now();
}
void section(const char* title) {
}
}
int main() {
const auto data = make_data();
section("1. direct chunk (basic_pipeline_t, default)");
{
double t = time_ms([&]{
auto fd =
h5::create(
"pipeline_default.h5", H5F_ACC_TRUNC);
h5::write(fd,
"dataset", data, h5::current_dims{k_rows, k_cols},
});
<<
" write+read: " <<
std::setw(7) << t <<
" ms"
<< " roundtrip ok: " << (back == data ? "yes" : "NO") << "\n";
}
section("2. CAPI hyperslab (HDF5's own chunk processor + filters)");
{
double t = time_ms([&]{
auto fd =
h5::create(
"pipeline_capi.h5", H5F_ACC_TRUNC);
h5::current_dims{k_rows, k_cols},
h5::chunk{k_chunk, k_cols} | h5::gzip{4});
h5::write(ds, data.data(), h5::count{k_rows, k_cols}, h5::offset{0, 0});
});
<< " roundtrip ok: " << (back == data ? "yes" : "NO") << "\n";
}
section("3. h5::threads + h5::backpressure (DAPL, pool_pipeline_t)");
std::cout <<
" hardware_concurrency() = " << hw <<
"\n";
{
h5::dapl_t dapl = h5::threads{hw} | h5::backpressure{32};
double t = time_ms([&]{
auto fd =
h5::create(
"pipeline_threads.h5", H5F_ACC_TRUNC);
h5::current_dims{k_rows, k_cols},
h5::chunk{k_chunk, k_cols} | h5::gzip{4}, dapl);
});
auto fd_r =
h5::open(
"pipeline_threads.h5", H5F_ACC_RDONLY);
<< " roundtrip ok: " << (back == data ? "yes" : "NO") << "\n";
}
return 0;
}
h5::at_t create(const hid_t &parent, const std::string &path, args_t &&... args)
Create a new attribute of element type T on a parent HDF5 object.
Definition H5Acreate.hpp:100
T aread(const hid_t &ds, const std::string &name, const h5::acpl_t &acpl=h5::default_acpl)
Read an attribute by name and return its value as type T.
Definition H5Aread.hpp:76
h5::at_t open(const hid_t &parent, const std::string &path, const h5::acpl_t &acpl=h5::default_acpl)
Open an existing attribute by name on a parent HDF5 object.
Definition H5Aopen.hpp:56
h5::gr_t write(const LOC &parent, const std::string &path, const T &src)
Write a sparse matrix or vector as a CSC group.
Definition H5Dsparse.hpp:185
T hardware_concurrency(T... args)
T setprecision(T... args)