Skip to content

Commit

Permalink
fixup! Added extra offset to index_pointers * Discussed in AllenInsti…
Browse files Browse the repository at this point in the history
  • Loading branch information
Blanco Alonso Jorge committed Apr 27, 2020
1 parent 49f80bf commit a708d0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/reports/data/sonata_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SonataData::SonataData(const std::string& report_name,
, hdf5_writer_(std::make_unique<HDF5Writer>(report_name))
, nodes_(nodes) {
prepare_buffer(max_buffer_size);
index_pointers_.resize(nodes->size() + 1);
index_pointers_.resize(nodes->size());
time_ = {tstart, tend, dt};

reporting_period_ = static_cast<int>(dt / SonataReport::atomic_step_);
Expand Down Expand Up @@ -207,6 +207,11 @@ void SonataData::prepare_dataset() {
total_elements_,
element_offset);

int last_rank = Implementation::get_last_rank(report_name_, SonataReport::rank_);
if(SonataReport::rank_ == last_rank) {
index_pointers_.resize(nodes_->size() + 1);
}

// Prepare index pointers
if (!index_pointers_.empty()) {
index_pointers_[0] = element_offset;
Expand Down
12 changes: 12 additions & 0 deletions src/reports/library/implementation_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct Implementation {
static hsize_t get_offset(const std::string& report_name, hsize_t value) {
return TImpl::get_offset(report_name, value);
}
static int get_last_rank(const std::string& report_name, int value) {
return TImpl::get_last_rank(report_name, value);
}
static hsize_t get_global_dims(const std::string& report_name, hsize_t value) {
return TImpl::get_global_dims(report_name, value);
}
Expand Down Expand Up @@ -186,6 +189,12 @@ struct ParallelImplementation {
return offset;
};

static int get_last_rank(const std::string& report_name, int value) {
int last_rank = 0;
MPI_Allreduce(&value, &last_rank, 1, MPI_INT, MPI_MAX, get_Comm(report_name));
return last_rank;
}

static hsize_t get_global_dims(const std::string& report_name, hsize_t value) {
hsize_t global_dims = value;
MPI_Allreduce(&value, &global_dims, 1, MPI_UNSIGNED_LONG, MPI_SUM, get_Comm(report_name));
Expand Down Expand Up @@ -293,6 +302,9 @@ struct SerialImplementation {
static hsize_t get_offset(const std::string& /*report_name*/, hsize_t /*value*/) {
return 0;
};
static int get_last_rank(const std::string& /*report_name*/, hsize_t /*value*/) {
return 0;
};
static hsize_t get_global_dims(const std::string& /*report_name*/, hsize_t value) {
return value;
};
Expand Down

0 comments on commit a708d0d

Please sign in to comment.