Xpetra_ConfigDefs.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_CONFIGDEFS_HPP
47 #define XPETRA_CONFIGDEFS_HPP
48 
49 #ifndef __cplusplus
50 #define __cplusplus
51 #endif // ifndef __cplusplus
52 
53 /* this section undefines all the things autotools defines for us that we wish it didn't. */
54 
55 #ifdef PACKAGE
56 #undef PACKAGE
57 #endif // ifdef PACKAGE
58 
59 #ifdef PACKAGE_NAME
60 #undef PACKAGE_NAME
61 #endif // ifdef PACKAGE_NAME
62 
63 #ifdef PACKAGE_BUGREPORT
64 #undef PACKAGE_BUGREPORT
65 #endif // ifdef PACKAGE_BUGREPORT
66 
67 #ifdef PACKAGE_STRING
68 #undef PACKAGE_STRING
69 #endif // ifdef PACKAGE_STRING
70 
71 #ifdef PACKAGE_TARNAME
72 #undef PACKAGE_TARNAME
73 #endif // ifdef PACKAGE_TARNAME
74 
75 #ifdef PACKAGE_VERSION
76 #undef PACKAGE_VERSION
77 #endif // ifdef PACKAGE_VERSION
78 
79 #ifdef VERSION
80 #undef VERSION
81 #endif // ifdef VERSION
82 
83 // end of undoing autoconf's work section
84 
85 #include <Xpetra_config.hpp>
86 #include <Teuchos_ConfigDefs.hpp>
87 #include <Kokkos_ConfigDefs.hpp>
88 
90 namespace Xpetra {
91  // Used in all Xpetra code that explicitly must a type (like a loop index)
92  // that is used with the Teuchos::Array[View,RCP] classes.
93 
95  typedef Teuchos_Ordinal Array_size_type;
96 }
97 
98 // these make some of the macros in Xpetra_Util.hpp much easier to describe
99 #ifdef HAVE_XPETRA_THROW_EFFICIENCY_WARNINGS
100 #define XPETRA_THROWS_EFFICIENCY_WARNINGS 1
101 #else
102 #define XPETRA_THROWS_EFFICIENCY_WARNINGS 0
103 #endif
104 
105 #ifdef HAVE_XPETRA_PRINT_EFFICIENCY_WARNINGS
106 #define XPETRA_PRINTS_EFFICIENCY_WARNINGS 1
107 #else
108 #define XPETRA_PRINTS_EFFICIENCY_WARNINGS 0
109 #endif
110 
111 #ifdef HAVE_XPETRA_THROW_ABUSE_WARNINGS
112 #define XPETRA_THROWS_ABUSE_WARNINGS 1
113 #else
114 #define XPETRA_THROWS_ABUSE_WARNINGS 0
115 #endif
116 
117 #ifdef HAVE_XPETRA_PRINT_ABUSE_WARNINGS
118 #define XPETRA_PRINTS_ABUSE_WARNINGS 1
119 #else
120 #define XPETRA_PRINTS_ABUSE_WARNINGS 0
121 #endif
122 
123 #ifdef HAVE_XPETRA_PROFILING
124 #include <string>
125 #include <Teuchos_TimeMonitor.hpp>
126 #define XPETRA_MONITOR(funcName) Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("Xpetra: ") + funcName));
127 #else
128 #define XPETRA_MONITOR(funcName)
129 #endif
130 
131 #include <functional>
132 
133 #ifndef __CUDACC__
134 // mem management
135 #include <Teuchos_ArrayView.hpp>
136 #include <Teuchos_ArrayRCP.hpp>
137 #include <Teuchos_Array.hpp>
138 #include <Teuchos_RCP.hpp>
139 // traits classes
140 #include <Teuchos_OrdinalTraits.hpp>
141 #include <Teuchos_ScalarTraits.hpp>
142 #include <Teuchos_TypeNameTraits.hpp>
143 #include <Teuchos_NullIteratorTraits.hpp>
144 #include <Teuchos_SerializationTraits.hpp>
145 // comm
146 #include <Teuchos_Comm.hpp>
147 #include <Teuchos_CommHelpers.hpp>
148 // misc
149 #include <Teuchos_ParameterList.hpp>
150 #endif
151 
153 namespace Xpetra {
161  typedef size_t global_size_t;
162 
164  enum LocalGlobal {
167  };
168 
173  };
174 
176  enum ProfileType {
179  };
180 
185  };
186 
199  // enum CombineMode {
200  // ADD, /*!< Existing values will be summed with new values. */
201  // INSERT, /*!< Insert new values that don't currently exist. */
202  // REPLACE, /*!< Existing values will be replaced with new values. */
203  // };
204 
205  enum CombineMode {
206  ADD,
209  };
210 
211  // import Teuchos memory management classes into Xpetra
212 #ifndef __CUDACC__
213  using Teuchos::ArrayRCP;
214  using Teuchos::ArrayView;
215  using Teuchos::Array;
216  using Teuchos::OrdinalTraits;
217  using Teuchos::ScalarTraits;
218  using Teuchos::RCP;
219  using Teuchos::Comm;
220  using Teuchos::null;
221 
222  using Teuchos::outArg;
223  using Teuchos::tuple;
224  using Teuchos::arcp;
225  using Teuchos::rcp;
226  using Teuchos::rcpFromRef;
227  using Teuchos::av_reinterpret_cast;
228  using Teuchos::arcp_reinterpret_cast;
229 
230  using Teuchos::typeName;
231 
232  using Teuchos::ParameterList;
233  using Teuchos::parameterList;
234  using Teuchos::sublist;
235 #endif
236 
237  // Xpetra functor objects
238  // inspired by SGI-specific project2nd, project1st
239  template <class Arg1, class Arg2>
240  class firstArg : std::binary_function<Arg1,Arg2,Arg1> {
241  public:
242  typedef Arg1 first_argument_type;
243  typedef Arg2 second_argument_type;
244  typedef Arg1 result_type;
245  inline Arg1 operator()(const Arg1 &arg1, const Arg2 &arg2) { return arg1;}
246  };
247 
248  template <class Arg1, class Arg2>
249  class secondArg : std::binary_function<Arg1,Arg2,Arg2> {
250  public:
251  typedef Arg1 first_argument_type;
252  typedef Arg2 second_argument_type;
253  typedef Arg2 result_type;
254  inline Arg2 operator()(const Arg1 &arg1, const Arg2 &arg2) { return arg2;}
255  };
256 
257 } // end of Xpetra namespace
258 
259 
261 namespace XpetraExamples {
262 }
263 
264 #define XPETRA_ERR_CHECK(arg) { int r = arg; if (r < 0) { std::cout << "r = " << r << std::endl; assert(r>=0); }; }; // TODO: throw exceptions
265 
266 #endif // XPETRA_CONFIGDEFS_HPP
Arg1 operator()(const Arg1 &arg1, const Arg2 &arg2)
Namespace for Xpetra example classes and methods.
Arg2 operator()(const Arg1 &arg1, const Arg2 &arg2)
Xpetra namespace
size_t global_size_t
Global size_t object.
CombineMode
Xpetra::Combine Mode enumerable type.
Teuchos_Ordinal Array_size_type
Size type for Teuchos Array objects.