Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:11

0001 // Copyright (C) 2007 Douglas Gregor 
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 // This file contains code for the distributed adjacency list's
0008 // message handlers. It should not be included directly by users.
0009 
0010 #ifndef BOOST_GRAPH_DISTRIBUTED_ADJLIST_HANDLERS_HPP
0011 #define BOOST_GRAPH_DISTRIBUTED_ADJLIST_HANDLERS_HPP
0012 
0013 #ifndef BOOST_GRAPH_USE_MPI
0014 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
0015 #endif
0016 
0017 #include <boost/graph/parallel/simple_trigger.hpp>
0018 #include <boost/graph/parallel/detail/untracked_pair.hpp>
0019 
0020 namespace boost { 
0021 
0022 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0023 void
0024 PBGL_DISTRIB_ADJLIST_TYPE::
0025 setup_triggers()
0026 {
0027   using boost::graph::parallel::simple_trigger;
0028 
0029   simple_trigger(process_group_, msg_add_vertex_with_property, this,
0030                  &adjacency_list::handle_add_vertex_with_property);
0031   simple_trigger(process_group_, msg_add_vertex_with_property_and_reply, this,
0032                  &adjacency_list::handle_add_vertex_with_property_and_reply);
0033   simple_trigger(process_group_, msg_add_edge, this, 
0034                  &adjacency_list::handle_add_edge);
0035   simple_trigger(process_group_, msg_add_edge_with_reply, this, 
0036                  &adjacency_list::handle_add_edge_with_reply);
0037   simple_trigger(process_group_, msg_add_edge_with_property, this,
0038                  &adjacency_list::handle_add_edge_with_property);
0039   simple_trigger(process_group_,  msg_add_edge_with_property_and_reply, this,
0040                  &adjacency_list::handle_add_edge_with_property_and_reply);
0041   simple_trigger(process_group_, msg_nonlocal_edge, this,
0042                  &adjacency_list::handle_nonlocal_edge);
0043   simple_trigger(process_group_, msg_remove_edge, this,
0044                  &adjacency_list::handle_remove_edge);
0045 }
0046 
0047 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0048 void 
0049 PBGL_DISTRIB_ADJLIST_TYPE::
0050 handle_add_vertex_with_property(int source, int tag, 
0051                                 const vertex_property_type& data, 
0052                                 trigger_receive_context)
0053 {
0054   vertex_descriptor v(this->processor(), 
0055                       add_vertex(this->build_vertex_property(data), 
0056                                  this->base()));
0057   if (on_add_vertex)
0058     on_add_vertex(v, *this);
0059 }
0060 
0061 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0062 typename PBGL_DISTRIB_ADJLIST_TYPE::local_vertex_descriptor
0063 PBGL_DISTRIB_ADJLIST_TYPE::
0064 handle_add_vertex_with_property_and_reply(int source, int tag, 
0065                                           const vertex_property_type& data, 
0066                                           trigger_receive_context)
0067 {
0068   // Try to find a vertex with this name
0069   local_vertex_descriptor local_v
0070     = add_vertex(this->build_vertex_property(data), this->base());
0071 
0072   vertex_descriptor v(processor(), local_v);
0073   if (on_add_vertex)
0074     on_add_vertex(v, *this);
0075 
0076   return local_v;
0077 }
0078 
0079 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0080 void 
0081 PBGL_DISTRIB_ADJLIST_TYPE::
0082 handle_add_edge(int source, int tag, const msg_add_edge_data& data,
0083                 trigger_receive_context)
0084 {
0085   add_edge(vertex_descriptor(processor(), data.source), 
0086            data.target, *this);
0087 }
0088 
0089 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0090 boost::parallel::detail::untracked_pair<typename PBGL_DISTRIB_ADJLIST_TYPE::edge_descriptor, bool>
0091 PBGL_DISTRIB_ADJLIST_TYPE::
0092 handle_add_edge_with_reply(int source, int tag, const msg_add_edge_data& data,
0093                            trigger_receive_context)
0094 {
0095   std::pair<typename PBGL_DISTRIB_ADJLIST_TYPE::edge_descriptor, bool> p = 
0096     add_edge(vertex_descriptor(processor(), data.source),data.target, *this);
0097   return p;
0098 }
0099 
0100 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0101 void 
0102 PBGL_DISTRIB_ADJLIST_TYPE::
0103 handle_add_edge_with_property(int source, int tag, 
0104                               const msg_add_edge_with_property_data& data,
0105                               trigger_receive_context)
0106 {
0107   add_edge(vertex_descriptor(processor(), data.source), 
0108            data.target, data.get_property(), *this);
0109 }
0110 
0111 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0112 boost::parallel::detail::untracked_pair<typename PBGL_DISTRIB_ADJLIST_TYPE::edge_descriptor, bool>
0113 PBGL_DISTRIB_ADJLIST_TYPE::
0114 handle_add_edge_with_property_and_reply
0115   (int source, int tag, 
0116    const msg_add_edge_with_property_data& data,
0117    trigger_receive_context)
0118 {
0119   std::pair<typename PBGL_DISTRIB_ADJLIST_TYPE::edge_descriptor, bool> p = 
0120     add_edge(vertex_descriptor(processor(), data.source), 
0121                   data.target, data.get_property(), *this);
0122   return p;
0123 }
0124 
0125 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0126 void 
0127 PBGL_DISTRIB_ADJLIST_TYPE::
0128 handle_nonlocal_edge(int source, int tag, 
0129                      const msg_nonlocal_edge_data& data,
0130                      trigger_receive_context)
0131 {
0132   add_remote_edge(data, source, directed_selector());
0133 }
0134 
0135 template<PBGL_DISTRIB_ADJLIST_TEMPLATE_PARMS>
0136 void 
0137 PBGL_DISTRIB_ADJLIST_TYPE::
0138 handle_remove_edge(int source, int tag, 
0139                    const msg_remove_edge_data& data,
0140                    trigger_receive_context)
0141 {
0142   remove_local_edge(data, source, directed_selector());
0143 }
0144 
0145 } 
0146 
0147 #endif // BOOST_GRAPH_DISTRIBUTED_ADJLIST_HANDLERS_HPP
0148