22#include "kamping/named_parameters_detail/status_parameters.hpp"
36template <
typename RequestType>
54 return static_cast<RequestType&
>(*this).request_ptr();
71 template <
typename StatusParamObjectType = decltype(status(ignore<>))>
75 "Only status parameters are allowed."
80 if constexpr (internal::is_extractable<StatusParamObjectType>) {
98 template <
typename StatusParamObjectType = decltype(status(ignore<>))>
102 "Only status parameters are allowed."
108 if constexpr (internal::is_extractable<StatusParamObjectType>) {
110 return std::optional{
status.extract()};
112 return std::optional<Status>{};
121 return *request_ptr();
126 return *request_ptr();
132 template <
typename T>
134 return *request_ptr() == *
other.request_ptr();
138 template <
typename T>
140 return !(*
this ==
other);
168template <
typename IndexType>
201 typename std::enable_if<
203 Container> && std::is_same_v<typename std::remove_reference_t<Container>::value_type, MPI_Request>,
205void wait_all(Container&& requests) {
206 int err = MPI_Waitall(asserting_cast<int>(requests.size()), requests.data(), MPI_STATUSES_IGNORE);
216 typename std::enable_if<
218 Container> && std::is_same_v<typename std::remove_reference_t<Container>::value_type, Request>,
220void wait_all_with_undefined_behavior(Container&& requests) {
224 sizeof(Request) ==
sizeof(MPI_Request) && std::is_standard_layout_v<Request>,
225 "Request is not layout compatible with MPI_Request."
228 MPI_Request* begin =
reinterpret_cast<MPI_Request*
>(requests.data());
229 wait_all(Span<MPI_Request>{begin, requests.size()});
238 typename std::enable_if<
240 Container> && std::is_same_v<typename std::remove_reference_t<Container>::value_type, Request>,
242void wait_all(Container&& requests) {
243 std::vector<MPI_Request> mpi_requests(requests.size());
245 auto begin = requests.data();
246 auto end = begin + requests.size();
248 for (
auto current = begin; current != end; current++) {
249 mpi_requests[idx] = current->mpi_request();
252 wait_all(mpi_requests);
259 typename... RequestType,
261 std::enable_if_t<std::conjunction_v<std::is_convertible<std::remove_reference_t<RequestType>, Request>...>>>
262void wait_all(RequestType&&... args) {
263 constexpr size_t req_size =
sizeof...(args);
264 MPI_Request reqs[req_size] = {Request{std::move(args)}.mpi_request()...};
265 wait_all(Span<MPI_Request>(reqs, req_size));
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
Wrapper for MPI requests owned by a RequestPool.
Definition request.hpp:169
MPI_Request * request_ptr()
returns a pointer to the wrapped MPI_Request.
Definition request.hpp:175
IndexType index() const
provides access to this request's index in the pool.
Definition request.hpp:185
PooledRequest(IndexType idx, MPI_Request &request)
constructs a PooledRequest with the given index idx and request.
Definition request.hpp:172
MPI_Request const * request_ptr() const
returns a const pointer to the wrapped MPI_Request.
Definition request.hpp:180
Base class for request wrappers.
Definition request.hpp:37
RequestBase & operator=(RequestBase const &)=delete
Copy assignment operator is deleted because requests should only be moved.
bool is_null() const
Definition request.hpp:86
bool operator!=(RequestBase< T > const &other) const
Definition request.hpp:139
RequestBase(RequestBase &&)=default
Move constructor.
RequestBase(RequestBase const &)=delete
Copy constructor is deleted because requests should only be moved.
RequestBase & operator=(RequestBase &&)=default
Move assignment operator.
MPI_Request & mpi_request()
Definition request.hpp:120
MPI_Request const & mpi_request() const
Definition request.hpp:125
auto test(StatusParamObjectType status_param=kamping::status(ignore<>))
Tests for completion of the underlying request. If the underlying request was initialized by a non-bl...
Definition request.hpp:99
bool operator==(RequestBase< T > const &other) const
Definition request.hpp:133
auto wait(StatusParamObjectType status_param=kamping::status(ignore<>))
Returns when the operation defined by the underlying request completes. If the underlying request was...
Definition request.hpp:72
Wrapper for MPI request handles (aka. MPI_Request).
Definition request.hpp:145
MPI_Request const * request_ptr() const
returns a const pointer to the wrapped MPI_Request.
Definition request.hpp:157
Request(MPI_Request request=MPI_REQUEST_NULL)
Constructs a request handle from an MPI_Request.
Definition request.hpp:149
MPI_Request * request_ptr()
returns a pointer to the wrapped MPI_Request.
Definition request.hpp:152
#define THROW_IF_MPI_ERROR(error_code, function)
Wrapper around THROWING_KASSERT for MPI errors.
Definition error_handling.hpp:33
auto status(internal::ignore_t< void >)
pass MPI_STATUS_IGNORE to the underlying MPI call.
Definition status_parameters.hpp:52
auto request()
Internally allocate a request object and return it to the user.
Definition named_parameters.hpp:1122
@ status
Tag used to represent the status in a MPI call.
constexpr bool has_data_member_v
Boolean value helping to decide if data type has .data() method.
Definition data_buffer.hpp:272
static MPI_Status * status_param_to_native_ptr(StatusParam ¶m)
returns a pointer to the MPI_Status encapsulated by the provided status parameter object.
Definition parameter_objects.hpp:489
Parameter objects return by named parameter factory functions.
Some functions and types simplifying/enabling the development of wrapped MPI calls in KaMPIng.