TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
MPI datatypes and operations

Detailed Description

Specify supported MPI datatypes and provide tools to simplify the creation of user-defined MPI types and operations.

The following functionality is provided:

See Example 3: Custom type and operator for a detailed example.

Classes

struct  mpi::mpi_type< T >
 Map C++ datatypes to the corresponding MPI datatypes. More...
 
struct  mpi::mpi_type< bool >
 Specialization of mpi_type for bool. More...
 
struct  mpi::mpi_type< char >
 Specialization of mpi_type for char. More...
 
struct  mpi::mpi_type< const T >
 Specialization of mpi::mpi_type for const types. More...
 
struct  mpi::mpi_type< double >
 Specialization of mpi_type for double. More...
 
struct  mpi::mpi_type< float >
 Specialization of mpi_type for float. More...
 
struct  mpi::mpi_type< int >
 Specialization of mpi_type for int. More...
 
struct  mpi::mpi_type< long >
 Specialization of mpi_type for long. More...
 
struct  mpi::mpi_type< long long >
 Specialization of mpi_type for long long. More...
 
struct  mpi::mpi_type< std::complex< double > >
 Specialization of mpi_type for std::complex<double>. More...
 
struct  mpi::mpi_type< std::tuple< T... > >
 Specialization of mpi::mpi_type for std::tuple. More...
 
struct  mpi::mpi_type< unsigned int >
 Specialization of mpi_type for unsigned int. More...
 
struct  mpi::mpi_type< unsigned long >
 Specialization of mpi_type for unsigned long. More...
 
struct  mpi::mpi_type< unsigned long long >
 Specialization of mpi_type for unsigned long long. More...
 
struct  mpi::mpi_type_from_tie< T >
 Create an MPI_Datatype from some struct. More...
 

Functions

template<typename... Ts>
MPI_Datatype mpi::get_mpi_type (std::tuple< Ts... > tup)
 Create a new MPI_Datatype from a tuple.
 
template<typename T >
MPI_Op mpi::map_add ()
 Create a new MPI_Op for a generic addition by calling MPI_Op_create.
 
template<typename T , T(*)(T const &, T const &) F>
MPI_Op mpi::map_C_function ()
 Create a new MPI_Op from a given binary function by calling MPI_Op_create.
 

Variables

template<typename T , typename = void>
constexpr bool mpi::has_mpi_type = false
 Type trait to check if a type T has a corresponding MPI datatype, i.e. if mpi::mpi_type has been specialized.
 

Function Documentation

◆ get_mpi_type()

template<typename... Ts>
MPI_Datatype mpi::get_mpi_type ( std::tuple< Ts... > tup)
nodiscard

#include <mpi/datatypes.hpp>

Create a new MPI_Datatype from a tuple.

The tuple element types must have corresponding MPI datatypes, i.e. they must have mpi::mpi_type specializtions. It uses MPI_Type_create_struct to create a new datatype consisting of the tuple element types.

It throws an exception in case a call to the MPI C library fails.

Template Parameters
TsTuple element types.
Parameters
tupTuple object.
Returns
MPI_Datatype consisting of the types of the tuple elements.

Definition at line 109 of file datatypes.hpp.

◆ map_add()

template<typename T >
MPI_Op mpi::map_add ( )

#include <mpi/operators.hpp>

Create a new MPI_Op for a generic addition by calling MPI_Op_create.

The type is required to have an overloaded operator+(const T& lhs, const T& rhs) -> T.

Template Parameters
TType used for the addition.
Returns
MPI_Op for the generic addition of the given type.

Definition at line 70 of file operators.hpp.

◆ map_C_function()

template<typename T , T(*)(T const &, T const &) F>
MPI_Op mpi::map_C_function ( )

#include <mpi/operators.hpp>

Create a new MPI_Op from a given binary function by calling MPI_Op_create.

The binary function must have the following signature (T const&, T const&) -> T.

It throws an exception in case a call to the MPI C library fails.

Template Parameters
TType on which the binary function operates.
FBinary function pointer to be mapped.
Returns
MPI_Op created from the binary function.

Definition at line 46 of file operators.hpp.

Variable Documentation

◆ has_mpi_type

template<typename T , typename = void>
bool mpi::has_mpi_type = false
constexpr

#include <mpi/datatypes.hpp>

Type trait to check if a type T has a corresponding MPI datatype, i.e. if mpi::mpi_type has been specialized.

Template Parameters
TType to be checked.

Definition at line 89 of file datatypes.hpp.