22#include "kamping/assertion_levels.hpp"
24#include "kamping/collectives/bcast.hpp"
25#include "kamping/collectives/gather.hpp"
26#include "kamping/communicator.hpp"
29#include "kamping/kassert/kassert.hpp"
81 template <
typename...>
82 typename DefaultContainerType,
83 template <
typename,
template <
typename...>
typename>
85template <
typename recv_value_type_tparam ,
typename... Args>
103 "Invalid root rank " <<
int_root <<
" in communicator of size " << size(),
107 this->is_same_on_all_ranks(
int_root),
108 "Root has to be the same on all ranks.",
116 .construct_buffer_or_rebind();
120 "Send buffer must be specified on root.",
128 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
136 !std::is_same_v<recv_value_type, internal::unused_tparam>,
137 "No send_buf or recv_buf parameter provided and no receive value given as template parameter. One of these is "
143 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
146 "Send type must be specified on root.",
154 internal::select_parameter_type_or_default<internal::ParameterType::send_count, default_send_count_type>(
158 .construct_buffer_or_rebind();
164 "No send count is given and the size of the send buffer ("
165 <<
send_buf.size() <<
") at the root is not divisible by the number of PEs (" << size()
166 <<
") in the communicator.",
177 internal::select_parameter_type_or_default<internal::ParameterType::recv_count, default_recv_count_type>(
181 .construct_buffer_or_rebind();
186 "recv_count() parameter is an output parameter on some PEs, but not on alle PEs.",
204 "Recv buffer is not large enough to hold all received elements.",
218 this->mpi_error_hook(
err,
"MPI_Scatter");
220 return make_mpi_result<std::tuple<
Args...>>(
245 template <
typename...>
247 template <
typename,
template <
typename...>
typename>
258 std::tuple(this->
root()),
263 if constexpr (kassert::internal::assertion_enabled(
assert::light)) {
264 if (is_root(
root.rank_signed())) {
274 "send_buf of size equal to comm.size() must be provided on the root rank.",
280 if constexpr (has_parameter_type<ParameterType::send_buf,
Args...>()) {
282 using value_type =
typename send_recv_buf_type::value_type;
333 template <
typename...>
335 template <
typename,
template <
typename...>
typename>
364 "Invalid root rank " <<
root_val <<
" in communicator of size " << size(),
369 "Root has to be the same on all ranks.",
377 .construct_buffer_or_rebind();
382 "Send buffer must be specified on root.",
390 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
398 !std::is_same_v<recv_value_type, internal::unused_tparam>,
399 "No send_buf or recv_buf parameter provided and no receive value given as template parameter. One of these is "
405 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
416 "send_counts() must be given on the root PE.",
421 "Send counts buffer is smaller than the number of PEs at the root PE.",
435 send_displs.resize_if_requested([&]() {
return this->size(); });
439 "Send displs buffer is smaller than the number of PEs at the root PE.",
452 .construct_buffer_or_rebind();
458 "recv_counts() must be given on all PEs or on no PEs",
472 return static_cast<size_t>(
recv_count.get_single_element());
479 "Recv buffer is not large enough to hold all received elements.",
494 this->mpi_error_hook(
err,
"MPI_Scatterv");
496 return make_mpi_result<std::tuple<
Args...>>(
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 scatter(Args... args) const
Wrapper for MPI_Scatter.
Definition scatter.hpp:86
auto scatterv(Args... args) const
Wrapper for MPI_Scatterv.
Definition scatter.hpp:338
auto scatter_single(Args... args) const
Definition scatter.hpp:250
static constexpr auto alloc_new
Convenience wrapper for creating library allocated containers. See AllocNewT for details.
Definition data_buffer.hpp:195
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:576
auto root(int rank)
Passes rank as root rank to the underlying call. This parameter is needed in functions like MPI_Gathe...
Definition named_parameters.hpp:981
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:205
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:139
auto send_count(int count)
Passes count as send count to the underlying call.
Definition named_parameters.hpp:323
auto send_displs_out()
Indicates to construct a container with type kamping::Communicator::default_container_type<int>,...
Definition named_parameters.hpp:681
auto recv_count(int count)
Passes count as recv count to the underlying call.
Definition named_parameters.hpp:492
auto send_counts_out()
Indicates to construct a container with type kamping::Communicator::default_container_type<int>,...
Definition named_parameters.hpp:311
auto recv_buf(Container &&container)
Passes a container, into which the received elements will be written, to the underlying call....
Definition named_parameters.hpp:861
auto recv_type(MPI_Datatype recv_type)
Passes recv_type as recv type to the underlying call.
Definition named_parameters.hpp:1302
auto send_type(MPI_Datatype send_type)
Passes send_type as send type to the underlying call.
Definition named_parameters.hpp:1259
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:349
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:518
auto send_buf(internal::ignore_t< Data > ignore)
Generates a dummy send buf that wraps a nullptr.
Definition named_parameters.hpp:53
std:: tuple_element_t< find_pos< std::integral_constant< ParameterType, parameter_type >, 0, Args... >(), std::tuple< Args... > > buffer_type_with_requested_parameter_type
Type of Buffer with requested.
Definition named_parameter_selection.hpp:175
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.
File containing the parameter types used by the KaMPIng library.
Factory methods for buffer wrappers.
Internal namespace marking the code that is not user-facing.
Definition collectives_helpers.hpp:20
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.