# include <cusparse.h>
#endif
+#include <Kokkos_Core.hpp>
DEAL_II_NAMESPACE_OPEN
* @ingroup Exceptions
*/
#ifdef DEBUG
-# ifdef DEAL_II_HAVE_BUILTIN_EXPECT
-# define Assert(cond, exc) \
- { \
- if (__builtin_expect(!(cond), false)) \
- ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
- ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
- abort_or_throw_on_exception, \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #cond, \
- #exc, \
- exc); \
- }
-# else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
-# define Assert(cond, exc) \
- { \
- if (!(cond)) \
- ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
- ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
- abort_or_throw_on_exception, \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #cond, \
- #exc, \
- exc); \
- }
-# endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
-#else
+# ifdef KOKKOS_VERSION >= 30600
+# ifdef DEAL_II_HAVE_BUILTIN_EXPECT
+# define Assert(cond, exc) \
+ { \
+ KOKKOS_IF_ON_HOST(({ \
+ if (__builtin_expect(!(cond), false)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
+ })) \
+ KOKKOS_IF_ON_DEVICE(({ \
+ if (!(cond)) \
+ Kokkos::abort(#cond); \
+ })) \
+ }
+# else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
+# define Assert(cond, exc) \
+ { \
+ KOKKOS_IF_ON_HOST(({ \
+ if (!(cond)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
+ })) \
+ KOKKOS_IF_ON_DEVICE(({ \
+ if (!(cond)) \
+ Kokkos::abort(#cond); \
+ })) \
+ }
+# endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
+# else /*ifdef KOKKOS_VERSION >= 30600*/
+# ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
+# ifdef DEAL_II_HAVE_BUILTIN_EXPECT
+# define Assert(cond, exc) \
+ { \
+ if (__builtin_expect(!(cond), false)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
+ }
+# else /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
+# define Assert(cond, exc) \
+ { \
+ if (!(cond)) \
+ ::dealii::deal_II_exceptions::internals::issue_error_noreturn( \
+ ::dealii::deal_II_exceptions::internals::ExceptionHandling:: \
+ abort_or_throw_on_exception, \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ #cond, \
+ #exc, \
+ exc); \
+ }
+# endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
+# else /*#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
+# define Assert(cond, exc) \
+ { \
+ if (!(cond)) \
+ Kokkos::abort(#cond); \
+ }
+# endif /*ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
+# endif /*KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
+#else /*ifdef DEBUG*/
# define Assert(cond, exc) \
{}
-#endif
+#endif /*ifdef DEBUG*/
inline DEAL_II_HOST_DEVICE
Point<dim, Number>::Point(const Number x)
{
-# ifndef __CUDA_ARCH__
Assert(dim == 1,
ExcMessage(
"You can only initialize Point<1> objects using the constructor "
"that takes only one argument. Point<dim> objects with dim!=1 "
"require initialization with the constructor that takes 'dim' "
"arguments."));
-# endif
// we can only get here if we pass the assertion. use the switch anyway so
// as to avoid compiler warnings about uninitialized elements or writing
inline DEAL_II_HOST_DEVICE
Point<dim, Number>::Point(const Number x, const Number y)
{
-# ifndef __CUDA_ARCH__
Assert(dim == 2,
ExcMessage(
"You can only initialize Point<2> objects using the constructor "
"that takes two arguments. Point<dim> objects with dim!=2 "
"require initialization with the constructor that takes 'dim' "
"arguments."));
-# endif
// we can only get here if we pass the assertion. use the indirection anyway
// so as to avoid compiler warnings about uninitialized elements or writing
inline DEAL_II_HOST_DEVICE
Point<dim, Number>::Point(const Number x, const Number y, const Number z)
{
-# ifndef __CUDA_ARCH__
Assert(dim == 3,
ExcMessage(
"You can only initialize Point<3> objects using the constructor "
"that takes three arguments. Point<dim> objects with dim!=3 "
"require initialization with the constructor that takes 'dim' "
"arguments."));
-# endif
// we can only get here if we pass the assertion. use the indirection anyway
// so as to avoid compiler warnings about uninitialized elements or writing
inline DEAL_II_HOST_DEVICE Number
Point<dim, Number>::operator()(const unsigned int index) const
{
-# ifndef __CUDA_ARCH__
AssertIndexRange(static_cast<int>(index), dim);
-# endif
return this->values[index];
}
inline DEAL_II_HOST_DEVICE Number &
Point<dim, Number>::operator()(const unsigned int index)
{
-# ifndef __CUDA_ARCH__
AssertIndexRange(static_cast<int>(index), dim);
-# endif
return this->values[index];
}
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE
Tensor<0, dim, Number>::operator Number &()
{
- // We cannot use Assert inside a CUDA kernel
-# ifndef __CUDA_ARCH__
Assert(dim != 0,
ExcMessage("Cannot access an object of type Tensor<0,0,Number>"));
-# endif
return value;
}
constexpr inline DEAL_II_ALWAYS_INLINE
DEAL_II_HOST_DEVICE Tensor<0, dim, Number>::operator const Number &() const
{
- // We cannot use Assert inside a CUDA kernel
-# ifndef __CUDA_ARCH__
Assert(dim != 0,
ExcMessage("Cannot access an object of type Tensor<0,0,Number>"));
-# endif
return value;
}
val *= s;
}
-# ifdef __CUDA_ARCH__
template <typename Number, typename OtherNumber>
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE void
- multiply_assign_scalar(std::complex<Number> &, const OtherNumber &)
+ multiply_assign_scalar(std::complex<Number> &val, const OtherNumber &s)
{
- printf("This function is not implemented for std::complex<Number>!\n");
- assert(false);
- }
+# ifdef KOKKOS_VERSION >= 30600
+ KOKKOS_IF_ON_HOST((val *= s;))
+ KOKKOS_IF_ON_DEVICE(({
+ (void)val;
+ (void)s;
+ Kokkos::abort(
+ "This function is not implemented for std::complex<Number>!\n");
+ }))
+# else
+# ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
+ val *= s;
+# else
+ (void)val;
+ (void)s;
+ Kokkos::abort(
+ "This function is not implemented for std::complex<Number>!\n");
+# endif
# endif
+ }
} // namespace ComplexWorkaround
} // namespace internal
typename Tensor<0, dim, Number>::real_type
Tensor<0, dim, Number>::norm_square() const
{
- // We cannot use Assert inside a CUDA kernel
-# ifndef __CUDA_ARCH__
Assert(dim != 0,
ExcMessage("Cannot access an object of type Tensor<0,0,Number>"));
-# endif
return numbers::NumberTraits<Number>::abs_square(value);
}
Tensor<rank_, dim, Number>::Tensor(
const ArrayView<ElementType, MemorySpace> &initializer)
{
- // We cannot use Assert in a CUDA kernel
-# ifndef __CUDA_ARCH__
AssertDimension(initializer.size(), n_independent_components);
-# endif
for (unsigned int i = 0; i < n_independent_components; ++i)
(*this)[unrolled_to_component_indices(i)] = initializer[i];
const unsigned int i,
std::integral_constant<int, dim>)
{
- // We cannot use Assert in a CUDA kernel
-# ifndef __CUDA_ARCH__
AssertIndexRange(i, dim);
-# endif
return values[i];
}
const unsigned int,
std::integral_constant<int, 0>)
{
- // We cannot use Assert in a CUDA kernel
-# ifndef __CUDA_ARCH__
Assert(
false,
ExcMessage(
"Cannot access elements of an object of type Tensor<rank,0,Number>."));
-# endif
return *dummy;
}
} // namespace TensorSubscriptor