Skip to content

Commit

Permalink
Merge pull request #276 from ValeevGroup/evaleev/improve/range-serial…
Browse files Browse the repository at this point in the history
…ization

Range avoids serializes rank only once
  • Loading branch information
evaleev authored May 25, 2021
2 parents e7f8f90 + 2827eb5 commit 8aa57c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/TiledArray/range.h
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,19 @@ class Range {

template <typename Archive>
void serialize(Archive& ar) {
ar& rank_& datavec_& offset_& volume_;
ar& rank_;
const auto four_x_rank = rank_ << 2;
// read via madness::archive::wrap to be able to
// - avoid having to serialize datavec_'s size
// - read old archives that represented datavec_ by bare ptr
if constexpr (madness::archive::is_input_archive<Archive>::value) {
datavec_.resize(four_x_rank);
ar >> madness::archive::wrap(datavec_.data(), four_x_rank);
} else if constexpr (madness::archive::is_output_archive<Archive>::value) {
ar << madness::archive::wrap(datavec_.data(), four_x_rank);
} else
abort(); // unreachable
ar& offset_& volume_;
}

void swap(Range_& other) {
Expand Down

0 comments on commit 8aa57c5

Please sign in to comment.