19#include <hip/hip_runtime.h>
41#ifdef MFEM_USE_EXCEPTIONS
51 virtual const char*
what()
const throw();
73#ifndef _MFEM_FUNC_NAME
76#define _MFEM_FUNC_NAME __PRETTY_FUNCTION__
81#define _MFEM_FUNC_NAME __FUNCSIG__
85#define MFEM_LOCATION \
86 "\n ... in function: " << _MFEM_FUNC_NAME << \
87 "\n ... in file: " << __FILE__ << ':' << __LINE__ << '\n'
90#define _MFEM_MESSAGE(msg, fn) \
92 std::ostringstream mfemMsgStream; \
93 mfemMsgStream << std::setprecision(16); \
94 mfemMsgStream << std::setiosflags(std::ios_base::scientific); \
95 mfemMsgStream << msg << MFEM_LOCATION; \
96 mfem::fn(mfemMsgStream.str().c_str()); \
104#define MFEM_ABORT(msg) _MFEM_MESSAGE("MFEM abort: " << msg, mfem_error)
107#define MFEM_VERIFY(x, msg) \
110 _MFEM_MESSAGE("Verification failed: (" \
111 << #x << ") is false:\n --> " << msg, mfem_error); \
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, mfem_error); \
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, mfem_warning)
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)
157#ifndef __HIP_DEVICE_COMPILE__
173#if defined(__CUDA_ARCH__)
174#define MFEM_ABORT_KERNEL(...) \
176 printf(__VA_ARGS__); \
179#elif defined(MFEM_USE_HIP)
180#define MFEM_ABORT_KERNEL(...) \
182 printf(__VA_ARGS__); \
186#define MFEM_ABORT_KERNEL(...) \
188 printf(__VA_ARGS__); \
194#define MFEM_VERIFY_KERNEL(x,...) \
197 MFEM_ABORT_KERNEL(__VA_ARGS__) \
202#define MFEM_ASSERT_KERNEL(x,...) \
205 MFEM_ABORT_KERNEL(__VA_ARGS__) \
208#define MFEM_ASSERT_KERNEL(x,...)
Exception class thrown when MFEM encounters an error and the current ErrorAction is set to MFEM_ERROR...
virtual const char * what() const
virtual ~ErrorException()
ErrorException(const std::string &in_msg)
__host__ void abort_msg(T &msg)
void mfem_error(const char *msg)
void mfem_warning(const char *msg)
void mfem_backtrace(int mode, int depth)
void set_error_action(ErrorAction action)
Set the action MFEM takes when an error is encountered.
__attribute__((enzyme_inactive, noreturn)) void mfem_error(const char *msg
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT,...
ErrorAction
Action to take when MFEM encounters an error.
ErrorAction get_error_action()
Get the action MFEM takes when an error is encountered.