Teuchos - Trilinos Tools Package Version of the Day
Teuchos_RawMPITraits.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 // ////////////////////////////////////////////////////////////////////////
00030 // Teuchos_RawMPITraits.hpp
00031 
00032 #ifndef TEUCHOS_RAW_MPI_TRAITS_H
00033 #define TEUCHOS_RAW_MPI_TRAITS_H
00034 
00035 #include "Teuchos_ConfigDefs.hpp"
00036 
00041 namespace Teuchos {
00042 
00068 template <class T> class RawMPITraits {
00069 public:
00071   static int adjustCount(const int count) { bool *junk1; T *junk2 = &junk1; return 0; } // Should not compile!
00073   static MPI_Datatype type() { bool *junk1; T *junk2 = &junk1; return MPI_DATATYPE_NULL; } // Should not compile!
00075   static MPI_Op sumOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
00077   static MPI_Op maxOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
00079   static MPI_Op minOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
00080 };
00081 
00082 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00083 
00085 template <> class RawMPITraits<char> {
00086 public:
00088   static int adjustCount(const int count) { return count; }
00090   static MPI_Datatype type() { return MPI_CHAR; }
00092   static MPI_Op sumOp() { return MPI_SUM; }
00094   static MPI_Op maxOp() { return MPI_MAX; }
00096   static MPI_Op minOp() { return MPI_MIN; }
00097 };
00098 
00101 template <> class RawMPITraits<int> {
00102 public:
00104   static int adjustCount(const int count) { return count; }
00106   static MPI_Datatype type() { return MPI_INT; }
00108   static MPI_Op sumOp() { return MPI_SUM; }
00110   static MPI_Op maxOp() { return MPI_MAX; }
00112   static MPI_Op minOp() { return MPI_MIN; }
00113 };
00114 
00117 template <> class RawMPITraits<float> {
00118 public:
00120   static int adjustCount(const int count) { return count; }
00122   static MPI_Datatype type() { return MPI_FLOAT; }
00124   static MPI_Op sumOp() { return MPI_SUM; }
00126   static MPI_Op maxOp() { return MPI_MAX; }
00128   static MPI_Op minOp() { return MPI_MIN; }
00129 };
00130 
00133 template <> class RawMPITraits<double> {
00134 public:
00136   static int adjustCount(const int count) { return count; }
00138   static MPI_Datatype type() { return MPI_DOUBLE; }
00140   static MPI_Op sumOp() { return MPI_SUM; }
00142   static MPI_Op maxOp() { return MPI_MAX; }
00144   static MPI_Op minOp() { return MPI_MIN; }
00145 };
00146 
00155 template <class T> class RawMPITraits< std::complex<T> > {
00156 public:
00158   static int adjustCount(const int count) { return (2*count); }
00160   static MPI_Datatype type() { return RawMPITraits<T>::type(); }
00162   static MPI_Op sumOp() { return MPI_SUM; }
00163 };
00164 
00165 #endif // DOXYGEN_SHOULD_SKIP_THIS
00166 
00167 } // namespace Teuchos
00168 
00169 #endif // TEUCHOS_RAW_MPI_TRAITS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines