|
5 | 5 |
|
6 | 6 | #include <AMReX.H> |
7 | 7 |
|
| 8 | +/** |
| 9 | + * \file AMReX_BLassert.H |
| 10 | + * \brief Assertion macros used across AMReX for runtime consistency checks. |
| 11 | + * |
| 12 | + * In debug builds (or when `AMREX_USE_ASSERTION` is defined) the macros expand |
| 13 | + * to runtime checks that call `amrex::Assert` if they fail. In release builds |
| 14 | + * without assertion support, the non-\*_ALWAYS variants become no-ops. |
| 15 | + * |
| 16 | + * - `AMREX_ASSERT(expr)` evaluates \p expr and aborts on failure, emitting the |
| 17 | + * expression, file, and line number. |
| 18 | + * - `AMREX_ASSERT_WITH_MESSAGE(expr,msg)` behaves the same but also forwards |
| 19 | + * the user-provided \p msg to `amrex::Assert`, allowing custom diagnostics. |
| 20 | + * - The `_ALWAYS_` variants (`AMREX_ALWAYS_ASSERT`, etc.) remain active even in |
| 21 | + * non-debug builds. |
| 22 | + * - `AMREX_GPU_ASSERT` provides the same semantics inside GPU code paths when |
| 23 | + * `AMREX_USE_GPU` is defined and either `AMREX_DEBUG` or `AMREX_USE_ASSERTION` |
| 24 | + * is enabled; otherwise it is a no-op. |
| 25 | + */ |
| 26 | + |
8 | 27 | #ifdef AMREX_ASSERT |
9 | 28 | #undef AMREX_ASSERT |
10 | 29 | #endif |
|
15 | 34 |
|
16 | 35 | #if !defined(AMREX_DEBUG) && !defined(AMREX_USE_ASSERTION) |
17 | 36 |
|
18 | | -/* |
19 | | - The macro AMREX_ASSERT(EX) is a debugging macro, used to test the |
20 | | - internal consistency of AMReX, that may also be useful in user |
21 | | - code. The argument EX is a C++ expression that you expect to |
22 | | - always evaluate to true. |
23 | | -
|
24 | | - When code is compiled with the DEBUG macro set to TRUE, the |
25 | | - AMREX_ASSERT(EX) macro expands to a boolean test of the expression EX. |
26 | | - If that expression evaluates to true, nothing happens, but if the |
27 | | - expression evaluates to false, a message is output detailing the |
28 | | - file and line number of the AMREX_ASSERT(EX) statement, as well as the |
29 | | - literal expression EX itself, and then exits via abort() using |
30 | | - amrex::Assert(). The idea is that if the assertion fails, something |
31 | | - has gone terribly wrong somewhere. |
32 | | -
|
33 | | - If the DEBUG macro is not set to TRUE, the AMREX_ASSERT(EX) call becomes |
34 | | - a null statement in the code, which will be eliminated by the code |
35 | | - optimizer. |
36 | | -*/ |
37 | 37 | #define AMREX_ASSERT_WITH_MESSAGE(EX,MSG) ((void)0) |
38 | 38 | #define AMREX_ASSERT(EX) ((void)0) |
39 | 39 | #define BL_ASSERT(EX) ((void)0) |
|
56 | 56 | #define AMREX_GPU_ASSERT(EX) (EX)?((void)0):amrex::Assert( # EX , __FILE__, __LINE__) |
57 | 57 | #endif |
58 | 58 |
|
59 | | -#endif /*BL_BL_ASSERT_H*/ |
| 59 | +#endif /* AMREX_BLASSERT_H_ */ |
0 commit comments