18#include <kassert/kassert.hpp>
21#include "kamping/assertion_levels.hpp"
23#include "kamping/collectives/collectives_helpers.hpp"
24#include "kamping/comm_helper/is_same_on_all_ranks.hpp"
25#include "kamping/communicator.hpp"
73 template <
typename...>
74 typename DefaultContainerType,
75 template <
typename,
template <
typename...>
typename>
77template <
typename... Args>
82 return allgather_inplace(std::forward<Args>(
args)...);
92 internal::select_parameter_type<internal::ParameterType::send_buf>(
args...).construct_buffer_or_rebind();
98 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
106 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
114 "All PEs have to send the same number of elements. Use allgatherv, if you want to send a different number "
123 internal::select_parameter_type_or_default<internal::ParameterType::send_count, default_send_count_type>(
127 .construct_buffer_or_rebind();
136 internal::select_parameter_type_or_default<internal::ParameterType::recv_count, default_recv_count_type>(
140 .construct_buffer_or_rebind();
154 "Recv buffer is not large enough to hold all received elements.",
166 this->mpi_communicator()
168 this->mpi_error_hook(
err,
"MPI_Allgather");
170 return make_mpi_result<std::tuple<
Args...>>(
204 template <
typename...>
206 template <
typename,
template <
typename...>
typename>
208template <
typename...
Args>
219 internal::select_parameter_type<internal::ParameterType::send_recv_buf>(
args...).construct_buffer_or_rebind();
220 using value_type =
typename std::remove_reference_t<
decltype(
buffer)>::value_type;
222 auto&& type = internal::determine_mpi_send_recv_datatype<value_type, decltype(buffer)>(
args...);
229 "All PEs have to send the same number of elements. Use allgatherv, if you want to send a different number of "
237 internal::select_parameter_type_or_default<internal::ParameterType::send_recv_count, default_count_type>(
241 .construct_buffer_or_rebind();
247 "There is no send_recv_count given and the number of elements in send_recv_buf is not divisible by the number "
250 "in the communicator.",
264 "Recv buffer is not large enough to hold all received elements.",
274 count.get_single_element(),
275 type.get_single_element(),
276 this->mpi_communicator()
278 this->mpi_error_hook(
err,
"MPI_Allgather");
280 return make_mpi_result<std::tuple<
Args...>>(std::move(
buffer), std::move(count), std::move(type));
321 template <
typename...>
323 template <
typename,
template <
typename...>
typename>
325template <
typename...
Args>
336 internal::select_parameter_type<internal::ParameterType::send_buf>(
args...).construct_buffer_or_rebind();
342 internal::select_parameter_type_or_default<internal::ParameterType::recv_buf, default_recv_buf_type>(
351 internal::determine_mpi_datatypes<send_value_type, recv_value_type, decltype(recv_buf)>(
args...);
358 internal::select_parameter_type_or_default<internal::ParameterType::send_count, default_send_count_type>(
362 .construct_buffer_or_rebind();
370 internal::select_parameter_type_or_default<internal::ParameterType::recv_counts, default_recv_counts_type>(
376 static_assert(std::is_same_v<std::remove_const_t<recv_counts_type>,
int>,
"Recv counts must be of type int");
381 "Receive counts are given on some ranks and have to be computed on others",
385 recv_counts.resize_if_requested([&]() {
return this->size(); });
398 internal::select_parameter_type_or_default<internal::ParameterType::recv_displs, default_recv_displs_type>(
404 static_assert(std::is_same_v<std::remove_const_t<recv_displs_type>,
int>,
"Recv displs must be of type int");
412 "Receive displacements are given on some ranks and have to be computed on others",
416 recv_displs.resize_if_requested([&]() {
return this->size(); });
424 return compute_required_recv_buf_size_in_vectorized_communication(
recv_counts,
recv_displs, this->size());
431 "Recv buffer is not large enough to hold all received elements.",
444 this->mpi_communicator()
446 this->mpi_error_hook(
err,
"MPI_Allgatherv");
448 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 allgather_inplace(Args... args) const
Wrapper for the in-place version of MPI_Allgather.
Definition allgather.hpp:209
auto allgather(Args... args) const
Wrapper for MPI_Allgather.
Definition allgather.hpp:78
auto allgatherv(Args... args) const
Wrapper for MPI_Allgatherv.
Definition allgather.hpp:326
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_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 recv_type(MPI_Datatype recv_type)
Passes recv_type as recv type to the underlying call.
Definition named_parameters.hpp:1238
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.
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.