|
KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
|
A standalone C++17 header-only library that maps C++ types to MPI datatypes.
kamping-types is extracted from KaMPIng and can be consumed independently — without the KaMPIng communicator layer.
Then include what you need:
| Option | Default | Description |
|---|---|---|
KAMPING_TYPES_BUILD_EXAMPLES | ON (top-level), OFF (subdirectory) | Build the example program |
KAMPING_TYPES_ENABLE_REFLECTION | OFF | Enable struct reflection via Boost.PFR for arbitrary struct types |
| Header | Contents |
|---|---|
kamping/types/builtin_types.hpp | TypeCategory, builtin_type<T>, is_builtin_type_v<T> |
kamping/types/mpi_type_traits.hpp | type_dispatcher<T>(), mpi_type_traits<T>, has_static_type_v<T> |
kamping/types/contiguous_type.hpp | contiguous_type<T,N>, byte_serialized<T> |
kamping/types/struct_type.hpp | kamping_tag, struct_type<T> |
kamping/types/scoped_datatype.hpp | ScopedDatatype — RAII commit/free wrapper |
kamping/types/kabool.hpp | kabool — bool wrapper safe for MPI containers |
type_dispatcher<T>() maps C++ types to type traits according to these rules:
| C++ type | Result |
|---|---|
MPI builtin (int, double, std::complex<float>, …) | builtin_type<T> — named MPI type, no commit |
| Enum | dispatches to underlying type |
T[N], std::array<T,N> | contiguous_type<T,N> — must be committed |
| Everything else | no_matching_type — specialize mpi_type_traits<T> |
Use has_static_type_v<T> to check at compile time whether a type is handled.
Specialize mpi_type_traits<T> to support your own types:
When linking against kamping::kamping instead of kamping::types, you additionally get:
type_dispatcher<T>() — also maps trivially-copyable types to byte_serialized<T>mpi_datatype<T>() — returns a committed, environment-managed MPI_Datatypeinclude/kamping/types/utility.hpp — mpi_type_traits for std::pairinclude/kamping/types/tuple.hpp — mpi_type_traits for std::tuple