Intrepid2
Intrepid2_DeviceAssert.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Intrepid2 Package
4 //
5 // Copyright 2007 NTESS and the Intrepid2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
15 #ifndef Intrepid2_DeviceAssert_h
16 #define Intrepid2_DeviceAssert_h
17 
18 #include <Kokkos_Core_fwd.hpp>
19 #include <impl/Kokkos_Error.hpp>
20 
21 #include <cstdio>
22 #include <cassert>
23 
24 namespace Intrepid2 {
25 #ifdef NDEBUG
26 #define device_assert( v ) ((void)0)
27 #else
28 
29  // assert that can reasonably be called in device code
30  KOKKOS_INLINE_FUNCTION
31  void device_assert(bool val) {
32  if (!val)
34 #if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
35  Kokkos::abort("ASSERT IN CUDA CALL, SHOULD ABORT\n");
36 #else
37  assert(false);
38 #endif
39  }
40 #endif
41 
42 }
43 
44 
45 #endif /* Interpid2_DeviceAssert_h */