Skip to content

Commit

Permalink
Remove leftovers of traits::type_size
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jul 5, 2015
1 parent 11210da commit 3abaedf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 233 deletions.
4 changes: 0 additions & 4 deletions hpx/runtime/actions/action_support.hpp
Expand Up @@ -227,10 +227,6 @@ namespace hpx { namespace actions
/// Return the thread stacksize this action has to be executed with
virtual threads::thread_stacksize get_thread_stacksize() const = 0;

/// Return the size of action arguments in bytes
/// flags should contain serialization options which affect the space required
virtual std::size_t get_type_size(int flags) const = 0;

/// Return whether the embedded action may require id-splitting
virtual bool may_require_id_splitting() const = 0;

Expand Down
8 changes: 0 additions & 8 deletions hpx/runtime/actions/transfer_action.hpp
Expand Up @@ -31,7 +31,6 @@
#include <hpx/traits/action_schedule_thread.hpp>
#include <hpx/traits/action_serialization_filter.hpp>
#include <hpx/traits/action_stacksize.hpp>
#include <hpx/traits/type_size.hpp>
#include <hpx/traits/serialize_as_future.hpp>
#include <hpx/util/move.hpp>
#include <hpx/util/serialize_exception.hpp>
Expand Down Expand Up @@ -256,13 +255,6 @@ namespace hpx { namespace actions
return stacksize_;
}

/// Return the size of action arguments in bytes
/// flags should contain serialization options which affect the space required
std::size_t get_type_size(int flags) const
{
return traits::type_size<arguments_type>::call(arguments_, flags);
}

/// Return whether the embedded action may require id-splitting
bool may_require_id_splitting() const
{
Expand Down
32 changes: 0 additions & 32 deletions hpx/runtime/parcelset/parcel.hpp
Expand Up @@ -19,7 +19,6 @@
#include <hpx/runtime/serialization/binary_filter.hpp>
#include <hpx/runtime/serialization/serialize.hpp>
#include <hpx/util/assert.hpp>
#include <hpx/traits/type_size.hpp>
#include <hpx/traits/serialize_as_future.hpp>

#include <boost/intrusive_ptr.hpp>
Expand Down Expand Up @@ -96,8 +95,6 @@ namespace hpx { namespace parcelset
virtual naming::gid_type get_parcel_id() const = 0;
virtual void set_parcel_id(naming::gid_type const& id) = 0;

virtual std::size_t get_type_size(int flags) const = 0;

virtual bool may_require_id_splitting() const = 0;

virtual bool does_termination_detection() const = 0;
Expand Down Expand Up @@ -318,11 +315,6 @@ namespace hpx { namespace parcelset
data_.parcel_id_ = id;
}

std::size_t get_type_size(int flags) const
{
return sizeof(parcel_buffer) + this->get_action()->get_type_size(flags);
}

bool may_require_id_splitting() const
{
return this->get_action()->may_require_id_splitting();
Expand Down Expand Up @@ -508,14 +500,6 @@ namespace hpx { namespace parcelset
data_.parcel_id_ = id;
}

std::size_t get_type_size(int flags) const
{
return sizeof(parcel_buffer) +
traits::type_size<std::vector<naming::id_type> >::call(dests_, flags) +
traits::type_size<std::vector<naming::address> >::call(addrs_, flags) +
this->get_action()->get_type_size(flags); // action
}

void save(serialization::output_archive& ar) const;

void load(serialization::input_archive& ar);
Expand Down Expand Up @@ -716,11 +700,6 @@ namespace hpx { namespace parcelset
return data_->get_message_handler(ph, loc, *this);
}

std::size_t get_type_size(int flags) const
{
return data_->get_type_size(flags);
}

bool may_require_id_splitting() const
{
return data_->may_require_id_splitting();
Expand Down Expand Up @@ -762,15 +741,6 @@ namespace hpx { namespace parcelset

namespace hpx { namespace traits
{
template <>
struct type_size<hpx::parcelset::parcel>
{
static std::size_t call(hpx::parcelset::parcel const& p, int flags)
{
return sizeof(hpx::parcelset::parcel) + p.get_type_size(flags);
}
};

template <>
struct serialize_as_future<hpx::parcelset::parcel>
: boost::mpl::true_
Expand Down Expand Up @@ -804,8 +774,6 @@ namespace hpx { namespace traits
#endif
}}

#include <hpx/traits/type_size.hpp>

#include <hpx/config/warnings_suffix.hpp>

#endif
17 changes: 0 additions & 17 deletions hpx/runtime/serialization/serialize_buffer.hpp
Expand Up @@ -457,23 +457,6 @@ namespace hpx { namespace traits
struct supports_streaming_with_any<serialization::serialize_buffer<T, Allocator> >
: boost::mpl::false_
{};

///////////////////////////////////////////////////////////////////////////
// Calculate the required amount of raw memory for serialization.
template <typename T, typename Allocator>
struct type_size<serialization::serialize_buffer<T, Allocator> >
{
static std::size_t call(serialization::serialize_buffer<T, Allocator> const& b, int flags)
{
if (flags & hpx::serialization::disable_data_chunking) {
return b.size() * sizeof(T) + sizeof(std::size_t) + sizeof(Allocator); //-V119
}
else {
// size required to specify a new pointer chunk is coming (needs checking)
return 8;
}
}
};
}}

#endif
164 changes: 0 additions & 164 deletions hpx/traits/type_size.hpp

This file was deleted.

22 changes: 17 additions & 5 deletions tests/performance/local/serialization_overhead.cpp
Expand Up @@ -3,16 +3,16 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <algorithm>
#include <iterator>
#include <fstream>

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/include/serialization.hpp>
#include <hpx/util/high_resolution_timer.hpp>

#include <algorithm>
#include <iterator>
#include <fstream>

#include <boost/format.hpp>

// This function will never be called
Expand All @@ -22,6 +22,18 @@ int test_function(hpx::serialization::serialize_buffer<double> const& b)
}
HPX_PLAIN_ACTION(test_function, test_action)

std::size_t get_archive_size(hpx::parcelset::parcel const& p,
boost::uint32_t flags,
std::vector<hpx::serialization::serialization_chunk>* chunks)
{
// gather the required size for the archive
hpx::serialization::detail::size_gatherer_container gather_size;
hpx::serialization::output_archive archive(
gather_size, flags, 0, chunks);
archive << p;
return gather_size.size();
}

///////////////////////////////////////////////////////////////////////////////
double benchmark_serialization(std::size_t data_size, std::size_t iterations,
bool continuation, bool zerocopy)
Expand Down Expand Up @@ -100,7 +112,7 @@ double benchmark_serialization(std::size_t data_size, std::size_t iterations,

for (std::size_t i = 0; i != iterations; ++i)
{
std::size_t arg_size = hpx::traits::get_type_size(outp, out_archive_flags);
std::size_t arg_size = get_archive_size(outp, out_archive_flags, chunks);
std::vector<char> out_buffer;

out_buffer.resize(arg_size + HPX_PARCEL_SERIALIZATION_OVERHEAD);
Expand Down
19 changes: 16 additions & 3 deletions tests/unit/serialization/zero_copy_serialization.cpp
Expand Up @@ -76,22 +76,35 @@ int test_function4(data_buffer<double> const& b)
}
HPX_PLAIN_ACTION(test_function4, test_action4)

std::size_t get_archive_size(hpx::parcelset::parcel const& p,
boost::uint32_t flags,
std::vector<hpx::serialization::serialization_chunk>* chunks)
{
// gather the required size for the archive
hpx::serialization::detail::size_gatherer_container gather_size;
hpx::serialization::output_archive archive(gather_size, flags, 0, chunks);
archive << p;
return gather_size.size();
}

///////////////////////////////////////////////////////////////////////////////
void test_parcel_serialization(hpx::parcelset::parcel outp,
int out_archive_flags, bool zero_copy)
{
// serialize data
std::size_t arg_size = hpx::traits::get_type_size(outp, out_archive_flags);
std::vector<char> out_buffer;
std::vector<hpx::serialization::serialization_chunk> out_chunks;
std::size_t arg_size = get_archive_size(outp, out_archive_flags,
zero_copy ? &out_chunks : 0);
std::vector<char> out_buffer;
boost::uint32_t dest_locality_id = outp.get_destination_locality_id();

out_buffer.resize(arg_size + HPX_PARCEL_SERIALIZATION_OVERHEAD);

{
// create an output archive and serialize the parcel
hpx::serialization::output_archive archive(
out_buffer, out_archive_flags, dest_locality_id, zero_copy ? &out_chunks : 0);
out_buffer, out_archive_flags, dest_locality_id,
zero_copy ? &out_chunks : 0);
archive << outp;

arg_size = archive.bytes_written();
Expand Down

0 comments on commit 3abaedf

Please sign in to comment.