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();
66 #ifndef _MFEM_FUNC_NAME
69 #define _MFEM_FUNC_NAME __PRETTY_FUNCTION__
74 #define _MFEM_FUNC_NAME __FUNCSIG__
78 #define MFEM_LOCATION \
79 "\n ... in function: " << _MFEM_FUNC_NAME << \
80 "\n ... in file: " << __FILE__ << ':' << __LINE__ << '\n'
83 #define _MFEM_MESSAGE(msg, warn) \
85 std::ostringstream mfemMsgStream; \
86 mfemMsgStream << std::setprecision(16); \
87 mfemMsgStream << std::setiosflags(std::ios_base::scientific); \
88 mfemMsgStream << msg << MFEM_LOCATION; \
90 mfem::mfem_error(mfemMsgStream.str().c_str()); \
92 mfem::mfem_warning(mfemMsgStream.str().c_str()); \
100 #define MFEM_ABORT(msg) _MFEM_MESSAGE("MFEM abort: " << msg, 0)
103 #define MFEM_VERIFY(x, msg) \
106 _MFEM_MESSAGE("Verification failed: (" \
107 << #x << ") is false:\n --> " << msg, 0); \
116 #define MFEM_CONTRACT_VAR(x) if (false && (&x)+1){}
121 #define MFEM_ASSERT(x, msg) \
124 _MFEM_MESSAGE("Assertion failed: (" \
125 << #x << ") is false:\n --> " << msg, 0); \
129 #define MFEM_DEBUG_DO(x) x
134 #define MFEM_ASSERT(x, msg)
137 #define MFEM_DEBUG_DO(x)
142 #define MFEM_WARNING(msg) _MFEM_MESSAGE("MFEM Warning: " << msg, 1)
145 #define MFEM_ASSERT_INDEX_IN_RANGE(i,imin,imax) \
146 MFEM_ASSERT((imin) <= (i) && (i) < (imax), \
147 "invalid index " #i << " = " << (i) << \
148 ", valid range is [" << (imin) << ',' << (imax) << ')')
152 #if defined(MFEM_USE_HIP)
167 #if defined(__CUDA_ARCH__)
168 #define MFEM_ABORT_KERNEL(msg) \
173 #elif defined(MFEM_USE_HIP)
174 #define MFEM_ABORT_KERNEL(msg) \
179 #define MFEM_ABORT_KERNEL(msg) MFEM_ABORT(msg)
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)