Kokkos Core Kernels Package
Version of the Day
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
core
src
Kokkos_Assert.hpp
1
//@HEADER
2
// ************************************************************************
3
//
4
// Kokkos v. 4.0
5
// Copyright (2022) National Technology & Engineering
6
// Solutions of Sandia, LLC (NTESS).
7
//
8
// Under the terms of Contract DE-NA0003525 with NTESS,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12
// See https://kokkos.org/LICENSE for license information.
13
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14
//
15
//@HEADER
16
17
#ifndef KOKKOS_ASSERT_HPP
18
#define KOKKOS_ASSERT_HPP
19
20
#include <Kokkos_Macros.hpp>
21
#include <Kokkos_Abort.hpp>
22
23
#if !defined(NDEBUG) || defined(KOKKOS_ENFORCE_CONTRACTS) || \
24
defined(KOKKOS_ENABLE_DEBUG)
25
#define KOKKOS_EXPECTS(...) \
26
{ \
27
if (!bool(__VA_ARGS__)) { \
28
::Kokkos::abort( \
29
"Kokkos contract violation:\n " \
30
" Expected precondition `" #__VA_ARGS__ \
31
"` evaluated false.\n" \
32
"Error at " KOKKOS_IMPL_TOSTRING(__FILE__) ":" KOKKOS_IMPL_TOSTRING( \
33
__LINE__) " \n"); \
34
} \
35
}
36
#define KOKKOS_ENSURES(...) \
37
{ \
38
if (!bool(__VA_ARGS__)) { \
39
::Kokkos::abort( \
40
"Kokkos contract violation:\n " \
41
" Ensured postcondition `" #__VA_ARGS__ \
42
"` evaluated false.\n" \
43
"Error at " KOKKOS_IMPL_TOSTRING(__FILE__) ":" KOKKOS_IMPL_TOSTRING( \
44
__LINE__) " \n"); \
45
} \
46
}
47
#define KOKKOS_ASSERT(...) \
48
{ \
49
if (!bool(__VA_ARGS__)) { \
50
::Kokkos::abort( \
51
"Kokkos contract violation:\n " \
52
" Asserted condition `" #__VA_ARGS__ \
53
"` evaluated false.\n" \
54
"Error at " KOKKOS_IMPL_TOSTRING(__FILE__) ":" KOKKOS_IMPL_TOSTRING( \
55
__LINE__) " \n"); \
56
} \
57
}
58
#else // not debug mode
59
#define KOKKOS_EXPECTS(...)
60
#define KOKKOS_ENSURES(...)
61
#ifndef KOKKOS_ASSERT
62
#define KOKKOS_ASSERT(...)
63
#endif // ifndef KOKKOS_ASSERT
64
#endif // end debug mode ifdefs
65
66
#endif
/* #ifndef KOKKOS_ASSERT_HPP */
Generated on Thu Dec 26 2024 09:19:27 for Kokkos Core Kernels Package by
1.8.5