BioCMAMC-ST
mpi_types.hpp
1#ifndef __MPI_TYPES_HPP__
2#define __MPI_TYPES_HPP__
3
4#include <mpi_w/message_t.hpp>
5#include <mpi.h>
6#include <type_traits>
7
8namespace WrapMPI
9{
10
11 template <typename T> constexpr MPI_Datatype get_type() noexcept
12 {
13 MPI_Datatype datatype{};
14
15 using _type = std::remove_const_t<std::remove_reference_t<T>>;
16
17 if constexpr (std::is_same_v<_type, size_t>)
18 {
19 datatype = MPI_UNSIGNED_LONG;
20 }
21 else if constexpr (std::is_same_v<_type, double>)
22 {
23 datatype = MPI_DOUBLE;
24 }
25 else if constexpr (std::is_same_v<_type, int>)
26 {
27 datatype = MPI_INT;
28 }
29 else if constexpr (std::is_same_v<_type, bool>)
30 {
31 datatype = MPI_CXX_BOOL;
32 }
33 else if constexpr (std::is_same_v<_type, char> ||
34 std::is_same_v<_type, WrapMPI::SIGNALS>)
35 {
36 datatype = MPI_BYTE;
37 }
38 else
39 {
40 []<bool flag = false>()
41 {
42 static_assert(flag, "no match");
43 }
44 ();
45 }
46
47 return datatype;
48 }
49} // namespace WrapMPI
50
51#endif //__MPI_TYPES_HPP__
Namespace to correclty wrap MPI C API for modern C++.
Definition impl_async.hpp:19
constexpr MPI_Datatype get_type() noexcept
Definition mpi_types.hpp:11