From 3abaedf7958c9488ed68a266fcb23c0b557bed7d Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sun, 5 Jul 2015 14:05:37 -0500 Subject: [PATCH 1/2] Remove leftovers of traits::type_size --- hpx/runtime/actions/action_support.hpp | 4 - hpx/runtime/actions/transfer_action.hpp | 8 - hpx/runtime/parcelset/parcel.hpp | 32 ---- .../serialization/serialize_buffer.hpp | 17 -- hpx/traits/type_size.hpp | 164 ------------------ .../local/serialization_overhead.cpp | 22 ++- .../serialization/zero_copy_serialization.cpp | 19 +- 7 files changed, 33 insertions(+), 233 deletions(-) delete mode 100644 hpx/traits/type_size.hpp diff --git a/hpx/runtime/actions/action_support.hpp b/hpx/runtime/actions/action_support.hpp index 3c7b3acaef92..89b054f3684e 100644 --- a/hpx/runtime/actions/action_support.hpp +++ b/hpx/runtime/actions/action_support.hpp @@ -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; diff --git a/hpx/runtime/actions/transfer_action.hpp b/hpx/runtime/actions/transfer_action.hpp index 985af6e2d3ed..115db4098a23 100644 --- a/hpx/runtime/actions/transfer_action.hpp +++ b/hpx/runtime/actions/transfer_action.hpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -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::call(arguments_, flags); - } - /// Return whether the embedded action may require id-splitting bool may_require_id_splitting() const { diff --git a/hpx/runtime/parcelset/parcel.hpp b/hpx/runtime/parcelset/parcel.hpp index fe832af00198..2ae17ebf19e8 100644 --- a/hpx/runtime/parcelset/parcel.hpp +++ b/hpx/runtime/parcelset/parcel.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -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; @@ -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(); @@ -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 >::call(dests_, flags) + - traits::type_size >::call(addrs_, flags) + - this->get_action()->get_type_size(flags); // action - } - void save(serialization::output_archive& ar) const; void load(serialization::input_archive& ar); @@ -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(); @@ -762,15 +741,6 @@ namespace hpx { namespace parcelset namespace hpx { namespace traits { - template <> - struct type_size - { - 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 : boost::mpl::true_ @@ -804,8 +774,6 @@ namespace hpx { namespace traits #endif }} -#include - #include #endif diff --git a/hpx/runtime/serialization/serialize_buffer.hpp b/hpx/runtime/serialization/serialize_buffer.hpp index 84162e147224..b70b85761f36 100644 --- a/hpx/runtime/serialization/serialize_buffer.hpp +++ b/hpx/runtime/serialization/serialize_buffer.hpp @@ -457,23 +457,6 @@ namespace hpx { namespace traits struct supports_streaming_with_any > : boost::mpl::false_ {}; - - /////////////////////////////////////////////////////////////////////////// - // Calculate the required amount of raw memory for serialization. - template - struct type_size > - { - static std::size_t call(serialization::serialize_buffer 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 diff --git a/hpx/traits/type_size.hpp b/hpx/traits/type_size.hpp deleted file mode 100644 index f8435e38ccd2..000000000000 --- a/hpx/traits/type_size.hpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2012 Vinay C Amatya -// Copyright (c) 2007-2012 Hartmut Kaiser -// -// 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) - -#if !defined(HPX_giMcvwgb6F6ljtAzZHfS99KSE6gn3KnvWt1TgTfV) -#define HPX_giMcvwgb6F6ljtAzZHfS99KSE6gn3KnvWt1TgTfV - -#include -#include - -#include - -#include -#include -#include -#include - -namespace hpx { namespace traits -{ - ////////////////////////////////////////////////////////////////////////// - namespace detail - { - BOOST_MPL_HAS_XXX_TRAIT_DEF(uses_sizeof); - } - - template - struct type_size - { - typedef void uses_sizeof; - // flags are used for serialization options which may affect final encoded size - static BOOST_FORCEINLINE std::size_t call(T const&, int) - { - return sizeof(T); - } - }; - - // handle references - template - struct type_size - : type_size - {}; - - template - struct type_size - : type_size - {}; - - /////////////////////////////////////////////////////////////////////////// - // handle containers - namespace detail - { - BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) - BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator) - BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type) - BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) - - template - struct is_container - : boost::mpl::bool_< - has_value_type::value && has_iterator::value && - has_size_type::value && has_reference::value> - {}; - - template - struct is_container - : is_container - {}; - } - - template - struct type_size >::type> - { - template - static BOOST_FORCEINLINE - std::size_t call(T_ const& v, int flags, boost::mpl::false_) - { - std::size_t sum = sizeof(T_); - typename T_::const_iterator end = v.end(); - for (typename T_::const_iterator it = v.begin(); it != end; ++it) - sum += type_size::call(*it, flags); - return sum; - } - - template - static BOOST_FORCEINLINE - std::size_t call(T_ const& v, int, boost::mpl::true_) - { - return sizeof(T_) + v.size() * sizeof(typename T_::value_type); //-V119 - } - - static BOOST_FORCEINLINE std::size_t call(T const& v, int flags) - { - typedef boost::mpl::bool_< - traits::detail::has_uses_sizeof< - traits::type_size - >::value> predicate; - return call(v, flags, predicate()); - } - }; - - ////////////////////////////////////////////////////////////////////////// - // handle Fusion sequences - namespace detail - { - struct get_size - { - typedef std::size_t result_type; - - template - BOOST_FORCEINLINE std::size_t - operator()(std::size_t size, T const& t, int flags) const - { - return size + type_size::call(t, flags); - } - }; - } - - template - struct type_size >::type> - { - static BOOST_FORCEINLINE std::size_t call(T const& v, int flags) - { - std::size_t sum = sizeof(T); - return boost::fusion::accumulate(v, sum, - util::bind(traits::detail::get_size(), - util::placeholders::_1, util::placeholders::_2, flags)); - } - }; - - ////////////////////////////////////////////////////////////////////////// - template - struct type_size > - { - static BOOST_FORCEINLINE - std::size_t call(boost::shared_ptr const& p, int flags) - { - return type_size::call(*p, flags); - } - }; - - ////////////////////////////////////////////////////////////////////////// - template - struct type_size > - { - static BOOST_FORCEINLINE - std::size_t call(boost::intrusive_ptr const& p, int flags) - { - return type_size::call(*p, flags); - } - }; - - ////////////////////////////////////////////////////////////////////////// - template - BOOST_FORCEINLINE std::size_t get_type_size(T const& t, int flags) - { - return type_size::call(t, flags); - } -}} - -#endif diff --git a/tests/performance/local/serialization_overhead.cpp b/tests/performance/local/serialization_overhead.cpp index e5ccb8cdf16d..2e38ba7fb9d4 100644 --- a/tests/performance/local/serialization_overhead.cpp +++ b/tests/performance/local/serialization_overhead.cpp @@ -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 -#include -#include - #include #include #include #include #include +#include +#include +#include + #include // This function will never be called @@ -22,6 +22,18 @@ int test_function(hpx::serialization::serialize_buffer 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* 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) @@ -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 out_buffer; out_buffer.resize(arg_size + HPX_PARCEL_SERIALIZATION_OVERHEAD); diff --git a/tests/unit/serialization/zero_copy_serialization.cpp b/tests/unit/serialization/zero_copy_serialization.cpp index 5c12c2bd18dc..4c69f6f9250f 100644 --- a/tests/unit/serialization/zero_copy_serialization.cpp +++ b/tests/unit/serialization/zero_copy_serialization.cpp @@ -76,14 +76,26 @@ int test_function4(data_buffer 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* 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 out_buffer; std::vector out_chunks; + std::size_t arg_size = get_archive_size(outp, out_archive_flags, + zero_copy ? &out_chunks : 0); + std::vector out_buffer; boost::uint32_t dest_locality_id = outp.get_destination_locality_id(); out_buffer.resize(arg_size + HPX_PARCEL_SERIALIZATION_OVERHEAD); @@ -91,7 +103,8 @@ void test_parcel_serialization(hpx::parcelset::parcel outp, { // 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(); From 69127fef4a63cc266a2adc4c9d988c4500867fe1 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Fri, 17 Jul 2015 12:28:47 -0500 Subject: [PATCH 2/2] Removing remaining mentioning of type_size --- hpx/traits.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hpx/traits.hpp b/hpx/traits.hpp index 18164884f107..11020766b7bf 100644 --- a/hpx/traits.hpp +++ b/hpx/traits.hpp @@ -97,10 +97,6 @@ namespace hpx { namespace traits struct action_schedule_thread; /////////////////////////////////////////////////////////////////////////// - // Customization point for type_size - template - struct type_size; - template struct is_chunk_allocator;