KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
MPI Utility

Quality of life features for MPI like automatic type conversion (from C++ to MPI) More...

Namespaces

namespace  kamping::internal
 Internal namespace marking the code that is not user-facing.
 

Classes

struct  kamping::builtin_type< T >
 Checks if the type T is a builtin MPI type. More...
 
struct  kamping::builtin_type< char >
 Specialization of builtin_type for char. More...
 
struct  kamping::builtin_type< signed char >
 Specialization of builtin_type for signed char. More...
 
struct  kamping::builtin_type< unsigned char >
 Specialization of builtin_type for unsigned char. More...
 
struct  kamping::builtin_type< wchar_t >
 Specialization of builtin_type for wchar_t. More...
 
struct  kamping::builtin_type< short int >
 Specialization of builtin_type for short int. More...
 
struct  kamping::builtin_type< unsigned short int >
 Specialization of builtin_type for unsigned short int. More...
 
struct  kamping::builtin_type< int >
 Specialization of builtin_type for int. More...
 
struct  kamping::builtin_type< unsigned int >
 Specialization of builtin_type for unsigned int. More...
 
struct  kamping::builtin_type< long int >
 Specialization of builtin_type for long int. More...
 
struct  kamping::builtin_type< unsigned long int >
 Specialization of builtin_type for unsigned long int. More...
 
struct  kamping::builtin_type< long long int >
 Specialization of builtin_type for long long int. More...
 
struct  kamping::builtin_type< unsigned long long int >
 Specialization of builtin_type for unsigned long long int. More...
 
struct  kamping::builtin_type< float >
 Specialization of builtin_type for float. More...
 
struct  kamping::builtin_type< double >
 Specialization of builtin_type for double. More...
 
struct  kamping::builtin_type< long double >
 Specialization of builtin_type for long double. More...
 
struct  kamping::builtin_type< bool >
 Specialization of builtin_type for bool. More...
 
struct  kamping::builtin_type< kabool >
 Specialization of builtin_type for kabool. More...
 
struct  kamping::builtin_type< std::complex< float > >
 Specialization of builtin_type for std::complex<float>. More...
 
struct  kamping::builtin_type< std::complex< double > >
 Specialization of builtin_type for std::complex<double>. More...
 
struct  kamping::builtin_type< std::complex< long double > >
 Specialization of builtin_type for std::complex<long double>. More...
 
struct  kamping::AllocNewT< Container >
 Buffer allocation tag used for indicating that a buffer should be allocated by KaMPIng. More...
 
struct  kamping::AllocNewUsingT< Container >
 Buffer allocation tag used for indicating that a buffer should be allocated by KaMPIng. More...
 
struct  kamping::AllocContainerOfT< T >
 Buffer allocation tag used for indicating that a buffer of type T should be allocated by KaMPIng. More...
 
struct  kamping::contiguous_type< T, N >
 Constructs an contiguous type of size N from type T using MPI_Type_contiguous. More...
 
struct  kamping::byte_serialized< T >
 Constructs a type that is serialized as a sequence of sizeof(T) bytes using MPI_BYTE. Note that you must ensure that this conversion is valid. More...
 
struct  kamping::struct_type< T >
 Constructs a MPI_Datatype for a struct-like type. More...
 
struct  kamping::no_matching_type
 Type tag for indicating that no static type definition exists for a type. More...
 
struct  kamping::mpi_type_traits< T, Enable >
 The type trait that maps a C++ type T to a type trait that can be used to construct an MPI_Datatype. More...
 
struct  kamping::mpi_type_traits< T, std::enable_if_t<!std::is_same_v< decltype(type_dispatcher< T >()), no_matching_type > > >
 The type trait that maps a C++ type T to a type trait that can be used to construct an MPI_Datatype. More...
 
struct  kamping::has_static_type< typename, Enable >
 Check if the type has a static type definition, i.e. mpi_type_traits is defined. More...
 
struct  kamping::has_static_type< T, std::void_t< decltype(mpi_type_traits< T >::data_type())> >
 Check if the type has a static type definition, i.e. mpi_type_traits is defined. More...
 
class  kamping::ScopedDatatype
 A scoped MPI_Datatype that commits the type on construction and frees it on destruction. This is useful for RAII-style management of MPI_Datatype objects. More...
 

Enumerations

enum class  kamping::TypeCategory {
  integer , floating , complex , logical ,
  byte , character , struct_like , contiguous
}
 the members specify which group the datatype belongs to according to the type groups specified in Section 6.9.2 of the MPI 4.0 standard.
 
enum class  kamping::BufferResizePolicy { BufferResizePolicy::no_resize , BufferResizePolicy::grow_only , BufferResizePolicy::resize_to_fit }
 Enum to specify in which cases a buffer is resized. More...
 

Functions

constexpr bool kamping::category_has_to_be_committed (TypeCategory category)
 Checks if a type of the given category has to commited before usage in MPI calls.
 
template<typename T >
auto kamping::type_dispatcher ()
 The type dispatcher that maps a C++ type T to a type trait that can be used to construct an MPI_Datatype.
 
template<typename T >
MPI_Datatype kamping::construct_and_commit_type ()
 Register a new MPI_Datatype for T with the MPI environment. It will be freed when the environment is finalized.
 
template<typename T >
MPI_Datatype kamping::mpi_datatype () KAMPING_NOEXCEPT
 Translate template parameter T to an MPI_Datatype. If no corresponding MPI_Datatype exists, we will create new continuous type. Based on https://gist.github.com/2b-t/50d85115db8b12ed263f8231abf07fa2 To check if type T maps to a builtin MPI_Datatype at compile-time, use mpi_type_traits.
 
template<typename StatusObject >
auto kamping::status_out (StatusObject &&status)
 Outputs the return status of the operation to the provided status object. The status object may be passed as lvalue-reference or rvalue.
 
auto kamping::status_out ()
 Constructs a status object internally, which may then be retrieved from kamping::MPIResult returned by the operation.
 
auto kamping::status (internal::ignore_t< void >)
 pass MPI_STATUS_IGNORE to the underlying MPI call.
 
auto kamping::statuses (internal::ignore_t< void >)
 pass MPI_STATUSES_IGNORE to the underlying MPI call.
 
template<BufferResizePolicy resize_policy = BufferResizePolicy::no_resize, typename Container >
auto kamping::statuses_out (Container &&container)
 Pass a Container of MPI_Status to the underlying MPI call in which the statuses are stored upon completion. The container may be resized according the provided resize_policy.
 
template<typename Container >
auto kamping::statuses_out (AllocNewT< Container >)
 Internally construct a new Container of MPI_Status, which will hold the returned statuses.
 
template<template< typename... > typename Container>
auto kamping::statuses_out (AllocNewUsingT< Container >)
 Internally construct a new Container<MPI_Status> which will hold the returned statuses.
 
auto kamping::statuses_out ()
 Internally construct a container of MPI_Status, which will hold the returned statuses. The container's type is usually determined by operations called on a RequestPool, and defaults to RequestPool::default_container_type.
 
static MPI_Datatype kamping::contiguous_type< T, N >::data_type ()
 The MPI_Datatype corresponding to the type.
 
static MPI_Datatype kamping::struct_type< T >::data_type ()
 The MPI_Datatype corresponding to the type.
 

Variables

template<typename T >
constexpr bool kamping::is_builtin_type_v = builtin_type<T>::value
 Helper variable template for builtin_type.
 
template<typename Container >
static constexpr auto kamping::alloc_new = AllocNewT<Container>{}
 Convenience wrapper for creating library allocated containers. See AllocNewT for details.
 
template<typename T >
static constexpr bool kamping::is_alloc_new_v = false
 Helper to decide if an allocation tag is an AllocNewT.
 
template<typename T >
static constexpr bool kamping::is_alloc_new_v< AllocNewT< T > > = true
 Helper to decide if an allocation tag is an AllocNewT.
 
template<template< typename... > typename Container>
static constexpr auto kamping::alloc_new_using = AllocNewUsingT<Container>{}
 Convenience wrapper for creating library allocated containers. See AllocNewUsingT for details.
 
template<typename T >
static constexpr bool kamping::is_alloc_new_using_v = false
 Helper to decide if an allocation tag is an AllocNewUsingT.
 
template<template< typename... > typename Container>
static constexpr bool kamping::is_alloc_new_using_v< AllocNewUsingT< Container > > = true
 Helper to decide if an allocation tag is an AllocNewUsingT.
 
template<typename T >
static constexpr auto kamping::alloc_container_of = AllocContainerOfT<T>{}
 Convenience wrapper for creating library allocated containers. See AllocContainerOfT for details.
 
template<typename T >
static constexpr bool kamping::is_alloc_container_of_v = false
 Helper to decide if an allocation tag is an AllocContainerOfT.
 
template<typename T >
static constexpr bool kamping::is_alloc_container_of_v< AllocContainerOfT< T > > = true
 Helper to decide if an allocation tag is an AllocContainerOfT.
 
constexpr BufferResizePolicy kamping::no_resize
 
constexpr BufferResizePolicy kamping::grow_only
 
constexpr BufferResizePolicy kamping::resize_to_fit
 
template<typename T >
static constexpr bool kamping::has_static_type_v = has_static_type<T>::value
 Check if the type has a static type definition, i.e. has a corresponding MPI_Datatype defined following the rules from type_dispatcher.
 

Detailed Description

Quality of life features for MPI like automatic type conversion (from C++ to MPI)

Enumeration Type Documentation

◆ BufferResizePolicy

Enum to specify in which cases a buffer is resized.

Enumerator
no_resize 

Policy indicating that the underlying buffer shall never be resized.

grow_only 

Policy indicating that the underlying buffer shall only be resized if the current size of the buffer is too small.

resize_to_fit 

Policy indicating that the underlying buffer is resized such that it has exactly the required size.

Function Documentation

◆ construct_and_commit_type()

template<typename T >
MPI_Datatype kamping::construct_and_commit_type ( )
inline

Register a new MPI_Datatype for T with the MPI environment. It will be freed when the environment is finalized.

The MPI_Datatype is created using mpi_type_traits<T>::data_type() and committed using MPI_Type_commit.

Template Parameters
TThe type to register.

◆ mpi_datatype()

template<typename T >
MPI_Datatype kamping::mpi_datatype ( )

Translate template parameter T to an MPI_Datatype. If no corresponding MPI_Datatype exists, we will create new continuous type. Based on https://gist.github.com/2b-t/50d85115db8b12ed263f8231abf07fa2 To check if type T maps to a builtin MPI_Datatype at compile-time, use mpi_type_traits.

Template Parameters
TThe type to translate into an MPI_Datatype.
Returns
The tag identifying the corresponding MPI_Datatype or the newly created type.
See also
mpi_custom_continuous_type()

Translate type T to an MPI_Datatype using the type defined via mpi_type_traits.

If the type has not been registered with MPI yet, it will be created and committed and automatically registered with the MPI environment, such that it will be freed when the environment is finalized.

Template Parameters
TThe type to translate into an MPI_Datatype.

◆ status_out()

template<typename StatusObject >
auto kamping::status_out ( StatusObject && status)
inline

Outputs the return status of the operation to the provided status object. The status object may be passed as lvalue-reference or rvalue.

Template Parameters
StatusObjecttype of the status object, may either be MPI_Status or kamping::Status
Parameters
statusThe status object.

◆ statuses_out()

template<BufferResizePolicy resize_policy = BufferResizePolicy::no_resize, typename Container >
auto kamping::statuses_out ( Container && container)
inline

Pass a Container of MPI_Status to the underlying MPI call in which the statuses are stored upon completion. The container may be resized according the provided resize_policy.

Template Parameters
resize_policyPolicy specifying whether (and if so, how) the underlying buffer shall be resized. The default
Containerthe container type to use for the statuses.

◆ type_dispatcher()

template<typename T >
auto kamping::type_dispatcher ( )

The type dispatcher that maps a C++ type T to a type trait that can be used to construct an MPI_Datatype.

The mapping is as follows:

  • C++ types directly supported by MPI are mapped to the corresponding MPI_Datatype.
  • Enums are mapped to the underlying type.
  • C-style arrays and std::array are mapped to contiguous types of the underlying type.
  • All other trivially copyable types are mapped to a contiguous type consisting of sizeof(T) bytes.
  • All other types are not supported directly and require a specialization of mpi_type_traits. In this case, the trait no_matching_type is returned.
Returns
The corresponding type trait for the type T.

Variable Documentation

◆ grow_only

constexpr BufferResizePolicy kamping::grow_only
constexpr
Initial value:
=
BufferResizePolicy::grow_only

Constant storing a BufferResizePolicy::grow_only enum member. It can be used to declare a buffer's resize policy in more concise manner.

◆ no_resize

constexpr BufferResizePolicy kamping::no_resize
constexpr
Initial value:
=
BufferResizePolicy::no_resize

Constant storing a BufferResizePolicy::no_resize enum member. It can be used to declare a buffer's resize policy in more concise manner.

◆ resize_to_fit

constexpr BufferResizePolicy kamping::resize_to_fit
constexpr
Initial value:
=
BufferResizePolicy::resize_to_fit

Constant storing a BufferResizePolicy::resize_to_fit enum member. It can be used to declare a buffer's resize policy in more concise manner.