diff options
author | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-09-14 10:56:04 +0300 |
---|---|---|
committer | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-09-14 10:56:04 +0300 |
commit | cf4d965eab8e00116d391487e1775b363a968aef (patch) | |
tree | 388c4ba30250b81f5a03bd412f630457cd9cb49d /contrib/restricted/boost | |
parent | a8f6f495b07e14c4c4356073ead36e2bea67ffd6 (diff) | |
download | ydb-cf4d965eab8e00116d391487e1775b363a968aef.tar.gz |
Reimport boost/property_map as a separate project
Diffstat (limited to 'contrib/restricted/boost')
23 files changed, 37 insertions, 2784 deletions
diff --git a/contrib/restricted/boost/CMakeLists.txt b/contrib/restricted/boost/CMakeLists.txt index e932a69337..b6ff8b2fc5 100644 --- a/contrib/restricted/boost/CMakeLists.txt +++ b/contrib/restricted/boost/CMakeLists.txt @@ -61,6 +61,7 @@ add_subdirectory(pool) add_subdirectory(predef) add_subdirectory(preprocessor) add_subdirectory(program_options) +add_subdirectory(property_map) add_subdirectory(property_tree) add_subdirectory(proto) add_subdirectory(ptr_container) diff --git a/contrib/restricted/boost/boost/property_map/compose_property_map.hpp b/contrib/restricted/boost/boost/property_map/compose_property_map.hpp deleted file mode 100644 index 4d8941d38e..0000000000 --- a/contrib/restricted/boost/boost/property_map/compose_property_map.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2013 Eurodecision -// Authors: Guillaume Pinot -// -// 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) -// -// See http://www.boost.org/libs/property_map for documentation. - -#ifndef BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP -#define BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP - -#include <boost/property_map/property_map.hpp> -#include <boost/type_traits.hpp> - -namespace boost { - -// A compose property map: make_compose_property_map(f, g)[x] == f[g[x]] -// -// g must be a readable property map. -// The category of compose_property_map(f, g) is the category of f. - -template <typename FPMap, typename GPMap> -class compose_property_map -{ -public: - typedef typename boost::property_traits<FPMap>::category category; - typedef typename boost::property_traits<GPMap>::key_type key_type; - typedef typename boost::property_traits<FPMap>::value_type value_type; - typedef typename boost::property_traits<FPMap>::reference reference; - - inline compose_property_map(const FPMap &f_p, const GPMap &g_p): - f(f_p), g(g_p) - {} - - inline compose_property_map() {} - - inline reference - operator[](const key_type &v) const { - return f[get(g, v)]; - } - - // return type of get(): - // if (reference is not a ref) - // value_type - // else if (reference is const) - // reference - // else - // const value_type& - inline friend typename boost::mpl::if_< - boost::mpl::not_< boost::is_reference<reference> >, - value_type, - typename boost::mpl::if_< - boost::is_const<reference>, - reference, - const value_type& - >::type - >::type - get(const compose_property_map &m, const key_type &k) { - return get(m.f, get(m.g, k)); - } - - inline friend void - put(const compose_property_map &m, const key_type &k, const value_type &v) { - put(m.f, get(m.g, k), v); - } - -private: - FPMap f; - GPMap g; -}; - -template <class FPMap, class GPMap> -inline compose_property_map<FPMap, GPMap> -make_compose_property_map(const FPMap &f, const GPMap &g) { - return compose_property_map<FPMap, GPMap>(f, g); -} - -} // namespace boost - -#endif // BOOST_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP diff --git a/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp b/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp deleted file mode 100644 index 4f5de47cab..0000000000 --- a/contrib/restricted/boost/boost/property_map/dynamic_property_map.hpp +++ /dev/null @@ -1,352 +0,0 @@ -#ifndef DYNAMIC_PROPERTY_MAP_RG09302004_HPP -#define DYNAMIC_PROPERTY_MAP_RG09302004_HPP - -// Copyright 2004-5 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// dynamic_property_map.hpp - -// Support for runtime-polymorphic property maps. This header is factored -// out of Doug Gregor's routines for reading GraphML files for use in reading -// GraphViz graph files. - -// Authors: Doug Gregor -// Ronald Garcia -// - - -#include <boost/config.hpp> -#include <boost/throw_exception.hpp> -#include <boost/property_map/property_map.hpp> -#include <boost/lexical_cast.hpp> -#include <boost/any.hpp> -#include <boost/function/function3.hpp> -#include <boost/type_traits/is_convertible.hpp> -#include <typeinfo> -#include <boost/mpl/bool.hpp> -#include <stdexcept> -#include <sstream> -#include <map> -#include <boost/type.hpp> -#include <boost/smart_ptr.hpp> - -namespace boost { - -namespace detail { - - // read_value - - // A wrapper around lexical_cast, which does not behave as - // desired for std::string types. - template<typename Value> - inline Value read_value(const std::string& value) - { return boost::lexical_cast<Value>(value); } - - template<> - inline std::string read_value<std::string>(const std::string& value) - { return value; } - -} - - -// dynamic_property_map - -// This interface supports polymorphic manipulation of property maps. -class dynamic_property_map -{ -public: - virtual ~dynamic_property_map() { } - - virtual boost::any get(const any& key) = 0; - virtual std::string get_string(const any& key) = 0; - virtual void put(const any& key, const any& value) = 0; - virtual const std::type_info& key() const = 0; - virtual const std::type_info& value() const = 0; -}; - - -////////////////////////////////////////////////////////////////////// -// Property map exceptions -////////////////////////////////////////////////////////////////////// - -struct dynamic_property_exception : public std::exception { - virtual ~dynamic_property_exception() {} - virtual const char* what() const noexcept = 0; -}; - -struct property_not_found : public dynamic_property_exception { - std::string property; - mutable std::string statement; - property_not_found(const std::string& property) : property(property) {} - virtual ~property_not_found() {} - - const char* what() const noexcept { - if(statement.empty()) - statement = - std::string("Property not found: ") + property + "."; - - return statement.c_str(); - } -}; - -struct dynamic_get_failure : public dynamic_property_exception { - std::string property; - mutable std::string statement; - dynamic_get_failure(const std::string& property) : property(property) {} - virtual ~dynamic_get_failure() {} - - const char* what() const noexcept { - if(statement.empty()) - statement = - std::string( - "dynamic property get cannot retrieve value for property: ") - + property + "."; - - return statement.c_str(); - } -}; - -struct dynamic_const_put_error : public dynamic_property_exception { - virtual ~dynamic_const_put_error() {} - - const char* what() const noexcept { - return "Attempt to put a value into a const property map: "; - } -}; - - -namespace detail { - -// Trying to work around VC++ problem that seems to relate to having too many -// functions named "get" -template <typename PMap, typename Key> -typename boost::property_traits<PMap>::reference -get_wrapper_xxx(const PMap& pmap, const Key& key) { - using boost::get; - return get(pmap, key); -} - -// -// dynamic_property_map_adaptor - -// property-map adaptor to support runtime polymorphism. -template<typename PropertyMap> -class dynamic_property_map_adaptor : public dynamic_property_map -{ - typedef typename property_traits<PropertyMap>::key_type key_type; - typedef typename property_traits<PropertyMap>::value_type value_type; - typedef typename property_traits<PropertyMap>::category category; - - // do_put - overloaded dispatches from the put() member function. - // Attempts to "put" to a property map that does not model - // WritablePropertyMap result in a runtime exception. - - // in_value must either hold an object of value_type or a string that - // can be converted to value_type via iostreams. - void do_put(const any& in_key, const any& in_value, mpl::bool_<true>) - { - using boost::put; - - key_type key_ = any_cast<key_type>(in_key); - if (in_value.type() == typeid(value_type)) { - put(property_map_, key_, any_cast<value_type>(in_value)); - } else { - // if in_value is an empty string, put a default constructed value_type. - std::string v = any_cast<std::string>(in_value); - if (v.empty()) { - put(property_map_, key_, value_type()); - } else { - put(property_map_, key_, detail::read_value<value_type>(v)); - } - } - } - - void do_put(const any&, const any&, mpl::bool_<false>) - { - BOOST_THROW_EXCEPTION(dynamic_const_put_error()); - } - -public: - explicit dynamic_property_map_adaptor(const PropertyMap& property_map_) - : property_map_(property_map_) { } - - virtual boost::any get(const any& key_) - { - return get_wrapper_xxx(property_map_, any_cast<typename boost::property_traits<PropertyMap>::key_type>(key_)); - } - - virtual std::string get_string(const any& key_) - { - std::ostringstream out; - out << get_wrapper_xxx(property_map_, any_cast<typename boost::property_traits<PropertyMap>::key_type>(key_)); - return out.str(); - } - - virtual void put(const any& in_key, const any& in_value) - { - do_put(in_key, in_value, - mpl::bool_<(is_convertible<category*, - writable_property_map_tag*>::value)>()); - } - - virtual const std::type_info& key() const { return typeid(key_type); } - virtual const std::type_info& value() const { return typeid(value_type); } - - PropertyMap& base() { return property_map_; } - const PropertyMap& base() const { return property_map_; } - -private: - PropertyMap property_map_; -}; - -} // namespace detail - -// -// dynamic_properties - -// container for dynamic property maps -// -struct dynamic_properties -{ - typedef std::multimap<std::string, boost::shared_ptr<dynamic_property_map> > - property_maps_type; - typedef boost::function3<boost::shared_ptr<dynamic_property_map>, - const std::string&, - const boost::any&, - const boost::any&> generate_fn_type; -public: - - typedef property_maps_type::iterator iterator; - typedef property_maps_type::const_iterator const_iterator; - - dynamic_properties() : generate_fn() { } - dynamic_properties(const generate_fn_type& g) : generate_fn(g) {} - - ~dynamic_properties() {} - - template<typename PropertyMap> - dynamic_properties& - property(const std::string& name, PropertyMap property_map_) - { - boost::shared_ptr<dynamic_property_map> pm( - boost::static_pointer_cast<dynamic_property_map>( - boost::make_shared<detail::dynamic_property_map_adaptor<PropertyMap> >(property_map_))); - property_maps.insert(property_maps_type::value_type(name, pm)); - - return *this; - } - - template<typename PropertyMap> - dynamic_properties - property(const std::string& name, PropertyMap property_map_) const - { - dynamic_properties result = *this; - result.property(name, property_map_); - return result; - } - - iterator begin() { return property_maps.begin(); } - const_iterator begin() const { return property_maps.begin(); } - iterator end() { return property_maps.end(); } - const_iterator end() const { return property_maps.end(); } - - iterator lower_bound(const std::string& name) - { return property_maps.lower_bound(name); } - - const_iterator lower_bound(const std::string& name) const - { return property_maps.lower_bound(name); } - - void - insert(const std::string& name, boost::shared_ptr<dynamic_property_map> pm) - { - property_maps.insert(property_maps_type::value_type(name, pm)); - } - - template<typename Key, typename Value> - boost::shared_ptr<dynamic_property_map> - generate(const std::string& name, const Key& key, const Value& value) - { - if(!generate_fn) { - BOOST_THROW_EXCEPTION(property_not_found(name)); - } else { - return generate_fn(name,key,value); - } - } - -private: - property_maps_type property_maps; - generate_fn_type generate_fn; -}; - -template<typename Key, typename Value> -bool -put(const std::string& name, dynamic_properties& dp, const Key& key, - const Value& value) -{ - for (dynamic_properties::iterator i = dp.lower_bound(name); - i != dp.end() && i->first == name; ++i) { - if (i->second->key() == typeid(key)) { - i->second->put(key, value); - return true; - } - } - - boost::shared_ptr<dynamic_property_map> new_map = dp.generate(name, key, value); - if (new_map.get()) { - new_map->put(key, value); - dp.insert(name, new_map); - return true; - } else { - return false; - } -} - -template<typename Value, typename Key> -Value -get(const std::string& name, const dynamic_properties& dp, const Key& key) -{ - for (dynamic_properties::const_iterator i = dp.lower_bound(name); - i != dp.end() && i->first == name; ++i) { - if (i->second->key() == typeid(key)) - return any_cast<Value>(i->second->get(key)); - } - - BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); -} - -template<typename Value, typename Key> -Value -get(const std::string& name, const dynamic_properties& dp, const Key& key, type<Value>) -{ - for (dynamic_properties::const_iterator i = dp.lower_bound(name); - i != dp.end() && i->first == name; ++i) { - if (i->second->key() == typeid(key)) - return any_cast<Value>(i->second->get(key)); - } - - BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); -} - -template<typename Key> -std::string -get(const std::string& name, const dynamic_properties& dp, const Key& key) -{ - for (dynamic_properties::const_iterator i = dp.lower_bound(name); - i != dp.end() && i->first == name; ++i) { - if (i->second->key() == typeid(key)) - return i->second->get_string(key); - } - - BOOST_THROW_EXCEPTION(dynamic_get_failure(name)); -} - -// The easy way to ignore properties. -inline -boost::shared_ptr<boost::dynamic_property_map> -ignore_other_properties(const std::string&, - const boost::any&, - const boost::any&) { - return boost::shared_ptr<boost::dynamic_property_map>(); -} - -} // namespace boost - -#endif // DYNAMIC_PROPERTY_MAP_RG09302004_HPP diff --git a/contrib/restricted/boost/boost/property_map/function_property_map.hpp b/contrib/restricted/boost/boost/property_map/function_property_map.hpp deleted file mode 100644 index c8c295f4c3..0000000000 --- a/contrib/restricted/boost/boost/property_map/function_property_map.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// -//======================================================================= -// Author: Philipp Moeller -// -// Copyright 2012, Philipp Moeller -// -// 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) -//======================================================================= -// - -#ifndef BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP -#define BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP - -#include <boost/config.hpp> -#include <boost/property_map/property_map.hpp> -#include <boost/type_traits.hpp> -#include <boost/utility/result_of.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/not.hpp> -#include <utility> - -namespace boost { - -template<typename Func, typename Key, typename Ret = typename boost::result_of<const Func(const Key&)>::type> -class function_property_map: public put_get_helper<Ret, function_property_map<Func, Key, Ret> > { - public: - typedef Key key_type; - typedef Ret reference; - typedef typename boost::remove_cv<typename boost::remove_reference<Ret>::type>::type value_type; - - typedef typename boost::mpl::if_< - boost::mpl::and_< - boost::is_reference<Ret>, - boost::mpl::not_<boost::is_const<Ret> > - >, - boost::lvalue_property_map_tag, - boost::readable_property_map_tag>::type - category; - - function_property_map(Func f = Func()) : f(f) {} - - reference operator[](const Key& k) const { - return f(k); - } - - private: - Func f; -}; - -template<typename Key, typename Func> -function_property_map<Func, Key> -make_function_property_map(const Func& f) { - return function_property_map<Func, Key>(f); -} - -template<typename Key, typename Ret, typename Func> -function_property_map<Func, Key, Ret> -make_function_property_map(const Func& f) { - return function_property_map<Func, Key, Ret>(f); -} - -} // boost - -#endif /* BOOST_PROPERTY_MAP_FUNCTION_PROPERTY_MAP_HPP */ diff --git a/contrib/restricted/boost/boost/property_map/parallel/basic_reduce.hpp b/contrib/restricted/boost/boost/property_map/parallel/basic_reduce.hpp deleted file mode 100644 index 44bd1ad510..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/basic_reduce.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2005 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine - -#ifndef BOOST_PARALLEL_BASIC_REDUCE_HPP -#define BOOST_PARALLEL_BASIC_REDUCE_HPP - -namespace boost { namespace parallel { - -/** Reduction operation used to reconcile differences between local - * and remote values for a particular key in a property map. The - * type @c T is typically the @c value_type of the property - * map. This basic reduction returns a default-constructed @c T as - * the default value and always resolves to the remote value. - */ -template<typename T> -struct basic_reduce -{ - BOOST_STATIC_CONSTANT(bool, non_default_resolver = false); - - /// Returns a default-constructed T object - template<typename Key> - T operator()(const Key&) const { return T(); } - - /// Returns the remote value - template<typename Key> - const T& operator()(const Key&, const T&, const T& remote) const - { return remote; } -}; - -} } // end namespace boost::parallel - -#endif // BOOST_PARALLEL_BASIC_REDUCE_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/caching_property_map.hpp b/contrib/restricted/boost/boost/property_map/parallel/caching_property_map.hpp deleted file mode 100644 index eeb5cfaaac..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/caching_property_map.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2004 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine -#ifndef BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP -#define BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP - -#include <boost/property_map/property_map.hpp> - -namespace boost { - -// This probably doesn't belong here -template<typename Key, typename Value> -inline void local_put(dummy_property_map, const Key&, const Value&) {} - -namespace parallel { - -/** Property map that caches values placed in it but does not - * broadcast values to remote processors. This class template is - * meant as an adaptor for @ref distributed_property_map that - * suppresses communication in the event of a remote @c put operation - * by mapping it to a local @c put operation. - * - * @todo Find a better name for @ref caching_property_map - */ -template<typename PropertyMap> -class caching_property_map -{ -public: - typedef typename property_traits<PropertyMap>::key_type key_type; - typedef typename property_traits<PropertyMap>::value_type value_type; - typedef typename property_traits<PropertyMap>::reference reference; - typedef typename property_traits<PropertyMap>::category category; - - explicit caching_property_map(const PropertyMap& property_map) - : property_map(property_map) {} - - PropertyMap& base() { return property_map; } - const PropertyMap& base() const { return property_map; } - - template<typename Reduce> - void set_reduce(const Reduce& reduce) - { property_map.set_reduce(reduce); } - - void reset() { property_map.reset(); } - -#if 0 - reference operator[](const key_type& key) const - { - return property_map[key]; - } -#endif - -private: - PropertyMap property_map; -}; - -template<typename PropertyMap, typename Key> -inline typename caching_property_map<PropertyMap>::value_type -get(const caching_property_map<PropertyMap>& pm, const Key& key) -{ return get(pm.base(), key); } - -template<typename PropertyMap, typename Key, typename Value> -inline void -local_put(const caching_property_map<PropertyMap>& pm, const Key& key, - const Value& value) -{ local_put(pm.base(), key, value); } - -template<typename PropertyMap, typename Key, typename Value> -inline void -cache(const caching_property_map<PropertyMap>& pm, const Key& key, - const Value& value) -{ cache(pm.base(), key, value); } - -template<typename PropertyMap, typename Key, typename Value> -inline void -put(const caching_property_map<PropertyMap>& pm, const Key& key, - const Value& value) -{ local_put(pm.base(), key, value); } - -template<typename PropertyMap> -inline caching_property_map<PropertyMap> -make_caching_property_map(const PropertyMap& pm) -{ return caching_property_map<PropertyMap>(pm); } - -} } // end namespace boost::parallel - -#endif // BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/detail/untracked_pair.hpp b/contrib/restricted/boost/boost/property_map/parallel/detail/untracked_pair.hpp deleted file mode 100644 index 779ee6cc2e..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/detail/untracked_pair.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2007 Matthias Troyer -// -// Use, modification and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// -// This file contains helper data structures for use in transmitting -// properties. The basic idea is to optimize away any storage for the -// properties when no properties are specified. -#ifndef BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP -#define BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP - -#include <boost/mpi/datatype.hpp> -#include <utility> // for std::pair -#include <boost/serialization/utility.hpp> - -namespace boost { namespace parallel { namespace detail { - -/** - * This structure is like std::pair, with the only difference - * that tracking in the serialization library is turned off. - */ - -template<typename T, typename U> -struct untracked_pair : public std::pair<T,U> -{ - untracked_pair() {} - - untracked_pair(const T& t, const U& u) - : std::pair<T,U>(t,u) {} - - template<class T1, class U1> - untracked_pair(std::pair<T1,U1> const& p) - : std::pair<T,U>(p) {} -}; - -template<typename T, typename U> -inline untracked_pair<T, U> -make_untracked_pair(const T& t, const U& u) -{ - return untracked_pair<T,U>(t,u); -} - -} } } // end namespace boost::parallel::detail - -namespace boost { namespace mpi { - -template<typename T, typename U> -struct is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> > - : is_mpi_datatype<std::pair<T,U> > {}; - -} } // end namespace boost::mpi - -namespace boost { namespace serialization { - -// pair -template<class Archive, class F, class S> -inline void serialize( - Archive & ar, - boost::parallel::detail::untracked_pair<F, S> & p, - const unsigned int /* file_version */ -){ - ar & boost::serialization::make_nvp("first", p.first); - ar & boost::serialization::make_nvp("second", p.second); -} - -template<typename T, typename U> -struct is_bitwise_serializable< - boost::parallel::detail::untracked_pair<T, U> > - : is_bitwise_serializable<std::pair<T, U> > {}; - -template<typename T, typename U> -struct implementation_level<boost::parallel::detail::untracked_pair<T, U> > - : mpl::int_<object_serializable> {} ; - -template<typename T, typename U> -struct tracking_level<boost::parallel::detail::untracked_pair<T, U> > - : mpl::int_<track_never> {} ; - -} } // end namespace boost::serialization - -#endif // BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/distributed_property_map.hpp b/contrib/restricted/boost/boost/property_map/parallel/distributed_property_map.hpp deleted file mode 100644 index 8ef6004c5b..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/distributed_property_map.hpp +++ /dev/null @@ -1,693 +0,0 @@ -// Copyright (C) 2004-2008 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Nick Edmonds -// Andrew Lumsdaine - -// The placement of this #include probably looks very odd relative to -// the #ifndef/#define pair below. However, this placement is -// extremely important to allow the various property map headers to be -// included in any order. -#include <boost/property_map/property_map.hpp> - -#ifndef BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP -#define BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP - -#include <boost/assert.hpp> -#include <boost/type_traits/is_base_and_derived.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> -#include <boost/optional.hpp> -#include <boost/property_map/parallel/process_group.hpp> -#include <boost/function/function1.hpp> -#include <vector> -#include <set> -#include <boost/property_map/parallel/basic_reduce.hpp> -#include <boost/property_map/parallel/detail/untracked_pair.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/property_map/parallel/local_property_map.hpp> -#include <map> -#include <boost/version.hpp> -#include <boost/property_map/parallel/unsafe_serialize.hpp> -#include <boost/multi_index_container.hpp> -#include <boost/multi_index/hashed_index.hpp> -#include <boost/multi_index/member.hpp> -#include <boost/multi_index/sequenced_index.hpp> - -// Serialization functions for constructs we use -#include <boost/serialization/utility.hpp> - -namespace boost { namespace parallel { - -namespace detail { - /************************************************************************** - * Metafunction that degrades an Lvalue Property Map category tag to - * a Read Write Property Map category tag. - **************************************************************************/ - template<bool IsLvaluePropertyMap> - struct make_nonlvalue_property_map - { - template<typename T> struct apply { typedef T type; }; - }; - - template<> - struct make_nonlvalue_property_map<true> - { - template<typename> - struct apply - { - typedef read_write_property_map_tag type; - }; - }; - - /************************************************************************** - * Performs a "put" on a property map so long as the property map is - * a Writable Property Map or a mutable Lvalue Property Map. This - * is required because the distributed property map's message - * handler handles "put" messages even for a const property map, - * although receipt of a "put" message is ill-formed. - **************************************************************************/ - template<bool IsLvaluePropertyMap> - struct maybe_put_in_lvalue_pm - { - template<typename PropertyMap, typename Key, typename Value> - static inline void - do_put(PropertyMap, const Key&, const Value&) - { BOOST_ASSERT(false); } - }; - - template<> - struct maybe_put_in_lvalue_pm<true> - { - template<typename PropertyMap, typename Key, typename Value> - static inline void - do_put(PropertyMap pm, const Key& key, const Value& value) - { - using boost::put; - - put(pm, key, value); - } - }; - - template<typename PropertyMap, typename Key, typename Value> - inline void - maybe_put_impl(PropertyMap pm, const Key& key, const Value& value, - writable_property_map_tag) - { - using boost::put; - - put(pm, key, value); - } - - template<typename PropertyMap, typename Key, typename Value> - inline void - maybe_put_impl(PropertyMap pm, const Key& key, const Value& value, - lvalue_property_map_tag) - { - typedef typename property_traits<PropertyMap>::value_type value_type; - typedef typename property_traits<PropertyMap>::reference reference; - // DPG TBD: Some property maps are improperly characterized as - // lvalue_property_maps, when in fact they do not provide true - // references. The most typical example is those property maps - // built from vector<bool> and its iterators, which deal with - // proxies. We don't want to mischaracterize these as not having a - // "put" operation, so we only consider an lvalue_property_map as - // constant if its reference is const value_type&. In fact, this - // isn't even quite correct (think of a - // vector<bool>::const_iterator), but at present C++ doesn't - // provide us with any alternatives. - typedef is_same<const value_type&, reference> is_constant; - - maybe_put_in_lvalue_pm<(!is_constant::value)>::do_put(pm, key, value); - } - - template<typename PropertyMap, typename Key, typename Value> - inline void - maybe_put_impl(PropertyMap, const Key&, const Value&, ...) - { BOOST_ASSERT(false); } - - template<typename PropertyMap, typename Key, typename Value> - inline void - maybe_put(PropertyMap pm, const Key& key, const Value& value) - { - maybe_put_impl(pm, key, value, - typename property_traits<PropertyMap>::category()); - } -} // end namespace detail - -/** The consistency model used by the distributed property map. */ -enum consistency_model { - cm_forward = 1 << 0, - cm_backward = 1 << 1, - cm_bidirectional = cm_forward | cm_backward, - cm_flush = 1 << 2, - cm_reset = 1 << 3, - cm_clear = 1 << 4 -}; - -/** Distributed property map adaptor. - * - * The distributed property map adaptor is a property map whose - * stored values are distributed across multiple non-overlapping - * memory spaces on different processes. Values local to the current - * process are stored within a local property map and may be - * immediately accessed via @c get and @c put. Values stored on - * remote processes may also be access via @c get and @c put, but the - * behavior differs slightly: - * - * - @c put operations update a local ghost cell and send a "put" - * message to the process that owns the value. The owner is free to - * update its own "official" value or may ignore the put request. - * - * - @c get operations returns the contents of the local ghost - * cell. If no ghost cell is available, one is created using the - * default value provided by the "reduce" operation. See, e.g., - * @ref basic_reduce and @ref property_reduce. - * - * Using distributed property maps requires a bit more care than using - * local, sequential property maps. While the syntax and semantics are - * similar, distributed property maps may contain out-of-date - * information that can only be guaranteed to be synchronized by - * calling the @ref synchronize function in all processes. - * - * To address the issue of out-of-date values, distributed property - * maps are supplied with a reduction operation. The reduction - * operation has two roles: - * - * -# When a value is needed for a remote key but no value is - * immediately available, the reduction operation provides a - * suitable default. For instance, a distributed property map - * storing distances may have a reduction operation that returns - * an infinite value as the default, whereas a distributed - * property map for vertex colors may return white as the - * default. - * - * -# When a value is received from a remote process, the process - * owning the key associated with that value must determine which - * value---the locally stored value, the value received from a - * remote process, or some combination of the two---will be - * stored as the "official" value in the property map. The - * reduction operation transforms the local and remote values - * into the "official" value to be stored. - * - * @tparam ProcessGroup the type of the process group over which the - * property map is distributed and is also the medium for - * communication. - * - * @tparam StorageMap the type of the property map that will - * store values for keys local to this processor. The @c value_type of - * this property map will become the @c value_type of the distributed - * property map. The distributed property map models the same property - * map concepts as the @c LocalPropertyMap, with one exception: a - * distributed property map cannot be an LvaluePropertyMap (because - * remote values are not addressable), and is therefore limited to - * ReadWritePropertyMap. - */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -class distributed_property_map -{ - public: - /// The key type of the property map. - typedef typename property_traits<GlobalMap>::key_type key_type; - - /// The value type of the property map. - typedef typename property_traits<StorageMap>::value_type value_type; - typedef typename property_traits<StorageMap>::reference reference; - typedef ProcessGroup process_group_type; - - private: - typedef distributed_property_map self_type; - typedef typename property_traits<StorageMap>::category local_category; - typedef typename property_traits<StorageMap>::key_type local_key_type; - typedef typename property_traits<GlobalMap>::value_type owner_local_pair; - typedef typename ProcessGroup::process_id_type process_id_type; - - enum property_map_messages { - /** A request to store a value in a property map. The message - * contains a std::pair<key, data>. - */ - property_map_put, - - /** A request to retrieve a particular value in a property - * map. The message contains a key. The owner of that key will - * reply with a value. - */ - property_map_get, - - /** A request to update values stored on a remote processor. The - * message contains a vector of keys for which the source - * requests updated values. This message will only be transmitted - * during synchronization. - */ - property_map_multiget, - - /** A request to store values in a ghost cell. This message - * contains a vector of key/value pairs corresponding to the - * sequence of keys sent to the source processor. - */ - property_map_multiget_reply, - - /** The payload containing a vector of local key-value pairs to be - * put into the remote property map. A key-value std::pair will be - * used to store each local key-value pair. - */ - property_map_multiput - }; - - // Code from JoaquÃn M López Muñoz to work around unusual implementation of - // std::pair in VC++ 10: - template<typename First,typename Second> - class pair_first_extractor { - typedef std::pair<First,Second> value_type; - - public: - typedef First result_type; - const result_type& operator()(const value_type& x) const { - return x.first; - } - - result_type& operator()(value_type& x) const { - return x.first; - } - }; - - public: - /// The type of the ghost cells - typedef multi_index::multi_index_container< - std::pair<key_type, value_type>, - multi_index::indexed_by< - multi_index::sequenced<>, - multi_index::hashed_unique< - pair_first_extractor<key_type, value_type> - > - > - > ghost_cells_type; - - /// Iterator into the ghost cells - typedef typename ghost_cells_type::iterator iterator; - - /// Key-based index into the ghost cells - typedef typename ghost_cells_type::template nth_index<1>::type - ghost_cells_key_index_type; - - /// Iterator into the ghost cells (by key) - typedef typename ghost_cells_key_index_type::iterator key_iterator; - - /** The property map category. A distributed property map cannot be - * an Lvalue Property Map, because values on remote processes cannot - * be addresses. - */ - typedef typename detail::make_nonlvalue_property_map< - (is_base_and_derived<lvalue_property_map_tag, local_category>::value - || is_same<lvalue_property_map_tag, local_category>::value)> - ::template apply<local_category>::type category; - - /** Default-construct a distributed property map. This function - * creates an initialized property map that must be assigned to a - * valid value before being used. It is only provided here because - * property maps must be Default Constructible. - */ - distributed_property_map() {} - - /** Construct a distributed property map. Builds a distributed - * property map communicating over the given process group and using - * the given local property map for storage. Since no reduction - * operation is provided, the default reduction operation @c - * basic_reduce<value_type> is used. - */ - distributed_property_map(const ProcessGroup& pg, const GlobalMap& global, - const StorageMap& pm) - : data(new data_t(pg, global, pm, basic_reduce<value_type>(), false)) - { - typedef handle_message<basic_reduce<value_type> > Handler; - - data->ghost_cells.reset(new ghost_cells_type()); - Handler handler(data); - data->process_group.replace_handler(handler, true); - data->process_group.template get_receiver<Handler>() - ->setup_triggers(data->process_group); - } - - /** Construct a distributed property map. Builds a distributed - * property map communicating over the given process group and using - * the given local property map for storage. The given @p reduce - * parameter is used as the reduction operation. - */ - template<typename Reduce> - distributed_property_map(const ProcessGroup& pg, const GlobalMap& global, - const StorageMap& pm, - const Reduce& reduce); - - ~distributed_property_map(); - - /// Set the reduce operation of the distributed property map. - template<typename Reduce> - void set_reduce(const Reduce& reduce); - - // Set the consistency model for the distributed property map - void set_consistency_model(int model); - - // Get the consistency model - int get_consistency_model() const { return data->model; } - - // Set the maximum number of ghost cells that we are allowed to - // maintain. If 0, all ghost cells will be retained. - void set_max_ghost_cells(std::size_t max_ghost_cells); - - // Clear out all ghost cells - void clear(); - - // Reset the values in all ghost cells to the default value - void reset(); - - // Flush all values destined for remote processors - void flush(); - - reference operator[](const key_type& key) const - { - owner_local_pair p = get(data->global, key); - - if (p.first == process_id(data->process_group)) { - return data->storage[p.second]; - } else { - return cell(key); - } - } - - process_group_type process_group() const - { - return data->process_group.base(); - } - - StorageMap& base() { return data->storage; } - const StorageMap& base() const { return data->storage; } - - /** Sends a "put" request. - * \internal - * - */ - void - request_put(process_id_type p, const key_type& k, const value_type& v) const - { - send(data->process_group, p, property_map_put, - boost::parallel::detail::make_untracked_pair(k, v)); - } - - /** Access the ghost cell for the given key. - * \internal - */ - value_type& cell(const key_type& k, bool request_if_missing = true) const; - - /** Perform synchronization - * \internal - */ - void do_synchronize(); - - const GlobalMap& global() const { return data->global; } - GlobalMap& global() { return data->global; } - - struct data_t - { - data_t(const ProcessGroup& pg, const GlobalMap& global, - const StorageMap& pm, const function1<value_type, key_type>& dv, - bool has_default_resolver) - : process_group(pg), global(global), storage(pm), - ghost_cells(), max_ghost_cells(1000000), get_default_value(dv), - has_default_resolver(has_default_resolver), model(cm_forward) { } - - /// The process group - ProcessGroup process_group; - - /// A mapping from the keys of this property map to the global - /// descriptor. - GlobalMap global; - - /// Local property map - StorageMap storage; - - /// The ghost cells - shared_ptr<ghost_cells_type> ghost_cells; - - /// The maximum number of ghost cells we are permitted to hold. If - /// zero, we are permitted to have an infinite number of ghost - /// cells. - std::size_t max_ghost_cells; - - /// Default value for remote ghost cells, as defined by the - /// reduction operation. - function1<value_type, key_type> get_default_value; - - /// True if this resolver is the "default" resolver, meaning that - /// we should not be able to get() a default value; it needs to be - /// request()ed first. - bool has_default_resolver; - - // Current consistency model - int model; - - // Function that resets all of the ghost cells to their default - // values. It knows the type of the resolver, so we can eliminate - // a large number of calls through function pointers. - void (data_t::*reset)(); - - // Clear out all ghost cells - void clear(); - - // Flush all values destined for remote processors - void flush(); - - // Send out requests to "refresh" the values of ghost cells that - // we're holding. - void refresh_ghost_cells(); - - private: - template<typename Resolver> void do_reset(); - - friend class distributed_property_map; - }; - friend struct data_t; - - shared_ptr<data_t> data; - - private: - // Prunes the least recently used ghost cells until we have @c - // max_ghost_cells or fewer ghost cells. - void prune_ghost_cells() const; - - /** Handles incoming messages. - * - * This function object is responsible for handling all incoming - * messages for the distributed property map. - */ - template<typename Reduce> - struct handle_message - { - explicit handle_message(const shared_ptr<data_t>& data, - const Reduce& reduce = Reduce()) - : data_ptr(data), reduce(reduce) { } - - void operator()(process_id_type source, int tag); - - /// Individual message handlers - void - handle_put(int source, int tag, - const boost::parallel::detail::untracked_pair<key_type, value_type>& data, - trigger_receive_context); - - value_type - handle_get(int source, int tag, const key_type& data, - trigger_receive_context); - - void - handle_multiget(int source, int tag, - const std::vector<key_type>& data, - trigger_receive_context); - - void - handle_multiget_reply - (int source, int tag, - const std::vector<boost::parallel::detail::untracked_pair<key_type, value_type> >& msg, - trigger_receive_context); - - void - handle_multiput - (int source, int tag, - const std::vector<unsafe_pair<local_key_type, value_type> >& data, - trigger_receive_context); - - void setup_triggers(process_group_type& pg); - - private: - weak_ptr<data_t> data_ptr; - Reduce reduce; - }; - - /* Sets up the next stage in a multi-stage synchronization, for - bidirectional consistency. */ - struct on_synchronize - { - explicit on_synchronize(const shared_ptr<data_t>& data) : data_ptr(data) { } - - void operator()(); - - private: - weak_ptr<data_t> data_ptr; - }; -}; - -/* An implementation helper macro for the common case of naming - distributed property maps with all of the normal template - parameters. */ -#define PBGL_DISTRIB_PMAP \ - distributed_property_map<ProcessGroup, GlobalMap, StorageMap> - -/* Request that the value for the given remote key be retrieved in - the next synchronization round. */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -inline void -request(const PBGL_DISTRIB_PMAP& pm, - typename PBGL_DISTRIB_PMAP::key_type const& key) -{ - if (get(pm.data->global, key).first != process_id(pm.data->process_group)) - pm.cell(key, false); -} - -/** Get the value associated with a particular key. Retrieves the - * value associated with the given key. If the key denotes a - * locally-owned object, it returns the value from the local property - * map; if the key denotes a remotely-owned object, retrieves the - * value of the ghost cell for that key, which may be the default - * value provided by the reduce operation. - * - * Complexity: For a local key, O(1) get operations on the underlying - * property map. For a non-local key, O(1) accesses to the ghost cells. - */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -inline -typename PBGL_DISTRIB_PMAP::value_type -get(const PBGL_DISTRIB_PMAP& pm, - typename PBGL_DISTRIB_PMAP::key_type const& key) -{ - using boost::get; - - typename property_traits<GlobalMap>::value_type p = - get(pm.data->global, key); - - if (p.first == process_id(pm.data->process_group)) { - return get(pm.data->storage, p.second); - } else { - return pm.cell(key); - } -} - -/** Put a value associated with the given key into the property map. - * When the key denotes a locally-owned object, this operation updates - * the underlying local property map. Otherwise, the local ghost cell - * is updated and a "put" message is sent to the processor owning this - * key. - * - * Complexity: For a local key, O(1) put operations on the underlying - * property map. For a nonlocal key, O(1) accesses to the ghost cells - * and will send O(1) messages of size O(sizeof(key) + sizeof(value)). - */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -put(const PBGL_DISTRIB_PMAP& pm, - typename PBGL_DISTRIB_PMAP::key_type const & key, - typename PBGL_DISTRIB_PMAP::value_type const & value) -{ - using boost::put; - - typename property_traits<GlobalMap>::value_type p = - get(pm.data->global, key); - - if (p.first == process_id(pm.data->process_group)) { - put(pm.data->storage, p.second, value); - } else { - if (pm.data->model & cm_forward) - pm.request_put(p.first, key, value); - - pm.cell(key, false) = value; - } -} - -/** Put a value associated with a given key into the local view of the - * property map. This operation is equivalent to @c put, but with one - * exception: no message will be sent to the owning processor in the - * case of a remote update. The effect is that any value written via - * @c local_put for a remote key may be overwritten in the next - * synchronization round. - */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -local_put(const PBGL_DISTRIB_PMAP& pm, - typename PBGL_DISTRIB_PMAP::key_type const & key, - typename PBGL_DISTRIB_PMAP::value_type const & value) -{ - using boost::put; - - typename property_traits<GlobalMap>::value_type p = - get(pm.data->global, key); - - if (p.first == process_id(pm.data->process_group)) - put(pm.data->storage, p.second, value); - else pm.cell(key, false) = value; -} - -/** Cache the value associated with the given remote key. If the key - * is local, ignore the operation. */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -inline void -cache(const PBGL_DISTRIB_PMAP& pm, - typename PBGL_DISTRIB_PMAP::key_type const & key, - typename PBGL_DISTRIB_PMAP::value_type const & value) -{ - typename ProcessGroup::process_id_type id = get(pm.data->global, key).first; - - if (id != process_id(pm.data->process_group)) pm.cell(key, false) = value; -} - -/// Synchronize the property map. -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -synchronize(PBGL_DISTRIB_PMAP& pm) -{ - pm.do_synchronize(); -} - -/// Create a distributed property map. -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -inline distributed_property_map<ProcessGroup, GlobalMap, StorageMap> -make_distributed_property_map(const ProcessGroup& pg, GlobalMap global, - StorageMap storage) -{ - typedef distributed_property_map<ProcessGroup, GlobalMap, StorageMap> - result_type; - return result_type(pg, global, storage); -} - -/** - * \overload - */ -template<typename ProcessGroup, typename GlobalMap, typename StorageMap, - typename Reduce> -inline distributed_property_map<ProcessGroup, GlobalMap, StorageMap> -make_distributed_property_map(const ProcessGroup& pg, GlobalMap global, - StorageMap storage, Reduce reduce) -{ - typedef distributed_property_map<ProcessGroup, GlobalMap, StorageMap> - result_type; - return result_type(pg, global, storage, reduce); -} - -} } // end namespace boost::parallel - -#include <boost/property_map/parallel/impl/distributed_property_map.ipp> - -#undef PBGL_DISTRIB_PMAP - -#endif // BOOST_PARALLEL_DISTRIBUTED_PROPERTY_MAP_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/global_index_map.hpp b/contrib/restricted/boost/boost/property_map/parallel/global_index_map.hpp deleted file mode 100644 index ab954445c5..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/global_index_map.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2005 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine -#ifndef BOOST_PARALLEL_GLOBAL_INDEX_MAP_HPP -#define BOOST_PARALLEL_GLOBAL_INDEX_MAP_HPP - -#include <boost/property_map/property_map.hpp> -#include <vector> -#include <boost/shared_ptr.hpp> - -namespace boost { namespace parallel { - -template<typename IndexMap, typename GlobalMap> -class global_index_map -{ -public: - typedef typename property_traits<IndexMap>::key_type key_type; - typedef typename property_traits<IndexMap>::value_type value_type; - typedef value_type reference; - typedef readable_property_map_tag category; - - template<typename ProcessGroup> - global_index_map(ProcessGroup pg, value_type num_local_indices, - IndexMap index_map, GlobalMap global) - : index_map(index_map), global(global) - { - typedef typename ProcessGroup::process_id_type process_id_type; - starting_index.reset(new std::vector<value_type>(num_processes(pg) + 1)); - send(pg, 0, 0, num_local_indices); - synchronize(pg); - - // Populate starting_index in all processes - if (process_id(pg) == 0) { - (*starting_index)[0] = 0; - for (process_id_type src = 0; src < num_processes(pg); ++src) { - value_type n; - receive(pg, src, 0, n); - (*starting_index)[src + 1] = (*starting_index)[src] + n; - } - for (process_id_type dest = 1; dest < num_processes(pg); ++dest) - send(pg, dest, 1, &starting_index->front(), num_processes(pg)); - synchronize(pg); - } else { - synchronize(pg); - receive(pg, 0, 1, &starting_index->front(), num_processes(pg)); - } - } - - friend inline value_type - get(const global_index_map& gim, const key_type& x) - { - using boost::get; - return (*gim.starting_index)[get(gim.global, x).first] - + get(gim.index_map, x); - } - -private: - shared_ptr<std::vector<value_type> > starting_index; - IndexMap index_map; - GlobalMap global; -}; - -} } // end namespace boost::parallel - -#endif // BOOST_PARALLEL_GLOBAL_INDEX_MAP_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/impl/distributed_property_map.ipp b/contrib/restricted/boost/boost/property_map/parallel/impl/distributed_property_map.ipp deleted file mode 100644 index a4213bcf9a..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/impl/distributed_property_map.ipp +++ /dev/null @@ -1,424 +0,0 @@ -// Copyright (C) 2004-2006 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Nick Edmonds -// Andrew Lumsdaine -#include <boost/assert.hpp> -#include <boost/property_map/parallel/distributed_property_map.hpp> -#include <boost/property_map/parallel/detail/untracked_pair.hpp> -#include <boost/type_traits/is_base_and_derived.hpp> -#include <boost/bind.hpp> -#include <boost/property_map/parallel/simple_trigger.hpp> - -namespace boost { namespace parallel { - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -PBGL_DISTRIB_PMAP -::distributed_property_map(const ProcessGroup& pg, const GlobalMap& global, - const StorageMap& pm, const Reduce& reduce) - : data(new data_t(pg, global, pm, reduce, Reduce::non_default_resolver)) -{ - typedef handle_message<Reduce> Handler; - - data->ghost_cells.reset(new ghost_cells_type()); - data->reset = &data_t::template do_reset<Reduce>; - data->process_group.replace_handler(Handler(data, reduce)); - data->process_group.template get_receiver<Handler>() - ->setup_triggers(data->process_group); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -PBGL_DISTRIB_PMAP::~distributed_property_map() { } - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::set_reduce(const Reduce& reduce) -{ - typedef handle_message<Reduce> Handler; - data->process_group.replace_handler(Handler(data, reduce)); - Handler* handler = data->process_group.template get_receiver<Handler>(); - BOOST_ASSERT(handler); - handler->setup_triggers(data->process_group); - data->get_default_value = reduce; - data->has_default_resolver = Reduce::non_default_resolver; - int model = data->model; - data->reset = &data_t::template do_reset<Reduce>; - set_consistency_model(model); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::prune_ghost_cells() const -{ - if (data->max_ghost_cells == 0) - return; - - while (data->ghost_cells->size() > data->max_ghost_cells) { - // Evict the last ghost cell - - if (data->model & cm_flush) { - // We need to flush values when we evict them. - boost::parallel::detail::untracked_pair<key_type, value_type> const& victim - = data->ghost_cells->back(); - send(data->process_group, get(data->global, victim.first).first, - property_map_put, victim); - } - - // Actually remove the ghost cell - data->ghost_cells->pop_back(); - } -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -typename PBGL_DISTRIB_PMAP::value_type& -PBGL_DISTRIB_PMAP::cell(const key_type& key, bool request_if_missing) const -{ - // Index by key - ghost_cells_key_index_type const& key_index - = data->ghost_cells->template get<1>(); - - // Search for the ghost cell by key, and project back to the sequence - iterator ghost_cell - = data->ghost_cells->template project<0>(key_index.find(key)); - if (ghost_cell == data->ghost_cells->end()) { - value_type value; - if (data->has_default_resolver) - // Since we have a default resolver, use it to create a default - // value for this ghost cell. - value = data->get_default_value(key); - else if (request_if_missing) - // Request the actual value of this key from its owner - send_oob_with_reply(data->process_group, get(data->global, key).first, - property_map_get, key, value); - else - value = value_type(); - - // Create a ghost cell containing the new value - ghost_cell - = data->ghost_cells->push_front(std::make_pair(key, value)).first; - - // If we need to, prune the ghost cells - if (data->max_ghost_cells > 0) - prune_ghost_cells(); - } else if (data->max_ghost_cells > 0) - // Put this cell at the beginning of the MRU list - data->ghost_cells->relocate(data->ghost_cells->begin(), ghost_cell); - - return const_cast<value_type&>(ghost_cell->second); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP -::handle_message<Reduce>::operator()(process_id_type source, int tag) -{ - BOOST_ASSERT(false); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -handle_put(int /*source*/, int /*tag*/, - const boost::parallel::detail::untracked_pair<key_type, value_type>& req, trigger_receive_context) -{ - using boost::get; - - shared_ptr<data_t> data(data_ptr); - - owner_local_pair p = get(data->global, req.first); - BOOST_ASSERT(p.first == process_id(data->process_group)); - - detail::maybe_put(data->storage, p.second, - reduce(req.first, - get(data->storage, p.second), - req.second)); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -typename PBGL_DISTRIB_PMAP::value_type -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -handle_get(int source, int /*tag*/, const key_type& key, - trigger_receive_context) -{ - using boost::get; - - shared_ptr<data_t> data(data_ptr); - BOOST_ASSERT(data); - - owner_local_pair p = get(data->global, key); - return get(data->storage, p.second); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -handle_multiget(int source, int tag, const std::vector<key_type>& keys, - trigger_receive_context) -{ - shared_ptr<data_t> data(data_ptr); - BOOST_ASSERT(data); - - typedef boost::parallel::detail::untracked_pair<key_type, value_type> key_value; - std::vector<key_value> results; - std::size_t n = keys.size(); - results.reserve(n); - - using boost::get; - - for (std::size_t i = 0; i < n; ++i) { - local_key_type local_key = get(data->global, keys[i]).second; - results.push_back(key_value(keys[i], get(data->storage, local_key))); - } - send(data->process_group, source, property_map_multiget_reply, results); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -handle_multiget_reply - (int source, int tag, - const std::vector<boost::parallel::detail::untracked_pair<key_type, value_type> >& msg, - trigger_receive_context) -{ - shared_ptr<data_t> data(data_ptr); - BOOST_ASSERT(data); - - // Index by key - ghost_cells_key_index_type const& key_index - = data->ghost_cells->template get<1>(); - - std::size_t n = msg.size(); - for (std::size_t i = 0; i < n; ++i) { - // Search for the ghost cell by key, and project back to the sequence - iterator position - = data->ghost_cells->template project<0>(key_index.find(msg[i].first)); - - if (position != data->ghost_cells->end()) - const_cast<value_type&>(position->second) = msg[i].second; - } -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -handle_multiput - (int source, int tag, - const std::vector<unsafe_pair<local_key_type, value_type> >& values, - trigger_receive_context) -{ - using boost::get; - - shared_ptr<data_t> data(data_ptr); - BOOST_ASSERT(data); - - std::size_t n = values.size(); - for (std::size_t i = 0; i < n; ++i) { - local_key_type local_key = values[i].first; - value_type local_value = get(data->storage, local_key); - detail::maybe_put(data->storage, values[i].first, - reduce(values[i].first, - local_value, - values[i].second)); - } -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Reduce> -void -PBGL_DISTRIB_PMAP::handle_message<Reduce>:: -setup_triggers(process_group_type& pg) -{ - using boost::parallel::simple_trigger; - - simple_trigger(pg, property_map_put, this, &handle_message::handle_put); - simple_trigger(pg, property_map_get, this, &handle_message::handle_get); - simple_trigger(pg, property_map_multiget, this, - &handle_message::handle_multiget); - simple_trigger(pg, property_map_multiget_reply, this, - &handle_message::handle_multiget_reply); - simple_trigger(pg, property_map_multiput, this, - &handle_message::handle_multiput); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -PBGL_DISTRIB_PMAP -::on_synchronize::operator()() -{ - int stage=0; // we only get called at the start now - shared_ptr<data_t> data(data_ptr); - BOOST_ASSERT(data); - - // Determine in which stage backward consistency messages should be sent. - int backward_stage = -1; - if (data->model & cm_backward) { - if (data->model & cm_flush) backward_stage = 1; - else backward_stage = 0; - } - - // Flush results in first stage - if (stage == 0 && data->model & cm_flush) - data->flush(); - - // Backward consistency - if (stage == backward_stage && !(data->model & (cm_clear | cm_reset))) - data->refresh_ghost_cells(); - - // Optionally clear results - if (data->model & cm_clear) - data->clear(); - - // Optionally reset results - if (data->model & cm_reset) { - if (data->reset) ((*data).*data->reset)(); - } -} - - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -PBGL_DISTRIB_PMAP::set_consistency_model(int model) -{ - data->model = model; - - bool need_on_synchronize = (model != cm_forward); - - // Backward consistency is a two-stage process. - if (model & cm_backward) { - // For backward consistency to work, we absolutely cannot throw - // away any ghost cells. - data->max_ghost_cells = 0; - } - - // attach the on_synchronize handler. - if (need_on_synchronize) - data->process_group.replace_on_synchronize_handler(on_synchronize(data)); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void -PBGL_DISTRIB_PMAP::set_max_ghost_cells(std::size_t max_ghost_cells) -{ - if ((data->model & cm_backward) && max_ghost_cells > 0) - boost::throw_exception(std::runtime_error("distributed_property_map::set_max_ghost_cells: " - "cannot limit ghost-cell usage with a backward " - "consistency model")); - - if (max_ghost_cells == 1) - // It is not safe to have only 1 ghost cell; the cell() method - // will fail. - max_ghost_cells = 2; - - data->max_ghost_cells = max_ghost_cells; - prune_ghost_cells(); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::clear() -{ - data->clear(); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::data_t::clear() -{ - ghost_cells->clear(); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::reset() -{ - if (data->reset) ((*data).*data->reset)(); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::flush() -{ - data->flush(); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::data_t::refresh_ghost_cells() -{ - using boost::get; - - std::vector<std::vector<key_type> > keys; - keys.resize(num_processes(process_group)); - - // Collect the set of keys for which we will request values - for (iterator i = ghost_cells->begin(); i != ghost_cells->end(); ++i) - keys[get(global, i->first).first].push_back(i->first); - - // Send multiget requests to each of the other processors - typedef typename ProcessGroup::process_size_type process_size_type; - process_size_type n = num_processes(process_group); - process_id_type id = process_id(process_group); - for (process_size_type p = (id + 1) % n ; p != id ; p = (p + 1) % n) { - if (!keys[p].empty()) - send(process_group, p, property_map_multiget, keys[p]); - } -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::data_t::flush() -{ - using boost::get; - - int n = num_processes(process_group); - std::vector<std::vector<unsafe_pair<local_key_type, value_type> > > values; - values.resize(n); - - // Collect all of the flushed values - for (iterator i = ghost_cells->begin(); i != ghost_cells->end(); ++i) { - std::pair<int, local_key_type> g = get(global, i->first); - values[g.first].push_back(std::make_pair(g.second, i->second)); - } - - // Transmit flushed values - for (int p = 0; p < n; ++p) { - if (!values[p].empty()) - send(process_group, p, property_map_multiput, values[p]); - } -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -void PBGL_DISTRIB_PMAP::do_synchronize() -{ - if (data->model & cm_backward) { - synchronize(data->process_group); - return; - } - - // Request refreshes of the values of our ghost cells - data->refresh_ghost_cells(); - - // Allows all of the multigets to get to their destinations - synchronize(data->process_group); - - // Allows all of the multiget responses to get to their destinations - synchronize(data->process_group); -} - -template<typename ProcessGroup, typename GlobalMap, typename StorageMap> -template<typename Resolver> -void PBGL_DISTRIB_PMAP::data_t::do_reset() -{ - Resolver* resolver = get_default_value.template target<Resolver>(); - BOOST_ASSERT(resolver); - - for (iterator i = ghost_cells->begin(); i != ghost_cells->end(); ++i) - const_cast<value_type&>(i->second) = (*resolver)(i->first); -} - -} } // end namespace boost::parallel diff --git a/contrib/restricted/boost/boost/property_map/parallel/local_property_map.hpp b/contrib/restricted/boost/boost/property_map/parallel/local_property_map.hpp deleted file mode 100644 index 4b16d9742b..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/local_property_map.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2004-2006 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine - -// The placement of this #include probably looks very odd relative to -// the #ifndef/#define pair below. However, this placement is -// extremely important to allow the various property map headers to be -// included in any order. -#include <boost/property_map/property_map.hpp> - -#ifndef BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP -#define BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP - -#include <boost/assert.hpp> - -namespace boost { - /** Property map that accesses an underlying, local property map - * using a subset of the global keys. - */ - template<typename ProcessGroup, typename GlobalMap, typename StorageMap> - class local_property_map - { - typedef typename property_traits<GlobalMap>::value_type owner_local_pair; - - public: - typedef ProcessGroup process_group_type; - typedef typename property_traits<StorageMap>::value_type value_type; - typedef typename property_traits<GlobalMap>::key_type key_type; - typedef typename property_traits<StorageMap>::reference reference; - typedef typename property_traits<StorageMap>::category category; - - local_property_map() { } - - local_property_map(const ProcessGroup& process_group, - const GlobalMap& global, const StorageMap& storage) - : process_group_(process_group), global_(global), storage(storage) { } - - reference operator[](const key_type& key) - { - owner_local_pair p = get(global_, key); - BOOST_ASSERT(p.first == process_id(process_group_)); - return storage[p.second]; - } - - GlobalMap& global() const { return global_; } - StorageMap& base() const { return storage; } - - ProcessGroup& process_group() { return process_group_; } - const ProcessGroup& process_group() const { return process_group_; } - - private: - ProcessGroup process_group_; - mutable GlobalMap global_; - mutable StorageMap storage; - }; - - template<typename ProcessGroup, typename GlobalMap, typename StorageMap> - inline - typename local_property_map<ProcessGroup, GlobalMap, StorageMap>::reference - get(const local_property_map<ProcessGroup, GlobalMap, StorageMap>& pm, - typename local_property_map<ProcessGroup, GlobalMap, StorageMap>::key_type - const & key) - - { - typename property_traits<GlobalMap>::value_type p = get(pm.global(), key); - return get(pm.base(), p.second); - } - - template<typename ProcessGroup, typename GlobalMap, typename StorageMap> - inline void - put(const local_property_map<ProcessGroup, GlobalMap, StorageMap>& pm, - typename local_property_map<ProcessGroup, GlobalMap, StorageMap> - ::key_type const & key, - typename local_property_map<ProcessGroup, GlobalMap, StorageMap> - ::value_type const& v) - { - typename property_traits<GlobalMap>::value_type p = get(pm.global(), key); - BOOST_ASSERT(p.first == process_id(pm.process_group())); - put(pm.base(), p.second, v); - } -} // end namespace boost -#endif // BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/parallel_property_maps.hpp b/contrib/restricted/boost/boost/property_map/parallel/parallel_property_maps.hpp deleted file mode 100644 index 04a268dc44..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/parallel_property_maps.hpp +++ /dev/null @@ -1,232 +0,0 @@ -// (C) Copyright Jeremy Siek 1999-2001. -// Copyright (C) 2006 Trustees of Indiana University -// Authors: Douglas Gregor and Jeremy Siek - -// 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) - -// See http://www.boost.org/libs/property_map for documentation. - -#ifndef BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP -#define BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP - -// Parallel property maps moved over from <boost/property_map/property_map.hpp> -// as part of refactoring out all parallel code from sequential property map -// library. - -#include <boost/assert.hpp> -#include <boost/config.hpp> -#include <boost/static_assert.hpp> -#include <cstddef> -#include <boost/detail/iterator.hpp> -#include <boost/concept_archetype.hpp> -#include <boost/mpl/assert.hpp> -#include <boost/mpl/or.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/has_xxx.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/property_map/property_map.hpp> - -#include <boost/property_map/parallel/distributed_property_map.hpp> -#include <boost/property_map/parallel/local_property_map.hpp> - -namespace boost { -/** Distributed iterator property map. - * - * This specialization of @ref iterator_property_map builds a - * distributed iterator property map given the local index maps - * generated by distributed graph types that automatically have index - * properties. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename RandomAccessIterator, typename ProcessGroup, - typename GlobalMap, typename StorageMap, - typename ValueType, typename Reference> -class iterator_property_map - <RandomAccessIterator, - local_property_map<ProcessGroup, GlobalMap, StorageMap>, - ValueType, Reference> - : public parallel::distributed_property_map - <ProcessGroup, - GlobalMap, - iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> > -{ - typedef iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef local_property_map<ProcessGroup, GlobalMap, StorageMap> - index_map_type; - typedef iterator_property_map self_type; - -public: - iterator_property_map() { } - - iterator_property_map(RandomAccessIterator cc, const index_map_type& id) - : inherited(id.process_group(), id.global(), - local_iterator_map(cc, id.base())) { } -}; - -/** Distributed iterator property map. - * - * This specialization of @ref iterator_property_map builds a - * distributed iterator property map given a distributed index - * map. Only the local portion of the distributed index property map - * is utilized. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename RandomAccessIterator, typename ProcessGroup, - typename GlobalMap, typename StorageMap, - typename ValueType, typename Reference> -class iterator_property_map< - RandomAccessIterator, - parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>, - ValueType, Reference - > - : public parallel::distributed_property_map - <ProcessGroup, - GlobalMap, - iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> > -{ - typedef iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - StorageMap> - index_map_type; - -public: - iterator_property_map() { } - - iterator_property_map(RandomAccessIterator cc, const index_map_type& id) - : inherited(id.process_group(), id.global(), - local_iterator_map(cc, id.base())) { } -}; - -namespace parallel { -// Generate an iterator property map with a specific kind of ghost -// cells -template<typename RandomAccessIterator, typename ProcessGroup, - typename GlobalMap, typename StorageMap> -distributed_property_map<ProcessGroup, - GlobalMap, - iterator_property_map<RandomAccessIterator, - StorageMap> > -make_iterator_property_map(RandomAccessIterator cc, - local_property_map<ProcessGroup, GlobalMap, - StorageMap> index_map) -{ - typedef distributed_property_map< - ProcessGroup, GlobalMap, - iterator_property_map<RandomAccessIterator, StorageMap> > - result_type; - return result_type(index_map.process_group(), index_map.global(), - make_iterator_property_map(cc, index_map.base())); -} - -} // end namespace parallel - -/** Distributed safe iterator property map. - * - * This specialization of @ref safe_iterator_property_map builds a - * distributed iterator property map given the local index maps - * generated by distributed graph types that automatically have index - * properties. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename RandomAccessIterator, typename ProcessGroup, - typename GlobalMap, typename StorageMap, typename ValueType, - typename Reference> -class safe_iterator_property_map - <RandomAccessIterator, - local_property_map<ProcessGroup, GlobalMap, StorageMap>, - ValueType, Reference> - : public parallel::distributed_property_map - <ProcessGroup, - GlobalMap, - safe_iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> > -{ - typedef safe_iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef local_property_map<ProcessGroup, GlobalMap, StorageMap> index_map_type; - -public: - safe_iterator_property_map() { } - - safe_iterator_property_map(RandomAccessIterator cc, std::size_t n, - const index_map_type& id) - : inherited(id.process_group(), id.global(), - local_iterator_map(cc, n, id.base())) { } -}; - -/** Distributed safe iterator property map. - * - * This specialization of @ref safe_iterator_property_map builds a - * distributed iterator property map given a distributed index - * map. Only the local portion of the distributed index property map - * is utilized. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename RandomAccessIterator, typename ProcessGroup, - typename GlobalMap, typename StorageMap, - typename ValueType, typename Reference> -class safe_iterator_property_map< - RandomAccessIterator, - parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>, - ValueType, Reference> - : public parallel::distributed_property_map - <ProcessGroup, - GlobalMap, - safe_iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> > -{ - typedef safe_iterator_property_map<RandomAccessIterator, StorageMap, - ValueType, Reference> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - StorageMap> - index_map_type; - -public: - safe_iterator_property_map() { } - - safe_iterator_property_map(RandomAccessIterator cc, std::size_t n, - const index_map_type& id) - : inherited(id.process_group(), id.global(), - local_iterator_map(cc, n, id.base())) { } -}; - -} - -#include <boost/property_map/vector_property_map.hpp> - -#endif /* BOOST_PROPERTY_MAP_PARALLEL_PROPERTY_MAPS_HPP */ - diff --git a/contrib/restricted/boost/boost/property_map/parallel/process_group.hpp b/contrib/restricted/boost/boost/property_map/parallel/process_group.hpp deleted file mode 100644 index fac0a19485..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/process_group.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2004 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine -#ifndef BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP -#define BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP - -#include <cstdlib> -#include <utility> - -namespace boost { namespace parallel { - -/** - * A special type used as a flag to a process group constructor that - * indicates that the copy of a process group will represent a new - * distributed data structure. - */ -struct attach_distributed_object { }; - -/** - * Describes the context in which a trigger is being invoked to - * receive a message. - */ -enum trigger_receive_context { - /// No trigger is active at this time. - trc_none, - /// The trigger is being invoked during synchronization, at the end - /// of a superstep. - trc_in_synchronization, - /// The trigger is being invoked as an "early" receive of a message - /// that was sent through the normal "send" operations to be - /// received by the end of the superstep, but the process group sent - /// the message earlier to clear its buffers. - trc_early_receive, - /// The trigger is being invoked for an out-of-band message, which - /// must be handled immediately. - trc_out_of_band, - /// The trigger is being invoked for an out-of-band message, which - /// must be handled immediately and has alredy been received by - /// an MPI_IRecv call. - trc_irecv_out_of_band -}; - -// Process group tags -struct process_group_tag {}; -struct linear_process_group_tag : virtual process_group_tag {}; -struct messaging_process_group_tag : virtual process_group_tag {}; -struct immediate_process_group_tag : virtual messaging_process_group_tag {}; -struct bsp_process_group_tag : virtual messaging_process_group_tag {}; -struct batch_process_group_tag : virtual messaging_process_group_tag {}; -struct locking_process_group_tag : virtual process_group_tag {}; -struct spawning_process_group_tag : virtual process_group_tag {}; - -struct process_group_archetype -{ - typedef int process_id_type; -}; - -void wait(process_group_archetype&); -void synchronize(process_group_archetype&); -int process_id(const process_group_archetype&); -int num_processes(const process_group_archetype&); - -template<typename T> void send(process_group_archetype&, int, int, const T&); - -template<typename T> -process_group_archetype::process_id_type -receive(const process_group_archetype& pg, - process_group_archetype::process_id_type source, int tag, T& value); - -template<typename T> -std::pair<process_group_archetype::process_id_type, std::size_t> -receive(const process_group_archetype& pg, int tag, T values[], std::size_t n); - -template<typename T> -std::pair<process_group_archetype::process_id_type, std::size_t> -receive(const process_group_archetype& pg, - process_group_archetype::process_id_type source, int tag, T values[], - std::size_t n); - -} } // end namespace boost::parallel - -namespace boost { namespace graph { namespace distributed { - using boost::parallel::trigger_receive_context; - using boost::parallel::trc_early_receive; - using boost::parallel::trc_out_of_band; - using boost::parallel::trc_irecv_out_of_band; - using boost::parallel::trc_in_synchronization; - using boost::parallel::trc_none; - using boost::parallel::attach_distributed_object; -} } } // end namespace boost::graph::distributed - -#endif // BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/simple_trigger.hpp b/contrib/restricted/boost/boost/property_map/parallel/simple_trigger.hpp deleted file mode 100644 index 8ab5cfde7f..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/simple_trigger.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2007 Douglas Gregor - -// Use, modification and distribution is subject to 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) - -// This file contains a simplification of the "trigger" method for -// process groups. The simple trigger handles the common case where -// the handler associated with a trigger is a member function bound to -// a particular pointer. - -#ifndef BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP -#define BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP - -#include <boost/property_map/parallel/process_group.hpp> - -namespace boost { namespace parallel { - -namespace detail { - -/** - * INTERNAL ONLY - * - * The actual function object that bridges from the normal trigger - * interface to the simplified interface. This is the equivalent of - * bind(pmf, self, _1, _2, _3, _4), but without the compile-time - * overhead of bind. - */ -template<typename Class, typename T, typename Result> -class simple_trigger_t -{ -public: - simple_trigger_t(Class* self, - Result (Class::*pmf)(int, int, const T&, - trigger_receive_context)) - : self(self), pmf(pmf) { } - - Result - operator()(int source, int tag, const T& data, - trigger_receive_context context) const - { - return (self->*pmf)(source, tag, data, context); - } - -private: - Class* self; - Result (Class::*pmf)(int, int, const T&, trigger_receive_context); -}; - -} // end namespace detail - -/** - * Simplified trigger interface that reduces the amount of code - * required to connect a process group trigger to a handler that is - * just a bound member function. - * - * INTERNAL ONLY - */ -template<typename ProcessGroup, typename Class, typename T> -inline void -simple_trigger(ProcessGroup& pg, int tag, Class* self, - void (Class::*pmf)(int source, int tag, const T& data, - trigger_receive_context context), int) -{ - pg.template trigger<T>(tag, - detail::simple_trigger_t<Class, T, void>(self, pmf)); -} - -/** - * Simplified trigger interface that reduces the amount of code - * required to connect a process group trigger with a reply to a - * handler that is just a bound member function. - * - * INTERNAL ONLY - */ -template<typename ProcessGroup, typename Class, typename T, typename Result> -inline void -simple_trigger(ProcessGroup& pg, int tag, Class* self, - Result (Class::*pmf)(int source, int tag, const T& data, - trigger_receive_context context), long) -{ - pg.template trigger_with_reply<T> - (tag, detail::simple_trigger_t<Class, T, Result>(self, pmf)); -} - -/** - * Simplified trigger interface that reduces the amount of code - * required to connect a process group trigger to a handler that is - * just a bound member function. - */ -template<typename ProcessGroup, typename Class, typename T, typename Result> -inline void -simple_trigger(ProcessGroup& pg, int tag, Class* self, - Result (Class::*pmf)(int source, int tag, const T& data, - trigger_receive_context context)) -{ - // We pass 0 (an int) to help VC++ disambiguate calls to simple_trigger - // with Result=void. - simple_trigger(pg, tag, self, pmf, 0); -} - -} } // end namespace boost::parallel - -namespace boost { namespace graph { namespace parallel { using boost::parallel::simple_trigger; } } } - -#endif // BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/unsafe_serialize.hpp b/contrib/restricted/boost/boost/property_map/parallel/unsafe_serialize.hpp deleted file mode 100644 index a37dc21dd7..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/unsafe_serialize.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2006 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Authors: Douglas Gregor -// Andrew Lumsdaine - -// This file contains the "unsafe_serialize" routine, which transforms -// types they may not be serializable (such as void*) into -// serializable equivalents. -#ifndef BOOST_PROPERTY_MAP_UNSAFE_SERIALIZE_HPP -#define BOOST_PROPERTY_MAP_UNSAFE_SERIALIZE_HPP - -#include <boost/mpi/datatype.hpp> -#include <boost/serialization/is_bitwise_serializable.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/if.hpp> -#include <boost/cstdint.hpp> -#include <boost/static_assert.hpp> -#include <boost/type_traits.hpp> -#include <utility> - -BOOST_IS_BITWISE_SERIALIZABLE(void*) -namespace boost { namespace mpi { - template<> struct is_mpi_datatype<void*> : mpl::true_ { }; -} } // end namespace boost::mpi - -namespace boost { - typedef mpl::if_c<(sizeof(int) == sizeof(void*)), - int, - mpl::if_c<(sizeof(long) == sizeof(void*)), - long, - mpl::if_c<(sizeof(void*) <= sizeof(boost::intmax_t)), - boost::intmax_t, - void>::type - >::type - >::type ptr_serialize_type; - - BOOST_STATIC_ASSERT ((!boost::is_void<ptr_serialize_type>::value)); - - template<typename T> inline T& unsafe_serialize(T& x) { return x; } - - inline ptr_serialize_type& unsafe_serialize(void*& x) - { return reinterpret_cast<ptr_serialize_type&>(x); } - - // Force Boost.MPI to serialize a void* like a ptr_serialize_type - namespace mpi { - template<> inline MPI_Datatype get_mpi_datatype<void*>(void* const& x) - { - return get_mpi_datatype<ptr_serialize_type>(); - } - } - - template<typename T, typename U> - struct unsafe_pair - { - unsafe_pair() { } - unsafe_pair(const T& t, const U& u) : first(t), second(u) { } - unsafe_pair(const std::pair<T, U>& p) : first(p.first), second(p.second) { } - T first; - U second; - - template<typename Archiver> - void serialize(Archiver& ar, const unsigned /*version*/) - { - ar & unsafe_serialize(first) & unsafe_serialize(second); - } - }; - - template<typename T, typename U> - bool operator<(unsafe_pair<T,U> const& x, unsafe_pair<T,U> const& y) - { - return std::make_pair(x.first, x.second) < - std::make_pair(y.first, y.second); - } - -} // end namespace boost - -#endif // BOOST_PROPERTY_MAP_UNSAFE_SERIALIZE_HPP diff --git a/contrib/restricted/boost/boost/property_map/parallel/vector_property_map.hpp b/contrib/restricted/boost/boost/property_map/parallel/vector_property_map.hpp deleted file mode 100644 index f1ad4c4fb0..0000000000 --- a/contrib/restricted/boost/boost/property_map/parallel/vector_property_map.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) Vladimir Prus 2003. -// 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) -// -// See http://www.boost.org/libs/graph/vector_property_map.html for -// documentation. -// - -#ifndef BOOST_PROPERTY_MAP_PARALLEL_VECTOR_PROPERTY_MAP_HPP_VP_2003_03_04 -#define BOOST_PROPERTY_MAP_PARALLEL_VECTOR_PROPERTY_MAP_HPP_VP_2003_03_04 - -#include <boost/property_map/property_map.hpp> -#include <boost/shared_ptr.hpp> -#include <vector> -#include <boost/property_map/parallel/distributed_property_map.hpp> -#include <boost/property_map/parallel/local_property_map.hpp> - -namespace boost { - -/** Distributed vector property map. - * - * This specialization of @ref vector_property_map builds a - * distributed vector property map given the local index maps - * generated by distributed graph types that automatically have index - * properties. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename T, typename ProcessGroup, typename GlobalMap, - typename StorageMap> -class vector_property_map<T, - local_property_map<ProcessGroup, GlobalMap, - StorageMap> > - : public parallel::distributed_property_map< - ProcessGroup, GlobalMap, vector_property_map<T, StorageMap> > -{ - typedef vector_property_map<T, StorageMap> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef local_property_map<ProcessGroup, GlobalMap, StorageMap> index_map_type; - -public: - vector_property_map(const index_map_type& index = index_map_type()) - : inherited(index.process_group(), index.global(), - local_iterator_map(index.base())) { } - - vector_property_map(unsigned inital_size, - const index_map_type& index = index_map_type()) - : inherited(index.process_group(), index.global(), - local_iterator_map(inital_size, index.base())) { } -}; - -/** Distributed vector property map. - * - * This specialization of @ref vector_property_map builds a - * distributed vector property map given the local index maps - * generated by distributed graph types that automatically have index - * properties. - * - * This specialization is useful when creating external distributed - * property maps via the same syntax used to create external - * sequential property maps. - */ -template<typename T, typename ProcessGroup, typename GlobalMap, - typename StorageMap> -class vector_property_map< - T, - parallel::distributed_property_map< - ProcessGroup, - GlobalMap, - StorageMap - > - > - : public parallel::distributed_property_map< - ProcessGroup, GlobalMap, vector_property_map<T, StorageMap> > -{ - typedef vector_property_map<T, StorageMap> local_iterator_map; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - local_iterator_map> inherited; - - typedef parallel::distributed_property_map<ProcessGroup, GlobalMap, - StorageMap> - index_map_type; - -public: - vector_property_map(const index_map_type& index = index_map_type()) - : inherited(index.process_group(), index.global(), - local_iterator_map(index.base())) { } - - vector_property_map(unsigned inital_size, - const index_map_type& index = index_map_type()) - : inherited(index.process_group(), index.global(), - local_iterator_map(inital_size, index.base())) { } -}; - -} - -#endif // BOOST_PROPERTY_MAP_PARALLEL_VECTOR_PROPERTY_MAP_HPP_VP_2003_03_04 diff --git a/contrib/restricted/boost/boost/property_map/property_map_iterator.hpp b/contrib/restricted/boost/boost/property_map/property_map_iterator.hpp deleted file mode 100644 index a7be8afecf..0000000000 --- a/contrib/restricted/boost/boost/property_map/property_map_iterator.hpp +++ /dev/null @@ -1,113 +0,0 @@ -// (C) Copyright Jeremy Siek, 2001. -// 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) - -// See http://www.boost.org/libs/property_map for documentation. - -#ifndef BOOST_PROPERTY_MAP_ITERATOR_HPP -#define BOOST_PROPERTY_MAP_ITERATOR_HPP - -#include <boost/property_map/property_map.hpp> -#include <boost/iterator/iterator_adaptor.hpp> -#include <boost/mpl/if.hpp> -#include <boost/type_traits/is_same.hpp> - -namespace boost { - - //====================================================================== - // property iterator, generalized from ideas by Francois Faure - - namespace detail { - - template <class Iterator, class LvaluePropertyMap> - class lvalue_pmap_iter - : public iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >, - Iterator, - typename property_traits<LvaluePropertyMap>::value_type, - use_default, - typename property_traits<LvaluePropertyMap>::reference> - { - friend class boost::iterator_core_access; - - typedef iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >, - Iterator, - typename property_traits<LvaluePropertyMap>::value_type, - use_default, - typename property_traits<LvaluePropertyMap>::reference> super_t; - - public: - lvalue_pmap_iter() { } - lvalue_pmap_iter(Iterator const& it, - LvaluePropertyMap m) - : super_t(it), - m_map(m) {} - - private: - typename super_t::reference - dereference() const - { - return m_map[*(this->base_reference())]; - } - - LvaluePropertyMap m_map; - }; - - template <class Iterator, class ReadablePropertyMap> - class readable_pmap_iter : - public iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >, - Iterator, - typename property_traits<ReadablePropertyMap>::value_type, - use_default, - typename property_traits<ReadablePropertyMap>::value_type> - - - { - friend class boost::iterator_core_access; - - typedef iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >, - Iterator, - typename property_traits<ReadablePropertyMap>::value_type, - use_default, - typename property_traits<ReadablePropertyMap>::value_type> super_t; - - public: - readable_pmap_iter() { } - readable_pmap_iter(Iterator const& it, - ReadablePropertyMap m) - : super_t(it), - m_map(m) {} - - private: - typename super_t::reference - dereference() const - { - return get(m_map, *(this->base_reference())); - } - - ReadablePropertyMap m_map; - }; - - - } // namespace detail - - template <class PropertyMap, class Iterator> - struct property_map_iterator_generator : - mpl::if_< is_same< typename property_traits<PropertyMap>::category, lvalue_property_map_tag>, - detail::lvalue_pmap_iter<Iterator, PropertyMap>, - detail::readable_pmap_iter<Iterator, PropertyMap> > - {}; - - template <class PropertyMap, class Iterator> - typename property_map_iterator_generator<PropertyMap, Iterator>::type - make_property_map_iterator(PropertyMap pmap, Iterator iter) - { - typedef typename property_map_iterator_generator<PropertyMap, - Iterator>::type Iter; - return Iter(iter, pmap); - } - -} // namespace boost - -#endif // BOOST_PROPERTY_MAP_ITERATOR_HPP - diff --git a/contrib/restricted/boost/boost/property_map/transform_value_property_map.hpp b/contrib/restricted/boost/boost/property_map/transform_value_property_map.hpp deleted file mode 100644 index 6a7b574a2d..0000000000 --- a/contrib/restricted/boost/boost/property_map/transform_value_property_map.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// -//======================================================================= -// Author: Philipp Moeller -// -// Copyright 2012, Philipp Moeller -// -// 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) -//======================================================================= -// - -#ifndef BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP -#define BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP - -#include <boost/config.hpp> -#include <boost/property_map/property_map.hpp> -#include <boost/type_traits.hpp> -#include <boost/utility/result_of.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/not.hpp> -#include <utility> - -namespace boost { - -template<typename Func, typename PM, typename Ret = typename boost::result_of<const Func(typename property_traits<PM>::reference)>::type> -class transform_value_property_map: public put_get_helper<Ret, transform_value_property_map<Func, PM, Ret> > { - public: - typedef typename property_traits<PM>::key_type key_type; - typedef Ret reference; - typedef typename boost::remove_cv<typename boost::remove_reference<Ret>::type>::type value_type; - - typedef typename boost::mpl::if_< - boost::mpl::and_< - boost::is_reference<Ret>, - boost::mpl::not_<boost::is_const<Ret> > - >, - boost::lvalue_property_map_tag, - boost::readable_property_map_tag>::type - category; - - transform_value_property_map(Func f, PM pm) : f(f), pm(pm) {} - - reference operator[](const key_type& k) const { - return f(get(pm, k)); - } - - private: - Func f; - PM pm; -}; - -template<typename PM, typename Func> -transform_value_property_map<Func, PM> -make_transform_value_property_map(const Func& f, const PM& pm) { - return transform_value_property_map<Func, PM>(f, pm); -} - -template<typename Ret, typename PM, typename Func> -transform_value_property_map<Func, PM, Ret> -make_transform_value_property_map(const Func& f, const PM& pm) { - return transform_value_property_map<Func, PM, Ret>(f, pm); -} - -} // boost - -#endif /* BOOST_PROPERTY_MAP_TRANSFORM_VALUE_PROPERTY_MAP_HPP */ diff --git a/contrib/restricted/boost/libs/graph/CMakeLists.txt b/contrib/restricted/boost/libs/graph/CMakeLists.txt index 39f1d9338d..36bba08dce 100644 --- a/contrib/restricted/boost/libs/graph/CMakeLists.txt +++ b/contrib/restricted/boost/libs/graph/CMakeLists.txt @@ -14,6 +14,7 @@ target_link_libraries(boost-libs-graph INTERFACE restricted-boost-atomic restricted-boost-exception restricted-boost-filesystem + restricted-boost-property_map restricted-boost-serialization restricted-boost-spirit restricted-boost-thread diff --git a/contrib/restricted/boost/property_map/CMakeLists.txt b/contrib/restricted/boost/property_map/CMakeLists.txt new file mode 100644 index 0000000000..6a302522b9 --- /dev/null +++ b/contrib/restricted/boost/property_map/CMakeLists.txt @@ -0,0 +1,35 @@ + +# This file was gererated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(restricted-boost-property_map INTERFACE) +target_include_directories(restricted-boost-property_map INTERFACE + ${CMAKE_SOURCE_DIR}/contrib/restricted/boost/property_map/include +) +target_link_libraries(restricted-boost-property_map INTERFACE + contrib-libs-cxxsupp + yutil + restricted-boost-any + restricted-boost-assert + restricted-boost-bind + restricted-boost-concept_check + restricted-boost-config + restricted-boost-core + restricted-boost-function + restricted-boost-iterator + restricted-boost-lexical_cast + restricted-boost-mpl + restricted-boost-multi_index + restricted-boost-optional + restricted-boost-serialization + restricted-boost-smart_ptr + restricted-boost-static_assert + restricted-boost-throw_exception + restricted-boost-type_traits + restricted-boost-utility +) diff --git a/contrib/restricted/boost/boost/property_map/property_map.hpp b/contrib/restricted/boost/property_map/include/boost/property_map/property_map.hpp index 22bdeaff15..22bdeaff15 100644 --- a/contrib/restricted/boost/boost/property_map/property_map.hpp +++ b/contrib/restricted/boost/property_map/include/boost/property_map/property_map.hpp diff --git a/contrib/restricted/boost/boost/property_map/shared_array_property_map.hpp b/contrib/restricted/boost/property_map/include/boost/property_map/shared_array_property_map.hpp index 8056d95e5a..8056d95e5a 100644 --- a/contrib/restricted/boost/boost/property_map/shared_array_property_map.hpp +++ b/contrib/restricted/boost/property_map/include/boost/property_map/shared_array_property_map.hpp diff --git a/contrib/restricted/boost/boost/property_map/vector_property_map.hpp b/contrib/restricted/boost/property_map/include/boost/property_map/vector_property_map.hpp index 8eac06d255..8eac06d255 100644 --- a/contrib/restricted/boost/boost/property_map/vector_property_map.hpp +++ b/contrib/restricted/boost/property_map/include/boost/property_map/vector_property_map.hpp |