Skip to content

Commit

Permalink
Merge pull request #2680 from STEllAR-GROUP/fixing_2679
Browse files Browse the repository at this point in the history
Fix bad size during archive creation
  • Loading branch information
hkaiser committed Jun 7, 2017
2 parents bb7ab04 + d65d18b commit 827652f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hpx/runtime/serialization/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace hpx { namespace serialization
naming::gid_type const & split_gid) = 0;
virtual void set_filter(binary_filter* filter) = 0;
virtual void save_binary(void const* address, std::size_t count) = 0;
virtual void save_binary_chunk(void const* address, std::size_t count) = 0;
virtual std::size_t save_binary_chunk(void const* address, std::size_t count) = 0;
virtual void reset() = 0;
virtual std::size_t get_num_chunks() const = 0;
virtual void flush() = 0;
Expand Down
12 changes: 8 additions & 4 deletions hpx/runtime/serialization/output_archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ namespace hpx { namespace serialization

private:
friend struct basic_archive<output_archive>;

template <class T>
friend class array;

Expand Down Expand Up @@ -357,11 +358,14 @@ namespace hpx { namespace serialization
void save_binary_chunk(void const * address, std::size_t count)
{
if(count == 0) return;
size_ += count;
if (disable_data_chunking())
if (disable_data_chunking()) {
size_ += count;
buffer_->save_binary(address, count);
else
buffer_->save_binary_chunk(address, count);
}
else {
// the size might grow if optimizations are not used
size_ += buffer_->save_binary_chunk(address, count);
}
}

typedef std::map<const void *, std::uint64_t> pointer_tracker;
Expand Down
11 changes: 8 additions & 3 deletions hpx/runtime/serialization/output_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,14 @@ namespace hpx { namespace serialization
current_ = new_current;
}

void save_binary_chunk(void const* address, std::size_t count) // override
std::size_t save_binary_chunk(void const* address, std::size_t count) // override
{
if (count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD)
{
// fall back to serialization_chunk-less archive
this->output_container::save_binary(address, count);
// the container has grown by count bytes
return count;
}
else {
HPX_ASSERT(
Expand All @@ -339,6 +341,8 @@ namespace hpx { namespace serialization
// add a new serialization_chunk referring to the external
// buffer
chunker_.push_back(create_pointer_chunk(address, count));
// the container did not grow
return 0;
}
}

Expand Down Expand Up @@ -408,17 +412,18 @@ namespace hpx { namespace serialization
this->current_ += count;
}

void save_binary_chunk(void const* address, std::size_t count) // override
std::size_t save_binary_chunk(void const* address, std::size_t count) // override
{
if (count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD)
{
// fall back to serialization_chunk-less archive
HPX_ASSERT(count != 0);
filter_->save(address, count);
this->current_ += count;
return count;
}
else {
this->base_type::save_binary_chunk(address, count);
return this->base_type::save_binary_chunk(address, count);
}
}

Expand Down

0 comments on commit 827652f

Please sign in to comment.