All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@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 // Special macro for exception testing
132 // XPETRA_TEST_FOR_EXCEPTION is only active if Xpetra is configured with Xpetra_ENABLE_DEBUG:BOOL=ON
133 // If you want an exception test both in the release and debug version of Xpetra you still can use directly
134 // TEUCHOS_TEST_FOR_EXCEPTION
135 #ifdef HAVE_XPETRA_DEBUG
136 #define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg) \
137  TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg);
138 #else
139 #define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
140 #endif
141 
142 #include <functional>
143 
144 // mem management
145 #include <Teuchos_ArrayView.hpp>
146 #include <Teuchos_ArrayRCP.hpp>
147 #include <Teuchos_Array.hpp>
148 #include <Teuchos_RCP.hpp>
149 // traits classes
150 #include <Teuchos_OrdinalTraits.hpp>
151 #include <Teuchos_ScalarTraits.hpp>
153 #include <Teuchos_NullIteratorTraits.hpp>
155 // comm
156 #include <Teuchos_Comm.hpp>
157 #include <Teuchos_CommHelpers.hpp>
158 // misc
159 #include <Teuchos_ParameterList.hpp>
160 
162 namespace Xpetra {
170  typedef size_t global_size_t;
171 
173  enum LocalGlobal {
176  };
177 
182  };
183 
185  enum ProfileType {
188  };
189 
194  };
195 
208  // enum CombineMode {
209  // ADD, /*!< Existing values will be summed with new values. */
210  // INSERT, /*!< Insert new values that don't currently exist. */
211  // REPLACE, /*!< Existing values will be replaced with new values. */
212  // };
213 
214  enum CombineMode {
215  ADD,
218  };
219 
220  // import Teuchos memory management classes into Xpetra
221  using Teuchos::ArrayRCP;
222  using Teuchos::ArrayView;
223  using Teuchos::Array;
225  using Teuchos::ScalarTraits;
226  using Teuchos::RCP;
227  using Teuchos::Comm;
228  using Teuchos::null;
229 
230  using Teuchos::outArg;
231  using Teuchos::tuple;
232  using Teuchos::arcp;
233  using Teuchos::rcp;
234  using Teuchos::rcpFromRef;
235  using Teuchos::av_reinterpret_cast;
236  using Teuchos::arcp_reinterpret_cast;
237 
238  using Teuchos::typeName;
239 
241  using Teuchos::parameterList;
242  using Teuchos::sublist;
243 
244  // Xpetra functor objects
245  // inspired by SGI-specific project2nd, project1st
246  template <class Arg1, class Arg2>
247  class firstArg : std::binary_function<Arg1,Arg2,Arg1> {
248  public:
249  typedef Arg1 first_argument_type;
250  typedef Arg2 second_argument_type;
251  typedef Arg1 result_type;
252  inline Arg1 operator()(const Arg1 &arg1, const Arg2 &arg2) { return arg1;}
253  };
254 
255  template <class Arg1, class Arg2>
256  class secondArg : std::binary_function<Arg1,Arg2,Arg2> {
257  public:
258  typedef Arg1 first_argument_type;
259  typedef Arg2 second_argument_type;
260  typedef Arg2 result_type;
261  inline Arg2 operator()(const Arg1 &arg1, const Arg2 &arg2) { return arg2;}
262  };
263 
264 } // end of Xpetra namespace
265 
266 
268 namespace XpetraExamples {
269 }
270 
271 #define XPETRA_ERR_CHECK(arg) { int r = arg; if (r < 0) { std::cout << "r = " << r << std::endl; assert(r>=0); }; }; // TODO: throw exceptions
272 
273 // This include file defines macros to avoid warnings under CUDA. See github issue #1133.
274 #include "Teuchos_CompilerCodeTweakMacros.hpp"
275 
276 #endif // XPETRA_CONFIGDEFS_HPP
Arg1 operator()(const Arg1 &arg1, const Arg2 &arg2)
Arg2 operator()(const Arg1 &arg1, const Arg2 &arg2)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
size_t global_size_t
Global size_t object.
CombineMode
Xpetra::Combine Mode enumerable type.
std::string typeName(const T &t)
Teuchos_Ordinal Array_size_type
Size type for Teuchos Array objects.