|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
Assertion / error-handling macros and supporting helper functions. More...
Go to the source code of this file.
Namespaces | |
| namespace | DNDS |
| the host side operators are provided as implemented | |
Macros | |
| #define | DNDS_check_throw(expr) |
Runtime check active in both debug and release builds. Throws std::runtime_error if expr evaluates to false. Prefer this over DNDS_assert for user-input and API-contract checks. | |
| #define | DNDS_check_throw_info(expr, info) |
Same as DNDS_check_throw but attaches a user-supplied info message to the thrown std::runtime_error. | |
| #define | DNDS_assert(expr) |
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + backtrace, then calls std::abort(). | |
| #define | DNDS_assert_info(expr, info) |
Debug-only assertion with an extra std::string info message. | |
| #define | DNDS_assert_infof(expr, info, ...) |
| Debug-only assertion with a printf-style format message. | |
| #define | DNDS_HD_assert(cond) DNDS_assert(cond) |
| Host-only expansion of DNDS_HD_assert (equivalent to DNDS_assert). | |
| #define | DNDS_HD_assert_infof(cond, info, ...) DNDS_assert_infof(cond, info, ##__VA_ARGS__) |
| Host-only expansion of DNDS_HD_assert_infof. | |
| #define | DNDS_DEVICE_CODE_GUARD_EIGEN_MALLOC (void(0)) |
Functions | |
| std::string | DNDS::getTraceString () |
| Return a symbolicated stack trace for the calling thread. | |
| void | DNDS::assert_false (const char *expr, const char *file, int line) |
| Low-level: print a red "DNDS_assertion failed" line and abort. | |
| void | DNDS::assert_false_info (const char *expr, const char *file, int line, const std::string &info) |
Variant of assert_false that prints an extra info string. | |
| void | DNDS::assert_false_infof (const char *expr, const char *file, int line, const char *info,...) |
printf-style variant of assert_false. Used by DNDS_assert_infof. | |
| template<class TException = std::runtime_error> | |
| void | DNDS::assert_false_info_throw (const char *expr, const char *file, int line, const std::string &info) |
| Throwing variant of assert_false_info. Used by DNDS_check_throw. | |
Assertion / error-handling macros and supporting helper functions.
Three distinct families of checks are provided; choose based on how the failure should surface:
| Macro | Release behaviour | Failure mode |
|---|---|---|
| DNDS_assert | Compiled out (NDEBUG) | std::abort() |
| DNDS_assert_info | Compiled out (NDEBUG) | std::abort() + message |
| DNDS_assert_infof | Compiled out (NDEBUG) | std::abort() + fmtprintf |
| DNDS_check_throw | Always active | throw std::runtime_error |
| DNDS_check_throw_info | Always active | throw + message |
| DNDS_HD_assert | Compiled out in NDEBUG | host: abort, device: trap |
Prefer DNDS_assert for internal invariants that are expensive to check or cannot fail in correct code; use DNDS_check_throw for user-input / runtime validation that must remain active in release builds.
The device variants (DNDS_HD_*) expand to host asserts on the host and to atomic-guarded PTX trap on CUDA devices so only one thread prints.
Definition in file Errors.hpp.
| #define DNDS_assert | ( | expr | ) |
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + backtrace, then calls std::abort().
Definition at line 108 of file Errors.hpp.
| #define DNDS_assert_info | ( | expr, | |
| info | |||
| ) |
Debug-only assertion with an extra std::string info message.
Definition at line 113 of file Errors.hpp.
| #define DNDS_assert_infof | ( | expr, | |
| info, | |||
| ... | |||
| ) |
Debug-only assertion with a printf-style format message.
Definition at line 118 of file Errors.hpp.
| #define DNDS_check_throw | ( | expr | ) |
Runtime check active in both debug and release builds. Throws std::runtime_error if expr evaluates to false. Prefer this over DNDS_assert for user-input and API-contract checks.
Definition at line 89 of file Errors.hpp.
| #define DNDS_check_throw_info | ( | expr, | |
| info | |||
| ) |
Same as DNDS_check_throw but attaches a user-supplied info message to the thrown std::runtime_error.
Definition at line 96 of file Errors.hpp.
| #define DNDS_DEVICE_CODE_GUARD_EIGEN_MALLOC (void(0)) |
Definition at line 207 of file Errors.hpp.
| #define DNDS_HD_assert | ( | cond | ) | DNDS_assert(cond) |
Host-only expansion of DNDS_HD_assert (equivalent to DNDS_assert).
Definition at line 189 of file Errors.hpp.
| #define DNDS_HD_assert_infof | ( | cond, | |
| info, | |||
| ... | |||
| ) | DNDS_assert_infof(cond, info, ##__VA_ARGS__) |
Host-only expansion of DNDS_HD_assert_infof.
Definition at line 191 of file Errors.hpp.