3 #ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
4 #define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
19 value = std::make_unique<T>();
23 :
value(std::make_unique<T>(std::forward<V>(t)))
27 T tmp = std::move(*
value);
31 operator bool ()
const {
48 : value(std::forward<V>(t))
56 operator bool ()
const{
70 operator bool ()
const{
81 template<
class R,
class S =
void>
83 mutable MPI_Request req_;
84 mutable MPI_Status status_;
90 : req_(MPI_REQUEST_NULL)
95 template<
class V = R,
class U = S>
96 MPIFuture(V&& recv_data, U&& send_data,
typename std::enable_if_t<!std::is_void<V>::value && !std::is_void<U>::value>* = 0) :
97 req_(MPI_REQUEST_NULL)
98 , data_(std::forward<R>(recv_data))
99 , send_data_(std::forward<S>(send_data))
103 template<
class V = R>
104 MPIFuture(V&& recv_data,
typename std::enable_if_t<!std::is_void<V>::value>* = 0)
105 : req_(MPI_REQUEST_NULL)
106 , data_(std::forward<V>(recv_data))
110 if(req_ != MPI_REQUEST_NULL){
113 MPI_Request_free(&req_);
120 : req_(MPI_REQUEST_NULL)
121 , data_(std::move(f.data_))
122 , send_data_(std::move(f.send_data_))
143 MPI_Wait(&req_, &status_);
148 MPI_Test(&req_, &flag, &status_);
159 return send_data_.
get();
163 return getMPIData<R>(*data_);
167 return getMPIData<S>(*send_data_);
Implements an utility class that provides collective communication methods for sequential programs.
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:544
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:14
void swap(T &v1, T &v2, bool mask)
Definition: simd.hh:470
Collective communication interface and sequential default implementation.
Definition: communication.hh:81
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition: future.hh:16
Definition: mpifuture.hh:16
std::unique_ptr< T > value
Definition: mpifuture.hh:25
T & operator*() const
Definition: mpifuture.hh:34
Buffer(V &&t)
Definition: mpifuture.hh:22
T get()
Definition: mpifuture.hh:26
Buffer(bool valid)
Definition: mpifuture.hh:17
T & get()
Definition: mpifuture.hh:51
Std::optional< std::reference_wrapper< T > > value
Definition: mpifuture.hh:50
Buffer(bool valid=false)
Definition: mpifuture.hh:41
Buffer(V &&t)
Definition: mpifuture.hh:47
bool valid_
Definition: mpifuture.hh:66
void get()
Definition: mpifuture.hh:73
Buffer(bool valid=false)
Definition: mpifuture.hh:67
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition: mpifuture.hh:82
MPIFuture(V &&recv_data, typename std::enable_if_t<!std::is_void< V >::value > *=0)
Definition: mpifuture.hh:104
bool ready() const
Definition: mpifuture.hh:146
bool valid() const
Definition: mpifuture.hh:136
~MPIFuture()
Definition: mpifuture.hh:109
MPIFuture(bool valid=false)
Definition: mpifuture.hh:89
auto get_send_mpidata()
Definition: mpifuture.hh:166
MPIFuture & operator=(MPIFuture &&f)
Definition: mpifuture.hh:128
void wait()
Definition: mpifuture.hh:140
auto get_mpidata()
Definition: mpifuture.hh:162
R get()
Definition: mpifuture.hh:152
MPIFuture(V &&recv_data, U &&send_data, typename std::enable_if_t<!std::is_void< V >::value &&!std::is_void< U >::value > *=0)
Definition: mpifuture.hh:96
S get_send_data()
Definition: mpifuture.hh:157
MPIFuture(MPIFuture &&f)
Definition: mpifuture.hh:119
Definition: optional.hh:91
void reset() noexcept
Definition: optional.hh:329