1 // Copyright (C) 2006 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Authors: Douglas Gregor
8 // Jeremiah Willcock
9 // Andrew Lumsdaine
10
11 // Distributed version of the two-bit color map
12 #ifndef BOOST_DISTRIBUTED_TWO_BIT_COLOR_MAP_HPP
13 #define BOOST_DISTRIBUTED_TWO_BIT_COLOR_MAP_HPP
14
15 #ifndef BOOST_GRAPH_USE_MPI
16 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
17 #endif
18
19 #include <boost/graph/two_bit_color_map.hpp>
20 #include <boost/property_map/parallel/distributed_property_map.hpp>
21 #include <boost/property_map/parallel/local_property_map.hpp>
22
23 namespace boost {
24
25 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
26 class two_bit_color_map<local_property_map<ProcessGroup,GlobalMap,StorageMap> >
27 : public parallel::distributed_property_map<ProcessGroup, GlobalMap,
28 two_bit_color_map<StorageMap> >
29 {
30 typedef two_bit_color_map<StorageMap> local_map;
31
32 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
33 local_map >
34 inherited;
35
36 typedef local_property_map<ProcessGroup, GlobalMap, StorageMap>
37 index_map_type;
38
39 public:
two_bit_color_map(std::size_t inital_size,const index_map_type & index=index_map_type ())40 two_bit_color_map(std::size_t inital_size,
41 const index_map_type& index = index_map_type())
42 : inherited(index.process_group(), index.global(),
43 local_map(inital_size, index.base())) { }
44
base()45 inherited& base() { return *this; }
base() const46 const inherited& base() const { return *this; }
47 };
48
49 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
50 inline two_bit_color_type
get(two_bit_color_map<local_property_map<ProcessGroup,GlobalMap,StorageMap>> const & pm,typename property_traits<GlobalMap>::key_type key)51 get(two_bit_color_map<local_property_map<ProcessGroup,GlobalMap,StorageMap> >
52 const& pm,
53 typename property_traits<GlobalMap>::key_type key)
54 {
55 return get(pm.base(), key);
56 }
57
58 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
59 inline void
put(two_bit_color_map<local_property_map<ProcessGroup,GlobalMap,StorageMap>> const & pm,typename property_traits<GlobalMap>::key_type key,two_bit_color_type value)60 put(two_bit_color_map<local_property_map<ProcessGroup,GlobalMap,StorageMap> >
61 const& pm,
62 typename property_traits<GlobalMap>::key_type key,
63 two_bit_color_type value)
64 {
65 put(pm.base(), key, value);
66 }
67
68 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
69 class two_bit_color_map<parallel::distributed_property_map<
70 ProcessGroup, GlobalMap, StorageMap> >
71 : public parallel::distributed_property_map<
72 ProcessGroup, GlobalMap, two_bit_color_map<StorageMap> >
73 {
74 typedef two_bit_color_map<StorageMap> local_map;
75
76 typedef parallel::distributed_property_map<ProcessGroup,GlobalMap,local_map>
77 inherited;
78
79 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
80 StorageMap>
81 index_map_type;
82
83 public:
two_bit_color_map(std::size_t inital_size,const index_map_type & index=index_map_type ())84 two_bit_color_map(std::size_t inital_size,
85 const index_map_type& index = index_map_type())
86 : inherited(index.process_group(), index.global(),
87 local_map(inital_size, index.base())) { }
88
base()89 inherited& base() { return *this; }
base() const90 const inherited& base() const { return *this; }
91 };
92
93 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
94 inline two_bit_color_type
get(two_bit_color_map<parallel::distributed_property_map<ProcessGroup,GlobalMap,two_bit_color_map<StorageMap>>> const & pm,typename property_traits<GlobalMap>::key_type key)95 get(two_bit_color_map<
96 parallel::distributed_property_map<
97 ProcessGroup, GlobalMap, two_bit_color_map<StorageMap> > > const& pm,
98 typename property_traits<GlobalMap>::key_type key)
99 {
100 return get(pm.base(), key);
101 }
102
103 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
104 inline void
put(two_bit_color_map<parallel::distributed_property_map<ProcessGroup,GlobalMap,two_bit_color_map<StorageMap>>> const & pm,typename property_traits<GlobalMap>::key_type key,two_bit_color_type value)105 put(two_bit_color_map<
106 parallel::distributed_property_map<
107 ProcessGroup, GlobalMap, two_bit_color_map<StorageMap> > > const& pm,
108 typename property_traits<GlobalMap>::key_type key,
109 two_bit_color_type value)
110 {
111 put(pm.base(), key, value);
112 }
113
114 } // end namespace boost
115
116 #endif // BOOST_DISTRIBUTED_TWO_BIT_COLOR_MAP_HPP
117