Skip to content

Commit

Permalink
Independent writing
Browse files Browse the repository at this point in the history
  • Loading branch information
jorblancoa committed Aug 14, 2024
1 parent 92f55ac commit 5f8a052
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/io/hdf5_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ HDF5Writer::HDF5Writer(const std::string& report_name, hid_t file_handler)
HDF5Writer::HDF5Writer(const std::string& report_name)
: report_name_(report_name) {
file_ = Implementation::prepare_write(report_name);
collective_list_ = Implementation::initialize_colective();
// Change this line to use independent list instead of collective
independent_list_ = Implementation::initialize_independent();

// Create enum type for the ordering of the spikes
spikes_attr_type_ = H5Tenum_create(H5T_STD_U8LE);
Expand Down Expand Up @@ -115,7 +116,8 @@ void HDF5Writer::write_2D(const std::vector<float>& buffer,

H5Sselect_hyperslab(
filespace, H5S_SELECT_SET, offset_.data(), nullptr, count.data(), nullptr);
H5Dwrite(dataset_, H5T_NATIVE_FLOAT, memspace, filespace, collective_list_, buffer.data());
// Change this line to use independent_list_ instead of collective_list_
H5Dwrite(dataset_, H5T_NATIVE_FLOAT, memspace, filespace, independent_list_, buffer.data());

H5Sclose(filespace);
H5Sclose(memspace);
Expand All @@ -142,7 +144,8 @@ void HDF5Writer::write(const std::string& dataset_name, const std::vector<T>& bu
hid_t filespace = H5Dget_space(data_set);

H5Sselect_hyperslab(filespace, H5S_SELECT_SET, &offset, nullptr, &dims, nullptr);
H5Dwrite(data_set, type, memspace, filespace, collective_list_, buffer.data());
// Change this line to use independent_list_ instead of collective_list_
H5Dwrite(data_set, type, memspace, filespace, independent_list_, buffer.data());

H5Sclose(filespace);
H5Sclose(memspace);
Expand Down
12 changes: 12 additions & 0 deletions src/library/implementation_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ struct Implementation {
static hid_t initialize_colective() {
return TImpl::initialize_colective();
}
static hid_t initialize_independent() {
return TImpl::initialize_independent();
}
static hsize_t get_offset(const std::string& report_name, hsize_t value) {
return TImpl::get_offset(report_name, value);
}
Expand Down Expand Up @@ -257,6 +260,12 @@ struct ParallelImplementation {
return collective_list;
}

static hid_t initialize_independent() {
hid_t independent_list = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(independent_list, H5FD_MPIO_INDEPENDENT);
return independent_list;
}

static hsize_t get_offset(const std::string& comm_name, hsize_t value) {
hsize_t offset = 0;
MPI_Scan(&value, &offset, 1, MPI_UNSIGNED_LONG, MPI_SUM, get_Comm(comm_name));
Expand Down Expand Up @@ -387,6 +396,9 @@ struct SerialImplementation {
static hid_t initialize_colective() {
return H5Pcreate(H5P_DATASET_XFER);
}
static hid_t initialize_independent() {
return H5Pcreate(H5P_DATASET_XFER);
}
static hsize_t get_offset(const std::string& /*report_name*/, hsize_t /*value*/) {
return 0;
};
Expand Down

0 comments on commit 5f8a052

Please sign in to comment.