PlayaMPITraits.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // @HEADER
00003 
00004 #ifndef PLAYA_MPITRAITS_H
00005 #define PLAYA_MPITRAITS_H
00006 
00007 /*! \file PlayaMPITraits.hpp
00008  * \brief Declaration of a templated traits class for binding MPI types to
00009  * C++ types. This is for use with the MPIComm class and is supposed to compile
00010  * rgeardless of whether MPI has been enabled. If you need to convert directly to 
00011  * MPI types (e.g., MPI_INT), please refer to Teuchos_MPIRawTraits.hpp.
00012 */
00013 
00014 #include "PlayaMPIComm.hpp"
00015 
00016 namespace Playa
00017 {
00018   using std::string;
00019 
00020   /** \ingroup MPI 
00021    * \brief Templated traits class that binds MPI types to C++ types
00022    * \note Template specializations exist for datatypes: <tt>char</tt>,
00023     <tt>int</tt>, <tt>float</tt>, and <tt>double</tt>.
00024    */
00025   template <class T> class MPITraits
00026     {
00027     public:
00028       /** \brief Return the MPI data type of the template argument */
00029       static MPIDataType type();
00030     };
00031 
00032   /** \ingroup MPI 
00033    */
00034   template <> class MPITraits<int>
00035     {
00036     public:
00037       /** return the MPI data type of the template argument */
00038       static MPIDataType type() {return MPIDataType::intType();}
00039     };
00040   
00041   /** \ingroup MPI 
00042    */
00043   template <> class MPITraits<float>
00044     {
00045     public:
00046       /** return the MPI data type of the template argument */
00047       static MPIDataType type() {return MPIDataType::floatType();}
00048     };
00049   
00050   /** \ingroup MPI 
00051    */
00052   template <> class MPITraits<double>
00053     {
00054     public:
00055       /** return the MPI data type of the template argument */
00056       static MPIDataType type() {return MPIDataType::doubleType();}
00057     };
00058   
00059   /** \ingroup MPI 
00060    */
00061   template <> class MPITraits<char>
00062     {
00063     public:
00064       /** return the MPI data type of the template argument */
00065       static MPIDataType type() {return MPIDataType::charType();}
00066     };
00067 
00068   
00069 } // namespace Playa
00070 
00071 #endif

Site Contact