KaMPIng 0.1.0
(Near) zero-overhead C++ MPI bindings.
Loading...
Searching...
No Matches
Utility

Quality of life features that make coding with (and within) KaMPIng easier. More...

Classes

struct  kamping::internal::ParameterTypeUnwrapping< Arg >
 Trait struct used to determine the underlying type and value of the parameter type of an object with a parameter type. (This is a building block to enable plugins to have their own named parameters). More...
 
struct  kamping::internal::ParameterTypeUnwrapping< std::integral_constant< T, v > >
 Trait struct used to determine the underlying type and value of the parameter type of an std::integral_constant wrapping a parameter type. (This is a building block to enable plugins to have their own named parameters). More...
 
struct  kamping::internal::has_parameter_helper< typename >
 Helper struct needed to retrieve the types stored in a std::tuple for the has_parameter_type check. More...
 

Typedefs

template<typename Arg >
using kamping::internal::parameter_type_t = typename ParameterTypeUnwrapping<Arg>::type
 Trait for the underlying type of the parameter type of.
 
template<ParameterType parameter_type, typename... Args>
using kamping::internal::buffer_type_with_requested_parameter_type
 Type of Buffer with requested.
 

Enumerations

enum class  kamping::internal::ParameterType {
  kamping::internal::ParameterType::send_buf , kamping::internal::ParameterType::recv_buf , kamping::internal::ParameterType::send_recv_buf , kamping::internal::ParameterType::recv_counts ,
  kamping::internal::ParameterType::recv_count , kamping::internal::ParameterType::recv_displs , kamping::internal::ParameterType::send_counts , kamping::internal::ParameterType::send_count ,
  kamping::internal::ParameterType::send_displs , kamping::internal::ParameterType::send_recv_count , kamping::internal::ParameterType::op , kamping::internal::ParameterType::source ,
  kamping::internal::ParameterType::destination , kamping::internal::ParameterType::status , kamping::internal::ParameterType::statuses , kamping::internal::ParameterType::request ,
  kamping::internal::ParameterType::root , kamping::internal::ParameterType::tag , kamping::internal::ParameterType::send_mode , kamping::internal::ParameterType::values_on_rank_0 ,
  kamping::internal::ParameterType::send_type , kamping::internal::ParameterType::recv_type , kamping::internal::ParameterType::send_recv_type
}
 Each input parameter to one of the MPI calls wrapped by KaMPIng needs to has one of the following tags. More...
 

Functions

template<class To , class From >
constexpr bool kamping::in_range (From value) noexcept
 Checks if an integer value can be safely casted into an integer type To, that is, it lies in the range [min(To), max(To)].
 
template<class To , class From >
constexpr To kamping::asserting_cast (From value) KAMPING_NOEXCEPT
 Casts an integer value to the integer type To. If the value is outside To's range, throws an assertion.
 
template<class To , class From >
constexpr To kamping::throwing_cast (From value)
 Casts an integer value to the integer type To. If the value is outside To's range, throws an exception.
 
template<typename T , typename U >
constexpr bool kamping::internal::has_same_parameter_type ()
 Check whether two objects have the same parameter type.
 
template<typename ParameterTypeConstant , size_t Index>
constexpr size_t kamping::internal::find_pos ()
 Base case if there are no parameters: always returns max index indicating that the parameter was not found.
 
template<typename ParameterTypeConstant , size_t Index, typename Arg >
constexpr size_t kamping::internal::find_pos ()
 Returns the Index parameter if the parameter type of Arg matches the requested parameter type. If not, this fails to compile.
 
template<typename ParameterTypeConstant , size_t Index, typename Arg , typename Arg2 , typename... Args>
constexpr size_t kamping::internal::find_pos ()
 Returns position of first argument in Args with Trait trait.
 
template<typename ParameterTypeConstant , typename... Args>
autokamping::internal::select_parameter_type (Args &... args)
 Returns parameter with requested parameter type.
 
template<ParameterType parameter_type, typename... Args>
autokamping::internal::select_parameter_type_in_tuple (std::tuple< Args... > &tuple)
 Returns parameter with requested parameter type.
 
template<ParameterType parameter_type, typename... Args>
auto constkamping::internal::select_parameter_type_in_tuple (std::tuple< Args... > const &tuple)
 Returns parameter with requested parameter type.
 
template<typename ParameterTypeConstant , typename... Args>
constexpr bool kamping::internal::has_parameter_type ()
 Checks if parameter with requested parameter type exists.
 
template<ParameterType parameter_type, typename... Args>
constexpr bool kamping::internal::has_parameter_type_in_tuple_impl (has_parameter_helper< std::tuple< Args... > >)
 Checks if parameter with requested parameter type exists. Wrapper using the functionality from kamping::internal::has_parameter_type() disassembling a std::tuple passed as parameter.
 
template<ParameterType parameter_type, typename Tuple >
constexpr bool kamping::internal::has_parameter_type_in_tuple ()
 Checks if parameter with requested parameter type exists.
 
template<typename ParameterTypeConstant , typename DefaultParameterType , typename... DefaultArguments, typename... Args>
decltype(autokamping::internal::select_parameter_type_or_default (std::tuple< DefaultArguments... > default_arguments, Args &... args)
 Checks if parameter with requested parameter type exists, if not constructs a default value.
 

Variables

template<typename Arg >
constexpr parameter_type_t< Argkamping::internal::parameter_type_v = ParameterTypeUnwrapping<Arg>::value
 Trait for the underlying value of the parameter type of.
 

Detailed Description

Quality of life features that make coding with (and within) KaMPIng easier.

Typedef Documentation

◆ buffer_type_with_requested_parameter_type

Initial value:
std::
tuple_element_t<find_pos<std::integral_constant<ParameterType, parameter_type>, 0, Args...>(), std::tuple<Args...>>

Type of Buffer with requested.

Template Parameters
parameter_type
TParameterTypeType of the parameter type (required for parameter selection within plugins).
parameter_typeThe parameter type with which a parameter should be found.
ArgsAll parameter types to be searched for type parameter_type.

◆ parameter_type_t

Trait for the underlying type of the parameter type of.

Template Parameters
Arg.

Enumeration Type Documentation

◆ ParameterType

Each input parameter to one of the MPI calls wrapped by KaMPIng needs to has one of the following tags.

The MPI calls wrapped by KaMPIng do not rely on the restricting positional parameter paradigm but use named parameters instead. The ParameterTypes defined in this enum are necessary to implement this approach, as KaMPIng needs to identify the purpose of each (unordered) argument. Note that not all enum entries are necessary in each wrapped MPI call.

Enumerator
send_buf 

Tag used to represent a send buffer, i.e. a buffer containing the data elements to be sent via MPI.

recv_buf 

Tag used to represent a receive buffer, i.e. a buffer containing the data elements to be received via MPI.

send_recv_buf 

Tag used to represent a send and receive buffer, i.e. a buffer containing the data elements to be sent or received (depending on the process' rank) via MPI.

recv_counts 

Tag used to represent a receive counts buffer, i.e. a buffer containing the receive counts from the involved PEs.

recv_count 

Tag used to represent the number of elements to be received.

recv_displs 

Tag used to represent a receive displacements buffer, i.e. a buffer containing the receive displacements from the involved PEs.

send_counts 

Tag used to represent a send counts buffer, i.e. a buffer containing the send counts from the involved PEs.

send_count 

Tag used to represent the number of elements to be sent.

send_displs 

Tag used to represent a send displacements buffer, i.e. a buffer containing the send displacements from the involved PEs.

send_recv_count 

Tag used to represent the number of elements to be sent or received.

op 

Tag used to represent a reduce operation in a MPI call.

source 

Tag used to represent the sending PE in a MPI call.

destination 

Tag used to represent the receiving PE in a MPI call.

status 

Tag used to represent the status in a MPI call.

statuses 

Tag used to represent a container of statuses in a MPI call.

request 

Tag used to represent an MPI_Request.

root 

Tag used to represent the root PE in a MPI collectives call.

tag 

Tag used to represent the message tag in a MPI call.

send_mode 

Tag used to represent the send mode used by a send operation.

values_on_rank_0 

Tag used to represent the value of the exclusive scan operation on rank 0.

send_type 

Tag used to represent a send type in an MPI call.

recv_type 

Tag used to represent a recv type in an MPI call.

send_recv_type 

Tag used to represent a send and/or recv type in an MPI call. This parameter type is used for example in MPI collective operations like MPI_Bcast where the corresponding MPI function expects only one MPI_Datatype parameter of type MPI_Datatype.

Function Documentation

◆ asserting_cast()

template<class To , class From >
constexpr To kamping::asserting_cast ( From value)
constexpr

Casts an integer value to the integer type To. If the value is outside To's range, throws an assertion.

Alternatively, exceptions can be used instead of assertions by using throwing_cast().

This function works only for integer types which have at most std::numeric_limits<intmax_t>::digits (To and From are signed) or std::numeric_limits<intmax_t>::digits (else) bits. These two assumptions are checked by in_range() using static_assert()s.

Template Parameters
ToType to cast to.
FromType to cast from, will be auto inferred.
Parameters
valueValue you want to cast.
Returns
Casted value.

◆ find_pos() [1/3]

constexpr size_t kamping::internal::find_pos ( )
constexpr

Base case if there are no parameters: always returns max index indicating that the parameter was not found.

Template Parameters
ParameterTypeConstantType and value of the parameter type (required for parameter selection within plugins).
IndexIndex of current argument to evaluate (ignored).
Returns
std::numeric_limits<size_t>::max().

◆ find_pos() [2/3]

constexpr size_t kamping::internal::find_pos ( )
constexpr

Returns the Index parameter if the parameter type of Arg matches the requested parameter type. If not, this fails to compile.

This is the base case of the recursion.

Template Parameters
ParameterTypeConstantType and value of the parameter type (required for parameter selection within plugins).
IndexIndex of current argument to evaluate.
ArgArgument to evaluate.
Returns
The index
std::numeric_limits<size_t>::max() if not found

◆ find_pos() [3/3]

template<typename ParameterTypeConstant , size_t Index, typename Arg , typename Arg2 , typename... Args>
constexpr size_t kamping::internal::find_pos ( )
constexpr

Returns position of first argument in Args with Trait trait.

Template Parameters
ParameterTypeConstantType and value of the parameter type (required for parameter selection within plugins).
IndexIndex of current argument to evaluate.
ArgArgument to evaluate.
Arg2The next argument.
ArgsAll remaining arguments.
Returns
Position of first argument with matched trait.
std::numeric_limits<size_t>::max() if not found

◆ has_parameter_type()

template<typename ParameterTypeConstant , typename... Args>
constexpr bool kamping::internal::has_parameter_type ( )
constexpr

Checks if parameter with requested parameter type exists.

Template Parameters
ParameterTypeConstantType and value of the parameter type to be searched(required for parameter selection within plugins).
ArgsAll parameter types to be searched.
Returns
true iff. Args contains a parameter of type ParameterTypeConstant::value.
Template Parameters
parameter_typeThe parameter type with which a parameter should be found.
ArgsAll parameter types to be searched.
Returns
true iff. Args contains a parameter of type parameter_type.

◆ has_parameter_type_in_tuple()

template<ParameterType parameter_type, typename Tuple >
constexpr bool kamping::internal::has_parameter_type_in_tuple ( )
constexpr

Checks if parameter with requested parameter type exists.

Template Parameters
parameter_typeThe parameter type with which a parameter should be found.
TupleIntended: std::tuple<Args...> containing all types to be searched.
Returns
true iff. Args contains a parameter of type parameter_type.

◆ has_parameter_type_in_tuple_impl()

template<ParameterType parameter_type, typename... Args>
constexpr bool kamping::internal::has_parameter_type_in_tuple_impl ( has_parameter_helper< std::tuple< Args... > > )
constexpr

Checks if parameter with requested parameter type exists. Wrapper using the functionality from kamping::internal::has_parameter_type() disassembling a std::tuple passed as parameter.

Template Parameters
parameter_typeThe parameter type with which a parameter should be found.
ArgsAll parameter types to be searched.
Returns
true iff. Args contains a parameter of type parameter_type.

◆ has_same_parameter_type()

template<typename T , typename U >
constexpr bool kamping::internal::has_same_parameter_type ( )
constexpr

Check whether two objects have the same parameter type.

Template Parameters
TFirst type.
USecond type.
Returns
True iff T's and U's underlying parameter type are equal.

◆ in_range()

template<class To , class From >
constexpr bool kamping::in_range ( From value)
constexprnoexcept

Checks if an integer value can be safely casted into an integer type To, that is, it lies in the range [min(To), max(To)].

This function works only for integer types which have at most std::numeric_limits<intmax_t>::digits (To and From are signed) or std::numeric_limits<intmax_t>::digits (else) bits. This function includes checks for these two assumptions using static_assert()s.

Template Parameters
ToType to be casted to.
FromType to be casted from, will be auto inferred.
Parameters
valueValue you want to cast.
Returns
true if value can be safely casted into type To, that is, value is in To's range.
false otherwise.

◆ select_parameter_type()

template<typename ParameterTypeConstant , typename... Args>
auto & kamping::internal::select_parameter_type ( Args &... args)

Returns parameter with requested parameter type.

"Specialization" for internal::ParameterType.

Template Parameters
ParameterTypeConstantType and value of the parameter type for which a parameter should be found(required for parameter selection within plugins).
ArgsAll parameter types to be searched for type ParameterTypeConstant::value.
Parameters
argsAll parameters from which a parameter with the correct type is selected.
Returns
The first parameter whose type has the requested parameter type.

◆ select_parameter_type_in_tuple() [1/2]

template<ParameterType parameter_type, typename... Args>
auto & kamping::internal::select_parameter_type_in_tuple ( std::tuple< Args... > & tuple)

Returns parameter with requested parameter type.

Template Parameters
parameter_typeThe parameter type with which a parameter should be found.
ArgsAll parameter types to be searched for type parameter_type.
Parameters
tuplestd::tuple with containing all parameters from which a parameter with the correct type is selected.
Returns
The first parameter whose type has the requested parameter type.

◆ select_parameter_type_in_tuple() [2/2]

template<ParameterType parameter_type, typename... Args>
auto const & kamping::internal::select_parameter_type_in_tuple ( std::tuple< Args... > const & tuple)

Returns parameter with requested parameter type.

Template Parameters
parameter_typeThe parameter type with which a parameter should be found.
ArgsAll parameter types to be searched for type parameter_type.
Parameters
tuplestd::tuple with containing all parameters from which a parameter with the correct type is selected.
Returns
The first parameter whose type has the requested parameter type.

◆ select_parameter_type_or_default()

template<typename ParameterTypeConstant , typename DefaultParameterType , typename... DefaultArguments, typename... Args>
decltype(auto) kamping::internal::select_parameter_type_or_default ( std::tuple< DefaultArguments... > default_arguments,
Args &... args )

Checks if parameter with requested parameter type exists, if not constructs a default value.

"Specialization" for internal::ParameterType.

Template Parameters
ParameterTypeConstantType and value of the parameter type for which a parameter should be found(required for parameter selection within plugins).
ArgsAll parameter types to be searched for parameter type ParameterTypeConstant::value.
DefaultParameterTypeThe type of the default parameter to be constructed.
DefaultArgumentsThe types of parameters passed to the constructor DefaultParameterType.
Parameters
default_argumentsTuple of the arguments passed to the constructor of DefaultParameterType.
argsAll parameters from which a parameter with the correct type is selected.
Returns
The first parameter whose type has the requested parameter type or the constructed default parameter if none is found.

◆ throwing_cast()

template<class To , class From >
constexpr To kamping::throwing_cast ( From value)
constexpr

Casts an integer value to the integer type To. If the value is outside To's range, throws an exception.

Alternatively, assertions can be used instead of exceptions by using asserting_cast().

This function works only for integer types which have at most std::numeric_limits<intmax_t>::digits (To and From are signed) or std::numeric_limits<intmax_t>::digits (else) bits. These two assumptions are checked by in_range() using static_assert()s.

Template Parameters
ToType to cast to.
FromType to cast from, will be auto inferred.
Parameters
valueValue you want to cast.
Returns
Casted value.

Variable Documentation

◆ parameter_type_v

template<typename Arg >
constexpr parameter_type_t<Arg> kamping::internal::parameter_type_v = ParameterTypeUnwrapping<Arg>::value
inlineconstexpr

Trait for the underlying value of the parameter type of.

Template Parameters
Arg.