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

Utility that maps C++ types to types that can be understood by MPI. More...

#include <type_traits>
#include <kassert/kassert.hpp>
#include <mpi.h>
#include "kamping/builtin_types.hpp"
#include "kamping/environment.hpp"
#include "kamping/noexcept.hpp"
Include dependency graph for mpi_datatype.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kamping::kamping_tag
 Tag used for indicating that a struct is reflectable. More...
 
struct  kamping::internal::is_std_pair< T >
 Helper to check if a type is a std::pair. More...
 
struct  kamping::internal::is_std_pair< std::pair< T1, T2 > >
 Helper to check if a type is a std::pair. More...
 
struct  kamping::internal::is_std_tuple< T >
 Helper to check if a type is a std::tuple. More...
 
struct  kamping::internal::is_std_tuple< std::tuple< Ts... > >
 Helper to check if a type is a std::tuple. More...
 
struct  kamping::internal::is_std_array< A >
 Helper to check if a type is a std::array. More...
 
struct  kamping::internal::is_std_array< std::array< T, N > >
 Helper to check if a type is a std::array. 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...
 

Namespaces

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

Functions

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 T , typename F , size_t... Is>
void kamping::internal::for_each_tuple_field (T &&t, F &&f, std::index_sequence< Is... >)
 Applies functor f to each field of the tuple with an index in index sequence Is.
 
template<typename T , typename F >
void kamping::internal::for_each_tuple_field (T &t, F &&f)
 Applies functor f to each field of the tuple t.
 
template<typename T , typename F >
void kamping::internal::for_each_field (T &t, F &&f)
 Applies functor f to each field of the tuple-like type t. This works for std::pair and std::tuple. If KaMPIng's reflection support is enabled, this also works with types that are reflectable with pfr.
 

Variables

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.
 
template<typename T >
constexpr size_t kamping::internal::tuple_size
 The number of elements in a tuple-like type. This works for std::pair and std::tuple. If KaMPIng's reflection support is enabled, this also works with types that are reflectable with pfr.
 

Detailed Description

Utility that maps C++ types to types that can be understood by MPI.