3#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
4#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
9#include <dune/common/parallel/future.hh>
20 value = std::make_unique<T>();
24 : value(
std::make_unique<T>(
std::forward<V>(t)))
26 std::unique_ptr<T> value;
28 T tmp = std::move(*value);
32 operator bool ()
const {
35 T& operator *()
const{
42 Buffer(
bool valid =
false)
49 : value(
std::forward<V>(t))
51 std::optional<std::reference_wrapper<T>> value;
57 operator bool ()
const{
60 T& operator *()
const{
68 Buffer(
bool valid =
false)
71 operator bool ()
const{
82 template<
class R,
class S =
void>
84 mutable MPI_Request req_;
85 mutable MPI_Status status_;
86 impl::Buffer<R> data_;
87 impl::Buffer<S> send_data_;
91 : req_(MPI_REQUEST_NULL)
96 template<
class V = R,
class U = S>
97 MPIFuture(V&& recv_data, U&& send_data,
typename std::enable_if_t<!std::is_void<V>::value && !std::is_void<U>::value>* = 0) :
98 req_(MPI_REQUEST_NULL)
99 , data_(std::forward<R>(recv_data))
100 , send_data_(std::forward<S>(send_data))
104 template<
class V = R>
105 MPIFuture(V&& recv_data,
typename std::enable_if_t<!std::is_void<V>::value>* = 0)
106 : req_(MPI_REQUEST_NULL)
107 , data_(std::forward<V>(recv_data))
111 if(req_ != MPI_REQUEST_NULL){
114 MPI_Request_free(&req_);
121 : req_(MPI_REQUEST_NULL)
122 , data_(std::move(f.data_))
123 , send_data_(std::move(f.send_data_))
125 std::swap(req_, f.req_);
126 std::swap(status_, f.status_);
130 std::swap(req_, f.req_);
131 std::swap(status_, f.status_);
132 std::swap(data_, f.data_);
133 std::swap(send_data_, f.send_data_);
144 MPI_Wait(&req_, &status_);
149 MPI_Test(&req_, &flag, &status_);
160 return send_data_.get();
164 return getMPIData(*data_);
167 auto get_send_mpidata(){
168 return getMPIData(*send_data_);
Collective communication interface and sequential default implementation.
Definition: communication.hh:98
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition: future.hh:16
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition: mpifuture.hh:83
Implements an utility class that provides collective communication methods for sequential programs.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
Dune namespace.
Definition: alignedallocator.hh:11