Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:15

0001 // Copyright 2004 The Trustees of Indiana University.
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Authors: Douglas Gregor
0008 //           Andrew Lumsdaine
0009 #ifndef BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
0010 #define BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
0011 
0012 #include <boost/property_map/property_map.hpp>
0013 
0014 namespace boost { 
0015 
0016 // This probably doesn't belong here
0017 template<typename Key, typename Value>
0018 inline void local_put(dummy_property_map, const Key&, const Value&) {}
0019 
0020 namespace parallel {
0021 
0022 /** Property map that caches values placed in it but does not
0023  * broadcast values to remote processors.  This class template is
0024  * meant as an adaptor for @ref distributed_property_map that
0025  * suppresses communication in the event of a remote @c put operation
0026  * by mapping it to a local @c put operation.
0027  *
0028  * @todo Find a better name for @ref caching_property_map
0029  */
0030 template<typename PropertyMap>
0031 class caching_property_map
0032 {
0033 public:
0034   typedef typename property_traits<PropertyMap>::key_type   key_type;
0035   typedef typename property_traits<PropertyMap>::value_type value_type;
0036   typedef typename property_traits<PropertyMap>::reference  reference;
0037   typedef typename property_traits<PropertyMap>::category   category;
0038 
0039   explicit caching_property_map(const PropertyMap& property_map)
0040     : property_map(property_map) {}
0041 
0042   PropertyMap&        base()       { return property_map; }
0043   const PropertyMap&  base() const { return property_map; }
0044 
0045   template<typename Reduce>
0046   void set_reduce(const Reduce& reduce)
0047   { property_map.set_reduce(reduce); }
0048 
0049   void reset() { property_map.reset(); }
0050 
0051 #if 0
0052   reference operator[](const key_type& key) const
0053   {
0054     return property_map[key];
0055   }
0056 #endif
0057 
0058 private:
0059   PropertyMap property_map;
0060 };
0061 
0062 template<typename PropertyMap, typename Key>
0063 inline typename caching_property_map<PropertyMap>::value_type
0064 get(const caching_property_map<PropertyMap>& pm, const Key& key)
0065 { return get(pm.base(), key); }
0066 
0067 template<typename PropertyMap, typename Key, typename Value>
0068 inline void
0069 local_put(const caching_property_map<PropertyMap>& pm, const Key& key,
0070           const Value& value)
0071 { local_put(pm.base(), key, value); }
0072 
0073 template<typename PropertyMap, typename Key, typename Value>
0074 inline void
0075 cache(const caching_property_map<PropertyMap>& pm, const Key& key,
0076       const Value& value)
0077 { cache(pm.base(), key, value); }
0078 
0079 template<typename PropertyMap, typename Key, typename Value>
0080 inline void
0081 put(const caching_property_map<PropertyMap>& pm, const Key& key,
0082     const Value& value)
0083 { local_put(pm.base(), key, value); }
0084 
0085 template<typename PropertyMap>
0086 inline caching_property_map<PropertyMap>
0087 make_caching_property_map(const PropertyMap& pm)
0088 { return caching_property_map<PropertyMap>(pm); }
0089 
0090 } } // end namespace boost::parallel
0091 
0092 #endif // BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP