3 #ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
4 #define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
20 value = std::make_unique<T>();
24 :
value(std::make_unique<T>(std::forward<V>(t)))
28 T tmp = std::move(*
value);
32 operator bool ()
const {
49 : value(std::forward<V>(t))
51 std::optional<std::reference_wrapper<T>>
value;
57 operator bool ()
const{
71 operator bool ()
const{
82 template<
class R,
class S =
void>
84 mutable MPI_Request req_;
85 mutable MPI_Status status_;
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_))
144 MPI_Wait(&req_, &status_);
149 MPI_Test(&req_, &flag, &status_);
160 return send_data_.
get();
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:11
auto getMPIData(T &t)
Definition: mpidata.hh:41
void swap(T &v1, T &v2, bool mask)
Definition: simd.hh:470
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
Definition: mpifuture.hh:17
std::unique_ptr< T > value
Definition: mpifuture.hh:26
T & operator*() const
Definition: mpifuture.hh:35
Buffer(V &&t)
Definition: mpifuture.hh:23
T get()
Definition: mpifuture.hh:27
Buffer(bool valid)
Definition: mpifuture.hh:18
T & get()
Definition: mpifuture.hh:52
std::optional< std::reference_wrapper< T > > value
Definition: mpifuture.hh:51
Buffer(bool valid=false)
Definition: mpifuture.hh:42
Buffer(V &&t)
Definition: mpifuture.hh:48
bool valid_
Definition: mpifuture.hh:67
void get()
Definition: mpifuture.hh:74
Buffer(bool valid=false)
Definition: mpifuture.hh:68
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition: mpifuture.hh:83
MPIFuture(V &&recv_data, typename std::enable_if_t<!std::is_void< V >::value > *=0)
Definition: mpifuture.hh:105
bool ready() const
Definition: mpifuture.hh:147
bool valid() const
Definition: mpifuture.hh:137
~MPIFuture()
Definition: mpifuture.hh:110
MPIFuture(bool valid=false)
Definition: mpifuture.hh:90
auto get_send_mpidata()
Definition: mpifuture.hh:167
MPIFuture & operator=(MPIFuture &&f)
Definition: mpifuture.hh:129
void wait()
Definition: mpifuture.hh:141
auto get_mpidata()
Definition: mpifuture.hh:163
R get()
Definition: mpifuture.hh:153
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:97
S get_send_data()
Definition: mpifuture.hh:158
MPIFuture(MPIFuture &&f)
Definition: mpifuture.hh:120