49 #ifndef __INTREPID2_UTILS_HPP__ 50 #define __INTREPID2_UTILS_HPP__ 52 #include "Intrepid2_ConfigDefs.hpp" 55 #include "Kokkos_Core.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"); \ 116 typedef typename T::scalar_type scalar_type;
125 typedef float scalar_type;
132 typedef double scalar_type;
139 typedef int scalar_type;
146 typedef long int scalar_type;
153 typedef long long scalar_type;
161 template<
typename ViewSpaceType,
typename UserSpaceType>
163 typedef UserSpaceType ExecSpaceType;
169 template<
typename ViewSpaceType>
171 typedef ViewSpaceType ExecSpaceType;
178 template <
typename ViewType>
180 using input_layout =
typename ViewType::array_layout;
181 using default_layout =
typename ViewType::device_type::execution_space::array_layout;
182 using result_layout =
183 typename std::conditional<
184 std::is_same< input_layout, Kokkos::LayoutStride >::value,
186 input_layout >::type;
195 template<
typename IdxType,
typename DimType,
typename IterType>
196 KOKKOS_FORCEINLINE_FUNCTION
198 unrollIndex(IdxType &i, IdxType &j,
201 const IterType iter) {
211 template<
typename IdxType,
typename DimType,
typename IterType>
212 KOKKOS_FORCEINLINE_FUNCTION
214 unrollIndex(IdxType &i, IdxType &j, IdxType &k,
218 const IterType iter) {
224 unrollIndex( i, tmp, dim0, dim1*dim2, iter);
225 unrollIndex( j, k, dim1, dim2, tmp);
234 KOKKOS_FORCEINLINE_FUNCTION
235 static T min(
const T a,
const T b) {
236 return (a < b ? a : b);
239 KOKKOS_FORCEINLINE_FUNCTION
240 static T max(
const T a,
const T b) {
241 return (a > b ? a : b);
244 KOKKOS_FORCEINLINE_FUNCTION
245 static T abs(
const T a) {
246 return (a > 0 ? a : T(-a));
252 KOKKOS_FORCEINLINE_FUNCTION
253 static T min(
const T &a,
const T &b) {
254 return (a < b ? a : b);
258 KOKKOS_FORCEINLINE_FUNCTION
259 static T max(
const T &a,
const T &b) {
260 return (a > b ? a : b);
264 KOKKOS_FORCEINLINE_FUNCTION
265 static T abs(
const T &a) {
266 return (a > 0 ? a : T(-a));
277 KOKKOS_FORCEINLINE_FUNCTION
279 std::enable_if< !std::is_pod<T>::value,
typename ScalarTraits<T>::scalar_type >::type
283 KOKKOS_FORCEINLINE_FUNCTION
285 std::enable_if< std::is_pod<T>::value,
typename ScalarTraits<T>::scalar_type >::type
286 get_scalar_value(
const T& obj){
return obj;}
295 template<
typename T,
typename ...P>
296 KOKKOS_INLINE_FUNCTION
298 std::enable_if< std::is_pod<T>::value,
unsigned >::type
301 template<
typename T,
typename ...P>
302 KOKKOS_INLINE_FUNCTION
304 std::enable_if< std::is_pod<T>::value,
unsigned >::type
305 dimension_scalar(
const Kokkos::View<T, P...> view) {
return 1;}
308 KOKKOS_FORCEINLINE_FUNCTION
309 static ordinal_type get_dimension_scalar(
const T view) {
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< std::is_pod< T >::value, unsigned >::type dimension_scalar(const Kokkos::DynRankView< T, P... > view)
specialization of functions for pod types, returning the scalar dimension (1 for pod types) of a view...
Contains definitions of custom data types in Intrepid2.
KOKKOS_FORCEINLINE_FUNCTION constexpr std::enable_if< !std::is_pod< T >::value, typename ScalarTraits< T >::scalar_type >::type get_scalar_value(const T &obj)
functions returning the scalar value. for pod types, they return the input object itself...
layout deduction (temporary meta-function)