5#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
6#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
11#include <dune/common/parallel/future.hh>
22 value = std::make_unique<T>();
26 : value(
std::make_unique<T>(
std::forward<V>(t)))
28 std::unique_ptr<T> value;
30 T tmp = std::move(*value);
34 operator bool ()
const {
37 T& operator *()
const{
44 Buffer(
bool valid =
false)
51 : value(
std::forward<V>(t))
53 std::optional<std::reference_wrapper<T>> value;
59 operator bool ()
const{
62 T& operator *()
const{
70 Buffer(
bool valid =
false)
73 operator bool ()
const{
84 template<
class R,
class S =
void>
86 mutable MPI_Request req_;
87 mutable MPI_Status status_;
88 impl::Buffer<R> data_;
89 impl::Buffer<S> send_data_;
93 : req_(MPI_REQUEST_NULL)
98 template<
class V = R,
class U = S>
99 MPIFuture(V&& recv_data, U&& send_data,
typename std::enable_if_t<!std::is_void<V>::value && !std::is_void<U>::value>* = 0) :
100 req_(MPI_REQUEST_NULL)
101 , data_(std::forward<R>(recv_data))
102 , send_data_(std::forward<S>(send_data))
106 template<
class V = R>
107 MPIFuture(V&& recv_data,
typename std::enable_if_t<!std::is_void<V>::value>* = 0)
108 : req_(MPI_REQUEST_NULL)
109 , data_(std::forward<V>(recv_data))
113 if(req_ != MPI_REQUEST_NULL){
116 MPI_Request_free(&req_);
123 : req_(MPI_REQUEST_NULL)
124 , data_(std::move(f.data_))
125 , send_data_(std::move(f.send_data_))
127 std::swap(req_, f.req_);
128 std::swap(status_, f.status_);
132 std::swap(req_, f.req_);
133 std::swap(status_, f.status_);
134 std::swap(data_, f.data_);
135 std::swap(send_data_, f.send_data_);
146 MPI_Wait(&req_, &status_);
151 MPI_Test(&req_, &flag, &status_);
162 return send_data_.get();
166 return getMPIData(*data_);
169 auto get_send_mpidata(){
170 return getMPIData(*send_data_);
Collective communication interface and sequential default implementation.
Definition: communication.hh:100
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition: future.hh:18
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition: mpifuture.hh:85
Implements an utility class that provides collective communication methods for sequential programs.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
Dune namespace.
Definition: alignedallocator.hh:13