process_group.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Copyright 2004 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Douglas Gregor
  6. // Andrew Lumsdaine
  7. #ifndef BOOST_GRAPH_PARALLEL_PROCESS_GROUP_HPP
  8. #define BOOST_GRAPH_PARALLEL_PROCESS_GROUP_HPP
  9. #ifndef BOOST_GRAPH_USE_MPI
  10. #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
  11. #endif
  12. #include <cstdlib>
  13. #include <utility>
  14. namespace boost { namespace graph { namespace parallel {
  15. /**
  16. * A special type used as a flag to a process group constructor that
  17. * indicates that the copy of a process group will represent a new
  18. * distributed data structure.
  19. */
  20. struct attach_distributed_object { };
  21. /**
  22. * Describes the context in which a trigger is being invoked to
  23. * receive a message.
  24. */
  25. enum trigger_receive_context {
  26. /// No trigger is active at this time.
  27. trc_none,
  28. /// The trigger is being invoked during synchronization, at the end
  29. /// of a superstep.
  30. trc_in_synchronization,
  31. /// The trigger is being invoked as an "early" receive of a message
  32. /// that was sent through the normal "send" operations to be
  33. /// received by the end of the superstep, but the process group sent
  34. /// the message earlier to clear its buffers.
  35. trc_early_receive,
  36. /// The trigger is being invoked for an out-of-band message, which
  37. /// must be handled immediately.
  38. trc_out_of_band,
  39. /// The trigger is being invoked for an out-of-band message, which
  40. /// must be handled immediately and has alredy been received by
  41. /// an MPI_IRecv call.
  42. trc_irecv_out_of_band
  43. };
  44. // Process group tags
  45. struct process_group_tag {};
  46. struct linear_process_group_tag : virtual process_group_tag {};
  47. struct messaging_process_group_tag : virtual process_group_tag {};
  48. struct immediate_process_group_tag : virtual messaging_process_group_tag {};
  49. struct bsp_process_group_tag : virtual messaging_process_group_tag {};
  50. struct batch_process_group_tag : virtual messaging_process_group_tag {};
  51. struct locking_process_group_tag : virtual process_group_tag {};
  52. struct spawning_process_group_tag : virtual process_group_tag {};
  53. struct process_group_archetype
  54. {
  55. typedef int process_id_type;
  56. };
  57. void wait(process_group_archetype&);
  58. void synchronize(process_group_archetype&);
  59. int process_id(const process_group_archetype&);
  60. int num_processes(const process_group_archetype&);
  61. template<typename T> void send(process_group_archetype&, int, int, const T&);
  62. template<typename T>
  63. process_group_archetype::process_id_type
  64. receive(const process_group_archetype& pg,
  65. process_group_archetype::process_id_type source, int tag, T& value);
  66. template<typename T>
  67. std::pair<process_group_archetype::process_id_type, std::size_t>
  68. receive(const process_group_archetype& pg, int tag, T values[], std::size_t n);
  69. template<typename T>
  70. std::pair<process_group_archetype::process_id_type, std::size_t>
  71. receive(const process_group_archetype& pg,
  72. process_group_archetype::process_id_type source, int tag, T values[],
  73. std::size_t n);
  74. } } } // end namespace boost::graph::parallel
  75. namespace boost { namespace graph { namespace distributed {
  76. using parallel::trigger_receive_context;
  77. using parallel::trc_early_receive;
  78. using parallel::trc_out_of_band;
  79. using parallel::trc_irecv_out_of_band;
  80. using parallel::trc_in_synchronization;
  81. using parallel::trc_none;
  82. using parallel::attach_distributed_object;
  83. } } } // end namespace boost::graph::distributed
  84. #endif // BOOST_GRAPH_PARALLEL_PROCESS_GROUP_HPP