Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_RawMPITraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TEUCHOS_RAW_MPI_TRAITS_H
43 #define TEUCHOS_RAW_MPI_TRAITS_H
44 
45 #include "Teuchos_ConfigDefs.hpp"
46 
50 
51 namespace Teuchos {
52 
81 template <class T> class TEUCHOS_DEPRECATED RawMPITraits {
82 public:
84  static int adjustCount(const int count) { bool *junk1; T *junk2 = &junk1; return 0; } // Should not compile!
86  static MPI_Datatype type() { bool *junk1; T *junk2 = &junk1; return MPI_DATATYPE_NULL; } // Should not compile!
88  static MPI_Op sumOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
90  static MPI_Op maxOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
92  static MPI_Op minOp() { bool *junk1; T *junk2 = &junk1; return MPI_OP_NULL; } // Should not compile!
93 };
94 
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96 template <> class TEUCHOS_DEPRECATED RawMPITraits<char> {
99 public:
101  static int adjustCount(const int count) { return count; }
103  static MPI_Datatype type() { return MPI_CHAR; }
105  static MPI_Op sumOp() { return MPI_SUM; }
107  static MPI_Op maxOp() { return MPI_MAX; }
109  static MPI_Op minOp() { return MPI_MIN; }
110 };
111 
114 template <> class TEUCHOS_DEPRECATED RawMPITraits<int> {
115 public:
117  static int adjustCount(const int count) { return count; }
119  static MPI_Datatype type() { return MPI_INT; }
121  static MPI_Op sumOp() { return MPI_SUM; }
123  static MPI_Op maxOp() { return MPI_MAX; }
125  static MPI_Op minOp() { return MPI_MIN; }
126 };
127 
130 template <> class TEUCHOS_DEPRECATED RawMPITraits<float> {
131 public:
133  static int adjustCount(const int count) { return count; }
135  static MPI_Datatype type() { return MPI_FLOAT; }
137  static MPI_Op sumOp() { return MPI_SUM; }
139  static MPI_Op maxOp() { return MPI_MAX; }
141  static MPI_Op minOp() { return MPI_MIN; }
142 };
143 
146 template <> class TEUCHOS_DEPRECATED RawMPITraits<double> {
147 public:
149  static int adjustCount(const int count) { return count; }
151  static MPI_Datatype type() { return MPI_DOUBLE; }
153  static MPI_Op sumOp() { return MPI_SUM; }
155  static MPI_Op maxOp() { return MPI_MAX; }
157  static MPI_Op minOp() { return MPI_MIN; }
158 };
159 
171 template <class T> class TEUCHOS_DEPRECATED RawMPITraits< std::complex<T> > {
172 public:
174  static int adjustCount(const int count) { return (2*count); }
176  static MPI_Datatype type() { return RawMPITraits<T>::type(); }
178  static MPI_Op sumOp() { return MPI_SUM; }
179 };
180 
181 #endif // DOXYGEN_SHOULD_SKIP_THIS
182 
183 } // namespace Teuchos
184 
185 #endif // TEUCHOS_RAW_MPI_TRAITS_H
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
static MPI_Op maxOp()
Return the MPI_Op object for a max reduction.
static MPI_Op sumOp()
Return the MPI_Op object for a sum reduction.
static MPI_Op minOp()
Return the MPI_Op object for a min reduction.
Templated traits class that allows a datatype to be used with MPI that MPI can directly handle...
static int adjustCount(const int count)
Return the adjusted std::cout of items.
static MPI_Datatype type()
Return the raw MPI data type of the template argument.