Skip to content

Commit

Permalink
This patch makes sure that all parcels in a batch are properly handled
Browse files Browse the repository at this point in the history
- the split_gids container is not a zombie anymore for anything but the first parcel
  • Loading branch information
hkaiser committed May 25, 2017
1 parent 6941187 commit 4218539
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 1 addition & 3 deletions hpx/runtime/parcelset/detail/parcel_await.hpp
Expand Up @@ -32,9 +32,7 @@ namespace hpx { namespace parcelset { namespace detail {

put_parcel_type put_parcel_;
std::vector<parcel> parcels_;
hpx::serialization::detail::preprocess preprocess_;
hpx::serialization::output_archive archive_;
std::size_t overhead_;
int archive_flags_;
std::size_t idx_;
};
}}}
Expand Down
36 changes: 20 additions & 16 deletions src/runtime/parcelset/detail/parcel_await.cpp
Expand Up @@ -15,31 +15,33 @@
namespace hpx { namespace parcelset { namespace detail {

parcel_await::parcel_await(parcel&& p, int archive_flags,
parcel_await::put_parcel_type pp)
parcel_await::put_parcel_type pp)
: put_parcel_(std::move(pp)),
archive_(preprocess_, archive_flags),
overhead_(archive_.bytes_written()),
archive_flags_(archive_flags),
idx_(0)
{
parcels_.push_back(std::move(p));
}

parcel_await::parcel_await(std::vector<parcel>&& parcels, int archive_flags,
parcel_await::put_parcel_type pp)
parcel_await::put_parcel_type pp)
: put_parcel_(std::move(pp)),
parcels_(std::move(parcels)),
archive_(preprocess_, archive_flags),
overhead_(archive_.bytes_written()),
archive_flags_(archive_flags),
idx_(0)
{
}
{}

void parcel_await::apply()
{
for (/*idx_*/; idx_ != parcels_.size(); ++idx_)
{
archive_.reset();
archive_ << parcels_[idx_];
// collect the necessary size the serialization operation
hpx::serialization::detail::preprocess preprocess;
hpx::serialization::output_archive archive(preprocess, archive_flags_);
std::size_t overhead = archive.bytes_written();

archive.reset();
archive << parcels_[idx_];

// We are doing a fixed point iteration until we are sure that the
// serialization process requires nothing more to wait on ...
Expand All @@ -48,16 +50,18 @@ namespace hpx { namespace parcelset { namespace detail {
// need to do another await round for the id splitting
// - id_type: we need to await, if and only if, the credit of the
// needs to split.
if(preprocess_.has_futures())
if(preprocess.has_futures())
{
auto this_ = this->shared_from_this();
preprocess_([this_](){ this_->apply(); });
preprocess([this_](){ this_->apply(); });
return;
}
archive_.flush();
parcels_[idx_].size() = preprocess_.size() + overhead_;
parcels_[idx_].num_chunks() = archive_.get_num_chunks();
parcels_[idx_].set_split_gids(std::move(preprocess_.split_gids_));
archive.flush();

parcels_[idx_].size() = preprocess.size() + overhead;
parcels_[idx_].num_chunks() = archive.get_num_chunks();
parcels_[idx_].set_split_gids(std::move(preprocess.split_gids_));

put_parcel_(std::move(parcels_[idx_]));
}
}
Expand Down

0 comments on commit 4218539

Please sign in to comment.