[Openmp-commits] [PATCH] D51226: [OpenMP][libomptarget] Bringing up to spec with respect to OMP_TARGET_OFFLOAD env var

Alexandre Eichenberger via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Aug 24 10:34:53 PDT 2018


AlexEichenberger created this revision.
Herald added subscribers: openmp-commits, guansong.

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,22 @@
 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)                                          \
+  {                                                                         \
+    fprintf(stderr, "Libomptarget fatal error %d: %s\n", _num, _str);       \
+    exit(1);                                                                \
+  }
+
+#define FATAL_MESSAGE(_num, _str, ...)                                      \
+  {                                                                         \
+    fprintf(stderr, "Libomptarget fatal error %d:" _str "\n", _num, __VA_ARGS__);\
+    exit(1);                                                                \
+  }
+
 // Implemented in libomp, they are called from within __tgt_* functions.
 #ifdef __cplusplus
 extern "C" {
@@ -54,8 +70,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);
       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.162414.patch
Type: text/x-patch
Size: 3072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180824/1ae500b5/attachment.bin>


More information about the Openmp-commits mailing list