24#include "kamping/serialization.hpp"
52#define KAMPING_REQUIRED_PARAMETERS(...) , ##__VA_ARGS__
58#define KAMPING_OPTIONAL_PARAMETERS(...) , ##__VA_ARGS__
80#define KAMPING_CHECK_PARAMETERS(args, required, optional) \
82 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETERS(args, required); \
84 using required_parameters_types = typename kamping::internal::parameter_types_to_integral_constants< \
85 KAMPING_PARAMETER_CHECK_HPP_PREFIX_PARAMETERS(required)>::type; \
86 using optional_parameters_types = typename kamping::internal::parameter_types_to_integral_constants< \
87 KAMPING_PARAMETER_CHECK_HPP_PREFIX_PARAMETERS(optional)>::type; \
88 using parameter_types = typename kamping::internal::parameters_to_integral_constant<args...>::type; \
91 has_no_unused_parameters<required_parameters_types, optional_parameters_types, args...>::assertion, \
92 "There are unsupported parameters, only support required " \
93 "parameters " KAMPING_PARAMETER_CHECK_HPP_EVAL_STRINGIFY(required \
94 ) " and optional parameters " KAMPING_PARAMETER_CHECK_HPP_EVAL_STRINGIFY(optional) \
96 static_assert(kamping::internal::all_unique_v<parameter_types>, "There are duplicate parameter types."); \
103#define KAMPING_PARAMETER_CHECK_HPP_EVAL_STRINGIFY(ignore, ...) "[" #__VA_ARGS__ "]"
171#define KAMPING_PARAMETER_CHECK_HPP_SELECT10(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, y, ...) y
183#define KAMPING_PARAMETER_CHECK_HPP_PREFIX_PARAMETERS(...) \
184 KAMPING_PARAMETER_CHECK_HPP_SELECT10( \
186 KAMPING_PARAMETER_CHECK_HPP_PREFIX9(__VA_ARGS__), \
187 KAMPING_PARAMETER_CHECK_HPP_PREFIX8(__VA_ARGS__), \
188 KAMPING_PARAMETER_CHECK_HPP_PREFIX7(__VA_ARGS__), \
189 KAMPING_PARAMETER_CHECK_HPP_PREFIX6(__VA_ARGS__), \
190 KAMPING_PARAMETER_CHECK_HPP_PREFIX5(__VA_ARGS__), \
191 KAMPING_PARAMETER_CHECK_HPP_PREFIX4(__VA_ARGS__), \
192 KAMPING_PARAMETER_CHECK_HPP_PREFIX3(__VA_ARGS__), \
193 KAMPING_PARAMETER_CHECK_HPP_PREFIX2(__VA_ARGS__), \
194 KAMPING_PARAMETER_CHECK_HPP_PREFIX1(__VA_ARGS__), \
195 KAMPING_PARAMETER_CHECK_HPP_PREFIX0(__VA_ARGS__), \
199#define KAMPING_PARAMETER_CHECK_HPP_PREFIX0(ignore)
200#define KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x1) kamping::internal::ParameterType::x1
201#define KAMPING_PARAMETER_CHECK_HPP_PREFIX2(ignore, x1, x2) \
202 KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x1), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x2)
203#define KAMPING_PARAMETER_CHECK_HPP_PREFIX3(ignore, x1, x2, x3) \
204 KAMPING_PARAMETER_CHECK_HPP_PREFIX2(ignore, x1, x2), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x3)
205#define KAMPING_PARAMETER_CHECK_HPP_PREFIX4(ignore, x1, x2, x3, x4) \
206 KAMPING_PARAMETER_CHECK_HPP_PREFIX3(ignore, x1, x2, x3), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x4)
207#define KAMPING_PARAMETER_CHECK_HPP_PREFIX5(ignore, x1, x2, x3, x4, x5) \
208 KAMPING_PARAMETER_CHECK_HPP_PREFIX4(ignore, x1, x2, x3, x4), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x5)
209#define KAMPING_PARAMETER_CHECK_HPP_PREFIX6(ignore, x1, x2, x3, x4, x5, x6) \
210 KAMPING_PARAMETER_CHECK_HPP_PREFIX5(ignore, x1, x2, x3, x4, x5), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x6)
211#define KAMPING_PARAMETER_CHECK_HPP_PREFIX7(ignore, x1, x2, x3, x4, x5, x6, x7) \
212 KAMPING_PARAMETER_CHECK_HPP_PREFIX6(ignore, x1, x2, x3, x4, x5, x6), KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x7)
213#define KAMPING_PARAMETER_CHECK_HPP_PREFIX8(ignore, x1, x2, x3, x4, x5, x6, x7, x8) \
214 KAMPING_PARAMETER_CHECK_HPP_PREFIX7(ignore, x1, x2, x3, x4, x5, x6, x7), \
215 KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x8)
216#define KAMPING_PARAMETER_CHECK_HPP_PREFIX9(ignore, x1, x2, x3, x4, x5, x6, x7, x8, x9) \
217 KAMPING_PARAMETER_CHECK_HPP_PREFIX8(ignore, x1, x2, x3, x4, x5, x6, x7, x8), \
218 KAMPING_PARAMETER_CHECK_HPP_PREFIX1(ignore, x9)
227#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETERS(args, ...) \
228 KAMPING_PARAMETER_CHECK_HPP_SELECT10( \
230 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER9(args, __VA_ARGS__), \
231 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER8(args, __VA_ARGS__), \
232 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER7(args, __VA_ARGS__), \
233 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER6(args, __VA_ARGS__), \
234 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER5(args, __VA_ARGS__), \
235 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER4(args, __VA_ARGS__), \
236 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER3(args, __VA_ARGS__), \
237 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER2(args, __VA_ARGS__), \
238 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, __VA_ARGS__), \
239 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER0(args, __VA_ARGS__), \
243#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER0(args, ignore)
244#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x1) \
246 kamping::internal::has_parameter_type<kamping::internal::ParameterType::x1, args...>(), \
247 "Missing required parameter " #x1 \
249#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER2(args, ignore, x1, x2) \
250 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x1); \
251 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x2)
252#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER3(args, ignore, x1, x2, x3) \
253 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER2(args, ignore, x1, x2); \
254 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x3)
255#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER4(args, ignore, x1, x2, x3, x4) \
256 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER3(args, ignore, x1, x2, x3); \
257 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x4)
258#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER5(args, ignore, x1, x2, x3, x4, x5) \
259 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER4(args, ignore, x1, x2, x3, x4); \
260 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x5)
261#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER6(args, ignore, x1, x2, x3, x4, x5, x6) \
262 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER5(args, ignore, x1, x2, x3, x4, x5); \
263 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x6)
264#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER7(args, ignore, x1, x2, x3, x4, x5, x6, x7) \
265 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER6(args, ignore, x1, x2, x3, x4, x5, x6); \
266 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x7)
267#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER8(args, ignore, x1, x2, x3, x4, x5, x6, x7, x8) \
268 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER7(args, ignore, x1, x2, x3, x4, x5, x6, x7); \
269 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x8)
270#define KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER9(args, ignore, x1, x2, x3, x4, x5, x6, x7, x8, x9) \
271 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER8(args, ignore, x1, x2, x3, x4, x5, x6, x7, x8); \
272 KAMPING_PARAMETER_CHECK_HPP_ASSERT_REQUIRED_PARAMETER1(args, ignore, x9)
277#define KAMPING_UNSUPPORTED_PARAMETER(args, parameter_type, whatfor) \
279 !kamping::internal::has_parameter_type<kamping::internal::ParameterType::parameter_type, args...>(), \
280 "Parameter type " #parameter_type " is not supported " #whatfor "." \
293template <
typename RequiredParametersTuple,
typename OptionalParametersTuple,
typename... Args>
311 return std::tuple_size_v<
decltype(std::tuple_cat(
314 std::tuple<std::tuple_element_t<Indices, all_available_parameters>>,
316 ))> +
sizeof...(
Args);
322 std::make_index_sequence<std::tuple_size_v<all_available_parameters>>{}
329template <
typename Tuple>
338template <
typename T,
typename...
Ts>
340 : std::conjunction<std::negation<std::disjunction<std::is_same<T, Ts>...>>, all_unique<std::tuple<Ts...>>> {};
343template <
typename Tuple>
348template <ParameterType T>
351 using type = std::integral_constant<ParameterType, T>;
371 using type =
decltype(std::tuple_cat(
386 if constexpr (
found_pos >=
sizeof...(Args)) {
390 return !FoundType::is_out_buffer;
397template <
typename BufferType>
399 std::remove_reference_t<BufferType>::is_out_buffer || std::remove_reference_t<BufferType>::is_lib_allocated;
414template <
typename DataBufferType>
416 typename std::remove_const_t<std::remove_reference_t<DataBufferType>>::MemberTypeWithConstAndRef>;
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
ParameterType
Each input parameter to one of the MPI calls wrapped by KaMPIng needs to has one of the following tag...
Definition named_parameter_types.hpp:33
constexpr bool has_parameter_type()
Checks if parameter with requested parameter type exists.
Definition named_parameter_selection.hpp:186
Template magic to implement named parameters in cpp.
File containing the parameter types used by the KaMPIng library.
Internal namespace marking the code that is not user-facing.
Definition collectives_helpers.hpp:20
static constexpr bool any_has_to_be_computed
Checks if any of the buffers have to be computed by kamping, i.e., if at least one buffer is an outpu...
Definition named_parameter_check.hpp:411
static constexpr bool buffer_uses_serialization
Checks if DataBufferType is a serialization buffer.
Definition named_parameter_check.hpp:415
constexpr bool is_serialization_buffer_v
Type trait to check if a type is a serialization buffer.
Definition serialization.hpp:114
static constexpr bool is_parameter_given_as_in_buffer
Checks if a data buffer with requested parameter type exists and it is an input parameter (i....
Definition named_parameter_check.hpp:384
static constexpr bool all_have_to_be_computed
Checks if all buffers have to be computed by kamping, i.e., if all buffers are output parameters of t...
Definition named_parameter_check.hpp:405
static constexpr bool all_unique_v
true if and only if all types of the tuple are unique.
Definition named_parameter_check.hpp:344
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
Base wrapper (std::integral_constant) to test if all types of a tuple are unique.
Definition named_parameter_check.hpp:330
Struct wrapping a check that verifies that no unused parameters are part of the arguments.
Definition named_parameter_check.hpp:294
static constexpr bool assertion
true if and only if no unused parameter can be found in Args.
Definition named_parameter_check.hpp:320
static constexpr auto number_distinct_parameters(std::index_sequence< Indices... > indices)
Get total number of different parameters (passed, required, and optional).
Definition named_parameter_check.hpp:310
decltype(std::tuple_cat(RequiredParametersTuple{}, OptionalParametersTuple{})) all_available_parameters
Concatenation of required and optional parameters.
Definition named_parameter_check.hpp:296
Wrapper to get an std::integral_constant for a kamping::internal::ParameterType.
Definition named_parameter_check.hpp:349
std::integral_constant< ParameterType, T > type
kamping::internal::ParameterType as std::integral_constant.
Definition named_parameter_check.hpp:351
Wrapper to get a tuple of std::integral_constant for each kamping::internal::ParameterType passed as ...
Definition named_parameter_check.hpp:358
decltype(std::tuple_cat(std::tuple< typename parameter_type_to_integral_constant< ParameterTypes >::type >{}...)) type
Type of the tuple.
Definition named_parameter_check.hpp:360
Wrapper to get a tuple of std::integral_constant for each kamping::internal::ParameterType of the par...
Definition named_parameter_check.hpp:369
decltype(std::tuple_cat( std::tuple< typename parameter_type_to_integral_constant< Parameters::parameter_type >::type >{}...)) type
Type of the tuple.
Definition named_parameter_check.hpp:371