#include <mpi.h>
#include <h5cpp/all>
#include <chrono>
#include <numeric>
#include <vector>
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
int rank = 0, world_size = 0;
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &world_size);
{
auto fd =
h5::create(
"throughput.h5", H5F_ACC_TRUNC, h5::default_fcpl,
h5::max_dims{static_cast<hsize_t>(world_size), nrows},
h5::chunk{1, nchunk} | h5::alloc_time_early);
h5::current_dims{static_cast<hsize_t>(world_size), nrows},
h5::offset{static_cast<hsize_t>(rank), 0},
h5::count{1, nrows},
const double MB_per_s = (double(vbytes) / 1e6) / seconds;
MPI_Gather(&MB_per_s, 1, MPI_DOUBLE, rates.
data(), 1, MPI_DOUBLE, 0, comm);
if (rank == 0) {
std::cout <<
"WRITE: " << total <<
" MB/s aggregate ("
<< world_size << " ranks)\n";
}
}
{
auto fd =
h5::open(
"throughput.h5", H5F_ACC_RDWR,
h5::offset{static_cast<hsize_t>(rank), 0},
h5::count{1, nrows},
const double MB_per_s = (double(vbytes) / 1e6) / seconds;
MPI_Gather(&MB_per_s, 1, MPI_DOUBLE, rates.
data(), 1, MPI_DOUBLE, 0, comm);
if (rank == 0) {
std::cout <<
"READ: " << total <<
" MB/s aggregate ("
<< world_size << " ranks)\n";
}
}
MPI_Barrier(comm);
MPI_Finalize();
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
std::enable_if_t<!std::is_same_v< T, char ** >, void > read(const h5::ds_t &ds, T *ptr, args_t &&... args)
Read elements from an open HDF5 dataset into caller-allocated memory.
Definition H5Dread.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