[Openmp-commits] [PATCH] D51226: [OpenMP][libomptarget] rework of fatal error reporting
Alexandre Eichenberger via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Aug 27 08:09:45 PDT 2018
AlexEichenberger updated this revision to Diff 162682.
AlexEichenberger added a comment.
- Merge branch 'unpatched-master' into unpatched-master-target-offload-envvar
- while (0) edit
Repository:
rOMP OpenMP
https://reviews.llvm.org/D51226
Files:
libomptarget/src/interface.cpp
libomptarget/src/omptarget.cpp
libomptarget/src/private.h
Index: libomptarget/src/private.h
===================================================================
--- libomptarget/src/private.h
+++ libomptarget/src/private.h
@@ -42,6 +42,23 @@
typedef enum kmp_target_offload_kind kmp_target_offload_kind_t;
extern kmp_target_offload_kind_t TargetOffloadPolicy;
+////////////////////////////////////////////////////////////////////////////////
+// implemtation for fatal messages
+////////////////////////////////////////////////////////////////////////////////
+
+#define FATAL_MESSAGE0(_num, _str) \
+ do { \
+ fprintf(stderr, "Libomptarget fatal error %d: %s\n", _num, _str); \
+ exit(1); \
+ } while (0)
+
+#define FATAL_MESSAGE(_num, _str, ...) \
+ do { \
+ fprintf(stderr, "Libomptarget fatal error %d:" _str "\n", _num, \
+ __VA_ARGS__); \
+ exit(1); \
+ } while (0)
+
// Implemented in libomp, they are called from within __tgt_* functions.
#ifdef __cplusplus
extern "C" {
@@ -54,8 +71,6 @@
}
#endif
-void FatalMessage(const int errorNum, const char *fmt, ...);
-
#ifdef OMPTARGET_DEBUG
extern int DebugLevel;
Index: libomptarget/src/omptarget.cpp
===================================================================
--- libomptarget/src/omptarget.cpp
+++ libomptarget/src/omptarget.cpp
@@ -26,23 +26,6 @@
int DebugLevel = 0;
#endif // OMPTARGET_DEBUG
-////////////////////////////////////////////////////////////////////////////////
-/// support for fatal messages
-
-// mutex
-std::mutex LibomptargetPrintMtx;
-
-void FatalMessage(const int errorNum, const char *fmt, ...) {
- va_list args;
- va_start(args, fmt);
- LibomptargetPrintMtx.lock();
- fprintf(stderr, "Libomptarget error %d:", errorNum);
- vfprintf(stderr, fmt, args);
- fprintf(stderr, "\n");
- LibomptargetPrintMtx.unlock();
- va_end(args);
- exit(1);
-}
/* All begin addresses for partially mapped structs must be 8-aligned in order
Index: libomptarget/src/interface.cpp
===================================================================
--- libomptarget/src/interface.cpp
+++ libomptarget/src/interface.cpp
@@ -55,16 +55,16 @@
switch (TargetOffloadPolicy) {
case tgt_disabled:
if (success) {
- FatalMessage(1, "expected no offloading while offloading is disabled");
+ FATAL_MESSAGE0(1, "expected no offloading while offloading is disabled");
}
break;
case tgt_default:
- DP("Should never reach this test with target offload set to default\n");
- assert(false);
+ FATAL_MESSAGE0(1, "default offloading policy must switched to "
+ "mandatory or disabled");
break;
case tgt_mandatory:
if (!success) {
- FatalMessage(1, "failure of target construct while offloading is mandatory");
+ FATAL_MESSAGE0(1, "failure of target construct while offloading is mandatory");
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51226.162682.patch
Type: text/x-patch
Size: 3215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180827/9f535510/attachment-0001.bin>
More information about the Openmp-commits
mailing list