OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
DataTypes.h
Go to the documentation of this file.
1 #ifndef IPPL_MPI_DATATYPES_H
2 #define IPPL_MPI_DATATYPES_H
3 
4 /*
5  * Implementation like Boost.MPI
6  */
7 
8 #include <mpi.h>
9 
10 template<typename> struct is_ippl_mpi_datatype: std::false_type {};
11 
12 template <typename T> MPI_Datatype get_mpi_datatype(const T& x)
13 {
14  static_assert(is_ippl_mpi_datatype<T>::value,
15  "type isn't an MPI type");
16  return get_mpi_datatype(T());
17 }
18 
19 
20 #define IPPL_MPI_DATATYPE(CppType, MPIType) \
21 template<> \
22 inline MPI_Datatype \
23 get_mpi_datatype< CppType >(const CppType&) { return MPIType; } \
24  \
25 template<> \
26 struct is_ippl_mpi_datatype<CppType>: std::true_type {};
27 
28 
29 IPPL_MPI_DATATYPE(char, MPI_CHAR);
30 
31 IPPL_MPI_DATATYPE(short, MPI_SHORT);
32 
33 IPPL_MPI_DATATYPE(int, MPI_INT);
34 
35 IPPL_MPI_DATATYPE(long, MPI_LONG);
36 
37 IPPL_MPI_DATATYPE(long long, MPI_LONG_LONG);
38 
39 IPPL_MPI_DATATYPE(unsigned char, MPI_UNSIGNED_CHAR);
40 
41 IPPL_MPI_DATATYPE(unsigned short, MPI_UNSIGNED_SHORT);
42 
43 IPPL_MPI_DATATYPE(unsigned int, MPI_UNSIGNED);
44 
45 IPPL_MPI_DATATYPE(unsigned long, MPI_UNSIGNED_LONG);
46 
47 IPPL_MPI_DATATYPE(unsigned long long, MPI_UNSIGNED_LONG_LONG);
48 
49 IPPL_MPI_DATATYPE(float, MPI_FLOAT);
50 
51 IPPL_MPI_DATATYPE(double, MPI_DOUBLE);
52 
53 IPPL_MPI_DATATYPE(long double, MPI_LONG_DOUBLE);
54 
55 IPPL_MPI_DATATYPE(bool, MPI_CXX_BOOL);
56 
57 #endif
Definition: rbendmap.h:8
MPI_Datatype get_mpi_datatype(const T &x)
Definition: DataTypes.h:12
#define IPPL_MPI_DATATYPE(CppType, MPIType)
Definition: DataTypes.h:20