Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range avoids serializes rank only once #276

Merged
merged 1 commit into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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