1 // Copyright 2004 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 // Andrew Lumsdaine 9 #ifndef BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP 10 #define BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP 11 12 #include <cstdlib> 13 #include <utility> 14 15 namespace boost { namespace parallel { 16 17 /** 18 * A special type used as a flag to a process group constructor that 19 * indicates that the copy of a process group will represent a new 20 * distributed data structure. 21 */ 22 struct attach_distributed_object { }; 23 24 /** 25 * Describes the context in which a trigger is being invoked to 26 * receive a message. 27 */ 28 enum trigger_receive_context { 29 /// No trigger is active at this time. 30 trc_none, 31 /// The trigger is being invoked during synchronization, at the end 32 /// of a superstep. 33 trc_in_synchronization, 34 /// The trigger is being invoked as an "early" receive of a message 35 /// that was sent through the normal "send" operations to be 36 /// received by the end of the superstep, but the process group sent 37 /// the message earlier to clear its buffers. 38 trc_early_receive, 39 /// The trigger is being invoked for an out-of-band message, which 40 /// must be handled immediately. 41 trc_out_of_band, 42 /// The trigger is being invoked for an out-of-band message, which 43 /// must be handled immediately and has alredy been received by 44 /// an MPI_IRecv call. 45 trc_irecv_out_of_band 46 }; 47 48 // Process group tags 49 struct process_group_tag {}; 50 struct linear_process_group_tag : virtual process_group_tag {}; 51 struct messaging_process_group_tag : virtual process_group_tag {}; 52 struct immediate_process_group_tag : virtual messaging_process_group_tag {}; 53 struct bsp_process_group_tag : virtual messaging_process_group_tag {}; 54 struct batch_process_group_tag : virtual messaging_process_group_tag {}; 55 struct locking_process_group_tag : virtual process_group_tag {}; 56 struct spawning_process_group_tag : virtual process_group_tag {}; 57 58 struct process_group_archetype 59 { 60 typedef int process_id_type; 61 }; 62 63 void wait(process_group_archetype&); 64 void synchronize(process_group_archetype&); 65 int process_id(const process_group_archetype&); 66 int num_processes(const process_group_archetype&); 67 68 template<typename T> void send(process_group_archetype&, int, int, const T&); 69 70 template<typename T> 71 process_group_archetype::process_id_type 72 receive(const process_group_archetype& pg, 73 process_group_archetype::process_id_type source, int tag, T& value); 74 75 template<typename T> 76 std::pair<process_group_archetype::process_id_type, std::size_t> 77 receive(const process_group_archetype& pg, int tag, T values[], std::size_t n); 78 79 template<typename T> 80 std::pair<process_group_archetype::process_id_type, std::size_t> 81 receive(const process_group_archetype& pg, 82 process_group_archetype::process_id_type source, int tag, T values[], 83 std::size_t n); 84 85 } } // end namespace boost::parallel 86 87 namespace boost { namespace graph { namespace distributed { 88 using boost::parallel::trigger_receive_context; 89 using boost::parallel::trc_early_receive; 90 using boost::parallel::trc_out_of_band; 91 using boost::parallel::trc_irecv_out_of_band; 92 using boost::parallel::trc_in_synchronization; 93 using boost::parallel::trc_none; 94 using boost::parallel::attach_distributed_object; 95 } } } // end namespace boost::graph::distributed 96 97 #endif // BOOST_PROPERTY_MAP_PARALLEL_PROCESS_GROUP_HPP 98