File indexing completed on 2025-01-30 09:46:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_MPI_REQUEST_HPP
0013 #define BOOST_MPI_REQUEST_HPP
0014
0015 #include <boost/mpi/config.hpp>
0016 #include <boost/mpi/status.hpp>
0017 #include <boost/optional.hpp>
0018 #include <boost/shared_ptr.hpp>
0019 #include <boost/mpi/packed_iarchive.hpp>
0020
0021 namespace boost { namespace mpi {
0022
0023 class status;
0024 class communicator;
0025
0026
0027
0028
0029
0030
0031
0032
0033 class BOOST_MPI_DECL request
0034 {
0035 public:
0036
0037
0038
0039 request();
0040
0041
0042
0043
0044 template<typename T>
0045 static request make_trivial_send(communicator const& comm, int dest, int tag, T const& value);
0046 template<typename T>
0047 static request make_trivial_send(communicator const& comm, int dest, int tag, T const* values, int n);
0048 static request make_packed_send(communicator const& comm, int dest, int tag, void const* values, std::size_t n);
0049
0050 static request make_bottom_send(communicator const& comm, int dest, int tag, MPI_Datatype tp);
0051 static request make_empty_send(communicator const& comm, int dest, int tag);
0052
0053
0054
0055 template<typename T>
0056 static request make_trivial_recv(communicator const& comm, int dest, int tag, T& value);
0057 template<typename T>
0058 static request make_trivial_recv(communicator const& comm, int dest, int tag, T* values, int n);
0059
0060 static request make_bottom_recv(communicator const& comm, int dest, int tag, MPI_Datatype tp);
0061 static request make_empty_recv(communicator const& comm, int dest, int tag);
0062
0063
0064
0065 static request make_dynamic();
0066
0067
0068
0069 template<typename T>
0070 static request make_serialized(communicator const& comm, int source, int tag, T& value);
0071
0072
0073
0074 template<typename T>
0075 static request make_serialized_array(communicator const& comm, int source, int tag, T* values, int n);
0076
0077
0078
0079 template<typename T, class A>
0080 static request
0081 make_dynamic_primitive_array_recv(communicator const& comm, int source, int tag,
0082 std::vector<T,A>& values);
0083
0084
0085
0086 template<typename T, class A>
0087 static request
0088 make_dynamic_primitive_array_send(communicator const& comm, int source, int tag,
0089 std::vector<T,A> const& values);
0090
0091
0092
0093
0094
0095 status wait() { return m_handler ? m_handler->wait() : status(); }
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 optional<status> test() { return active() ? m_handler->test() : optional<status>(); }
0106
0107
0108
0109
0110
0111 void cancel() { if (m_handler) { m_handler->cancel(); } m_preserved.reset(); }
0112
0113
0114
0115
0116
0117 optional<MPI_Request&> trivial() { return (m_handler
0118 ? m_handler->trivial()
0119 : optional<MPI_Request&>()); }
0120
0121
0122
0123
0124 bool active() const { return bool(m_handler) && m_handler->active(); }
0125
0126
0127 void preserve(boost::shared_ptr<void> d);
0128
0129 class handler {
0130 public:
0131 virtual BOOST_MPI_DECL ~handler() = 0;
0132 virtual status wait() = 0;
0133 virtual optional<status> test() = 0;
0134 virtual void cancel() = 0;
0135
0136 virtual bool active() const = 0;
0137 virtual optional<MPI_Request&> trivial() = 0;
0138 };
0139
0140 private:
0141
0142 request(handler *h) : m_handler(h) {};
0143
0144
0145 class legacy_handler;
0146 class trivial_handler;
0147 class dynamic_handler;
0148 template<typename T> class legacy_serialized_handler;
0149 template<typename T> class legacy_serialized_array_handler;
0150 template<typename T, class A> class legacy_dynamic_primitive_array_handler;
0151 #if BOOST_MPI_VERSION >= 3
0152 template<class Data> class probe_handler;
0153 #endif
0154 private:
0155 shared_ptr<handler> m_handler;
0156 shared_ptr<void> m_preserved;
0157 };
0158
0159 } }
0160
0161 #endif