#ifndef HPC_MPI_FUNDAMENTAL_HPP #define HPC_MPI_FUNDAMENTAL_HPP 1 #include #include namespace hpc { namespace mpi { template struct fundamental_type { static constexpr bool defined = false; }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_CHAR; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_SIGNED_CHAR; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_UNSIGNED_CHAR; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_SHORT; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_UNSIGNED_SHORT; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_INT; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_UNSIGNED; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_LONG; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_UNSIGNED_LONG; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_LONG_LONG; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_UNSIGNED_LONG_LONG; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_FLOAT; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_DOUBLE; } }; template<> struct fundamental_type { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_LONG_DOUBLE; } }; /* the following types are not supported by older MPI implementations; hence we make it dependent on the corresponding preprocessor symbols */ #ifdef MPI_CXX_FLOAT_COMPLEX template<> struct fundamental_type> { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_CXX_FLOAT_COMPLEX; } }; #endif #ifdef MPI_CXX_DOUBLE_COMPLEX template<> struct fundamental_type> { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_CXX_DOUBLE_COMPLEX; } }; #endif #ifdef MPI_CXX_LONG_DOUBLE_COMPLEX template<> struct fundamental_type> { static constexpr bool defined = true; constexpr MPI_Datatype get() const { return MPI_CXX_LONG_DOUBLE_COMPLEX; } }; #endif template typename std::enable_if< fundamental_type::defined, MPI_Datatype>::type get_type(const T& value) { return fundamental_type().get(); } } } // namespaces mpi, hpc #endif