21#include <kassert/kassert.hpp>
24#include "kamping/assertion_levels.hpp"
26#include "kamping/collectives/barrier.hpp"
27#include "kamping/collectives/collectives_helpers.hpp"
28#include "kamping/collectives/ibarrier.hpp"
29#include "kamping/comm_helper/is_same_on_all_ranks.hpp"
30#include "kamping/communicator.hpp"
35#include "kamping/p2p/iprobe.hpp"
36#include "kamping/p2p/isend.hpp"
37#include "kamping/p2p/recv.hpp"
38#include "kamping/request_pool.hpp"
81 template <
typename...>
82 typename DefaultContainerType,
83 template <
typename,
template <
typename...>
typename>
85template <
typename... Args>
87 using namespace internal;
90 return this->alltoall_inplace(std::forward<Args>(
args)...);
100 internal::select_parameter_type<internal::ParameterType::send_buf>(
args...).construct_buffer_or_rebind();
107 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
114 static_assert(!std::is_const_v<recv_value_type>,
"The receive buffer must not have a const value_type.");
117 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
123 internal::select_parameter_type_or_default<internal::ParameterType::send_count, default_send_count_type>(
127 .construct_buffer_or_rebind();
135 internal::select_parameter_type_or_default<internal::ParameterType::recv_count, default_recv_count_type>(
139 .construct_buffer_or_rebind();
148 "There are no send counts given and the number of elements in send_buf is not divisible by the number of "
150 "in the communicator.",
162 "Recv buffer is not large enough to hold all received elements.",
180 this->mpi_error_hook(
err,
"MPI_Alltoall");
181 return make_mpi_result<std::tuple<
Args...>>(
220 template <
typename...>
222 template <
typename,
template <
typename...>
typename>
224template <
typename...
Args>
226 using namespace internal;
234 internal::select_parameter_type<internal::ParameterType::send_recv_buf>(
args...).construct_buffer_or_rebind();
237 internal::determine_mpi_send_recv_datatype<send_recv_value_type, decltype(send_recv_buf)>(
args...);
242 auto&&
count_param = internal::select_parameter_type_or_default<ParameterType::send_recv_count, default_count_type>(
246 .construct_buffer_or_rebind();
251 "There is no send_recv_count given and the number of elements in send_recv_buf is not divisible by the number "
254 "in the communicator.",
269 "send_recv_buf is not large enough to hold all received elements.",
281 this->mpi_error_hook(
err,
"MPI_Alltoall");
283 return make_mpi_result<std::tuple<
Args...>>(
330 template <
typename...>
332 template <
typename,
template <
typename...>
typename>
334template <
typename...
Args>
345 internal::select_parameter_type<internal::ParameterType::send_buf>(
args...).construct_buffer_or_rebind();
352 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
361 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
366 auto const&
send_counts = internal::select_parameter_type<internal::ParameterType::send_counts>(
args...)
369 static_assert(std::is_same_v<std::remove_const_t<send_counts_type>,
int>,
"Send counts must be of type int");
372 "Send counts must be given as an input parameter"
379 internal::select_parameter_type_or_default<internal::ParameterType::recv_counts, default_recv_counts_type>(
385 static_assert(std::is_same_v<std::remove_const_t<recv_counts_type>,
int>,
"Recv counts must be of type int");
390 internal::select_parameter_type_or_default<internal::ParameterType::send_displs, default_send_displs_type>(
396 static_assert(std::is_same_v<std::remove_const_t<send_displs_type>,
int>,
"Send displs must be of type int");
401 internal::select_parameter_type_or_default<internal::ParameterType::recv_displs, default_recv_displs_type>(
407 static_assert(std::is_same_v<std::remove_const_t<recv_displs_type>,
int>,
"Recv displs must be of type int");
409 static_assert(!std::is_const_v<recv_value_type>,
"The receive buffer must not have a const value_type.");
415 "Receive counts are given on some ranks and have to be computed on others",
420 recv_counts.resize_if_requested([&]() {
return this->size(); });
431 "Send displacements are given on some ranks and have to be computed on others",
436 send_displs.resize_if_requested([&]() {
return this->size(); });
458 "Receive displacements are given on some ranks and have to be computed on others",
462 recv_displs.resize_if_requested([&]() {
return this->size(); });
470 return compute_required_recv_buf_size_in_vectorized_communication(
recv_counts,
recv_displs, this->size());
478 "Recv buffer is not large enough to hold all received elements.",
495 this->mpi_error_hook(
err,
"MPI_Alltoallv");
Helper functions that make casts safer.
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
T value_type
The value type.
Definition allocator.hpp:53
constexpr int light
Assertion level for lightweight assertions.
Definition assertion_levels.hpp:13
constexpr int light_communication
Assertions that perform lightweight communication.
Definition assertion_levels.hpp:25
auto alltoall(Args... args) const
Wrapper for MPI_Alltoall.
Definition alltoall.hpp:86
auto alltoall_inplace(Args... args) const
Wrapper for the in-place version of Communicator::alltoall.
Definition alltoall.hpp:225
auto alltoallv(Args... args) const
Wrapper for MPI_Alltoallv.
Definition alltoall.hpp:335
static constexpr auto alloc_new
Convenience wrapper for creating library allocated containers. See AllocNewT for details.
Definition data_buffer.hpp:194
auto send_count(int count)
Passes count as send count to the underlying call.
Definition named_parameters.hpp:321
auto recv_counts(Container &&container)
Passes a container as recv counts to the underlying call, i.e. the container's storage must contain t...
Definition named_parameters.hpp:366
auto send_type(MPI_Datatype send_type)
Passes send_type as send type to the underlying call.
Definition named_parameters.hpp:1195
auto recv_buf(Container &&container)
Passes a container, into which the received elements will be written, to the underlying call....
Definition named_parameters.hpp:859
auto send_buf(internal::ignore_t< Data > ignore)
Generates a dummy send buf that wraps a nullptr.
Definition named_parameters.hpp:51
auto send_count_out()
Indicates to deduce the send count and return it to the caller as part of the underlying call's resul...
Definition named_parameters.hpp:347
auto send_recv_buf(Data &&data)
Passes a container/single value as a send or receive buffer to the underlying MPI call.
Definition named_parameters.hpp:137
auto recv_counts_out()
Indicates to construct a container with type kamping::Communicator::default_container_type<int>,...
Definition named_parameters.hpp:478
auto recv_displs_out()
Indicates to construct a container with type kamping::Communicator::default_container_type<int>,...
Definition named_parameters.hpp:802
auto send_counts(Container &&container)
Passes a container as send counts to the underlying call, i.e. the container's storage must contain t...
Definition named_parameters.hpp:203
auto send_recv_count(int count)
Passes count as send/recv count to the underlying call.
Definition named_parameters.hpp:529
auto recv_displs(Container &&container)
Passes a container as receive displacements to the underlying call, i.e. the container's storage must...
Definition named_parameters.hpp:697
auto recv_count(int count)
Passes count as recv count to the underlying call.
Definition named_parameters.hpp:490
auto send_displs_out()
Indicates to construct a container with type kamping::Communicator::default_container_type<int>,...
Definition named_parameters.hpp:679
auto recv_type(MPI_Datatype recv_type)
Passes recv_type as recv type to the underlying call.
Definition named_parameters.hpp:1238
auto send_displs(Container &&container)
Passes a container as send displacements to the underlying call, i.e. the container's storage must co...
Definition named_parameters.hpp:574
auto send_recv_type(MPI_Datatype send_recv_type)
Passes send_recv_type as send/recv type to the underlying call. (This parameter is in MPI routines su...
Definition named_parameters.hpp:1282
auto recv_count_out()
Indicates to deduce the recv count and return it to the caller as part of the underlying call's resul...
Definition named_parameters.hpp:516
auto send_recv_count_out()
Indicates to deduce the send/recv count and return it to the caller as part of the underlying call's ...
Definition named_parameters.hpp:555
constexpr bool has_parameter_type()
Checks if parameter with requested parameter type exists.
Definition named_parameter_selection.hpp:186
Utility that maps C++ types to types that can be understood by MPI.
Template magic to check named parameters passed to wrappers at compile time.
#define KAMPING_REQUIRED_PARAMETERS(...)
Wrapper to pass (possibly empty) list of parameter type names as required parameters to KAMPING_CHECK...
Definition named_parameter_check.hpp:52
#define KAMPING_OPTIONAL_PARAMETERS(...)
Wrapper to pass (possibly empty) list of parameter type names as optional parameters to KAMPING_CHECK...
Definition named_parameter_check.hpp:58
#define KAMPING_CHECK_PARAMETERS(args, required, optional)
Assertion macro that checks if passed parameters are correct, i.e., all parameter types are unique,...
Definition named_parameter_check.hpp:80
Template magic to implement named parameters in cpp.
Factory methods for buffer wrappers.
auto make_mpi_result(Buffers &&... buffers)
Construct result object for a wrapped MPI call. Four different cases are handled: a) The recv_buffer ...
Definition result.hpp:1017
static constexpr bool has_to_be_computed
Checks if the buffer has to be computed by kamping, i.e. if it is an output parameter or the buffer h...
Definition named_parameter_check.hpp:398
Some functions and types simplifying/enabling the development of wrapped MPI calls in KaMPIng.