12 #ifndef MFEM_ERROR_HPP 13 #define MFEM_ERROR_HPP 15 #include "../config/config.hpp" 19 #include <hip/hip_runtime.h> 41 #ifdef MFEM_USE_EXCEPTIONS 51 virtual const char*
what()
const throw();
64 #ifdef MFEM_USE_ENZYME 65 static void* __enzyme_inactive_global_err = (
void*)
mfem_error;
66 static void* __enzyme_inactive_global_warn = (
void*)
mfem_warning;
70 #ifndef _MFEM_FUNC_NAME 73 #define _MFEM_FUNC_NAME __PRETTY_FUNCTION__ 78 #define _MFEM_FUNC_NAME __FUNCSIG__ 82 #define MFEM_LOCATION \ 83 "\n ... in function: " << _MFEM_FUNC_NAME << \ 84 "\n ... in file: " << __FILE__ << ':' << __LINE__ << '\n' 87 #define _MFEM_MESSAGE(msg, warn) \ 89 std::ostringstream mfemMsgStream; \ 90 mfemMsgStream << std::setprecision(16); \ 91 mfemMsgStream << std::setiosflags(std::ios_base::scientific); \ 92 mfemMsgStream << msg << MFEM_LOCATION; \ 94 mfem::mfem_error(mfemMsgStream.str().c_str()); \ 96 mfem::mfem_warning(mfemMsgStream.str().c_str()); \ 104 #define MFEM_ABORT(msg) _MFEM_MESSAGE("MFEM abort: " << msg, 0) 107 #define MFEM_VERIFY(x, msg) \ 110 _MFEM_MESSAGE("Verification failed: (" \ 111 << #x << ") is false:\n --> " << msg, 0); \ 120 #define MFEM_CONTRACT_VAR(x) (void)(x) 125 #define MFEM_ASSERT(x, msg) \ 128 _MFEM_MESSAGE("Assertion failed: (" \ 129 << #x << ") is false:\n --> " << msg, 0); \ 133 #define MFEM_DEBUG_DO(x) x 138 #define MFEM_ASSERT(x, msg) 141 #define MFEM_DEBUG_DO(x) 146 #define MFEM_WARNING(msg) _MFEM_MESSAGE("MFEM Warning: " << msg, 1) 149 #define MFEM_ASSERT_INDEX_IN_RANGE(i,imin,imax) \ 150 MFEM_ASSERT((imin) <= (i) && (i) < (imax), \ 151 "invalid index " #i << " = " << (i) << \ 152 ", valid range is [" << (imin) << ',' << (imax) << ')') 156 #if defined(MFEM_USE_HIP) 171 #if defined(__CUDA_ARCH__) 172 #define MFEM_ABORT_KERNEL(...) \ 174 printf(__VA_ARGS__); \ 177 #elif defined(MFEM_USE_HIP) 178 #define MFEM_ABORT_KERNEL(...) \ 180 printf(__VA_ARGS__); \ 184 #define MFEM_ABORT_KERNEL(...) \ 186 printf(__VA_ARGS__); \ 192 #define MFEM_VERIFY_KERNEL(x,...) \ 195 MFEM_ABORT_KERNEL(__VA_ARGS__) \ 200 #define MFEM_ASSERT_KERNEL(x,...) \ 203 MFEM_ABORT_KERNEL(__VA_ARGS__) \ 206 #define MFEM_ASSERT_KERNEL(x,...) virtual const char * what() const
ErrorAction get_error_action()
Get the action MFEM takes when an error is encountered.
Exception class thrown when MFEM encounters an error and the current ErrorAction is set to MFEM_ERROR...
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
virtual ~ErrorException()
void set_error_action(ErrorAction action)
Set the action MFEM takes when an error is encountered.
ErrorAction
Action to take when MFEM encounters an error.
ErrorException(const std::string &in_msg)
__host__ void abort_msg(T &msg)
void mfem_warning(const char *msg)
Function called by the macro MFEM_WARNING.
void mfem_backtrace(int mode, int depth)