49 #ifndef __INTREPID2_UTILS_HPP__
50 #define __INTREPID2_UTILS_HPP__
52 #include "Intrepid2_ConfigDefs.hpp"
55 #include "Kokkos_Core.hpp"
56 #include "Kokkos_Macros.hpp"
60 #if defined(KOKKOS_OPT_RANGE_AGGRESSIVE_VECTORIZATION) && defined(KOKKOS_ENABLE_PRAGMA_IVDEP) && !defined(__CUDA_ARCH__)
61 #define INTREPID2_USE_IVDEP
68 #define INTREPID2_TEST_FOR_WARNING(test, msg) \
70 printf("[Intrepid2] Warning in file %s, line %d\n",__FILE__,__LINE__); \
71 printf(" Test that evaluated to true: %s\n", #test); \
72 printf(" %s \n", msg); \
75 #define INTREPID2_TEST_FOR_EXCEPTION(test, x, msg) \
77 printf("[Intrepid2] Error in file %s, line %d\n",__FILE__,__LINE__); \
78 printf(" Test that evaluated to true: %s\n", #test); \
79 printf(" %s \n", msg); \
83 #define INTREPID2_TEST_FOR_ABORT(test, msg) \
85 printf("[Intrepid2] Error in file %s, line %d\n",__FILE__,__LINE__); \
86 printf(" Test that evaluated to true: %s\n", #test); \
87 printf(" %s \n", msg); \
88 Kokkos::abort( "[Intrepid2] Abort\n"); \
92 #ifdef INTREPID2_TEST_FOR_DEBUG_ABORT_OVERRIDE_TO_CONTINUE
93 #define INTREPID2_TEST_FOR_DEBUG_ABORT(test, info, msg) \
94 if (!(info) && (test)) { \
95 printf("[Intrepid2] Error in file %s, line %d\n",__FILE__,__LINE__); \
96 printf(" Test that evaluated to true: %s\n", #test); \
97 printf(" %s \n", msg); \
101 #define INTREPID2_TEST_FOR_DEBUG_ABORT(test, info, msg) \
102 if (!(info) && (test)) { \
103 printf("[Intrepid2] Error in file %s, line %d\n",__FILE__,__LINE__); \
104 printf(" Test that evaluated to true: %s\n", #test); \
105 printf(" %s \n", msg); \
107 Kokkos::abort( "[Intrepid2] Abort\n"); \
112 #if defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG)
113 #if defined(KOKKOS_COMPILER_CLANG)
114 #define INTREPID2_DEPRECATED_TYPENAME_REPLACEMENT(msg,fixit) __attribute__((deprecated(msg,fixit)))
115 #define INTREPID2_DEPRECATED_TYPENAME_TRAILING_ATTRIBUTE(msg)
117 #if not defined(KOKKOS_ENABLE_CUDA)
118 #define INTREPID2_DEPRECATED_TYPENAME_REPLACEMENT(msg,fixit) __attribute__ ((deprecated(msg)))
119 #define INTREPID2_DEPRECATED_TYPENAME_TRAILING_ATTRIBUTE(msg)
124 #define INTREPID2_DEPRECATED_TYPENAME_REPLACEMENT(msg,fixit)
125 #define INTREPID2_DEPRECATED_TYPENAME_TRAILING_ATTRIBUTE(msg)
130 #define INTREPID2_DEPRECATED_TYPENAME_REPLACEMENT(msg,fixit)
131 #define INTREPID2_DEPRECATED_TYPENAME_TRAILING_ATTRIBUTE(msg)
138 typedef typename T::scalar_type scalar_type;
147 typedef float scalar_type;
154 typedef double scalar_type;
161 typedef int scalar_type;
168 typedef long int scalar_type;
175 typedef long long scalar_type;
183 template<
typename ViewSpaceType,
typename UserSpaceType>
185 typedef UserSpaceType ExecSpaceType;
191 template<
typename ViewSpaceType>
193 typedef ViewSpaceType ExecSpaceType;
200 template <
typename ViewType>
202 using input_layout =
typename ViewType::array_layout;
203 using default_layout =
typename ViewType::device_type::execution_space::array_layout;
204 using result_layout =
205 typename std::conditional<
206 std::is_same< input_layout, Kokkos::LayoutStride >::value,
208 input_layout >::type;
217 template<
typename IdxType,
typename DimType,
typename IterType>
218 KOKKOS_FORCEINLINE_FUNCTION
220 unrollIndex(IdxType &i, IdxType &j,
223 const IterType iter) {
233 template<
typename IdxType,
typename DimType,
typename IterType>
234 KOKKOS_FORCEINLINE_FUNCTION
236 unrollIndex(IdxType &i, IdxType &j, IdxType &k,
240 const IterType iter) {
246 unrollIndex( i, tmp, dim0, dim1*dim2, iter);
247 unrollIndex( j, k, dim1, dim2, tmp);
256 KOKKOS_FORCEINLINE_FUNCTION
257 static T min(
const T a,
const T b) {
258 return (a < b ? a : b);
261 KOKKOS_FORCEINLINE_FUNCTION
262 static T max(
const T a,
const T b) {
263 return (a > b ? a : b);
266 KOKKOS_FORCEINLINE_FUNCTION
267 static T abs(
const T a) {
268 return (a > 0 ? a : T(-a));
274 KOKKOS_FORCEINLINE_FUNCTION
275 static T min(
const T &a,
const T &b) {
276 return (a < b ? a : b);
280 KOKKOS_FORCEINLINE_FUNCTION
281 static T max(
const T &a,
const T &b) {
282 return (a > b ? a : b);
286 KOKKOS_FORCEINLINE_FUNCTION
287 static T abs(
const T &a) {
288 return (a > 0 ? a : T(-a));
299 KOKKOS_FORCEINLINE_FUNCTION
301 std::enable_if< !std::is_pod<T>::value,
typename ScalarTraits<T>::scalar_type >::type
302 get_scalar_value(
const T& obj) {
return obj.val();}
305 KOKKOS_FORCEINLINE_FUNCTION
307 std::enable_if< std::is_pod<T>::value,
typename ScalarTraits<T>::scalar_type >::type
308 get_scalar_value(
const T& obj){
return obj;}
317 template<
typename T,
typename ...P>
318 KOKKOS_INLINE_FUNCTION
320 std::enable_if< std::is_pod<T>::value,
unsigned >::type
321 dimension_scalar(
const Kokkos::DynRankView<T, P...> ) {
return 1;}
323 template<
typename T,
typename ...P>
324 KOKKOS_INLINE_FUNCTION
326 std::enable_if< std::is_pod<T>::value,
unsigned >::type
327 dimension_scalar(
const Kokkos::View<T, P...> view) {
return 1;}
330 KOKKOS_FORCEINLINE_FUNCTION
331 static ordinal_type get_dimension_scalar(
const T view) {
332 return dimension_scalar(view);
Contains definitions of custom data types in Intrepid2.
layout deduction (temporary meta-function)