process_group.hpp 3.5 KB

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